-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
107 lines (83 loc) · 2.78 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { SecretCallback, SecretCallbackLong } from 'express-jwt';
declare function JwksEc(options: JwksEc.ClientOptions): JwksEc.JwksClient;
declare namespace JwksEc {
class JwksClient {
constructor(options: ClientOptions);
getKeys(cb: (err: Error | null, keys: unknown) => void): void;
getSigningKeys(cb: (err: Error | null, keys: SigningKey[]) => void): void;
getSigningKey: (kid: string, cb: (err: Error | null, key: SigningKey) => void) => void;
}
interface Headers {
[key: string]: string;
}
interface ClientOptions {
jwksUri: string;
rateLimit?: boolean;
cache?: boolean;
cacheMaxEntries?: number;
cacheMaxAge?: number;
jwksRequestsPerMinute?: number;
strictSsl?: boolean;
requestHeaders?: Headers;
}
interface SigningKey {
kid: string;
nbf: string;
publicKey: string;
privateKey: string|undefined;
}
interface AgentOptions {
[key: string]: string;
}
interface Options {
jwksUri: string;
rateLimit?: boolean;
cache?: boolean;
cacheMaxEntries?: number;
cacheMaxAge?: number;
jwksRequestsPerMinute?: number;
strictSsl?: boolean;
requestHeaders?: Headers;
requestAgentOptions?: AgentOptions;
handleSigningKeyError?(err: Error, cb: (err: Error) => void): any;
}
function expressJwtSecret(options: ExpressJwtOptions): SecretCallbackLong;
function passportJwtSecret(options: ExpressJwtOptions): SecretCallback;
interface ExpressJwtOptions extends ClientOptions {
handleSigningKeyError?: (err: Error | null, cb: (err: Error | null) => void) => void;
}
function hapiJwt2Key(options: HapiJwtOptions): (decodedToken: DecodedToken, cb: HapiCallback) => void;
interface HapiJwtOptions extends ClientOptions {
handleSigningKeyError?: (err: Error | null, cb: HapiCallback) => void;
}
type HapiCallback = (err: Error | null, publicKey: string, signingKey: SigningKey) => void;
interface DecodedToken {
header: TokenHeader;
}
interface TokenHeader {
alg: string;
kid: string;
}
function hapiJwt2KeyAsync(options: HapiJwtOptions): (decodedToken: DecodedToken) => Promise<{ key: string }>;
function koaJwtSecret(options: KoaJwtOptions): (header: TokenHeader) => Promise<string>;
interface KoaJwtOptions extends ClientOptions {
handleSigningKeyError?(err: Error | null): Promise<void>;
}
class ArgumentError extends Error {
name: 'ArgumentError';
constructor(message: string);
}
class JwksError extends Error {
name: 'JwksError';
constructor(message: string);
}
class JwksRateLimitError extends Error {
name: 'JwksRateLimitError';
constructor(message: string);
}
class SigningKeyNotFoundError extends Error {
name: 'SigningKeyNotFoundError';
constructor(message: string);
}
}
export = JwksEc;