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,22 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C_Pgydhf.cjs");
|
|
2
|
+
const require_cookies = require("./cookies-DQ52rcOy.cjs");
|
|
3
|
+
const require_json = require("./json-D3aq-nH2.cjs");
|
|
4
|
+
require("./hono-pgK4H_U1.cjs");
|
|
5
|
+
const require_logged = require("./logged-BIpCpnVY.cjs");
|
|
6
|
+
const require_url = require("./url-DjCmCUHS.cjs");
|
|
7
|
+
const require_middleware = require("./middleware-Cd-VkNxB.cjs");
|
|
8
|
+
let _faire_auth_core_env = require("@faire-auth/core/env");
|
|
9
|
+
let _faire_auth_core_error = require("@faire-auth/core/error");
|
|
10
|
+
let _faire_auth_core_factory = require("@faire-auth/core/factory");
|
|
11
|
+
let _faire_auth_core_static = require("@faire-auth/core/static");
|
|
12
|
+
let _faire_auth_core_utils = require("@faire-auth/core/utils");
|
|
13
|
+
let _faire_auth_core_datatypes = require("@faire-auth/core/datatypes");
|
|
13
14
|
let hono_http_exception = require("hono/http-exception");
|
|
14
15
|
let zod = require("zod");
|
|
15
|
-
zod =
|
|
16
|
-
let
|
|
16
|
+
zod = require_rolldown_runtime.__toESM(zod, 1);
|
|
17
|
+
let _faire_auth_core_db = require("@faire-auth/core/db");
|
|
17
18
|
let hono_context_storage = require("hono/context-storage");
|
|
18
|
-
|
|
19
|
-
//#region src/api/middleware/context.ts
|
|
19
|
+
// src/api/middleware/context.ts
|
|
20
20
|
/**
|
|
21
21
|
* Initializes the context middleware.
|
|
22
22
|
* @template O - The options type.
|
|
@@ -30,14 +30,12 @@ const initContextMiddleware = (options, context, api) => require_middleware.crea
|
|
|
30
30
|
ctx.set("path", ctx.req.path.slice((options.basePath ?? "/api/auth").length));
|
|
31
31
|
return await next();
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/api/middleware/hooks.ts
|
|
33
|
+
// src/api/middleware/hooks.ts
|
|
36
34
|
const runHooks = async (ctx, hooks) => {
|
|
37
35
|
let response = void 0;
|
|
38
36
|
for (const hook of hooks) if (hook.matcher(ctx)) try {
|
|
39
37
|
const maybePromise = hook.handler(ctx);
|
|
40
|
-
const result = (0,
|
|
38
|
+
const result = (0, _faire_auth_core_static.isPromise)(maybePromise) ? await maybePromise : maybePromise;
|
|
41
39
|
if (result instanceof Response) response = result;
|
|
42
40
|
} catch (error) {
|
|
43
41
|
ctx.error = error;
|
|
@@ -86,9 +84,7 @@ const initHooksMiddleware = (options) => {
|
|
|
86
84
|
if (after instanceof Response) ctx.res = after;
|
|
87
85
|
});
|
|
88
86
|
};
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/api/middleware/on-error.ts
|
|
87
|
+
// src/api/middleware/on-error.ts
|
|
92
88
|
/**
|
|
93
89
|
* Initializes the error handler.
|
|
94
90
|
* @param options - The FaireAuth options.
|
|
@@ -96,19 +92,19 @@ const initHooksMiddleware = (options) => {
|
|
|
96
92
|
*/
|
|
97
93
|
const initErrorHandler = (options) => require_middleware.createErrorHandler()(async (e, ctx) => {
|
|
98
94
|
const ret = ctx.finalized === true ? ctx.res : e instanceof Response ? e : e instanceof hono_http_exception.HTTPException ? e.getResponse() : ctx.json({
|
|
99
|
-
success:
|
|
95
|
+
success: _faire_auth_core_static.False,
|
|
100
96
|
...options.onAPIError?.exposeMessage === true && { message: e.message }
|
|
101
97
|
}, 500);
|
|
102
|
-
if (e instanceof
|
|
98
|
+
if (e instanceof _faire_auth_core_error.APIError && e.statusText === "FOUND") return ret;
|
|
103
99
|
if (options.onAPIError?.throw === true) throw e;
|
|
104
100
|
if (options.onAPIError?.onError) {
|
|
105
|
-
const res
|
|
106
|
-
if ((0,
|
|
101
|
+
const res = options.onAPIError.onError(e, ctx);
|
|
102
|
+
if ((0, _faire_auth_core_static.isPromise)(res)) await res;
|
|
107
103
|
return ret;
|
|
108
104
|
}
|
|
109
105
|
const optLogLevel = options.logger?.level;
|
|
110
106
|
const critLog = ctx.get("context")?.logger ?? console;
|
|
111
|
-
const log = optLogLevel === "error" || optLogLevel === "warn" || optLogLevel === "debug" ?
|
|
107
|
+
const log = optLogLevel === "error" || optLogLevel === "warn" || optLogLevel === "debug" ? _faire_auth_core_env.logger : void 0;
|
|
112
108
|
if (options.logger?.disabled !== true) {
|
|
113
109
|
if (e != null && typeof e === "object" && "message" in e && typeof e.message === "string") {
|
|
114
110
|
if (e.message.includes("no column") || e.message.includes("column") || e.message.includes("relation") || e.message.includes("table") || e.message.includes("does not exist")) {
|
|
@@ -116,16 +112,14 @@ const initErrorHandler = (options) => require_middleware.createErrorHandler()(as
|
|
|
116
112
|
return ret;
|
|
117
113
|
}
|
|
118
114
|
}
|
|
119
|
-
if (e instanceof
|
|
115
|
+
if (e instanceof _faire_auth_core_error.APIError) {
|
|
120
116
|
if (e.statusText === "INTERNAL_SERVER_ERROR") critLog.error(e.statusText, e);
|
|
121
117
|
log?.error(e.message);
|
|
122
118
|
} else critLog.error(e != null && typeof e === "object" && "name" in e ? e.name : "", e);
|
|
123
119
|
}
|
|
124
120
|
return ret;
|
|
125
121
|
});
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/api/middleware/server-api.ts
|
|
122
|
+
// src/api/middleware/server-api.ts
|
|
129
123
|
/**
|
|
130
124
|
* Middleware that sets a flag indicating the route was called from the server-side API.
|
|
131
125
|
* This should only be used with localApp in createEndpoint to provide permissions depth.
|
|
@@ -134,9 +128,7 @@ const serverApiMiddleware = require_middleware.createMiddleware()(async (ctx, ne
|
|
|
134
128
|
ctx.set("isServer", true);
|
|
135
129
|
return await next();
|
|
136
130
|
});
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/utils/hono.ts
|
|
131
|
+
// src/utils/hono.ts
|
|
140
132
|
const createDefaultExecutionCtx = (ctx) => {
|
|
141
133
|
Object.defineProperty(ctx, "executionCtx", {
|
|
142
134
|
get: () => ({
|
|
@@ -148,9 +140,7 @@ const createDefaultExecutionCtx = (ctx) => {
|
|
|
148
140
|
enumerable: true
|
|
149
141
|
});
|
|
150
142
|
};
|
|
151
|
-
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/api/middleware/set-execution-ctx.ts
|
|
143
|
+
// src/api/middleware/set-execution-ctx.ts
|
|
154
144
|
/**
|
|
155
145
|
* Sets the default execution context if not already present.
|
|
156
146
|
* Manages promises to await after the middleware chain.
|
|
@@ -167,21 +157,17 @@ const setDefaultExecutionCtx = require_middleware.createMiddleware()(async (ctx,
|
|
|
167
157
|
await next();
|
|
168
158
|
if (hasDefaultExecutionCtx === true) await Promise.allSettled(ctx.get("toAwait"));
|
|
169
159
|
});
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/api/middleware/set-renderer.ts
|
|
160
|
+
// src/api/middleware/set-renderer.ts
|
|
173
161
|
/**
|
|
174
162
|
* Sets the renderer for the context.
|
|
175
163
|
*
|
|
176
164
|
* @todo `options.hono?.advanced?.cbor === true ? cborRespond : ctx.json`
|
|
177
165
|
*/
|
|
178
166
|
const setRenderer = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
179
|
-
ctx.setRenderer((0,
|
|
167
|
+
ctx.setRenderer((0, _faire_auth_core_factory.initRenderer)(ctx));
|
|
180
168
|
return await next();
|
|
181
169
|
});
|
|
182
|
-
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/api/factory/endpoint.ts
|
|
170
|
+
// src/api/factory/endpoint.ts
|
|
185
171
|
/**
|
|
186
172
|
* Creates an auth endpoint.
|
|
187
173
|
* @template C - The route config type.
|
|
@@ -195,48 +181,48 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
195
181
|
return ((options) => {
|
|
196
182
|
const resolvedHandler = handler(options);
|
|
197
183
|
let localApp = null;
|
|
198
|
-
const execute = require_logged.
|
|
184
|
+
const execute = require_logged.LoggerAPI.wrap(async (...args) => {
|
|
199
185
|
if (!bundle) throw new Error(`${config.operationId} config() must be called before using execute()!`);
|
|
200
186
|
const [inputOrCtx, maybeCtx] = args;
|
|
201
|
-
const { input, ctx, opts } = (0,
|
|
187
|
+
const { input, ctx, opts } = (0, _faire_auth_core_utils.isContextLike)(inputOrCtx) ? {
|
|
202
188
|
input: void 0,
|
|
203
189
|
ctx: inputOrCtx,
|
|
204
190
|
opts: void 0
|
|
205
|
-
} : (0,
|
|
191
|
+
} : (0, _faire_auth_core_utils.isContextLike)(maybeCtx) ? {
|
|
206
192
|
input: inputOrCtx,
|
|
207
193
|
ctx: maybeCtx,
|
|
208
194
|
opts: void 0
|
|
209
|
-
} : (0,
|
|
195
|
+
} : (0, _faire_auth_core_utils.isExecOpts)(inputOrCtx) ? {
|
|
210
196
|
input: void 0,
|
|
211
197
|
ctx: void 0,
|
|
212
198
|
opts: inputOrCtx
|
|
213
199
|
} : {
|
|
214
200
|
input: inputOrCtx,
|
|
215
201
|
ctx: void 0,
|
|
216
|
-
opts: (0,
|
|
202
|
+
opts: (0, _faire_auth_core_utils.isExecOpts)(maybeCtx) ? maybeCtx : void 0
|
|
217
203
|
};
|
|
218
204
|
if (ctx == null) {
|
|
219
205
|
if (localApp == null) throw new Error(`${config.operationId} handler() must be called before using server-side execute()!`);
|
|
220
|
-
const res
|
|
221
|
-
if (opts?.returnHeaders === true) return res
|
|
222
|
-
headers: res
|
|
206
|
+
const res = localApp.fetch(new Request(...bundle.builder(input, opts?.headers)));
|
|
207
|
+
if (opts?.returnHeaders === true) return res instanceof Response ? bundle.parser(res).then((r) => ({
|
|
208
|
+
headers: res.headers,
|
|
223
209
|
response: r
|
|
224
|
-
})) : res
|
|
210
|
+
})) : res.then((re) => bundle.parser(re).then((r) => ({
|
|
225
211
|
headers: re.headers,
|
|
226
212
|
response: r
|
|
227
213
|
})));
|
|
228
|
-
if (opts?.asResponse === true) return res
|
|
229
|
-
return Promise.resolve(res
|
|
214
|
+
if (opts?.asResponse === true) return res;
|
|
215
|
+
return Promise.resolve(res).then((r) => bundle.parser(r));
|
|
230
216
|
}
|
|
231
|
-
const out = await resolvedHandler((0,
|
|
217
|
+
const out = await resolvedHandler((0, _faire_auth_core_utils.withOverlays)(ctx, input, config), async () => {
|
|
232
218
|
throw new Error("next() called in manual execution when response was expected");
|
|
233
219
|
});
|
|
234
220
|
return bundle.parser(out);
|
|
235
221
|
}, config.operationId, "immediate");
|
|
236
222
|
execute.toArgs = (builtSchemas, context, api, routeHook = hook) => {
|
|
237
|
-
if (!bundle) bundle = (0,
|
|
238
|
-
else if (!(0,
|
|
239
|
-
if (!localApp) localApp = (0,
|
|
223
|
+
if (!bundle) bundle = (0, _faire_auth_core_factory.buildRouteBundle)(config, resolvedHandler, require_url.getBaseURL(options.baseURL, options.basePath), options, builtSchemas, routeHook, context.logger);
|
|
224
|
+
else if (!(0, _faire_auth_core_env.isTest)()) context.logger.warn(`${bundle.resolvedConfig.operationId} config() already initialized`);
|
|
225
|
+
if (!localApp) localApp = (0, _faire_auth_core_factory.createRouteAppWrapper)(bundle.routeApp, [
|
|
240
226
|
serverApiMiddleware,
|
|
241
227
|
setDefaultExecutionCtx,
|
|
242
228
|
setRenderer,
|
|
@@ -244,7 +230,7 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
244
230
|
(0, hono_context_storage.contextStorage)(),
|
|
245
231
|
initHooksMiddleware(options)
|
|
246
232
|
], initErrorHandler(options), options.basePath);
|
|
247
|
-
else if (!(0,
|
|
233
|
+
else if (!(0, _faire_auth_core_env.isTest)()) context.logger.warn(`${config.operationId} handler() was called when already initialized`);
|
|
248
234
|
return [
|
|
249
235
|
bundle.resolvedConfig,
|
|
250
236
|
resolvedHandler,
|
|
@@ -255,10 +241,12 @@ const createEndpoint = (config, handler, hook) => {
|
|
|
255
241
|
});
|
|
256
242
|
};
|
|
257
243
|
const createAPI = (endpoints) => endpoints;
|
|
258
|
-
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/api/schema/session.ts
|
|
244
|
+
// src/api/schema/session.ts
|
|
261
245
|
const getSessionQuerySchema = zod.object({
|
|
246
|
+
/**
|
|
247
|
+
* If cookie cache is enabled, it will disable the cache
|
|
248
|
+
* and fetch the session from the database
|
|
249
|
+
*/
|
|
262
250
|
disableCookieCache: zod.boolean().or(zod.string().transform((v) => v === "true")).openapi({
|
|
263
251
|
param: {
|
|
264
252
|
in: "query",
|
|
@@ -275,41 +263,37 @@ const getSessionQuerySchema = zod.object({
|
|
|
275
263
|
})
|
|
276
264
|
}).partial();
|
|
277
265
|
const revokeSessionSchema = zod.object({ token: zod.string().openapi({ description: "The token to revoke" }) });
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
//#region src/api/routes/session.ts
|
|
281
|
-
const getSessionRoute = (0, __faire_auth_core_factory.createRoute)({
|
|
282
|
-
operationId: __faire_auth_core_static.Routes.GET_SESSION,
|
|
266
|
+
const getSession = createEndpoint((0, _faire_auth_core_factory.createRoute)({
|
|
267
|
+
operationId: _faire_auth_core_static.Routes.GET_SESSION,
|
|
283
268
|
method: "get",
|
|
284
269
|
path: "/get-session",
|
|
285
270
|
description: "Get the current session",
|
|
286
|
-
request: (0,
|
|
287
|
-
responses: (0,
|
|
288
|
-
})
|
|
289
|
-
const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
271
|
+
request: (0, _faire_auth_core_factory.req)().qry(getSessionQuerySchema).bld(),
|
|
272
|
+
responses: (0, _faire_auth_core_factory.res)(_faire_auth_core_static.SCHEMAS[_faire_auth_core_static.Definitions.SESSION_USER].default).err(401, "Failed to get session or expired").zod().err(500, "Unexpected Error").bld()
|
|
273
|
+
}), (options) => async (ctx) => {
|
|
290
274
|
const { disableCookieCache, disableRefresh } = ctx.req.valid("query");
|
|
291
275
|
const context = ctx.get("context");
|
|
292
276
|
try {
|
|
293
277
|
const sessionCookieToken = await (0, require_cookies.cookies_exports.getSignedCookie)(ctx, context.secret, context.authCookies.sessionToken.name);
|
|
294
278
|
if (sessionCookieToken == null) return ctx.render({
|
|
295
|
-
success:
|
|
296
|
-
message:
|
|
279
|
+
success: _faire_auth_core_static.False,
|
|
280
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
297
281
|
}, 401);
|
|
298
282
|
if (sessionCookieToken === false) return ctx.render({
|
|
299
|
-
success:
|
|
300
|
-
message:
|
|
283
|
+
success: _faire_auth_core_static.False,
|
|
284
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.SESSION_EXPIRED
|
|
301
285
|
}, 401);
|
|
302
286
|
const sessionDataCookie = (0, require_cookies.cookies_exports.getCookie)(ctx, context.authCookies.sessionData.name);
|
|
303
|
-
const sessionDataPayload = sessionDataCookie != null ? require_json.safeJSONParse(
|
|
287
|
+
const sessionDataPayload = sessionDataCookie != null ? require_json.safeJSONParse(_faire_auth_core_datatypes.binary.decode(_faire_auth_core_datatypes.base64Url.decode(sessionDataCookie))) : null;
|
|
304
288
|
if (sessionDataPayload) {
|
|
305
|
-
if (!await (0,
|
|
289
|
+
if (!await (0, _faire_auth_core_datatypes.createHMAC)("SHA-256", "base64urlnopad").verify(context.secret, JSON.stringify({
|
|
306
290
|
...sessionDataPayload.session,
|
|
307
291
|
expiresAt: sessionDataPayload.expiresAt
|
|
308
292
|
}), sessionDataPayload.signature)) {
|
|
309
293
|
(0, require_cookies.cookies_exports.deleteCookie)(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
310
294
|
return ctx.render({
|
|
311
|
-
success:
|
|
312
|
-
message:
|
|
295
|
+
success: _faire_auth_core_static.False,
|
|
296
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
313
297
|
}, 401);
|
|
314
298
|
}
|
|
315
299
|
}
|
|
@@ -318,11 +302,11 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
318
302
|
* If session data is present in the cookie, return it
|
|
319
303
|
*/
|
|
320
304
|
if (sessionDataPayload?.session && options.session?.cookieCache?.enabled === true && disableCookieCache !== true) {
|
|
321
|
-
const { session
|
|
322
|
-
if (!(session
|
|
323
|
-
if (!(sessionDataPayload.expiresAt < Date.now() || session
|
|
324
|
-
ctx.set("session", session
|
|
325
|
-
return ctx.render(session
|
|
305
|
+
const { session } = sessionDataPayload;
|
|
306
|
+
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");
|
|
307
|
+
if (!(sessionDataPayload.expiresAt < Date.now() || session.session.expiresAt < /* @__PURE__ */ new Date())) {
|
|
308
|
+
ctx.set("session", session);
|
|
309
|
+
return ctx.render(session, 200);
|
|
326
310
|
}
|
|
327
311
|
(0, require_cookies.cookies_exports.deleteCookie)(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
328
312
|
}
|
|
@@ -333,13 +317,13 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
333
317
|
if (session) {
|
|
334
318
|
await context.internalAdapter.deleteSession(session.session.token);
|
|
335
319
|
return ctx.render({
|
|
336
|
-
success:
|
|
337
|
-
message:
|
|
320
|
+
success: _faire_auth_core_static.False,
|
|
321
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.SESSION_EXPIRED
|
|
338
322
|
}, 401);
|
|
339
323
|
}
|
|
340
324
|
return ctx.render({
|
|
341
|
-
success:
|
|
342
|
-
message:
|
|
325
|
+
success: _faire_auth_core_static.False,
|
|
326
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
343
327
|
}, 401);
|
|
344
328
|
}
|
|
345
329
|
/**
|
|
@@ -350,7 +334,7 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
350
334
|
const { expiresIn, updateAge } = context.sessionConfig;
|
|
351
335
|
if (session.session.expiresAt.valueOf() - expiresIn * 1e3 + updateAge * 1e3 <= Date.now() && !options.session?.disableSessionRefresh) {
|
|
352
336
|
const updatedSession = await context.internalAdapter.updateSession(session.session.token, {
|
|
353
|
-
expiresAt: (0,
|
|
337
|
+
expiresAt: (0, _faire_auth_core_utils.getDate)(context.sessionConfig.expiresIn, "sec"),
|
|
354
338
|
updatedAt: /* @__PURE__ */ new Date()
|
|
355
339
|
});
|
|
356
340
|
if (updatedSession == null) {
|
|
@@ -359,8 +343,8 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
359
343
|
*/
|
|
360
344
|
require_cookies.deleteSessionCookie(ctx);
|
|
361
345
|
return ctx.render({
|
|
362
|
-
success:
|
|
363
|
-
message:
|
|
346
|
+
success: _faire_auth_core_static.False,
|
|
347
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_CREATE_SESSION
|
|
364
348
|
}, 401);
|
|
365
349
|
}
|
|
366
350
|
const maxAge = (updatedSession.expiresAt.valueOf() - Date.now()) / 1e3;
|
|
@@ -380,8 +364,8 @@ const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
|
380
364
|
} catch (error) {
|
|
381
365
|
context.logger.error("INTERNAL_SERVER_ERROR", error);
|
|
382
366
|
return ctx.render({
|
|
383
|
-
success:
|
|
384
|
-
message:
|
|
367
|
+
success: _faire_auth_core_static.False,
|
|
368
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
385
369
|
}, 500);
|
|
386
370
|
}
|
|
387
371
|
});
|
|
@@ -391,13 +375,13 @@ const getSessionFromCtx = async (ctx, config) => {
|
|
|
391
375
|
const newSession = await ctx.get("api").getSession({ query: { ...config && config } }, ctx).then(async (s) => s.success === true ? {
|
|
392
376
|
success: true,
|
|
393
377
|
data: {
|
|
394
|
-
session:
|
|
395
|
-
user:
|
|
378
|
+
session: _faire_auth_core_db.looseSessionSchema.parse(s.data.session),
|
|
379
|
+
user: _faire_auth_core_db.looseUserSchema.parse(s.data.user)
|
|
396
380
|
}
|
|
397
381
|
} : s);
|
|
398
382
|
if (newSession.success === false) return ctx.render(session ?? {
|
|
399
|
-
success:
|
|
400
|
-
message:
|
|
383
|
+
success: _faire_auth_core_static.False,
|
|
384
|
+
message: _faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
401
385
|
}, 401);
|
|
402
386
|
ctx.set("session", newSession.data);
|
|
403
387
|
return newSession.data;
|
|
@@ -443,70 +427,67 @@ const freshSessionMiddleware = require_middleware.createMiddleware()(async (ctx,
|
|
|
443
427
|
if (context.sessionConfig.freshAge === 0) return await next();
|
|
444
428
|
const lastUpdated = (session.session.updatedAt ?? session.session.createdAt).valueOf();
|
|
445
429
|
if (!(Date.now() - lastUpdated < context.sessionConfig.freshAge * 1e3)) return ctx.render({
|
|
446
|
-
success:
|
|
430
|
+
success: _faire_auth_core_static.False,
|
|
447
431
|
message: "Session is not fresh"
|
|
448
432
|
}, 403);
|
|
449
433
|
return await next();
|
|
450
434
|
});
|
|
451
|
-
const
|
|
452
|
-
operationId:
|
|
435
|
+
const listSessions = createEndpoint((0, _faire_auth_core_factory.createRoute)({
|
|
436
|
+
operationId: _faire_auth_core_static.Routes.LIST_SESSIONS,
|
|
453
437
|
method: "get",
|
|
454
438
|
path: "/list-sessions",
|
|
455
439
|
description: "List all active sessions for the user",
|
|
456
440
|
middleware: [sessionMiddleware()],
|
|
457
|
-
responses: (0,
|
|
458
|
-
})
|
|
459
|
-
const listSessions = createEndpoint(listSessionsRoute, (_options) => async (ctx) => {
|
|
441
|
+
responses: (0, _faire_auth_core_factory.res)(_faire_auth_core_static.SCHEMAS[_faire_auth_core_static.Definitions.SESSIONS_LIST].default).err(500).bld()
|
|
442
|
+
}), (_options) => async (ctx) => {
|
|
460
443
|
try {
|
|
461
444
|
const activeSessions = (await ctx.get("context").internalAdapter.listSessions(ctx.get("session").user.id)).filter((s) => s.expiresAt > /* @__PURE__ */ new Date());
|
|
462
445
|
return ctx.render(activeSessions, 200);
|
|
463
446
|
} catch (e) {
|
|
464
447
|
ctx.get("context").logger.error(e instanceof Error ? e.message : String(e), e);
|
|
465
448
|
return ctx.render({
|
|
466
|
-
success:
|
|
449
|
+
success: _faire_auth_core_static.False,
|
|
467
450
|
message: "Internal server error"
|
|
468
451
|
}, 500);
|
|
469
452
|
}
|
|
470
453
|
});
|
|
471
|
-
const
|
|
472
|
-
operationId:
|
|
454
|
+
const revokeSession = createEndpoint((0, _faire_auth_core_factory.createRoute)({
|
|
455
|
+
operationId: _faire_auth_core_static.Routes.REVOKE_SESSION,
|
|
473
456
|
method: "post",
|
|
474
457
|
path: "/revoke-session",
|
|
475
458
|
description: "Revoke a single session",
|
|
476
459
|
middleware: [sensitiveSessionMiddleware],
|
|
477
|
-
request: (0,
|
|
478
|
-
responses: (0,
|
|
479
|
-
})
|
|
480
|
-
const revokeSession = createEndpoint(revokeSessionRoute, (_options) => async (ctx) => {
|
|
460
|
+
request: (0, _faire_auth_core_factory.req)().bdy(revokeSessionSchema).bld(),
|
|
461
|
+
responses: (0, _faire_auth_core_factory.res)(_faire_auth_core_static.SCHEMAS[_faire_auth_core_static.Definitions.SUCCESS].default).zod().err(400).err(401).err(500).bld()
|
|
462
|
+
}), (_options) => async (ctx) => {
|
|
481
463
|
const context = ctx.get("context");
|
|
482
464
|
const session = ctx.get("session");
|
|
483
465
|
const { token } = ctx.req.valid("json");
|
|
484
466
|
const foundSession = await context.internalAdapter.findSession(token);
|
|
485
467
|
if (!foundSession) return ctx.render({
|
|
486
|
-
success:
|
|
468
|
+
success: _faire_auth_core_static.False,
|
|
487
469
|
message: "Session not found"
|
|
488
470
|
}, 400);
|
|
489
|
-
if (foundSession.session.userId !== session.user.id) return ctx.render({ success:
|
|
471
|
+
if (foundSession.session.userId !== session.user.id) return ctx.render({ success: _faire_auth_core_static.False }, 401);
|
|
490
472
|
try {
|
|
491
473
|
await context.internalAdapter.deleteSession(token);
|
|
492
474
|
} catch (error) {
|
|
493
475
|
context.logger.error(error != null && typeof error === "object" && "name" in error ? String(error.name) : "Unknown Error", error);
|
|
494
476
|
return ctx.render({
|
|
495
|
-
success:
|
|
477
|
+
success: _faire_auth_core_static.False,
|
|
496
478
|
message: "Internal server error"
|
|
497
479
|
}, 500);
|
|
498
480
|
}
|
|
499
|
-
return ctx.render({ success:
|
|
481
|
+
return ctx.render({ success: _faire_auth_core_static.True }, 200);
|
|
500
482
|
});
|
|
501
|
-
const
|
|
502
|
-
operationId:
|
|
483
|
+
const revokeSessions = createEndpoint((0, _faire_auth_core_factory.createRoute)({
|
|
484
|
+
operationId: _faire_auth_core_static.Routes.REVOKE_SESSIONS,
|
|
503
485
|
method: "post",
|
|
504
486
|
path: "/revoke-sessions",
|
|
505
487
|
description: "Revoke all sessions for the user",
|
|
506
488
|
middleware: [sensitiveSessionMiddleware],
|
|
507
|
-
responses: (0,
|
|
508
|
-
})
|
|
509
|
-
const revokeSessions = createEndpoint(revokeSessionsRoute, (_options) => async (ctx) => {
|
|
489
|
+
responses: (0, _faire_auth_core_factory.res)(_faire_auth_core_static.SCHEMAS[_faire_auth_core_static.Definitions.SUCCESS].default).err(500).bld()
|
|
490
|
+
}), (_options) => async (ctx) => {
|
|
510
491
|
const context = ctx.get("context");
|
|
511
492
|
const session = ctx.get("session");
|
|
512
493
|
try {
|
|
@@ -514,128 +495,125 @@ const revokeSessions = createEndpoint(revokeSessionsRoute, (_options) => async (
|
|
|
514
495
|
} catch (error) {
|
|
515
496
|
context.logger.error(error != null && typeof error === "object" && "name" in error ? String(error.name) : "Unknown Error", error);
|
|
516
497
|
return ctx.render({
|
|
517
|
-
success:
|
|
498
|
+
success: _faire_auth_core_static.False,
|
|
518
499
|
message: "Internal server error"
|
|
519
500
|
}, 500);
|
|
520
501
|
}
|
|
521
|
-
return ctx.render({ success:
|
|
502
|
+
return ctx.render({ success: _faire_auth_core_static.True }, 200);
|
|
522
503
|
});
|
|
523
|
-
const
|
|
524
|
-
operationId:
|
|
504
|
+
const revokeOtherSessions = createEndpoint((0, _faire_auth_core_factory.createRoute)({
|
|
505
|
+
operationId: _faire_auth_core_static.Routes.REVOKE_OTHER_SESSIONS,
|
|
525
506
|
method: "post",
|
|
526
507
|
path: "/revoke-other-sessions",
|
|
527
508
|
description: "Revoke all other sessions for the user except the current one",
|
|
528
509
|
middleware: [sensitiveSessionMiddleware],
|
|
529
|
-
responses: (0,
|
|
530
|
-
})
|
|
531
|
-
const revokeOtherSessions = createEndpoint(revokeOtherSessionsRoute, (_options) => async (ctx) => {
|
|
510
|
+
responses: (0, _faire_auth_core_factory.res)(_faire_auth_core_static.SCHEMAS[_faire_auth_core_static.Definitions.SUCCESS].default).bld()
|
|
511
|
+
}), (_options) => async (ctx) => {
|
|
532
512
|
const context = ctx.get("context");
|
|
533
513
|
const session = ctx.get("session");
|
|
534
|
-
const otherSessions = (await context.internalAdapter.listSessions(session.user.id)).filter((session
|
|
535
|
-
await Promise.all(otherSessions.map(async (session
|
|
536
|
-
return ctx.render({ success:
|
|
514
|
+
const otherSessions = (await context.internalAdapter.listSessions(session.user.id)).filter((session) => session.expiresAt > /* @__PURE__ */ new Date()).filter((sess) => sess.token !== session.session.token);
|
|
515
|
+
await Promise.all(otherSessions.map(async (session) => context.internalAdapter.deleteSession(session.token)));
|
|
516
|
+
return ctx.render({ success: _faire_auth_core_static.True }, 200);
|
|
517
|
+
});
|
|
518
|
+
Object.defineProperty(exports, "createAPI", {
|
|
519
|
+
enumerable: true,
|
|
520
|
+
get: function() {
|
|
521
|
+
return createAPI;
|
|
522
|
+
}
|
|
537
523
|
});
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return createAPI;
|
|
544
|
-
}
|
|
524
|
+
Object.defineProperty(exports, "createEndpoint", {
|
|
525
|
+
enumerable: true,
|
|
526
|
+
get: function() {
|
|
527
|
+
return createEndpoint;
|
|
528
|
+
}
|
|
545
529
|
});
|
|
546
|
-
Object.defineProperty(exports,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
530
|
+
Object.defineProperty(exports, "freshSessionMiddleware", {
|
|
531
|
+
enumerable: true,
|
|
532
|
+
get: function() {
|
|
533
|
+
return freshSessionMiddleware;
|
|
534
|
+
}
|
|
551
535
|
});
|
|
552
|
-
Object.defineProperty(exports,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
536
|
+
Object.defineProperty(exports, "getSession", {
|
|
537
|
+
enumerable: true,
|
|
538
|
+
get: function() {
|
|
539
|
+
return getSession;
|
|
540
|
+
}
|
|
557
541
|
});
|
|
558
|
-
Object.defineProperty(exports,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
542
|
+
Object.defineProperty(exports, "getSessionFromCtx", {
|
|
543
|
+
enumerable: true,
|
|
544
|
+
get: function() {
|
|
545
|
+
return getSessionFromCtx;
|
|
546
|
+
}
|
|
563
547
|
});
|
|
564
|
-
Object.defineProperty(exports,
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
548
|
+
Object.defineProperty(exports, "initContextMiddleware", {
|
|
549
|
+
enumerable: true,
|
|
550
|
+
get: function() {
|
|
551
|
+
return initContextMiddleware;
|
|
552
|
+
}
|
|
569
553
|
});
|
|
570
|
-
Object.defineProperty(exports,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
554
|
+
Object.defineProperty(exports, "initErrorHandler", {
|
|
555
|
+
enumerable: true,
|
|
556
|
+
get: function() {
|
|
557
|
+
return initErrorHandler;
|
|
558
|
+
}
|
|
575
559
|
});
|
|
576
|
-
Object.defineProperty(exports,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
560
|
+
Object.defineProperty(exports, "initHooksMiddleware", {
|
|
561
|
+
enumerable: true,
|
|
562
|
+
get: function() {
|
|
563
|
+
return initHooksMiddleware;
|
|
564
|
+
}
|
|
581
565
|
});
|
|
582
|
-
Object.defineProperty(exports,
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
566
|
+
Object.defineProperty(exports, "listSessions", {
|
|
567
|
+
enumerable: true,
|
|
568
|
+
get: function() {
|
|
569
|
+
return listSessions;
|
|
570
|
+
}
|
|
587
571
|
});
|
|
588
|
-
Object.defineProperty(exports,
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
572
|
+
Object.defineProperty(exports, "requestOnlySessionMiddleware", {
|
|
573
|
+
enumerable: true,
|
|
574
|
+
get: function() {
|
|
575
|
+
return requestOnlySessionMiddleware;
|
|
576
|
+
}
|
|
593
577
|
});
|
|
594
|
-
Object.defineProperty(exports,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
578
|
+
Object.defineProperty(exports, "revokeOtherSessions", {
|
|
579
|
+
enumerable: true,
|
|
580
|
+
get: function() {
|
|
581
|
+
return revokeOtherSessions;
|
|
582
|
+
}
|
|
599
583
|
});
|
|
600
|
-
Object.defineProperty(exports,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
584
|
+
Object.defineProperty(exports, "revokeSession", {
|
|
585
|
+
enumerable: true,
|
|
586
|
+
get: function() {
|
|
587
|
+
return revokeSession;
|
|
588
|
+
}
|
|
605
589
|
});
|
|
606
|
-
Object.defineProperty(exports,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
590
|
+
Object.defineProperty(exports, "revokeSessions", {
|
|
591
|
+
enumerable: true,
|
|
592
|
+
get: function() {
|
|
593
|
+
return revokeSessions;
|
|
594
|
+
}
|
|
611
595
|
});
|
|
612
|
-
Object.defineProperty(exports,
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
596
|
+
Object.defineProperty(exports, "sensitiveSessionMiddleware", {
|
|
597
|
+
enumerable: true,
|
|
598
|
+
get: function() {
|
|
599
|
+
return sensitiveSessionMiddleware;
|
|
600
|
+
}
|
|
617
601
|
});
|
|
618
|
-
Object.defineProperty(exports,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
602
|
+
Object.defineProperty(exports, "sessionMiddleware", {
|
|
603
|
+
enumerable: true,
|
|
604
|
+
get: function() {
|
|
605
|
+
return sessionMiddleware;
|
|
606
|
+
}
|
|
623
607
|
});
|
|
624
|
-
Object.defineProperty(exports,
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
608
|
+
Object.defineProperty(exports, "setDefaultExecutionCtx", {
|
|
609
|
+
enumerable: true,
|
|
610
|
+
get: function() {
|
|
611
|
+
return setDefaultExecutionCtx;
|
|
612
|
+
}
|
|
629
613
|
});
|
|
630
|
-
Object.defineProperty(exports,
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
614
|
+
Object.defineProperty(exports, "setRenderer", {
|
|
615
|
+
enumerable: true,
|
|
616
|
+
get: function() {
|
|
617
|
+
return setRenderer;
|
|
618
|
+
}
|
|
635
619
|
});
|
|
636
|
-
Object.defineProperty(exports, 'setRenderer', {
|
|
637
|
-
enumerable: true,
|
|
638
|
-
get: function () {
|
|
639
|
-
return setRenderer;
|
|
640
|
-
}
|
|
641
|
-
});
|