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,37 @@
|
|
|
1
|
+
require('../crypto-CcTxYH82.cjs');
|
|
2
|
+
require('../json-CcJ2HjGo.cjs');
|
|
3
|
+
const require_cookies = require('../cookies-B5xeA6i8.cjs');
|
|
4
|
+
const require_middleware = require('../middleware-CWvRH4EW.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/react-start.ts
|
|
7
|
+
const reactStartCookies = () => {
|
|
8
|
+
return {
|
|
9
|
+
id: "react-start-cookies",
|
|
10
|
+
hooks: { after: [{
|
|
11
|
+
matcher: (_ctx) => true,
|
|
12
|
+
handler: (_authOptions) => require_middleware.createHook()(async (ctx) => {
|
|
13
|
+
const setCookies = ctx.res.headers.getSetCookie();
|
|
14
|
+
if (!setCookies.length) return;
|
|
15
|
+
const parsed = require_cookies.parseSetCookieHeader(setCookies);
|
|
16
|
+
const { setCookie } = await import("@tanstack/start-server-core");
|
|
17
|
+
parsed.forEach((value, key) => {
|
|
18
|
+
if (!key) return;
|
|
19
|
+
const opts = {
|
|
20
|
+
sameSite: value.samesite,
|
|
21
|
+
secure: value.secure,
|
|
22
|
+
maxAge: value["max-age"],
|
|
23
|
+
httpOnly: value.httponly,
|
|
24
|
+
domain: value.domain,
|
|
25
|
+
path: value.path
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
setCookie(key, decodeURIComponent(value.value), opts);
|
|
29
|
+
} catch (e) {}
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
}] }
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.reactStartCookies = reactStartCookies;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../index-B-WeOMzg.cjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DOM31WQz.cjs";
|
|
3
|
+
import * as _faire_auth_core_types44 from "@faire-auth/core/types";
|
|
4
|
+
import * as hono68 from "hono";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/react-start.d.ts
|
|
7
|
+
declare const reactStartCookies: () => {
|
|
8
|
+
id: "react-start-cookies";
|
|
9
|
+
hooks: {
|
|
10
|
+
after: {
|
|
11
|
+
matcher: (_ctx: hono68.Context<ContextVars<any>, any, {}>) => true;
|
|
12
|
+
handler: (_authOptions: _faire_auth_core_types44.FaireAuthOptions<any>) => (ctx: hono68.Context<ContextVars<object>, string, {}>) => Promise<void>;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { reactStartCookies };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../index-jlessPI0.mjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DuE14mmj.mjs";
|
|
3
|
+
import * as hono33 from "hono";
|
|
4
|
+
import * as _faire_auth_core_types31 from "@faire-auth/core/types";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/react-start.d.ts
|
|
7
|
+
declare const reactStartCookies: () => {
|
|
8
|
+
id: "react-start-cookies";
|
|
9
|
+
hooks: {
|
|
10
|
+
after: {
|
|
11
|
+
matcher: (_ctx: hono33.Context<ContextVars<any>, any, {}>) => true;
|
|
12
|
+
handler: (_authOptions: _faire_auth_core_types31.FaireAuthOptions<any>) => (ctx: hono33.Context<ContextVars<object>, string, {}>) => Promise<void>;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { reactStartCookies };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "../crypto-CyQRFtkq.mjs";
|
|
2
|
+
import "../json-B1v2qRTQ.mjs";
|
|
3
|
+
import { p as parseSetCookieHeader } from "../cookies-Ch1JfQIz.mjs";
|
|
4
|
+
import { n as createHook } from "../middleware-CE6OhDkq.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/react-start.ts
|
|
7
|
+
const reactStartCookies = () => {
|
|
8
|
+
return {
|
|
9
|
+
id: "react-start-cookies",
|
|
10
|
+
hooks: { after: [{
|
|
11
|
+
matcher: (_ctx) => true,
|
|
12
|
+
handler: (_authOptions) => createHook()(async (ctx) => {
|
|
13
|
+
const setCookies = ctx.res.headers.getSetCookie();
|
|
14
|
+
if (!setCookies.length) return;
|
|
15
|
+
const parsed = parseSetCookieHeader(setCookies);
|
|
16
|
+
const { setCookie } = await import("@tanstack/start-server-core");
|
|
17
|
+
parsed.forEach((value, key) => {
|
|
18
|
+
if (!key) return;
|
|
19
|
+
const opts = {
|
|
20
|
+
sameSite: value.samesite,
|
|
21
|
+
secure: value.secure,
|
|
22
|
+
maxAge: value["max-age"],
|
|
23
|
+
httpOnly: value.httponly,
|
|
24
|
+
domain: value.domain,
|
|
25
|
+
path: value.path
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
setCookie(key, decodeURIComponent(value.value), opts);
|
|
29
|
+
} catch (e) {}
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
}] }
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { reactStartCookies };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/integrations/solid-start.ts
|
|
3
|
+
function toSolidStartHandler(auth) {
|
|
4
|
+
const handler = async (event) => {
|
|
5
|
+
return "handler" in auth ? auth.handler(event.request) : auth(event.request);
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
GET: handler,
|
|
9
|
+
POST: handler
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.toSolidStartHandler = toSolidStartHandler;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/integrations/solid-start.d.ts
|
|
2
|
+
declare function toSolidStartHandler(auth: {
|
|
3
|
+
handler: (request: Request) => Promise<Response>;
|
|
4
|
+
} | ((request: Request) => Promise<Response>)): {
|
|
5
|
+
GET: (event: {
|
|
6
|
+
request: Request;
|
|
7
|
+
}) => Promise<Response>;
|
|
8
|
+
POST: (event: {
|
|
9
|
+
request: Request;
|
|
10
|
+
}) => Promise<Response>;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { toSolidStartHandler };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/integrations/solid-start.d.ts
|
|
2
|
+
declare function toSolidStartHandler(auth: {
|
|
3
|
+
handler: (request: Request) => Promise<Response>;
|
|
4
|
+
} | ((request: Request) => Promise<Response>)): {
|
|
5
|
+
GET: (event: {
|
|
6
|
+
request: Request;
|
|
7
|
+
}) => Promise<Response>;
|
|
8
|
+
POST: (event: {
|
|
9
|
+
request: Request;
|
|
10
|
+
}) => Promise<Response>;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { toSolidStartHandler };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/integrations/solid-start.ts
|
|
2
|
+
function toSolidStartHandler(auth) {
|
|
3
|
+
const handler = async (event) => {
|
|
4
|
+
return "handler" in auth ? auth.handler(event.request) : auth(event.request);
|
|
5
|
+
};
|
|
6
|
+
return {
|
|
7
|
+
GET: handler,
|
|
8
|
+
POST: handler
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { toSolidStartHandler };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require('../crypto-CcTxYH82.cjs');
|
|
2
|
+
require('../json-CcJ2HjGo.cjs');
|
|
3
|
+
const require_cookies = require('../cookies-B5xeA6i8.cjs');
|
|
4
|
+
const require_middleware = require('../middleware-CWvRH4EW.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/svelte-kit.ts
|
|
7
|
+
const toSvelteKitHandler = (auth) => (event) => auth.handler(event.request);
|
|
8
|
+
const svelteKitHandler = async ({ auth, event, resolve, building }) => {
|
|
9
|
+
if (building) return resolve(event);
|
|
10
|
+
const { request, url } = event;
|
|
11
|
+
if (isAuthPath(url.toString(), auth.options)) return auth.handler(request);
|
|
12
|
+
return resolve(event);
|
|
13
|
+
};
|
|
14
|
+
function isAuthPath(url, options) {
|
|
15
|
+
const _url = new URL(url);
|
|
16
|
+
const baseURL = new URL(`${options.baseURL || _url.origin}${options.basePath || "/api/auth"}`);
|
|
17
|
+
if (_url.origin !== baseURL.origin) return false;
|
|
18
|
+
if (!_url.pathname.startsWith(baseURL.pathname.endsWith("/") ? baseURL.pathname : `${baseURL.pathname}/`)) return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const sveltekitCookies = (getRequestEvent) => {
|
|
22
|
+
return {
|
|
23
|
+
id: "sveltekit-cookies",
|
|
24
|
+
hooks: { after: [{
|
|
25
|
+
matcher: (_ctx) => true,
|
|
26
|
+
handler: (_authOptions) => require_middleware.createHook()(async (ctx) => {
|
|
27
|
+
const setCookies = ctx.res.headers.getSetCookie();
|
|
28
|
+
if (!setCookies.length) return;
|
|
29
|
+
const event = getRequestEvent();
|
|
30
|
+
if (!event) return;
|
|
31
|
+
const parsed = require_cookies.parseSetCookieHeader(setCookies);
|
|
32
|
+
for (const [name, { value,...ops }] of parsed) try {
|
|
33
|
+
event.cookies.set(name, decodeURIComponent(value), {
|
|
34
|
+
sameSite: ops.samesite,
|
|
35
|
+
path: ops.path || "/",
|
|
36
|
+
expires: ops.expires,
|
|
37
|
+
secure: ops.secure,
|
|
38
|
+
httpOnly: ops.httponly,
|
|
39
|
+
domain: ops.domain,
|
|
40
|
+
maxAge: ops["max-age"]
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {}
|
|
43
|
+
})
|
|
44
|
+
}] }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.isAuthPath = isAuthPath;
|
|
50
|
+
exports.svelteKitHandler = svelteKitHandler;
|
|
51
|
+
exports.sveltekitCookies = sveltekitCookies;
|
|
52
|
+
exports.toSvelteKitHandler = toSvelteKitHandler;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1 } from "../index-B-WeOMzg.cjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DOM31WQz.cjs";
|
|
3
|
+
import * as _faire_auth_core_types31 from "@faire-auth/core/types";
|
|
4
|
+
import * as hono31 from "hono";
|
|
5
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
6
|
+
|
|
7
|
+
//#region src/integrations/svelte-kit.d.ts
|
|
8
|
+
declare const toSvelteKitHandler: (auth: {
|
|
9
|
+
handler: (request: Request) => any;
|
|
10
|
+
options: FaireAuthOptions$1;
|
|
11
|
+
}) => (event: {
|
|
12
|
+
request: Request;
|
|
13
|
+
}) => any;
|
|
14
|
+
declare const svelteKitHandler: ({
|
|
15
|
+
auth,
|
|
16
|
+
event,
|
|
17
|
+
resolve,
|
|
18
|
+
building
|
|
19
|
+
}: {
|
|
20
|
+
auth: {
|
|
21
|
+
handler: (request: Request) => any;
|
|
22
|
+
options: FaireAuthOptions$1;
|
|
23
|
+
};
|
|
24
|
+
event: {
|
|
25
|
+
request: Request;
|
|
26
|
+
url: URL;
|
|
27
|
+
};
|
|
28
|
+
resolve: (event: any) => any;
|
|
29
|
+
building: boolean;
|
|
30
|
+
}) => Promise<any>;
|
|
31
|
+
declare function isAuthPath(url: string, options: FaireAuthOptions$1): boolean;
|
|
32
|
+
declare const sveltekitCookies: (getRequestEvent: () => RequestEvent<Record<string, string>, string | null>) => {
|
|
33
|
+
id: "sveltekit-cookies";
|
|
34
|
+
hooks: {
|
|
35
|
+
after: {
|
|
36
|
+
matcher: (_ctx: hono31.Context<ContextVars<any>, any, {}>) => true;
|
|
37
|
+
handler: (_authOptions: _faire_auth_core_types31.FaireAuthOptions<any>) => (ctx: hono31.Context<ContextVars<object>, string, {}>) => Promise<void>;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { isAuthPath, svelteKitHandler, sveltekitCookies, toSvelteKitHandler };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1 } from "../index-jlessPI0.mjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DuE14mmj.mjs";
|
|
3
|
+
import * as hono31 from "hono";
|
|
4
|
+
import * as _faire_auth_core_types30 from "@faire-auth/core/types";
|
|
5
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
6
|
+
|
|
7
|
+
//#region src/integrations/svelte-kit.d.ts
|
|
8
|
+
declare const toSvelteKitHandler: (auth: {
|
|
9
|
+
handler: (request: Request) => any;
|
|
10
|
+
options: FaireAuthOptions$1;
|
|
11
|
+
}) => (event: {
|
|
12
|
+
request: Request;
|
|
13
|
+
}) => any;
|
|
14
|
+
declare const svelteKitHandler: ({
|
|
15
|
+
auth,
|
|
16
|
+
event,
|
|
17
|
+
resolve,
|
|
18
|
+
building
|
|
19
|
+
}: {
|
|
20
|
+
auth: {
|
|
21
|
+
handler: (request: Request) => any;
|
|
22
|
+
options: FaireAuthOptions$1;
|
|
23
|
+
};
|
|
24
|
+
event: {
|
|
25
|
+
request: Request;
|
|
26
|
+
url: URL;
|
|
27
|
+
};
|
|
28
|
+
resolve: (event: any) => any;
|
|
29
|
+
building: boolean;
|
|
30
|
+
}) => Promise<any>;
|
|
31
|
+
declare function isAuthPath(url: string, options: FaireAuthOptions$1): boolean;
|
|
32
|
+
declare const sveltekitCookies: (getRequestEvent: () => RequestEvent<Record<string, string>, string | null>) => {
|
|
33
|
+
id: "sveltekit-cookies";
|
|
34
|
+
hooks: {
|
|
35
|
+
after: {
|
|
36
|
+
matcher: (_ctx: hono31.Context<ContextVars<any>, any, {}>) => true;
|
|
37
|
+
handler: (_authOptions: _faire_auth_core_types30.FaireAuthOptions<any>) => (ctx: hono31.Context<ContextVars<object>, string, {}>) => Promise<void>;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { isAuthPath, svelteKitHandler, sveltekitCookies, toSvelteKitHandler };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "../crypto-CyQRFtkq.mjs";
|
|
2
|
+
import "../json-B1v2qRTQ.mjs";
|
|
3
|
+
import { p as parseSetCookieHeader } from "../cookies-Ch1JfQIz.mjs";
|
|
4
|
+
import { n as createHook } from "../middleware-CE6OhDkq.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/integrations/svelte-kit.ts
|
|
7
|
+
const toSvelteKitHandler = (auth) => (event) => auth.handler(event.request);
|
|
8
|
+
const svelteKitHandler = async ({ auth, event, resolve, building }) => {
|
|
9
|
+
if (building) return resolve(event);
|
|
10
|
+
const { request, url } = event;
|
|
11
|
+
if (isAuthPath(url.toString(), auth.options)) return auth.handler(request);
|
|
12
|
+
return resolve(event);
|
|
13
|
+
};
|
|
14
|
+
function isAuthPath(url, options) {
|
|
15
|
+
const _url = new URL(url);
|
|
16
|
+
const baseURL = new URL(`${options.baseURL || _url.origin}${options.basePath || "/api/auth"}`);
|
|
17
|
+
if (_url.origin !== baseURL.origin) return false;
|
|
18
|
+
if (!_url.pathname.startsWith(baseURL.pathname.endsWith("/") ? baseURL.pathname : `${baseURL.pathname}/`)) return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const sveltekitCookies = (getRequestEvent) => {
|
|
22
|
+
return {
|
|
23
|
+
id: "sveltekit-cookies",
|
|
24
|
+
hooks: { after: [{
|
|
25
|
+
matcher: (_ctx) => true,
|
|
26
|
+
handler: (_authOptions) => createHook()(async (ctx) => {
|
|
27
|
+
const setCookies = ctx.res.headers.getSetCookie();
|
|
28
|
+
if (!setCookies.length) return;
|
|
29
|
+
const event = getRequestEvent();
|
|
30
|
+
if (!event) return;
|
|
31
|
+
const parsed = parseSetCookieHeader(setCookies);
|
|
32
|
+
for (const [name, { value,...ops }] of parsed) try {
|
|
33
|
+
event.cookies.set(name, decodeURIComponent(value), {
|
|
34
|
+
sameSite: ops.samesite,
|
|
35
|
+
path: ops.path || "/",
|
|
36
|
+
expires: ops.expires,
|
|
37
|
+
secure: ops.secure,
|
|
38
|
+
httpOnly: ops.httponly,
|
|
39
|
+
domain: ops.domain,
|
|
40
|
+
maxAge: ops["max-age"]
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {}
|
|
43
|
+
})
|
|
44
|
+
}] }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { isAuthPath, svelteKitHandler, sveltekitCookies, toSvelteKitHandler };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-oakRccI5.cjs');
|
|
2
|
+
const require_hono = require('./hono-Cdukwu5K.cjs');
|
|
3
|
+
let node_async_hooks = require("node:async_hooks");
|
|
4
|
+
let __faire_auth_core_env = require("@faire-auth/core/env");
|
|
5
|
+
|
|
6
|
+
//#region src/context/transaction.ts
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const currentAdapterAsyncStorage = new node_async_hooks.AsyncLocalStorage();
|
|
11
|
+
const getCurrentAdapter = (adapter) => currentAdapterAsyncStorage.getStore() ?? adapter ?? require_hono.getContext().get("context").adapter;
|
|
12
|
+
const runWithTransaction = (adapter, fn) => adapter.transaction((trx) => currentAdapterAsyncStorage.run(trx, fn));
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/utils/ip.ts
|
|
16
|
+
const isValidIP = (ip) => {
|
|
17
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) return ip.split(".").map(Number).every((part) => part >= 0 && part <= 255);
|
|
18
|
+
return /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(ip);
|
|
19
|
+
};
|
|
20
|
+
const getIp = (req, options) => {
|
|
21
|
+
if (options.advanced?.ipAddress?.disableIpTracking === true) return null;
|
|
22
|
+
const testIP = "127.0.0.1";
|
|
23
|
+
if ((0, __faire_auth_core_env.isTest)()) return testIP;
|
|
24
|
+
const headers = "raw" in req && "headers" in req.raw ? req.raw.headers : req;
|
|
25
|
+
const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders ?? ["x-forwarded-for"];
|
|
26
|
+
for (const key of ipHeaders) {
|
|
27
|
+
const value = "get" in headers ? headers.get(key) : headers[key];
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
const ip = value.split(",")[0]?.trim();
|
|
30
|
+
if (ip != null && isValidIP(ip)) return ip;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
Object.defineProperty(exports, 'getCurrentAdapter', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return getCurrentAdapter;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, 'getIp', {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return getIp;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, 'runWithTransaction', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return runWithTransaction;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { n as getContext } from "./hono-CoKYWnXA.mjs";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
import { isTest } from "@faire-auth/core/env";
|
|
4
|
+
|
|
5
|
+
//#region src/context/transaction.ts
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
const currentAdapterAsyncStorage = new AsyncLocalStorage();
|
|
10
|
+
const getCurrentAdapter = (adapter) => currentAdapterAsyncStorage.getStore() ?? adapter ?? getContext().get("context").adapter;
|
|
11
|
+
const runWithTransaction = (adapter, fn) => adapter.transaction((trx) => currentAdapterAsyncStorage.run(trx, fn));
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/utils/ip.ts
|
|
15
|
+
const isValidIP = (ip) => {
|
|
16
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) return ip.split(".").map(Number).every((part) => part >= 0 && part <= 255);
|
|
17
|
+
return /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(ip);
|
|
18
|
+
};
|
|
19
|
+
const getIp = (req, options) => {
|
|
20
|
+
if (options.advanced?.ipAddress?.disableIpTracking === true) return null;
|
|
21
|
+
const testIP = "127.0.0.1";
|
|
22
|
+
if (isTest()) return testIP;
|
|
23
|
+
const headers = "raw" in req && "headers" in req.raw ? req.raw.headers : req;
|
|
24
|
+
const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders ?? ["x-forwarded-for"];
|
|
25
|
+
for (const key of ipHeaders) {
|
|
26
|
+
const value = "get" in headers ? headers.get(key) : headers[key];
|
|
27
|
+
if (typeof value === "string") {
|
|
28
|
+
const ip = value.split(",")[0]?.trim();
|
|
29
|
+
if (ip != null && isValidIP(ip)) return ip;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getCurrentAdapter as n, runWithTransaction as r, getIp as t };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { logger } from "@faire-auth/core/env";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/json.ts
|
|
4
|
+
function safeJSONParse(data) {
|
|
5
|
+
function reviver(_, value) {
|
|
6
|
+
if (typeof value === "string") {
|
|
7
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(value)) {
|
|
8
|
+
const date = new Date(value);
|
|
9
|
+
if (!isNaN(date.getTime())) return date;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
if (typeof data !== "string") return data;
|
|
16
|
+
return JSON.parse(data, reviver);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
logger.error("Error parsing JSON", { error: e });
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { safeJSONParse as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-oakRccI5.cjs');
|
|
2
|
+
let __faire_auth_core_env = require("@faire-auth/core/env");
|
|
3
|
+
|
|
4
|
+
//#region src/utils/json.ts
|
|
5
|
+
function safeJSONParse(data) {
|
|
6
|
+
function reviver(_, value) {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(value)) {
|
|
9
|
+
const date = new Date(value);
|
|
10
|
+
if (!isNaN(date.getTime())) return date;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
if (typeof data !== "string") return data;
|
|
17
|
+
return JSON.parse(data, reviver);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
__faire_auth_core_env.logger.error("Error parsing JSON", { error: e });
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
Object.defineProperty(exports, 'safeJSONParse', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return safeJSONParse;
|
|
29
|
+
}
|
|
30
|
+
});
|