From 5ee20656d49b30722ce63b9f0e7876903eeed4b1 Mon Sep 17 00:00:00 2001 From: Ricky Curtice Date: Thu, 8 Oct 2020 13:10:01 -0700 Subject: [PATCH] Allow the key type to be a Buffer The underlying code doesn't really care, been running with these scissors for several months in a private patch. Allowing a Buffer through allows for some more clever ways of handling the key - for instance being able to wipe the memory used by that buffer after it's done, or passing in other kinds of keys: whatever the [underlying crypto](https://nodejs.org/api/crypto.html#crypto_crypto_createhmac_algorithm_key_options) handles. --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 52ccff7..293d4bb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,6 +4,6 @@ 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 encode(payload: any, key: string, algorithm?: TAlgorithm, options?: IOptions): string; +export function encode(payload: any, key: string | Buffer, algorithm?: TAlgorithm, options?: IOptions): string;