@aura-stack/auth 0.1.0-rc.9 → 0.2.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 (153) hide show
  1. package/dist/@types/index.cjs +15 -15
  2. package/dist/@types/index.d.ts +7 -31
  3. package/dist/@types/index.js +1 -1
  4. package/dist/@types/router.d.cjs +1 -1
  5. package/dist/@types/router.d.d.ts +7 -7
  6. package/dist/@types/utility.cjs +15 -15
  7. package/dist/@types/utility.d.ts +4 -8
  8. package/dist/@types/utility.js +1 -1
  9. package/dist/actions/callback/access-token.cjs +176 -155
  10. package/dist/actions/callback/access-token.d.ts +15 -20
  11. package/dist/actions/callback/access-token.js +10 -4
  12. package/dist/actions/callback/callback.cjs +394 -490
  13. package/dist/actions/callback/callback.d.ts +10 -12
  14. package/dist/actions/callback/callback.js +16 -12
  15. package/dist/actions/callback/userinfo.cjs +166 -145
  16. package/dist/actions/callback/userinfo.d.ts +9 -9
  17. package/dist/actions/callback/userinfo.js +12 -6
  18. package/dist/actions/csrfToken/csrfToken.cjs +112 -190
  19. package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
  20. package/dist/actions/csrfToken/csrfToken.js +12 -8
  21. package/dist/actions/index.cjs +652 -814
  22. package/dist/actions/index.d.ts +13 -13
  23. package/dist/actions/index.js +34 -18
  24. package/dist/actions/session/session.cjs +86 -176
  25. package/dist/actions/session/session.d.ts +3 -3
  26. package/dist/actions/session/session.js +10 -7
  27. package/dist/actions/signIn/authorization.cjs +254 -263
  28. package/dist/actions/signIn/authorization.d.ts +12 -18
  29. package/dist/actions/signIn/authorization.js +16 -6
  30. package/dist/actions/signIn/signIn.cjs +320 -456
  31. package/dist/actions/signIn/signIn.d.ts +10 -10
  32. package/dist/actions/signIn/signIn.js +13 -10
  33. package/dist/actions/signOut/signOut.cjs +304 -473
  34. package/dist/actions/signOut/signOut.d.ts +3 -3
  35. package/dist/actions/signOut/signOut.js +14 -11
  36. package/dist/assert.cjs +40 -36
  37. package/dist/assert.d.ts +13 -4
  38. package/dist/assert.js +12 -2
  39. package/dist/chunk-3EUWD5BB.js +63 -0
  40. package/dist/chunk-42XB3YCW.js +19 -17
  41. package/dist/chunk-6R2YZ4AC.js +22 -0
  42. package/dist/chunk-A3N4PVAT.js +70 -0
  43. package/dist/chunk-B737EUJV.js +22 -0
  44. package/dist/chunk-CXLATHS5.js +143 -0
  45. package/dist/chunk-E3OXBRYF.js +19 -17
  46. package/dist/chunk-EIL2FPSS.js +22 -0
  47. package/dist/chunk-EMKJA2GJ.js +89 -0
  48. package/dist/chunk-FIPU4MLT.js +18 -16
  49. package/dist/chunk-FKRDCWBF.js +19 -17
  50. package/dist/chunk-GA2SMTJO.js +58 -0
  51. package/dist/chunk-HP34YGGJ.js +22 -0
  52. package/dist/chunk-HT4YLL7N.js +35 -0
  53. package/dist/chunk-IKHPGFCW.js +11 -9
  54. package/dist/chunk-IUYZQTJV.js +30 -0
  55. package/dist/chunk-IVET23KF.js +58 -0
  56. package/dist/chunk-JVFTCTTE.js +33 -0
  57. package/dist/chunk-KRNOMBXQ.js +19 -17
  58. package/dist/chunk-KSWLO5ZU.js +102 -0
  59. package/dist/chunk-N2APGLXA.js +71 -0
  60. package/dist/chunk-N4SX7TZT.js +96 -0
  61. package/dist/chunk-RRLIF4PQ.js +55 -0
  62. package/dist/chunk-STHEPPUZ.js +8 -6
  63. package/dist/chunk-TLE4PXY3.js +39 -0
  64. package/dist/chunk-W6LG7BFW.js +197 -0
  65. package/dist/chunk-YRCB5FLE.js +79 -0
  66. package/dist/chunk-ZNCZVF6U.js +14 -0
  67. package/dist/cookie.cjs +222 -187
  68. package/dist/cookie.d.ts +39 -76
  69. package/dist/cookie.js +27 -34
  70. package/dist/errors.cjs +85 -0
  71. package/dist/errors.d.ts +49 -0
  72. package/dist/errors.js +18 -0
  73. package/dist/headers.cjs +28 -28
  74. package/dist/headers.d.ts +2 -2
  75. package/dist/headers.js +6 -2
  76. package/dist/index-DkaLJFn8.d.ts +679 -0
  77. package/dist/index.cjs +1074 -1007
  78. package/dist/index.d.ts +10 -31
  79. package/dist/index.js +85 -51
  80. package/dist/jose.cjs +74 -66
  81. package/dist/jose.d.ts +11 -8
  82. package/dist/jose.js +10 -5
  83. package/dist/oauth/bitbucket.cjs +38 -38
  84. package/dist/oauth/bitbucket.d.ts +7 -7
  85. package/dist/oauth/bitbucket.js +6 -2
  86. package/dist/oauth/discord.cjs +47 -48
  87. package/dist/oauth/discord.d.ts +7 -7
  88. package/dist/oauth/discord.js +6 -2
  89. package/dist/oauth/figma.cjs +39 -39
  90. package/dist/oauth/figma.d.ts +7 -7
  91. package/dist/oauth/figma.js +6 -2
  92. package/dist/oauth/github.cjs +31 -31
  93. package/dist/oauth/github.d.ts +7 -7
  94. package/dist/oauth/github.js +6 -2
  95. package/dist/oauth/gitlab.cjs +39 -39
  96. package/dist/oauth/gitlab.d.ts +7 -7
  97. package/dist/oauth/gitlab.js +6 -2
  98. package/dist/oauth/index.cjs +350 -180
  99. package/dist/oauth/index.d.ts +7 -26
  100. package/dist/oauth/index.js +51 -9
  101. package/dist/oauth/mailchimp.cjs +46 -0
  102. package/dist/oauth/mailchimp.d.ts +7 -0
  103. package/dist/oauth/mailchimp.js +6 -0
  104. package/dist/oauth/pinterest.cjs +46 -0
  105. package/dist/oauth/pinterest.d.ts +7 -0
  106. package/dist/oauth/pinterest.js +6 -0
  107. package/dist/oauth/spotify.cjs +39 -39
  108. package/dist/oauth/spotify.d.ts +7 -7
  109. package/dist/oauth/spotify.js +6 -2
  110. package/dist/oauth/strava.cjs +46 -0
  111. package/dist/oauth/strava.d.ts +7 -0
  112. package/dist/oauth/strava.js +6 -0
  113. package/dist/oauth/x.cjs +39 -39
  114. package/dist/oauth/x.d.ts +7 -7
  115. package/dist/oauth/x.js +6 -2
  116. package/dist/request.cjs +38 -0
  117. package/dist/request.d.ts +13 -0
  118. package/dist/request.js +6 -0
  119. package/dist/schemas.cjs +103 -97
  120. package/dist/schemas.d.ts +96 -126
  121. package/dist/schemas.js +20 -18
  122. package/dist/secure.cjs +106 -101
  123. package/dist/secure.d.ts +17 -17
  124. package/dist/secure.js +19 -4
  125. package/dist/utils.cjs +197 -135
  126. package/dist/utils.d.ts +20 -26
  127. package/dist/utils.js +25 -21
  128. package/package.json +8 -7
  129. package/dist/chunk-256KIVJL.js +0 -110
  130. package/dist/chunk-6SM22VVJ.js +0 -15
  131. package/dist/chunk-CAKJT3KS.js +0 -77
  132. package/dist/chunk-EBPE35JT.js +0 -29
  133. package/dist/chunk-FJUDBLCP.js +0 -52
  134. package/dist/chunk-GZU3RBTB.js +0 -51
  135. package/dist/chunk-HGJ4TXY4.js +0 -105
  136. package/dist/chunk-HMRKN75I.js +0 -74
  137. package/dist/chunk-JAPMIE6S.js +0 -8
  138. package/dist/chunk-LLR722CL.js +0 -75
  139. package/dist/chunk-RLT4RFKV.js +0 -36
  140. package/dist/chunk-SJPDVKUS.js +0 -93
  141. package/dist/chunk-SMQO5WD7.js +0 -20
  142. package/dist/chunk-UJJ7R56J.js +0 -42
  143. package/dist/chunk-UTDLUEEG.js +0 -25
  144. package/dist/chunk-VFTYH33W.js +0 -44
  145. package/dist/chunk-XXJKNKGQ.js +0 -27
  146. package/dist/chunk-ZV4BH47P.js +0 -156
  147. package/dist/error.cjs +0 -88
  148. package/dist/error.d.ts +0 -62
  149. package/dist/error.js +0 -9
  150. package/dist/index-DpfbvTZ_.d.ts +0 -597
  151. package/dist/response.cjs +0 -34
  152. package/dist/response.d.ts +0 -10
  153. package/dist/response.js +0 -2
