/** * An access token. */ interface Token { /** * The token value. */ readonly value: string; /** * The expires date. It may be unknown, that's why it is optional. */ readonly expires?: Date; } /** * Describes how a token should be transported. */ type TokenTransport = BearerTokenTransport | ParameterTokenTransport; /** * Token should be transported as HTTP Header: '':'Bearer ' */ interface BearerTokenTransport { /** * Mode identifier. */ mode: "BEARER_HEADER"; /** * The default header name is 'Authorization' */ headerName: string; } /** * Token should be transported as HTTP Query Parameter 'url?=' */ interface ParameterTokenTransport { /** * Mode identifier. */ mode: "PARAMETER"; /** Name of the parameter to use. */ parameterName: string; } /** * Result of a token lookup. * A client should respect the TokenTransport information. */ interface TokenLookupResult { /** * The token. */ readonly token: Token; /** * The transport to use. */ readonly transportAs: TokenTransport; } /** * Options object, which transports an abort signal. */ interface AbortOptions { signal?: AbortSignal; } /** * A token services is responsible to manage tokens in the client. */ interface TokenService { /** * Finds already available token information for a given url. * This function uses already stored information to lookup the token. * Token information is only available if 'findTokenFor' method was invoked. * * @param target url for which a token should be looked up. */ findDirectAvailableTokenFor(target: string | URL): TokenLookupResult | undefined; /** * Finds a token for a given url. * The client should respect the transport metadata information. * A token lookup result may be undefined, which means that no token is found. * * @param target url for which a token should be looked up. * @param options transports an abort signal (optional) */ findTokenFor(target: string | URL, options?: AbortOptions): Promise; } export type { AbortOptions, BearerTokenTransport, ParameterTokenTransport, Token, TokenLookupResult, TokenService, TokenTransport };