@aura-stack/auth 0.2.0 → 0.4.0-rc.1
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/@types/index.d.ts +3 -2
- package/dist/@types/router.d.d.ts +3 -2
- package/dist/actions/callback/access-token.cjs +52 -41
- package/dist/actions/callback/access-token.d.ts +5 -4
- package/dist/actions/callback/access-token.js +3 -2
- package/dist/actions/callback/callback.cjs +69 -52
- package/dist/actions/callback/callback.d.ts +26 -3
- package/dist/actions/callback/callback.js +6 -5
- package/dist/actions/callback/userinfo.cjs +54 -43
- package/dist/actions/callback/userinfo.d.ts +3 -2
- package/dist/actions/callback/userinfo.js +3 -2
- package/dist/actions/csrfToken/csrfToken.cjs +2 -2
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -1
- package/dist/actions/csrfToken/csrfToken.js +2 -2
- package/dist/actions/index.cjs +93 -71
- package/dist/actions/index.d.ts +3 -2
- package/dist/actions/index.js +15 -14
- package/dist/actions/session/session.d.ts +3 -1
- package/dist/actions/session/session.js +2 -2
- package/dist/actions/signIn/authorization.cjs +40 -40
- package/dist/actions/signIn/authorization.d.ts +3 -2
- package/dist/actions/signIn/authorization.js +2 -2
- package/dist/actions/signIn/signIn.cjs +63 -50
- package/dist/actions/signIn/signIn.d.ts +25 -3
- package/dist/actions/signIn/signIn.js +4 -3
- package/dist/actions/signOut/signOut.cjs +66 -66
- package/dist/actions/signOut/signOut.d.ts +9 -1
- package/dist/actions/signOut/signOut.js +4 -4
- package/dist/assert.d.ts +3 -2
- package/dist/{chunk-2RXNXMCZ.js → chunk-3EUWD5BB.js} +15 -7
- package/dist/{chunk-NEVKX6K2.js → chunk-A3N4PVAT.js} +3 -3
- package/dist/chunk-B737EUJV.js +22 -0
- package/dist/{chunk-7H3OR6UU.js → chunk-EMKJA2GJ.js} +18 -10
- package/dist/{chunk-4V4JNXVF.js → chunk-GA2SMTJO.js} +9 -6
- package/dist/chunk-HP34YGGJ.js +22 -0
- package/dist/{chunk-QDO2KSRJ.js → chunk-HT4YLL7N.js} +1 -1
- package/dist/{chunk-ZLR3LI6X.js → chunk-IVET23KF.js} +7 -4
- package/dist/{chunk-PTJUYB33.js → chunk-JVFTCTTE.js} +1 -1
- package/dist/{chunk-UEH3LVON.js → chunk-KSWLO5ZU.js} +21 -16
- package/dist/{chunk-QEZL7EYN.js → chunk-N4SX7TZT.js} +3 -3
- package/dist/{chunk-IMICRJ5U.js → chunk-W6LG7BFW.js} +14 -14
- package/dist/{chunk-WD7AUHQ5.js → chunk-YRCB5FLE.js} +8 -8
- package/dist/chunk-ZNCZVF6U.js +14 -0
- package/dist/cookie.cjs +14 -14
- package/dist/cookie.d.ts +3 -2
- package/dist/cookie.js +1 -1
- package/dist/errors.d.ts +3 -2
- package/dist/{index-EqsoyjrF.d.ts → index-B8jeIElf.d.ts} +57 -8
- package/dist/index.cjs +159 -95
- package/dist/index.d.ts +66 -5
- package/dist/index.js +23 -19
- package/dist/jose.cjs +2 -2
- package/dist/oauth/bitbucket.d.ts +3 -2
- package/dist/oauth/discord.d.ts +3 -2
- package/dist/oauth/figma.d.ts +3 -2
- package/dist/oauth/github.d.ts +3 -2
- package/dist/oauth/gitlab.d.ts +3 -2
- package/dist/oauth/index.cjs +85 -41
- package/dist/oauth/index.d.ts +3 -2
- package/dist/oauth/index.js +16 -8
- package/dist/oauth/mailchimp.cjs +46 -0
- package/dist/oauth/mailchimp.d.ts +7 -0
- package/dist/oauth/mailchimp.js +6 -0
- package/dist/oauth/pinterest.cjs +46 -0
- package/dist/oauth/pinterest.d.ts +7 -0
- package/dist/oauth/pinterest.js +6 -0
- package/dist/oauth/spotify.d.ts +3 -2
- package/dist/oauth/strava.d.ts +3 -2
- package/dist/oauth/x.d.ts +3 -2
- package/dist/request.cjs +38 -0
- package/dist/request.d.ts +13 -0
- package/dist/request.js +6 -0
- package/dist/schemas.cjs +40 -40
- package/dist/schemas.d.ts +15 -15
- package/dist/schemas.js +1 -1
- package/dist/secure.cjs +5 -5
- package/dist/secure.d.ts +3 -2
- package/dist/utils.d.ts +3 -3
- package/package.json +7 -5
|
@@ -33,11 +33,19 @@ __export(signIn_exports, {
|
|
|
33
33
|
signInAction: () => signInAction
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(signIn_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_zod2 = require("zod");
|
|
37
37
|
var import_router2 = require("@aura-stack/router");
|
|
38
38
|
|
|
39
|
+
// src/headers.ts
|
|
40
|
+
var cacheControl = {
|
|
41
|
+
"Cache-Control": "no-store",
|
|
42
|
+
Pragma: "no-cache",
|
|
43
|
+
Expires: "0",
|
|
44
|
+
Vary: "Cookie"
|
|
45
|
+
};
|
|
46
|
+
|
|
39
47
|
// src/secure.ts
|
|
40
|
-
var
|
|
48
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
49
|
|
|
42
50
|
// src/utils.ts
|
|
43
51
|
var import_router = require("@aura-stack/router");
|
|
@@ -152,10 +160,10 @@ var isValidURL = (value) => {
|
|
|
152
160
|
|
|
153
161
|
// src/secure.ts
|
|
154
162
|
var generateSecure = (length = 32) => {
|
|
155
|
-
return
|
|
163
|
+
return import_crypto.default.randomBytes(length).toString("base64url");
|
|
156
164
|
};
|
|
157
165
|
var createHash = (data, base = "hex") => {
|
|
158
|
-
return
|
|
166
|
+
return import_crypto.default.createHash("sha256").update(data).digest().toString(base);
|
|
159
167
|
};
|
|
160
168
|
var createPKCE = async (verifier) => {
|
|
161
169
|
const codeVerifier = verifier ?? generateSecure(86);
|
|
@@ -164,28 +172,28 @@ var createPKCE = async (verifier) => {
|
|
|
164
172
|
};
|
|
165
173
|
|
|
166
174
|
// src/schemas.ts
|
|
167
|
-
var
|
|
168
|
-
var OAuthProviderConfigSchema = (0,
|
|
169
|
-
authorizeURL: (0,
|
|
170
|
-
accessToken: (0,
|
|
171
|
-
scope: (0,
|
|
172
|
-
userInfo: (0,
|
|
173
|
-
responseType: (0,
|
|
174
|
-
clientId: (0,
|
|
175
|
-
clientSecret: (0,
|
|
175
|
+
var import_zod = require("zod");
|
|
176
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
177
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
178
|
+
accessToken: (0, import_zod.string)().url(),
|
|
179
|
+
scope: (0, import_zod.string)().optional(),
|
|
180
|
+
userInfo: (0, import_zod.string)().url(),
|
|
181
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
182
|
+
clientId: (0, import_zod.string)(),
|
|
183
|
+
clientSecret: (0, import_zod.string)()
|
|
176
184
|
});
|
|
177
185
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
178
|
-
redirectURI: (0,
|
|
179
|
-
state: (0,
|
|
180
|
-
codeChallenge: (0,
|
|
181
|
-
codeChallengeMethod: (0,
|
|
186
|
+
redirectURI: (0, import_zod.string)(),
|
|
187
|
+
state: (0, import_zod.string)(),
|
|
188
|
+
codeChallenge: (0, import_zod.string)(),
|
|
189
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
182
190
|
});
|
|
183
|
-
var OAuthAuthorizationResponse = (0,
|
|
184
|
-
state: (0,
|
|
185
|
-
code: (0,
|
|
191
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
192
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
193
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
186
194
|
});
|
|
187
|
-
var OAuthAuthorizationErrorResponse = (0,
|
|
188
|
-
error: (0,
|
|
195
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
196
|
+
error: (0, import_zod.enum)([
|
|
189
197
|
"invalid_request",
|
|
190
198
|
"unauthorized_client",
|
|
191
199
|
"access_denied",
|
|
@@ -194,24 +202,24 @@ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
|
194
202
|
"server_error",
|
|
195
203
|
"temporarily_unavailable"
|
|
196
204
|
]),
|
|
197
|
-
error_description: (0,
|
|
198
|
-
error_uri: (0,
|
|
199
|
-
state: (0,
|
|
205
|
+
error_description: (0, import_zod.string)().optional(),
|
|
206
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
207
|
+
state: (0, import_zod.string)()
|
|
200
208
|
});
|
|
201
209
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
202
|
-
redirectURI: (0,
|
|
203
|
-
code: (0,
|
|
204
|
-
codeVerifier: (0,
|
|
210
|
+
redirectURI: (0, import_zod.string)(),
|
|
211
|
+
code: (0, import_zod.string)(),
|
|
212
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
205
213
|
});
|
|
206
|
-
var OAuthAccessTokenResponse = (0,
|
|
207
|
-
access_token: (0,
|
|
208
|
-
token_type: (0,
|
|
209
|
-
expires_in: (0,
|
|
210
|
-
refresh_token: (0,
|
|
211
|
-
scope: (0,
|
|
214
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
215
|
+
access_token: (0, import_zod.string)(),
|
|
216
|
+
token_type: (0, import_zod.string)().optional(),
|
|
217
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
218
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
219
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
212
220
|
});
|
|
213
|
-
var OAuthAccessTokenErrorResponse = (0,
|
|
214
|
-
error: (0,
|
|
221
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
222
|
+
error: (0, import_zod.enum)([
|
|
215
223
|
"invalid_request",
|
|
216
224
|
"invalid_client",
|
|
217
225
|
"invalid_grant",
|
|
@@ -219,16 +227,16 @@ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
|
219
227
|
"unsupported_grant_type",
|
|
220
228
|
"invalid_scope"
|
|
221
229
|
]),
|
|
222
|
-
error_description: (0,
|
|
223
|
-
error_uri: (0,
|
|
230
|
+
error_description: (0, import_zod.string)().optional(),
|
|
231
|
+
error_uri: (0, import_zod.string)().optional()
|
|
224
232
|
});
|
|
225
|
-
var OAuthErrorResponse = (0,
|
|
226
|
-
error: (0,
|
|
227
|
-
error_description: (0,
|
|
233
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
234
|
+
error: (0, import_zod.string)(),
|
|
235
|
+
error_description: (0, import_zod.string)().optional()
|
|
228
236
|
});
|
|
229
|
-
var OAuthEnvSchema = (0,
|
|
230
|
-
clientId:
|
|
231
|
-
clientSecret:
|
|
237
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
238
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
239
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
232
240
|
});
|
|
233
241
|
|
|
234
242
|
// src/actions/signIn/authorization.ts
|
|
@@ -306,9 +314,14 @@ var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
|
|
|
306
314
|
var signInConfig = (oauth) => {
|
|
307
315
|
return (0, import_router2.createEndpointConfig)("/signIn/:oauth", {
|
|
308
316
|
schemas: {
|
|
309
|
-
params:
|
|
310
|
-
oauth:
|
|
311
|
-
|
|
317
|
+
params: import_zod2.z.object({
|
|
318
|
+
oauth: import_zod2.z.enum(
|
|
319
|
+
Object.keys(oauth),
|
|
320
|
+
"The OAuth provider is not supported or invalid."
|
|
321
|
+
)
|
|
322
|
+
}),
|
|
323
|
+
searchParams: import_zod2.z.object({
|
|
324
|
+
redirectTo: import_zod2.z.string().optional()
|
|
312
325
|
})
|
|
313
326
|
}
|
|
314
327
|
});
|
|
@@ -320,8 +333,8 @@ var signInAction = (oauth) => {
|
|
|
320
333
|
async (ctx) => {
|
|
321
334
|
const {
|
|
322
335
|
request,
|
|
323
|
-
|
|
324
|
-
|
|
336
|
+
params: { oauth: oauth2 },
|
|
337
|
+
searchParams: { redirectTo },
|
|
325
338
|
context: { oauth: providers, cookies, trustedProxyHeaders, basePath }
|
|
326
339
|
} = ctx;
|
|
327
340
|
const state = generateSecure();
|
|
@@ -329,7 +342,7 @@ var signInAction = (oauth) => {
|
|
|
329
342
|
const redirectToValue = createRedirectTo(request, redirectTo, trustedProxyHeaders);
|
|
330
343
|
const { codeVerifier, codeChallenge, method } = await createPKCE();
|
|
331
344
|
const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method);
|
|
332
|
-
const headers =
|
|
345
|
+
const headers = new import_router2.HeadersBuilder(cacheControl).setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirectURI.name, redirectURI, cookies.redirectURI.attributes).setCookie(cookies.redirectTo.name, redirectToValue, cookies.redirectTo.attributes).setCookie(cookies.codeVerifier.name, codeVerifier, cookies.codeVerifier.attributes).toHeaders();
|
|
333
346
|
return Response.json(
|
|
334
347
|
{ oauth: oauth2 },
|
|
335
348
|
{
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { j as OAuthProviderRecord } from '../../index-B8jeIElf.js';
|
|
4
4
|
import '../../schemas.js';
|
|
5
5
|
import '@aura-stack/router/cookie';
|
|
6
|
+
import '@aura-stack/jose';
|
|
6
7
|
import '@aura-stack/jose/jose';
|
|
7
8
|
import '../../@types/utility.js';
|
|
8
9
|
|
|
9
|
-
declare const signInAction: (oauth:
|
|
10
|
+
declare const signInAction: (oauth: OAuthProviderRecord) => _aura_stack_router.RouteEndpoint<"GET", "/signIn/:oauth", {
|
|
11
|
+
schemas?: {
|
|
12
|
+
params: z.ZodObject<{
|
|
13
|
+
oauth: z.ZodEnum<{
|
|
14
|
+
[x: string & Record<never, never>]: string & Record<never, never>;
|
|
15
|
+
github: "github";
|
|
16
|
+
bitbucket: "bitbucket";
|
|
17
|
+
figma: "figma";
|
|
18
|
+
discord: "discord";
|
|
19
|
+
gitlab: "gitlab";
|
|
20
|
+
spotify: "spotify";
|
|
21
|
+
x: "x";
|
|
22
|
+
strava: "strava";
|
|
23
|
+
mailchimp: "mailchimp";
|
|
24
|
+
pinterest: "pinterest";
|
|
25
|
+
}>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
searchParams: z.ZodObject<{
|
|
28
|
+
redirectTo: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
} | undefined;
|
|
31
|
+
}>;
|
|
10
32
|
|
|
11
33
|
export { signInAction };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
signInAction
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-3EUWD5BB.js";
|
|
4
|
+
import "../../chunk-N4SX7TZT.js";
|
|
5
|
+
import "../../chunk-STHEPPUZ.js";
|
|
6
6
|
import "../../chunk-N2APGLXA.js";
|
|
7
7
|
import "../../chunk-CXLATHS5.js";
|
|
8
8
|
import "../../chunk-EIL2FPSS.js";
|
|
9
9
|
import "../../chunk-RRLIF4PQ.js";
|
|
10
|
+
import "../../chunk-YRCB5FLE.js";
|
|
10
11
|
export {
|
|
11
12
|
signInAction
|
|
12
13
|
};
|
|
@@ -33,11 +33,11 @@ __export(signOut_exports, {
|
|
|
33
33
|
signOutAction: () => signOutAction
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(signOut_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_zod2 = require("zod");
|
|
37
37
|
var import_router2 = require("@aura-stack/router");
|
|
38
38
|
|
|
39
39
|
// src/secure.ts
|
|
40
|
-
var
|
|
40
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
41
|
|
|
42
42
|
// src/utils.ts
|
|
43
43
|
var import_router = require("@aura-stack/router");
|
|
@@ -132,7 +132,7 @@ var verifyCSRF = async (jose, cookie, header) => {
|
|
|
132
132
|
if (!equals(headerBuffer.length, cookieBuffer.length)) {
|
|
133
133
|
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
134
134
|
}
|
|
135
|
-
if (!
|
|
135
|
+
if (!import_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
|
|
136
136
|
throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
|
|
137
137
|
}
|
|
138
138
|
return true;
|
|
@@ -149,29 +149,49 @@ var cacheControl = {
|
|
|
149
149
|
Vary: "Cookie"
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
+
// src/cookie.ts
|
|
153
|
+
var import_cookie = require("@aura-stack/router/cookie");
|
|
154
|
+
var defaultCookieOptions = {
|
|
155
|
+
httpOnly: true,
|
|
156
|
+
sameSite: "lax",
|
|
157
|
+
path: "/",
|
|
158
|
+
maxAge: 60 * 60 * 24 * 15
|
|
159
|
+
};
|
|
160
|
+
var oauthCookieOptions = {
|
|
161
|
+
httpOnly: true,
|
|
162
|
+
maxAge: 5 * 60,
|
|
163
|
+
sameSite: "lax",
|
|
164
|
+
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
165
|
+
};
|
|
166
|
+
var expiredCookieAttributes = {
|
|
167
|
+
...defaultCookieOptions,
|
|
168
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
169
|
+
maxAge: 0
|
|
170
|
+
};
|
|
171
|
+
|
|
152
172
|
// src/schemas.ts
|
|
153
|
-
var
|
|
154
|
-
var OAuthProviderConfigSchema = (0,
|
|
155
|
-
authorizeURL: (0,
|
|
156
|
-
accessToken: (0,
|
|
157
|
-
scope: (0,
|
|
158
|
-
userInfo: (0,
|
|
159
|
-
responseType: (0,
|
|
160
|
-
clientId: (0,
|
|
161
|
-
clientSecret: (0,
|
|
173
|
+
var import_zod = require("zod");
|
|
174
|
+
var OAuthProviderConfigSchema = (0, import_zod.object)({
|
|
175
|
+
authorizeURL: (0, import_zod.string)().url(),
|
|
176
|
+
accessToken: (0, import_zod.string)().url(),
|
|
177
|
+
scope: (0, import_zod.string)().optional(),
|
|
178
|
+
userInfo: (0, import_zod.string)().url(),
|
|
179
|
+
responseType: (0, import_zod.enum)(["code", "token", "id_token"]),
|
|
180
|
+
clientId: (0, import_zod.string)(),
|
|
181
|
+
clientSecret: (0, import_zod.string)()
|
|
162
182
|
});
|
|
163
183
|
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
164
|
-
redirectURI: (0,
|
|
165
|
-
state: (0,
|
|
166
|
-
codeChallenge: (0,
|
|
167
|
-
codeChallengeMethod: (0,
|
|
184
|
+
redirectURI: (0, import_zod.string)(),
|
|
185
|
+
state: (0, import_zod.string)(),
|
|
186
|
+
codeChallenge: (0, import_zod.string)(),
|
|
187
|
+
codeChallengeMethod: (0, import_zod.enum)(["plain", "S256"])
|
|
168
188
|
});
|
|
169
|
-
var OAuthAuthorizationResponse = (0,
|
|
170
|
-
state: (0,
|
|
171
|
-
code: (0,
|
|
189
|
+
var OAuthAuthorizationResponse = (0, import_zod.object)({
|
|
190
|
+
state: (0, import_zod.string)({ message: "Missing state parameter in the OAuth authorization response." }),
|
|
191
|
+
code: (0, import_zod.string)({ message: "Missing code parameter in the OAuth authorization response." })
|
|
172
192
|
});
|
|
173
|
-
var OAuthAuthorizationErrorResponse = (0,
|
|
174
|
-
error: (0,
|
|
193
|
+
var OAuthAuthorizationErrorResponse = (0, import_zod.object)({
|
|
194
|
+
error: (0, import_zod.enum)([
|
|
175
195
|
"invalid_request",
|
|
176
196
|
"unauthorized_client",
|
|
177
197
|
"access_denied",
|
|
@@ -180,24 +200,24 @@ var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
|
180
200
|
"server_error",
|
|
181
201
|
"temporarily_unavailable"
|
|
182
202
|
]),
|
|
183
|
-
error_description: (0,
|
|
184
|
-
error_uri: (0,
|
|
185
|
-
state: (0,
|
|
203
|
+
error_description: (0, import_zod.string)().optional(),
|
|
204
|
+
error_uri: (0, import_zod.string)().optional(),
|
|
205
|
+
state: (0, import_zod.string)()
|
|
186
206
|
});
|
|
187
207
|
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
188
|
-
redirectURI: (0,
|
|
189
|
-
code: (0,
|
|
190
|
-
codeVerifier: (0,
|
|
208
|
+
redirectURI: (0, import_zod.string)(),
|
|
209
|
+
code: (0, import_zod.string)(),
|
|
210
|
+
codeVerifier: (0, import_zod.string)().min(43).max(128)
|
|
191
211
|
});
|
|
192
|
-
var OAuthAccessTokenResponse = (0,
|
|
193
|
-
access_token: (0,
|
|
194
|
-
token_type: (0,
|
|
195
|
-
expires_in: (0,
|
|
196
|
-
refresh_token: (0,
|
|
197
|
-
scope: (0,
|
|
212
|
+
var OAuthAccessTokenResponse = (0, import_zod.object)({
|
|
213
|
+
access_token: (0, import_zod.string)(),
|
|
214
|
+
token_type: (0, import_zod.string)().optional(),
|
|
215
|
+
expires_in: (0, import_zod.number)().optional(),
|
|
216
|
+
refresh_token: (0, import_zod.string)().optional(),
|
|
217
|
+
scope: (0, import_zod.string)().optional().or((0, import_zod.null)())
|
|
198
218
|
});
|
|
199
|
-
var OAuthAccessTokenErrorResponse = (0,
|
|
200
|
-
error: (0,
|
|
219
|
+
var OAuthAccessTokenErrorResponse = (0, import_zod.object)({
|
|
220
|
+
error: (0, import_zod.enum)([
|
|
201
221
|
"invalid_request",
|
|
202
222
|
"invalid_client",
|
|
203
223
|
"invalid_grant",
|
|
@@ -205,16 +225,16 @@ var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
|
205
225
|
"unsupported_grant_type",
|
|
206
226
|
"invalid_scope"
|
|
207
227
|
]),
|
|
208
|
-
error_description: (0,
|
|
209
|
-
error_uri: (0,
|
|
228
|
+
error_description: (0, import_zod.string)().optional(),
|
|
229
|
+
error_uri: (0, import_zod.string)().optional()
|
|
210
230
|
});
|
|
211
|
-
var OAuthErrorResponse = (0,
|
|
212
|
-
error: (0,
|
|
213
|
-
error_description: (0,
|
|
231
|
+
var OAuthErrorResponse = (0, import_zod.object)({
|
|
232
|
+
error: (0, import_zod.string)(),
|
|
233
|
+
error_description: (0, import_zod.string)().optional()
|
|
214
234
|
});
|
|
215
|
-
var OAuthEnvSchema = (0,
|
|
216
|
-
clientId:
|
|
217
|
-
clientSecret:
|
|
235
|
+
var OAuthEnvSchema = (0, import_zod.object)({
|
|
236
|
+
clientId: import_zod.z.string().min(1, "OAuth Client ID is required in the environment variables."),
|
|
237
|
+
clientSecret: import_zod.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
|
|
218
238
|
});
|
|
219
239
|
|
|
220
240
|
// src/actions/signIn/authorization.ts
|
|
@@ -273,32 +293,12 @@ var createRedirectTo = (request, redirectTo, trustedProxyHeaders) => {
|
|
|
273
293
|
}
|
|
274
294
|
};
|
|
275
295
|
|
|
276
|
-
// src/cookie.ts
|
|
277
|
-
var import_cookie = require("@aura-stack/router/cookie");
|
|
278
|
-
var defaultCookieOptions = {
|
|
279
|
-
httpOnly: true,
|
|
280
|
-
sameSite: "lax",
|
|
281
|
-
path: "/",
|
|
282
|
-
maxAge: 60 * 60 * 24 * 15
|
|
283
|
-
};
|
|
284
|
-
var oauthCookieOptions = {
|
|
285
|
-
httpOnly: true,
|
|
286
|
-
maxAge: 5 * 60,
|
|
287
|
-
sameSite: "lax",
|
|
288
|
-
expires: new Date(Date.now() + 5 * 60 * 1e3)
|
|
289
|
-
};
|
|
290
|
-
var expiredCookieAttributes = {
|
|
291
|
-
...defaultCookieOptions,
|
|
292
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
293
|
-
maxAge: 0
|
|
294
|
-
};
|
|
295
|
-
|
|
296
296
|
// src/actions/signOut/signOut.ts
|
|
297
297
|
var config = (0, import_router2.createEndpointConfig)({
|
|
298
298
|
schemas: {
|
|
299
|
-
searchParams:
|
|
300
|
-
token_type_hint:
|
|
301
|
-
redirectTo:
|
|
299
|
+
searchParams: import_zod2.z.object({
|
|
300
|
+
token_type_hint: import_zod2.z.literal("session_token"),
|
|
301
|
+
redirectTo: import_zod2.z.string().optional()
|
|
302
302
|
})
|
|
303
303
|
}
|
|
304
304
|
});
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import * as _aura_stack_router from '@aura-stack/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
5
6
|
*/
|
|
6
|
-
declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {
|
|
7
|
+
declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {
|
|
8
|
+
schemas?: {
|
|
9
|
+
searchParams: z.ZodObject<{
|
|
10
|
+
token_type_hint: z.ZodLiteral<"session_token">;
|
|
11
|
+
redirectTo: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
} | undefined;
|
|
14
|
+
}>;
|
|
7
15
|
|
|
8
16
|
export { signOutAction };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
signOutAction
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-A3N4PVAT.js";
|
|
4
|
+
import "../../chunk-N4SX7TZT.js";
|
|
5
|
+
import "../../chunk-W6LG7BFW.js";
|
|
6
6
|
import "../../chunk-STHEPPUZ.js";
|
|
7
|
-
import "../../chunk-WD7AUHQ5.js";
|
|
8
7
|
import "../../chunk-N2APGLXA.js";
|
|
9
8
|
import "../../chunk-CXLATHS5.js";
|
|
10
9
|
import "../../chunk-EIL2FPSS.js";
|
|
11
10
|
import "../../chunk-RRLIF4PQ.js";
|
|
11
|
+
import "../../chunk-YRCB5FLE.js";
|
|
12
12
|
export {
|
|
13
13
|
signOutAction
|
|
14
14
|
};
|
package/dist/assert.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { J as JWTPayloadWithToken } from './index-
|
|
2
|
-
import 'zod
|
|
1
|
+
import { J as JWTPayloadWithToken } from './index-B8jeIElf.js';
|
|
2
|
+
import 'zod';
|
|
3
3
|
import './schemas.js';
|
|
4
4
|
import '@aura-stack/router/cookie';
|
|
5
|
+
import '@aura-stack/jose';
|
|
5
6
|
import '@aura-stack/jose/jose';
|
|
6
7
|
import './@types/utility.js';
|
|
7
8
|
|
|
@@ -2,20 +2,28 @@ import {
|
|
|
2
2
|
createAuthorizationURL,
|
|
3
3
|
createRedirectTo,
|
|
4
4
|
createRedirectURI
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-N4SX7TZT.js";
|
|
6
|
+
import {
|
|
7
|
+
cacheControl
|
|
8
|
+
} from "./chunk-STHEPPUZ.js";
|
|
6
9
|
import {
|
|
7
10
|
createPKCE,
|
|
8
11
|
generateSecure
|
|
9
12
|
} from "./chunk-N2APGLXA.js";
|
|
10
13
|
|
|
11
14
|
// src/actions/signIn/signIn.ts
|
|
12
|
-
import z from "zod";
|
|
13
|
-
import { createEndpoint, createEndpointConfig } from "@aura-stack/router";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { createEndpoint, createEndpointConfig, HeadersBuilder } from "@aura-stack/router";
|
|
14
17
|
var signInConfig = (oauth) => {
|
|
15
18
|
return createEndpointConfig("/signIn/:oauth", {
|
|
16
19
|
schemas: {
|
|
17
20
|
params: z.object({
|
|
18
|
-
oauth: z.enum(
|
|
21
|
+
oauth: z.enum(
|
|
22
|
+
Object.keys(oauth),
|
|
23
|
+
"The OAuth provider is not supported or invalid."
|
|
24
|
+
)
|
|
25
|
+
}),
|
|
26
|
+
searchParams: z.object({
|
|
19
27
|
redirectTo: z.string().optional()
|
|
20
28
|
})
|
|
21
29
|
}
|
|
@@ -28,8 +36,8 @@ var signInAction = (oauth) => {
|
|
|
28
36
|
async (ctx) => {
|
|
29
37
|
const {
|
|
30
38
|
request,
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
params: { oauth: oauth2 },
|
|
40
|
+
searchParams: { redirectTo },
|
|
33
41
|
context: { oauth: providers, cookies, trustedProxyHeaders, basePath }
|
|
34
42
|
} = ctx;
|
|
35
43
|
const state = generateSecure();
|
|
@@ -37,7 +45,7 @@ var signInAction = (oauth) => {
|
|
|
37
45
|
const redirectToValue = createRedirectTo(request, redirectTo, trustedProxyHeaders);
|
|
38
46
|
const { codeVerifier, codeChallenge, method } = await createPKCE();
|
|
39
47
|
const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method);
|
|
40
|
-
const headers =
|
|
48
|
+
const headers = new HeadersBuilder(cacheControl).setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirectURI.name, redirectURI, cookies.redirectURI.attributes).setCookie(cookies.redirectTo.name, redirectToValue, cookies.redirectTo.attributes).setCookie(cookies.codeVerifier.name, codeVerifier, cookies.codeVerifier.attributes).toHeaders();
|
|
41
49
|
return Response.json(
|
|
42
50
|
{ oauth: oauth2 },
|
|
43
51
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRedirectTo
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N4SX7TZT.js";
|
|
4
4
|
import {
|
|
5
5
|
expiredCookieAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W6LG7BFW.js";
|
|
7
7
|
import {
|
|
8
8
|
cacheControl
|
|
9
9
|
} from "./chunk-STHEPPUZ.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./chunk-RRLIF4PQ.js";
|
|
19
19
|
|
|
20
20
|
// src/actions/signOut/signOut.ts
|
|
21
|
-
import z from "zod";
|
|
21
|
+
import { z } from "zod";
|
|
22
22
|
import { createEndpoint, createEndpointConfig, HeadersBuilder, statusCode } from "@aura-stack/router";
|
|
23
23
|
var config = createEndpointConfig({
|
|
24
24
|
schemas: {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/oauth/mailchimp.ts
|
|
2
|
+
var mailchimp = {
|
|
3
|
+
id: "mailchimp",
|
|
4
|
+
name: "Mailchimp",
|
|
5
|
+
authorizeURL: "https://login.mailchimp.com/oauth2/authorize",
|
|
6
|
+
accessToken: "https://login.mailchimp.com/oauth2/token",
|
|
7
|
+
userInfo: "https://login.mailchimp.com/oauth2/metadata",
|
|
8
|
+
scope: "",
|
|
9
|
+
responseType: "code",
|
|
10
|
+
profile(profile) {
|
|
11
|
+
return {
|
|
12
|
+
sub: profile.user_id,
|
|
13
|
+
name: profile.accountname,
|
|
14
|
+
email: profile.login.login_email,
|
|
15
|
+
image: null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
mailchimp
|
|
22
|
+
};
|
|
@@ -1,36 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
x
|
|
3
|
+
} from "./chunk-42XB3YCW.js";
|
|
4
|
+
import {
|
|
5
|
+
figma
|
|
6
|
+
} from "./chunk-FKRDCWBF.js";
|
|
1
7
|
import {
|
|
2
8
|
github
|
|
3
9
|
} from "./chunk-IKHPGFCW.js";
|
|
4
10
|
import {
|
|
5
11
|
gitlab
|
|
6
12
|
} from "./chunk-KRNOMBXQ.js";
|
|
13
|
+
import {
|
|
14
|
+
mailchimp
|
|
15
|
+
} from "./chunk-B737EUJV.js";
|
|
16
|
+
import {
|
|
17
|
+
pinterest
|
|
18
|
+
} from "./chunk-HP34YGGJ.js";
|
|
7
19
|
import {
|
|
8
20
|
spotify
|
|
9
21
|
} from "./chunk-E3OXBRYF.js";
|
|
10
22
|
import {
|
|
11
23
|
strava
|
|
12
24
|
} from "./chunk-6R2YZ4AC.js";
|
|
13
|
-
import {
|
|
14
|
-
x
|
|
15
|
-
} from "./chunk-42XB3YCW.js";
|
|
16
25
|
import {
|
|
17
26
|
bitbucket
|
|
18
27
|
} from "./chunk-FIPU4MLT.js";
|
|
19
28
|
import {
|
|
20
29
|
discord
|
|
21
30
|
} from "./chunk-IUYZQTJV.js";
|
|
22
|
-
import {
|
|
23
|
-
figma
|
|
24
|
-
} from "./chunk-FKRDCWBF.js";
|
|
25
|
-
import {
|
|
26
|
-
OAuthEnvSchema
|
|
27
|
-
} from "./chunk-WD7AUHQ5.js";
|
|
28
31
|
import {
|
|
29
32
|
formatZodError
|
|
30
33
|
} from "./chunk-CXLATHS5.js";
|
|
31
34
|
import {
|
|
32
35
|
AuthInternalError
|
|
33
36
|
} from "./chunk-RRLIF4PQ.js";
|
|
37
|
+
import {
|
|
38
|
+
OAuthEnvSchema
|
|
39
|
+
} from "./chunk-YRCB5FLE.js";
|
|
34
40
|
|
|
35
41
|
// src/oauth/index.ts
|
|
36
42
|
var builtInOAuthProviders = {
|
|
@@ -41,7 +47,9 @@ var builtInOAuthProviders = {
|
|
|
41
47
|
gitlab,
|
|
42
48
|
spotify,
|
|
43
49
|
x,
|
|
44
|
-
strava
|
|
50
|
+
strava,
|
|
51
|
+
mailchimp,
|
|
52
|
+
pinterest
|
|
45
53
|
};
|
|
46
54
|
var defineOAuthEnvironment = (oauth) => {
|
|
47
55
|
const env = process.env;
|