@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.
Files changed (79) hide show
  1. package/dist/@types/index.d.ts +3 -2
  2. package/dist/@types/router.d.d.ts +3 -2
  3. package/dist/actions/callback/access-token.cjs +52 -41
  4. package/dist/actions/callback/access-token.d.ts +5 -4
  5. package/dist/actions/callback/access-token.js +3 -2
  6. package/dist/actions/callback/callback.cjs +69 -52
  7. package/dist/actions/callback/callback.d.ts +26 -3
  8. package/dist/actions/callback/callback.js +6 -5
  9. package/dist/actions/callback/userinfo.cjs +54 -43
  10. package/dist/actions/callback/userinfo.d.ts +3 -2
  11. package/dist/actions/callback/userinfo.js +3 -2
  12. package/dist/actions/csrfToken/csrfToken.cjs +2 -2
  13. package/dist/actions/csrfToken/csrfToken.d.ts +3 -1
  14. package/dist/actions/csrfToken/csrfToken.js +2 -2
  15. package/dist/actions/index.cjs +93 -71
  16. package/dist/actions/index.d.ts +3 -2
  17. package/dist/actions/index.js +15 -14
  18. package/dist/actions/session/session.d.ts +3 -1
  19. package/dist/actions/session/session.js +2 -2
  20. package/dist/actions/signIn/authorization.cjs +40 -40
  21. package/dist/actions/signIn/authorization.d.ts +3 -2
  22. package/dist/actions/signIn/authorization.js +2 -2
  23. package/dist/actions/signIn/signIn.cjs +63 -50
  24. package/dist/actions/signIn/signIn.d.ts +25 -3
  25. package/dist/actions/signIn/signIn.js +4 -3
  26. package/dist/actions/signOut/signOut.cjs +66 -66
  27. package/dist/actions/signOut/signOut.d.ts +9 -1
  28. package/dist/actions/signOut/signOut.js +4 -4
  29. package/dist/assert.d.ts +3 -2
  30. package/dist/{chunk-2RXNXMCZ.js → chunk-3EUWD5BB.js} +15 -7
  31. package/dist/{chunk-NEVKX6K2.js → chunk-A3N4PVAT.js} +3 -3
  32. package/dist/chunk-B737EUJV.js +22 -0
  33. package/dist/{chunk-7H3OR6UU.js → chunk-EMKJA2GJ.js} +18 -10
  34. package/dist/{chunk-4V4JNXVF.js → chunk-GA2SMTJO.js} +9 -6
  35. package/dist/chunk-HP34YGGJ.js +22 -0
  36. package/dist/{chunk-QDO2KSRJ.js → chunk-HT4YLL7N.js} +1 -1
  37. package/dist/{chunk-ZLR3LI6X.js → chunk-IVET23KF.js} +7 -4
  38. package/dist/{chunk-PTJUYB33.js → chunk-JVFTCTTE.js} +1 -1
  39. package/dist/{chunk-UEH3LVON.js → chunk-KSWLO5ZU.js} +21 -16
  40. package/dist/{chunk-QEZL7EYN.js → chunk-N4SX7TZT.js} +3 -3
  41. package/dist/{chunk-IMICRJ5U.js → chunk-W6LG7BFW.js} +14 -14
  42. package/dist/{chunk-WD7AUHQ5.js → chunk-YRCB5FLE.js} +8 -8
  43. package/dist/chunk-ZNCZVF6U.js +14 -0
  44. package/dist/cookie.cjs +14 -14
  45. package/dist/cookie.d.ts +3 -2
  46. package/dist/cookie.js +1 -1
  47. package/dist/errors.d.ts +3 -2
  48. package/dist/{index-EqsoyjrF.d.ts → index-B8jeIElf.d.ts} +57 -8
  49. package/dist/index.cjs +159 -95
  50. package/dist/index.d.ts +66 -5
  51. package/dist/index.js +23 -19
  52. package/dist/jose.cjs +2 -2
  53. package/dist/oauth/bitbucket.d.ts +3 -2
  54. package/dist/oauth/discord.d.ts +3 -2
  55. package/dist/oauth/figma.d.ts +3 -2
  56. package/dist/oauth/github.d.ts +3 -2
  57. package/dist/oauth/gitlab.d.ts +3 -2
  58. package/dist/oauth/index.cjs +85 -41
  59. package/dist/oauth/index.d.ts +3 -2
  60. package/dist/oauth/index.js +16 -8
  61. package/dist/oauth/mailchimp.cjs +46 -0
  62. package/dist/oauth/mailchimp.d.ts +7 -0
  63. package/dist/oauth/mailchimp.js +6 -0
  64. package/dist/oauth/pinterest.cjs +46 -0
  65. package/dist/oauth/pinterest.d.ts +7 -0
  66. package/dist/oauth/pinterest.js +6 -0
  67. package/dist/oauth/spotify.d.ts +3 -2
  68. package/dist/oauth/strava.d.ts +3 -2
  69. package/dist/oauth/x.d.ts +3 -2
  70. package/dist/request.cjs +38 -0
  71. package/dist/request.d.ts +13 -0
  72. package/dist/request.js +6 -0
  73. package/dist/schemas.cjs +40 -40
  74. package/dist/schemas.d.ts +15 -15
  75. package/dist/schemas.js +1 -1
  76. package/dist/secure.cjs +5 -5
  77. package/dist/secure.d.ts +3 -2
  78. package/dist/utils.d.ts +3 -3
  79. 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 import_zod = __toESM(require("zod"), 1);
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 import_node_crypto = __toESM(require("crypto"), 1);
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 import_node_crypto.default.randomBytes(length).toString("base64url");
163
+ return import_crypto.default.randomBytes(length).toString("base64url");
156
164
  };