@@ -1,8 +1,8 @@
1
- import * as _aura_stack_router from "@aura-stack/router"
1
+ import * as _aura_stack_router from '@aura-stack/router';
2
2
 
3
3
  /**
4
4
  * @see https://datatracker.ietf.org/doc/html/rfc7009
5
5
  */
6
- declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {}>
6
+ declare const signOutAction: _aura_stack_router.RouteEndpoint<"POST", "/signOut", {}>;
7
7
 
8
- export { signOutAction }
8
+ export { signOutAction };
@@ -1,11 +1,14 @@
1
- import { signOutAction } from "../../chunk-SJPDVKUS.js"
2
- import "../../chunk-CAKJT3KS.js"
3
- import "../../chunk-ZV4BH47P.js"
4
- import "../../chunk-6SM22VVJ.js"
5
- import "../../chunk-STHEPPUZ.js"
6
- import "../../chunk-GZU3RBTB.js"
7
- import "../../chunk-256KIVJL.js"
8
- import "../../chunk-FJUDBLCP.js"
9
- import "../../chunk-JAPMIE6S.js"
10
- import "../../chunk-HMRKN75I.js"
11
- export { signOutAction }
1
+ import {
2
+ signOutAction
3
+ } from "../../chunk-A3N4PVAT.js";
4
+ import "../../chunk-N4SX7TZT.js";
5
+ import "../../chunk-W6LG7BFW.js";
6
+ import "../../chunk-STHEPPUZ.js";
7
+ import "../../chunk-N2APGLXA.js";
8
+ import "../../chunk-CXLATHS5.js";
9
+ import "../../chunk-EIL2FPSS.js";
10
+ import "../../chunk-RRLIF4PQ.js";
11
+ import "../../chunk-YRCB5FLE.js";
12
+ export {
13
+ signOutAction
14
+ };
package/dist/assert.cjs CHANGED
@@ -1,45 +1,49 @@
1
- "use strict"
2
- var __defProp = Object.defineProperty
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor
4
- var __getOwnPropNames = Object.getOwnPropertyNames
5
- var __hasOwnProp = Object.prototype.hasOwnProperty
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
- for (var name in all) __defProp(target, name, { get: all[name], enumerable: true })
8
- }
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
9
10
  var __copyProps = (to, from, except, desc) => {
10
- if ((from && typeof from === "object") || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
14
- }
15
- return to
16
- }
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
19
 
