@nopwdio/sdk-js
Version:
Nopwd JS SDK
24 lines (23 loc) • 945 B
TypeScript
export type TokenPayload = {
sub: string;
aud: string;
exp: number;
iat: number;
iss: string;
jti: string;
amr: string[];
};
/**
* Checks if the token is valid and returns its payload.
* Important: make sure to verify the "aud" claim matches your own domain.
* @param token the access token to verify
* @param signal a way to abord the request (clientside) if needed
* @returns the jwt's payload (if valid)
* @throws {AbortError} when the authentication flow has been canceled (using signal)
* @throws {MissingTokenError} if the token is not defined
* @throws {NetworkError} when a connection error occured
* @throws {InvalidTokenError} when the access token is malformed or expired
* @throws {UnexpectedError} when an unexpected error occured
*/
export declare const verify: (token: string, signal?: AbortSignal) => Promise<TokenPayload>;
export declare const getPayload: (token: string) => TokenPayload;