UNPKG

@trimble-oss/trimble-id

Version:

Trimble Identity SDK for JavaScript/ TypeScript

78 lines (77 loc) 4.49 kB
import { ITokenProvider } from "./ITokenProvider" import { IEndpointProvider } from "./IEndpointProvider" import { IClaimsetProvider } from "./IClaimsetProvider" import { IPersistantStorage } from "./IPersistantStorage" /** * @implements {ITokenProvider} * @description In the Implicit Grant flow, Application gets an access token directly without an intermediate code exchange step. */ declare class ImplicitGrantTokenProvider implements ITokenProvider { /** * @description Public constructor for ImplicitGrantTokenProvider class * @param {IEndpointProvider} endpointProvider An endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints. * It can be be OpenIdEndpointProvider/FixedEndpointProvider * @param {string} consumerKey The consumer key for the calling application * @param {string} redirectUrl The URL to which Trimble Identity should redirect after successfully authenticating a user */ constructor(endpointProvider: IEndpointProvider, consumerKey: string, redirectUrl: string); /** * @description Fluent extension to add scopes * @param {IEnumerable<string>} scopes The scopes to add to the token provider */ WithScopes(scopes: string[]): this; /** * @description Add ID token validation to an ImplicitGrantTokenProvider * @param {IPersistantStorage} persistantStorage A store that persists the nonce value during the OAuth redirect workflow * @param {IClaimsetProvider} claimsetProvider A claimset provider that returns the JSON web keyset for validating the JWT ID token */ WithIDTokenValidation(persistantStorage: IPersistantStorage, claimsetProvider: IClaimsetProvider): this; /** * @description Add silent authentication to an ImplicitGrantTokenProvider * @param {string} state The state parameter to pass with silent authentication * @param {string} callback The callback URL for silent authentication */ WithSilentAuthentication(state: string, callback: string): this; /** * @description Fluent extension to add logout redirect URL * @param {string} logoutRedirectUrl */ WithLogoutRedirect(logoutRedirectUrl: string): this; /** * @description Get a redirect URL for Trimble Identity * @param {string} state An optional state parameter that will be passed back to the caller via the redirect URL * @returns {PromiseLike<string>} An awaitable Task that resolves to the redirect URL * @exception Thrown when an authorization endpoint is not provided by the endpoint provider */ GetOAuthRedirect(state?: string): Promise<string>; /** * @description Validate the hash parameters passed back to the application by Trimble Identity * @param {string} hash The hash string from the URL * @returns {PromiseLike<string>} An awaitable Task * @exception Thrown when a token endpoint is not provided by the endpoint provider * @exception Thrown when a call to the token endpoint fails */ DecodeHash(hash: string): Promise<string>; /** * @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 Revoke the token for the authenticated user and return a redirect URL to log them out of all Trimble Identity applications * @returns {PromiseLike<string>} A Task that resolves to the value of the redirect URL on completion * @exception Thrown when a token revocation endpoint is not provided by the endpoint provider * @exception Thrown when a call to the token revocation endpoint fails * @remarks Obsolete! Access tokens cannot be revoked in Trimble Identity v4 */ RevokeToken(): Promise<string>; /** * @description Return a redirect URL to log out of all Trimble Identity applications * @param {string} state An optional state parameter that will be passed back to the caller via the redirect URL * @returns {PromiseLike<string>} A promise that resolves to the value of the redirect URL on completion */ GetOAuthLogoutRedirect(state?: string): Promise<string>; } export default ImplicitGrantTokenProvider