@aura-stack/auth 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/README.md +36 -1
  2. package/dist/@types/index.cjs +0 -18
  3. package/dist/@types/index.d.ts +2 -12
  4. package/dist/@types/index.js +0 -1
  5. package/dist/assert-_fBNnaOk.js +3 -0
  6. package/dist/assert-hDwQ_SPO.cjs +3 -0
  7. package/dist/client/index.cjs +1 -135
  8. package/dist/client/index.d.ts +11 -14
  9. package/dist/client/index.js +1 -10
  10. package/dist/crypto-D6_SoGMH.cjs +1 -0
  11. package/dist/crypto-DyrRzBSQ.js +1 -0
  12. package/dist/env-7as-tgzO.cjs +1 -0
  13. package/dist/env-CJtSi1eX.js +1 -0
  14. package/dist/errors-Czt_w1t_.js +1 -0
  15. package/dist/errors-DcK2ELlk.cjs +1 -0
  16. package/dist/identity-b8FCr0Oa.cjs +1 -0
  17. package/dist/index-C9U6ICDT.d.ts +2796 -0
  18. package/dist/index.cjs +1 -2427
  19. package/dist/index.d.ts +2 -14
  20. package/dist/index.js +1 -59
  21. package/dist/logger-DjXkgSn5.js +1 -0
  22. package/dist/logger-G5PinyEc.cjs +1 -0
  23. package/dist/oauth/atlassian.cjs +1 -57
  24. package/dist/oauth/atlassian.d.ts +2 -12
  25. package/dist/oauth/atlassian.js +1 -6
  26. package/dist/oauth/bitbucket.cjs +1 -49
  27. package/dist/oauth/bitbucket.d.ts +2 -12
  28. package/dist/oauth/bitbucket.js +1 -6
  29. package/dist/oauth/click-up.cjs +1 -0
  30. package/dist/oauth/click-up.d.ts +2 -0
  31. package/dist/oauth/click-up.js +1 -0
  32. package/dist/oauth/discord.cjs +1 -57
  33. package/dist/oauth/discord.d.ts +2 -12
  34. package/dist/oauth/discord.js +1 -6
  35. package/dist/oauth/dribbble.cjs +1 -0
  36. package/dist/oauth/dribbble.d.ts +2 -0
  37. package/dist/oauth/dribbble.js +1 -0
  38. package/dist/oauth/dropbox.cjs +1 -53
  39. package/dist/oauth/dropbox.d.ts +2 -12
  40. package/dist/oauth/dropbox.js +1 -6
  41. package/dist/oauth/figma.cjs +1 -49
  42. package/dist/oauth/figma.d.ts +2 -12
  43. package/dist/oauth/figma.js +1 -6
  44. package/dist/oauth/github.cjs +1 -49
  45. package/dist/oauth/github.d.ts +2 -12
  46. package/dist/oauth/github.js +1 -6
  47. package/dist/oauth/gitlab.cjs +1 -49
  48. package/dist/oauth/gitlab.d.ts +2 -12
  49. package/dist/oauth/gitlab.js +1 -6
  50. package/dist/oauth/index.cjs +1 -673
  51. package/dist/oauth/index.d.ts +2 -12
  52. package/dist/oauth/index.js +1 -68
  53. package/dist/oauth/mailchimp.cjs +1 -49
  54. package/dist/oauth/mailchimp.d.ts +2 -12
  55. package/dist/oauth/mailchimp.js +1 -6
  56. package/dist/oauth/notion.cjs +1 -131
  57. package/dist/oauth/notion.d.ts +2 -12
  58. package/dist/oauth/notion.js +1 -9
  59. package/dist/oauth/pinterest.cjs +1 -49
  60. package/dist/oauth/pinterest.d.ts +2 -12
  61. package/dist/oauth/pinterest.js +1 -6
  62. package/dist/oauth/spotify.cjs +1 -49
  63. package/dist/oauth/spotify.d.ts +2 -12
  64. package/dist/oauth/spotify.js +1 -6
  65. package/dist/oauth/strava.cjs +1 -49
  66. package/dist/oauth/strava.d.ts +2 -12
  67. package/dist/oauth/strava.js +1 -6
  68. package/dist/oauth/twitch.cjs +1 -95
  69. package/dist/oauth/twitch.d.ts +2 -12
  70. package/dist/oauth/twitch.js +1 -7
  71. package/dist/oauth/x.cjs +1 -49
  72. package/dist/oauth/x.d.ts +2 -12
  73. package/dist/oauth/x.js +1 -6
  74. package/dist/oauth-D3_mnBOx.js +1 -0
  75. package/dist/oauth-gPiWxjBd.cjs +1 -0
  76. package/dist/shared/crypto.cjs +1 -0
  77. package/dist/shared/crypto.d.ts +71 -0
  78. package/dist/shared/crypto.js +1 -0
  79. package/dist/shared/identity.cjs +1 -0
  80. package/dist/shared/identity.d.ts +2 -0
  81. package/dist/shared/identity.js +1 -0
  82. package/dist/shared/index.cjs +1 -0
  83. package/dist/shared/index.d.ts +5 -0
  84. package/dist/shared/index.js +1 -0
  85. package/package.json +37 -11
  86. package/dist/@types/router.d.cjs +0 -1
  87. package/dist/@types/router.d.d.ts +0 -16
  88. package/dist/@types/router.d.js +0 -0
  89. package/dist/@types/utility.cjs +0 -18
  90. package/dist/@types/utility.d.ts +0 -6
  91. package/dist/@types/utility.js +0 -1
  92. package/dist/actions/callback/access-token.cjs +0 -250
  93. package/dist/actions/callback/access-token.d.ts +0 -33
  94. package/dist/actions/callback/access-token.js +0 -9
  95. package/dist/actions/callback/callback.cjs +0 -715
  96. package/dist/actions/callback/callback.d.ts +0 -42
  97. package/dist/actions/callback/callback.js +0 -18
  98. package/dist/actions/callback/userinfo.cjs +0 -283
  99. package/dist/actions/callback/userinfo.d.ts +0 -25
  100. package/dist/actions/callback/userinfo.js +0 -13
  101. package/dist/actions/csrfToken/csrfToken.cjs +0 -189
  102. package/dist/actions/csrfToken/csrfToken.d.ts +0 -7
  103. package/dist/actions/csrfToken/csrfToken.js +0 -13
  104. package/dist/actions/index.cjs +0 -1161
  105. package/dist/actions/index.d.ts +0 -17
  106. package/dist/actions/index.js +0 -39
  107. package/dist/actions/session/session.cjs +0 -188
  108. package/dist/actions/session/session.d.ts +0 -7
  109. package/dist/actions/session/session.js +0 -12
  110. package/dist/actions/signIn/authorization-url.cjs +0 -288
  111. package/dist/actions/signIn/authorization-url.d.ts +0 -31
  112. package/dist/actions/signIn/authorization-url.js +0 -16
  113. package/dist/actions/signIn/authorization.cjs +0 -281
  114. package/dist/actions/signIn/authorization.d.ts +0 -54
  115. package/dist/actions/signIn/authorization.js +0 -19
  116. package/dist/actions/signIn/signIn.cjs +0 -595
  117. package/dist/actions/signIn/signIn.d.ts +0 -42
  118. package/dist/actions/signIn/signIn.js +0 -16
  119. package/dist/actions/signOut/signOut.cjs +0 -492
  120. package/dist/actions/signOut/signOut.d.ts +0 -16
  121. package/dist/actions/signOut/signOut.js +0 -15
  122. package/dist/api/createApi.cjs +0 -750
  123. package/dist/api/createApi.d.ts +0 -12
  124. package/dist/api/createApi.js +0 -19
  125. package/dist/api/getSession.cjs +0 -141
  126. package/dist/api/getSession.d.ts +0 -16
  127. package/dist/api/getSession.js +0 -10
  128. package/dist/api/signIn.cjs +0 -549
  129. package/dist/api/signIn.d.ts +0 -26
  130. package/dist/api/signIn.js +0 -15
  131. package/dist/api/signOut.cjs +0 -279
  132. package/dist/api/signOut.d.ts +0 -16
  133. package/dist/api/signOut.js +0 -13
  134. package/dist/assert.cjs +0 -194
  135. package/dist/assert.d.ts +0 -37
  136. package/dist/assert.js +0 -26
  137. package/dist/chunk-2A5B7GWR.js +0 -125
  138. package/dist/chunk-2GQLSIJ2.js +0 -40
  139. package/dist/chunk-2IR674WX.js +0 -44
  140. package/dist/chunk-3J5TUH2I.js +0 -50
  141. package/dist/chunk-4RWSYUKX.js +0 -98
  142. package/dist/chunk-4YHJ4IEQ.js +0 -25
  143. package/dist/chunk-54CZPKR4.js +0 -25
  144. package/dist/chunk-5LZ7TOM3.js +0 -25
  145. package/dist/chunk-5X7JZMEF.js +0 -0
  146. package/dist/chunk-7BE46WWS.js +0 -88
  147. package/dist/chunk-7YYXFKLR.js +0 -35
  148. package/dist/chunk-C3A37LQC.js +0 -33
  149. package/dist/chunk-CITNGXDA.js +0 -31
  150. package/dist/chunk-CWX724AG.js +0 -78
  151. package/dist/chunk-D2CSIUKP.js +0 -74
  152. package/dist/chunk-E6G5YCI6.js +0 -25
  153. package/dist/chunk-EBAMFRB7.js +0 -34
  154. package/dist/chunk-EEE7UM5T.js +0 -25
  155. package/dist/chunk-FPCVZUVG.js +0 -37
  156. package/dist/chunk-FW4W3REU.js +0 -25
  157. package/dist/chunk-GNNBM2WJ.js +0 -83
  158. package/dist/chunk-IPKO6UQN.js +0 -25
  159. package/dist/chunk-ITQ7352M.js +0 -0
  160. package/dist/chunk-JOCGX3RP.js +0 -59
  161. package/dist/chunk-KBXWTD6E.js +0 -94
  162. package/dist/chunk-KMMAZFSJ.js +0 -25
  163. package/dist/chunk-LATR3NIV.js +0 -117
  164. package/dist/chunk-LAYPUDQF.js +0 -39
  165. package/dist/chunk-LDU7A2JE.js +0 -25
  166. package/dist/chunk-LX3TJ2TJ.js +0 -294
  167. package/dist/chunk-NHZBQNRR.js +0 -143
  168. package/dist/chunk-OVHNRULD.js +0 -33
  169. package/dist/chunk-PDP3PHB3.js +0 -127
  170. package/dist/chunk-PG7UYFG5.js +0 -0
  171. package/dist/chunk-PHYNROD4.js +0 -47
  172. package/dist/chunk-QQEKY4XP.js +0 -29
  173. package/dist/chunk-U4RK4LKJ.js +0 -348
  174. package/dist/chunk-U5663F2U.js +0 -70
  175. package/dist/chunk-UN7X6SU5.js +0 -53
  176. package/dist/chunk-UZQJJD6A.js +0 -100
  177. package/dist/chunk-V6LLEAR4.js +0 -80
  178. package/dist/chunk-WHNDRO3N.js +0 -50
  179. package/dist/chunk-XY5R3EHH.js +0 -204
  180. package/dist/chunk-ZNCZVF6U.js +0 -14
  181. package/dist/client/client.cjs +0 -135
  182. package/dist/client/client.d.ts +0 -85
  183. package/dist/client/client.js +0 -9
  184. package/dist/context.cjs +0 -1237
  185. package/dist/context.d.ts +0 -16
  186. package/dist/context.js +0 -28
  187. package/dist/cookie.cjs +0 -277
  188. package/dist/cookie.d.ts +0 -89
  189. package/dist/cookie.js +0 -30
  190. package/dist/createAuth.cjs +0 -2320
  191. package/dist/createAuth.d.ts +0 -12
  192. package/dist/createAuth.js +0 -48
  193. package/dist/env.cjs +0 -78
  194. package/dist/env.d.ts +0 -10
  195. package/dist/env.js +0 -12
  196. package/dist/errors.cjs +0 -102
  197. package/dist/errors.d.ts +0 -60
  198. package/dist/errors.js +0 -22
  199. package/dist/headers.cjs +0 -61
  200. package/dist/headers.d.ts +0 -33
  201. package/dist/headers.js +0 -12
  202. package/dist/index-_aXtxb_s.d.ts +0 -1377
  203. package/dist/jose.cjs +0 -166
  204. package/dist/jose.d.ts +0 -12
  205. package/dist/jose.js +0 -20
  206. package/dist/logger.cjs +0 -424
  207. package/dist/logger.d.ts +0 -12
  208. package/dist/logger.js +0 -17
  209. package/dist/request.cjs +0 -38
  210. package/dist/request.d.ts +0 -13
  211. package/dist/request.js +0 -6
  212. package/dist/schemas.cjs +0 -158
  213. package/dist/schemas.d.ts +0 -229
  214. package/dist/schemas.js +0 -24
  215. package/dist/secure.cjs +0 -170
  216. package/dist/secure.d.ts +0 -41
  217. package/dist/secure.js +0 -20
  218. package/dist/utils.cjs +0 -329
  219. package/dist/utils.d.ts +0 -35
  220. package/dist/utils.js +0 -36
