@trimble-oss/trimble-id
Version:
Trimble Identity SDK for JavaScript/ TypeScript
66 lines (63 loc) • 3.89 kB
TypeScript
import { IEndpointProvider } from './IEndpointProvider';
import RefreshableTokenProvider from './RefreshableTokenProvider';
import { ITokenProvider } from "./ITokenProvider"
/**
* @implements {ITokenProvider}
* @description The Authorization Code grant type is intended to be used by user-facing web applications with a server-side component. When the user grants authorization, the Identity authorization endpoint provides the client with a short-lived authorization code through a browser redirect. The client subsequently exchanges the authorization_code for an access_token.
* The Authorization Code with Proof Key for Code Exchange (PKCE) flow is an extension of the Authorization Code grant flow. Along with the request, the client application sends code_challenge and code_challenge_method.
*/
declare class AuthorizationCodeGrantTokenProvider extends RefreshableTokenProvider implements ITokenProvider {
/**
* @description Public constructor for AuthorizationCodeGrantTokenProvider class
* @param {IEndpointProvider} endpointProvider An endpoint provider that provides the URL for the Trimble Identity authorization and token endpoints.
* It can 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 Fluent extension to add logout redirect URL
* @param {string} logoutRedirectUrl
*/
WithLogoutRedirect(logoutRedirectUrl: string): this;
/**
* @description Fluent extension to add identity provider
* @param {string} identityProvider
*/
WithIdentityProvider(identityProvider: 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>} A promise 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 query parameters passed back to the application by Trimble Identity
* @param {string} query The query string from the URL
* @returns {PromiseLike<boolean>} A promise that resolves to true if the query string is valid
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
ValidateQuery(query: string): Promise<boolean>;
/**
* @description Validate the code passed back to the application by Trimble Identity
* @param {string} code from the URL
* @returns {PromiseLike<boolean>} A promise that resolves to true if the code is valid
* @exception Thrown when a token endpoint is not provided by the endpoint provider
* @exception Thrown when a call to the token endpoint fails
*/
ValidateCode(code: string): Promise<boolean>;
/**
* @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 AuthorizationCodeGrantTokenProvider