mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
[jsonwebtoken] FIX: Better typing to replace 'Function'
This commit is contained in:
Vendored
+26
-2
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user