@@ -1,279 +0,0 @@
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
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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);
19
-
20
- // src/api/signOut.ts
21
- var signOut_exports = {};
22
- __export(signOut_exports, {
23
- signOut: () => signOut
24
- });
25
- module.exports = __toCommonJS(signOut_exports);
26
-
27
- // src/env.ts
28
- var import_meta = {};
29
- var env = new Proxy({}, {
30
- get(_, prop) {
31
- if (typeof prop !== "string") return void 0;
32
- const hasProperty = (process2) => {
33
- return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
34
- };
35
- try {
36
- if (typeof process !== "undefined" && hasProperty(process.env)) {
37
- return process.env[prop];
38
- }
39
- if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
40
- return import_meta.env[prop];
41
- }
42
- if (typeof Deno !== "undefined" && Deno.env?.get) {
43
- return Deno.env.get(prop);
44
- }
45
- if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
46
- return Bun.env[prop];
47
- }
48
- const globalValue = globalThis[prop];
49
- return typeof globalValue === "string" ? globalValue : void 0;
50
- } catch {
51
- return void 0;
52
- }
53
- }
54
- });
55
-
56
- // src/cookie.ts
57
- var import_cookie = require("@aura-stack/router/cookie");
58
-
59
- // src/errors.ts
60
- var AuthInternalError = class extends Error {
61
- type = "AUTH_INTERNAL_ERROR";
62
- code;
63
- constructor(code, message, options) {
64
- super(message, options);
65
- this.code = code;
66
- this.name = new.target.name;
67
- Error.captureStackTrace(this, new.target);
68
- }
69
- };
70
- var AuthSecurityError = class extends Error {
71
- type = "AUTH_SECURITY_ERROR";
72
- code;
73
- constructor(code, message, options) {
74
- super(message, options);
75
- this.code = code;
76
- this.name = new.target.name;
77
- Error.captureStackTrace(this, new.target);
78
- }
79
- };
80
-
81
- // src/cookie.ts
82
- var defaultCookieOptions = {
83
- httpOnly: true,
84
- sameSite: "lax",
85
- path: "/",
86
- maxAge: 60 * 60 * 24 * 15
87
- };
88
- var oauthCookieOptions = {
89
- httpOnly: true,
90
- maxAge: 5 * 60,
91
- sameSite: "lax",
92
- expires: new Date(Date.now() + 5 * 60 * 1e3)
93
- };
94
- var expiredCookieAttributes = {
95
- ...defaultCookieOptions,
96
- expires: /* @__PURE__ */ new Date(0),
97
- maxAge: 0,
98
- secure: true
99
- };
100
- var getCookie = (request, cookieName) => {
101
- const cookies = request instanceof Request ? request.headers.get("Cookie") : request.get("Cookie");
102
- if (!cookies) {
103
- throw new AuthInternalError("COOKIE_NOT_FOUND", "No cookies found. There is no active session");
104
- }
105
- const value = (0, import_cookie.parse)(cookies)[cookieName];
106
- if (!value) {
107
- throw new AuthInternalError("COOKIE_NOT_FOUND", `Cookie "${cookieName}" not found. There is no active session`);
108
- }
109
- return value;
110
- };
111
-
112
- // src/utils.ts
113
- var import_router = require("@aura-stack/router");
114
-
115
- // src/assert.ts
116
- var import_crypto = require("@aura-stack/jose/crypto");
117
- var isJWTPayloadWithToken = (payload) => {
118
- return typeof payload === "object" && payload !== null && "token" in payload && typeof payload?.token === "string";
119
- };
120
- var timingSafeEqual = (a, b) => {
121
- const bufferA = import_crypto.encoder.encode(a);
122
- const bufferB = import_crypto.encoder.encode(b);
123
- const len = Math.max(bufferA.length, bufferB.length);
124
- let diff = 0;
125
- for (let i = 0; i < len; i++) {
126
- diff |= (bufferA[i] ?? 0) ^ (bufferB[i] ?? 0);
127
- }
128
- return diff === 0 && bufferA.length === bufferB.length;
129
- };
130
-
131
- // src/utils.ts
132
- var equals = (a, b) => {
133
- if (a === null || b === null || a === void 0 || b === void 0) return false;
134
- return a === b;
135
- };
136
- var getErrorName = (error) => {
137
- if (error instanceof Error) {
138
- return error.name;
139
- }
140
- return typeof error === "string" ? error : "UnknownError";
141
- };
142
-
143
- // src/jose.ts
144
- var import_jose = require("@aura-stack/jose");
145
- var import_jose2 = require("@aura-stack/jose/jose");
146
- var import_crypto2 = require("@aura-stack/jose/crypto");
147
- var jwtVerificationOptions = {
148
- algorithms: ["HS256"],
149
- typ: "JWT"
150
- };
151
-
152
- // src/secure.ts
153
- var verifyCSRF = async (jose, cookie, header) => {
154
- try {
155
- const cookiePayload = await jose.verifyJWS(cookie, jwtVerificationOptions);
156
- const headerPayload = await jose.verifyJWS(header, jwtVerificationOptions);
157
- if (!isJWTPayloadWithToken(cookiePayload)) {
158
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "Cookie payload missing token field.");
159
- }
160
- if (!isJWTPayloadWithToken(headerPayload)) {
161
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "Header payload missing token field.");
162
- }
163
- if (!equals(cookiePayload.token.length, headerPayload.token.length)) {
164
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
165
- }
166
- if (!timingSafeEqual(cookiePayload.token, headerPayload.token)) {
167
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
168
- }
169
- return true;
170
- } catch {
171
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "The CSRF tokens do not match.");
172
- }
173
- };
174
-
175
- // src/headers.ts
176
- var cacheControl = {
177
- "Cache-Control": "no-store",
178
- Pragma: "no-cache",
179
- Expires: "0",
180
- Vary: "Cookie"
181
- };
182
- var contentSecurityPolicy = {
183
- "Content-Security-Policy": [
184
- "default-src 'none'",
185
- "script-src 'self'",
186
- "frame-src 'none'",
187
- "object-src 'none'",
188
- "frame-ancestors 'none'",
189
- "base-uri 'none'"
190
- ].join("; ")
191
- };
192
- var secureHeaders = {
193
- "X-Content-Type-Options": "nosniff",
194
- "X-Frame-Options": "DENY",
195
- "Referrer-Policy": "strict-origin-when-cross-origin"
196
- };
197
- var secureApiHeaders = {
198
- ...cacheControl,
199
- ...contentSecurityPolicy,
200
- ...secureHeaders
201
- };
202
-
203
- // src/api/signOut.ts
204
- var import_router2 = require("@aura-stack/router");
205
- var signOut = async ({
206
- ctx,
207
- headers: headersInit,
208
- redirectTo = "/",
209
- skipCSRFCheck = false
210
- }) => {
211
- const headers = new Headers(headersInit);
212
- const header = headers.get("X-CSRF-Token");
213
- let session = null;
214
- let csrfToken = null;
215
- try {
216
- session = getCookie(headers, ctx.cookies.sessionToken.name);
217
- } catch {
218
- throw new AuthSecurityError("SESSION_TOKEN_MISSING", "The sessionToken is missing.");
219
- }
220
- try {
221
- csrfToken = getCookie(headers, ctx.cookies.csrfToken.name);
222
- } catch {
223
- throw new AuthSecurityError("CSRF_TOKEN_MISSING", "The CSRF token is missing.");
224
- }
225
- ctx?.logger?.log("SIGN_OUT_ATTEMPT", {
226
- structuredData: {
227
- has_session: Boolean(session),
228
- has_csrf_token: Boolean(csrfToken),
229
- has_csrf_header: Boolean(header),
230
- skip_csrf_check: skipCSRFCheck
231
- }
232
- });
233
- if (!session) {
234
- ctx?.logger?.log("SESSION_TOKEN_MISSING");
235
- throw new AuthSecurityError("SESSION_TOKEN_MISSING", "The sessionToken is missing.");
236
- }
237
- if (!skipCSRFCheck) {
238
- if (!csrfToken) {
239
- ctx?.logger?.log("CSRF_TOKEN_MISSING");
240
- throw new AuthSecurityError("CSRF_TOKEN_MISSING", "The CSRF token is missing.");
241
- }
242
- if (!header) {
243
- ctx?.logger?.log("CSRF_HEADER_MISSING");
244
- throw new AuthSecurityError("CSRF_HEADER_MISSING", "The CSRF header is missing.");
245
- }
246
- try {
247
- await verifyCSRF(ctx.jose, csrfToken, header);
248
- } catch (error) {
249
- ctx?.logger?.log("CSRF_TOKEN_INVALID", { structuredData: { error_type: getErrorName(error) } });
250
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "CSRF token verification failed");
251
- }
252
- ctx?.logger?.log("SIGN_OUT_CSRF_VERIFIED");
253
- } else {
254
- try {
255
- await ctx.jose.verifyJWS(csrfToken);
256
- } catch (error) {
257
- ctx?.logger?.log("CSRF_TOKEN_INVALID", { structuredData: { error_type: getErrorName(error) } });
258
- throw new AuthSecurityError("CSRF_TOKEN_INVALID", "CSRF token verification failed");
259
- }
260
- }
261
- try {
262
- await ctx.jose.decodeJWT(session);
263
- ctx?.logger?.log("SIGN_OUT_SUCCESS");
264
- } catch (error) {
265
- ctx?.logger?.log("INVALID_JWT_TOKEN", { structuredData: { error_type: getErrorName(error) } });
266
- }
267
- const headersList = new import_router2.HeadersBuilder(secureApiHeaders).setHeader("Location", redirectTo).setCookie(ctx.cookies.csrfToken.name, "", expiredCookieAttributes).setCookie(ctx.cookies.sessionToken.name, "", expiredCookieAttributes).toHeaders();
268
- return Response.json(
269
- { redirect: Boolean(redirectTo), url: redirectTo },
270
- {
271
- status: 202,
272
- headers: headersList
273
- }
274
- );
275
- };
276
- // Annotate the CommonJS export names for ESM import in node:
277
- 0 && (module.exports = {
278
- signOut
279
- });
@@ -1,16 +0,0 @@
1
- import { F as FunctionAPIContext, i as SignOutAPIOptions } from '../index-_aXtxb_s.js';
2
- import 'zod';
3
- import '../schemas.js';
4
- import 'zod/v4';
5
- import '@aura-stack/jose';
6
- import '@aura-stack/jose/jose';
7
- import '@aura-stack/jose/crypto';
8
- import '@aura-stack/router/cookie';
9
- import '../@types/utility.js';
10
- import 'jose';
11
- import '@aura-stack/router';
12
- import 'zod/v4/core';
13
-
14
- declare const signOut: ({ ctx, headers: headersInit, redirectTo, skipCSRFCheck, }: FunctionAPIContext<SignOutAPIOptions>) => Promise<Response>;
15
-
16
- export { signOut };
@@ -1,13 +0,0 @@
1
- import {
2
- signOut
3
- } from "../chunk-KBXWTD6E.js";
4
- import "../chunk-V6LLEAR4.js";
5
- import "../chunk-UZQJJD6A.js";
6
- import "../chunk-LX3TJ2TJ.js";
7
- import "../chunk-XY5R3EHH.js";
8
- import "../chunk-WHNDRO3N.js";
9
- import "../chunk-U5663F2U.js";
10
- import "../chunk-EBAMFRB7.js";
11
- export {
12
- signOut
13
- };
package/dist/assert.cjs DELETED
@@ -1,194 +0,0 @@
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
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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);
19
-
20
- // src/assert.ts
21
- var assert_exports = {};
22
- __export(assert_exports, {
23
- isFalsy: () => isFalsy,
24
- isJWTPayloadWithToken: () => isJWTPayloadWithToken,
25
- isRelativeURL: () => isRelativeURL,
26
- isRequest: () => isRequest,
27
- isSameOrigin: () => isSameOrigin,
28
- isTrustedOrigin: () => isTrustedOrigin,
29
- isValidURL: () => isValidURL,
30
- patternToRegex: () => patternToRegex,
31
- timingSafeEqual: () => timingSafeEqual,
32
- unsafeChars: () => unsafeChars
33
- });
34
- module.exports = __toCommonJS(assert_exports);
35
-
36
- // src/utils.ts
37
- var import_router = require("@aura-stack/router");
38
-
39
- // src/env.ts
40
- var import_meta = {};
41
- var env = new Proxy({}, {
42
- get(_, prop) {
43
- if (typeof prop !== "string") return void 0;
44
- const hasProperty = (process2) => {
45
- return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
46
- };
47
- try {
48
- if (typeof process !== "undefined" && hasProperty(process.env)) {
49
- return process.env[prop];
50
- }
51
- if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
52
- return import_meta.env[prop];
53
- }
54
- if (typeof Deno !== "undefined" && Deno.env?.get) {
55
- return Deno.env.get(prop);
56
- }
57
- if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
58
- return Bun.env[prop];
59
- }
60
- const globalValue = globalThis[prop];
61
- return typeof globalValue === "string" ? globalValue : void 0;
62
- } catch {
63
- return void 0;
64
- }
65
- }
66
- });
67
-
68
- // src/utils.ts
69
- var equals = (a, b) => {
70
- if (a === null || b === null || a === void 0 || b === void 0) return false;
71
- return a === b;
72
- };
73
-
74
- // src/assert.ts
75
- var import_crypto = require("@aura-stack/jose/crypto");
76
- var isFalsy = (value) => {
77
- return value === false || value === 0 || value === "" || value === null || value === void 0 || Number.isNaN(value);
78
- };
79
- var isRequest = (value) => {
80
- return typeof Request !== "undefined" && value instanceof Request;
81
- };
82
- var unsafeChars = [
83
- "<",
84
- ">",
85
- '"',
86
- "`",
87
- " ",
88
- "\r",
89
- "\n",
90
- " ",
91
- "\\",
92
- "%2F",
93
- "%5C",
94
- "%2f",
95
- "%5c",
96
- "\r\n",
97
- "%0A",
98
- "%0D",
99
- "%0a",
100
- "%0d",
101
- "..",
102
- "//",
103
- "///",
104
- "...",
105
- "%20",
106
- "\0"
107
- ];
108
- var isValidURL = (value) => {
109
- if (!new RegExp(/^https?:\/\/[^/]/).test(value)) {
110
- return false;
111
- }
112
- const match = value.match(/^(https?:\/\/)(.*)$/);
113
- if (!match) return false;
114
- const rest = match[2];
115
- for (const char of unsafeChars) {
116
- if (rest.includes(char)) return false;
117
- }
118
- const regex = /^https?:\/\/(?:[a-zA-Z0-9._-]+|localhost|\[[0-9a-fA-F:]+\])(?::\d{1,5})?(?:\/[a-zA-Z0-9._~!$&'()?#*+,;=:@-]*)*\/?$/;
119
- return regex.test(match[0]);
120
- };
121
- var isJWTPayloadWithToken = (payload) => {
122
- return typeof payload === "object" && payload !== null && "token" in payload && typeof payload?.token === "string";
123
- };
124
- var isRelativeURL = (value) => {
125
- if (value.length > 100) return false;
126
- for (const char of unsafeChars) {
127
- if (value.includes(char)) return false;
128
- }
129
- const regex = /^\/[a-zA-Z0-9\-_\/.?&=#]*\/?$/;
130
- return regex.test(value);
131
- };
132
- var isSameOrigin = (origin, expected) => {
133
- const originURL = new URL(origin);
134
- const expectedURL = new URL(expected);
135
- return equals(originURL.origin, expectedURL.origin);
136
- };
137
- var patternToRegex = (pattern) => {
138
- try {
139
- if (pattern.length > 2048) return null;
140
- pattern = pattern.replace(/\\/g, "");
141
- const match = pattern.match(/^(https?):\/\/([a-zA-Z0-9.*-]{1,253})(?::(\d{1,5}|\*))?(?:\/.*)?$/);
142
- if (!match) return null;
143
- const [, protocol, host, port] = match;
144
- const hasWildcard = host.includes("*");
145
- if (hasWildcard && !host.startsWith("*.")) return null;
146
- if (hasWildcard && host.slice(2).includes("*")) return null;
147
- const domain = hasWildcard ? host.slice(2) : host;
148
- const escapedDomain = domain.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
149
- const hostRegex = hasWildcard ? `[^.]+\\.${escapedDomain}` : escapedDomain;
150
- const portRegex = port === "*" ? ":\\d{1,5}" : port ? `:${port}` : "";
151
- return new RegExp(`^${protocol}:\\/\\/${hostRegex}${portRegex}$`);
152
- } catch {
153
- return null;
154
- }
155
- };
156
- var isTrustedOrigin = (url, trustedOrigins) => {
157
- if (!isValidURL(url) || trustedOrigins.length === 0) return false;
158
- try {
159
- const urlOrigin = new URL(url).origin;
160
- for (const pattern of trustedOrigins) {
161
- const regex = patternToRegex(pattern);
162
- if (regex?.test(urlOrigin)) return true;
163
- try {
164
- if (isValidURL(pattern) && equals(new URL(pattern).origin, urlOrigin)) return true;
165
- } catch {
166
- }
167
- }
168
- } catch {
169
- }
170
- return false;
171
- };
172
- var timingSafeEqual = (a, b) => {
173
- const bufferA = import_crypto.encoder.encode(a);
174
- const bufferB = import_crypto.encoder.encode(b);
175
- const len = Math.max(bufferA.length, bufferB.length);
176
- let diff = 0;
177
- for (let i = 0; i < len; i++) {
178
- diff |= (bufferA[i] ?? 0) ^ (bufferB[i] ?? 0);
179
- }
180
- return diff === 0 && bufferA.length === bufferB.length;
181
- };
182
- // Annotate the CommonJS export names for ESM import in node:
183
- 0 && (module.exports = {
184
- isFalsy,
185
- isJWTPayloadWithToken,
186
- isRelativeURL,
187
- isRequest,
188
- isSameOrigin,
189
- isTrustedOrigin,
190
- isValidURL,
191
- patternToRegex,
192
- timingSafeEqual,
193
- unsafeChars
194
- });
package/dist/assert.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { J as JWTPayloadWithToken } from './index-_aXtxb_s.js';
2
- import 'zod';
3
- import './schemas.js';
4
- import 'zod/v4';
5
- import '@aura-stack/jose';
6
- import '@aura-stack/jose/jose';
7
- import '@aura-stack/jose/crypto';
8
- import '@aura-stack/router/cookie';
9
- import './@types/utility.js';
10
- import 'jose';
11
- import '@aura-stack/router';
12
- import 'zod/v4/core';
13
-
14
- declare const isFalsy: (value: unknown) => boolean;
15
- declare const isRequest: (value: unknown) => value is Request;
16
- declare const unsafeChars: string[];
17
- declare const isValidURL: (value: string) => boolean;
18
- declare const isJWTPayloadWithToken: (payload: unknown) => payload is JWTPayloadWithToken;
19
- declare const isRelativeURL: (value: string) => boolean;
20
- declare const isSameOrigin: (origin: string, expected: string) => boolean;
21
- /**
22
- * Converts a trusted origin pattern to a regex for matching.
23
- * Supports `*` as subdomain wildcard: `https://*.example.com` matches `https://app.example.com`
24
- * @todo: add support to Custom URI Schemes (e.g. `myapp://*`).
25
- */
26
- declare const patternToRegex: (pattern: string) => RegExp | null;
27
- /**
28
- * Checks if a URL matches any of the trusted origin patterns.
29
- * A URL is trusted if its origin matches any pattern (exact or wildcard).
30
- *
31
- * @param url - The URL to validate (e.g. from Referer, Origin, redirectTo)
32
- * @param trustedOrigins - Array of exact URLs or patterns (e.g. `https://*.example.com`)
33
- */
34
- declare const isTrustedOrigin: (url: string, trustedOrigins: string[]) => boolean;
35
- declare const timingSafeEqual: (a: string, b: string) => boolean;
36
-
37
- export { isFalsy, isJWTPayloadWithToken, isRelativeURL, isRequest, isSameOrigin, isTrustedOrigin, isValidURL, patternToRegex, timingSafeEqual, unsafeChars };
package/dist/assert.js DELETED
@@ -1,26 +0,0 @@
1
- import {
2
- isFalsy,
3
- isJWTPayloadWithToken,
4
- isRelativeURL,
5
- isRequest,
6
- isSameOrigin,
7
- isTrustedOrigin,
8
- isValidURL,
9
- patternToRegex,
10
- timingSafeEqual,
11
- unsafeChars
12
- } from "./chunk-LX3TJ2TJ.js";
13
- import "./chunk-WHNDRO3N.js";
14
- import "./chunk-U5663F2U.js";
15
- export {
16
- isFalsy,
17
- isJWTPayloadWithToken,
18
- isRelativeURL,
19
- isRequest,
20
- isSameOrigin,
21
- isTrustedOrigin,
22
- isValidURL,
23
- patternToRegex,
24
- timingSafeEqual,
25
- unsafeChars
26
- };
@@ -1,125 +0,0 @@
1
- // src/schemas.ts
2
- import { object, string, enum as options, number, z, null as nullable, union, array } from "zod/v4";
3
- var AuthorizeConfigSchema = z.union([
4
- string().url(),
5
- object({
6
- url: string().url(),
7
- params: object({
8
- responseType: options(["code", "token", "id_token", "refresh_token"]).optional(),
9
- scope: string().optional()
10
- })
11
- })
12
- ]);
13
- var AccessTokenConfigSchema = z.union([
14
- string().url(),
15
- object({
16
- url: string().url(),
17
- headers: z.record(string(), string()).optional()
18
- })
19
- ]);
20
- var UserInfoConfigSchema = z.union([
21
- string().url(),
22
- object({
23
- url: string().url(),
24
- headers: z.record(string(), string()).optional(),
25
- method: string().optional()
26
- })
27
- ]);
28
- var OAuthProviderCredentialsSchema = object({
29
- id: string(),
30
- name: string(),
31
- authorize: AuthorizeConfigSchema.optional(),
32
- /** @deprecated */
33
- authorizeURL: string().url().optional(),
34
- accessToken: AccessTokenConfigSchema,
35
- /** @deprecated */
36
- scope: string().optional(),
37
- userInfo: UserInfoConfigSchema,
38
- /** @deprecated */
39
- responseType: options(["code", "token", "id_token", "refresh_token"]).optional(),
40
- clientId: string(),
41
- clientSecret: string(),
42
- profile: z.function().optional()
43
- });
44
- var OAuthProviderConfigSchema = object({
45
- authorize: AuthorizeConfigSchema.optional(),
46
- /** @deprecated */
47
- authorizeURL: string().url().optional(),
48
- accessToken: AccessTokenConfigSchema,
49
- /** @deprecated */
50
- scope: string().optional(),
51
- userInfo: UserInfoConfigSchema,
52
- /** @deprecated */
53
- responseType: options(["code", "token", "id_token", "refresh_token"]).optional(),
54
- clientId: string(),
55
- clientSecret: string()
56
- });
57
- var OAuthAuthorization = OAuthProviderConfigSchema.extend({
58
- redirectURI: string(),
59
- state: string(),
60
- codeChallenge: string(),
61
- codeChallengeMethod: options(["plain", "S256"])
62
- });
63
- var OAuthAuthorizationResponse = object({
64
- state: string({ message: "Missing state parameter in the OAuth authorization response." }),
65
- code: string({ message: "Missing code parameter in the OAuth authorization response." })
66
- });
67
- var OAuthAuthorizationErrorResponse = object({
68
- error: options([
69
- "invalid_request",
70
- "unauthorized_client",
71
- "access_denied",
72
- "unsupported_response_type",
73
- "invalid_scope",
74
- "server_error",
75
- "temporarily_unavailable"
76
- ]),
77
- error_description: string().optional(),
78
- error_uri: string().optional(),
79
- state: string()
80
- });
81
- var OAuthAccessToken = OAuthProviderConfigSchema.extend({
82
- redirectURI: string(),
83
- code: string(),
84
- codeVerifier: string().min(43).max(128)
85
- });
86
- var OAuthAccessTokenResponse = object({
87
- access_token: string(),
88
- token_type: string().optional(),
89
- expires_in: number().optional(),
90
- refresh_token: string().optional(),
91
- scope: union([string().optional().or(nullable()), array(string()).optional()])
92
- });
93
- var OAuthAccessTokenErrorResponse = object({
94
- error: options([
95
- "invalid_request",
96
- "invalid_client",
97
- "invalid_grant",
98
- "unauthorized_client",
99
- "unsupported_grant_type",
100
- "invalid_scope"
101
- ]),
102
- error_description: string().optional(),
103
- error_uri: string().optional()
104
- });
105
- var OAuthErrorResponse = object({
106
- error: string(),
107
- error_description: string().optional()
108
- });
109
- var OAuthEnvSchema = object({
110
- clientId: z.string().min(1, "OAuth Client ID is required in the environment variables."),
111
- clientSecret: z.string().min(1, "OAuth Client Secret is required in the environment variables.")
112
- });
113
-
114
- export {
115
- OAuthProviderCredentialsSchema,
116
- OAuthProviderConfigSchema,
117
- OAuthAuthorization,
118
- OAuthAuthorizationResponse,
119
- OAuthAuthorizationErrorResponse,
120
- OAuthAccessToken,
121
- OAuthAccessTokenResponse,
122
- OAuthAccessTokenErrorResponse,
123
- OAuthErrorResponse,
124
- OAuthEnvSchema
125
- };