-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.d.ts
53 lines (49 loc) · 1.14 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
type TokenType = 'id' | 'access'
interface AccessTokenPayload {
sub: string
iss: string
client_id: string
origin_jti: string
event_id: string
token_use: 'access'
scope: string
auth_time: number
exp: number
iat: number
jti: string
username: string
[key: string]: any
}
interface IdTokenPayload {
sub: string
email_verified: boolean
iss: string
preferred_username: string
origin_jti: string
aud: string
event_id: string
token_use: 'id'
auth_time: number
name: string
exp: number
iat: number
jti: string
email: string
[key: `custom:${string}`]: string
}
export function verifierFactory<T extends TokenType>(options: {
appClientId: string
region: string
tokenType: T
userPoolId: string
}): {
verify(
token: string,
): Promise<T extends 'access' ? AccessTokenPayload : IdTokenPayload>
}
export const errors = {
JwksFetchError: class JwksFetchError extends Error {},
JwksNoMatchingKeyError: class JwksNoMatchingKeyError extends Error {},
JwtCognitoClaimValidationError: class JwtCognitoClaimValidationError extends Error {},
JwtVerificationError: class JwtVerificationError extends Error {},
}