157
165
  var createHash = (data, base = "hex") => {
158
- return import_node_crypto.default.createHash("sha256").update(data).digest().toString(base);
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 import_v4 = require("zod/v4");
168
- var OAuthProviderConfigSchema = (0, import_v4.object)({
169
- authorizeURL: (0, import_v4.httpUrl)(),
170
- accessToken: (0, import_v4.httpUrl)(),
171
- scope: (0, import_v4.string)().optional(),
172
- userInfo: (0, import_v4.httpUrl)(),
173
- responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
174
- clientId: (0, import_v4.string)(),
175
- clientSecret: (0, import_v4.string)()
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, import_v4.string)(),
179
- state: (0, import_v4.string)(),
180
- codeChallenge: (0, import_v4.string)(),
181
- codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
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, import_v4.object)({
184
- state: (0, import_v4.string)("Missing state parameter in the OAuth authorization response."),
185
- code: (0, import_v4.string)("Missing code parameter in the OAuth authorization response.")
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, import_v4.object)({
188
- error: (0, import_v4.enum)([
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, import_v4.string)().optional(),
198
- error_uri: (0, import_v4.string)().optional(),
199
- state: (0, import_v4.string)()
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, import_v4.string)(),
203
- code: (0, import_v4.string)(),
204
- codeVerifier: (0, import_v4.string)().min(43).max(128)
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, import_v4.object)({
207
- access_token: (0, import_v4.string)(),
208
- token_type: (0, import_v4.string)(),
209
- expires_in: (0, import_v4.number)().optional(),
210
- refresh_token: (0, import_v4.string)().optional(),
211
- scope: (0, import_v4.string)().optional()
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, import_v4.object)({
214
- error: (0, import_v4.enum)([
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, import_v4.string)().optional(),
223
- error_uri: (0, import_v4.string)().optional()
230
+ error_description: (0, import_zod.string)().optional(),
231
+ error_uri: (0, import_zod.string)().optional()
224
232
  });
225
- var OAuthErrorResponse = (0, import_v4.object)({
226
- error: (0, import_v4.string)(),
227
- error_description: (0, import_v4.string)().optional()
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, import_v4.object)({
230
- clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
231
- clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
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: import_zod.default.object({
310
- oauth: import_zod.default.enum(Object.keys(oauth), "The OAuth provider is not supported or invalid."),
311
- redirectTo: import_zod.default.string().optional()
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
- headers: headersBuilder,
324
- params: { oauth: oauth2, redirectTo },
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 = headersBuilder.setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirect_uri.name, redirectURI, cookies.redirect_uri.attributes).setCookie(cookies.redirect_to.name, redirectToValue, cookies.redirect_to.attributes).setCookie(cookies.code_verifier.name, codeVerifier, cookies.code_verifier.attributes).toHeaders();
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 { A as AuthRuntimeConfig } from '../../index-EqsoyjrF.js';
3
- import 'zod/v4';
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: AuthRuntimeConfig["oauth"]) => _aura_stack_router.RouteEndpoint<"GET", "/signIn/: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-2RXNXMCZ.js";
4
- import "../../chunk-QEZL7EYN.js";
5
- import "../../chunk-WD7AUHQ5.js";
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 import_zod = __toESM(require("zod"), 1);
36
+ var import_zod2 = require("zod");
37
37
  var import_router2 = require("@aura-stack/router");
38
38
 
39
39
  // src/secure.ts
40
- var import_node_crypto = __toESM(require("crypto"), 1);
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 (!import_node_crypto.default.timingSafeEqual(cookieBuffer, headerBuffer)) {
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 import_v4 = require("zod/v4");
154
- var OAuthProviderConfigSchema = (0, import_v4.object)({
155
- authorizeURL: (0, import_v4.httpUrl)(),
156
- accessToken: (0, import_v4.httpUrl)(),
157
- scope: (0, import_v4.string)().optional(),
158
- userInfo: (0, import_v4.httpUrl)(),
159
- responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
160
- clientId: (0, import_v4.string)(),
161
- clientSecret: (0, import_v4.string)()
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, import_v4.string)(),
165
- state: (0, import_v4.string)(),
166
- codeChallenge: (0, import_v4.string)(),
167
- codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
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, import_v4.object)({
170
- state: (0, import_v4.string)("Missing state parameter in the OAuth authorization response."),
171
- code: (0, import_v4.string)("Missing code parameter in the OAuth authorization response.")
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, import_v4.object)({
174
- error: (0, import_v4.enum)([
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, import_v4.string)().optional(),
184
- error_uri: (0, import_v4.string)().optional(),
185
- state: (0, import_v4.string)()
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, import_v4.string)(),
189
- code: (0, import_v4.string)(),
190
- codeVerifier: (0, import_v4.string)().min(43).max(128)
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, import_v4.object)({
193
- access_token: (0, import_v4.string)(),
194
- token_type: (0, import_v4.string)(),
195
- expires_in: (0, import_v4.number)().optional(),
196
- refresh_token: (0, import_v4.string)().optional(),
197
- scope: (0, import_v4.string)().optional()
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, import_v4.object)({
200
- error: (0, import_v4.enum)([
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, import_v4.string)().optional(),
209
- error_uri: (0, import_v4.string)().optional()
228
+ error_description: (0, import_zod.string)().optional(),
229
+ error_uri: (0, import_zod.string)().optional()
210
230
  });
211
- var OAuthErrorResponse = (0, import_v4.object)({
212
- error: (0, import_v4.string)(),
213
- error_description: (0, import_v4.string)().optional()
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, import_v4.object)({
216
- clientId: import_v4.z.string().min(1, "OAuth Client ID is required in the environment variables."),
217
- clientSecret: import_v4.z.string().min(1, "OAuth Client Secret is required in the environment variables.")
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: import_zod.default.object({
300
- token_type_hint: import_zod.default.literal("session_token"),
301
- redirectTo: import_zod.default.string().optional()
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-NEVKX6K2.js";
4
- import "../../chunk-QEZL7EYN.js";
5
- import "../../chunk-IMICRJ5U.js";
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-EqsoyjrF.js';
2
- import 'zod/v4';
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-QEZL7EYN.js";
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(Object.keys(oauth), "The OAuth provider is not supported or invalid."),
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
- headers: headersBuilder,
32
- params: { oauth: oauth2, redirectTo },
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 = headersBuilder.setHeader("Location", authorization).setCookie(cookies.state.name, state, cookies.state.attributes).setCookie(cookies.redirect_uri.name, redirectURI, cookies.redirect_uri.attributes).setCookie(cookies.redirect_to.name, redirectToValue, cookies.redirect_to.attributes).setCookie(cookies.code_verifier.name, codeVerifier, cookies.code_verifier.attributes).toHeaders();
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-QEZL7EYN.js";
3
+ } from "./chunk-N4SX7TZT.js";
4
4
  import {
5
5
  expiredCookieAttributes
6
- } from "./chunk-IMICRJ5U.js";
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;