/** * Transports of tokens. * bearer = Header: `Authorization=Bearer ` * token_query_param = `?token=` */ type TokenTransport = "bearer" | "token_query_param"; /** * Result of a token lookup. */ interface TokenResult { /** Returns true if the token has not expired yet. */ isValid(): boolean; /** Raw token value. */ readonly token: string; /** The way the token is transported. */ readonly transport: TokenTransport; } /** * Interface to resolve tokens. * Use the service name `manager.TokenProvider` to inject an instance of this interface. */ interface TokenProvider { /** * Returns a registered token for the given service url or undefined, * if no token could be found. * Note that the returned token may have expired already. */ getToken(serviceUrl: string): Promise; } /** * Token data to store. */ interface TokenData { /** Service that handed out this token, e.g. https://example.com/portal */ readonly sourceUrl: string; /** Raw token value. */ readonly token: string; /** Lifetime of the token. */ readonly validUntil: Date; /** Raw refresh token value. */ readonly refreshToken?: string; /** Lifetime of the refresh token. */ readonly refreshTokenValidUntil?: Date; /** * The services for which this token can be used. */ readonly targetServices: string[]; /** * The way the token is transported to the services. */ readonly transport: TokenTransport; /** * User data associated with the token. */ readonly userData: UserType; } /** * A way to register tokens by external extensions. * Currently only provided for the security-manager-next "arcgis" mode. */ interface TokenRegistry { /** * Registers a new token. * The token will be returned by future calls to `getRegisteredToken(serviceUrl)`. * * @param tokenData */ registerToken(tokenData: TokenData): void; /** * Returns the full registered token data for the given service url or undefined, * if no token could be found. * Note that the returned token may have expired already. */ getRegisteredToken(serviceUrl: string): Promise | undefined>; /** Removes all registered tokens. */ removeTokens(): void; } export { TokenData, TokenProvider, TokenRegistry, TokenResult, TokenTransport };