19
20
  // src/assert.ts
20
- var assert_exports = {}
21
+ var assert_exports = {};
21
22
  __export(assert_exports, {
22
- isFalsy: () => isFalsy,
23
- isRequest: () => isRequest,
24
- isValidURL: () => isValidURL,
25
- })
26
- module.exports = __toCommonJS(assert_exports)
23
+ isFalsy: () => isFalsy,
24
+ isJWTPayloadWithToken: () => isJWTPayloadWithToken,
25
+ isRequest: () => isRequest,
26
+ isValidURL: () => isValidURL
27
+ });
28
+ module.exports = __toCommonJS(assert_exports);
27
29
  var isFalsy = (value) => {
28
- return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value)
29
- }
30
+ return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value);
31
+ };
30
32
  var isRequest = (value) => {
31
- return typeof Request !== "undefined" && value instanceof Request
32
- }
33
+ return typeof Request !== "undefined" && value instanceof Request;
34
+ };
33
35
  var isValidURL = (value) => {
34
- if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false
35
- const regex =
36
- /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/
37
- return regex.test(value)
38
- }
36
+ if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
37
+ const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/;
38
+ return regex.test(value);
39
+ };
40
+ var isJWTPayloadWithToken = (payload) => {
41
+ return typeof payload === "object" && payload !== null && "token" in payload && typeof payload?.token === "string";
42
+ };
39
43
  // Annotate the CommonJS export names for ESM import in node:
