From 36acfdff27060f5341edafbe3db41ac3408560c7 Mon Sep 17 00:00:00 2001 From: David Evans Date: Sun, 13 Sep 2020 11:36:37 +0100 Subject: [PATCH] Add Buffer and KeyObject as possible key types Fixes #97 --- index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 52ccff7..47e3a6e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,9 +1,13 @@ +import { KeyLike } from 'crypto'; + export type TAlgorithm = 'HS256' | 'HS384' | 'HS512' | 'RS256'; export interface IOptions { header: any; } -export function decode(token: string, key: string, noVerify?: boolean, algorithm?: TAlgorithm): any; +export function decode(token: string, key: string | Buffer, noVerify?: boolean, algorithm?: TAlgorithm): any; +export function decode(token: string, key: KeyLike, noVerify: true): any; +export function decode(token: string, key: KeyLike, noVerify: boolean, algorithm: TAlgorithm): any; -export function encode(payload: any, key: string, algorithm?: TAlgorithm, options?: IOptions): string; +export function encode(payload: any, key: KeyLike, algorithm?: TAlgorithm, options?: IOptions): string;