Skip to content

Commit 7723887

Browse files
committed
Add Typescript definition files
1 parent 2f086d3 commit 7723887

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"jsonwebtoken"
3030
],
3131
"dependencies": {
32+
"@types/bluebird": "^3.5.8",
33+
"@types/jsonwebtoken": "^7.2.2",
3234
"base64url": "2.0.0",
3335
"bluebird": "3.5.0",
3436
"debug": "2.6.3",
@@ -53,5 +55,6 @@
5355
"before",
5456
"after"
5557
]
56-
}
58+
},
59+
"types": "types/index.d.ts"
5760
}

types/index.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as Promise from "bluebird"
2+
import {JsonWebTokenError, VerifyOptions} from "jsonwebtoken"
3+
4+
export {TokenExpiredError, NotBeforeError, JsonWebTokenError} from "jsonwebtoken"
5+
6+
type PublicKeyResolver = (keyId: string) => { cert: string, alg: string } | Promise<{ cert: string, alg: string }>;
7+
type PrivateKeyResolver = (keyId: string) => { key: string, passphrase: string, alg: string } | Promise<{ key: string, passphrase: string, alg: string }>;
8+
9+
export class MissingKeyIdError extends JsonWebTokenError {
10+
constructor()
11+
}
12+
13+
export class UnknownKeyIdError extends JsonWebTokenError {
14+
constructor(keyId: string)
15+
}
16+
17+
export interface HandlerObject {
18+
extractKeyId(jwtRaw: string): Promise<string>;
19+
20+
verify(jwtRaw: string, options: VerifyOptions): Promise<string>;
21+
22+
create(tokenBody: string | Buffer | object, keyId: string): Promise<string>;
23+
}
24+
25+
export function Handler(debugNamePrefix: string, publicKeyResolver?: PublicKeyResolver, privateKeyResolver?: PrivateKeyResolver): HandlerObject;

0 commit comments

Comments
 (0)