40
- 0 &&
41
- (module.exports = {
42
- isFalsy,
43
- isRequest,
44
- isValidURL,
45
- })
44
+ 0 && (module.exports = {
45
+ isFalsy,
46
+ isJWTPayloadWithToken,
47
+ isRequest,
48
+ isValidURL
49
+ });
package/dist/assert.d.ts CHANGED
@@ -1,5 +1,14 @@
1
- declare const isFalsy: (value: unknown) => boolean
2
- declare const isRequest: (value: unknown) => value is Request
3
- declare const isValidURL: (value: string) => boolean
1
+ import { J as JWTPayloadWithToken } from './index-DkaLJFn8.js';
2
+ import 'zod';
3
+ import './schemas.js';
4
+ import '@aura-stack/router/cookie';
5
+ import '@aura-stack/jose';
6
+ import '@aura-stack/jose/jose';
7
+ import './@types/utility.js';
4
8
 
5
- export { isFalsy, isRequest, isValidURL }
9
+ declare const isFalsy: (value: unknown) => boolean;
10
+ declare const isRequest: (value: unknown) => value is Request;
11
+ declare const isValidURL: (value: string) => boolean;
12
+ declare const isJWTPayloadWithToken: (payload: unknown) => payload is JWTPayloadWithToken;
13
+
14
+ export { isFalsy, isJWTPayloadWithToken, isRequest, isValidURL };
package/dist/assert.js CHANGED
@@ -1,2 +1,12 @@
1
- import { isFalsy, isRequest, isValidURL } from "./chunk-6SM22VVJ.js"
2
- export { isFalsy, isRequest, isValidURL }
1
+ import {
2
+ isFalsy,
3
+ isJWTPayloadWithToken,
4
+ isRequest,
5
+ isValidURL
6
+ } from "./chunk-EIL2FPSS.js";
7
+ export {
8
+ isFalsy,
9
+ isJWTPayloadWithToken,
10
+ isRequest,
11
+ isValidURL
12
+ };
@@ -0,0 +1,63 @@
1
+ import {
2
+ createAuthorizationURL,
3
+ createRedirectTo,
4
+ createRedirectURI
5
+ } from "./chunk-N4SX7TZT.js";
6
+ import {
7
+ cacheControl
8
+ } from "./chunk-STHEPPUZ.js";
9
+ import {
10
+ createPKCE,
11
+ generateSecure
12
+ } from "./chunk-N2APGLXA.js";
13
+
14
+ // src/actions/signIn/signIn.ts
15
+ import { z } from "zod";
16
+ import { createEndpoint, createEndpointConfig, HeadersBuilder } from "@aura-stack/router";
17
+ var signInConfig = (oauth) => {
18
+ return createEndpointConfig("/signIn/:oauth", {
19
+ schemas: {
20
+ params: z.object({
21
+ oauth: z.enum(
22
+ Object.keys(oauth),
23
+ "The OAuth provider is not supported or invalid."
24
+ )
25
+ }),
26
+ searchParams: z.object({
27
+ redirectTo: z.string().optional()
28
+ })
29
+ }
30
+ });
31
+ };
32
+ var signInAction = (oauth) => {
33
+ return createEndpoint(
34
+ "GET",
35
+ "/signIn/:oauth",
36
+ async (ctx) => {
37
+ const {
38
+ request,
39
+ params: { oauth: oauth2 },
40
+ searchParams: { redirectTo },
41
+ context: { oauth: providers, cookies, trustedProxyHeaders, basePath }
42
+ } = ctx;
43
+ const state = generateSecure();
44
+ const redirectURI = createRedirectURI(request, oauth2, basePath, trustedProxyHeaders);
45
+ const redirectToValue = createRedirectTo(request, redirectTo, trustedProxyHeaders);
46
+ const { codeVerifier, codeChallenge, method } = await createPKCE();
47
+ const authorization = createAuthorizationURL(providers[oauth2], redirectURI, state, codeChallenge, method);
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();
49
+ return Response.json(
50
+ { oauth: oauth2 },
51
+ {
52
+ status: 302,
53
+ headers
54
+ }
55
+ );
56
+ },
57
+ signInConfig(oauth)
58
+ );
59
+ };
60
+
61
+ export {
62
+ signInAction
63
+ };
@@ -1,20 +1,22 @@
1
1
  // src/oauth/x.ts
