UNPKG

rauth

Version:

Authentication and Authorization library via JWT

63 lines (62 loc) 2.22 kB
/// <reference types="node" /> import { DecodeOptions, Secret, SignOptions, VerifyOptions } from 'jsonwebtoken'; import { Data, Scope, SessionId, UserID } from './Session'; export interface TokenDecoded { refreshAt?: number; exp?: number; iat?: number; sessionId?: SessionId; data?: Data; scope?: Scope; userId?: UserID; clientId?: string; } export interface JWTControlOption { algorithm?: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512' | 'PS256' | 'PS384'; signOptions?: SignOptions; verifyOptions?: VerifyOptions; secret?: string | Buffer; privateKey?: Secret; publicKey?: string | Buffer; } export declare class JWTControl { private opts?; constructor(opts?: JWTControlOption | undefined); readonly algorithm: string; readonly signOptions: SignOptions; readonly verifyOptions: VerifyOptions; readonly secretOrPrivateKey: Secret; readonly secretOrPublicKey: string | Buffer; sign(payload: any, options?: SignOptions): string; decode(token: string, options?: DecodeOptions): any; verify(token: string, options?: VerifyOptions): any; toJWK(): Promise<{ alg: "none" | "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | undefined; kid: string | undefined; crv?: string | undefined; d?: string | undefined; dp?: string | undefined; dq?: string | undefined; e?: string | undefined; ext?: boolean | undefined; k?: string | undefined; key_ops?: string[] | undefined; kty?: string | undefined; n?: string | undefined; oth?: { d?: string | undefined; r?: string | undefined; t?: string | undefined; }[] | undefined; p?: string | undefined; q?: string | undefined; qi?: string | undefined; use?: string | undefined; x?: string | undefined; y?: string | undefined; x5c?: string[] | undefined; x5t?: string | undefined; 'x5t#S256'?: string | undefined; x5u?: string | undefined; }>; }