Class: UnknownAuthScheme
@divine/uri.UnknownAuthScheme
The AuthScheme class used when an authentication scheme is unsupported. All of its methods just throw AuthSchemeError
or return false.
Hierarchy
- ↳ - UnknownAuthScheme
Constructors
constructor
• new UnknownAuthScheme(scheme?)
Parameters
| Name | Type | Default value | 
|---|---|---|
| scheme | string | 'unknown' | 
Overrides
Defined in
Properties
proxy
• proxy: boolean
Specifies wheter or not this scheme provides proxy auhentication. Usually false.
Inherited from
Defined in
realm
• Optional realm: string
The realm or domain this instance is handling.
Inherited from
Defined in
scheme
• scheme: string
The canonical name of the scheme this instance handles.
Inherited from
Defined in
Methods
_assertCompatibleAuthHeader
▸ Protected _assertCompatibleAuthHeader<H>(header): H
Asserts that an authentication header is compatible with this AuthScheme.
Throws
AuthSchemeError If the header is incompatible with this AuthScheme.
Type parameters
| Name | Type | 
|---|---|
| H | extends undefined|AuthHeader | 
Parameters
| Name | Type | Description | 
|---|---|---|
| header | H | The header to check, or undefinedto do nothing. | 
Returns
H
The provided header.
Inherited from
AuthScheme._assertCompatibleAuthHeader
Defined in
_assertCompatibleCredentials
▸ Protected _assertCompatibleCredentials<C>(credentials): C
Asserts that some credentials are compatible with this AuthScheme.
Throws
AuthSchemeError If the credentials are incompatible with this AuthScheme.
Type parameters
| Name | Type | Description | 
|---|---|---|
| C | extends undefined|Credentials | The type of credentials that the scheme uses. | 
Parameters
| Name | Type | Description | 
|---|---|---|
| credentials | C | The credentials to check, or undefinedto do nothing. | 
Returns
C
The provided credentials.
Inherited from
AuthScheme._assertCompatibleCredentials
Defined in
_createChallenge
▸ Protected _createChallenge(authorization?): Promise<WWWAuthenticate>
Creates a new challenge for the client.
Parameters
| Name | Type | Description | 
|---|---|---|
| authorization? | Authorization | The authentication the client provided. | 
Returns
Promise<WWWAuthenticate>
A new challenge.
Inherited from
Defined in
_getCredentials
▸ Protected _getCredentials(options): Promise<undefined | Credentials>
Asks the credentials provider for credentials.
Throws
AuthSchemeError If the authentication, challenge or the credentials provided via setCredentialsProvider are incompatibe with this AuthScheme.
Parameters
| Name | Type | Description | 
|---|---|---|
| options | CredentialsProviderOptions<Credentials> | Options to pass to the credentials provider. | 
Returns
Promise<undefined | Credentials>
Valid credentials or undefined if no credentials could be provided.
Inherited from
Defined in
_isCompatibleCredentials
▸ _isCompatibleCredentials(_credentials): boolean
Checks if the provided credentials are compatible with this AuthScheme.
Throws
AuthSchemeError If the credentials provided are incompatibe with this AuthScheme.
Parameters
| Name | Type | Description | 
|---|---|---|
| _credentials | Credentials | The credentials to check for compatibility. | 
Returns
boolean
true if the provided credentials are usable by this AuthScheme.
Overrides
AuthScheme._isCompatibleCredentials
Defined in
createAuthorization
▸ createAuthorization(_challenge?, _request?, _payload?): Promise<undefined | Authorization>
Generates an Authorization header for an outgoing request.
Throws
AuthSchemeError If the challenge or the credentials provided via setCredentialsProvider are incompatibe with this AuthScheme.
Parameters
| Name | Type | Description | 
|---|---|---|
| _challenge? | WWWAuthenticate | An optional challenge sent by the remote server. | 
| _request? | AuthSchemeRequest | The request that is to be authenticated. | 
| _payload? | Uint8Array | The request payload that will be sent. | 
Returns
Promise<undefined | Authorization>
An Authorization header with the provided credentials.
Overrides
AuthScheme.createAuthorization
Defined in
setCredentialsProvider
▸ setCredentialsProvider(cp?): UnknownAuthScheme
Attaches a CredentialsProvider for retrieving or verifying credentials.
Parameters
| Name | Type | Description | 
|---|---|---|
| cp? | Credentials|CredentialsProvider<Credentials> | The CredentialsProvider to register. | 
Returns
This AuthScheme.
Inherited from
AuthScheme.setCredentialsProvider
Defined in
setProxyMode
▸ setProxyMode(proxy): UnknownAuthScheme
Sets the proxy mode.
Parameters
| Name | Type | Description | 
|---|---|---|
| proxy | boolean | trueif proxy mode, elsefalse. | 
Returns
This AuthScheme.
Inherited from
Defined in
setRealm
▸ setRealm(realm): UnknownAuthScheme
Sets the realm/domain.
Parameters
| Name | Type | Description | 
|---|---|---|
| realm | string | The realm this instance handles. | 
Returns
This AuthScheme.
Inherited from
Defined in
verifyAuthenticationInfo
▸ verifyAuthenticationInfo<T>(_authentication, _request?, _payload?): Promise<T>
Verifies an AuthenticationInfo or ServerAuthorization header received from a server response.
Not all protocols supports verification of responses. In that case, this method does nothing.
Throws
AuthSchemeError If the authentication or the credentials provided via setCredentialsProvider are incompatibe with this AuthScheme.
Type parameters
| Name | Type | Description | 
|---|---|---|
| T | extends undefined|AuthenticationInfo|ServerAuthorization | The type of the header to validate. | 
Parameters
| Name | Type | Description | 
|---|---|---|
| _authentication | T | The authentication provided by the remote server. | 
| _request? | AuthSchemeRequest | The response to a request that is to be authenticated. | 
| _payload? | Uint8Array | The response payload received from the remote server. | 
Returns
Promise<T>
The validated AuthenticationInfo/ServerAuthorization header.
Overrides
AuthScheme.verifyAuthenticationInfo
Defined in
verifyAuthorization
▸ verifyAuthorization<T>(_authorization, _request?, _payload?): Promise<T>
Verifies an Authorization header from an incoming request.
Throws
AuthSchemeError If the authentication or the credentials provided via setCredentialsProvider are incompatibe with this AuthScheme.
Type parameters
| Name | Type | Description | 
|---|---|---|
| T | extends undefined|Authorization | The type of the header to validate. | 
Parameters
| Name | Type | Description | 
|---|---|---|
| _authorization | T | The authentication provided by the remote client. | 
| _request? | AuthSchemeRequest | The request that is to be authenticated. | 
| _payload? | Uint8Array | The request payload that was sent. | 
Returns
Promise<T>
The validated Authorization header.
Overrides
AuthScheme.verifyAuthorization
Defined in
create
▸ Static create(from, proxy?): AuthScheme<Credentials>
Creates an authentication scheme class from an authentication header or authentication name.
If the authentication scheme is unknown, an instance of UnknownAuthScheme will be returned.
Parameters
| Name | Type | Description | 
|---|---|---|
| from | string|RegExp|AuthHeader | The type of authentication scheme to create. | 
| proxy? | boolean | Set to trueto force proxy mode. Defaults to AuthHeader.isProxyHeader orfalse. | 
Returns
An AuthScheme instance that provides authentication for the requested scheme.
Inherited from
Defined in
register
▸ Static register<C>(scheme, authScheme): typeof AuthScheme
Registers a new authentication scheme. All subclasses must register their authentication type support with this method.
Type parameters
| Name | Type | Description | 
|---|---|---|
| C | extends Credentials | The type of credentials this authentication scheme uses. | 
Parameters
| Name | Type | Description | 
|---|---|---|
| scheme | string | The name of the authentication scheme to be registered. | 
| authScheme | Constructor<AuthScheme<C>> | The AuthScheme subclass to register. | 
Returns
typeof AuthScheme
The AuthScheme base class (for method chaining).
Inherited from
Defined in
safeCompare
▸ Static safeCompare(untrusted, trusted): boolean
Utility method to compare two secrets in a time-constant manner.
Parameters
| Name | Type | Description | 
|---|---|---|
| untrusted | string|number[] | The untrusted secret that should be verified. | 
| trusted | string|number[] | The trusted secret that the untrusted secret should be compared against. | 
Returns
boolean
true if the secrets are equal, else false.