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
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { $ as Client, Ct as InferPluginRateLimit, F as DTO, I as FaireAuthOptions, L as FaireAuthRateLimitOptions, P as CustomRules, Q as CamelCase, R as Hooks, St as InferPluginMiddleware, Z as AtomListener, _t as FaireAuthPlugin, a as InferPluginTypes, an as AuthContext, at as InferAdditionalAsClient, bt as InferPluginErrorCodes, c as Models, cn as Adapter, ct as InferPluginsFromClient, dn as DBAdapter, dt as IsSignal, et as ClientOptions, fn as DBAdapterInstance, ft as RevalidateOptions, gn as Where, gt as AuthPluginSchema, hn as TransactionAdapter, i as AdditionalUserFieldsOutput, it as InferActions, l as RateLimit, ln as AdapterInstance, lt as InferSessionFromClient, mn as DBTransactionAdapter, mt as Store, n as AdditionalSessionFieldsOutput, nn as AuthFactory, nt as FaireAuthClientPlugin, o as InferSession, on as init, ot as InferAdditionalFromClient, pn as DBAdapterSchemaCreation, pt as SessionQueryParams, r as AdditionalUserFieldsInput, rn as AuthProperties, rt as Inc, s as InferUser, st as InferErrorCodes, t as AdditionalSessionFieldsInput, tn as AuthEndpoint, tt as CreateSchemaType, un as AdapterSchemaCreation, ut as InferUserFromClient, vt as InferOptionSchema, xt as InferPluginHooks, yt as InferPluginDTO, z as Middleware } from "../index-B-WeOMzg.cjs";
|
|
2
|
+
import { n as Execute, r as ToExecFull, t as ContextVars } from "../hono-DOM31WQz.cjs";
|
|
3
|
+
export { Adapter, AdapterInstance, AdapterSchemaCreation, AdditionalSessionFieldsInput, AdditionalSessionFieldsOutput, AdditionalUserFieldsInput, AdditionalUserFieldsOutput, AtomListener, AuthContext, AuthEndpoint, AuthFactory, AuthPluginSchema, AuthProperties, CamelCase, Client, ClientOptions, ContextVars, CreateSchemaType, CustomRules, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, DTO, Execute, FaireAuthClientPlugin, FaireAuthOptions, FaireAuthPlugin, FaireAuthRateLimitOptions, Hooks, Inc, InferActions, InferAdditionalAsClient, InferAdditionalFromClient, InferErrorCodes, InferOptionSchema, InferPluginDTO, InferPluginErrorCodes, InferPluginHooks, InferPluginMiddleware, InferPluginRateLimit, InferPluginTypes, InferPluginsFromClient, InferSession, InferSessionFromClient, InferUser, InferUserFromClient, IsSignal, Middleware, Models, RateLimit, RevalidateOptions, SessionQueryParams, Store, ToExecFull, TransactionAdapter, Where, init };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { $ as Client, Ct as InferPluginRateLimit, F as DTO, I as FaireAuthOptions, L as FaireAuthRateLimitOptions, P as CustomRules, Q as CamelCase, R as Hooks, St as InferPluginMiddleware, Z as AtomListener, _t as FaireAuthPlugin, a as InferPluginTypes, an as AuthContext, at as InferAdditionalAsClient, bt as InferPluginErrorCodes, c as Models, cn as Adapter, ct as InferPluginsFromClient, dn as DBAdapter, dt as IsSignal, et as ClientOptions, fn as DBAdapterInstance, ft as RevalidateOptions, gn as Where, gt as AuthPluginSchema, hn as TransactionAdapter, i as AdditionalUserFieldsOutput, it as InferActions, l as RateLimit, ln as AdapterInstance, lt as InferSessionFromClient, mn as DBTransactionAdapter, mt as Store, n as AdditionalSessionFieldsOutput, nn as AuthFactory, nt as FaireAuthClientPlugin, o as InferSession, on as init, ot as InferAdditionalFromClient, pn as DBAdapterSchemaCreation, pt as SessionQueryParams, r as AdditionalUserFieldsInput, rn as AuthProperties, rt as Inc, s as InferUser, st as InferErrorCodes, t as AdditionalSessionFieldsInput, tn as AuthEndpoint, tt as CreateSchemaType, un as AdapterSchemaCreation, ut as InferUserFromClient, vt as InferOptionSchema, xt as InferPluginHooks, yt as InferPluginDTO, z as Middleware } from "../index-jlessPI0.mjs";
|
|
2
|
+
import { n as Execute, r as ToExecFull, t as ContextVars } from "../hono-DuE14mmj.mjs";
|
|
3
|
+
export { Adapter, AdapterInstance, AdapterSchemaCreation, AdditionalSessionFieldsInput, AdditionalSessionFieldsOutput, AdditionalUserFieldsInput, AdditionalUserFieldsOutput, AtomListener, AuthContext, AuthEndpoint, AuthFactory, AuthPluginSchema, AuthProperties, CamelCase, Client, ClientOptions, ContextVars, CreateSchemaType, CustomRules, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, DTO, Execute, FaireAuthClientPlugin, FaireAuthOptions, FaireAuthPlugin, FaireAuthRateLimitOptions, Hooks, Inc, InferActions, InferAdditionalAsClient, InferAdditionalFromClient, InferErrorCodes, InferOptionSchema, InferPluginDTO, InferPluginErrorCodes, InferPluginHooks, InferPluginMiddleware, InferPluginRateLimit, InferPluginTypes, InferPluginsFromClient, InferSession, InferSessionFromClient, InferUser, InferUserFromClient, IsSignal, Middleware, Models, RateLimit, RevalidateOptions, SessionQueryParams, Store, ToExecFull, TransactionAdapter, Where, init };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { env } from "@faire-auth/core/env";
|
|
2
|
+
import { FaireAuthError } from "@faire-auth/core/error";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/url.ts
|
|
5
|
+
const checkHasPath = (url) => {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(url).pathname !== "/";
|
|
8
|
+
} catch {
|
|
9
|
+
throw new FaireAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const withPath = (url, path = "/api/auth") => {
|
|
13
|
+
if (checkHasPath(url)) return url;
|
|
14
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
15
|
+
return `${url.replace(/\/+$/, "")}${path}`;
|
|
16
|
+
};
|
|
17
|
+
const getOrigin = (url) => {
|
|
18
|
+
try {
|
|
19
|
+
return new URL(url).origin;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const getProtocol = (url) => {
|
|
25
|
+
try {
|
|
26
|
+
return new URL(url).protocol;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getHost = (url) => {
|
|
32
|
+
try {
|
|
33
|
+
return new URL(url).host;
|
|
34
|
+
} catch {
|
|
35
|
+
return url;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const getBaseURLFromEnv = () => env["FAIRE_AUTH_URL"] ?? env["NEXT_PUBLIC_FAIRE_AUTH_URL"] ?? env["PUBLIC_FAIRE_AUTH_URL"] ?? env["NUXT_PUBLIC_FAIRE_AUTH_URL"] ?? env["NUXT_PUBLIC_AUTH_URL"] ?? (env["BASE_URL"] !== "/" ? env["BASE_URL"] : void 0);
|
|
39
|
+
const getBaseURL = (url, path, request) => {
|
|
40
|
+
if (url) return withPath(url, path);
|
|
41
|
+
const fromEnv = getBaseURLFromEnv();
|
|
42
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
43
|
+
if (request) {
|
|
44
|
+
const fromRequest = request.header("x-forwarded-host");
|
|
45
|
+
const fromRequestProto = request.header("x-forwarded-proto");
|
|
46
|
+
if (fromRequest != null && fromRequestProto != null) return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
47
|
+
const url$1 = getOrigin(request.url);
|
|
48
|
+
if (url$1 == null || url$1 === "") throw new FaireAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
49
|
+
return withPath(url$1, path);
|
|
50
|
+
}
|
|
51
|
+
if (typeof window !== "undefined" && window.location != null) return withPath(window.location.origin, path);
|
|
52
|
+
};
|
|
53
|
+
const getTrustedOrigins = (options, context, request) => {
|
|
54
|
+
const result = {
|
|
55
|
+
ready: false,
|
|
56
|
+
trustedOrigins: /* @__PURE__ */ new Set()
|
|
57
|
+
};
|
|
58
|
+
if (context?.trustedOrigins != null) if (!request) return {
|
|
59
|
+
ready: true,
|
|
60
|
+
trustedOrigins: context.trustedOrigins
|
|
61
|
+
};
|
|
62
|
+
else context.trustedOrigins.forEach((o) => result.trustedOrigins.add(o));
|
|
63
|
+
const checkFalsy = () => {
|
|
64
|
+
for (const o of result.trustedOrigins) if (!o) throw new FaireAuthError("A provided trusted origin is invalid, make sure your trusted origins list is properly defined.");
|
|
65
|
+
};
|
|
66
|
+
const optionsTrustedOrigins = options.trustedOrigins;
|
|
67
|
+
if (!context?.trustedOrigins) {
|
|
68
|
+
const baseURL = options.baseURL ?? context?.baseURL;
|
|
69
|
+
if (baseURL) result.trustedOrigins.add(new URL(baseURL).origin);
|
|
70
|
+
const envTrustedOrigins = process.env["FAIRE_AUTH_TRUSTED_ORIGINS"];
|
|
71
|
+
if (envTrustedOrigins != null) envTrustedOrigins.split(",").forEach((o) => result.trustedOrigins.add(o));
|
|
72
|
+
if (optionsTrustedOrigins && Array.isArray(optionsTrustedOrigins)) optionsTrustedOrigins.forEach((o) => result.trustedOrigins.add(o));
|
|
73
|
+
}
|
|
74
|
+
if (typeof optionsTrustedOrigins === "function" && request) result.dynamicPromise = (async () => {
|
|
75
|
+
const dynamic = await optionsTrustedOrigins(request);
|
|
76
|
+
if (dynamic) dynamic.forEach((o) => result.trustedOrigins.add(o));
|
|
77
|
+
checkFalsy();
|
|
78
|
+
result.ready = true;
|
|
79
|
+
})();
|
|
80
|
+
else {
|
|
81
|
+
checkFalsy();
|
|
82
|
+
result.ready = true;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { getTrustedOrigins as a, getProtocol as i, getHost as n, getOrigin as r, getBaseURL as t };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-oakRccI5.cjs');
|
|
2
|
+
let __faire_auth_core_env = require("@faire-auth/core/env");
|
|
3
|
+
let __faire_auth_core_error = require("@faire-auth/core/error");
|
|
4
|
+
|
|
5
|
+
//#region src/utils/url.ts
|
|
6
|
+
const checkHasPath = (url) => {
|
|
7
|
+
try {
|
|
8
|
+
return new URL(url).pathname !== "/";
|
|
9
|
+
} catch {
|
|
10
|
+
throw new __faire_auth_core_error.FaireAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const withPath = (url, path = "/api/auth") => {
|
|
14
|
+
if (checkHasPath(url)) return url;
|
|
15
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
16
|
+
return `${url.replace(/\/+$/, "")}${path}`;
|
|
17
|
+
};
|
|
18
|
+
const getOrigin = (url) => {
|
|
19
|
+
try {
|
|
20
|
+
return new URL(url).origin;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const getProtocol = (url) => {
|
|
26
|
+
try {
|
|
27
|
+
return new URL(url).protocol;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const getHost = (url) => {
|
|
33
|
+
try {
|
|
34
|
+
return new URL(url).host;
|
|
35
|
+
} catch {
|
|
36
|
+
return url;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const getBaseURLFromEnv = () => __faire_auth_core_env.env["FAIRE_AUTH_URL"] ?? __faire_auth_core_env.env["NEXT_PUBLIC_FAIRE_AUTH_URL"] ?? __faire_auth_core_env.env["PUBLIC_FAIRE_AUTH_URL"] ?? __faire_auth_core_env.env["NUXT_PUBLIC_FAIRE_AUTH_URL"] ?? __faire_auth_core_env.env["NUXT_PUBLIC_AUTH_URL"] ?? (__faire_auth_core_env.env["BASE_URL"] !== "/" ? __faire_auth_core_env.env["BASE_URL"] : void 0);
|
|
40
|
+
const getBaseURL = (url, path, request) => {
|
|
41
|
+
if (url) return withPath(url, path);
|
|
42
|
+
const fromEnv = getBaseURLFromEnv();
|
|
43
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
44
|
+
if (request) {
|
|
45
|
+
const fromRequest = request.header("x-forwarded-host");
|
|
46
|
+
const fromRequestProto = request.header("x-forwarded-proto");
|
|
47
|
+
if (fromRequest != null && fromRequestProto != null) return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
48
|
+
const url$1 = getOrigin(request.url);
|
|
49
|
+
if (url$1 == null || url$1 === "") throw new __faire_auth_core_error.FaireAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
50
|
+
return withPath(url$1, path);
|
|
51
|
+
}
|
|
52
|
+
if (typeof window !== "undefined" && window.location != null) return withPath(window.location.origin, path);
|
|
53
|
+
};
|
|
54
|
+
const getTrustedOrigins = (options, context, request) => {
|
|
55
|
+
const result = {
|
|
56
|
+
ready: false,
|
|
57
|
+
trustedOrigins: /* @__PURE__ */ new Set()
|
|
58
|
+
};
|
|
59
|
+
if (context?.trustedOrigins != null) if (!request) return {
|
|
60
|
+
ready: true,
|
|
61
|
+
trustedOrigins: context.trustedOrigins
|
|
62
|
+
};
|
|
63
|
+
else context.trustedOrigins.forEach((o) => result.trustedOrigins.add(o));
|
|
64
|
+
const checkFalsy = () => {
|
|
65
|
+
for (const o of result.trustedOrigins) if (!o) throw new __faire_auth_core_error.FaireAuthError("A provided trusted origin is invalid, make sure your trusted origins list is properly defined.");
|
|
66
|
+
};
|
|
67
|
+
const optionsTrustedOrigins = options.trustedOrigins;
|
|
68
|
+
if (!context?.trustedOrigins) {
|
|
69
|
+
const baseURL = options.baseURL ?? context?.baseURL;
|
|
70
|
+
if (baseURL) result.trustedOrigins.add(new URL(baseURL).origin);
|
|
71
|
+
const envTrustedOrigins = process.env["FAIRE_AUTH_TRUSTED_ORIGINS"];
|
|
72
|
+
if (envTrustedOrigins != null) envTrustedOrigins.split(",").forEach((o) => result.trustedOrigins.add(o));
|
|
73
|
+
if (optionsTrustedOrigins && Array.isArray(optionsTrustedOrigins)) optionsTrustedOrigins.forEach((o) => result.trustedOrigins.add(o));
|
|
74
|
+
}
|
|
75
|
+
if (typeof optionsTrustedOrigins === "function" && request) result.dynamicPromise = (async () => {
|
|
76
|
+
const dynamic = await optionsTrustedOrigins(request);
|
|
77
|
+
if (dynamic) dynamic.forEach((o) => result.trustedOrigins.add(o));
|
|
78
|
+
checkFalsy();
|
|
79
|
+
result.ready = true;
|
|
80
|
+
})();
|
|
81
|
+
else {
|
|
82
|
+
checkFalsy();
|
|
83
|
+
result.ready = true;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
Object.defineProperty(exports, 'getBaseURL', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return getBaseURL;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, 'getHost', {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return getHost;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, 'getOrigin', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return getOrigin;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'getProtocol', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return getProtocol;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, 'getTrustedOrigins', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return getTrustedOrigins;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-oakRccI5.cjs');
|
|
2
|
+
require('../crypto-CcTxYH82.cjs');
|
|
3
|
+
require('../json-CcJ2HjGo.cjs');
|
|
4
|
+
const require_cookies = require('../cookies-B5xeA6i8.cjs');
|
|
5
|
+
let hono_utils_cookie = require("hono/utils/cookie");
|
|
6
|
+
|
|
7
|
+
exports.checkAuthCookie = require_cookies.checkAuthCookie;
|
|
8
|
+
exports.createCookieCapture = require_cookies.createCookieCapture;
|
|
9
|
+
exports.createCookieCreator = require_cookies.createCookieCreator;
|
|
10
|
+
exports.createCookieSetter = require_cookies.createCookieSetter;
|
|
11
|
+
exports.deleteSessionCookie = require_cookies.deleteSessionCookie;
|
|
12
|
+
exports.getCookieCache = require_cookies.getCookieCache;
|
|
13
|
+
exports.getCookieKey = require_cookies.getCookieKey;
|
|
14
|
+
exports.getCookies = require_cookies.getCookies;
|
|
15
|
+
exports.getSessionCookie = require_cookies.getSessionCookie;
|
|
16
|
+
Object.defineProperty(exports, 'parse', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return hono_utils_cookie.parse;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
exports.parseCookies = require_cookies.parseCookies;
|
|
23
|
+
exports.parseSetCookieHeader = require_cookies.parseSetCookieHeader;
|
|
24
|
+
Object.defineProperty(exports, 'parseSigned', {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return hono_utils_cookie.parseSigned;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, 'serialize', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return hono_utils_cookie.serialize;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, 'serializeSigned', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return hono_utils_cookie.serializeSigned;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.serializeSignedCookie = require_cookies.serializeSignedCookie;
|
|
43
|
+
exports.setCookieCache = require_cookies.setCookieCache;
|
|
44
|
+
exports.setSessionCookie = require_cookies.setSessionCookie;
|
|
45
|
+
var hono_cookie = require("hono/cookie");
|
|
46
|
+
Object.keys(hono_cookie).forEach(function (k) {
|
|
47
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return hono_cookie[k]; }
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1, an as AuthContext$1 } from "../index-B-WeOMzg.cjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DOM31WQz.cjs";
|
|
3
|
+
import { LiteralStringUnion } from "@faire-auth/core/types";
|
|
4
|
+
import { Context } from "hono";
|
|
5
|
+
import { Session, User } from "@faire-auth/core/db";
|
|
6
|
+
import { SuccessContext } from "@better-fetch/fetch";
|
|
7
|
+
import { parse, parseSigned, serialize, serializeSigned } from "hono/utils/cookie";
|
|
8
|
+
export * from "hono/cookie";
|
|
9
|
+
|
|
10
|
+
//#region src/utils/cookies.d.ts
|
|
11
|
+
type FaireAuthCookies = ReturnType<typeof getCookies>;
|
|
12
|
+
type EligibleCookies = LiteralStringUnion<keyof FaireAuthCookies>;
|
|
13
|
+
interface CookieAttributes {
|
|
14
|
+
value: string;
|
|
15
|
+
"max-age"?: number;
|
|
16
|
+
expires?: Date;
|
|
17
|
+
domain?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
secure?: boolean;
|
|
20
|
+
httponly?: boolean;
|
|
21
|
+
samesite?: "lax" | "none" | "strict";
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
type CookiePrefixOptions = "host" | "secure";
|
|
25
|
+
interface CookieOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Domain of the cookie
|
|
28
|
+
*
|
|
29
|
+
* The Domain attribute specifies which server can receive a cookie. If specified, cookies are
|
|
30
|
+
* available on the specified server and its subdomains. If the it is not
|
|
31
|
+
* specified, the cookies are available on the server that sets it but not on
|
|
32
|
+
* its subdomains.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* `domain: "example.com"`
|
|
36
|
+
*/
|
|
37
|
+
domain?: string;
|
|
38
|
+
/**
|
|
39
|
+
* A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
|
|
40
|
+
* Expires attribute:
|
|
41
|
+
*
|
|
42
|
+
* Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
|
|
43
|
+
* takes precedence when both are set. The rationale behind this is that when you set an
|
|
44
|
+
* Expires date and time, they're relative to the client the cookie is being set on. If the
|
|
45
|
+
* server is set to a different time, this could cause errors
|
|
46
|
+
*/
|
|
47
|
+
expires?: Date;
|
|
48
|
+
/**
|
|
49
|
+
* Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
|
|
50
|
+
* property. Note that a cookie that has been created with HttpOnly will still be sent with
|
|
51
|
+
* JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
|
|
52
|
+
* This mitigates attacks against cross-site scripting
|
|
53
|
+
*/
|
|
54
|
+
httpOnly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates the number of seconds until the cookie expires. A zero or negative number will
|
|
57
|
+
* expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
|
|
58
|
+
*
|
|
59
|
+
* @example 604800 - 7 days
|
|
60
|
+
*/
|
|
61
|
+
maxAge?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Indicates the path that must exist in the requested URL for the browser to send the Cookie
|
|
64
|
+
* header.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* "/docs"
|
|
68
|
+
* // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
|
|
69
|
+
*/
|
|
70
|
+
path?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Indicates that the cookie is sent to the server only when a request is made with the https:
|
|
73
|
+
* scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
|
|
74
|
+
*/
|
|
75
|
+
secure?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Controls whether or not a cookie is sent with cross-site requests, providing some protection
|
|
78
|
+
* against cross-site request forgery attacks (CSRF).
|
|
79
|
+
*
|
|
80
|
+
* Strict - Means that the browser sends the cookie only for same-site requests, that is,
|
|
81
|
+
* requests originating from the same site that set the cookie. If a request originates from a
|
|
82
|
+
* different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
|
|
83
|
+
* attribute are sent.
|
|
84
|
+
*
|
|
85
|
+
* Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
|
|
86
|
+
* images or frames, but is sent when a user is navigating to the origin site from an external
|
|
87
|
+
* site (for example, when following a link). This is the default behavior if the SameSite
|
|
88
|
+
* attribute is not specified.
|
|
89
|
+
*
|
|
90
|
+
* None - Means that the browser sends the cookie with both cross-site and same-site requests.
|
|
91
|
+
* The Secure attribute must also be set when setting this value.
|
|
92
|
+
*/
|
|
93
|
+
sameSite?: "Lax" | "lax" | "None" | "none" | "Strict" | "strict";
|
|
94
|
+
/**
|
|
95
|
+
* Indicates that the cookie should be stored using partitioned storage. Note that if this is
|
|
96
|
+
* set, the Secure directive must also be set.
|
|
97
|
+
*
|
|
98
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
|
|
99
|
+
*/
|
|
100
|
+
partitioned?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Cooke Prefix
|
|
103
|
+
*
|
|
104
|
+
* - secure: `__Secure-` -> `__Secure-cookie-name`
|
|
105
|
+
* - host: `__Host-` -> `__Host-cookie-name`
|
|
106
|
+
*
|
|
107
|
+
* `secure` must be set to true to use prefixes
|
|
108
|
+
*/
|
|
109
|
+
prefix?: CookiePrefixOptions;
|
|
110
|
+
}
|
|
111
|
+
declare const getCookieKey: (key: string, prefix?: CookiePrefixOptions) => string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie
|
|
114
|
+
* name-value pairs.
|
|
115
|
+
*
|
|
116
|
+
* Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts
|
|
117
|
+
*
|
|
118
|
+
* @param str the string representing a `Cookie` header value
|
|
119
|
+
*/
|
|
120
|
+
declare const parseCookies: (str: string) => Map<string, string>;
|
|
121
|
+
declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
|
|
122
|
+
declare const checkAuthCookie: (request: Headers | Request, auth: {
|
|
123
|
+
$context: Promise<AuthContext$1> | AuthContext$1;
|
|
124
|
+
}) => Promise<string | null>;
|
|
125
|
+
/**
|
|
126
|
+
* IMPORTANT - each Set-Cookie header should be a single cookie
|
|
127
|
+
*/
|
|
128
|
+
declare const parseSetCookieHeader: (setCookie: string | string[]) => Map<string, CookieAttributes>;
|
|
129
|
+
declare const createCookieCreator: (options: FaireAuthOptions$1) => (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
130
|
+
name: string;
|
|
131
|
+
attributes: CookieOptions;
|
|
132
|
+
};
|
|
133
|
+
declare const getCookies: (options: FaireAuthOptions$1) => {
|
|
134
|
+
sessionToken: {
|
|
135
|
+
name: string;
|
|
136
|
+
options: CookieOptions;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* This cookie is used to store the session data in the cookie
|
|
140
|
+
* This is useful for when you want to cache the session in the cookie
|
|
141
|
+
*/
|
|
142
|
+
sessionData: {
|
|
143
|
+
name: string;
|
|
144
|
+
options: CookieOptions;
|
|
145
|
+
};
|
|
146
|
+
dontRememberToken: {
|
|
147
|
+
name: string;
|
|
148
|
+
options: CookieOptions;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
declare const createCookieSetter: (headers: Headers) => (name: string, value: string) => void;
|
|
152
|
+
declare const createCookieCapture: (headers: Headers) => (callback?: (cookieMap: Map<string, string>) => void) => <Res = {}>(context: SuccessContext<Res> | {
|
|
153
|
+
response: Response;
|
|
154
|
+
}) => void;
|
|
155
|
+
declare const getCookieCache: <S extends {
|
|
156
|
+
session: Session;
|
|
157
|
+
user: User;
|
|
158
|
+
}>(request: Headers | Request, config?: {
|
|
159
|
+
cookiePrefix?: string;
|
|
160
|
+
cookieName?: string;
|
|
161
|
+
isSecure?: boolean;
|
|
162
|
+
secret?: string;
|
|
163
|
+
}) => Promise<S | null>;
|
|
164
|
+
declare const setCookieCache: <V extends object>(ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "session">, session: {
|
|
165
|
+
session: Session;
|
|
166
|
+
user: User;
|
|
167
|
+
}, dontRememberMe?: boolean) => Promise<void>;
|
|
168
|
+
declare const getSessionCookie: (request: Headers | Request, config?: {
|
|
169
|
+
cookiePrefix?: string;
|
|
170
|
+
cookieName?: string;
|
|
171
|
+
path?: string;
|
|
172
|
+
}) => string | null;
|
|
173
|
+
declare const setSessionCookie: <V extends object>(ctx: Context<ContextVars<V>>, authOptions: Pick<FaireAuthOptions$1, "session" | "secondaryStorage">, session: {
|
|
174
|
+
session: Session;
|
|
175
|
+
user: User;
|
|
176
|
+
}, dontRememberMe?: boolean, overrides?: Partial<CookieOptions>) => Promise<void>;
|
|
177
|
+
declare const deleteSessionCookie: <V extends object>(ctx: Context<ContextVars<V>>, skipDontRememberMe?: boolean) => void;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { CookieOptions, CookiePrefixOptions, EligibleCookies, FaireAuthCookies, checkAuthCookie, createCookieCapture, createCookieCreator, createCookieSetter, deleteSessionCookie, getCookieCache, getCookieKey, getCookies, getSessionCookie, parse, parseCookies, parseSetCookieHeader, parseSigned, serialize, serializeSigned, serializeSignedCookie, setCookieCache, setSessionCookie };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1, an as AuthContext$1 } from "../index-jlessPI0.mjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DuE14mmj.mjs";
|
|
3
|
+
import { Context } from "hono";
|
|
4
|
+
import { parse, parseSigned, serialize, serializeSigned } from "hono/utils/cookie";
|
|
5
|
+
import { Session, User } from "@faire-auth/core/db";
|
|
6
|
+
import { SuccessContext } from "@better-fetch/fetch";
|
|
7
|
+
import { LiteralStringUnion } from "@faire-auth/core/types";
|
|
8
|
+
export * from "hono/cookie";
|
|
9
|
+
|
|
10
|
+
//#region src/utils/cookies.d.ts
|
|
11
|
+
type FaireAuthCookies = ReturnType<typeof getCookies>;
|
|
12
|
+
type EligibleCookies = LiteralStringUnion<keyof FaireAuthCookies>;
|
|
13
|
+
interface CookieAttributes {
|
|
14
|
+
value: string;
|
|
15
|
+
"max-age"?: number;
|
|
16
|
+
expires?: Date;
|
|
17
|
+
domain?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
secure?: boolean;
|
|
20
|
+
httponly?: boolean;
|
|
21
|
+
samesite?: "lax" | "none" | "strict";
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
type CookiePrefixOptions = "host" | "secure";
|
|
25
|
+
interface CookieOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Domain of the cookie
|
|
28
|
+
*
|
|
29
|
+
* The Domain attribute specifies which server can receive a cookie. If specified, cookies are
|
|
30
|
+
* available on the specified server and its subdomains. If the it is not
|
|
31
|
+
* specified, the cookies are available on the server that sets it but not on
|
|
32
|
+
* its subdomains.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* `domain: "example.com"`
|
|
36
|
+
*/
|
|
37
|
+
domain?: string;
|
|
38
|
+
/**
|
|
39
|
+
* A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
|
|
40
|
+
* Expires attribute:
|
|
41
|
+
*
|
|
42
|
+
* Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
|
|
43
|
+
* takes precedence when both are set. The rationale behind this is that when you set an
|
|
44
|
+
* Expires date and time, they're relative to the client the cookie is being set on. If the
|
|
45
|
+
* server is set to a different time, this could cause errors
|
|
46
|
+
*/
|
|
47
|
+
expires?: Date;
|
|
48
|
+
/**
|
|
49
|
+
* Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
|
|
50
|
+
* property. Note that a cookie that has been created with HttpOnly will still be sent with
|
|
51
|
+
* JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
|
|
52
|
+
* This mitigates attacks against cross-site scripting
|
|
53
|
+
*/
|
|
54
|
+
httpOnly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates the number of seconds until the cookie expires. A zero or negative number will
|
|
57
|
+
* expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
|
|
58
|
+
*
|
|
59
|
+
* @example 604800 - 7 days
|
|
60
|
+
*/
|
|
61
|
+
maxAge?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Indicates the path that must exist in the requested URL for the browser to send the Cookie
|
|
64
|
+
* header.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* "/docs"
|
|
68
|
+
* // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
|
|
69
|
+
*/
|
|
70
|
+
path?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Indicates that the cookie is sent to the server only when a request is made with the https:
|
|
73
|
+
* scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
|
|
74
|
+
*/
|
|
75
|
+
secure?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Controls whether or not a cookie is sent with cross-site requests, providing some protection
|
|
78
|
+
* against cross-site request forgery attacks (CSRF).
|
|
79
|
+
*
|
|
80
|
+
* Strict - Means that the browser sends the cookie only for same-site requests, that is,
|
|
81
|
+
* requests originating from the same site that set the cookie. If a request originates from a
|
|
82
|
+
* different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
|
|
83
|
+
* attribute are sent.
|
|
84
|
+
*
|
|
85
|
+
* Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
|
|
86
|
+
* images or frames, but is sent when a user is navigating to the origin site from an external
|
|
87
|
+
* site (for example, when following a link). This is the default behavior if the SameSite
|
|
88
|
+
* attribute is not specified.
|
|
89
|
+
*
|
|
90
|
+
* None - Means that the browser sends the cookie with both cross-site and same-site requests.
|
|
91
|
+
* The Secure attribute must also be set when setting this value.
|
|
92
|
+
*/
|
|
93
|
+
sameSite?: "Lax" | "lax" | "None" | "none" | "Strict" | "strict";
|
|
94
|
+
/**
|
|
95
|
+
* Indicates that the cookie should be stored using partitioned storage. Note that if this is
|
|
96
|
+
* set, the Secure directive must also be set.
|
|
97
|
+
*
|
|
98
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
|
|
99
|
+
*/
|
|
100
|
+
partitioned?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Cooke Prefix
|
|
103
|
+
*
|
|
104
|
+
* - secure: `__Secure-` -> `__Secure-cookie-name`
|
|
105
|
+
* - host: `__Host-` -> `__Host-cookie-name`
|
|
106
|
+
*
|
|
107
|
+
* `secure` must be set to true to use prefixes
|
|
108
|
+
*/
|
|
109
|
+
prefix?: CookiePrefixOptions;
|
|
110
|
+
}
|
|
111
|
+
declare const getCookieKey: (key: string, prefix?: CookiePrefixOptions) => string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie
|
|
114
|
+
* name-value pairs.
|
|
115
|
+
*
|
|
116
|
+
* Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts
|
|
117
|
+
*
|
|
118
|
+
* @param str the string representing a `Cookie` header value
|
|
119
|
+
*/
|
|
120
|
+
declare const parseCookies: (str: string) => Map<string, string>;
|
|
121
|
+
declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
|
|
122
|
+
declare const checkAuthCookie: (request: Headers | Request, auth: {
|
|
123
|
+
$context: Promise<AuthContext$1> | AuthContext$1;
|
|
124
|
+
}) => Promise<string | null>;
|
|
125
|
+
/**
|
|
126
|
+
* IMPORTANT - each Set-Cookie header should be a single cookie
|
|
127
|
+
*/
|
|
128
|
+
declare const parseSetCookieHeader: (setCookie: string | string[]) => Map<string, CookieAttributes>;
|
|
129
|
+
declare const createCookieCreator: (options: FaireAuthOptions$1) => (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
130
|
+
name: string;
|
|
131
|
+
attributes: CookieOptions;
|
|
132
|
+
};
|
|
133
|
+
declare const getCookies: (options: FaireAuthOptions$1) => {
|
|
134
|
+
sessionToken: {
|
|
135
|
+
name: string;
|
|
136
|
+
options: CookieOptions;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* This cookie is used to store the session data in the cookie
|
|
140
|
+
* This is useful for when you want to cache the session in the cookie
|
|
141
|
+
*/
|
|
142
|
+
sessionData: {
|
|
143
|
+
name: string;
|
|
144
|
+
options: CookieOptions;
|
|
145
|
+
};
|
|
146
|
+
dontRememberToken: {
|
|
147
|
+
name: string;
|
|
148
|
+
options: CookieOptions;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
declare const createCookieSetter: (headers: Headers) => (name: string, value: string) => void;
|
|
152
|
+
declare const createCookieCapture: (headers: Headers) => (callback?: (cookieMap: Map<string, string>) => void) => <Res = {}>(context: SuccessContext<Res> | {
|
|
153
|
+
response: Response;
|
|
154
|
+
}) => void;
|
|
155
|
+
declare const getCookieCache: <S extends {
|
|
156
|
+
session: Session;
|
|
157
|
+
user: User;
|
|
158
|
+
}>(request: Headers | Request, config?: {
|
|
159
|
+
cookiePrefix?: string;
|
|
160
|
+
cookieName?: string;
|
|
161
|
+
isSecure?: boolean;
|
|
162
|
+
secret?: string;
|
|
163
|
+
}) => Promise<S | null>;
|
|
164
|
+
declare const setCookieCache: <V extends object>(ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "session">, session: {
|
|
165
|
+
session: Session;
|
|
166
|
+
user: User;
|
|
167
|
+
}, dontRememberMe?: boolean) => Promise<void>;
|
|
168
|
+
declare const getSessionCookie: (request: Headers | Request, config?: {
|
|
169
|
+
cookiePrefix?: string;
|
|
170
|
+
cookieName?: string;
|
|
171
|
+
path?: string;
|
|
172
|
+
}) => string | null;
|
|
173
|
+
declare const setSessionCookie: <V extends object>(ctx: Context<ContextVars<V>>, authOptions: Pick<FaireAuthOptions$1, "session" | "secondaryStorage">, session: {
|
|
174
|
+
session: Session;
|
|
175
|
+
user: User;
|
|
176
|
+
}, dontRememberMe?: boolean, overrides?: Partial<CookieOptions>) => Promise<void>;
|
|
177
|
+
declare const deleteSessionCookie: <V extends object>(ctx: Context<ContextVars<V>>, skipDontRememberMe?: boolean) => void;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { CookieOptions, CookiePrefixOptions, EligibleCookies, FaireAuthCookies, checkAuthCookie, createCookieCapture, createCookieCreator, createCookieSetter, deleteSessionCookie, getCookieCache, getCookieKey, getCookies, getSessionCookie, parse, parseCookies, parseSetCookieHeader, parseSigned, serialize, serializeSigned, serializeSignedCookie, setCookieCache, setSessionCookie };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../crypto-CyQRFtkq.mjs";
|
|
2
|
+
import "../json-B1v2qRTQ.mjs";
|
|
3
|
+
import { _ as serializeSignedCookie, a as createCookieSetter, c as getCookieKey, d as parse, f as parseCookies, g as serializeSigned, h as serialize, i as createCookieCreator, l as getCookies, m as parseSigned, o as deleteSessionCookie, p as parseSetCookieHeader, r as createCookieCapture, s as getCookieCache, t as checkAuthCookie, u as getSessionCookie, v as setCookieCache, y as setSessionCookie } from "../cookies-Ch1JfQIz.mjs";
|
|
4
|
+
|
|
5
|
+
export * from "hono/cookie"
|
|
6
|
+
|
|
7
|
+
export { checkAuthCookie, createCookieCapture, createCookieCreator, createCookieSetter, deleteSessionCookie, getCookieCache, getCookieKey, getCookies, getSessionCookie, parse, parseCookies, parseSetCookieHeader, parseSigned, serialize, serializeSigned, serializeSignedCookie, setCookieCache, setSessionCookie };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ENV as ENV$1, createLogger as createLogger$1, logger as logger$1 } from "@faire-auth/core/env";
|
|
2
|
+
import { generateId, generateRandomString } from "@faire-auth/core/crypto";
|
|
3
|
+
|
|
4
|
+
export { logger$1 as a, generateRandomString as i, createLogger$1 as n, generateId as r, ENV$1 as t };
|