UNPKG

@authlink/client

Version:

Official client SDK for integrating with the Authlink Identity Provider

48 lines (47 loc) 2.23 kB
import type { AuthorizeResponse, CodeChallengeMethod, TokenResponse, OpenIdConfiguration } from "./types"; /** * Creates a code verifier. * @returns The code verifier string. * */ export declare function createCodeVerifier(): string; /** * Creates a code challenge from the given code verifier. * */ export declare function createCodeChallenge(codeVerifier: string, method: CodeChallengeMethod): Promise<string>; /** * Generate a random string of the specified length using the Web Crypto API. * @param length The length of the string to generate. * @returns A random string in hexadecimal format. * */ export declare function generateRandomString(length: number): string; /** * Creates a silent iframe to load a URL without user interaction. * @param url The URL to load in the iframe. * @return The created iframe element. * */ export declare function createSilentIframe(url: string): HTMLIFrameElement; /** * Listens for a web message with the specified state and origin. * @param state The expected state of the authorization response. * @param expectedOrigin The expected origin of the message. * @returns A promise that resolves with the authorization response data. */ export declare function listenForWebMessage(state: string, expectedOrigin: string): Promise<any>; /** * Maps the JSON response from the token endpoint to a TokenResponse object. * @param json The JSON response from the token endpoint. * @return A TokenResponse object containing the token information. * */ export declare function mapTokenResponse(json: any): TokenResponse; /** * Maps the JSON response from the authorization endpoint to an AuthorizeResponse object. * @param json The JSON response from the authorization endpoint. * @return An AuthorizeResponse object containing the authorization information. * */ export declare function mapAuthorizeResponse(json: any): AuthorizeResponse; /** * Maps the JSON response from the OpenID configuration endpoint to an OpenIdConfiguration object. * @param json The JSON response from the OpenID configuration endpoint. * @return An OpenIdConfiguration object containing the issuer and JWKS URI. * */ export declare function mapOpenIdConfiguration(json: any): OpenIdConfiguration;