/// // TypeScript Version: 3.6 import { KeyObject, PrivateKeyInput, PublicKeyInput, JsonWebKeyInput } from 'crypto' export interface ProduceOptions { assertion?: string | Buffer audience?: string expiresIn?: string footer?: Record | string | Buffer iat?: boolean issuer?: string jti?: string kid?: string notBefore?: string now?: Date subject?: string } export interface ConsumeOptions { assertion?: string | Buffer audience?: string clockTolerance?: string complete?: TComplete buffer?: false ignoreExp?: boolean ignoreIat?: boolean ignoreNbf?: boolean issuer?: string maxTokenAge?: string now?: Date subject?: string } export interface CompleteResult> { footer?: Buffer payload: T purpose: 'local' | 'public' version: string } export interface ConsumeOptionsBuffer { assertion?: string | Buffer complete?: TComplete buffer: true } export interface CompleteResultBuffer { footer?: Buffer payload: Buffer purpose: 'local' | 'public' version: string } export interface DecodeResult> { footer?: Buffer payload?: T purpose: 'local' | 'public' version: string } export interface DecodeResultBuffer { footer?: Buffer payload?: Buffer purpose: 'local' | 'public' version: string } export function decode>(token: string): DecodeResult export namespace V1 { function sign( payload: Record | Buffer, key: KeyObject | Buffer | PrivateKeyInput | JsonWebKeyInput | string, options?: Omit, ): Promise function encrypt( payload: Record | Buffer, key: KeyObject | Buffer | string, options?: Omit, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise> function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function decrypt>( token: string, key: KeyObject | Buffer | string, options?: Omit, 'assertion'>, ): Promise function decrypt>( token: string, key: KeyObject | Buffer | string, options?: Omit, 'assertion'>, ): Promise> function decrypt( token: string, key: KeyObject | Buffer | string, options?: Omit, 'assertion'>, ): Promise function decrypt( token: string, key: KeyObject | Buffer | string, options?: Omit, 'assertion'>, ): Promise function generateKey(purpose: 'local' | 'public'): Promise function generateKey( purpose: 'local' | 'public', options: { format: 'keyobject' }, ): Promise function generateKey(purpose: 'local', options: { format: 'paserk' }): Promise function generateKey( purpose: 'public', options: { format: 'paserk' }, ): Promise<{ secretKey: string; publicKey: string }> } export namespace V2 { function sign( payload: Record | Buffer, key: KeyObject | Buffer | PrivateKeyInput | JsonWebKeyInput | string, options?: Omit, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise> function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: Omit, 'assertion'>, ): Promise function generateKey(purpose: 'public'): Promise function generateKey(purpose: 'public', options: { format: 'keyobject' }): Promise function generateKey( purpose: 'public', options: { format: 'paserk' }, ): Promise<{ secretKey: string; publicKey: string }> function bytesToKeyObject(bytes: Buffer): KeyObject function keyObjectToBytes(keyObject: KeyObject): Buffer } export namespace V3 { function sign( payload: Record | Buffer, key: KeyObject | Buffer | PrivateKeyInput | JsonWebKeyInput | string, options?: ProduceOptions, ): Promise function encrypt( payload: Record | Buffer, key: KeyObject | Buffer | string, options?: ProduceOptions, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptions, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptions, ): Promise> function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptionsBuffer, ): Promise function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptionsBuffer, ): Promise function decrypt>( token: string, key: KeyObject | Buffer | string, options?: ConsumeOptions, ): Promise function decrypt>( token: string, key: KeyObject | Buffer | string, options?: ConsumeOptions, ): Promise> function decrypt( token: string, key: KeyObject | Buffer | string, options?: ConsumeOptionsBuffer, ): Promise function decrypt( token: string, key: KeyObject | Buffer | string, options?: ConsumeOptionsBuffer, ): Promise function generateKey(purpose: 'local' | 'public'): Promise function generateKey( purpose: 'local' | 'public', options: { format: 'keyobject' }, ): Promise function generateKey(purpose: 'local', options: { format: 'paserk' }): Promise function generateKey( purpose: 'public', options: { format: 'paserk' }, ): Promise<{ secretKey: string; publicKey: string }> function bytesToKeyObject(bytes: Buffer): KeyObject function keyObjectToBytes(keyObject: KeyObject): Buffer } export namespace V4 { function sign( payload: Record | Buffer, key: KeyObject | Buffer | PrivateKeyInput | JsonWebKeyInput | string, options?: ProduceOptions, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptions, ): Promise function verify>( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptions, ): Promise> function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptionsBuffer, ): Promise function verify( token: string, key: KeyObject | Buffer | PublicKeyInput | JsonWebKeyInput | string, options?: ConsumeOptionsBuffer, ): Promise function generateKey(purpose: 'public'): Promise function generateKey(purpose: 'public', options: { format: 'keyobject' }): Promise function generateKey( purpose: 'public', options: { format: 'paserk' }, ): Promise<{ secretKey: string; publicKey: string }> function bytesToKeyObject(bytes: Buffer): KeyObject function keyObjectToBytes(keyObject: KeyObject): Buffer } export namespace errors { class PasetoError extends Error {} class PasetoClaimInvalid extends PasetoError {} class PasetoDecryptionFailed extends PasetoError {} class PasetoInvalid extends PasetoError {} class PasetoNotSupported extends PasetoError {} class PasetoVerificationFailed extends PasetoError {} }