faire-auth 1.0.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/LICENSE +661 -0
- package/README.md +34 -0
- package/dist/access-B5bBI4uT.mjs +39 -0
- package/dist/access-Crt-IJ2P.cjs +51 -0
- package/dist/adapter-factory-BXei1QRX.mjs +881 -0
- package/dist/adapter-factory-DT-_2aHJ.cjs +893 -0
- package/dist/adapters/drizzle-adapter/index.cjs +208 -0
- package/dist/adapters/drizzle-adapter/index.d.cts +48 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +48 -0
- package/dist/adapters/drizzle-adapter/index.mjs +207 -0
- package/dist/adapters/index.cjs +23 -0
- package/dist/adapters/index.d.cts +157 -0
- package/dist/adapters/index.d.mts +157 -0
- package/dist/adapters/index.mjs +17 -0
- package/dist/adapters/kysely-adapter/index.cjs +11 -0
- package/dist/adapters/kysely-adapter/index.d.cts +52 -0
- package/dist/adapters/kysely-adapter/index.d.mts +52 -0
- package/dist/adapters/kysely-adapter/index.mjs +9 -0
- package/dist/adapters/memory-adapter/index.cjs +9 -0
- package/dist/adapters/memory-adapter/index.d.cts +15 -0
- package/dist/adapters/memory-adapter/index.d.mts +15 -0
- package/dist/adapters/memory-adapter/index.mjs +9 -0
- package/dist/adapters/mongodb-adapter/index.cjs +9 -0
- package/dist/adapters/mongodb-adapter/index.d.cts +4 -0
- package/dist/adapters/mongodb-adapter/index.d.mts +4 -0
- package/dist/adapters/mongodb-adapter/index.mjs +9 -0
- package/dist/adapters/prisma-adapter/index.cjs +156 -0
- package/dist/adapters/prisma-adapter/index.d.cts +35 -0
- package/dist/adapters/prisma-adapter/index.d.mts +35 -0
- package/dist/adapters/prisma-adapter/index.mjs +155 -0
- package/dist/adapters/test.cjs +797 -0
- package/dist/adapters/test.d.cts +82 -0
- package/dist/adapters/test.d.mts +82 -0
- package/dist/adapters/test.mjs +793 -0
- package/dist/api/index.cjs +20 -0
- package/dist/api/index.d.cts +3 -0
- package/dist/api/index.d.mts +3 -0
- package/dist/api/index.mjs +20 -0
- package/dist/api/middleware/index.cjs +16 -0
- package/dist/api/middleware/index.d.cts +16 -0
- package/dist/api/middleware/index.d.mts +16 -0
- package/dist/api/middleware/index.mjs +11 -0
- package/dist/api-Bm89BLgN.cjs +1899 -0
- package/dist/api-_B7qO28y.mjs +1892 -0
- package/dist/auth-Bo9PDt5j.cjs +739 -0
- package/dist/auth-Ds4AG4h4.mjs +709 -0
- package/dist/bearer-0SeEmaS4.mjs +54 -0
- package/dist/bearer-CHeREcGT.cjs +60 -0
- package/dist/bun-sqlite-dialect-CfkBo2v5.mjs +155 -0
- package/dist/bun-sqlite-dialect-wuaC2-gh.cjs +156 -0
- package/dist/chunk-Ceigfy4P.mjs +39 -0
- package/dist/chunk-oakRccI5.cjs +60 -0
- package/dist/client/index.cjs +22 -0
- package/dist/client/index.d.cts +8 -0
- package/dist/client/index.d.mts +8 -0
- package/dist/client/index.mjs +19 -0
- package/dist/client/lynx/index.cjs +79 -0
- package/dist/client/lynx/index.d.cts +156 -0
- package/dist/client/lynx/index.d.mts +156 -0
- package/dist/client/lynx/index.mjs +76 -0
- package/dist/client/plugins/index.cjs +11 -0
- package/dist/client/plugins/index.d.cts +17 -0
- package/dist/client/plugins/index.d.mts +17 -0
- package/dist/client/plugins/index.mjs +10 -0
- package/dist/client/react/index.cjs +79 -0
- package/dist/client/react/index.d.cts +156 -0
- package/dist/client/react/index.d.mts +156 -0
- package/dist/client/react/index.mjs +76 -0
- package/dist/client/solid/index.cjs +51 -0
- package/dist/client/solid/index.d.cts +90 -0
- package/dist/client/solid/index.d.mts +90 -0
- package/dist/client/solid/index.mjs +50 -0
- package/dist/client/svelte/index.cjs +28 -0
- package/dist/client/svelte/index.d.cts +110 -0
- package/dist/client/svelte/index.d.mts +110 -0
- package/dist/client/svelte/index.mjs +28 -0
- package/dist/client/vue/index.cjs +68 -0
- package/dist/client/vue/index.d.cts +123 -0
- package/dist/client/vue/index.d.mts +123 -0
- package/dist/client/vue/index.mjs +67 -0
- package/dist/cookies-B5xeA6i8.cjs +456 -0
- package/dist/cookies-Ch1JfQIz.mjs +367 -0
- package/dist/crypto/index.cjs +11 -0
- package/dist/crypto/index.d.cts +22 -0
- package/dist/crypto/index.d.mts +22 -0
- package/dist/crypto/index.mjs +5 -0
- package/dist/crypto-CcTxYH82.cjs +57 -0
- package/dist/crypto-CyQRFtkq.mjs +41 -0
- package/dist/db/index.cjs +40 -0
- package/dist/db/index.d.cts +4 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +16 -0
- package/dist/db-BTKyYu-_.cjs +1180 -0
- package/dist/db-xiJtoDgz.mjs +1119 -0
- package/dist/defu-B0Svx_x4.cjs +34 -0
- package/dist/defu-SZkpHhbR.mjs +28 -0
- package/dist/email-verification-C-AsfJsb.cjs +247 -0
- package/dist/email-verification-CWhj2qfb.mjs +228 -0
- package/dist/hono-BEq1NYVX.cjs +526 -0
- package/dist/hono-Cdukwu5K.cjs +13 -0
- package/dist/hono-CoKYWnXA.mjs +7 -0
- package/dist/hono-Covz10jU.mjs +508 -0
- package/dist/hono-DOM31WQz.d.cts +18 -0
- package/dist/hono-DuE14mmj.d.mts +18 -0
- package/dist/index-B-WeOMzg.d.cts +13350 -0
- package/dist/index-B09P9p5_.d.cts +33 -0
- package/dist/index-B5_0QTLg.d.mts +3 -0
- package/dist/index-B7SKyR_a.d.cts +3 -0
- package/dist/index-BVHscLQl.d.cts +992 -0
- package/dist/index-C2-2QDyS.d.cts +35 -0
- package/dist/index-CTwrVluH.d.mts +41 -0
- package/dist/index-CWAqWfoZ.d.cts +27 -0
- package/dist/index-CYSShrFx.d.mts +27 -0
- package/dist/index-Qu-iJGNr.d.mts +992 -0
- package/dist/index-cs4Sh0En.d.cts +41 -0
- package/dist/index-jlessPI0.d.mts +13350 -0
- package/dist/index-ppgcFe12.d.mts +33 -0
- package/dist/index-to0RO38U.d.mts +35 -0
- package/dist/index.cjs +85 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +27 -0
- package/dist/integrations/next-js.cjs +50 -0
- package/dist/integrations/next-js.d.cts +23 -0
- package/dist/integrations/next-js.d.mts +23 -0
- package/dist/integrations/next-js.mjs +49 -0
- package/dist/integrations/node.cjs +139 -0
- package/dist/integrations/node.d.cts +22 -0
- package/dist/integrations/node.d.mts +22 -0
- package/dist/integrations/node.mjs +134 -0
- package/dist/integrations/react-start.cjs +37 -0
- package/dist/integrations/react-start.d.cts +17 -0
- package/dist/integrations/react-start.d.mts +17 -0
- package/dist/integrations/react-start.mjs +37 -0
- package/dist/integrations/solid-start.cjs +14 -0
- package/dist/integrations/solid-start.d.cts +13 -0
- package/dist/integrations/solid-start.d.mts +13 -0
- package/dist/integrations/solid-start.mjs +13 -0
- package/dist/integrations/svelte-kit.cjs +52 -0
- package/dist/integrations/svelte-kit.d.cts +42 -0
- package/dist/integrations/svelte-kit.d.mts +42 -0
- package/dist/integrations/svelte-kit.mjs +49 -0
- package/dist/ip-B5SwXaMB.cjs +54 -0
- package/dist/ip-BjNYspCH.mjs +36 -0
- package/dist/json-B1v2qRTQ.mjs +24 -0
- package/dist/json-CcJ2HjGo.cjs +30 -0
- package/dist/kysely-adapter-Bxi7sPdG.cjs +288 -0
- package/dist/kysely-adapter-DRuoT_X8.mjs +270 -0
- package/dist/logged-CyGfp8_H.mjs +187 -0
- package/dist/logged-DQK3C64b.cjs +193 -0
- package/dist/memory-adapter-BlnDIAAX.cjs +154 -0
- package/dist/memory-adapter-Db3tsJTn.mjs +148 -0
- package/dist/middleware-CE6OhDkq.mjs +29 -0
- package/dist/middleware-CWvRH4EW.cjs +47 -0
- package/dist/mongodb-adapter-C_qGQED5.mjs +291 -0
- package/dist/mongodb-adapter-C_qfK87x.cjs +297 -0
- package/dist/node-sqlite-dialect-BfBzyOAg.mjs +155 -0
- package/dist/node-sqlite-dialect-mJWC8LWQ.cjs +156 -0
- package/dist/oauth2/index.cjs +25 -0
- package/dist/oauth2/index.d.cts +42 -0
- package/dist/oauth2/index.d.mts +42 -0
- package/dist/oauth2/index.mjs +16 -0
- package/dist/oauth2-B8M0lW9l.mjs +159 -0
- package/dist/oauth2-BLeOEi7Y.cjs +177 -0
- package/dist/origin-check-8Gajklvh.mjs +228 -0
- package/dist/origin-check-id9lTnqZ.cjs +246 -0
- package/dist/parser-CdncAl9i.cjs +83 -0
- package/dist/parser-CeAer-RM.mjs +71 -0
- package/dist/passkey-B6N20LSS.cjs +512 -0
- package/dist/passkey-DJsR_GX3.mjs +505 -0
- package/dist/plugins/access/index.cjs +4 -0
- package/dist/plugins/access/index.d.cts +2 -0
- package/dist/plugins/access/index.d.mts +2 -0
- package/dist/plugins/access/index.mjs +3 -0
- package/dist/plugins/bearer/index.cjs +7 -0
- package/dist/plugins/bearer/index.d.cts +4 -0
- package/dist/plugins/bearer/index.d.mts +4 -0
- package/dist/plugins/bearer/index.mjs +7 -0
- package/dist/plugins/index.cjs +49 -0
- package/dist/plugins/index.d.cts +9326 -0
- package/dist/plugins/index.d.mts +9326 -0
- package/dist/plugins/index.mjs +26 -0
- package/dist/plugins/passkey/index.cjs +15 -0
- package/dist/plugins/passkey/index.d.cts +4 -0
- package/dist/plugins/passkey/index.d.mts +4 -0
- package/dist/plugins/passkey/index.mjs +15 -0
- package/dist/plugins-C1lm2Wj3.cjs +5254 -0
- package/dist/plugins-Dai1QkRU.mjs +5199 -0
- package/dist/request-1NL_1lyJ.mjs +58 -0
- package/dist/request-CPNlp-DK.cjs +100 -0
- package/dist/schema-D-qjygfE.cjs +179 -0
- package/dist/schema-DTIwLLmf.mjs +125 -0
- package/dist/session-De9POJTW.cjs +641 -0
- package/dist/session-rH8ougDl.mjs +538 -0
- package/dist/social-providers/index.cjs +10 -0
- package/dist/social-providers/index.d.cts +2 -0
- package/dist/social-providers/index.d.mts +2 -0
- package/dist/social-providers/index.mjs +5 -0
- package/dist/social-providers-DcFNUT0S.cjs +13 -0
- package/dist/social-providers-DoYJhBe3.mjs +9 -0
- package/dist/state--f7fwIGh.cjs +99 -0
- package/dist/state-CqJfCIl9.mjs +86 -0
- package/dist/test-utils/index.cjs +27492 -0
- package/dist/test-utils/index.d.cts +4584 -0
- package/dist/test-utils/index.d.mts +4584 -0
- package/dist/test-utils/index.mjs +27490 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/url-BoUuoIwZ.mjs +88 -0
- package/dist/url-D2yvKaM7.cjs +118 -0
- package/dist/utils/cookies.cjs +51 -0
- package/dist/utils/cookies.d.cts +179 -0
- package/dist/utils/cookies.d.mts +179 -0
- package/dist/utils/cookies.mjs +7 -0
- package/dist/utils-44aDDP8f.cjs +2 -0
- package/dist/utils-D4vZd1-9.mjs +4 -0
- package/dist/vanilla-Bu2PmFzE.cjs +30 -0
- package/dist/vanilla-TfHqeiC7.mjs +25 -0
- package/package.json +470 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-oakRccI5.cjs');
|
|
2
|
+
const require_json = require('./json-CcJ2HjGo.cjs');
|
|
3
|
+
const require_cookies = require('./cookies-B5xeA6i8.cjs');
|
|
4
|
+
const require_logged = require('./logged-DQK3C64b.cjs');
|
|
5
|
+
const require_url = require('./url-D2yvKaM7.cjs');
|
|
6
|
+
const require_middleware = require('./middleware-CWvRH4EW.cjs');
|
|
7
|
+
let __faire_auth_core_env = require("@faire-auth/core/env");
|
|
8
|
+
let __faire_auth_core_error = require("@faire-auth/core/error");
|
|
9
|
+
let __faire_auth_core_factory = require("@faire-auth/core/factory");
|
|
10
|
+
let __faire_auth_core_static = require("@faire-auth/core/static");
|
|
11
|
+
let __faire_auth_core_utils = require("@faire-auth/core/utils");
|
|
12
|
+
let __faire_auth_core_datatypes = require("@faire-auth/core/datatypes");
|
|
13
|
+
let hono_http_exception = require("hono/http-exception");
|
|
14
|
+
let zod = require("zod");
|
|
15
|
+
zod = require_chunk.__toESM(zod);
|
|
16
|
+
let __faire_auth_core_db = require("@faire-auth/core/db");
|
|
17
|
+
let hono_context_storage = require("hono/context-storage");
|
|
18
|
+
|
|
19
|
+
//#region src/api/middleware/context.ts
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the context middleware.
|
|
22
|
+
* @template O - The options type.
|
|
23
|
+
* @param options - The FaireAuth options.
|
|
24
|
+
* @param context - The auth context.
|
|
25
|
+
* @returns The middleware function.
|
|
26
|
+
*/
|
|
27
|
+
const initContextMiddleware = (options, context, api) => require_middleware.createMiddleware()(async (ctx, next) => {
|
|
28
|
+
ctx.set("context", context);
|
|
29
|
+
ctx.set("api", api);
|
|
30
|
+
ctx.set("path", ctx.req.path.slice((options.basePath ?? "/api/auth").length));
|
|
31
|
+
return await next();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/api/middleware/hooks.ts
|
|
36
|
+
const runHooks = async (ctx, hooks) => {
|
|
37
|
+
let response = void 0;
|
|
38
|
+
for (const hook of hooks) if (hook.matcher(ctx)) try {
|
|
39
|
+
const maybePromise = hook.handler(ctx);
|
|
40
|
+
const result = (0, __faire_auth_core_static.isPromise)(maybePromise) ? await maybePromise : maybePromise;
|
|
41
|
+
if (result instanceof Response) response = result;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
ctx.error = error;
|
|
44
|
+
}
|
|
45
|
+
return response;
|
|
46
|
+
};
|
|
47
|
+
const getHooks = (options) => {
|
|
48
|
+
const beforeHooks = [];
|
|
49
|
+
const afterHooks = [];
|
|
50
|
+
if (options.hooks?.before != null) beforeHooks.push({
|
|
51
|
+
matcher: () => true,
|
|
52
|
+
handler: options.hooks.before(options)
|
|
53
|
+
});
|
|
54
|
+
if (options.hooks?.after != null) afterHooks.push({
|
|
55
|
+
matcher: () => true,
|
|
56
|
+
handler: options.hooks.after(options)
|
|
57
|
+
});
|
|
58
|
+
options.plugins?.forEach((p) => {
|
|
59
|
+
p.hooks?.before?.forEach((h) => beforeHooks.push({
|
|
60
|
+
matcher: h.matcher,
|
|
61
|
+
handler: h.handler(options)
|
|
62
|
+
}));
|
|
63
|
+
p.hooks?.after?.forEach((h) => afterHooks.push({
|
|
64
|
+
matcher: h.matcher,
|
|
65
|
+
handler: h.handler(options)
|
|
66
|
+
}));
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
beforeHooks,
|
|
70
|
+
afterHooks
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Initializes the hooks middleware.
|
|
75
|
+
* @template O - The options type.
|
|
76
|
+
* @param options - The FaireAuth options.
|
|
77
|
+
* @returns The middleware function.
|
|
78
|
+
*/
|
|
79
|
+
const initHooksMiddleware = (options) => {
|
|
80
|
+
const { beforeHooks, afterHooks } = getHooks(options);
|
|
81
|
+
return require_middleware.createMiddleware()(async (ctx, next) => {
|
|
82
|
+
const before = await runHooks(ctx, beforeHooks);
|
|
83
|
+
if (before instanceof Response) return before;
|
|
84
|
+
await next();
|
|
85
|
+
const after = await runHooks(ctx, afterHooks);
|
|
86
|
+
if (after instanceof Response) ctx.res = after;
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/api/middleware/on-error.ts
|
|
92
|
+
/**
|
|
93
|
+
* Initializes the error handler.
|
|
94
|
+
* @param options - The FaireAuth options.
|
|
95
|
+
* @returns The error handler function.
|
|
96
|
+
*/
|
|
97
|
+
const initErrorHandler = (options) => require_middleware.createErrorHandler()(async (e, ctx) => {
|
|
98
|
+
const ret = ctx.finalized === true ? ctx.res : e instanceof Response ? e : e instanceof hono_http_exception.HTTPException ? e.getResponse() : ctx.json({
|
|
99
|
+
success: __faire_auth_core_static.False,
|
|
100
|
+
...options.onAPIError?.exposeMessage === true && { message: e.message }
|
|
101
|
+
}, 500);
|
|
102
|
+
if (e instanceof __faire_auth_core_error.APIError && e.statusText === "FOUND") return ret;
|
|
103
|
+
if (options.onAPIError?.throw === true) throw e;
|
|
104
|
+
if (options.onAPIError?.onError) {
|
|
105
|
+
const res$1 = options.onAPIError.onError(e, ctx);
|
|
106
|
+
if ((0, __faire_auth_core_static.isPromise)(res$1)) await res$1;
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
const optLogLevel = options.logger?.level;
|
|
110
|
+
const critLog = ctx.get("context")?.logger ?? console;
|
|
111
|
+
const log = optLogLevel === "error" || optLogLevel === "warn" || optLogLevel === "debug" ? __faire_auth_core_env.logger : void 0;
|
|
112
|
+
if (options.logger?.disabled !== true) {
|
|
113
|
+
if (e != null && typeof e === "object" && "message" in e && typeof e.message === "string") {
|
|
114
|
+
if (e.message.includes("no column") || e.message.includes("column") || e.message.includes("relation") || e.message.includes("table") || e.message.includes("does not exist")) {
|
|
115
|
+
critLog.error(e.message);
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (e instanceof __faire_auth_core_error.APIError) {
|
|
120
|
+
if (e.statusText === "INTERNAL_SERVER_ERROR") critLog.error(e.statusText, e);
|
|
121
|
+
log?.error(e.message);
|
|
122
|
+
} else critLog.error(e != null && typeof e === "object" && "name" in e ? e.name : "", e);
|
|
123
|
+
}
|
|
124
|
+
return ret;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/api/middleware/server-api.ts
|
|
129
|
+
/**
|
|
130
|
+
* Middleware that sets a flag indicating the route was called from the server-side API.
|
|
131
|
+
* This should only be used with localApp in createEndpoint to provide permissions depth.
|
|
132
|
+
*/
|
|
133
|
+
const serverApiMiddleware = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
134
|
+
ctx.set("isServer", true);
|
|
135
|
+
return await next();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/utils/hono.ts
|
|
140
|
+
const createDefaultExecutionCtx = (ctx) => {
|
|
141
|
+
Object.defineProperty(ctx, "executionCtx", {
|
|
142
|
+
get: () => ({
|
|
143
|
+
waitUntil: (promise) => ctx.get("toAwait").push(promise),
|
|
144
|
+
passThroughOnException: () => {},
|
|
145
|
+
props: {}
|
|
146
|
+
}),
|
|
147
|
+
configurable: true,
|
|
148
|
+
enumerable: true
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/api/middleware/set-execution-ctx.ts
|
|
154
|
+
/**
|
|
155
|
+
* Sets the default execution context if not already present.
|
|
156
|
+
* Manages promises to await after the middleware chain.
|
|
157
|
+
*/
|
|
158
|
+
const setDefaultExecutionCtx = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
159
|
+
ctx.set("toAwait", []);
|
|
160
|
+
let hasDefaultExecutionCtx = false;
|
|
161
|
+
try {
|
|
162
|
+
ctx.executionCtx;
|
|
163
|
+
} catch {
|
|
164
|
+
createDefaultExecutionCtx(ctx);
|
|
165
|
+
hasDefaultExecutionCtx = true;
|
|
166
|
+
}
|
|
167
|
+
await next();
|
|
168
|
+
if (hasDefaultExecutionCtx === true) await Promise.allSettled(ctx.get("toAwait"));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/api/middleware/set-renderer.ts
|
|
173
|
+
/**
|
|
174
|
+
* Sets the renderer for the context.
|
|
175
|
+
*
|
|
176
|
+
* @todo `options.hono?.advanced?.cbor === true ? cborRespond : ctx.json`
|
|
177
|
+
*/
|
|
178
|
+
const setRenderer = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
179
|
+
ctx.setRenderer((0, __faire_auth_core_factory.initRenderer)(ctx));
|
|
180
|
+
return await next();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/api/factory/endpoint.ts
|
|
185
|
+
/**
|
|
186
|
+
* Creates an auth endpoint.
|
|
187
|
+
* @template C - The route config type.
|
|
188
|
+
* @param config - The route configuration.
|
|
189
|
+
* @param handler - The route handler function.
|
|
190
|
+
* @param hook - Optional route hook.
|
|
191
|
+
* @returns The auth endpoint function.
|
|
192
|
+
*/
|
|
193
|
+
const createEndpoint = (config, handler, hook) => {
|
|
194
|
+
let bundle = null;
|
|
195
|
+
return ((options) => {
|
|
196
|
+
const resolvedHandler = handler(options);
|
|
197
|
+
let localApp = null;
|
|
198
|
+
const execute = require_logged.logged_default.wrap(async (...args) => {
|
|
199
|
+
if (!bundle) throw new Error(`${config.operationId} config() must be called before using execute()!`);
|
|
200
|
+
const [inputOrCtx, maybeCtx] = args;
|
|
201
|
+
const { input, ctx, opts } = (0, __faire_auth_core_utils.isContextLike)(inputOrCtx) ? {
|
|
202
|
+
input: void 0,
|
|
203
|
+
ctx: inputOrCtx,
|
|
204
|
+
opts: void 0
|
|
205
|
+
} : (0, __faire_auth_core_utils.isContextLike)(maybeCtx) ? {
|
|
206
|
+
input: inputOrCtx,
|
|
207
|
+
ctx: maybeCtx,
|
|
208
|
+
opts: void 0
|
|
209
|
+
} : (0, __faire_auth_core_utils.isExecOpts)(inputOrCtx) ? {
|
|
210
|
+
input: void 0,
|
|
211
|
+
ctx: void 0,
|
|
212
|
+
opts: inputOrCtx
|
|
213
|
+
} : {
|
|
214
|
+
input: inputOrCtx,
|
|
215
|
+
ctx: void 0,
|
|
216
|
+
opts: (0, __faire_auth_core_utils.isExecOpts)(maybeCtx) ? maybeCtx : void 0
|
|
217
|
+
};
|
|
218
|
+
if (ctx == null) {
|
|
219
|
+
if (localApp == null) throw new Error(`${config.operationId} handler() must be called before using server-side execute()!`);
|
|
220
|
+
const res$1 = localApp.fetch(new Request(...bundle.builder(input, opts?.headers)));
|
|
221
|
+
if (opts?.returnHeaders === true) return res$1 instanceof Response ? bundle.parser(res$1).then((r) => ({
|
|
222
|
+
headers: res$1.headers,
|
|
223
|
+
response: r
|
|
224
|
+
})) : res$1.then((re) => bundle.parser(re).then((r) => ({
|
|
225
|
+
headers: re.headers,
|
|
226
|
+
response: r
|
|
227
|
+
})));
|
|
228
|
+
if (opts?.asResponse === true) return res$1;
|
|
229
|
+
return Promise.resolve(res$1).then((r) => bundle.parser(r));
|
|
230
|
+
}
|
|
231
|
+
const out = await resolvedHandler((0, __faire_auth_core_utils.withOverlays)(ctx, input, config), async () => {
|
|
232
|
+
throw new Error("next() called in manual execution when response was expected");
|
|
233
|
+
});
|
|
234
|
+
return bundle.parser(out);
|
|
235
|
+
}, config.operationId, "immediate");
|
|
236
|
+
execute.toArgs = (builtSchemas, context, api, routeHook = hook) => {
|
|
237
|
+
if (!bundle) bundle = (0, __faire_auth_core_factory.buildRouteBundle)(config, resolvedHandler, require_url.getBaseURL(options.baseURL, options.basePath), options, builtSchemas, routeHook, context.logger);
|
|
238
|
+
else if (!(0, __faire_auth_core_env.isTest)()) context.logger.warn(`${bundle.resolvedConfig.operationId} config() already initialized`);
|
|
239
|
+
if (!localApp) localApp = (0, __faire_auth_core_factory.createRouteAppWrapper)(bundle.routeApp, [
|
|
240
|
+
serverApiMiddleware,
|
|
241
|
+
setDefaultExecutionCtx,
|
|
242
|
+
setRenderer,
|
|
243
|
+
initContextMiddleware(options, context, api),
|
|
244
|
+
(0, hono_context_storage.contextStorage)(),
|
|
245
|
+
initHooksMiddleware(options)
|
|
246
|
+
], initErrorHandler(options), options.basePath);
|
|
247
|
+
else if (!(0, __faire_auth_core_env.isTest)()) context.logger.warn(`${config.operationId} handler() was called when already initialized`);
|
|
248
|
+
return [
|
|
249
|
+
bundle.resolvedConfig,
|
|
250
|
+
resolvedHandler,
|
|
251
|
+
routeHook
|
|
252
|
+
];
|
|
253
|
+
};
|
|
254
|
+
return execute;
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
const createAPI = (endpoints) => endpoints;
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/api/schema/session.ts
|
|
261
|
+
const getSessionQuerySchema = zod.object({
|
|
262
|
+
disableCookieCache: zod.boolean().or(zod.string().transform((v) => v === "true")).openapi({
|
|
263
|
+
param: {
|
|
264
|
+
in: "query",
|
|
265
|
+
name: "disableCookieCache"
|
|
266
|
+
},
|
|
267
|
+
description: "Disable cookie cache and fetch session from database"
|
|
268
|
+
}),
|
|
269
|
+
disableRefresh: zod.boolean().or(zod.string().transform((v) => v === "true")).openapi({
|
|
270
|
+
param: {
|
|
271
|
+
in: "query",
|
|
272
|
+
name: "disableRefresh"
|
|
273
|
+
},
|
|
274
|
+
description: "Disable session refresh. Useful for checking session status, without updating the session"
|
|
275
|
+
})
|
|
276
|
+
}).partial();
|
|
277
|
+
const revokeSessionSchema = zod.object({ token: zod.string().openapi({ description: "The token to revoke" }) });
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
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,
|
|
283
|
+
method: "get",
|
|
284
|
+
path: "/get-session",
|
|
285
|
+
description: "Get the current session",
|
|
286
|
+
request: (0, __faire_auth_core_factory.req)().qry(getSessionQuerySchema).bld(),
|
|
287
|
+
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()
|
|
288
|
+
});
|
|
289
|
+
const getSession = createEndpoint(getSessionRoute, (options) => async (ctx) => {
|
|
290
|
+
const { disableCookieCache, disableRefresh } = ctx.req.valid("query");
|
|
291
|
+
const context = ctx.get("context");
|
|
292
|
+
try {
|
|
293
|
+
const sessionCookieToken = await (0, require_cookies.cookies_exports.getSignedCookie)(ctx, context.secret, context.authCookies.sessionToken.name);
|
|
294
|
+
if (sessionCookieToken == null) return ctx.render({
|
|
295
|
+
success: __faire_auth_core_static.False,
|
|
296
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
297
|
+
}, 401);
|
|
298
|
+
if (sessionCookieToken === false) return ctx.render({
|
|
299
|
+
success: __faire_auth_core_static.False,
|
|
300
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.SESSION_EXPIRED
|
|
301
|
+
}, 401);
|
|
302
|
+
const sessionDataCookie = (0, require_cookies.cookies_exports.getCookie)(ctx, context.authCookies.sessionData.name);
|
|
303
|
+
const sessionDataPayload = sessionDataCookie != null ? require_json.safeJSONParse(__faire_auth_core_datatypes.binary.decode(__faire_auth_core_datatypes.base64Url.decode(sessionDataCookie))) : null;
|
|
304
|
+
if (sessionDataPayload) {
|
|
305
|
+
if (!await (0, __faire_auth_core_datatypes.createHMAC)("SHA-256", "base64urlnopad").verify(context.secret, JSON.stringify({
|
|
306
|
+
...sessionDataPayload.session,
|
|
307
|
+
expiresAt: sessionDataPayload.expiresAt
|
|
308
|
+
}), sessionDataPayload.signature)) {
|
|
309
|
+
(0, require_cookies.cookies_exports.deleteCookie)(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
310
|
+
return ctx.render({
|
|
311
|
+
success: __faire_auth_core_static.False,
|
|
312
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
313
|
+
}, 401);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const dontRememberMe = await (0, require_cookies.cookies_exports.getSignedCookie)(ctx, context.secret, context.authCookies.dontRememberToken.name);
|
|
317
|
+
/**
|
|
318
|
+
* If session data is present in the cookie, return it
|
|
319
|
+
*/
|
|
320
|
+
if (sessionDataPayload?.session && options.session?.cookieCache?.enabled === true && disableCookieCache !== true) {
|
|
321
|
+
const { session: session$1 } = sessionDataPayload;
|
|
322
|
+
if (!(session$1.session.createdAt instanceof Date) || !(session$1.session.updatedAt instanceof Date) || !(session$1.session.expiresAt instanceof Date) || !(session$1.user.createdAt instanceof Date) || !(session$1.user.updatedAt instanceof Date)) console.warn("not date ln 122");
|
|
323
|
+
if (!(sessionDataPayload.expiresAt < Date.now() || session$1.session.expiresAt < /* @__PURE__ */ new Date())) {
|
|
324
|
+
ctx.set("session", session$1);
|
|
325
|
+
return ctx.render(session$1, 200);
|
|
326
|
+
}
|
|
327
|
+
(0, require_cookies.cookies_exports.deleteCookie)(ctx, context.authCookies.sessionData.name, context.authCookies.sessionData.options);
|
|
328
|
+
}
|
|
329
|
+
const session = await context.internalAdapter.findSession(sessionCookieToken);
|
|
330
|
+
ctx.set("session", session);
|
|
331
|
+
if (!session || session.session.expiresAt < /* @__PURE__ */ new Date()) {
|
|
332
|
+
require_cookies.deleteSessionCookie(ctx);
|
|
333
|
+
if (session) {
|
|
334
|
+
await context.internalAdapter.deleteSession(session.session.token);
|
|
335
|
+
return ctx.render({
|
|
336
|
+
success: __faire_auth_core_static.False,
|
|
337
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.SESSION_EXPIRED
|
|
338
|
+
}, 401);
|
|
339
|
+
}
|
|
340
|
+
return ctx.render({
|
|
341
|
+
success: __faire_auth_core_static.False,
|
|
342
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
343
|
+
}, 401);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* We don't need to update the session if the user doesn't want to be remembered
|
|
347
|
+
* or if the session refresh is disabled
|
|
348
|
+
*/
|
|
349
|
+
if (dontRememberMe != null && dontRememberMe !== false || disableRefresh === true) return ctx.render(session, 200);
|
|
350
|
+
const { expiresIn, updateAge } = context.sessionConfig;
|
|
351
|
+
if (session.session.expiresAt.valueOf() - expiresIn * 1e3 + updateAge * 1e3 <= Date.now() && !options.session?.disableSessionRefresh) {
|
|
352
|
+
const updatedSession = await context.internalAdapter.updateSession(session.session.token, {
|
|
353
|
+
expiresAt: (0, __faire_auth_core_utils.getDate)(context.sessionConfig.expiresIn, "sec"),
|
|
354
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
355
|
+
});
|
|
356
|
+
if (updatedSession == null) {
|
|
357
|
+
/**
|
|
358
|
+
* Handle case where session update fails (e.g., concurrent deletion)
|
|
359
|
+
*/
|
|
360
|
+
require_cookies.deleteSessionCookie(ctx);
|
|
361
|
+
return ctx.render({
|
|
362
|
+
success: __faire_auth_core_static.False,
|
|
363
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_CREATE_SESSION
|
|
364
|
+
}, 401);
|
|
365
|
+
}
|
|
366
|
+
const maxAge = (updatedSession.expiresAt.valueOf() - Date.now()) / 1e3;
|
|
367
|
+
await require_cookies.setSessionCookie(ctx, options, {
|
|
368
|
+
session: updatedSession,
|
|
369
|
+
user: session.user
|
|
370
|
+
}, false, { maxAge });
|
|
371
|
+
if (!(updatedSession.createdAt instanceof Date) || !(updatedSession.updatedAt instanceof Date) || !(updatedSession.expiresAt instanceof Date) || !(session.user.createdAt instanceof Date) || !(session.user.updatedAt instanceof Date)) console.warn("not date ln 220");
|
|
372
|
+
return ctx.render({
|
|
373
|
+
session: updatedSession,
|
|
374
|
+
user: session.user
|
|
375
|
+
}, 200);
|
|
376
|
+
}
|
|
377
|
+
if (options.session?.cookieCache?.enabled === true) await require_cookies.setCookieCache(ctx, options, session, dontRememberMe);
|
|
378
|
+
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 231");
|
|
379
|
+
return ctx.render(session, 200);
|
|
380
|
+
} catch (error) {
|
|
381
|
+
context.logger.error("INTERNAL_SERVER_ERROR", error);
|
|
382
|
+
return ctx.render({
|
|
383
|
+
success: __faire_auth_core_static.False,
|
|
384
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
385
|
+
}, 500);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
const getSessionFromCtx = async (ctx, config) => {
|
|
389
|
+
const session = ctx.get("session");
|
|
390
|
+
if (session) return session;
|
|
391
|
+
const newSession = await ctx.get("api").getSession({ query: { ...config && config } }, ctx).then(async (s) => s.success === true ? {
|
|
392
|
+
success: true,
|
|
393
|
+
data: {
|
|
394
|
+
session: __faire_auth_core_db.looseSessionSchema.parse(s.data.session),
|
|
395
|
+
user: __faire_auth_core_db.looseUserSchema.parse(s.data.user)
|
|
396
|
+
}
|
|
397
|
+
} : s);
|
|
398
|
+
if (newSession.success === false) return ctx.render(session ?? {
|
|
399
|
+
success: __faire_auth_core_static.False,
|
|
400
|
+
message: __faire_auth_core_error.BASE_ERROR_CODES.FAILED_TO_GET_SESSION
|
|
401
|
+
}, 401);
|
|
402
|
+
ctx.set("session", newSession.data);
|
|
403
|
+
return newSession.data;
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* The middleware forces the endpoint to require a valid session.
|
|
407
|
+
*/
|
|
408
|
+
const sessionMiddleware = () => require_middleware.createMiddleware()(async (ctx, next) => {
|
|
409
|
+
const session = await getSessionFromCtx(ctx);
|
|
410
|
+
if (session instanceof Response) return session;
|
|
411
|
+
return await next();
|
|
412
|
+
});
|
|
413
|
+
/**
|
|
414
|
+
* This middleware forces the endpoint to require a valid session and ignores cookie cache.
|
|
415
|
+
* This should be used for sensitive operations like password changes, account deletion, etc.
|
|
416
|
+
* to ensure that revoked sessions cannot be used even if they're still cached in cookies.
|
|
417
|
+
*/
|
|
418
|
+
const sensitiveSessionMiddleware = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
419
|
+
const session = await getSessionFromCtx(ctx, { disableCookieCache: true });
|
|
420
|
+
if (session instanceof Response) return session;
|
|
421
|
+
return await next();
|
|
422
|
+
});
|
|
423
|
+
/**
|
|
424
|
+
* This middleware allows you to call the endpoint on the client if session is valid.
|
|
425
|
+
* However, if called on the server, no session is required.
|
|
426
|
+
*/
|
|
427
|
+
const requestOnlySessionMiddleware = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
428
|
+
const session = await getSessionFromCtx(ctx);
|
|
429
|
+
if (session instanceof Response && ctx.get("isServer") !== true) return session;
|
|
430
|
+
return await next();
|
|
431
|
+
});
|
|
432
|
+
/**
|
|
433
|
+
* This middleware forces the endpoint to require a valid session,
|
|
434
|
+
* as well as making sure the session is fresh before proceeding.
|
|
435
|
+
*
|
|
436
|
+
* Session freshness check will be skipped if the session config's freshAge
|
|
437
|
+
* is set to 0
|
|
438
|
+
*/
|
|
439
|
+
const freshSessionMiddleware = require_middleware.createMiddleware()(async (ctx, next) => {
|
|
440
|
+
const session = await getSessionFromCtx(ctx);
|
|
441
|
+
if (session instanceof Response) return session;
|
|
442
|
+
const context = ctx.get("context");
|
|
443
|
+
if (context.sessionConfig.freshAge === 0) return await next();
|
|
444
|
+
const lastUpdated = (session.session.updatedAt ?? session.session.createdAt).valueOf();
|
|
445
|
+
if (!(Date.now() - lastUpdated < context.sessionConfig.freshAge * 1e3)) return ctx.render({
|
|
446
|
+
success: __faire_auth_core_static.False,
|
|
447
|
+
message: "Session is not fresh"
|
|
448
|
+
}, 403);
|
|
449
|
+
return await next();
|
|
450
|
+
});
|
|
451
|
+
const listSessionsRoute = (0, __faire_auth_core_factory.createRoute)({
|
|
452
|
+
operationId: __faire_auth_core_static.Routes.LIST_SESSIONS,
|
|
453
|
+
method: "get",
|
|
454
|
+
path: "/list-sessions",
|
|
455
|
+
description: "List all active sessions for the user",
|
|
456
|
+
middleware: [sessionMiddleware()],
|
|
457
|
+
responses: (0, __faire_auth_core_factory.res)(__faire_auth_core_static.SCHEMAS[__faire_auth_core_static.Definitions.SESSIONS_LIST].default).err(500).bld()
|
|
458
|
+
});
|
|
459
|
+
const listSessions = createEndpoint(listSessionsRoute, (_options) => async (ctx) => {
|
|
460
|
+
try {
|
|
461
|
+
const activeSessions = (await ctx.get("context").internalAdapter.listSessions(ctx.get("session").user.id)).filter((s) => s.expiresAt > /* @__PURE__ */ new Date());
|
|
462
|
+
return ctx.render(activeSessions, 200);
|
|
463
|
+
} catch (e) {
|
|
464
|
+
ctx.get("context").logger.error(e instanceof Error ? e.message : String(e), e);
|
|
465
|
+
return ctx.render({
|
|
466
|
+
success: __faire_auth_core_static.False,
|
|
467
|
+
message: "Internal server error"
|
|
468
|
+
}, 500);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
const revokeSessionRoute = (0, __faire_auth_core_factory.createRoute)({
|
|
472
|
+
operationId: __faire_auth_core_static.Routes.REVOKE_SESSION,
|
|
473
|
+
method: "post",
|
|
474
|
+
path: "/revoke-session",
|
|
475
|
+
description: "Revoke a single session",
|
|
476
|
+
middleware: [sensitiveSessionMiddleware],
|
|
477
|
+
request: (0, __faire_auth_core_factory.req)().bdy(revokeSessionSchema).bld(),
|
|
478
|
+
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()
|
|
479
|
+
});
|
|
480
|
+
const revokeSession = createEndpoint(revokeSessionRoute, (_options) => async (ctx) => {
|
|
481
|
+
const context = ctx.get("context");
|
|
482
|
+
const session = ctx.get("session");
|
|
483
|
+
const { token } = ctx.req.valid("json");
|
|
484
|
+
const foundSession = await context.internalAdapter.findSession(token);
|
|
485
|
+
if (!foundSession) return ctx.render({
|
|
486
|
+
success: __faire_auth_core_static.False,
|
|
487
|
+
message: "Session not found"
|
|
488
|
+
}, 400);
|
|
489
|
+
if (foundSession.session.userId !== session.user.id) return ctx.render({ success: __faire_auth_core_static.False }, 401);
|
|
490
|
+
try {
|
|
491
|
+
await context.internalAdapter.deleteSession(token);
|
|
492
|
+
} catch (error) {
|
|
493
|
+
context.logger.error(error != null && typeof error === "object" && "name" in error ? String(error.name) : "Unknown Error", error);
|
|
494
|
+
return ctx.render({
|
|
495
|
+
success: __faire_auth_core_static.False,
|
|
496
|
+
message: "Internal server error"
|
|
497
|
+
}, 500);
|
|
498
|
+
}
|
|
499
|
+
return ctx.render({ success: __faire_auth_core_static.True }, 200);
|
|
500
|
+
});
|
|
501
|
+
const revokeSessionsRoute = (0, __faire_auth_core_factory.createRoute)({
|
|
502
|
+
operationId: __faire_auth_core_static.Routes.REVOKE_SESSIONS,
|
|
503
|
+
method: "post",
|
|
504
|
+
path: "/revoke-sessions",
|
|
505
|
+
description: "Revoke all sessions for the user",
|
|
506
|
+
middleware: [sensitiveSessionMiddleware],
|
|
507
|
+
responses: (0, __faire_auth_core_factory.res)(__faire_auth_core_static.SCHEMAS[__faire_auth_core_static.Definitions.SUCCESS].default).err(500).bld()
|
|
508
|
+
});
|
|
509
|
+
const revokeSessions = createEndpoint(revokeSessionsRoute, (_options) => async (ctx) => {
|
|
510
|
+
const context = ctx.get("context");
|
|
511
|
+
const session = ctx.get("session");
|
|
512
|
+
try {
|
|
513
|
+
await context.internalAdapter.deleteSessions(session.user.id);
|
|
514
|
+
} catch (error) {
|
|
515
|
+
context.logger.error(error != null && typeof error === "object" && "name" in error ? String(error.name) : "Unknown Error", error);
|
|
516
|
+
return ctx.render({
|
|
517
|
+
success: __faire_auth_core_static.False,
|
|
518
|
+
message: "Internal server error"
|
|
519
|
+
}, 500);
|
|
520
|
+
}
|
|
521
|
+
return ctx.render({ success: __faire_auth_core_static.True }, 200);
|
|
522
|
+
});
|
|
523
|
+
const revokeOtherSessionsRoute = (0, __faire_auth_core_factory.createRoute)({
|
|
524
|
+
operationId: __faire_auth_core_static.Routes.REVOKE_OTHER_SESSIONS,
|
|
525
|
+
method: "post",
|
|
526
|
+
path: "/revoke-other-sessions",
|
|
527
|
+
description: "Revoke all other sessions for the user except the current one",
|
|
528
|
+
middleware: [sensitiveSessionMiddleware],
|
|
529
|
+
responses: (0, __faire_auth_core_factory.res)(__faire_auth_core_static.SCHEMAS[__faire_auth_core_static.Definitions.SUCCESS].default).bld()
|
|
530
|
+
});
|
|
531
|
+
const revokeOtherSessions = createEndpoint(revokeOtherSessionsRoute, (_options) => async (ctx) => {
|
|
532
|
+
const context = ctx.get("context");
|
|
533
|
+
const session = ctx.get("session");
|
|
534
|
+
const otherSessions = (await context.internalAdapter.listSessions(session.user.id)).filter((session$1) => session$1.expiresAt > /* @__PURE__ */ new Date()).filter((sess) => sess.token !== session.session.token);
|
|
535
|
+
await Promise.all(otherSessions.map(async (session$1) => context.internalAdapter.deleteSession(session$1.token)));
|
|
536
|
+
return ctx.render({ success: __faire_auth_core_static.True }, 200);
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
//#endregion
|
|
540
|
+
Object.defineProperty(exports, 'createAPI', {
|
|
541
|
+
enumerable: true,
|
|
542
|
+
get: function () {
|
|
543
|
+
return createAPI;
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
Object.defineProperty(exports, 'createEndpoint', {
|
|
547
|
+
enumerable: true,
|
|
548
|
+
get: function () {
|
|
549
|
+
return createEndpoint;
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
Object.defineProperty(exports, 'freshSessionMiddleware', {
|
|
553
|
+
enumerable: true,
|
|
554
|
+
get: function () {
|
|
555
|
+
return freshSessionMiddleware;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
Object.defineProperty(exports, 'getSession', {
|
|
559
|
+
enumerable: true,
|
|
560
|
+
get: function () {
|
|
561
|
+
return getSession;
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
Object.defineProperty(exports, 'getSessionFromCtx', {
|
|
565
|
+
enumerable: true,
|
|
566
|
+
get: function () {
|
|
567
|
+
return getSessionFromCtx;
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
Object.defineProperty(exports, 'initContextMiddleware', {
|
|
571
|
+
enumerable: true,
|
|
572
|
+
get: function () {
|
|
573
|
+
return initContextMiddleware;
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
Object.defineProperty(exports, 'initErrorHandler', {
|
|
577
|
+
enumerable: true,
|
|
578
|
+
get: function () {
|
|
579
|
+
return initErrorHandler;
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
Object.defineProperty(exports, 'initHooksMiddleware', {
|
|
583
|
+
enumerable: true,
|
|
584
|
+
get: function () {
|
|
585
|
+
return initHooksMiddleware;
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
Object.defineProperty(exports, 'listSessions', {
|
|
589
|
+
enumerable: true,
|
|
590
|
+
get: function () {
|
|
591
|
+
return listSessions;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
Object.defineProperty(exports, 'requestOnlySessionMiddleware', {
|
|
595
|
+
enumerable: true,
|
|
596
|
+
get: function () {
|
|
597
|
+
return requestOnlySessionMiddleware;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
Object.defineProperty(exports, 'revokeOtherSessions', {
|
|
601
|
+
enumerable: true,
|
|
602
|
+
get: function () {
|
|
603
|
+
return revokeOtherSessions;
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
Object.defineProperty(exports, 'revokeSession', {
|
|
607
|
+
enumerable: true,
|
|
608
|
+
get: function () {
|
|
609
|
+
return revokeSession;
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
Object.defineProperty(exports, 'revokeSessions', {
|
|
613
|
+
enumerable: true,
|
|
614
|
+
get: function () {
|
|
615
|
+
return revokeSessions;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
Object.defineProperty(exports, 'sensitiveSessionMiddleware', {
|
|
619
|
+
enumerable: true,
|
|
620
|
+
get: function () {
|
|
621
|
+
return sensitiveSessionMiddleware;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
Object.defineProperty(exports, 'sessionMiddleware', {
|
|
625
|
+
enumerable: true,
|
|
626
|
+
get: function () {
|
|
627
|
+
return sessionMiddleware;
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
Object.defineProperty(exports, 'setDefaultExecutionCtx', {
|
|
631
|
+
enumerable: true,
|
|
632
|
+
get: function () {
|
|
633
|
+
return setDefaultExecutionCtx;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
Object.defineProperty(exports, 'setRenderer', {
|
|
637
|
+
enumerable: true,
|
|
638
|
+
get: function () {
|
|
639
|
+
return setRenderer;
|
|
640
|
+
}
|
|
641
|
+
});
|