@trimble-oss/trimble-id
Version:
Trimble Identity SDK for JavaScript/ TypeScript
99 lines (98 loc) • 4.95 kB
TypeScript
import { ITokenProvider } from "./ITokenProvider"
import { IEndpointProvider } from "./IEndpointProvider"
import { IPersistantStorage } from "./IPersistantStorage"
/**
* @implements {ITokenProvider}
* @description The Refresh Token grant type is used by clients to exchange a refresh token for an access token when the access token has expired.
*/
declare class RefreshableTokenProvider implements ITokenProvider {
/**
* @description Static method to generate a code verifier
* @returns {string} A code verifier string
*/
static GenerateCodeVerifier(): string;
/**
* @description Public constructor for RefreshableTokenProvider class
* @param {IEndpointProvider} endpointProvider An endpoint provider that provides the URL for the Trimble Identity token endpoint.
* It can be be OpenIdEndpointProvider/FixedEndpointProvider
* @param {string} consumerKey The consumer key for the calling application
*/
constructor(endpointProvider: IEndpointProvider, consumerKey: string);
/**
* @description Fluent extension for Authorization Code with PKCE
* @param {string} codeVerifier The PKCE code verifier for the calling application
*/
WithProofKeyForCodeExchange(codeVerifier: string): this;
/**
* @description Fluent extension for Authorization Code with client secret
* @param {string} consumerSecret The consumer secret for the calling application
*/
WithConsumerSecret(consumerSecret: string): this;
/**
* @description Fluent extension for Authorization Code with access token
* @param {string} accessToken The access token for the calling application
* @param {datetime} tokenExpiry The access token expiry for the calling application
*/
WithAccessToken(accessToken: string, tokenExpiry: any): this;
/**
* @description Fluent extension for Authorization Code with id token
* @param {string} idToken The ID token for the calling application
*/
WithIdToken(idToken: string): this;
/**
* @description Fluent extension for Authorization Code with refresh token
* @param {string} refreshToken The refresh token for the calling application
*/
WithRefreshToken(refreshToken: string): this;
/**
* @description Fluent extension for Authorization Code with persistent storage
* @param {IPersistentStorage} persistentStorage The persistent storage method for the calling application
*/
WithPersistentStorage(persistentStorage: IPersistantStorage): this;
/**
* @description Fluent extension to add logout redirect URL
* @param {string} logoutRedirectUrl
*/
WithLogoutRedirect(logoutRedirectUrl: string): this;
/**
* @description Retrieves an access token for the authenticated user
* @returns {PromiseLike<string>} A Task that resolves to the value of the access token on completion
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
RetrieveToken(): Promise<string>;
/**
* @description Retrieves an access token expiry for the authenticated user
* @returns {PromiseLike<string>} A Task that resolves to the value of the access token expiry on completion
*/
RetrieveTokenExpiry(): Promise<string>;
/**
* @description Retrieves an ID token for the authenticated user
* @returns {PromiseLike<string>} A Task that resolves to the value of the ID token on completion
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
RetrieveIdToken(): Promise<string>;
/**
* @description Retrieves a refresh token for the authenticated user
* @returns {PromiseLike<string>} A Task that resolves to the value of the refresh token on completion
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
RetrieveRefreshToken(): Promise<string>;
/**
* @description Retrieves a code verifier for the authenticated user for PKCE grant
* @returns {PromiseLike<string>} A Task that resolves to the value of the code verifier on completion
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
RetrieveCodeVerifier(): Promise<string>;
/**
* @description Revokes refresh token for the authenticated user
* @returns {PromiseLike<void>} A Task that revokes the refresh token on completion
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
RevokeRefreshToken(): Promise<void>;
}
export default RefreshableTokenProvider