2
2
  var x = {
3
- id: "x",
4
- name: "X",
5
- authorizeURL: "https://x.com/i/oauth2/authorize",
6
- accessToken: "https://api.x.com/2/oauth2/token",
7
- userInfo: "https://api.x.com/2/users/me?user.fields=profile_image_url",
8
- scope: "users.read users.email tweet.read offline.access",
9
- responseType: "code",
10
- profile({ data }) {
11
- return {
12
- sub: data.id,
13
- name: data.name,
14
- image: data.profile_image_url,
15
- email: "",
16
- }
17
- },
18
- }
3
+ id: "x",
4
+ name: "X",
5
+ authorizeURL: "https://x.com/i/oauth2/authorize",
6
+ accessToken: "https://api.x.com/2/oauth2/token",
7
+ userInfo: "https://api.x.com/2/users/me?user.fields=profile_image_url",
8
+ scope: "users.read users.email tweet.read offline.access",
9
+ responseType: "code",
10
+ profile({ data }) {
11
+ return {
12
+ sub: data.id,
13
+ name: data.name,
14
+ image: data.profile_image_url,
15
+ email: ""
16
+ };
17
+ }
18
+ };
19
19
 
20
- export { x }
20
+ export {
21
+ x
22
+ };
@@ -0,0 +1,22 @@
1
+ // src/oauth/strava.ts
2
+ var strava = {
3
+ id: "strava",
4
+ name: "Strava",
5
+ authorizeURL: "https://www.strava.com/oauth/authorize",
6
+ accessToken: "https://www.strava.com/oauth/token",
7
+ userInfo: "https://www.strava.com/api/v3/athlete",
8
+ scope: "read",
9
+ responseType: "code",
10
+ profile(profile) {
11
+ return {
12
+ sub: profile.id.toString(),
13
+ name: `${profile.firstname} ${profile.lastname}`,
14
+ image: profile.profile,
15
+ email: ""
16
+ };
17
+ }
18
+ };
19
+
20
+ export {
21
+ strava
22
+ };
@@ -0,0 +1,70 @@
1
+ import {
2
+ createRedirectTo
3
+ } from "./chunk-N4SX7TZT.js";
4
+ import {
5
+ expiredCookieAttributes
6
+ } from "./chunk-W6LG7BFW.js";
7
+ import {
8
+ cacheControl
9
+ } from "./chunk-STHEPPUZ.js";
10
+ import {
11
+ verifyCSRF
12
+ } from "./chunk-N2APGLXA.js";
13
+ import {
14
+ getNormalizedOriginPath
15
+ } from "./chunk-CXLATHS5.js";
16
+ import {
17
+ AuthSecurityError
18
+ } from "./chunk-RRLIF4PQ.js";
19
+
20
+ // src/actions/signOut/signOut.ts
21
+ import { z } from "zod";
22
+ import { createEndpoint, createEndpointConfig, HeadersBuilder, statusCode } from "@aura-stack/router";
23
+ var config = createEndpointConfig({
24
+ schemas: {
25
+ searchParams: z.object({
26
+ token_type_hint: z.literal("session_token"),
27
+ redirectTo: z.string().optional()
28
+ })
29
+ }
30
+ });
31
+ var signOutAction = createEndpoint(
32
+ "POST",
33
+ "/signOut",
34
+ async (ctx) => {
35
+ const {
36
+ request,
37
+ headers,
38
+ searchParams: { redirectTo },
39
+ context: { jose, cookies }
40
+ } = ctx;
41
+ const session = headers.getCookie(cookies.sessionToken.name);
42
+ const csrfToken = headers.getCookie(cookies.csrfToken.name);
43
+ const header = headers.getHeader("X-CSRF-Token");
44
+ if (!session) {
45
+ throw new AuthSecurityError("SESSION_TOKEN_MISSING", "The sessionToken is missing.");
46
+ }
47
+ if (!csrfToken) {
48
+ throw new AuthSecurityError("CSRF_TOKEN_MISSING", "The CSRF token is missing.");
49
+ }
50
+ if (!header) {
51
+ throw new AuthSecurityError("CSRF_TOKEN_MISSING", "The CSRF header is missing.");
52
+ }
53
+ await verifyCSRF(jose, csrfToken, header);
54
+ await jose.decodeJWT(session);
55
+ const normalizedOriginPath = getNormalizedOriginPath(request.url);
56
+ const location = createRedirectTo(
57
+ new Request(normalizedOriginPath, {
58
+ headers: headers.toHeaders()
59
+ }),
60
+ redirectTo
61
+ );
62
+ const headersList = new HeadersBuilder(cacheControl).setHeader("Location", location).setCookie(cookies.csrfToken.name, "", expiredCookieAttributes).setCookie(cookies.sessionToken.name, "", expiredCookieAttributes).toHeaders();
63
+ return Response.json({ message: "Signed out successfully" }, { status: statusCode.ACCEPTED, headers: headersList });
64
+ },
65
+ config
66
+ );
67
+
68
+ export {
69
+ signOutAction
70
+ };
@@ -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
+ };
@@ -0,0 +1,143 @@
1
+ import {
2
+ isAuthInternalError,
3
+ isAuthSecurityError,
4
+ isOAuthProtocolError
5
+ } from "./chunk-RRLIF4PQ.js";
6
+
7
+ // src/utils.ts
8
+ import { isInvalidZodSchemaError, isRouterError } from "@aura-stack/router";
9
+ var toSnakeCase = (str) => {
10
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/^_+/, "");
11
+ };
12
+ var toUpperCase = (str) => {
13
+ return str.toUpperCase();
14
+ };
15
+ var toCastCase = (obj, type = "snake") => {
16
+ return Object.entries(obj).reduce((previous, [key, value]) => {
17
+ const newKey = type === "snake" ? toSnakeCase(key) : toUpperCase(key);
18
+ return { ...previous, [newKey]: value };
19
+ }, {});
20
+ };
21
+ var equals = (a, b) => {
22
+ if (a === null || b === null || a === void 0 || b === void 0) return false;
23
+ return a === b;
24
+ };
25
+ var sanitizeURL = (url) => {
26
+ try {
27
+ let decodedURL = decodeURIComponent(url).trim();
28
+ const protocolMatch = decodedURL.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)/);
29
+ let protocol = "";
30
+ let rest = decodedURL;
31
+ if (protocolMatch) {
32
+ protocol = protocolMatch[1];
33
+ rest = decodedURL.slice(protocol.length);
34
+ const slashIndex = rest.indexOf("/");
35
+ if (slashIndex === -1) {
36
+ return protocol + rest;
37
+ }
38
+ const domain = rest.slice(0, slashIndex);
39
+ let path = rest.slice(slashIndex).replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
40
+ if (path !== "/" && path.endsWith("/")) {
41
+ path = path.replace(/\/+$/, "/");
42
+ } else if (path !== "/") {
43
+ path = path.replace(/\/+$/, "");
44
+ }
45
+ return protocol + domain + path;
46
+ }
47
+ let sanitized = decodedURL.replace(/\/\.\.\//g, "/").replace(/\/\.\.$/, "").replace(/\.{2,}/g, "").replace(/\/{2,}/g, "/");
48
+ if (sanitized !== "/" && sanitized.endsWith("/")) {
49
+ sanitized = sanitized.replace(/\/+$/, "/");
50
+ } else if (sanitized !== "/") {
51
+ sanitized = sanitized.replace(/\/+$/, "");
52
+ }
53
+ return sanitized;
54
+ } catch {
55
+ return url.trim();
56
+ }
57
+ };
58
+ var isValidRelativePath = (path) => {
59
+ if (!path || typeof path !== "string") return false;
60
+ if (!path.startsWith("/") || path.includes("://") || path.includes("\r") || path.includes("\n")) return false;
61
+ if (/[\x00-\x1F\x7F]/.test(path) || path.includes("\0")) return false;
62
+ const sanitized = sanitizeURL(path);
63
+ if (sanitized.includes("..")) return false;
64
+ return true;
65
+ };
66
+ var onErrorHandler = (error) => {
67
+ if (isRouterError(error)) {
68
+ const { message, status, statusText } = error;
69
+ return Response.json({ type: "ROUTER_ERROR", code: "ROUTER_INTERNAL_ERROR", message }, { status, statusText });
70
+ }
71
+ if (isInvalidZodSchemaError(error)) {
72
+ return Response.json({ type: "ROUTER_ERROR", code: "INVALID_REQUEST", message: error.errors }, { status: 422 });
73
+ }
74
+ if (isOAuthProtocolError(error)) {
75
+ const { error: errorCode, message, type, errorURI } = error;
76
+ return Response.json(
77
+ {
78
+ type,
79
+ error: errorCode,
80
+ error_description: message,
81
+ error_uri: errorURI
82
+ },
83
+ { status: 400 }
84
+ );
85
+ }
86
+ if (isAuthInternalError(error) || isAuthSecurityError(error)) {
87
+ const { type, code, message } = error;
88
+ return Response.json(
89
+ {
90
+ type,
91
+ code,
92
+ message
93
+ },
94
+ { status: 400 }
95
+ );
96
+ }
97
+ return Response.json({ type: "SERVER_ERROR", code: "server_error", message: "An unexpected error occurred" }, { status: 500 });
98
+ };
99
+ var getNormalizedOriginPath = (path) => {
100
+ try {
101
+ const url = new URL(path);
102
+ url.hash = "";
103
+ url.search = "";
104
+ return `${url.origin}${url.pathname}`;
105
+ } catch {
106
+ return sanitizeURL(path);
107
+ }
108
+ };
109
+ var toISOString = (date) => {
110
+ return new Date(date).toISOString();
111
+ };
112
+ var useSecureCookies = (request, trustedProxyHeaders) => {
113
+ return trustedProxyHeaders ? request.url.startsWith("https://") || request.headers.get("X-Forwarded-Proto") === "https" || (request.headers.get("Forwarded")?.includes("proto=https") ?? false) : request.url.startsWith("https://");
114
+ };
115
+ var formatZodError = (error) => {
116
+ if (!error.issues || error.issues.length === 0) {
117
+ return {};
118
+ }
119
+ return error.issues.reduce((previous, issue) => {
120
+ const key = issue.path.join(".");
121
+ return {
122
+ ...previous,
123
+ [key]: {
124
+ code: issue.code,
125
+ message: issue.message
126
+ }
127
+ };
128
+ }, {});
129
+ };
130
+
131
+ export {
132
+ toSnakeCase,
133
+ toUpperCase,
134
+ toCastCase,
135
+ equals,
136
+ sanitizeURL,
137
+ isValidRelativePath,
138
+ onErrorHandler,
139
+ getNormalizedOriginPath,
140
+ toISOString,
141
+ useSecureCookies,
142
+ formatZodError
143
+ };
@@ -1,20 +1,22 @@
1
1
  // src/oauth/spotify.ts
