[jsonwebtoken] FIX: Better typing to replace 'Function'

This commit is contained in:
Daniel Parker
2018-10-22 11:56:03 -05:00
parent a1ad26b3c6
commit d9aff1fdeb
2 changed files with 27 additions and 3 deletions
+26 -2
View File
@@ -90,6 +90,30 @@ export interface SignCallback {
(err: Error, encoded: string): void;
}
export interface JwtHeader {
alg: string
typ?: string
kid?: string
jku?: string
x5u?: string
x5t?: string
}
export interface SigningKeyCallback {
(
err: any,
signingKey?: Secret,
): void
}
export interface GetPublicKeyOrSecret {
(
header: JwtHeader,
callback: SigningKeyCallback
): void;
}
export type Secret = string | Buffer | { key: string; passphrase: string };
/**
@@ -150,12 +174,12 @@ export declare function verify(
*/
export declare function verify(
token: string,
secretOrPublicKey: string | Buffer | Function,
secretOrPublicKey: string | Buffer | GetPublicKeyOrSecret,
callback?: VerifyCallback,
): void;
export declare function verify(
token: string,
secretOrPublicKey: string | Buffer | Function,
secretOrPublicKey: string | Buffer | GetPublicKeyOrSecret,
options?: VerifyOptions,
callback?: VerifyCallback,
): void;
+1 -1
View File
@@ -84,7 +84,7 @@ jwt.verify(token, cert, function(err, decoded) {
});
// verify a token assymetric with async key fetch function
function getKey(header: Object, callback: Function) {
function getKey(header: jwt.JwtHeader, callback: jwt.SigningKeyCallback) {
cert = fs.readFileSync("public.pem");
callback(null, cert);