@shware/security 2.5.3 → 3.0.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 +519 -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 +512 -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 +18 -59
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +13 -24
- package/dist/core/index.d.cts.map +1 -0
- package/dist/core/index.d.mts +21 -0
- package/dist/core/index.d.mts.map +1 -0
- package/dist/core/index.mjs +17 -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 +18 -54
- package/dist/index.d.cts +10 -15
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +5 -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 +12 -37
- package/dist/oauth2/types.cjs.map +1 -1
- package/dist/oauth2/types.d.cts +176 -180
- package/dist/oauth2/types.d.cts.map +1 -0
- package/dist/oauth2/types.d.mts +207 -0
- package/dist/oauth2/types.d.mts.map +1 -0
- package/dist/oauth2/types.mjs +12 -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 +22 -12
- 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,207 @@
|
|
|
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
|
-
declare
|
|
89
|
-
|
|
90
|
-
profile = "profile",
|
|
91
|
-
email = "email",
|
|
92
|
-
phone = "phone",
|
|
93
|
-
address = "address",
|
|
94
|
-
offline_access = "offline_access"
|
|
95
|
-
}
|
|
89
|
+
declare const OIDC_SCOPES: readonly ['openid', 'profile', 'email', 'phone', 'address', 'offline_access'];
|
|
90
|
+
type OidcScope = (typeof OIDC_SCOPES)[number];
|
|
96
91
|
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
|
-
|
|
92
|
+
sub: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
given_name?: string;
|
|
95
|
+
family_name?: string;
|
|
96
|
+
middle_name?: string;
|
|
97
|
+
nickname?: string;
|
|
98
|
+
preferred_username?: string;
|
|
99
|
+
profile?: string;
|
|
100
|
+
picture?: string;
|
|
101
|
+
website?: string;
|
|
102
|
+
email?: string;
|
|
103
|
+
email_verified?: boolean;
|
|
104
|
+
gender?: 'female' | 'male' | (string & {});
|
|
105
|
+
birthdate?: string;
|
|
106
|
+
zoneinfo?: string;
|
|
107
|
+
locale?: string;
|
|
108
|
+
phone_number?: string;
|
|
109
|
+
phone_number_verified?: boolean;
|
|
110
|
+
address?: {
|
|
111
|
+
formatted: string;
|
|
112
|
+
street_address: string;
|
|
113
|
+
locality: string;
|
|
114
|
+
region: string;
|
|
115
|
+
postal_code: string;
|
|
116
|
+
country: string;
|
|
117
|
+
};
|
|
118
|
+
updated_at?: number;
|
|
124
119
|
}
|
|
125
120
|
interface UserInfo<T = unknown> {
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
claims: StandardClaims;
|
|
122
|
+
data: T;
|
|
128
123
|
}
|
|
129
124
|
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
|
-
|
|
125
|
+
/** Authorization URI for the provider. */
|
|
126
|
+
authorizationUri: string;
|
|
127
|
+
/** Token URI for the provider. */
|
|
128
|
+
tokenUri: string;
|
|
129
|
+
/** Token revoke URI for the provider. */
|
|
130
|
+
tokenRevokeUri?: string;
|
|
131
|
+
/** Token refresh URI for the provider. */
|
|
132
|
+
tokenRefreshUri?: string;
|
|
133
|
+
/** User info URI for the provider. */
|
|
134
|
+
userInfoUri?: string;
|
|
135
|
+
/** User info authentication method for the provider. */
|
|
136
|
+
userInfoAuthenticationMethod?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.
|
|
139
|
+
* */
|
|
140
|
+
userNameAttribute?: string;
|
|
141
|
+
/** JWK set URI for the provider */
|
|
142
|
+
jwkSetUri?: string;
|
|
143
|
+
/**
|
|
144
|
+
* URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization
|
|
145
|
+
* Server Metadata endpoint defined by RFC 8414.
|
|
146
|
+
* */
|
|
147
|
+
issuerUri?: string;
|
|
148
|
+
/** Default scopes for the provider. */
|
|
149
|
+
defaultScope: string[];
|
|
150
|
+
/** step 1: generate authorization uri and redirect user to it */
|
|
151
|
+
createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;
|
|
152
|
+
/** step 2: exchange code for token */
|
|
153
|
+
exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;
|
|
154
|
+
/** step 3: get user info */
|
|
155
|
+
getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;
|
|
156
|
+
/** others: refresh access token */
|
|
157
|
+
refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;
|
|
158
|
+
/** others: revoke token */
|
|
159
|
+
revokeToken?: (params: RevokeTokenParams) => Promise<void>;
|
|
160
|
+
loginOAuth2Native?: (params: LoginOAuth2NativeParams) => Promise<{
|
|
161
|
+
token: OAuth2Token;
|
|
162
|
+
userInfo: UserInfo;
|
|
163
|
+
}>;
|
|
169
164
|
}
|
|
170
165
|
interface OneTapProvider extends Provider {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
getTokenInfo: (id_token: string) => Promise<{
|
|
167
|
+
token: OAuth2Token;
|
|
168
|
+
userInfo: UserInfo;
|
|
169
|
+
}>;
|
|
175
170
|
}
|
|
176
171
|
interface Registration {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'
|
|
174
|
+
* property or used one of the commonly used providers (google, github, facebook, okta).
|
|
175
|
+
* */
|
|
176
|
+
provider?: string;
|
|
177
|
+
/** Client ID for the registration. */
|
|
178
|
+
clientId: string;
|
|
179
|
+
/** Client secret of the registration. */
|
|
180
|
+
clientSecret: string;
|
|
181
|
+
/** Client authentication method. May be left blank when using a pre-defined provider. */
|
|
182
|
+
clientAuthenticationMethod?: string;
|
|
183
|
+
/** Authorization grant type. May be left blank when using a pre-defined provider. */
|
|
184
|
+
authorizationGrantType?: 'authorization_code' | 'client_credentials' | 'device_code' | 'jwt_bearer' | 'password' | 'refresh_token' | 'token_exchange';
|
|
185
|
+
/** Redirect URI. May be left blank when using a pre-defined provider. */
|
|
186
|
+
redirectUri?: string;
|
|
187
|
+
/** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */
|
|
188
|
+
scope?: string[];
|
|
189
|
+
/** Client name. May be left blank when using a pre-defined provider. */
|
|
190
|
+
clientName?: string;
|
|
196
191
|
}
|
|
197
192
|
interface OAuth2ClientConfig {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export {
|
|
193
|
+
baseUri: string;
|
|
194
|
+
errorUri: string;
|
|
195
|
+
successUri: string;
|
|
196
|
+
provider: {
|
|
197
|
+
[name: string]: Provider | undefined;
|
|
198
|
+
};
|
|
199
|
+
registration: {
|
|
200
|
+
[name: string]: Registration | undefined;
|
|
201
|
+
} | (() => Promise<{
|
|
202
|
+
[name: string]: Registration | undefined;
|
|
203
|
+
}>);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
export { ExchangeCodeParams, LoginOAuth2NativeParams, NativeCredential, OAuth2AuthorizationRequest, OAuth2ClientConfig, OAuth2Token, OIDC_SCOPES, OidcScope, OidcToken, OneTapProvider, PkceParameters, Provider, RefreshTokenParams, Registration, RevokeTokenParams, StandardClaims, UserInfo };
|
|
207
|
+
//# 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;;cAGW;KASD,oBAAoB;UAGf;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,207 @@
|
|
|
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 const OIDC_SCOPES: readonly ['openid', 'profile', 'email', 'phone', 'address', 'offline_access'];
|
|
90
|
+
type OidcScope = (typeof OIDC_SCOPES)[number];
|
|
91
|
+
interface StandardClaims {
|
|
92
|
+
sub: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
given_name?: string;
|
|
95
|
+
family_name?: string;
|
|
96
|
+
middle_name?: string;
|
|
97
|
+
nickname?: string;
|
|
98
|
+
preferred_username?: string;
|
|
99
|
+
profile?: string;
|
|
100
|
+
picture?: string;
|
|
101
|
+
website?: string;
|
|
102
|
+
email?: string;
|
|
103
|
+
email_verified?: boolean;
|
|
104
|
+
gender?: 'female' | 'male' | (string & {});
|
|
105
|
+
birthdate?: string;
|
|
106
|
+
zoneinfo?: string;
|
|
107
|
+
locale?: string;
|
|
108
|
+
phone_number?: string;
|
|
109
|
+
phone_number_verified?: boolean;
|
|
110
|
+
address?: {
|
|
111
|
+
formatted: string;
|
|
112
|
+
street_address: string;
|
|
113
|
+
locality: string;
|
|
114
|
+
region: string;
|
|
115
|
+
postal_code: string;
|
|
116
|
+
country: string;
|
|
117
|
+
};
|
|
118
|
+
updated_at?: number;
|
|
119
|
+
}
|
|
120
|
+
interface UserInfo<T = unknown> {
|
|
121
|
+
claims: StandardClaims;
|
|
122
|
+
data: T;
|
|
123
|
+
}
|
|
124
|
+
interface Provider {
|
|
125
|
+
/** Authorization URI for the provider. */
|
|
126
|
+
authorizationUri: string;
|
|
127
|
+
/** Token URI for the provider. */
|
|
128
|
+
tokenUri: string;
|
|
129
|
+
/** Token revoke URI for the provider. */
|
|
130
|
+
tokenRevokeUri?: string;
|
|
131
|
+
/** Token refresh URI for the provider. */
|
|
132
|
+
tokenRefreshUri?: string;
|
|
133
|
+
/** User info URI for the provider. */
|
|
134
|
+
userInfoUri?: string;
|
|
135
|
+
/** User info authentication method for the provider. */
|
|
136
|
+
userInfoAuthenticationMethod?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.
|
|
139
|
+
* */
|
|
140
|
+
userNameAttribute?: string;
|
|
141
|
+
/** JWK set URI for the provider */
|
|
142
|
+
jwkSetUri?: string;
|
|
143
|
+
/**
|
|
144
|
+
* URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization
|
|
145
|
+
* Server Metadata endpoint defined by RFC 8414.
|
|
146
|
+
* */
|
|
147
|
+
issuerUri?: string;
|
|
148
|
+
/** Default scopes for the provider. */
|
|
149
|
+
defaultScope: string[];
|
|
150
|
+
/** step 1: generate authorization uri and redirect user to it */
|
|
151
|
+
createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;
|
|
152
|
+
/** step 2: exchange code for token */
|
|
153
|
+
exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;
|
|
154
|
+
/** step 3: get user info */
|
|
155
|
+
getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;
|
|
156
|
+
/** others: refresh access token */
|
|
157
|
+
refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;
|
|
158
|
+
/** others: revoke token */
|
|
159
|
+
revokeToken?: (params: RevokeTokenParams) => Promise<void>;
|
|
160
|
+
loginOAuth2Native?: (params: LoginOAuth2NativeParams) => Promise<{
|
|
161
|
+
token: OAuth2Token;
|
|
162
|
+
userInfo: UserInfo;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
interface OneTapProvider extends Provider {
|
|
166
|
+
getTokenInfo: (id_token: string) => Promise<{
|
|
167
|
+
token: OAuth2Token;
|
|
168
|
+
userInfo: UserInfo;
|
|
169
|
+
}>;
|
|
170
|
+
}
|
|
171
|
+
interface Registration {
|
|
172
|
+
/**
|
|
173
|
+
* Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'
|
|
174
|
+
* property or used one of the commonly used providers (google, github, facebook, okta).
|
|
175
|
+
* */
|
|
176
|
+
provider?: string;
|
|
177
|
+
/** Client ID for the registration. */
|
|
178
|
+
clientId: string;
|
|
179
|
+
/** Client secret of the registration. */
|
|
180
|
+
clientSecret: string;
|
|
181
|
+
/** Client authentication method. May be left blank when using a pre-defined provider. */
|
|
182
|
+
clientAuthenticationMethod?: string;
|
|
183
|
+
/** Authorization grant type. May be left blank when using a pre-defined provider. */
|
|
184
|
+
authorizationGrantType?: 'authorization_code' | 'client_credentials' | 'device_code' | 'jwt_bearer' | 'password' | 'refresh_token' | 'token_exchange';
|
|
185
|
+
/** Redirect URI. May be left blank when using a pre-defined provider. */
|
|
186
|
+
redirectUri?: string;
|
|
187
|
+
/** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */
|
|
188
|
+
scope?: string[];
|
|
189
|
+
/** Client name. May be left blank when using a pre-defined provider. */
|
|
190
|
+
clientName?: string;
|
|
191
|
+
}
|
|
192
|
+
interface OAuth2ClientConfig {
|
|
193
|
+
baseUri: string;
|
|
194
|
+
errorUri: string;
|
|
195
|
+
successUri: string;
|
|
196
|
+
provider: {
|
|
197
|
+
[name: string]: Provider | undefined;
|
|
198
|
+
};
|
|
199
|
+
registration: {
|
|
200
|
+
[name: string]: Registration | undefined;
|
|
201
|
+
} | (() => Promise<{
|
|
202
|
+
[name: string]: Registration | undefined;
|
|
203
|
+
}>);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
export { ExchangeCodeParams, LoginOAuth2NativeParams, NativeCredential, OAuth2AuthorizationRequest, OAuth2ClientConfig, OAuth2Token, OIDC_SCOPES, OidcScope, OidcToken, OneTapProvider, PkceParameters, Provider, RefreshTokenParams, Registration, RevokeTokenParams, StandardClaims, UserInfo };
|
|
207
|
+
//# 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;;cAGW;KASD,oBAAoB;UAGf;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,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
};
|
|
1
|
+
//#region src/oauth2/types.ts
|
|
2
|
+
const OIDC_SCOPES = [
|
|
3
|
+
"openid",
|
|
4
|
+
"profile",
|
|
5
|
+
"email",
|
|
6
|
+
"phone",
|
|
7
|
+
"address",
|
|
8
|
+
"offline_access"
|
|
9
|
+
];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OIDC_SCOPES };
|
|
12
|
+
|
|
14
13
|
//# sourceMappingURL=types.mjs.map
|