faire-auth 1.0.3 → 1.1.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.
- package/dist/{adapter-factory-lKIOf2OR.mjs → adapter-factory-qPVW8x9-.mjs} +34 -36
- package/dist/{adapter-factory-D1I7joki.cjs → adapter-factory-u8r3oTez.cjs} +66 -68
- package/dist/adapters/drizzle-adapter/index.cjs +34 -40
- package/dist/adapters/drizzle-adapter/index.d.cts +4 -9
- package/dist/adapters/drizzle-adapter/index.d.mts +4 -9
- package/dist/adapters/drizzle-adapter/index.mjs +20 -26
- package/dist/adapters/index.cjs +11 -16
- package/dist/adapters/index.d.cts +11 -37
- package/dist/adapters/index.d.mts +11 -37
- package/dist/adapters/index.mjs +4 -13
- package/dist/adapters/kysely-adapter/index.cjs +270 -11
- package/dist/adapters/kysely-adapter/index.d.cts +9 -19
- package/dist/adapters/kysely-adapter/index.d.mts +9 -19
- package/dist/adapters/kysely-adapter/index.mjs +267 -9
- package/dist/adapters/memory-adapter/index.cjs +146 -9
- package/dist/adapters/memory-adapter/index.d.cts +4 -10
- package/dist/adapters/memory-adapter/index.d.mts +4 -10
- package/dist/adapters/memory-adapter/index.mjs +145 -9
- package/dist/adapters/mongodb-adapter/index.cjs +13 -21
- package/dist/adapters/mongodb-adapter/index.d.cts +3 -8
- package/dist/adapters/mongodb-adapter/index.d.mts +4 -9
- package/dist/adapters/mongodb-adapter/index.mjs +12 -20
- package/dist/adapters/prisma-adapter/index.cjs +12 -20
- package/dist/adapters/prisma-adapter/index.d.cts +4 -8
- package/dist/adapters/prisma-adapter/index.d.mts +4 -8
- package/dist/adapters/prisma-adapter/index.mjs +5 -13
- package/dist/adapters/test.cjs +86 -69
- package/dist/adapters/test.d.cts +7 -11
- package/dist/adapters/test.d.mts +7 -11
- package/dist/adapters/test.mjs +83 -66
- package/dist/api/index.cjs +3 -20
- package/dist/api/index.d.cts +2 -3
- package/dist/api/index.d.mts +2 -3
- package/dist/api/index.mjs +1 -20
- package/dist/api/middleware/index.cjs +4 -11
- package/dist/api/middleware/index.d.cts +3 -9
- package/dist/api/middleware/index.d.mts +3 -9
- package/dist/api/middleware/index.mjs +3 -11
- package/dist/{api-B4RDwBty.mjs → api-0f-F-Fi2.mjs} +292 -189
- package/dist/{api-CaRC1Gio.cjs → api-LjfH6hQi.cjs} +557 -452
- package/dist/{test-utils/bun-sqlite-dialect-BZBvHchL.cjs → bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
- package/dist/{test-utils/bun-sqlite-dialect-BSWhhKNs.mjs → bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
- package/dist/client/index.cjs +8 -15
- package/dist/client/index.d.cts +9 -14
- package/dist/client/index.d.mts +9 -14
- package/dist/client/index.mjs +7 -15
- package/dist/client/lynx/index.cjs +10 -18
- package/dist/client/lynx/index.d.cts +402 -71
- package/dist/client/lynx/index.d.mts +402 -71
- package/dist/client/lynx/index.mjs +5 -13
- package/dist/client/plugins/index.cjs +3 -5
- package/dist/client/plugins/index.d.cts +5 -10
- package/dist/client/plugins/index.d.mts +5 -10
- package/dist/client/plugins/index.mjs +2 -4
- package/dist/client/react/index.cjs +6 -14
- package/dist/client/react/index.d.cts +402 -71
- package/dist/client/react/index.d.mts +402 -71
- package/dist/client/react/index.mjs +5 -13
- package/dist/client/solid/index.cjs +6 -14
- package/dist/client/solid/index.d.cts +393 -57
- package/dist/client/solid/index.d.mts +393 -57
- package/dist/client/solid/index.mjs +5 -13
- package/dist/client/svelte/index.cjs +5 -10
- package/dist/client/svelte/index.d.cts +400 -67
- package/dist/client/svelte/index.d.mts +400 -67
- package/dist/client/svelte/index.mjs +4 -10
- package/dist/client/vue/index.cjs +6 -14
- package/dist/client/vue/index.d.cts +401 -68
- package/dist/client/vue/index.d.mts +401 -68
- package/dist/client/vue/index.mjs +5 -13
- package/dist/{cookies-BTs1o992.mjs → cookies-D9aY_gJh.mjs} +25 -21
- package/dist/{cookies-BTl72THv.cjs → cookies-DQ52rcOy.cjs} +119 -115
- package/dist/crypto/index.cjs +10 -8
- package/dist/crypto/index.d.cts +5 -13
- package/dist/crypto/index.d.mts +5 -13
- package/dist/crypto/index.mjs +2 -5
- package/dist/{crypto-DH2Aa7jN.mjs → crypto-BH-hD0lJ.mjs} +7 -10
- package/dist/{crypto-DpSCnrTp.cjs → crypto-BITfWVwD.cjs} +24 -27
- package/dist/db/index.cjs +1135 -29
- package/dist/db/index.d.cts +1 -2
- package/dist/db/index.d.mts +1 -2
- package/dist/db/index.mjs +1115 -16
- package/dist/defu-D2h4S3X-.mjs +87 -0
- package/dist/defu-DWS5RPWt.cjs +134 -0
- package/dist/{email-verification-DI_0H4JC.cjs → email-verification-DOPnSgbI.cjs} +65 -71
- package/dist/{email-verification-C_lBu_JY.mjs → email-verification-YSR5n5lb.mjs} +23 -29
- package/dist/{hono-CO-zsqI-.mjs → hono-BAV2wQkK.mjs} +16 -33
- package/dist/hono-SVQuc5Ru.mjs +4 -0
- package/dist/hono-pgK4H_U1.cjs +9 -0
- package/dist/{hono-DnW5crl1.cjs → hono-tyFFJFdS.cjs} +42 -60
- package/dist/index-B86Cy0dE.d.cts +2 -0
- package/dist/index-B86Cy0dE.d.mts +2 -0
- package/dist/index.cjs +115 -150
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +46 -81
- package/dist/integrations/next-js.cjs +5 -9
- package/dist/integrations/next-js.d.cts +6 -14
- package/dist/integrations/next-js.d.mts +6 -14
- package/dist/integrations/next-js.mjs +4 -9
- package/dist/integrations/node.cjs +16 -14
- package/dist/integrations/node.d.cts +6 -14
- package/dist/integrations/node.d.mts +6 -14
- package/dist/integrations/node.mjs +15 -13
- package/dist/integrations/react-start.cjs +7 -11
- package/dist/integrations/react-start.d.cts +5 -13
- package/dist/integrations/react-start.d.mts +5 -13
- package/dist/integrations/react-start.mjs +6 -11
- package/dist/integrations/solid-start.cjs +3 -5
- package/dist/integrations/solid-start.d.cts +2 -5
- package/dist/integrations/solid-start.d.mts +2 -5
- package/dist/integrations/solid-start.mjs +2 -4
- package/dist/integrations/svelte-kit.cjs +6 -10
- package/dist/integrations/svelte-kit.d.cts +11 -23
- package/dist/integrations/svelte-kit.d.mts +11 -23
- package/dist/integrations/svelte-kit.mjs +5 -10
- package/dist/{ip-BjNYspCH.mjs → ip-6Lv2o42m.mjs} +4 -9
- package/dist/{ip-C17Qdq-G.cjs → ip-DPydExzV.cjs} +21 -27
- package/dist/{json--tl7Grvs.cjs → json-D3aq-nH2.cjs} +9 -13
- package/dist/{json-B1v2qRTQ.mjs → json-DooGMtnJ.mjs} +2 -5
- package/dist/{logged-CyGfp8_H.mjs → logged-B83SzMnJ.mjs} +6 -10
- package/dist/{logged-Dv3st5qc.cjs → logged-BIpCpnVY.cjs} +13 -18
- package/dist/{middleware-CE6OhDkq.mjs → middleware-Cakg4e1D.mjs} +2 -4
- package/dist/{middleware-CWvRH4EW.cjs → middleware-Cd-VkNxB.cjs} +17 -20
- package/dist/{node-sqlite-dialect-w4DAg0PH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
- package/dist/{test-utils/node-sqlite-dialect-BgJqjBOu.cjs → node-sqlite-dialect-D3QPFROH.cjs} +5 -9
- package/dist/oauth2/index.cjs +166 -22
- package/dist/oauth2/index.d.cts +5 -17
- package/dist/oauth2/index.d.mts +5 -17
- package/dist/oauth2/index.mjs +156 -16
- package/dist/{origin-check-DjLTuZQ8.cjs → origin-check-BflGhEEN.cjs} +34 -38
- package/dist/{origin-check-8Gajklvh.mjs → origin-check-CRgs1M7k.mjs} +13 -16
- package/dist/{parser-B25ylT5u.mjs → parser-CqwvpF6l.cjs} +12 -10
- package/dist/{parser-B_wxvaAr.cjs → parser-DcKDjjHO.mjs} +7 -22
- package/dist/plugins/access/index.cjs +38 -4
- package/dist/plugins/access/index.d.cts +36 -2
- package/dist/plugins/access/index.d.mts +36 -2
- package/dist/plugins/access/index.mjs +36 -3
- package/dist/plugins/bearer/index.cjs +52 -7
- package/dist/plugins/bearer/index.d.cts +27 -4
- package/dist/plugins/bearer/index.d.mts +27 -4
- package/dist/plugins/bearer/index.mjs +51 -7
- package/dist/plugins/index.cjs +1385 -842
- package/dist/plugins/index.d.cts +489 -7566
- package/dist/plugins/index.d.mts +489 -7566
- package/dist/plugins/index.mjs +1118 -576
- package/dist/plugins/passkey/index.cjs +551 -15
- package/dist/plugins/passkey/index.d.cts +123 -4
- package/dist/plugins/passkey/index.d.mts +123 -4
- package/dist/plugins/passkey/index.mjs +547 -15
- package/dist/{chunk-BFnQceUY.mjs → rolldown-runtime-BKpuH2hG.mjs} +6 -7
- package/dist/{chunk-fPmz2rbM.cjs → rolldown-runtime-C_Pgydhf.cjs} +22 -24
- package/dist/{schema-DTIwLLmf.mjs → schema-CFCpv0tK.mjs} +3 -6
- package/dist/{schema-CirKflVs.cjs → schema-b-lKhMkG.cjs} +51 -55
- package/dist/{session-CM3rmOYF.mjs → session-BGjJgihS.mjs} +51 -74
- package/dist/{session-Cwrj4GfV.cjs → session-CzZSMmQC.cjs} +197 -219
- package/dist/shared.d.cts +1581 -0
- package/dist/shared.d.mts +1581 -0
- package/dist/social-providers/index.cjs +9 -9
- package/dist/social-providers/index.d.cts +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/dist/social-providers/index.mjs +3 -5
- package/dist/social-providers-CjPww-qf.mjs +6 -0
- package/dist/social-providers-D7w_7Ym8.cjs +10 -0
- package/dist/{state-CvSihlVT.cjs → state-2OrNjOO-.cjs} +24 -24
- package/dist/{state-CQghgH9I.mjs → state-Dooeisfq.mjs} +17 -17
- package/dist/{bun-sqlite-dialect-DPgTzc0w.cjs → test-utils/bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
- package/dist/{bun-sqlite-dialect-6NqeV3px.mjs → test-utils/bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
- package/dist/test-utils/index.cjs +8831 -7941
- package/dist/test-utils/index.d.cts +310 -12440
- package/dist/test-utils/index.d.mts +313 -12440
- package/dist/test-utils/index.mjs +8591 -7701
- package/dist/test-utils/{node-sqlite-dialect-DAQXiobH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
- package/dist/{node-sqlite-dialect-DP11CB0y.cjs → test-utils/node-sqlite-dialect-D3QPFROH.cjs} +5 -9
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.mts +2 -3
- package/dist/types/index.mjs +1 -1
- package/dist/{url-BoUuoIwZ.mjs → url-CJtdrrUu.mjs} +12 -13
- package/dist/{url-Ce7CVaQD.cjs → url-DjCmCUHS.cjs} +42 -44
- package/dist/utils/cookies.cjs +29 -30
- package/dist/utils/cookies.d.cts +21 -25
- package/dist/utils/cookies.d.mts +20 -24
- package/dist/utils/cookies.mjs +2 -7
- package/dist/utils-C7OHyfHa.mjs +4 -0
- package/dist/utils-iX0Vy_UL.cjs +3 -0
- package/package.json +40 -30
- package/dist/access-BZ7-AbTM.cjs +0 -51
- package/dist/access-D0DRqUKC.mjs +0 -39
- package/dist/bearer-DDzrp5M7.cjs +0 -60
- package/dist/bearer-WZcs7gxL.mjs +0 -54
- package/dist/db-4tUsQJXd.mjs +0 -1119
- package/dist/db-ChMbb_U-.cjs +0 -1180
- package/dist/defu-BmOYq4PU.cjs +0 -34
- package/dist/defu-D9ZTXqlo.mjs +0 -28
- package/dist/hono-C14rpOEa.cjs +0 -13
- package/dist/hono-CoKYWnXA.mjs +0 -7
- package/dist/hono-D0VqxVy1.d.mts +0 -18
- package/dist/hono-DOM31WQz.d.cts +0 -18
- package/dist/index-BCTFWP_o.d.mts +0 -992
- package/dist/index-BDhhaE6Y.d.cts +0 -3
- package/dist/index-BVRfQy6L.d.mts +0 -992
- package/dist/index-Baarsq5J.d.mts +0 -33
- package/dist/index-By364WbF.d.cts +0 -992
- package/dist/index-BzWwMgxr.d.cts +0 -992
- package/dist/index-CF9iq55a.d.mts +0 -3
- package/dist/index-CJD2yB-W.d.cts +0 -33
- package/dist/index-CRt_fppq.d.mts +0 -41
- package/dist/index-CdLyn7qP.d.cts +0 -41
- package/dist/index-CsWF3f7U.d.cts +0 -13350
- package/dist/index-CzidsAyA.d.mts +0 -13350
- package/dist/index-DvW-GCcI.d.cts +0 -33
- package/dist/index-f-5OJ9yV.d.cts +0 -13350
- package/dist/index-rFv8Hxld.d.mts +0 -13350
- package/dist/index-ztVZPQdV.d.mts +0 -33
- package/dist/kysely-adapter-CtIdoHa8.mjs +0 -270
- package/dist/kysely-adapter-QZTx077T.cjs +0 -288
- package/dist/memory-adapter-17RZd5df.cjs +0 -154
- package/dist/memory-adapter-Dp4XdCZK.mjs +0 -148
- package/dist/oauth2-5RL4cVNS.cjs +0 -177
- package/dist/oauth2-C56wz-n9.mjs +0 -159
- package/dist/passkey-BTT-v5c-.cjs +0 -512
- package/dist/passkey-CzY_W2us.mjs +0 -505
- package/dist/request-1NL_1lyJ.mjs +0 -58
- package/dist/request-CPNlp-DK.cjs +0 -100
- package/dist/social-providers-B8RK5yqI.mjs +0 -9
- package/dist/social-providers-BmFOIIPk.cjs +0 -13
- package/dist/utils-44aDDP8f.cjs +0 -2
- package/dist/utils-D4vZd1-9.mjs +0 -4
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { n as __reExport, t as
|
|
2
|
-
import { n as crypto_exports } from "./crypto-
|
|
3
|
-
import { t as safeJSONParse } from "./json-
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BKpuH2hG.mjs";
|
|
2
|
+
import { n as crypto_exports } from "./crypto-BH-hD0lJ.mjs";
|
|
3
|
+
import { t as safeJSONParse } from "./json-DooGMtnJ.mjs";
|
|
4
4
|
import { env, isProduction } from "@faire-auth/core/env";
|
|
5
5
|
import { FaireAuthError } from "@faire-auth/core/error";
|
|
6
6
|
import { isPromise } from "@faire-auth/core/static";
|
|
7
7
|
import { createTime, getDate } from "@faire-auth/core/utils";
|
|
8
8
|
import { base64Url, binary, createHMAC } from "@faire-auth/core/datatypes";
|
|
9
9
|
import * as hc from "hono/cookie";
|
|
10
|
-
import { parse, parseSigned, serialize
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var cookies_exports = /* @__PURE__ */ __export({
|
|
10
|
+
import { parse, parseSigned, serialize, serializeSigned } from "hono/utils/cookie";
|
|
11
|
+
// src/utils/cookies.ts
|
|
12
|
+
var cookies_exports = /* @__PURE__ */ __exportAll({
|
|
14
13
|
checkAuthCookie: () => checkAuthCookie,
|
|
15
14
|
createCookieCapture: () => createCookieCapture,
|
|
16
15
|
createCookieCreator: () => createCookieCreator,
|
|
@@ -24,12 +23,12 @@ var cookies_exports = /* @__PURE__ */ __export({
|
|
|
24
23
|
parseCookies: () => parseCookies,
|
|
25
24
|
parseSetCookieHeader: () => parseSetCookieHeader,
|
|
26
25
|
parseSigned: () => parseSigned,
|
|
27
|
-
serialize: () => serialize
|
|
26
|
+
serialize: () => serialize,
|
|
28
27
|
serializeSigned: () => serializeSigned,
|
|
29
28
|
serializeSignedCookie: () => serializeSignedCookie,
|
|
30
29
|
setCookieCache: () => setCookieCache,
|
|
31
30
|
setSessionCookie: () => setSessionCookie
|
|
32
|
-
});
|
|
31
|
+
}, 2);
|
|
33
32
|
import * as import_hono_cookie from "hono/cookie";
|
|
34
33
|
__reExport(cookies_exports, import_hono_cookie);
|
|
35
34
|
const tryDecode = (str) => {
|
|
@@ -41,9 +40,11 @@ const tryDecode = (str) => {
|
|
|
41
40
|
};
|
|
42
41
|
const getCookieKey = (key, prefix) => {
|
|
43
42
|
let finalKey = key;
|
|
44
|
-
if (prefix)
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
if (prefix) {
|
|
44
|
+
if (prefix === "secure") finalKey = `__Secure-${key}`;
|
|
45
|
+
else if (prefix === "host") finalKey = `__Host-${key}`;
|
|
46
|
+
else return;
|
|
47
|
+
}
|
|
47
48
|
return finalKey;
|
|
48
49
|
};
|
|
49
50
|
/**
|
|
@@ -161,7 +162,8 @@ const parseSetCookieHeader = (setCookie) => {
|
|
|
161
162
|
cookies.set(name, attrObj);
|
|
162
163
|
return cookies;
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
const attributesStr = setCookie.slice(firstSemicolon + 1);
|
|
166
|
+
splitAttributes(attributesStr).forEach((attribute) => {
|
|
165
167
|
const eqIndex = attribute.indexOf("=");
|
|
166
168
|
const attrName = eqIndex === -1 ? attribute.trim() : attribute.slice(0, eqIndex).trim();
|
|
167
169
|
const attrValue = eqIndex === -1 ? "" : attribute.slice(eqIndex + 1).trim();
|
|
@@ -201,9 +203,7 @@ const parseSetCookieHeader = (setCookie) => {
|
|
|
201
203
|
case "partitioned":
|
|
202
204
|
attrObj.partitioned = true;
|
|
203
205
|
break;
|
|
204
|
-
default:
|
|
205
|
-
if (normalizedAttrName) attrObj[normalizedAttrName] = attrValue || true;
|
|
206
|
-
break;
|
|
206
|
+
default: if (normalizedAttrName) attrObj[normalizedAttrName] = attrValue || true;
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
cookies.set(name, attrObj);
|
|
@@ -244,6 +244,10 @@ const getCookies = (options) => {
|
|
|
244
244
|
name: sessionToken.name,
|
|
245
245
|
options: sessionToken.attributes
|
|
246
246
|
},
|
|
247
|
+
/**
|
|
248
|
+
* This cookie is used to store the session data in the cookie
|
|
249
|
+
* This is useful for when you want to cache the session in the cookie
|
|
250
|
+
*/
|
|
247
251
|
sessionData: {
|
|
248
252
|
name: sessionData.name,
|
|
249
253
|
options: sessionData.attributes
|
|
@@ -315,8 +319,10 @@ const setCookieCache = async (ctx, options, session, dontRememberMe = false) =>
|
|
|
315
319
|
}
|
|
316
320
|
};
|
|
317
321
|
const getSessionCookie = (request, config) => {
|
|
318
|
-
if (config?.cookiePrefix != null)
|
|
319
|
-
|
|
322
|
+
if (config?.cookiePrefix != null) {
|
|
323
|
+
if (config.cookieName != null) config.cookiePrefix = `${config.cookiePrefix}-`;
|
|
324
|
+
else config.cookiePrefix = `${config.cookiePrefix}.`;
|
|
325
|
+
}
|
|
320
326
|
const cookies = ("headers" in request ? request.headers : request).get("cookie");
|
|
321
327
|
if (cookies == null) return null;
|
|
322
328
|
const { cookieName = "session_token", cookiePrefix = "faire-auth." } = config ?? {};
|
|
@@ -362,6 +368,4 @@ const deleteSessionCookie = (ctx, skipDontRememberMe) => {
|
|
|
362
368
|
hc.deleteCookie(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
363
369
|
if (!skipDontRememberMe) hc.deleteCookie(ctx, context.authCookies.dontRememberToken.name, context.authCookies.dontRememberToken.options);
|
|
364
370
|
};
|
|
365
|
-
|
|
366
|
-
//#endregion
|
|
367
|
-
export { serializeSignedCookie as _, createCookieSetter as a, getCookieKey as c, parse as d, parseCookies as f, serializeSigned as g, serialize$1 as h, createCookieCreator as i, getCookies as l, parseSigned as m, cookies_exports as n, deleteSessionCookie as o, parseSetCookieHeader as p, createCookieCapture as r, getCookieCache as s, checkAuthCookie as t, getSessionCookie as u, setCookieCache as v, setSessionCookie as y };
|
|
371
|
+
export { serializeSignedCookie as _, createCookieSetter as a, getCookieKey as c, parse as d, parseCookies as f, serializeSigned as g, serialize as h, createCookieCreator as i, getCookies as l, parseSigned as m, cookies_exports as n, deleteSessionCookie as o, parseSetCookieHeader as p, createCookieCapture as r, getCookieCache as s, checkAuthCookie as t, getSessionCookie as u, setCookieCache as v, setSessionCookie as y };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_crypto = require(
|
|
3
|
-
const require_json = require(
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C_Pgydhf.cjs");
|
|
2
|
+
const require_crypto = require("./crypto-BITfWVwD.cjs");
|
|
3
|
+
const require_json = require("./json-D3aq-nH2.cjs");
|
|
4
|
+
let _faire_auth_core_env = require("@faire-auth/core/env");
|
|
5
|
+
let _faire_auth_core_error = require("@faire-auth/core/error");
|
|
6
|
+
let _faire_auth_core_static = require("@faire-auth/core/static");
|
|
7
|
+
let _faire_auth_core_utils = require("@faire-auth/core/utils");
|
|
8
|
+
let _faire_auth_core_datatypes = require("@faire-auth/core/datatypes");
|
|
9
9
|
let hono_cookie = require("hono/cookie");
|
|
10
|
-
hono_cookie =
|
|
10
|
+
hono_cookie = require_rolldown_runtime.__toESM(hono_cookie, 1);
|
|
11
11
|
let hono_utils_cookie = require("hono/utils/cookie");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var cookies_exports = /* @__PURE__ */ require_chunk.__export({
|
|
12
|
+
// src/utils/cookies.ts
|
|
13
|
+
var cookies_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
15
14
|
checkAuthCookie: () => checkAuthCookie,
|
|
16
15
|
createCookieCapture: () => createCookieCapture,
|
|
17
16
|
createCookieCreator: () => createCookieCreator,
|
|
@@ -30,8 +29,8 @@ var cookies_exports = /* @__PURE__ */ require_chunk.__export({
|
|
|
30
29
|
serializeSignedCookie: () => serializeSignedCookie,
|
|
31
30
|
setCookieCache: () => setCookieCache,
|
|
32
31
|
setSessionCookie: () => setSessionCookie
|
|
33
|
-
});
|
|
34
|
-
|
|
32
|
+
}, 2);
|
|
33
|
+
require_rolldown_runtime.__reExport(cookies_exports, require("hono/cookie"));
|
|
35
34
|
const tryDecode = (str) => {
|
|
36
35
|
try {
|
|
37
36
|
return str.includes("%") ? decodeURIComponent(str) : str;
|
|
@@ -41,9 +40,11 @@ const tryDecode = (str) => {
|
|
|
41
40
|
};
|
|
42
41
|
const getCookieKey = (key, prefix) => {
|
|
43
42
|
let finalKey = key;
|
|
44
|
-
if (prefix)
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
if (prefix) {
|
|
44
|
+
if (prefix === "secure") finalKey = `__Secure-${key}`;
|
|
45
|
+
else if (prefix === "host") finalKey = `__Host-${key}`;
|
|
46
|
+
else return;
|
|
47
|
+
}
|
|
47
48
|
return finalKey;
|
|
48
49
|
};
|
|
49
50
|
/**
|
|
@@ -114,7 +115,7 @@ const serializeSignedCookie = async (key, value, secret, opt) => {
|
|
|
114
115
|
const checkAuthCookie = async (request, auth) => {
|
|
115
116
|
const cookies = (request instanceof Headers ? request : request.headers).get("cookie");
|
|
116
117
|
if (cookies == null) return null;
|
|
117
|
-
const cookieName = ((0,
|
|
118
|
+
const cookieName = ((0, _faire_auth_core_static.isPromise)(auth.$context) ? await auth.$context : auth.$context).authCookies.sessionToken.name;
|
|
118
119
|
const sessionToken = parseCookies(cookies).get(cookieName);
|
|
119
120
|
if (sessionToken != null) return sessionToken;
|
|
120
121
|
return null;
|
|
@@ -161,7 +162,8 @@ const parseSetCookieHeader = (setCookie) => {
|
|
|
161
162
|
cookies.set(name, attrObj);
|
|
162
163
|
return cookies;
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
const attributesStr = setCookie.slice(firstSemicolon + 1);
|
|
166
|
+
splitAttributes(attributesStr).forEach((attribute) => {
|
|
165
167
|
const eqIndex = attribute.indexOf("=");
|
|
166
168
|
const attrName = eqIndex === -1 ? attribute.trim() : attribute.slice(0, eqIndex).trim();
|
|
167
169
|
const attrValue = eqIndex === -1 ? "" : attribute.slice(eqIndex + 1).trim();
|
|
@@ -201,19 +203,17 @@ const parseSetCookieHeader = (setCookie) => {
|
|
|
201
203
|
case "partitioned":
|
|
202
204
|
attrObj.partitioned = true;
|
|
203
205
|
break;
|
|
204
|
-
default:
|
|
205
|
-
if (normalizedAttrName) attrObj[normalizedAttrName] = attrValue || true;
|
|
206
|
-
break;
|
|
206
|
+
default: if (normalizedAttrName) attrObj[normalizedAttrName] = attrValue || true;
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
cookies.set(name, attrObj);
|
|
210
210
|
return cookies;
|
|
211
211
|
};
|
|
212
212
|
const createCookieCreator = (options) => {
|
|
213
|
-
const secureCookiePrefix = (options.advanced?.useSecureCookies !== void 0 ? options.advanced.useSecureCookies : options.baseURL !== void 0 ? options.baseURL.startsWith("https://") ? true : false : (0,
|
|
213
|
+
const secureCookiePrefix = (options.advanced?.useSecureCookies !== void 0 ? options.advanced.useSecureCookies : options.baseURL !== void 0 ? options.baseURL.startsWith("https://") ? true : false : (0, _faire_auth_core_env.isProduction)()) ? "__Secure-" : "";
|
|
214
214
|
const crossSubdomainEnabled = options.advanced?.crossSubDomainCookies?.enabled === true;
|
|
215
215
|
const domain = crossSubdomainEnabled ? options.advanced?.crossSubDomainCookies?.domain ?? (options.baseURL != null ? new URL(options.baseURL).hostname : void 0) : void 0;
|
|
216
|
-
if (crossSubdomainEnabled && domain == null) throw new
|
|
216
|
+
if (crossSubdomainEnabled && domain == null) throw new _faire_auth_core_error.FaireAuthError("baseURL is required when crossSubdomainCookies are enabled");
|
|
217
217
|
const createCookie = (cookieName, overrideAttributes = {}) => {
|
|
218
218
|
const prefix = options.advanced?.cookiePrefix ?? "faire-auth";
|
|
219
219
|
const name = options.advanced?.cookies?.[cookieName]?.name ?? `${prefix}.${cookieName}`;
|
|
@@ -236,7 +236,7 @@ const createCookieCreator = (options) => {
|
|
|
236
236
|
};
|
|
237
237
|
const getCookies = (options) => {
|
|
238
238
|
const createCookie = createCookieCreator(options);
|
|
239
|
-
const sessionToken = createCookie("session_token", { maxAge: options.session?.expiresIn ?? (0,
|
|
239
|
+
const sessionToken = createCookie("session_token", { maxAge: options.session?.expiresIn ?? (0, _faire_auth_core_utils.createTime)(7, "d").toSeconds() });
|
|
240
240
|
const sessionData = createCookie("session_data", { maxAge: options.session?.cookieCache?.maxAge ?? 300 });
|
|
241
241
|
const dontRememberToken = createCookie("dont_remember");
|
|
242
242
|
return {
|
|
@@ -244,6 +244,10 @@ const getCookies = (options) => {
|
|
|
244
244
|
name: sessionToken.name,
|
|
245
245
|
options: sessionToken.attributes
|
|
246
246
|
},
|
|
247
|
+
/**
|
|
248
|
+
* This cookie is used to store the session data in the cookie
|
|
249
|
+
* This is useful for when you want to cache the session in the cookie
|
|
250
|
+
*/
|
|
247
251
|
sessionData: {
|
|
248
252
|
name: sessionData.name,
|
|
249
253
|
options: sessionData.attributes
|
|
@@ -271,14 +275,14 @@ const getCookieCache = async (request, config) => {
|
|
|
271
275
|
const cookies = (request instanceof Headers ? request : request.headers).get("cookie");
|
|
272
276
|
if (cookies == null) return null;
|
|
273
277
|
const { cookieName = "session_data", cookiePrefix = "faire-auth" } = config ?? {};
|
|
274
|
-
const name = config?.isSecure !== void 0 ? config.isSecure ? `__Secure-${cookiePrefix}.${cookieName}` : `${cookiePrefix}.${cookieName}` : (0,
|
|
278
|
+
const name = config?.isSecure !== void 0 ? config.isSecure ? `__Secure-${cookiePrefix}.${cookieName}` : `${cookiePrefix}.${cookieName}` : (0, _faire_auth_core_env.isProduction)() ? `__Secure-${cookiePrefix}.${cookieName}` : `${cookiePrefix}.${cookieName}`;
|
|
275
279
|
const sessionData = parseCookies(cookies).get(name);
|
|
276
280
|
if (sessionData != null) {
|
|
277
|
-
const sessionDataPayload = require_json.safeJSONParse(
|
|
281
|
+
const sessionDataPayload = require_json.safeJSONParse(_faire_auth_core_datatypes.binary.decode(_faire_auth_core_datatypes.base64Url.decode(sessionData)));
|
|
278
282
|
if (!sessionDataPayload) return null;
|
|
279
|
-
const secret = config?.secret ??
|
|
280
|
-
if (secret == null) throw new
|
|
281
|
-
if (!await (0,
|
|
283
|
+
const secret = config?.secret ?? _faire_auth_core_env.env["FAIRE_AUTH_SECRET"];
|
|
284
|
+
if (secret == null) throw new _faire_auth_core_error.FaireAuthError("getCookieCache requires a secret to be provided. Either pass it as an option or set the FAIRE_AUTH_SECRET environment variable");
|
|
285
|
+
if (!await (0, _faire_auth_core_datatypes.createHMAC)("SHA-256", "base64urlnopad").verify(secret, JSON.stringify({
|
|
282
286
|
...sessionDataPayload.session,
|
|
283
287
|
expiresAt: sessionDataPayload.expiresAt
|
|
284
288
|
}), sessionDataPayload.signature)) return null;
|
|
@@ -301,22 +305,24 @@ const setCookieCache = async (ctx, options, session, dontRememberMe = false) =>
|
|
|
301
305
|
...context.authCookies.sessionData.options,
|
|
302
306
|
...dontRememberMe && { maxAge: context.authCookies.sessionData.options.maxAge }
|
|
303
307
|
};
|
|
304
|
-
const expiresAtDate = (0,
|
|
305
|
-
const data =
|
|
308
|
+
const expiresAtDate = (0, _faire_auth_core_utils.getDate)(cookieOptions.maxAge || 60, "sec").getTime();
|
|
309
|
+
const data = _faire_auth_core_datatypes.base64Url.encode(JSON.stringify({
|
|
306
310
|
session: sessionData,
|
|
307
311
|
expiresAt: expiresAtDate,
|
|
308
|
-
signature: await (0,
|
|
312
|
+
signature: await (0, _faire_auth_core_datatypes.createHMAC)("SHA-256", "base64urlnopad").sign(context.secret, JSON.stringify({
|
|
309
313
|
...sessionData,
|
|
310
314
|
expiresAt: expiresAtDate
|
|
311
315
|
}))
|
|
312
316
|
}), { padding: false });
|
|
313
|
-
if (data.length > 4093) throw new
|
|
317
|
+
if (data.length > 4093) throw new _faire_auth_core_error.FaireAuthError("Session data is too large to store in the cookie. Please disable session cookie caching or reduce the size of the session data");
|
|
314
318
|
hono_cookie.setCookie(ctx, context.authCookies.sessionData.name, data, cookieOptions);
|
|
315
319
|
}
|
|
316
320
|
};
|
|
317
321
|
const getSessionCookie = (request, config) => {
|
|
318
|
-
if (config?.cookiePrefix != null)
|
|
319
|
-
|
|
322
|
+
if (config?.cookiePrefix != null) {
|
|
323
|
+
if (config.cookieName != null) config.cookiePrefix = `${config.cookiePrefix}-`;
|
|
324
|
+
else config.cookiePrefix = `${config.cookiePrefix}.`;
|
|
325
|
+
}
|
|
320
326
|
const cookies = ("headers" in request ? request.headers : request).get("cookie");
|
|
321
327
|
if (cookies == null) return null;
|
|
322
328
|
const { cookieName = "session_token", cookiePrefix = "faire-auth." } = config ?? {};
|
|
@@ -351,7 +357,7 @@ const setSessionCookie = (ctx, authOptions, session, dontRememberMe, overrides)
|
|
|
351
357
|
user: session.user,
|
|
352
358
|
session: session.session
|
|
353
359
|
}), Math.floor((new Date(session.session.expiresAt).getTime() - Date.now()) / 1e3));
|
|
354
|
-
if ((0,
|
|
360
|
+
if ((0, _faire_auth_core_static.isPromise)(maybePromise)) return maybePromise;
|
|
355
361
|
}
|
|
356
362
|
return Promise.resolve();
|
|
357
363
|
});
|
|
@@ -362,95 +368,93 @@ const deleteSessionCookie = (ctx, skipDontRememberMe) => {
|
|
|
362
368
|
hono_cookie.deleteCookie(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
363
369
|
if (!skipDontRememberMe) hono_cookie.deleteCookie(ctx, context.authCookies.dontRememberToken.name, context.authCookies.dontRememberToken.options);
|
|
364
370
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return checkAuthCookie;
|
|
371
|
-
}
|
|
371
|
+
Object.defineProperty(exports, "checkAuthCookie", {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function() {
|
|
374
|
+
return checkAuthCookie;
|
|
375
|
+
}
|
|
372
376
|
});
|
|
373
|
-
Object.defineProperty(exports,
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
Object.defineProperty(exports, "cookies_exports", {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function() {
|
|
380
|
+
return cookies_exports;
|
|
381
|
+
}
|
|
378
382
|
});
|
|
379
|
-
Object.defineProperty(exports,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
Object.defineProperty(exports, "createCookieCapture", {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
get: function() {
|
|
386
|
+
return createCookieCapture;
|
|
387
|
+
}
|
|
384
388
|
});
|
|
385
|
-
Object.defineProperty(exports,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
Object.defineProperty(exports, "createCookieCreator", {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function() {
|
|
392
|
+
return createCookieCreator;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(exports, "createCookieSetter", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function() {
|
|
398
|
+
return createCookieSetter;
|
|
399
|
+
}
|
|
390
400
|
});
|
|
391
|
-
Object.defineProperty(exports,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
401
|
+
Object.defineProperty(exports, "deleteSessionCookie", {
|
|
402
|
+
enumerable: true,
|
|
403
|
+
get: function() {
|
|
404
|
+
return deleteSessionCookie;
|
|
405
|
+
}
|
|
396
406
|
});
|
|
397
|
-
Object.defineProperty(exports,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
407
|
+
Object.defineProperty(exports, "getCookieCache", {
|
|
408
|
+
enumerable: true,
|
|
409
|
+
get: function() {
|
|
410
|
+
return getCookieCache;
|
|
411
|
+
}
|
|
402
412
|
});
|
|
403
|
-
Object.defineProperty(exports,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
413
|
+
Object.defineProperty(exports, "getCookieKey", {
|
|
414
|
+
enumerable: true,
|
|
415
|
+
get: function() {
|
|
416
|
+
return getCookieKey;
|
|
417
|
+
}
|
|
408
418
|
});
|
|
409
|
-
Object.defineProperty(exports,
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
Object.defineProperty(exports, "getCookies", {
|
|
420
|
+
enumerable: true,
|
|
421
|
+
get: function() {
|
|
422
|
+
return getCookies;
|
|
423
|
+
}
|
|
414
424
|
});
|
|
415
|
-
Object.defineProperty(exports,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
425
|
+
Object.defineProperty(exports, "getSessionCookie", {
|
|
426
|
+
enumerable: true,
|
|
427
|
+
get: function() {
|
|
428
|
+
return getSessionCookie;
|
|
429
|
+
}
|
|
420
430
|
});
|
|
421
|
-
Object.defineProperty(exports,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
431
|
+
Object.defineProperty(exports, "parseCookies", {
|
|
432
|
+
enumerable: true,
|
|
433
|
+
get: function() {
|
|
434
|
+
return parseCookies;
|
|
435
|
+
}
|
|
426
436
|
});
|
|
427
|
-
Object.defineProperty(exports,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
437
|
+
Object.defineProperty(exports, "parseSetCookieHeader", {
|
|
438
|
+
enumerable: true,
|
|
439
|
+
get: function() {
|
|
440
|
+
return parseSetCookieHeader;
|
|
441
|
+
}
|
|
432
442
|
});
|
|
433
|
-
Object.defineProperty(exports,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
443
|
+
Object.defineProperty(exports, "serializeSignedCookie", {
|
|
444
|
+
enumerable: true,
|
|
445
|
+
get: function() {
|
|
446
|
+
return serializeSignedCookie;
|
|
447
|
+
}
|
|
438
448
|
});
|
|
439
|
-
Object.defineProperty(exports,
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
449
|
+
Object.defineProperty(exports, "setCookieCache", {
|
|
450
|
+
enumerable: true,
|
|
451
|
+
get: function() {
|
|
452
|
+
return setCookieCache;
|
|
453
|
+
}
|
|
444
454
|
});
|
|
445
|
-
Object.defineProperty(exports,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
455
|
+
Object.defineProperty(exports, "setSessionCookie", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
get: function() {
|
|
458
|
+
return setSessionCookie;
|
|
459
|
+
}
|
|
450
460
|
});
|
|
451
|
-
Object.defineProperty(exports, 'setSessionCookie', {
|
|
452
|
-
enumerable: true,
|
|
453
|
-
get: function () {
|
|
454
|
-
return setSessionCookie;
|
|
455
|
-
}
|
|
456
|
-
});
|
package/dist/crypto/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_crypto = require("../crypto-BITfWVwD.cjs");
|
|
3
3
|
exports.checkPassword = require_crypto.checkPassword;
|
|
4
4
|
exports.validatePassword = require_crypto.validatePassword;
|
|
5
|
-
var
|
|
6
|
-
Object.keys(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var _faire_auth_core_crypto = require("@faire-auth/core/crypto");
|
|
6
|
+
Object.keys(_faire_auth_core_crypto).forEach(function(k) {
|
|
7
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
10
|
+
return _faire_auth_core_crypto[k];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
11
13
|
});
|
package/dist/crypto/index.d.cts
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as _faire_auth_core_types30 from "@faire-auth/core/types";
|
|
1
|
+
import { P as ContextVars } from "../shared.cjs";
|
|
3
2
|
import { Context } from "hono";
|
|
4
3
|
export * from "@faire-auth/core/crypto";
|
|
5
|
-
|
|
6
|
-
//#region src/crypto/index.d.ts
|
|
7
|
-
declare const validatePassword: <T extends object>(ctx: Context<ContextVars<T>>, data: {
|
|
4
|
+
export declare const validatePassword: <T extends object>(ctx: Context<ContextVars<T>>, data: {
|
|
8
5
|
password: string;
|
|
9
6
|
userId: string;
|
|
10
|
-
}) => Promise<
|
|
11
|
-
declare const checkPassword: <T extends object>(userId: string, ctx: Context<ContextVars<T>, any, {
|
|
7
|
+
}) => Promise<any>;
|
|
8
|
+
export declare const checkPassword: <T extends object>(userId: string, ctx: Context<ContextVars<T>, any, {
|
|
12
9
|
out: {
|
|
13
10
|
json: {
|
|
14
11
|
password?: string;
|
|
15
12
|
};
|
|
16
13
|
};
|
|
17
|
-
}>) => Promise<true |
|
|
18
|
-
success: false;
|
|
19
|
-
message: string;
|
|
20
|
-
}, 400>>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { checkPassword, validatePassword };
|
|
14
|
+
}>) => Promise<true | Response>;
|
package/dist/crypto/index.d.mts
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { t as ContextVars } from "../
|
|
1
|
+
import { t as ContextVars } from "../shared.mjs";
|
|
2
2
|
import { Context } from "hono";
|
|
3
|
-
import * as _faire_auth_core_types0 from "@faire-auth/core/types";
|
|
4
3
|
export * from "@faire-auth/core/crypto";
|
|
5
|
-
|
|
6
|
-
//#region src/crypto/index.d.ts
|
|
7
|
-
declare const validatePassword: <T extends object>(ctx: Context<ContextVars<T>>, data: {
|
|
4
|
+
export declare const validatePassword: <T extends object>(ctx: Context<ContextVars<T>>, data: {
|
|
8
5
|
password: string;
|
|
9
6
|
userId: string;
|
|
10
|
-
}) => Promise<
|
|
11
|
-
declare const checkPassword: <T extends object>(userId: string, ctx: Context<ContextVars<T>, any, {
|
|
7
|
+
}) => Promise<any>;
|
|
8
|
+
export declare const checkPassword: <T extends object>(userId: string, ctx: Context<ContextVars<T>, any, {
|
|
12
9
|
out: {
|
|
13
10
|
json: {
|
|
14
11
|
password?: string;
|
|
15
12
|
};
|
|
16
13
|
};
|
|
17
|
-
}>) => Promise<true |
|
|
18
|
-
success: false;
|
|
19
|
-
message: string;
|
|
20
|
-
}, 400>>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { checkPassword, validatePassword };
|
|
14
|
+
}>) => Promise<true | Response>;
|
package/dist/crypto/index.mjs
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from "@faire-auth/core/crypto"
|
|
4
|
-
|
|
5
|
-
export { checkPassword, validatePassword };
|
|
1
|
+
export { t as checkPassword, r as validatePassword } from "../crypto-BH-hD0lJ.mjs";
|
|
2
|
+
export * from "@faire-auth/core/crypto";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { n as __reExport, t as
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BKpuH2hG.mjs";
|
|
2
2
|
import { False } from "@faire-auth/core/static";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var crypto_exports = /* @__PURE__ */ __export({
|
|
3
|
+
// src/crypto/index.ts
|
|
4
|
+
var crypto_exports = /* @__PURE__ */ __exportAll({
|
|
6
5
|
checkPassword: () => checkPassword,
|
|
7
6
|
validatePassword: () => validatePassword
|
|
8
|
-
});
|
|
9
|
-
import * as
|
|
10
|
-
__reExport(crypto_exports,
|
|
7
|
+
}, 2);
|
|
8
|
+
import * as import__faire_auth_core_crypto from "@faire-auth/core/crypto";
|
|
9
|
+
__reExport(crypto_exports, import__faire_auth_core_crypto);
|
|
11
10
|
const validatePassword = async (ctx, data) => {
|
|
12
11
|
const context = ctx.get("context");
|
|
13
12
|
const credentialAccount = (await context.internalAdapter.findAccounts(data.userId)).find((account) => account.providerId === "credential");
|
|
@@ -36,6 +35,4 @@ const checkPassword = async (userId, ctx) => {
|
|
|
36
35
|
}, 400);
|
|
37
36
|
return true;
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { crypto_exports as n, validatePassword as r, checkPassword as t };
|
|
38
|
+
export { crypto_exports as n, validatePassword as r, checkPassword as t };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var crypto_exports = /* @__PURE__ */ require_chunk.__export({
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C_Pgydhf.cjs");
|
|
2
|
+
let _faire_auth_core_static = require("@faire-auth/core/static");
|
|
3
|
+
// src/crypto/index.ts
|
|
4
|
+
var crypto_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
6
5
|
checkPassword: () => checkPassword,
|
|
7
6
|
validatePassword: () => validatePassword
|
|
8
|
-
});
|
|
9
|
-
|
|
7
|
+
}, 2);
|
|
8
|
+
require_rolldown_runtime.__reExport(crypto_exports, require("@faire-auth/core/crypto"));
|
|
10
9
|
const validatePassword = async (ctx, data) => {
|
|
11
10
|
const context = ctx.get("context");
|
|
12
11
|
const credentialAccount = (await context.internalAdapter.findAccounts(data.userId)).find((account) => account.providerId === "credential");
|
|
@@ -23,35 +22,33 @@ const checkPassword = async (userId, ctx) => {
|
|
|
23
22
|
const credentialAccount = (await context.internalAdapter.findAccounts(userId)).find((account) => account.providerId === "credential");
|
|
24
23
|
const currentPassword = credentialAccount?.password;
|
|
25
24
|
if (!credentialAccount || !currentPassword || !password) return ctx.render({
|
|
26
|
-
success:
|
|
25
|
+
success: _faire_auth_core_static.False,
|
|
27
26
|
message: "No password credential found"
|
|
28
27
|
}, 400);
|
|
29
28
|
if (!await context.password.verify({
|
|
30
29
|
hash: currentPassword,
|
|
31
30
|
password
|
|
32
31
|
})) return ctx.render({
|
|
33
|
-
success:
|
|
32
|
+
success: _faire_auth_core_static.False,
|
|
34
33
|
message: "Invalid password"
|
|
35
34
|
}, 400);
|
|
36
35
|
return true;
|
|
37
36
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
Object.defineProperty(exports, "checkPassword", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return checkPassword;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "crypto_exports", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return crypto_exports;
|
|
47
|
+
}
|
|
45
48
|
});
|
|
46
|
-
Object.defineProperty(exports,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
Object.defineProperty(exports, "validatePassword", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return validatePassword;
|
|
53
|
+
}
|
|
51
54
|
});
|
|
52
|
-
Object.defineProperty(exports, 'validatePassword', {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return validatePassword;
|
|
56
|
-
}
|
|
57
|
-
});
|