UNPKG

@authlink/client

Version:

Official client SDK for integrating with the Authlink Identity Provider

40 lines (39 loc) 1.73 kB
import type { AuthorizeOptions, TokenOptions, TokenResponse, LogoutOptions } from "./types"; export declare class IdentityProviderClient { private readonly baseUrl; private readonly clientId; private readonly cleanupDelayMs; private readonly codeVerifierKey; private readonly stateKey; private readonly nonceKey; constructor(baseUrl: string, clientId: string, cleanupDelayMs?: number); /** * Initiates the authorization process by redirecting the user to the authorization server. * @param options The authorization options. * @returns A promise that resolves when the authorization process is initiated. * */ authorize(options?: AuthorizeOptions): Promise<void>; /** * Initiates the silent authorization process by creating an invisible iframe. * @param options The authorization options. * @returns A promise that resolves to the authorization code. * */ silentAuthorize(options?: AuthorizeOptions): Promise<string>; /** * Checks if the state returned from the authorization server matches the stored state * @param state The state returned from the authorization server * @returns True if the state is valid, false otherwise * */ isValidState(state: string): boolean; /** * Logs out the user by redirecting to the identity provider's logout endpoint * @param options The logout options. * */ logout(options?: LogoutOptions): void; /** * Exchanges the authorization code or refresh token for new tokens * @param options The token exchange options. * @returns A promise that resolves to the token response. * */ token(options?: TokenOptions): Promise<TokenResponse>; }