forked from auth0/node-jwks-rsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
118 lines (92 loc) · 2.99 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
108
109
110
111
112
113
114
115
116
117
118
import { SecretCallback, SecretCallbackLong } from 'express-jwt';
declare function JwksRsa(options: JwksRsa.ClientOptions): JwksRsa.JwksClient;
declare namespace JwksRsa {
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;
proxy?: string;
strictSsl?: boolean;
requestHeaders?: Headers;
timeout?: number;
}
interface CertSigningKey {
kid: string;
nbf: string;
getPublicKey(): string;
publicKey: string;
}
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;
}
interface RsaSigningKey {
kid: string;
nbf: string;
getPublicKey(): string;
rsaPublicKey: string;
}
type SigningKey = CertSigningKey | RsaSigningKey;
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 = JwksRsa;