unwrapAuthHeaderValue function
Returns the auth key from an auth value that has potentially been wrapped. This operation is the inverse of wrapAsBasicAuthHeaderValue. If null is provided, null is returned.
Implementation
String? unwrapAuthHeaderValue(String? authValue) {
if (authValue == null) return null;
if (isWrappedBasicAuthHeaderValue(authValue)) {
// auth value was wrapped, unbake
var parts = authValue.split(' ');
return utf8.decode(base64.decode(parts[1]));
} else {
// auth value was not wrapped, return as is
return authValue;
}
}