@better-auth/core 1.3.26 → 1.3.28
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/.turbo/turbo-build.log +60 -9
- package/build.config.ts +7 -0
- package/dist/db/adapter/index.cjs +2 -0
- package/dist/db/adapter/index.d.cts +14 -0
- package/dist/db/adapter/index.d.mts +14 -0
- package/dist/db/adapter/index.d.ts +14 -0
- package/dist/db/adapter/index.mjs +1 -0
- package/dist/db/index.cjs +89 -0
- package/dist/db/index.d.cts +16 -107
- package/dist/db/index.d.mts +16 -107
- package/dist/db/index.d.ts +16 -107
- package/dist/db/index.mjs +69 -0
- package/dist/env/index.cjs +312 -0
- package/dist/env/index.d.cts +36 -0
- package/dist/env/index.d.mts +36 -0
- package/dist/env/index.d.ts +36 -0
- package/dist/env/index.mjs +297 -0
- package/dist/error/index.cjs +44 -0
- package/dist/error/index.d.cts +33 -0
- package/dist/error/index.d.mts +33 -0
- package/dist/error/index.d.ts +33 -0
- package/dist/error/index.mjs +41 -0
- package/dist/index.d.cts +179 -1
- package/dist/index.d.mts +179 -1
- package/dist/index.d.ts +179 -1
- package/dist/middleware/index.cjs +25 -0
- package/dist/middleware/index.d.cts +14 -0
- package/dist/middleware/index.d.mts +14 -0
- package/dist/middleware/index.d.ts +14 -0
- package/dist/middleware/index.mjs +21 -0
- package/dist/oauth2/index.cjs +368 -0
- package/dist/oauth2/index.d.cts +100 -0
- package/dist/oauth2/index.d.mts +100 -0
- package/dist/oauth2/index.d.ts +100 -0
- package/dist/oauth2/index.mjs +357 -0
- package/dist/shared/core.BJPBStdk.d.ts +1693 -0
- package/dist/shared/core.Bl6TpxyD.d.mts +181 -0
- package/dist/shared/core.Bqe5IGAi.d.ts +13 -0
- package/dist/shared/core.BwoNUcJQ.d.cts +53 -0
- package/dist/shared/core.BwoNUcJQ.d.mts +53 -0
- package/dist/shared/core.BwoNUcJQ.d.ts +53 -0
- package/dist/shared/core.CajxAutx.d.cts +143 -0
- package/dist/shared/core.CajxAutx.d.mts +143 -0
- package/dist/shared/core.CajxAutx.d.ts +143 -0
- package/dist/shared/core.CkkLHQWc.d.mts +1693 -0
- package/dist/shared/core.DkdZ1o38.d.ts +181 -0
- package/dist/shared/core.Dl-70uns.d.cts +84 -0
- package/dist/shared/core.Dl-70uns.d.mts +84 -0
- package/dist/shared/core.Dl-70uns.d.ts +84 -0
- package/dist/shared/core.DyEdx0m7.d.cts +181 -0
- package/dist/shared/core.E9DfzGLz.d.mts +13 -0
- package/dist/shared/core.HqYn20Fi.d.cts +13 -0
- package/dist/shared/core.gYIBmdi1.d.cts +1693 -0
- package/dist/social-providers/index.cjs +2793 -0
- package/dist/social-providers/index.d.cts +3903 -0
- package/dist/social-providers/index.d.mts +3903 -0
- package/dist/social-providers/index.d.ts +3903 -0
- package/dist/social-providers/index.mjs +2743 -0
- package/dist/utils/index.cjs +7 -0
- package/dist/utils/index.d.cts +10 -0
- package/dist/utils/index.d.mts +10 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.mjs +5 -0
- package/package.json +109 -2
- package/src/db/adapter/index.ts +448 -0
- package/src/db/index.ts +13 -0
- package/src/db/plugin.ts +11 -0
- package/src/db/schema/account.ts +34 -0
- package/src/db/schema/rate-limit.ts +21 -0
- package/src/db/schema/session.ts +17 -0
- package/src/db/schema/shared.ts +7 -0
- package/src/db/schema/user.ts +16 -0
- package/src/db/schema/verification.ts +15 -0
- package/src/db/type.ts +50 -0
- package/src/env/color-depth.ts +172 -0
- package/src/env/env-impl.ts +123 -0
- package/src/env/index.ts +23 -0
- package/src/env/logger.test.ts +33 -0
- package/src/env/logger.ts +145 -0
- package/src/error/codes.ts +31 -0
- package/src/error/index.ts +11 -0
- package/src/index.ts +1 -1
- package/src/middleware/index.ts +33 -0
- package/src/oauth2/client-credentials-token.ts +102 -0
- package/src/oauth2/create-authorization-url.ts +85 -0
- package/src/oauth2/index.ts +22 -0
- package/src/oauth2/oauth-provider.ts +194 -0
- package/src/oauth2/refresh-access-token.ts +124 -0
- package/src/oauth2/utils.ts +36 -0
- package/src/oauth2/validate-authorization-code.ts +156 -0
- package/src/social-providers/apple.ts +213 -0
- package/src/social-providers/atlassian.ts +130 -0
- package/src/social-providers/cognito.ts +269 -0
- package/src/social-providers/discord.ts +172 -0
- package/src/social-providers/dropbox.ts +112 -0
- package/src/social-providers/facebook.ts +204 -0
- package/src/social-providers/figma.ts +115 -0
- package/src/social-providers/github.ts +154 -0
- package/src/social-providers/gitlab.ts +152 -0
- package/src/social-providers/google.ts +171 -0
- package/src/social-providers/huggingface.ts +116 -0
- package/src/social-providers/index.ts +118 -0
- package/src/social-providers/kakao.ts +178 -0
- package/src/social-providers/kick.ts +95 -0
- package/src/social-providers/line.ts +169 -0
- package/src/social-providers/linear.ts +120 -0
- package/src/social-providers/linkedin.ts +110 -0
- package/src/social-providers/microsoft-entra-id.ts +243 -0
- package/src/social-providers/naver.ts +112 -0
- package/src/social-providers/notion.ts +106 -0
- package/src/social-providers/paypal.ts +261 -0
- package/src/social-providers/reddit.ts +122 -0
- package/src/social-providers/roblox.ts +110 -0
- package/src/social-providers/salesforce.ts +157 -0
- package/src/social-providers/slack.ts +114 -0
- package/src/social-providers/spotify.ts +93 -0
- package/src/social-providers/tiktok.ts +211 -0
- package/src/social-providers/twitch.ts +111 -0
- package/src/social-providers/twitter.ts +194 -0
- package/src/social-providers/vk.ts +128 -0
- package/src/social-providers/zoom.ts +218 -0
- package/src/types/context.ts +313 -0
- package/src/types/cookie.ts +7 -0
- package/src/types/helper.ts +5 -0
- package/src/types/index.ts +20 -1
- package/src/types/init-options.ts +1161 -0
- package/src/types/plugin-client.ts +69 -0
- package/src/types/plugin.ts +134 -0
- package/src/utils/error-codes.ts +51 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const base64 = require('@better-auth/utils/base64');
|
|
4
|
+
const fetch = require('@better-fetch/fetch');
|
|
5
|
+
const jose = require('jose');
|
|
6
|
+
|
|
7
|
+
function getOAuth2Tokens(data) {
|
|
8
|
+
const getDate = (seconds) => {
|
|
9
|
+
const now = /* @__PURE__ */ new Date();
|
|
10
|
+
return new Date(now.getTime() + seconds * 1e3);
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
tokenType: data.token_type,
|
|
14
|
+
accessToken: data.access_token,
|
|
15
|
+
refreshToken: data.refresh_token,
|
|
16
|
+
accessTokenExpiresAt: data.expires_in ? getDate(data.expires_in) : void 0,
|
|
17
|
+
refreshTokenExpiresAt: data.refresh_token_expires_in ? getDate(data.refresh_token_expires_in) : void 0,
|
|
18
|
+
scopes: data?.scope ? typeof data.scope === "string" ? data.scope.split(" ") : data.scope : [],
|
|
19
|
+
idToken: data.id_token
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function generateCodeChallenge(codeVerifier) {
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const data = encoder.encode(codeVerifier);
|
|
25
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
26
|
+
return base64.base64Url.encode(new Uint8Array(hash), {
|
|
27
|
+
padding: false
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function createAuthorizationURL({
|
|
32
|
+
id,
|
|
33
|
+
options,
|
|
34
|
+
authorizationEndpoint,
|
|
35
|
+
state,
|
|
36
|
+
codeVerifier,
|
|
37
|
+
scopes,
|
|
38
|
+
claims,
|
|
39
|
+
redirectURI,
|
|
40
|
+
duration,
|
|
41
|
+
prompt,
|
|
42
|
+
accessType,
|
|
43
|
+
responseType,
|
|
44
|
+
display,
|
|
45
|
+
loginHint,
|
|
46
|
+
hd,
|
|
47
|
+
responseMode,
|
|
48
|
+
additionalParams,
|
|
49
|
+
scopeJoiner
|
|
50
|
+
}) {
|
|
51
|
+
const url = new URL(authorizationEndpoint);
|
|
52
|
+
url.searchParams.set("response_type", responseType || "code");
|
|
53
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
54
|
+
url.searchParams.set("client_id", primaryClientId);
|
|
55
|
+
url.searchParams.set("state", state);
|
|
56
|
+
url.searchParams.set("scope", scopes.join(scopeJoiner || " "));
|
|
57
|
+
url.searchParams.set("redirect_uri", options.redirectURI || redirectURI);
|
|
58
|
+
duration && url.searchParams.set("duration", duration);
|
|
59
|
+
display && url.searchParams.set("display", display);
|
|
60
|
+
loginHint && url.searchParams.set("login_hint", loginHint);
|
|
61
|
+
prompt && url.searchParams.set("prompt", prompt);
|
|
62
|
+
hd && url.searchParams.set("hd", hd);
|
|
63
|
+
accessType && url.searchParams.set("access_type", accessType);
|
|
64
|
+
responseMode && url.searchParams.set("response_mode", responseMode);
|
|
65
|
+
if (codeVerifier) {
|
|
66
|
+
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
67
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
68
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
69
|
+
}
|
|
70
|
+
if (claims) {
|
|
71
|
+
const claimsObj = claims.reduce(
|
|
72
|
+
(acc, claim) => {
|
|
73
|
+
acc[claim] = null;
|
|
74
|
+
return acc;
|
|
75
|
+
},
|
|
76
|
+
{}
|
|
77
|
+
);
|
|
78
|
+
url.searchParams.set(
|
|
79
|
+
"claims",
|
|
80
|
+
JSON.stringify({
|
|
81
|
+
id_token: { email: null, email_verified: null, ...claimsObj }
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (additionalParams) {
|
|
86
|
+
Object.entries(additionalParams).forEach(([key, value]) => {
|
|
87
|
+
url.searchParams.set(key, value);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return url;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function createAuthorizationCodeRequest({
|
|
94
|
+
code,
|
|
95
|
+
codeVerifier,
|
|
96
|
+
redirectURI,
|
|
97
|
+
options,
|
|
98
|
+
authentication,
|
|
99
|
+
deviceId,
|
|
100
|
+
headers,
|
|
101
|
+
additionalParams = {},
|
|
102
|
+
resource
|
|
103
|
+
}) {
|
|
104
|
+
const body = new URLSearchParams();
|
|
105
|
+
const requestHeaders = {
|
|
106
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
107
|
+
accept: "application/json",
|
|
108
|
+
"user-agent": "better-auth",
|
|
109
|
+
...headers
|
|
110
|
+
};
|
|
111
|
+
body.set("grant_type", "authorization_code");
|
|
112
|
+
body.set("code", code);
|
|
113
|
+
codeVerifier && body.set("code_verifier", codeVerifier);
|
|
114
|
+
options.clientKey && body.set("client_key", options.clientKey);
|
|
115
|
+
deviceId && body.set("device_id", deviceId);
|
|
116
|
+
body.set("redirect_uri", options.redirectURI || redirectURI);
|
|
117
|
+
if (resource) {
|
|
118
|
+
if (typeof resource === "string") {
|
|
119
|
+
body.append("resource", resource);
|
|
120
|
+
} else {
|
|
121
|
+
for (const _resource of resource) {
|
|
122
|
+
body.append("resource", _resource);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (authentication === "basic") {
|
|
127
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
128
|
+
const encodedCredentials = base64.base64.encode(
|
|
129
|
+
`${primaryClientId}:${options.clientSecret ?? ""}`
|
|
130
|
+
);
|
|
131
|
+
requestHeaders["authorization"] = `Basic ${encodedCredentials}`;
|
|
132
|
+
} else {
|
|
133
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
134
|
+
body.set("client_id", primaryClientId);
|
|
135
|
+
if (options.clientSecret) {
|
|
136
|
+
body.set("client_secret", options.clientSecret);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const [key, value] of Object.entries(additionalParams)) {
|
|
140
|
+
if (!body.has(key)) body.append(key, value);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
body,
|
|
144
|
+
headers: requestHeaders
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async function validateAuthorizationCode({
|
|
148
|
+
code,
|
|
149
|
+
codeVerifier,
|
|
150
|
+
redirectURI,
|
|
151
|
+
options,
|
|
152
|
+
tokenEndpoint,
|
|
153
|
+
authentication,
|
|
154
|
+
deviceId,
|
|
155
|
+
headers,
|
|
156
|
+
additionalParams = {},
|
|
157
|
+
resource
|
|
158
|
+
}) {
|
|
159
|
+
const { body, headers: requestHeaders } = createAuthorizationCodeRequest({
|
|
160
|
+
code,
|
|
161
|
+
codeVerifier,
|
|
162
|
+
redirectURI,
|
|
163
|
+
options,
|
|
164
|
+
authentication,
|
|
165
|
+
deviceId,
|
|
166
|
+
headers,
|
|
167
|
+
additionalParams,
|
|
168
|
+
resource
|
|
169
|
+
});
|
|
170
|
+
const { data, error } = await fetch.betterFetch(tokenEndpoint, {
|
|
171
|
+
method: "POST",
|
|
172
|
+
body,
|
|
173
|
+
headers: requestHeaders
|
|
174
|
+
});
|
|
175
|
+
if (error) {
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
const tokens = getOAuth2Tokens(data);
|
|
179
|
+
return tokens;
|
|
180
|
+
}
|
|
181
|
+
async function validateToken(token, jwksEndpoint) {
|
|
182
|
+
const { data, error } = await fetch.betterFetch(jwksEndpoint, {
|
|
183
|
+
method: "GET",
|
|
184
|
+
headers: {
|
|
185
|
+
accept: "application/json",
|
|
186
|
+
"user-agent": "better-auth"
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
if (error) {
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
const keys = data["keys"];
|
|
193
|
+
const header = JSON.parse(atob(token.split(".")[0]));
|
|
194
|
+
const key = keys.find((key2) => key2.kid === header.kid);
|
|
195
|
+
if (!key) {
|
|
196
|
+
throw new Error("Key not found");
|
|
197
|
+
}
|
|
198
|
+
const verified = await jose.jwtVerify(token, key);
|
|
199
|
+
return verified;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function createRefreshAccessTokenRequest({
|
|
203
|
+
refreshToken,
|
|
204
|
+
options,
|
|
205
|
+
authentication,
|
|
206
|
+
extraParams,
|
|
207
|
+
resource
|
|
208
|
+
}) {
|
|
209
|
+
const body = new URLSearchParams();
|
|
210
|
+
const headers = {
|
|
211
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
212
|
+
accept: "application/json"
|
|
213
|
+
};
|
|
214
|
+
body.set("grant_type", "refresh_token");
|
|
215
|
+
body.set("refresh_token", refreshToken);
|
|
216
|
+
if (authentication === "basic") {
|
|
217
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
218
|
+
if (primaryClientId) {
|
|
219
|
+
headers["authorization"] = "Basic " + base64.base64.encode(`${primaryClientId}:${options.clientSecret ?? ""}`);
|
|
220
|
+
} else {
|
|
221
|
+
headers["authorization"] = "Basic " + base64.base64.encode(`:${options.clientSecret ?? ""}`);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
225
|
+
body.set("client_id", primaryClientId);
|
|
226
|
+
if (options.clientSecret) {
|
|
227
|
+
body.set("client_secret", options.clientSecret);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (resource) {
|
|
231
|
+
if (typeof resource === "string") {
|
|
232
|
+
body.append("resource", resource);
|
|
233
|
+
} else {
|
|
234
|
+
for (const _resource of resource) {
|
|
235
|
+
body.append("resource", _resource);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (extraParams) {
|
|
240
|
+
for (const [key, value] of Object.entries(extraParams)) {
|
|
241
|
+
body.set(key, value);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
body,
|
|
246
|
+
headers
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
async function refreshAccessToken({
|
|
250
|
+
refreshToken,
|
|
251
|
+
options,
|
|
252
|
+
tokenEndpoint,
|
|
253
|
+
authentication,
|
|
254
|
+
extraParams
|
|
255
|
+
}) {
|
|
256
|
+
const { body, headers } = createRefreshAccessTokenRequest({
|
|
257
|
+
refreshToken,
|
|
258
|
+
options,
|
|
259
|
+
authentication,
|
|
260
|
+
extraParams
|
|
261
|
+
});
|
|
262
|
+
const { data, error } = await fetch.betterFetch(tokenEndpoint, {
|
|
263
|
+
method: "POST",
|
|
264
|
+
body,
|
|
265
|
+
headers
|
|
266
|
+
});
|
|
267
|
+
if (error) {
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
const tokens = {
|
|
271
|
+
accessToken: data.access_token,
|
|
272
|
+
refreshToken: data.refresh_token,
|
|
273
|
+
tokenType: data.token_type,
|
|
274
|
+
scopes: data.scope?.split(" "),
|
|
275
|
+
idToken: data.id_token
|
|
276
|
+
};
|
|
277
|
+
if (data.expires_in) {
|
|
278
|
+
const now = /* @__PURE__ */ new Date();
|
|
279
|
+
tokens.accessTokenExpiresAt = new Date(
|
|
280
|
+
now.getTime() + data.expires_in * 1e3
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return tokens;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function createClientCredentialsTokenRequest({
|
|
287
|
+
options,
|
|
288
|
+
scope,
|
|
289
|
+
authentication,
|
|
290
|
+
resource
|
|
291
|
+
}) {
|
|
292
|
+
const body = new URLSearchParams();
|
|
293
|
+
const headers = {
|
|
294
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
295
|
+
accept: "application/json"
|
|
296
|
+
};
|
|
297
|
+
body.set("grant_type", "client_credentials");
|
|
298
|
+
scope && body.set("scope", scope);
|
|
299
|
+
if (resource) {
|
|
300
|
+
if (typeof resource === "string") {
|
|
301
|
+
body.append("resource", resource);
|
|
302
|
+
} else {
|
|
303
|
+
for (const _resource of resource) {
|
|
304
|
+
body.append("resource", _resource);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (authentication === "basic") {
|
|
309
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
310
|
+
const encodedCredentials = base64.base64Url.encode(
|
|
311
|
+
`${primaryClientId}:${options.clientSecret}`
|
|
312
|
+
);
|
|
313
|
+
headers["authorization"] = `Basic ${encodedCredentials}`;
|
|
314
|
+
} else {
|
|
315
|
+
const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
|
|
316
|
+
body.set("client_id", primaryClientId);
|
|
317
|
+
body.set("client_secret", options.clientSecret);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
body,
|
|
321
|
+
headers
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
async function clientCredentialsToken({
|
|
325
|
+
options,
|
|
326
|
+
tokenEndpoint,
|
|
327
|
+
scope,
|
|
328
|
+
authentication,
|
|
329
|
+
resource
|
|
330
|
+
}) {
|
|
331
|
+
const { body, headers } = createClientCredentialsTokenRequest({
|
|
332
|
+
options,
|
|
333
|
+
scope,
|
|
334
|
+
authentication,
|
|
335
|
+
resource
|
|
336
|
+
});
|
|
337
|
+
const { data, error } = await fetch.betterFetch(tokenEndpoint, {
|
|
338
|
+
method: "POST",
|
|
339
|
+
body,
|
|
340
|
+
headers
|
|
341
|
+
});
|
|
342
|
+
if (error) {
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
const tokens = {
|
|
346
|
+
accessToken: data.access_token,
|
|
347
|
+
tokenType: data.token_type,
|
|
348
|
+
scopes: data.scope?.split(" ")
|
|
349
|
+
};
|
|
350
|
+
if (data.expires_in) {
|
|
351
|
+
const now = /* @__PURE__ */ new Date();
|
|
352
|
+
tokens.accessTokenExpiresAt = new Date(
|
|
353
|
+
now.getTime() + data.expires_in * 1e3
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
return tokens;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
exports.clientCredentialsToken = clientCredentialsToken;
|
|
360
|
+
exports.createAuthorizationCodeRequest = createAuthorizationCodeRequest;
|
|
361
|
+
exports.createAuthorizationURL = createAuthorizationURL;
|
|
362
|
+
exports.createClientCredentialsTokenRequest = createClientCredentialsTokenRequest;
|
|
363
|
+
exports.createRefreshAccessTokenRequest = createRefreshAccessTokenRequest;
|
|
364
|
+
exports.generateCodeChallenge = generateCodeChallenge;
|
|
365
|
+
exports.getOAuth2Tokens = getOAuth2Tokens;
|
|
366
|
+
exports.refreshAccessToken = refreshAccessToken;
|
|
367
|
+
exports.validateAuthorizationCode = validateAuthorizationCode;
|
|
368
|
+
exports.validateToken = validateToken;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { O as OAuth2Tokens, P as ProviderOptions } from '../shared/core.DyEdx0m7.cjs';
|
|
2
|
+
export { b as OAuth2UserInfo, a as OAuthProvider } from '../shared/core.DyEdx0m7.cjs';
|
|
3
|
+
import * as jose from 'jose';
|
|
4
|
+
import '../shared/core.CajxAutx.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
declare function getOAuth2Tokens(data: Record<string, any>): OAuth2Tokens;
|
|
8
|
+
declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
|
|
9
|
+
|
|
10
|
+
declare function createAuthorizationURL({ id, options, authorizationEndpoint, state, codeVerifier, scopes, claims, redirectURI, duration, prompt, accessType, responseType, display, loginHint, hd, responseMode, additionalParams, scopeJoiner, }: {
|
|
11
|
+
id: string;
|
|
12
|
+
options: ProviderOptions;
|
|
13
|
+
redirectURI: string;
|
|
14
|
+
authorizationEndpoint: string;
|
|
15
|
+
state: string;
|
|
16
|
+
codeVerifier?: string;
|
|
17
|
+
scopes: string[];
|
|
18
|
+
claims?: string[];
|
|
19
|
+
duration?: string;
|
|
20
|
+
prompt?: string;
|
|
21
|
+
accessType?: string;
|
|
22
|
+
responseType?: string;
|
|
23
|
+
display?: string;
|
|
24
|
+
loginHint?: string;
|
|
25
|
+
hd?: string;
|
|
26
|
+
responseMode?: string;
|
|
27
|
+
additionalParams?: Record<string, string>;
|
|
28
|
+
scopeJoiner?: string;
|
|
29
|
+
}): Promise<URL>;
|
|
30
|
+
|
|
31
|
+
declare function createAuthorizationCodeRequest({ code, codeVerifier, redirectURI, options, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
32
|
+
code: string;
|
|
33
|
+
redirectURI: string;
|
|
34
|
+
options: Partial<ProviderOptions>;
|
|
35
|
+
codeVerifier?: string;
|
|
36
|
+
deviceId?: string;
|
|
37
|
+
authentication?: "basic" | "post";
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
additionalParams?: Record<string, string>;
|
|
40
|
+
resource?: string | string[];
|
|
41
|
+
}): {
|
|
42
|
+
body: URLSearchParams;
|
|
43
|
+
headers: Record<string, any>;
|
|
44
|
+
};
|
|
45
|
+
declare function validateAuthorizationCode({ code, codeVerifier, redirectURI, options, tokenEndpoint, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
46
|
+
code: string;
|
|
47
|
+
redirectURI: string;
|
|
48
|
+
options: Partial<ProviderOptions>;
|
|
49
|
+
codeVerifier?: string;
|
|
50
|
+
deviceId?: string;
|
|
51
|
+
tokenEndpoint: string;
|
|
52
|
+
authentication?: "basic" | "post";
|
|
53
|
+
headers?: Record<string, string>;
|
|
54
|
+
additionalParams?: Record<string, string>;
|
|
55
|
+
resource?: string | string[];
|
|
56
|
+
}): Promise<OAuth2Tokens>;
|
|
57
|
+
declare function validateToken(token: string, jwksEndpoint: string): Promise<jose.JWTVerifyResult<jose.JWTPayload>>;
|
|
58
|
+
|
|
59
|
+
declare function createRefreshAccessTokenRequest({ refreshToken, options, authentication, extraParams, resource, }: {
|
|
60
|
+
refreshToken: string;
|
|
61
|
+
options: Partial<ProviderOptions>;
|
|
62
|
+
authentication?: "basic" | "post";
|
|
63
|
+
extraParams?: Record<string, string>;
|
|
64
|
+
resource?: string | string[];
|
|
65
|
+
}): {
|
|
66
|
+
body: URLSearchParams;
|
|
67
|
+
headers: Record<string, any>;
|
|
68
|
+
};
|
|
69
|
+
declare function refreshAccessToken({ refreshToken, options, tokenEndpoint, authentication, extraParams, }: {
|
|
70
|
+
refreshToken: string;
|
|
71
|
+
options: Partial<ProviderOptions>;
|
|
72
|
+
tokenEndpoint: string;
|
|
73
|
+
authentication?: "basic" | "post";
|
|
74
|
+
extraParams?: Record<string, string>;
|
|
75
|
+
/** @deprecated always "refresh_token" */
|
|
76
|
+
grantType?: string;
|
|
77
|
+
}): Promise<OAuth2Tokens>;
|
|
78
|
+
|
|
79
|
+
declare function createClientCredentialsTokenRequest({ options, scope, authentication, resource, }: {
|
|
80
|
+
options: ProviderOptions & {
|
|
81
|
+
clientSecret: string;
|
|
82
|
+
};
|
|
83
|
+
scope?: string;
|
|
84
|
+
authentication?: "basic" | "post";
|
|
85
|
+
resource?: string | string[];
|
|
86
|
+
}): {
|
|
87
|
+
body: URLSearchParams;
|
|
88
|
+
headers: Record<string, any>;
|
|
89
|
+
};
|
|
90
|
+
declare function clientCredentialsToken({ options, tokenEndpoint, scope, authentication, resource, }: {
|
|
91
|
+
options: ProviderOptions & {
|
|
92
|
+
clientSecret: string;
|
|
93
|
+
};
|
|
94
|
+
tokenEndpoint: string;
|
|
95
|
+
scope: string;
|
|
96
|
+
authentication?: "basic" | "post";
|
|
97
|
+
resource?: string | string[];
|
|
98
|
+
}): Promise<OAuth2Tokens>;
|
|
99
|
+
|
|
100
|
+
export { OAuth2Tokens, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { O as OAuth2Tokens, P as ProviderOptions } from '../shared/core.Bl6TpxyD.mjs';
|
|
2
|
+
export { b as OAuth2UserInfo, a as OAuthProvider } from '../shared/core.Bl6TpxyD.mjs';
|
|
3
|
+
import * as jose from 'jose';
|
|
4
|
+
import '../shared/core.CajxAutx.mjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
declare function getOAuth2Tokens(data: Record<string, any>): OAuth2Tokens;
|
|
8
|
+
declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
|
|
9
|
+
|
|
10
|
+
declare function createAuthorizationURL({ id, options, authorizationEndpoint, state, codeVerifier, scopes, claims, redirectURI, duration, prompt, accessType, responseType, display, loginHint, hd, responseMode, additionalParams, scopeJoiner, }: {
|
|
11
|
+
id: string;
|
|
12
|
+
options: ProviderOptions;
|
|
13
|
+
redirectURI: string;
|
|
14
|
+
authorizationEndpoint: string;
|
|
15
|
+
state: string;
|
|
16
|
+
codeVerifier?: string;
|
|
17
|
+
scopes: string[];
|
|
18
|
+
claims?: string[];
|
|
19
|
+
duration?: string;
|
|
20
|
+
prompt?: string;
|
|
21
|
+
accessType?: string;
|
|
22
|
+
responseType?: string;
|
|
23
|
+
display?: string;
|
|
24
|
+
loginHint?: string;
|
|
25
|
+
hd?: string;
|
|
26
|
+
responseMode?: string;
|
|
27
|
+
additionalParams?: Record<string, string>;
|
|
28
|
+
scopeJoiner?: string;
|
|
29
|
+
}): Promise<URL>;
|
|
30
|
+
|
|
31
|
+
declare function createAuthorizationCodeRequest({ code, codeVerifier, redirectURI, options, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
32
|
+
code: string;
|
|
33
|
+
redirectURI: string;
|
|
34
|
+
options: Partial<ProviderOptions>;
|
|
35
|
+
codeVerifier?: string;
|
|
36
|
+
deviceId?: string;
|
|
37
|
+
authentication?: "basic" | "post";
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
additionalParams?: Record<string, string>;
|
|
40
|
+
resource?: string | string[];
|
|
41
|
+
}): {
|
|
42
|
+
body: URLSearchParams;
|
|
43
|
+
headers: Record<string, any>;
|
|
44
|
+
};
|
|
45
|
+
declare function validateAuthorizationCode({ code, codeVerifier, redirectURI, options, tokenEndpoint, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
46
|
+
code: string;
|
|
47
|
+
redirectURI: string;
|
|
48
|
+
options: Partial<ProviderOptions>;
|
|
49
|
+
codeVerifier?: string;
|
|
50
|
+
deviceId?: string;
|
|
51
|
+
tokenEndpoint: string;
|
|
52
|
+
authentication?: "basic" | "post";
|
|
53
|
+
headers?: Record<string, string>;
|
|
54
|
+
additionalParams?: Record<string, string>;
|
|
55
|
+
resource?: string | string[];
|
|
56
|
+
}): Promise<OAuth2Tokens>;
|
|
57
|
+
declare function validateToken(token: string, jwksEndpoint: string): Promise<jose.JWTVerifyResult<jose.JWTPayload>>;
|
|
58
|
+
|
|
59
|
+
declare function createRefreshAccessTokenRequest({ refreshToken, options, authentication, extraParams, resource, }: {
|
|
60
|
+
refreshToken: string;
|
|
61
|
+
options: Partial<ProviderOptions>;
|
|
62
|
+
authentication?: "basic" | "post";
|
|
63
|
+
extraParams?: Record<string, string>;
|
|
64
|
+
resource?: string | string[];
|
|
65
|
+
}): {
|
|
66
|
+
body: URLSearchParams;
|
|
67
|
+
headers: Record<string, any>;
|
|
68
|
+
};
|
|
69
|
+
declare function refreshAccessToken({ refreshToken, options, tokenEndpoint, authentication, extraParams, }: {
|
|
70
|
+
refreshToken: string;
|
|
71
|
+
options: Partial<ProviderOptions>;
|
|
72
|
+
tokenEndpoint: string;
|
|
73
|
+
authentication?: "basic" | "post";
|
|
74
|
+
extraParams?: Record<string, string>;
|
|
75
|
+
/** @deprecated always "refresh_token" */
|
|
76
|
+
grantType?: string;
|
|
77
|
+
}): Promise<OAuth2Tokens>;
|
|
78
|
+
|
|
79
|
+
declare function createClientCredentialsTokenRequest({ options, scope, authentication, resource, }: {
|
|
80
|
+
options: ProviderOptions & {
|
|
81
|
+
clientSecret: string;
|
|
82
|
+
};
|
|
83
|
+
scope?: string;
|
|
84
|
+
authentication?: "basic" | "post";
|
|
85
|
+
resource?: string | string[];
|
|
86
|
+
}): {
|
|
87
|
+
body: URLSearchParams;
|
|
88
|
+
headers: Record<string, any>;
|
|
89
|
+
};
|
|
90
|
+
declare function clientCredentialsToken({ options, tokenEndpoint, scope, authentication, resource, }: {
|
|
91
|
+
options: ProviderOptions & {
|
|
92
|
+
clientSecret: string;
|
|
93
|
+
};
|
|
94
|
+
tokenEndpoint: string;
|
|
95
|
+
scope: string;
|
|
96
|
+
authentication?: "basic" | "post";
|
|
97
|
+
resource?: string | string[];
|
|
98
|
+
}): Promise<OAuth2Tokens>;
|
|
99
|
+
|
|
100
|
+
export { OAuth2Tokens, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { O as OAuth2Tokens, P as ProviderOptions } from '../shared/core.DkdZ1o38.js';
|
|
2
|
+
export { b as OAuth2UserInfo, a as OAuthProvider } from '../shared/core.DkdZ1o38.js';
|
|
3
|
+
import * as jose from 'jose';
|
|
4
|
+
import '../shared/core.CajxAutx.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
declare function getOAuth2Tokens(data: Record<string, any>): OAuth2Tokens;
|
|
8
|
+
declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
|
|
9
|
+
|
|
10
|
+
declare function createAuthorizationURL({ id, options, authorizationEndpoint, state, codeVerifier, scopes, claims, redirectURI, duration, prompt, accessType, responseType, display, loginHint, hd, responseMode, additionalParams, scopeJoiner, }: {
|
|
11
|
+
id: string;
|
|
12
|
+
options: ProviderOptions;
|
|
13
|
+
redirectURI: string;
|
|
14
|
+
authorizationEndpoint: string;
|
|
15
|
+
state: string;
|
|
16
|
+
codeVerifier?: string;
|
|
17
|
+
scopes: string[];
|
|
18
|
+
claims?: string[];
|
|
19
|
+
duration?: string;
|
|
20
|
+
prompt?: string;
|
|
21
|
+
accessType?: string;
|
|
22
|
+
responseType?: string;
|
|
23
|
+
display?: string;
|
|
24
|
+
loginHint?: string;
|
|
25
|
+
hd?: string;
|
|
26
|
+
responseMode?: string;
|
|
27
|
+
additionalParams?: Record<string, string>;
|
|
28
|
+
scopeJoiner?: string;
|
|
29
|
+
}): Promise<URL>;
|
|
30
|
+
|
|
31
|
+
declare function createAuthorizationCodeRequest({ code, codeVerifier, redirectURI, options, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
32
|
+
code: string;
|
|
33
|
+
redirectURI: string;
|
|
34
|
+
options: Partial<ProviderOptions>;
|
|
35
|
+
codeVerifier?: string;
|
|
36
|
+
deviceId?: string;
|
|
37
|
+
authentication?: "basic" | "post";
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
additionalParams?: Record<string, string>;
|
|
40
|
+
resource?: string | string[];
|
|
41
|
+
}): {
|
|
42
|
+
body: URLSearchParams;
|
|
43
|
+
headers: Record<string, any>;
|
|
44
|
+
};
|
|
45
|
+
declare function validateAuthorizationCode({ code, codeVerifier, redirectURI, options, tokenEndpoint, authentication, deviceId, headers, additionalParams, resource, }: {
|
|
46
|
+
code: string;
|
|
47
|
+
redirectURI: string;
|
|
48
|
+
options: Partial<ProviderOptions>;
|
|
49
|
+
codeVerifier?: string;
|
|
50
|
+
deviceId?: string;
|
|
51
|
+
tokenEndpoint: string;
|
|
52
|
+
authentication?: "basic" | "post";
|
|
53
|
+
headers?: Record<string, string>;
|
|
54
|
+
additionalParams?: Record<string, string>;
|
|
55
|
+
resource?: string | string[];
|
|
56
|
+
}): Promise<OAuth2Tokens>;
|
|
57
|
+
declare function validateToken(token: string, jwksEndpoint: string): Promise<jose.JWTVerifyResult<jose.JWTPayload>>;
|
|
58
|
+
|
|
59
|
+
declare function createRefreshAccessTokenRequest({ refreshToken, options, authentication, extraParams, resource, }: {
|
|
60
|
+
refreshToken: string;
|
|
61
|
+
options: Partial<ProviderOptions>;
|
|
62
|
+
authentication?: "basic" | "post";
|
|
63
|
+
extraParams?: Record<string, string>;
|
|
64
|
+
resource?: string | string[];
|
|
65
|
+
}): {
|
|
66
|
+
body: URLSearchParams;
|
|
67
|
+
headers: Record<string, any>;
|
|
68
|
+
};
|
|
69
|
+
declare function refreshAccessToken({ refreshToken, options, tokenEndpoint, authentication, extraParams, }: {
|
|
70
|
+
refreshToken: string;
|
|
71
|
+
options: Partial<ProviderOptions>;
|
|
72
|
+
tokenEndpoint: string;
|
|
73
|
+
authentication?: "basic" | "post";
|
|
74
|
+
extraParams?: Record<string, string>;
|
|
75
|
+
/** @deprecated always "refresh_token" */
|
|
76
|
+
grantType?: string;
|
|
77
|
+
}): Promise<OAuth2Tokens>;
|
|
78
|
+
|
|
79
|
+
declare function createClientCredentialsTokenRequest({ options, scope, authentication, resource, }: {
|
|
80
|
+
options: ProviderOptions & {
|
|
81
|
+
clientSecret: string;
|
|
82
|
+
};
|
|
83
|
+
scope?: string;
|
|
84
|
+
authentication?: "basic" | "post";
|
|
85
|
+
resource?: string | string[];
|
|
86
|
+
}): {
|
|
87
|
+
body: URLSearchParams;
|
|
88
|
+
headers: Record<string, any>;
|
|
89
|
+
};
|
|
90
|
+
declare function clientCredentialsToken({ options, tokenEndpoint, scope, authentication, resource, }: {
|
|
91
|
+
options: ProviderOptions & {
|
|
92
|
+
clientSecret: string;
|
|
93
|
+
};
|
|
94
|
+
tokenEndpoint: string;
|
|
95
|
+
scope: string;
|
|
96
|
+
authentication?: "basic" | "post";
|
|
97
|
+
resource?: string | string[];
|
|
98
|
+
}): Promise<OAuth2Tokens>;
|
|
99
|
+
|
|
100
|
+
export { OAuth2Tokens, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|