@shware/security 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +520 -561
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +104 -106
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.mts +109 -0
- package/dist/auth/index.d.mts.map +1 -0
- package/dist/auth/index.mjs +513 -536
- package/dist/auth/index.mjs.map +1 -1
- package/dist/auth/types.cjs +0 -19
- package/dist/auth/types.d.cts +44 -44
- package/dist/auth/types.d.cts.map +1 -0
- package/dist/auth/types.d.mts +50 -0
- package/dist/auth/types.d.mts.map +1 -0
- package/dist/auth/types.mjs +1 -1
- package/dist/core/index.cjs +34 -59
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +23 -21
- package/dist/core/index.d.cts.map +1 -0
- package/dist/core/index.d.mts +34 -0
- package/dist/core/index.d.mts.map +1 -0
- package/dist/core/index.mjs +32 -33
- package/dist/core/index.mjs.map +1 -1
- package/dist/email/schema.cjs +13 -38
- package/dist/email/schema.cjs.map +1 -1
- package/dist/email/schema.d.cts +11 -12
- package/dist/email/schema.d.cts.map +1 -0
- package/dist/email/schema.d.mts +12 -0
- package/dist/email/schema.d.mts.map +1 -0
- package/dist/email/schema.mjs +10 -11
- package/dist/email/schema.mjs.map +1 -1
- package/dist/index.cjs +17 -54
- package/dist/index.d.cts +10 -15
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +4 -17
- package/dist/oauth2/client.cjs +109 -145
- package/dist/oauth2/client.cjs.map +1 -1
- package/dist/oauth2/client.d.cts +55 -56
- package/dist/oauth2/client.d.cts.map +1 -0
- package/dist/oauth2/client.d.mts +58 -0
- package/dist/oauth2/client.d.mts.map +1 -0
- package/dist/oauth2/client.mjs +104 -116
- package/dist/oauth2/client.mjs.map +1 -1
- package/dist/oauth2/error.cjs +19 -44
- package/dist/oauth2/error.cjs.map +1 -1
- package/dist/oauth2/error.d.cts +8 -6
- package/dist/oauth2/error.d.cts.map +1 -0
- package/dist/oauth2/{error.d.ts → error.d.mts} +8 -6
- package/dist/oauth2/error.d.mts.map +1 -0
- package/dist/oauth2/error.mjs +18 -19
- package/dist/oauth2/error.mjs.map +1 -1
- package/dist/oauth2/provider/apple.cjs +75 -88
- package/dist/oauth2/provider/apple.cjs.map +1 -1
- package/dist/oauth2/provider/apple.d.cts +31 -30
- package/dist/oauth2/provider/apple.d.cts.map +1 -0
- package/dist/oauth2/provider/apple.d.mts +42 -0
- package/dist/oauth2/provider/apple.d.mts.map +1 -0
- package/dist/oauth2/provider/apple.mjs +71 -60
- package/dist/oauth2/provider/apple.mjs.map +1 -1
- package/dist/oauth2/provider/common.cjs +86 -109
- package/dist/oauth2/provider/common.cjs.map +1 -1
- package/dist/oauth2/provider/common.d.cts +19 -18
- package/dist/oauth2/provider/common.d.cts.map +1 -0
- package/dist/oauth2/provider/common.d.mts +30 -0
- package/dist/oauth2/provider/common.d.mts.map +1 -0
- package/dist/oauth2/provider/common.mjs +80 -79
- package/dist/oauth2/provider/common.mjs.map +1 -1
- package/dist/oauth2/provider/facebook.cjs +93 -109
- package/dist/oauth2/provider/facebook.cjs.map +1 -1
- package/dist/oauth2/provider/facebook.d.cts +29 -28
- package/dist/oauth2/provider/facebook.d.cts.map +1 -0
- package/dist/oauth2/provider/facebook.d.mts +45 -0
- package/dist/oauth2/provider/facebook.d.mts.map +1 -0
- package/dist/oauth2/provider/facebook.mjs +89 -81
- package/dist/oauth2/provider/facebook.mjs.map +1 -1
- package/dist/oauth2/provider/github.cjs +64 -91
- package/dist/oauth2/provider/github.cjs.map +1 -1
- package/dist/oauth2/provider/github.d.cts +52 -51
- package/dist/oauth2/provider/github.d.cts.map +1 -0
- package/dist/oauth2/provider/github.d.mts +60 -0
- package/dist/oauth2/provider/github.d.mts.map +1 -0
- package/dist/oauth2/provider/github.mjs +60 -63
- package/dist/oauth2/provider/github.mjs.map +1 -1
- package/dist/oauth2/provider/google.cjs +105 -122
- package/dist/oauth2/provider/google.cjs.map +1 -1
- package/dist/oauth2/provider/google.d.cts +34 -33
- package/dist/oauth2/provider/google.d.cts.map +1 -0
- package/dist/oauth2/provider/google.d.mts +44 -0
- package/dist/oauth2/provider/google.d.mts.map +1 -0
- package/dist/oauth2/provider/google.mjs +101 -94
- package/dist/oauth2/provider/google.mjs.map +1 -1
- package/dist/oauth2/provider/index.cjs +13 -46
- package/dist/oauth2/provider/index.d.cts +7 -7
- package/dist/oauth2/provider/index.d.mts +7 -0
- package/dist/oauth2/provider/index.mjs +1 -10
- package/dist/oauth2/provider/wechat.cjs +77 -99
- package/dist/oauth2/provider/wechat.cjs.map +1 -1
- package/dist/oauth2/provider/wechat.d.cts +28 -27
- package/dist/oauth2/provider/wechat.d.cts.map +1 -0
- package/dist/oauth2/provider/wechat.d.mts +39 -0
- package/dist/oauth2/provider/wechat.d.mts.map +1 -0
- package/dist/oauth2/provider/wechat.mjs +74 -72
- package/dist/oauth2/provider/wechat.mjs.map +1 -1
- package/dist/oauth2/provider/x.cjs +102 -125
- package/dist/oauth2/provider/x.cjs.map +1 -1
- package/dist/oauth2/provider/x.d.cts +51 -50
- package/dist/oauth2/provider/x.d.cts.map +1 -0
- package/dist/oauth2/provider/x.d.mts +69 -0
- package/dist/oauth2/provider/x.d.mts.map +1 -0
- package/dist/oauth2/provider/x.mjs +99 -103
- package/dist/oauth2/provider/x.mjs.map +1 -1
- package/dist/oauth2/types.cjs +13 -37
- package/dist/oauth2/types.cjs.map +1 -1
- package/dist/oauth2/types.d.cts +180 -178
- package/dist/oauth2/types.d.cts.map +1 -0
- package/dist/oauth2/types.d.mts +213 -0
- package/dist/oauth2/types.d.mts.map +1 -0
- package/dist/oauth2/types.mjs +13 -13
- package/dist/oauth2/types.mjs.map +1 -1
- package/dist/session/common.cjs +17 -43
- package/dist/session/common.cjs.map +1 -1
- package/dist/session/common.d.cts +4 -4
- package/dist/session/common.d.cts.map +1 -0
- package/dist/session/{common.d.ts → common.d.mts} +4 -4
- package/dist/session/common.d.mts.map +1 -0
- package/dist/session/common.mjs +14 -16
- package/dist/session/common.mjs.map +1 -1
- package/dist/session/db.cjs +88 -123
- package/dist/session/db.cjs.map +1 -1
- package/dist/session/db.d.cts +36 -36
- package/dist/session/db.d.cts.map +1 -0
- package/dist/session/db.d.mts +44 -0
- package/dist/session/db.d.mts.map +1 -0
- package/dist/session/db.mjs +84 -95
- package/dist/session/db.mjs.map +1 -1
- package/dist/session/map-session.cjs +71 -103
- package/dist/session/map-session.cjs.map +1 -1
- package/dist/session/map-session.d.cts +24 -24
- package/dist/session/map-session.d.cts.map +1 -0
- package/dist/session/map-session.d.mts +27 -0
- package/dist/session/map-session.d.mts.map +1 -0
- package/dist/session/map-session.mjs +70 -78
- package/dist/session/map-session.mjs.map +1 -1
- package/dist/session/redis.cjs +270 -319
- package/dist/session/redis.cjs.map +1 -1
- package/dist/session/redis.d.cts +51 -51
- package/dist/session/redis.d.cts.map +1 -0
- package/dist/session/redis.d.mts +58 -0
- package/dist/session/redis.d.mts.map +1 -0
- package/dist/session/redis.mjs +266 -291
- package/dist/session/redis.mjs.map +1 -1
- package/dist/session/types.cjs +0 -19
- package/dist/session/types.d.cts +34 -33
- package/dist/session/types.d.cts.map +1 -0
- package/dist/session/types.d.mts +45 -0
- package/dist/session/types.d.mts.map +1 -0
- package/dist/session/types.mjs +1 -1
- package/dist/utils/http.cjs +31 -55
- package/dist/utils/http.cjs.map +1 -1
- package/dist/utils/http.d.cts +7 -10
- package/dist/utils/http.d.cts.map +1 -0
- package/dist/utils/{http.d.ts → http.d.mts} +7 -10
- package/dist/utils/http.d.mts.map +1 -0
- package/dist/utils/http.mjs +24 -24
- package/dist/utils/http.mjs.map +1 -1
- package/dist/utils/oauth2.cjs +6 -30
- package/dist/utils/oauth2.cjs.map +1 -1
- package/dist/utils/oauth2.d.cts +3 -1
- package/dist/utils/oauth2.d.cts.map +1 -0
- package/dist/utils/oauth2.d.mts +5 -0
- package/dist/utils/oauth2.d.mts.map +1 -0
- package/dist/utils/oauth2.mjs +5 -5
- package/dist/utils/oauth2.mjs.map +1 -1
- package/dist/utils/timing.cjs +49 -70
- package/dist/utils/timing.cjs.map +1 -1
- package/dist/utils/timing.d.cts +10 -8
- package/dist/utils/timing.d.cts.map +1 -0
- package/dist/utils/timing.d.mts +15 -0
- package/dist/utils/timing.d.mts.map +1 -0
- package/dist/utils/timing.mjs +48 -45
- package/dist/utils/timing.mjs.map +1 -1
- package/dist/utils/valid.cjs +50 -71
- package/dist/utils/valid.cjs.map +1 -1
- package/dist/utils/valid.d.cts +17 -16
- package/dist/utils/valid.d.cts.map +1 -0
- package/dist/utils/valid.d.mts +28 -0
- package/dist/utils/valid.d.mts.map +1 -0
- package/dist/utils/valid.mjs +47 -44
- package/dist/utils/valid.mjs.map +1 -1
- package/package.json +23 -13
- package/dist/auth/index.d.ts +0 -111
- package/dist/auth/types.cjs.map +0 -1
- package/dist/auth/types.d.ts +0 -50
- package/dist/auth/types.mjs.map +0 -1
- package/dist/core/index.d.ts +0 -32
- package/dist/email/schema.d.ts +0 -13
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.mjs.map +0 -1
- package/dist/oauth2/client.d.ts +0 -59
- package/dist/oauth2/provider/apple.d.ts +0 -41
- package/dist/oauth2/provider/common.d.ts +0 -29
- package/dist/oauth2/provider/facebook.d.ts +0 -44
- package/dist/oauth2/provider/github.d.ts +0 -59
- package/dist/oauth2/provider/google.d.ts +0 -43
- package/dist/oauth2/provider/index.cjs.map +0 -1
- package/dist/oauth2/provider/index.d.ts +0 -7
- package/dist/oauth2/provider/index.mjs.map +0 -1
- package/dist/oauth2/provider/wechat.d.ts +0 -38
- package/dist/oauth2/provider/x.d.ts +0 -68
- package/dist/oauth2/types.d.ts +0 -211
- package/dist/session/__tests__/redis.test.cjs +0 -247
- package/dist/session/__tests__/redis.test.cjs.map +0 -1
- package/dist/session/__tests__/redis.test.d.cts +0 -2
- package/dist/session/__tests__/redis.test.d.ts +0 -2
- package/dist/session/__tests__/redis.test.mjs +0 -252
- package/dist/session/__tests__/redis.test.mjs.map +0 -1
- package/dist/session/db.d.ts +0 -44
- package/dist/session/map-session.d.ts +0 -27
- package/dist/session/redis.d.ts +0 -58
- package/dist/session/types.cjs.map +0 -1
- package/dist/session/types.d.ts +0 -44
- package/dist/session/types.mjs.map +0 -1
- package/dist/utils/oauth2.d.ts +0 -3
- package/dist/utils/timing.d.ts +0 -13
- package/dist/utils/valid.d.ts +0 -27
package/dist/oauth2/types.d.cts
CHANGED
|
@@ -1,211 +1,213 @@
|
|
|
1
|
+
//#region src/oauth2/types.d.ts
|
|
1
2
|
interface PkceParameters {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
code_verifier: string;
|
|
4
|
+
code_challenge: string;
|
|
5
|
+
code_challenge_method: 'S256' | 'plain';
|
|
5
6
|
}
|
|
6
7
|
interface OAuth2AuthorizationRequest {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
state: string;
|
|
9
|
+
registrationId: string;
|
|
10
|
+
authorizationRequestUri: string;
|
|
11
|
+
additionalParameters: PkceParameters;
|
|
11
12
|
}
|
|
12
13
|
interface CreateAuthorizationUriParams {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
state: string;
|
|
15
|
+
clientId: string;
|
|
16
|
+
redirectUri: string;
|
|
17
|
+
scope: string[] | undefined;
|
|
18
|
+
pkce?: Omit<PkceParameters, 'code_verifier'>;
|
|
18
19
|
}
|
|
19
20
|
interface ExchangeCodeParams {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
code: string;
|
|
22
|
+
clientId: string;
|
|
23
|
+
clientSecret: string;
|
|
24
|
+
redirectUri: string;
|
|
25
|
+
pkce?: Omit<PkceParameters, 'code_challenge' | 'code_challenge_method'>;
|
|
25
26
|
}
|
|
26
27
|
interface RefreshTokenParams {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
clientId: string;
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
refreshToken: string;
|
|
30
31
|
}
|
|
31
32
|
interface RevokeTokenParams {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
token: string;
|
|
34
|
+
clientId: string;
|
|
35
|
+
clientSecret: string;
|
|
35
36
|
}
|
|
36
37
|
interface LoginOAuth2NativeParams {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
clientId: string;
|
|
39
|
+
clientSecret: string;
|
|
40
|
+
redirectUri: string;
|
|
41
|
+
pkce?: PkceParameters;
|
|
42
|
+
credentials: NativeCredential;
|
|
42
43
|
}
|
|
43
44
|
interface OAuth2Token {
|
|
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
|
-
|
|
45
|
+
/**
|
|
46
|
+
* REQUIRED.
|
|
47
|
+
* The access token issued by the authorization server.
|
|
48
|
+
*/
|
|
49
|
+
access_token: string;
|
|
50
|
+
/**
|
|
51
|
+
* REQUIRED.
|
|
52
|
+
* The type of the token issued as described in Section 7.1. Value is case insensitive.
|
|
53
|
+
*/
|
|
54
|
+
token_type: 'Bearer' | 'bearer' | 'mac' | (string & {});
|
|
55
|
+
/**
|
|
56
|
+
* RECOMMENDED.
|
|
57
|
+
* The lifetime in seconds of the access token. For example, the value "3600" denotes that the
|
|
58
|
+
* access token will expire in one hour from the time the response was generated. If omitted, the
|
|
59
|
+
* authorization server SHOULD provide the expiration time via other means or document the default
|
|
60
|
+
* value.
|
|
61
|
+
*/
|
|
62
|
+
expires_in?: number;
|
|
63
|
+
/**
|
|
64
|
+
* OPTIONAL.
|
|
65
|
+
* The refresh token, which can be used to obtain new access tokens using the same authorization
|
|
66
|
+
* grant as described in Section 6.
|
|
67
|
+
*/
|
|
68
|
+
refresh_token?: string;
|
|
69
|
+
/**
|
|
70
|
+
* OPTIONAL.
|
|
71
|
+
* If identical to the scope requested by the client; otherwise, REQUIRED. The scope of the
|
|
72
|
+
* access token as described by Section 3.3.
|
|
73
|
+
*/
|
|
74
|
+
scope?: string;
|
|
75
|
+
id_token?: string;
|
|
76
|
+
[key: string]: unknown;
|
|
76
77
|
}
|
|
77
78
|
interface OidcToken extends OAuth2Token {
|
|
78
|
-
|
|
79
|
+
id_token: string;
|
|
79
80
|
}
|
|
80
81
|
type NativeCredential = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
state?: string;
|
|
83
|
+
code?: string;
|
|
84
|
+
client_id?: string;
|
|
85
|
+
redirect_uri?: string;
|
|
86
|
+
id_token?: string;
|
|
87
|
+
access_token?: string;
|
|
87
88
|
};
|
|
88
89
|
declare enum OidcScopes {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
openid = "openid",
|
|
91
|
+
profile = "profile",
|
|
92
|
+
email = "email",
|
|
93
|
+
phone = "phone",
|
|
94
|
+
address = "address",
|
|
95
|
+
offline_access = "offline_access"
|
|
95
96
|
}
|
|
96
97
|
interface StandardClaims {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
98
|
+
sub: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
given_name?: string;
|
|
101
|
+
family_name?: string;
|
|
102
|
+
middle_name?: string;
|
|
103
|
+
nickname?: string;
|
|
104
|
+
preferred_username?: string;
|
|
105
|
+
profile?: string;
|
|
106
|
+
picture?: string;
|
|
107
|
+
website?: string;
|
|
108
|
+
email?: string;
|
|
109
|
+
email_verified?: boolean;
|
|
110
|
+
gender?: 'female' | 'male' | (string & {});
|
|
111
|
+
birthdate?: string;
|
|
112
|
+
zoneinfo?: string;
|
|
113
|
+
locale?: string;
|
|
114
|
+
phone_number?: string;
|
|
115
|
+
phone_number_verified?: boolean;
|
|
116
|
+
address?: {
|
|
117
|
+
formatted: string;
|
|
118
|
+
street_address: string;
|
|
119
|
+
locality: string;
|
|
120
|
+
region: string;
|
|
121
|
+
postal_code: string;
|
|
122
|
+
country: string;
|
|
123
|
+
};
|
|
124
|
+
updated_at?: number;
|
|
124
125
|
}
|
|
125
126
|
interface UserInfo<T = unknown> {
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
claims: StandardClaims;
|
|
128
|
+
data: T;
|
|
128
129
|
}
|
|
129
130
|
interface Provider {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
131
|
+
/** Authorization URI for the provider. */
|
|
132
|
+
authorizationUri: string;
|
|
133
|
+
/** Token URI for the provider. */
|
|
134
|
+
tokenUri: string;
|
|
135
|
+
/** Token revoke URI for the provider. */
|
|
136
|
+
tokenRevokeUri?: string;
|
|
137
|
+
/** Token refresh URI for the provider. */
|
|
138
|
+
tokenRefreshUri?: string;
|
|
139
|
+
/** User info URI for the provider. */
|
|
140
|
+
userInfoUri?: string;
|
|
141
|
+
/** User info authentication method for the provider. */
|
|
142
|
+
userInfoAuthenticationMethod?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.
|
|
145
|
+
* */
|
|
146
|
+
userNameAttribute?: string;
|
|
147
|
+
/** JWK set URI for the provider */
|
|
148
|
+
jwkSetUri?: string;
|
|
149
|
+
/**
|
|
150
|
+
* URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization
|
|
151
|
+
* Server Metadata endpoint defined by RFC 8414.
|
|
152
|
+
* */
|
|
153
|
+
issuerUri?: string;
|
|
154
|
+
/** Default scopes for the provider. */
|
|
155
|
+
defaultScope: string[];
|
|
156
|
+
/** step 1: generate authorization uri and redirect user to it */
|
|
157
|
+
createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;
|
|
158
|
+
/** step 2: exchange code for token */
|
|
159
|
+
exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;
|
|
160
|
+
/** step 3: get user info */
|
|
161
|
+
getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;
|
|
162
|
+
/** others: refresh access token */
|
|
163
|
+
refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;
|
|
164
|
+
/** others: revoke token */
|
|
165
|
+
revokeToken?: (params: RevokeTokenParams) => Promise<void>;
|
|
166
|
+
loginOAuth2Native?: (params: LoginOAuth2NativeParams) => Promise<{
|
|
167
|
+
token: OAuth2Token;
|
|
168
|
+
userInfo: UserInfo;
|
|
169
|
+
}>;
|
|
169
170
|
}
|
|
170
171
|
interface OneTapProvider extends Provider {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
getTokenInfo: (id_token: string) => Promise<{
|
|
173
|
+
token: OAuth2Token;
|
|
174
|
+
userInfo: UserInfo;
|
|
175
|
+
}>;
|
|
175
176
|
}
|
|
176
177
|
interface Registration {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'
|
|
180
|
+
* property or used one of the commonly used providers (google, github, facebook, okta).
|
|
181
|
+
* */
|
|
182
|
+
provider?: string;
|
|
183
|
+
/** Client ID for the registration. */
|
|
184
|
+
clientId: string;
|
|
185
|
+
/** Client secret of the registration. */
|
|
186
|
+
clientSecret: string;
|
|
187
|
+
/** Client authentication method. May be left blank when using a pre-defined provider. */
|
|
188
|
+
clientAuthenticationMethod?: string;
|
|
189
|
+
/** Authorization grant type. May be left blank when using a pre-defined provider. */
|
|
190
|
+
authorizationGrantType?: 'authorization_code' | 'client_credentials' | 'device_code' | 'jwt_bearer' | 'password' | 'refresh_token' | 'token_exchange';
|
|
191
|
+
/** Redirect URI. May be left blank when using a pre-defined provider. */
|
|
192
|
+
redirectUri?: string;
|
|
193
|
+
/** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */
|
|
194
|
+
scope?: string[];
|
|
195
|
+
/** Client name. May be left blank when using a pre-defined provider. */
|
|
196
|
+
clientName?: string;
|
|
196
197
|
}
|
|
197
198
|
interface OAuth2ClientConfig {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export {
|
|
199
|
+
baseUri: string;
|
|
200
|
+
errorUri: string;
|
|
201
|
+
successUri: string;
|
|
202
|
+
provider: {
|
|
203
|
+
[name: string]: Provider | undefined;
|
|
204
|
+
};
|
|
205
|
+
registration: {
|
|
206
|
+
[name: string]: Registration | undefined;
|
|
207
|
+
} | (() => Promise<{
|
|
208
|
+
[name: string]: Registration | undefined;
|
|
209
|
+
}>);
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { ExchangeCodeParams, LoginOAuth2NativeParams, NativeCredential, OAuth2AuthorizationRequest, OAuth2ClientConfig, OAuth2Token, OidcScopes, OidcToken, OneTapProvider, PkceParameters, Provider, RefreshTokenParams, Registration, RevokeTokenParams, StandardClaims, UserInfo };
|
|
213
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/oauth2/types.ts"],"mappings":";UACiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,sBAAsB;;UAGd;EACR;EACA;EACA;EACA;EACA,OAAO,KAAK;;UAGG;EACf;EACA;EACA;EACA;EACA,OAAO,KAAK;;UAGG;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,OAAO;EACP,aAAa;;UAIE;;;;;EAKf;;;;;EAMA;;;;;;;;EASA;;;;;;EAOA;;;;;;EAOA;EAEA;GAEC;;UAGc,kBAAkB;EACjC;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;aAGU;EACV;EACA;EACA;EACA;EACA;EACA;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;UAGe,SAAS;EACxB,QAAQ;EACR,MAAM;;UAGS;;EAEf;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;;;EAKA;;EAGA;;;;;EAMA;;EAGA;;EAGA,yBAAyB,QAAQ,iCAAiC;;EAGlE,4BAA4B,QAAQ,uBAAuB,QAAQ;;EAGnE,cAAc,OAAO,gBAAgB,QAAQ;;EAG7C,sBAAsB,QAAQ,uBAAuB,QAAQ;;EAG7D,eAAe,QAAQ,sBAAsB;EAE7C,qBACE,QAAQ,4BACL;IAAU,OAAO;IAAa,UAAU;;;UAG9B,uBAAuB;EACtC,eAAe,qBAAqB;IAAU,OAAO;IAAa,UAAU;;;UAG7D;;;;;EAKf;;EAGA;;EAGA;;EAGA;;EAGA;;EAYA;;EAGA;;EAGA;;UAGe;EACf;EACA;EACA;EACA;KAAa,eAAe;;EAC5B;KACO,eAAe;aACX;KAAW,eAAe"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
//#region src/oauth2/types.d.ts
|
|
2
|
+
interface PkceParameters {
|
|
3
|
+
code_verifier: string;
|
|
4
|
+
code_challenge: string;
|
|
5
|
+
code_challenge_method: 'S256' | 'plain';
|
|
6
|
+
}
|
|
7
|
+
interface OAuth2AuthorizationRequest {
|
|
8
|
+
state: string;
|
|
9
|
+
registrationId: string;
|
|
10
|
+
authorizationRequestUri: string;
|
|
11
|
+
additionalParameters: PkceParameters;
|
|
12
|
+
}
|
|
13
|
+
interface CreateAuthorizationUriParams {
|
|
14
|
+
state: string;
|
|
15
|
+
clientId: string;
|
|
16
|
+
redirectUri: string;
|
|
17
|
+
scope: string[] | undefined;
|
|
18
|
+
pkce?: Omit<PkceParameters, 'code_verifier'>;
|
|
19
|
+
}
|
|
20
|
+
interface ExchangeCodeParams {
|
|
21
|
+
code: string;
|
|
22
|
+
clientId: string;
|
|
23
|
+
clientSecret: string;
|
|
24
|
+
redirectUri: string;
|
|
25
|
+
pkce?: Omit<PkceParameters, 'code_challenge' | 'code_challenge_method'>;
|
|
26
|
+
}
|
|
27
|
+
interface RefreshTokenParams {
|
|
28
|
+
clientId: string;
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
refreshToken: string;
|
|
31
|
+
}
|
|
32
|
+
interface RevokeTokenParams {
|
|
33
|
+
token: string;
|
|
34
|
+
clientId: string;
|
|
35
|
+
clientSecret: string;
|
|
36
|
+
}
|
|
37
|
+
interface LoginOAuth2NativeParams {
|
|
38
|
+
clientId: string;
|
|
39
|
+
clientSecret: string;
|
|
40
|
+
redirectUri: string;
|
|
41
|
+
pkce?: PkceParameters;
|
|
42
|
+
credentials: NativeCredential;
|
|
43
|
+
}
|
|
44
|
+
interface OAuth2Token {
|
|
45
|
+
/**
|
|
46
|
+
* REQUIRED.
|
|
47
|
+
* The access token issued by the authorization server.
|
|
48
|
+
*/
|
|
49
|
+
access_token: string;
|
|
50
|
+
/**
|
|
51
|
+
* REQUIRED.
|
|
52
|
+
* The type of the token issued as described in Section 7.1. Value is case insensitive.
|
|
53
|
+
*/
|
|
54
|
+
token_type: 'Bearer' | 'bearer' | 'mac' | (string & {});
|
|
55
|
+
/**
|
|
56
|
+
* RECOMMENDED.
|
|
57
|
+
* The lifetime in seconds of the access token. For example, the value "3600" denotes that the
|
|
58
|
+
* access token will expire in one hour from the time the response was generated. If omitted, the
|
|
59
|
+
* authorization server SHOULD provide the expiration time via other means or document the default
|
|
60
|
+
* value.
|
|
61
|
+
*/
|
|
62
|
+
expires_in?: number;
|
|
63
|
+
/**
|
|
64
|
+
* OPTIONAL.
|
|
65
|
+
* The refresh token, which can be used to obtain new access tokens using the same authorization
|
|
66
|
+
* grant as described in Section 6.
|
|
67
|
+
*/
|
|
68
|
+
refresh_token?: string;
|
|
69
|
+
/**
|
|
70
|
+
* OPTIONAL.
|
|
71
|
+
* If identical to the scope requested by the client; otherwise, REQUIRED. The scope of the
|
|
72
|
+
* access token as described by Section 3.3.
|
|
73
|
+
*/
|
|
74
|
+
scope?: string;
|
|
75
|
+
id_token?: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
interface OidcToken extends OAuth2Token {
|
|
79
|
+
id_token: string;
|
|
80
|
+
}
|
|
81
|
+
type NativeCredential = {
|
|
82
|
+
state?: string;
|
|
83
|
+
code?: string;
|
|
84
|
+
client_id?: string;
|
|
85
|
+
redirect_uri?: string;
|
|
86
|
+
id_token?: string;
|
|
87
|
+
access_token?: string;
|
|
88
|
+
};
|
|
89
|
+
declare enum OidcScopes {
|
|
90
|
+
openid = "openid",
|
|
91
|
+
profile = "profile",
|
|
92
|
+
email = "email",
|
|
93
|
+
phone = "phone",
|
|
94
|
+
address = "address",
|
|
95
|
+
offline_access = "offline_access"
|
|
96
|
+
}
|
|
97
|
+
interface StandardClaims {
|
|
98
|
+
sub: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
given_name?: string;
|
|
101
|
+
family_name?: string;
|
|
102
|
+
middle_name?: string;
|
|
103
|
+
nickname?: string;
|
|
104
|
+
preferred_username?: string;
|
|
105
|
+
profile?: string;
|
|
106
|
+
picture?: string;
|
|
107
|
+
website?: string;
|
|
108
|
+
email?: string;
|
|
109
|
+
email_verified?: boolean;
|
|
110
|
+
gender?: 'female' | 'male' | (string & {});
|
|
111
|
+
birthdate?: string;
|
|
112
|
+
zoneinfo?: string;
|
|
113
|
+
locale?: string;
|
|
114
|
+
phone_number?: string;
|
|
115
|
+
phone_number_verified?: boolean;
|
|
116
|
+
address?: {
|
|
117
|
+
formatted: string;
|
|
118
|
+
street_address: string;
|
|
119
|
+
locality: string;
|
|
120
|
+
region: string;
|
|
121
|
+
postal_code: string;
|
|
122
|
+
country: string;
|
|
123
|
+
};
|
|
124
|
+
updated_at?: number;
|
|
125
|
+
}
|
|
126
|
+
interface UserInfo<T = unknown> {
|
|
127
|
+
claims: StandardClaims;
|
|
128
|
+
data: T;
|
|
129
|
+
}
|
|
130
|
+
interface Provider {
|
|
131
|
+
/** Authorization URI for the provider. */
|
|
132
|
+
authorizationUri: string;
|
|
133
|
+
/** Token URI for the provider. */
|
|
134
|
+
tokenUri: string;
|
|
135
|
+
/** Token revoke URI for the provider. */
|
|
136
|
+
tokenRevokeUri?: string;
|
|
137
|
+
/** Token refresh URI for the provider. */
|
|
138
|
+
tokenRefreshUri?: string;
|
|
139
|
+
/** User info URI for the provider. */
|
|
140
|
+
userInfoUri?: string;
|
|
141
|
+
/** User info authentication method for the provider. */
|
|
142
|
+
userInfoAuthenticationMethod?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.
|
|
145
|
+
* */
|
|
146
|
+
userNameAttribute?: string;
|
|
147
|
+
/** JWK set URI for the provider */
|
|
148
|
+
jwkSetUri?: string;
|
|
149
|
+
/**
|
|
150
|
+
* URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization
|
|
151
|
+
* Server Metadata endpoint defined by RFC 8414.
|
|
152
|
+
* */
|
|
153
|
+
issuerUri?: string;
|
|
154
|
+
/** Default scopes for the provider. */
|
|
155
|
+
defaultScope: string[];
|
|
156
|
+
/** step 1: generate authorization uri and redirect user to it */
|
|
157
|
+
createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;
|
|
158
|
+
/** step 2: exchange code for token */
|
|
159
|
+
exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;
|
|
160
|
+
/** step 3: get user info */
|
|
161
|
+
getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;
|
|
162
|
+
/** others: refresh access token */
|
|
163
|
+
refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;
|
|
164
|
+
/** others: revoke token */
|
|
165
|
+
revokeToken?: (params: RevokeTokenParams) => Promise<void>;
|
|
166
|
+
loginOAuth2Native?: (params: LoginOAuth2NativeParams) => Promise<{
|
|
167
|
+
token: OAuth2Token;
|
|
168
|
+
userInfo: UserInfo;
|
|
169
|
+
}>;
|
|
170
|
+
}
|
|
171
|
+
interface OneTapProvider extends Provider {
|
|
172
|
+
getTokenInfo: (id_token: string) => Promise<{
|
|
173
|
+
token: OAuth2Token;
|
|
174
|
+
userInfo: UserInfo;
|
|
175
|
+
}>;
|
|
176
|
+
}
|
|
177
|
+
interface Registration {
|
|
178
|
+
/**
|
|
179
|
+
* Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'
|
|
180
|
+
* property or used one of the commonly used providers (google, github, facebook, okta).
|
|
181
|
+
* */
|
|
182
|
+
provider?: string;
|
|
183
|
+
/** Client ID for the registration. */
|
|
184
|
+
clientId: string;
|
|
185
|
+
/** Client secret of the registration. */
|
|
186
|
+
clientSecret: string;
|
|
187
|
+
/** Client authentication method. May be left blank when using a pre-defined provider. */
|
|
188
|
+
clientAuthenticationMethod?: string;
|
|
189
|
+
/** Authorization grant type. May be left blank when using a pre-defined provider. */
|
|
190
|
+
authorizationGrantType?: 'authorization_code' | 'client_credentials' | 'device_code' | 'jwt_bearer' | 'password' | 'refresh_token' | 'token_exchange';
|
|
191
|
+
/** Redirect URI. May be left blank when using a pre-defined provider. */
|
|
192
|
+
redirectUri?: string;
|
|
193
|
+
/** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */
|
|
194
|
+
scope?: string[];
|
|
195
|
+
/** Client name. May be left blank when using a pre-defined provider. */
|
|
196
|
+
clientName?: string;
|
|
197
|
+
}
|
|
198
|
+
interface OAuth2ClientConfig {
|
|
199
|
+
baseUri: string;
|
|
200
|
+
errorUri: string;
|
|
201
|
+
successUri: string;
|
|
202
|
+
provider: {
|
|
203
|
+
[name: string]: Provider | undefined;
|
|
204
|
+
};
|
|
205
|
+
registration: {
|
|
206
|
+
[name: string]: Registration | undefined;
|
|
207
|
+
} | (() => Promise<{
|
|
208
|
+
[name: string]: Registration | undefined;
|
|
209
|
+
}>);
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { ExchangeCodeParams, LoginOAuth2NativeParams, NativeCredential, OAuth2AuthorizationRequest, OAuth2ClientConfig, OAuth2Token, OidcScopes, OidcToken, OneTapProvider, PkceParameters, Provider, RefreshTokenParams, Registration, RevokeTokenParams, StandardClaims, UserInfo };
|
|
213
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/oauth2/types.ts"],"mappings":";UACiB;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,sBAAsB;;UAGd;EACR;EACA;EACA;EACA;EACA,OAAO,KAAK;;UAGG;EACf;EACA;EACA;EACA;EACA,OAAO,KAAK;;UAGG;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,OAAO;EACP,aAAa;;UAIE;;;;;EAKf;;;;;EAMA;;;;;;;;EASA;;;;;;EAOA;;;;;;EAOA;EAEA;GAEC;;UAGc,kBAAkB;EACjC;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;aAGU;EACV;EACA;EACA;EACA;EACA;EACA;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;UAGe,SAAS;EACxB,QAAQ;EACR,MAAM;;UAGS;;EAEf;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;;;EAKA;;EAGA;;;;;EAMA;;EAGA;;EAGA,yBAAyB,QAAQ,iCAAiC;;EAGlE,4BAA4B,QAAQ,uBAAuB,QAAQ;;EAGnE,cAAc,OAAO,gBAAgB,QAAQ;;EAG7C,sBAAsB,QAAQ,uBAAuB,QAAQ;;EAG7D,eAAe,QAAQ,sBAAsB;EAE7C,qBACE,QAAQ,4BACL;IAAU,OAAO;IAAa,UAAU;;;UAG9B,uBAAuB;EACtC,eAAe,qBAAqB;IAAU,OAAO;IAAa,UAAU;;;UAG7D;;;;;EAKf;;EAGA;;EAGA;;EAGA;;EAGA;;EAYA;;EAGA;;EAGA;;UAGe;EACf;EACA;EACA;EACA;KAAa,eAAe;;EAC5B;KACO,eAAe;aACX;KAAW,eAAe"}
|
package/dist/oauth2/types.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//#region src/oauth2/types.ts
|
|
2
|
+
let OidcScopes = /* @__PURE__ */ function(OidcScopes) {
|
|
3
|
+
OidcScopes["openid"] = "openid";
|
|
4
|
+
OidcScopes["profile"] = "profile";
|
|
5
|
+
OidcScopes["email"] = "email";
|
|
6
|
+
OidcScopes["phone"] = "phone";
|
|
7
|
+
OidcScopes["address"] = "address";
|
|
8
|
+
OidcScopes["offline_access"] = "offline_access";
|
|
9
|
+
return OidcScopes;
|
|
10
|
+
}({});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OidcScopes };
|
|
13
|
+
|
|
14
14
|
//# sourceMappingURL=types.mjs.map
|