UNPKG

@xeedware/cognito-jwt

Version:

AWS Cognito AccessToken and IdToken classes.

84 lines (83 loc) 2.41 kB
import { AccessToken, AccessTokenPayload } from './AccessToken'; import { VerifyOptions } from 'jsonwebtoken'; export interface CognitoAccessTokenPayload extends AccessTokenPayload { auth_time?: number; client_id?: string; 'cognito:groups'?: string[]; device_key?: string; email?: string; email_verified?: boolean; event_id?: string; scope?: string; token_use?: string; username?: string; } /** @class */ export declare class CognitoAccessToken extends AccessToken { protected pem?: string; /** * Constructs a new CognitoAccessToken object * @param {string} token The JWT token. * @param {string} [pem] * @param {VerifyOptions} [options] */ constructor(token: string, pem?: string, options?: VerifyOptions); /** * Get the JWT payload * @returns {CognitoAccessTokenPayload} */ getCognitoAccessTokenPayload(): CognitoAccessTokenPayload; /** * Authentication Time: Time when the authentication occurred. * The number of seconds from 1970-01-01T0:0:0Z as measured in UTC. */ get auth_time(): number; /** * Client ID: The AWS Cognito User Pool Application Client ID the token was issued to. */ get client_id(): string; /** * Cognito user pool groups to which authenticated user belongs. * @returns {string[]} */ get cognito_groups(): string[]; /** * Device Key: Key assigned to device being used by the authenticated user. */ get device_key(): string; /** * Email: Preferred email address of the authenticated user. */ get email(): string; /** * Email Verified: A true or false value indicating if the user's * email address has been verified. */ get email_verified(): boolean; /** * Event ID * @returns {string} */ get event_id(): string; /** * String containing a space-separated list of scopes associated with this token. */ get scope(): string; /** * Token Use: 'access' or 'id'. * * @deprecated since version 1.2.0. * Will be deleted in version 2.0.0. * Use token_use instead. * */ get tokenUse(): string; /** * Token Use: 'access' or 'id'. */ get token_use(): string; /** * The username of the authenticated AWS Cognito User Pool user. */ get username(): string; }