faire-auth 1.0.4 → 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 +45 -80
- 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--DLiUhEn.d.mts +0 -33
- package/dist/index-B4bqEDYG.d.mts +0 -992
- package/dist/index-BDhhaE6Y.d.cts +0 -3
- package/dist/index-Boa0SV4h.d.cts +0 -13350
- package/dist/index-Bykgiq3o.d.cts +0 -13350
- package/dist/index-CF9iq55a.d.mts +0 -3
- package/dist/index-CRt_fppq.d.mts +0 -41
- package/dist/index-CdLyn7qP.d.cts +0 -41
- package/dist/index-ClFGA8tb.d.mts +0 -33
- package/dist/index-ClOM0wFf.d.cts +0 -992
- package/dist/index-CsxNfGAV.d.mts +0 -13350
- package/dist/index-DKnO_Zfm.d.cts +0 -992
- package/dist/index-DRYO4mGd.d.cts +0 -33
- package/dist/index-Dsua4U8w.d.cts +0 -33
- package/dist/index-DxXFCG2_.d.mts +0 -13350
- package/dist/index-gtCVvDvC.d.mts +0 -992
- 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,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var
|
|
7
|
-
let target = {};
|
|
6
|
+
var __exportAll = (all, flags) => {
|
|
7
|
+
let target = Object.setPrototypeOf({}, null);
|
|
8
8
|
for (var name in all) __defProp(target, name, {
|
|
9
9
|
get: all[name],
|
|
10
10
|
enumerable: true
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
13
14
|
};
|
|
14
15
|
var __copyProps = (to, from, except, desc) => {
|
|
15
16
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -22,6 +23,4 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
22
23
|
return to;
|
|
23
24
|
};
|
|
24
25
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { __reExport as n, __export as t };
|
|
26
|
+
export { __reExport as n, __exportAll as t };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
let target = {};
|
|
8
|
+
var __exportAll = (all, flags) => {
|
|
9
|
+
let target = Object.setPrototypeOf({}, null);
|
|
10
10
|
for (var name in all) __defProp(target, name, {
|
|
11
11
|
get: all[name],
|
|
12
12
|
enumerable: true
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
15
16
|
};
|
|
16
17
|
var __copyProps = (to, from, except, desc) => {
|
|
17
18
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -24,28 +25,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
25
|
return to;
|
|
25
26
|
};
|
|
26
27
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
28
29
|
value: mod,
|
|
29
30
|
enumerable: true
|
|
30
31
|
}) : target, mod));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function() {
|
|
35
|
+
return __exportAll;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "__reExport", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function() {
|
|
41
|
+
return __reExport;
|
|
42
|
+
}
|
|
39
43
|
});
|
|
40
|
-
Object.defineProperty(exports,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
Object.defineProperty(exports, "__toESM", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function() {
|
|
47
|
+
return __toESM;
|
|
48
|
+
}
|
|
45
49
|
});
|
|
46
|
-
Object.defineProperty(exports, '__toESM', {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () {
|
|
49
|
-
return __toESM;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as getContext } from "./hono-
|
|
1
|
+
import { n as getContext } from "./hono-SVQuc5Ru.mjs";
|
|
2
2
|
import { False } from "@faire-auth/core/static";
|
|
3
|
-
|
|
4
|
-
//#region src/db/schema.ts
|
|
3
|
+
// src/db/schema.ts
|
|
5
4
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
6
5
|
function parseOutputData(data, schema) {
|
|
7
6
|
const fields = schema.fields;
|
|
@@ -120,6 +119,4 @@ function mergeSchema(schema, newSchema) {
|
|
|
120
119
|
}
|
|
121
120
|
return schema;
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
//#endregion
|
|
125
|
-
export { parseInputData as a, parseUserInput as c, parseAdditionalUserInput as i, parseUserOutput as l, parseAccountInput as n, parseSessionInput as o, parseAccountOutput as r, parseSessionOutput as s, mergeSchema as t };
|
|
122
|
+
export { parseInputData as a, parseUserInput as c, parseAdditionalUserInput as i, parseUserOutput as l, parseAccountInput as n, parseSessionInput as o, parseAccountOutput as r, parseSessionOutput as s, mergeSchema as t };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/db/schema.ts
|
|
1
|
+
const require_hono = require("./hono-pgK4H_U1.cjs");
|
|
2
|
+
let _faire_auth_core_static = require("@faire-auth/core/static");
|
|
3
|
+
// src/db/schema.ts
|
|
6
4
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
7
5
|
function parseOutputData(data, schema) {
|
|
8
6
|
const fields = schema.fields;
|
|
@@ -59,7 +57,7 @@ function parseInputData(data, schema) {
|
|
|
59
57
|
}
|
|
60
58
|
if (data[key]) {
|
|
61
59
|
fieldError = ctx.render({
|
|
62
|
-
success:
|
|
60
|
+
success: _faire_auth_core_static.False,
|
|
63
61
|
message: `${key} is not allowed to be set`
|
|
64
62
|
}, 400);
|
|
65
63
|
break;
|
|
@@ -83,7 +81,7 @@ function parseInputData(data, schema) {
|
|
|
83
81
|
}
|
|
84
82
|
if (fields[key].required && action === "create") {
|
|
85
83
|
fieldError = ctx.render({
|
|
86
|
-
success:
|
|
84
|
+
success: _faire_auth_core_static.False,
|
|
87
85
|
message: `${key} is required`
|
|
88
86
|
}, 400);
|
|
89
87
|
break;
|
|
@@ -121,59 +119,57 @@ function mergeSchema(schema, newSchema) {
|
|
|
121
119
|
}
|
|
122
120
|
return schema;
|
|
123
121
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return mergeSchema;
|
|
130
|
-
}
|
|
122
|
+
Object.defineProperty(exports, "mergeSchema", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function() {
|
|
125
|
+
return mergeSchema;
|
|
126
|
+
}
|
|
131
127
|
});
|
|
132
|
-
Object.defineProperty(exports,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
Object.defineProperty(exports, "parseAccountInput", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function() {
|
|
131
|
+
return parseAccountInput;
|
|
132
|
+
}
|
|
137
133
|
});
|
|
138
|
-
Object.defineProperty(exports,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
Object.defineProperty(exports, "parseAccountOutput", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function() {
|
|
137
|
+
return parseAccountOutput;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "parseAdditionalUserInput", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return parseAdditionalUserInput;
|
|
144
|
+
}
|
|
143
145
|
});
|
|
144
|
-
Object.defineProperty(exports,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
Object.defineProperty(exports, "parseInputData", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function() {
|
|
149
|
+
return parseInputData;
|
|
150
|
+
}
|
|
149
151
|
});
|
|
150
|
-
Object.defineProperty(exports,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
Object.defineProperty(exports, "parseSessionInput", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function() {
|
|
155
|
+
return parseSessionInput;
|
|
156
|
+
}
|
|
155
157
|
});
|
|
156
|
-
Object.defineProperty(exports,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
Object.defineProperty(exports, "parseSessionOutput", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function() {
|
|
161
|
+
return parseSessionOutput;
|
|
162
|
+
}
|
|
161
163
|
});
|
|
162
|
-
Object.defineProperty(exports,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
Object.defineProperty(exports, "parseUserInput", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return parseUserInput;
|
|
168
|
+
}
|
|
167
169
|
});
|
|
168
|
-
Object.defineProperty(exports,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
Object.defineProperty(exports, "parseUserOutput", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function() {
|
|
173
|
+
return parseUserOutput;
|
|
174
|
+
}
|
|
173
175
|
});
|
|
174
|
-
Object.defineProperty(exports, 'parseUserOutput', {
|
|
175
|
-
enumerable: true,
|
|
176
|
-
get: function () {
|
|
177
|
-
return parseUserOutput;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as safeJSONParse } from "./json-
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as getBaseURL } from "./url-
|
|
6
|
-
import { r as createMiddleware, t as createErrorHandler } from "./middleware-
|
|
1
|
+
import { n as cookies_exports, o as deleteSessionCookie, v as setCookieCache, y as setSessionCookie } from "./cookies-D9aY_gJh.mjs";
|
|
2
|
+
import { t as safeJSONParse } from "./json-DooGMtnJ.mjs";
|
|
3
|
+
import { t as contextStorage } from "./hono-SVQuc5Ru.mjs";
|
|
4
|
+
import { t as LoggerAPI } from "./logged-B83SzMnJ.mjs";
|
|
5
|
+
import { t as getBaseURL } from "./url-CJtdrrUu.mjs";
|
|
6
|
+
import { r as createMiddleware, t as createErrorHandler } from "./middleware-Cakg4e1D.mjs";
|
|
7
7
|
import { isTest, logger } from "@faire-auth/core/env";
|
|
8
8
|
import { APIError, BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
9
9
|
import { buildRouteBundle, createRoute, createRouteAppWrapper, initRenderer, req, res } from "@faire-auth/core/factory";
|
|
@@ -11,10 +11,9 @@ import { Definitions, False, Routes, SCHEMAS, True, isPromise } from "@faire-aut
|
|
|
11
11
|
import { getDate, isContextLike, isExecOpts, withOverlays } from "@faire-auth/core/utils";
|
|
12
12
|
import { base64Url, binary, createHMAC } from "@faire-auth/core/datatypes";
|
|
13
13
|
import { HTTPException } from "hono/http-exception";
|
|
14
|
-
import * as z
|
|
14
|
+
import * as z from "zod";
|
|
15
15
|
import { looseSessionSchema, looseUserSchema } from "@faire-auth/core/db";
|
|
16
|
-
|
|
17
|
-
//#region src/api/middleware/context.ts
|
|
16
|
+
// src/api/middleware/context.ts
|
|
18
17
|
/**
|
|
19
18
|
* Initializes the context middleware.
|
|
20
19
|
* @template O - The options type.
|
|
@@ -28,9 +27,7 @@ const initContextMiddleware = (options, context, api) => createMiddleware()(asyn
|
|
|
28
27
|
ctx.set("path", ctx.req.path.slice((options.basePath ?? "/api/auth").length));
|
|
29
28
|
return await next();
|
|
30
29
|
});
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/api/middleware/hooks.ts
|
|
30
|
+
// src/api/middleware/hooks.ts
|
|
34
31
|
const runHooks = async (ctx, hooks) => {
|
|
35
32
|
let response = void 0;
|
|
36
33
|
for (const hook of hooks) if (hook.matcher(ctx)) try {
|
|
@@ -84,9 +81,7 @@ const initHooksMiddleware = (options) => {
|
|
|
84
81
|
if (after instanceof Response) ctx.res = after;
|
|
85
82
|
});
|
|
86
83
|
};
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/api/middleware/on-error.ts
|
|
84
|
+
// src/api/middleware/on-error.ts
|
|
90
85
|
/**
|
|
91
86
|
* Initializes the error handler.
|
|
92
87
|
* @param options - The FaireAuth options.
|
|
@@ -100,8 +95,8 @@ const initErrorHandler = (options) => createErrorHandler()(async (e, ctx) => {
|
|
|
100
95
|
if (e instanceof APIError && e.statusText === "FOUND") return ret;
|
|
101
96
|
if (options.onAPIError?.throw === true) throw e;
|
|
102
97
|
if (options.onAPIError?.onError) {
|
|
103
|
-
const res
|
|
104
|
-
if (isPromise(res
|
|
98
|
+
const res = options.onAPIError.onError(e, ctx);
|
|
99
|
+
if (isPromise(res)) await res;
|
|
105
100
|
return ret;
|
|
106
101
|
}
|
|
107
102
|
const optLogLevel = options.logger?.level;
|
|
@@ -121,9 +116,7 @@ const initErrorHandler = (options) => createErrorHandler()(async (e, ctx) => {
|
|
|
121
116
|
}
|
|
122
117
|
return ret;
|
|
123
118
|
});
|
|
124
|
-
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/api/middleware/server-api.ts
|
|
119
|
+
// src/api/middleware/server-api.ts
|
|
127
120
|
/**
|
|
128
121
|
* Middleware that sets a flag indicating the route was called from the server-side API.
|
|
129
122
|
* This should only be used with localApp in createEndpoint to provide permissions depth.
|
|
@@ -132,9 +125,7 @@ const serverApiMiddleware = createMiddleware()(async (ctx, next) => {
|
|
|
132
125
|
ctx.set("isServer", true);
|
|
133
126
|
return await next();
|
|
134
127
|
});
|
|
135
|
-
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/utils/hono.ts
|
|
128
|
+
// src/utils/hono.ts
|
|
138
129
|
const createDefaultExecutionCtx = (ctx) => {
|
|
139
130
|
Object.defineProperty(ctx, "executionCtx", {
|
|
140
131
|
get: () => ({
|
|
@@ -146,9 +137,7 @@ const createDefaultExecutionCtx = (ctx) => {
|
|
|
146
137
|
enumerable: true
|
|
147
138
|
});
|
|
148
139
|
};
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/api/middleware/set-execution-ctx.ts
|
|
140
|
+
// src/api/middleware/set-execution-ctx.ts
|
|
152
141
|
/**
|
|
153
142
|
* Sets the default execution context if not already present.
|
|
154
143
|
* Manages promises to await after the middleware chain.
|
|
@@ -165,9 +154,7 @@ const setDefaultExecutionCtx = createMiddleware()(async (ctx, next) => {
|
|
|
165
154
|
await next();
|
|
166
155
|
if (hasDefaultExecutionCtx === true) await Promise.allSettled(ctx.get("toAwait"));
|
|
167
156
|
});
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/api/middleware/set-renderer.ts
|
|
157
|
+
// src/api/middleware/set-renderer.ts
|
|
171
158
|
/**
|
|
172
159
|
* Sets the renderer for the context.
|
|
173
160
|
*
|
|
@@ -177,9 +164,7 @@ const setRenderer = createMiddleware()(async (ctx, next) => {
|
|
|
177
164
|
ctx.setRenderer(initRenderer(ctx));
|
|
178
165
|
return await next();
|
|
179
166
|
});
|
|
180
|
-
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/api/factory/endpoint.ts
|
|
167
|
+
// src/api/factory/endpoint.ts
|
|
183
168
|
/**
|
|
184
169
|
* Creates an auth endpoint.
|
|
185
170
|
* @template C - The route config type.
|
|
@@ -193,7 +178,7 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
193
178
|
return ((options) => {
|
|
194
179
|
const resolvedHandler = handler(options);
|
|
195
180
|
let localApp = null;
|
|
196
|
-
const execute =
|
|
181
|
+
const execute = LoggerAPI.wrap(async (...args) => {
|
|
197
182
|
if (!bundle) throw new Error(`${config.operationId} config() must be called before using execute()!`);
|
|
198
183
|
const [inputOrCtx, maybeCtx] = args;
|
|
199
184
|
const { input, ctx, opts } = isContextLike(inputOrCtx) ? {
|
|
@@ -215,16 +200,16 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
215
200
|
};
|
|
216
201
|
if (ctx == null) {
|
|
217
202
|
if (localApp == null) throw new Error(`${config.operationId} handler() must be called before using server-side execute()!`);
|
|
218
|
-
const res
|
|
219
|
-
if (opts?.returnHeaders === true) return res
|
|
220
|
-
headers: res
|
|
203
|
+
const res = localApp.fetch(new Request(...bundle.builder(input, opts?.headers)));
|
|
204
|
+
if (opts?.returnHeaders === true) return res instanceof Response ? bundle.parser(res).then((r) => ({
|
|
205
|
+
headers: res.headers,
|
|
221
206
|
response: r
|
|
222
|
-
})) : res
|
|
207
|
+
})) : res.then((re) => bundle.parser(re).then((r) => ({
|
|
223
208
|
headers: re.headers,
|
|
224
209
|
response: r
|
|
225
210
|
})));
|
|
226
|
-
if (opts?.asResponse === true) return res
|
|
227
|
-
return Promise.resolve(res
|
|
211
|
+
if (opts?.asResponse === true) return res;
|
|
212
|
+
return Promise.resolve(res).then((r) => bundle.parser(r));
|
|
228
213
|
}
|
|
229
214
|
const out = await resolvedHandler(withOverlays(ctx, input, config), async () => {
|
|
230
215
|
throw new Error("next() called in manual execution when response was expected");
|
|
@@ -253,18 +238,20 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
253
238
|
});
|
|
254
239
|
};
|
|
255
240
|
const createAPI = (endpoints) => endpoints;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
241
|
+
// src/api/schema/session.ts
|
|
242
|
+
const getSessionQuerySchema = z.object({
|
|
243
|
+
/**
|
|
244
|
+
* If cookie cache is enabled, it will disable the cache
|
|
245
|
+
* and fetch the session from the database
|
|
246
|
+
*/
|
|
247
|
+
disableCookieCache: z.boolean().or(z.string().transform((v) => v === "true")).openapi({
|
|
261
248
|
param: {
|
|
262
249
|
in: "query",
|
|
263
250
|
name: "disableCookieCache"
|
|
264
251
|
},
|
|
265
252
|
description: "Disable cookie cache and fetch session from database"
|
|
266
253
|
}),
|
|
267
|
-
disableRefresh: z
|
|
254
|
+
disableRefresh: z.boolean().or(z.string().transform((v) => v === "true")).openapi({
|
|
268
255
|
param: {
|
|
269
256
|
in: "query",
|
|
270
257
|
name: "disableRefresh"
|
|
@@ -272,19 +259,15 @@ const getSessionQuerySchema = z$1.object({
|
|
|
272
259
|
description: "Disable session refresh. Useful for checking session status, without updating the session"
|
|
273
260
|
})
|
|
274
261
|
}).partial();
|
|
275
|
-
const revokeSessionSchema = z
|
|
276
|
-
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/api/routes/session.ts
|
|
279
|
-
const getSessionRoute = createRoute({
|
|
262
|
+
const revokeSessionSchema = z.object({ token: z.string().openapi({ description: "The token to revoke" }) });
|
|
263
|
+
const getSession = createEndpoint(createRoute({
|
|
280
264
|
operationId: Routes.GET_SESSION,
|
|
281
265
|
method: "get",
|
|
282
266
|
path: "/get-session",
|
|
283
267
|
description: "Get the current session",
|
|
284
268
|
request: req().qry(getSessionQuerySchema).bld(),
|
|
285
269
|
responses: res(SCHEMAS[Definitions.SESSION_USER].default).err(401, "Failed to get session or expired").zod().err(500, "Unexpected Error").bld()
|
|
286
|
-
})
|
|
287
|
-
const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
270
|
+
}), (options) => async (ctx) => {
|
|
288
271
|
const { disableCookieCache, disableRefresh } = ctx.req.valid("query");
|
|
289
272
|
const context = ctx.get("context");
|
|
290
273
|
try {
|
|
@@ -316,11 +299,11 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
316
299
|
* If session data is present in the cookie, return it
|
|
317
300
|
*/
|
|
318
301
|
if (sessionDataPayload?.session && options.session?.cookieCache?.enabled === true && disableCookieCache !== true) {
|
|
319
|
-
const { session
|
|
320
|
-
if (!(session
|
|
321
|
-
if (!(sessionDataPayload.expiresAt < Date.now() || session
|
|
322
|
-
ctx.set("session", session
|
|
323
|
-
return ctx.render(session
|
|
302
|
+
const { session } = sessionDataPayload;
|
|
303
|
+
if (!(session.session.createdAt instanceof Date) || !(session.session.updatedAt instanceof Date) || !(session.session.expiresAt instanceof Date) || !(session.user.createdAt instanceof Date) || !(session.user.updatedAt instanceof Date)) console.warn("not date ln 122");
|
|
304
|
+
if (!(sessionDataPayload.expiresAt < Date.now() || session.session.expiresAt < /* @__PURE__ */ new Date())) {
|
|
305
|
+
ctx.set("session", session);
|
|
306
|
+
return ctx.render(session, 200);
|
|
324
307
|
}
|
|
325
308
|
(0, cookies_exports.deleteCookie)(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
326
309
|
}
|
|
@@ -446,15 +429,14 @@ const freshSessionMiddleware = createMiddleware()(async (ctx, next) => {
|
|
|
446
429
|
}, 403);
|
|
447
430
|
return await next();
|
|
448
431
|
});
|
|
449
|
-
const
|
|
432
|
+
const listSessions = createEndpoint(createRoute({
|
|
450
433
|
operationId: Routes.LIST_SESSIONS,
|
|
451
434
|
method: "get",
|
|
452
435
|
path: "/list-sessions",
|
|
453
436
|
description: "List all active sessions for the user",
|
|
454
437
|
middleware: [sessionMiddleware()],
|
|
455
438
|
responses: res(SCHEMAS[Definitions.SESSIONS_LIST].default).err(500).bld()
|
|
456
|
-
})
|
|
457
|
-
const listSessions = createEndpoint(listSessionsRoute, (_options) => async (ctx) => {
|
|
439
|
+
}), (_options) => async (ctx) => {
|
|
458
440
|
try {
|
|
459
441
|
const activeSessions = (await ctx.get("context").internalAdapter.listSessions(ctx.get("session").user.id)).filter((s) => s.expiresAt > /* @__PURE__ */ new Date());
|
|
460
442
|
return ctx.render(activeSessions, 200);
|
|
@@ -466,7 +448,7 @@ const listSessions = createEndpoint(listSessionsRoute, (_options) => async (ctx)
|
|
|
466
448
|
}, 500);
|
|
467
449
|
}
|
|
468
450
|
});
|
|
469
|
-
const
|
|
451
|
+
const revokeSession = createEndpoint(createRoute({
|
|
470
452
|
operationId: Routes.REVOKE_SESSION,
|
|
471
453
|
method: "post",
|
|
472
454
|
path: "/revoke-session",
|
|
@@ -474,8 +456,7 @@ const revokeSessionRoute = createRoute({
|
|
|
474
456
|
middleware: [sensitiveSessionMiddleware],
|
|
475
457
|
request: req().bdy(revokeSessionSchema).bld(),
|
|
476
458
|
responses: res(SCHEMAS[Definitions.SUCCESS].default).zod().err(400).err(401).err(500).bld()
|
|
477
|
-
})
|
|
478
|
-
const revokeSession = createEndpoint(revokeSessionRoute, (_options) => async (ctx) => {
|
|
459
|
+
}), (_options) => async (ctx) => {
|
|
479
460
|
const context = ctx.get("context");
|
|
480
461
|
const session = ctx.get("session");
|
|
481
462
|
const { token } = ctx.req.valid("json");
|
|
@@ -496,15 +477,14 @@ const revokeSession = createEndpoint(revokeSessionRoute, (_options) => async (ct
|
|
|
496
477
|
}
|
|
497
478
|
return ctx.render({ success: True }, 200);
|
|
498
479
|
});
|
|
499
|
-
const
|
|
480
|
+
const revokeSessions = createEndpoint(createRoute({
|
|
500
481
|
operationId: Routes.REVOKE_SESSIONS,
|
|
501
482
|
method: "post",
|
|
502
483
|
path: "/revoke-sessions",
|
|
503
484
|
description: "Revoke all sessions for the user",
|
|
504
485
|
middleware: [sensitiveSessionMiddleware],
|
|
505
486
|
responses: res(SCHEMAS[Definitions.SUCCESS].default).err(500).bld()
|
|
506
|
-
})
|
|
507
|
-
const revokeSessions = createEndpoint(revokeSessionsRoute, (_options) => async (ctx) => {
|
|
487
|
+
}), (_options) => async (ctx) => {
|
|
508
488
|
const context = ctx.get("context");
|
|
509
489
|
const session = ctx.get("session");
|
|
510
490
|
try {
|
|
@@ -518,21 +498,18 @@ const revokeSessions = createEndpoint(revokeSessionsRoute, (_options) => async (
|
|
|
518
498
|
}
|
|
519
499
|
return ctx.render({ success: True }, 200);
|
|
520
500
|
});
|
|
521
|
-
const
|
|
501
|
+
const revokeOtherSessions = createEndpoint(createRoute({
|
|
522
502
|
operationId: Routes.REVOKE_OTHER_SESSIONS,
|
|
523
503
|
method: "post",
|
|
524
504
|
path: "/revoke-other-sessions",
|
|
525
505
|
description: "Revoke all other sessions for the user except the current one",
|
|
526
506
|
middleware: [sensitiveSessionMiddleware],
|
|
527
507
|
responses: res(SCHEMAS[Definitions.SUCCESS].default).bld()
|
|
528
|
-
})
|
|
529
|
-
const revokeOtherSessions = createEndpoint(revokeOtherSessionsRoute, (_options) => async (ctx) => {
|
|
508
|
+
}), (_options) => async (ctx) => {
|
|
530
509
|
const context = ctx.get("context");
|
|
531
510
|
const session = ctx.get("session");
|
|
532
|
-
const otherSessions = (await context.internalAdapter.listSessions(session.user.id)).filter((session
|
|
533
|
-
await Promise.all(otherSessions.map(async (session
|
|
511
|
+
const otherSessions = (await context.internalAdapter.listSessions(session.user.id)).filter((session) => session.expiresAt > /* @__PURE__ */ new Date()).filter((sess) => sess.token !== session.session.token);
|
|
512
|
+
await Promise.all(otherSessions.map(async (session) => context.internalAdapter.deleteSession(session.token)));
|
|
534
513
|
return ctx.render({ success: True }, 200);
|
|
535
514
|
});
|
|
536
|
-
|
|
537
|
-
//#endregion
|
|
538
|
-
export { initContextMiddleware as _, requestOnlySessionMiddleware as a, revokeSessions as c, createAPI as d, createEndpoint as f, initHooksMiddleware as g, initErrorHandler as h, listSessions as i, sensitiveSessionMiddleware as l, setDefaultExecutionCtx as m, getSession as n, revokeOtherSessions as o, setRenderer as p, getSessionFromCtx as r, revokeSession as s, freshSessionMiddleware as t, sessionMiddleware as u };
|
|
515
|
+
export { initContextMiddleware as _, requestOnlySessionMiddleware as a, revokeSessions as c, createAPI as d, createEndpoint as f, initHooksMiddleware as g, initErrorHandler as h, listSessions as i, sensitiveSessionMiddleware as l, setDefaultExecutionCtx as m, getSession as n, revokeOtherSessions as o, setRenderer as p, getSessionFromCtx as r, revokeSession as s, freshSessionMiddleware as t, sessionMiddleware as u };
|