2
2
  var spotify = {
3
- id: "spotify",
4
- name: "Spotify",
5
- authorizeURL: "https://accounts.spotify.com/authorize",
6
- accessToken: "https://accounts.spotify.com/api/token",
7
- userInfo: "https://api.spotify.com/v1/me",
8
- scope: "user-read-email user-read-private",
9
- responseType: "token",
10
- profile(profile) {
11
- return {
12
- sub: profile.id,
13
- name: profile.display_name,
14
- email: profile.email,
15
- image: profile.images?.[0]?.url,
16
- }
17
- },
18
- }
3
+ id: "spotify",
4
+ name: "Spotify",
5
+ authorizeURL: "https://accounts.spotify.com/authorize",
6
+ accessToken: "https://accounts.spotify.com/api/token",
7
+ userInfo: "https://api.spotify.com/v1/me",
8
+ scope: "user-read-email user-read-private",
9
+ responseType: "token",
10
+ profile(profile) {
11
+ return {
12
+ sub: profile.id,
13
+ name: profile.display_name,
14
+ email: profile.email,
15
+ image: profile.images?.[0]?.url
16
+ };
17
+ }
18
+ };
19
19
 
20
- export { spotify }
20
+ export {
21
+ spotify
22
+ };
@@ -0,0 +1,22 @@
1
+ // src/assert.ts
2
+ var isFalsy = (value) => {
3
+ return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value);
4
+ };
5
+ var isRequest = (value) => {
6
+ return typeof Request !== "undefined" && value instanceof Request;
7
+ };
8
+ var isValidURL = (value) => {
9
+ if (value.includes("\r\n") || value.includes("\n") || value.includes("\r")) return false;
10
+ const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()*+,;=:@-]*)*\/?$/;
11
+ return regex.test(value);
12
+ };
13
+ var isJWTPayloadWithToken = (payload) => {
14
+ return typeof payload === "object" && payload !== null && "token" in payload && typeof payload?.token === "string";
15
+ };
16
+
17
+ export {
18
+ isFalsy,
19
+ isRequest,
20
+ isValidURL,
21
+ isJWTPayloadWithToken
22
+ };