faire-auth 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-factory-lKIOf2OR.mjs → adapter-factory-qPVW8x9-.mjs} +34 -36
- package/dist/{adapter-factory-D1I7joki.cjs → adapter-factory-u8r3oTez.cjs} +66 -68
- package/dist/adapters/drizzle-adapter/index.cjs +34 -40
- package/dist/adapters/drizzle-adapter/index.d.cts +4 -9
- package/dist/adapters/drizzle-adapter/index.d.mts +4 -9
- package/dist/adapters/drizzle-adapter/index.mjs +20 -26
- package/dist/adapters/index.cjs +11 -16
- package/dist/adapters/index.d.cts +11 -37
- package/dist/adapters/index.d.mts +11 -37
- package/dist/adapters/index.mjs +4 -13
- package/dist/adapters/kysely-adapter/index.cjs +270 -11
- package/dist/adapters/kysely-adapter/index.d.cts +9 -19
- package/dist/adapters/kysely-adapter/index.d.mts +9 -19
- package/dist/adapters/kysely-adapter/index.mjs +267 -9
- package/dist/adapters/memory-adapter/index.cjs +146 -9
- package/dist/adapters/memory-adapter/index.d.cts +4 -10
- package/dist/adapters/memory-adapter/index.d.mts +4 -10
- package/dist/adapters/memory-adapter/index.mjs +145 -9
- package/dist/adapters/mongodb-adapter/index.cjs +13 -21
- package/dist/adapters/mongodb-adapter/index.d.cts +3 -8
- package/dist/adapters/mongodb-adapter/index.d.mts +4 -9
- package/dist/adapters/mongodb-adapter/index.mjs +12 -20
- package/dist/adapters/prisma-adapter/index.cjs +12 -20
- package/dist/adapters/prisma-adapter/index.d.cts +4 -8
- package/dist/adapters/prisma-adapter/index.d.mts +4 -8
- package/dist/adapters/prisma-adapter/index.mjs +5 -13
- package/dist/adapters/test.cjs +86 -69
- package/dist/adapters/test.d.cts +7 -11
- package/dist/adapters/test.d.mts +7 -11
- package/dist/adapters/test.mjs +83 -66
- package/dist/api/index.cjs +3 -20
- package/dist/api/index.d.cts +2 -3
- package/dist/api/index.d.mts +2 -3
- package/dist/api/index.mjs +1 -20
- package/dist/api/middleware/index.cjs +4 -11
- package/dist/api/middleware/index.d.cts +3 -9
- package/dist/api/middleware/index.d.mts +3 -9
- package/dist/api/middleware/index.mjs +3 -11
- package/dist/{api-B4RDwBty.mjs → api-0f-F-Fi2.mjs} +292 -189
- package/dist/{api-CaRC1Gio.cjs → api-LjfH6hQi.cjs} +557 -452
- package/dist/{test-utils/bun-sqlite-dialect-BZBvHchL.cjs → bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
- package/dist/{test-utils/bun-sqlite-dialect-BSWhhKNs.mjs → bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
- package/dist/client/index.cjs +8 -15
- package/dist/client/index.d.cts +9 -14
- package/dist/client/index.d.mts +9 -14
- package/dist/client/index.mjs +7 -15
- package/dist/client/lynx/index.cjs +10 -18
- package/dist/client/lynx/index.d.cts +402 -71
- package/dist/client/lynx/index.d.mts +402 -71
- package/dist/client/lynx/index.mjs +5 -13
- package/dist/client/plugins/index.cjs +3 -5
- package/dist/client/plugins/index.d.cts +5 -10
- package/dist/client/plugins/index.d.mts +5 -10
- package/dist/client/plugins/index.mjs +2 -4
- package/dist/client/react/index.cjs +6 -14
- package/dist/client/react/index.d.cts +402 -71
- package/dist/client/react/index.d.mts +402 -71
- package/dist/client/react/index.mjs +5 -13
- package/dist/client/solid/index.cjs +6 -14
- package/dist/client/solid/index.d.cts +393 -57
- package/dist/client/solid/index.d.mts +393 -57
- package/dist/client/solid/index.mjs +5 -13
- package/dist/client/svelte/index.cjs +5 -10
- package/dist/client/svelte/index.d.cts +400 -67
- package/dist/client/svelte/index.d.mts +400 -67
- package/dist/client/svelte/index.mjs +4 -10
- package/dist/client/vue/index.cjs +6 -14
- package/dist/client/vue/index.d.cts +401 -68
- package/dist/client/vue/index.d.mts +401 -68
- package/dist/client/vue/index.mjs +5 -13
- package/dist/{cookies-BTs1o992.mjs → cookies-D9aY_gJh.mjs} +25 -21
- package/dist/{cookies-BTl72THv.cjs → cookies-DQ52rcOy.cjs} +119 -115
- package/dist/crypto/index.cjs +10 -8
- package/dist/crypto/index.d.cts +5 -13
- package/dist/crypto/index.d.mts +5 -13
- package/dist/crypto/index.mjs +2 -5
- package/dist/{crypto-DH2Aa7jN.mjs → crypto-BH-hD0lJ.mjs} +7 -10
- package/dist/{crypto-DpSCnrTp.cjs → crypto-BITfWVwD.cjs} +24 -27
- package/dist/db/index.cjs +1135 -29
- package/dist/db/index.d.cts +1 -2
- package/dist/db/index.d.mts +1 -2
- package/dist/db/index.mjs +1115 -16
- package/dist/defu-D2h4S3X-.mjs +87 -0
- package/dist/defu-DWS5RPWt.cjs +134 -0
- package/dist/{email-verification-DI_0H4JC.cjs → email-verification-DOPnSgbI.cjs} +65 -71
- package/dist/{email-verification-C_lBu_JY.mjs → email-verification-YSR5n5lb.mjs} +23 -29
- package/dist/{hono-CO-zsqI-.mjs → hono-BAV2wQkK.mjs} +16 -33
- package/dist/hono-SVQuc5Ru.mjs +4 -0
- package/dist/hono-pgK4H_U1.cjs +9 -0
- package/dist/{hono-DnW5crl1.cjs → hono-tyFFJFdS.cjs} +42 -60
- package/dist/index-B86Cy0dE.d.cts +2 -0
- package/dist/index-B86Cy0dE.d.mts +2 -0
- package/dist/index.cjs +115 -150
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +45 -80
- package/dist/integrations/next-js.cjs +5 -9
- package/dist/integrations/next-js.d.cts +6 -14
- package/dist/integrations/next-js.d.mts +6 -14
- package/dist/integrations/next-js.mjs +4 -9
- package/dist/integrations/node.cjs +16 -14
- package/dist/integrations/node.d.cts +6 -14
- package/dist/integrations/node.d.mts +6 -14
- package/dist/integrations/node.mjs +15 -13
- package/dist/integrations/react-start.cjs +7 -11
- package/dist/integrations/react-start.d.cts +5 -13
- package/dist/integrations/react-start.d.mts +5 -13
- package/dist/integrations/react-start.mjs +6 -11
- package/dist/integrations/solid-start.cjs +3 -5
- package/dist/integrations/solid-start.d.cts +2 -5
- package/dist/integrations/solid-start.d.mts +2 -5
- package/dist/integrations/solid-start.mjs +2 -4
- package/dist/integrations/svelte-kit.cjs +6 -10
- package/dist/integrations/svelte-kit.d.cts +11 -23
- package/dist/integrations/svelte-kit.d.mts +11 -23
- package/dist/integrations/svelte-kit.mjs +5 -10
- package/dist/{ip-BjNYspCH.mjs → ip-6Lv2o42m.mjs} +4 -9
- package/dist/{ip-C17Qdq-G.cjs → ip-DPydExzV.cjs} +21 -27
- package/dist/{json--tl7Grvs.cjs → json-D3aq-nH2.cjs} +9 -13
- package/dist/{json-B1v2qRTQ.mjs → json-DooGMtnJ.mjs} +2 -5
- package/dist/{logged-CyGfp8_H.mjs → logged-B83SzMnJ.mjs} +6 -10
- package/dist/{logged-Dv3st5qc.cjs → logged-BIpCpnVY.cjs} +13 -18
- package/dist/{middleware-CE6OhDkq.mjs → middleware-Cakg4e1D.mjs} +2 -4
- package/dist/{middleware-CWvRH4EW.cjs → middleware-Cd-VkNxB.cjs} +17 -20
- package/dist/{node-sqlite-dialect-w4DAg0PH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
- package/dist/{test-utils/node-sqlite-dialect-BgJqjBOu.cjs → node-sqlite-dialect-D3QPFROH.cjs} +5 -9
- package/dist/oauth2/index.cjs +166 -22
- package/dist/oauth2/index.d.cts +5 -17
- package/dist/oauth2/index.d.mts +5 -17
- package/dist/oauth2/index.mjs +156 -16
- package/dist/{origin-check-DjLTuZQ8.cjs → origin-check-BflGhEEN.cjs} +34 -38
- package/dist/{origin-check-8Gajklvh.mjs → origin-check-CRgs1M7k.mjs} +13 -16
- package/dist/{parser-B25ylT5u.mjs → parser-CqwvpF6l.cjs} +12 -10
- package/dist/{parser-B_wxvaAr.cjs → parser-DcKDjjHO.mjs} +7 -22
- package/dist/plugins/access/index.cjs +38 -4
- package/dist/plugins/access/index.d.cts +36 -2
- package/dist/plugins/access/index.d.mts +36 -2
- package/dist/plugins/access/index.mjs +36 -3
- package/dist/plugins/bearer/index.cjs +52 -7
- package/dist/plugins/bearer/index.d.cts +27 -4
- package/dist/plugins/bearer/index.d.mts +27 -4
- package/dist/plugins/bearer/index.mjs +51 -7
- package/dist/plugins/index.cjs +1385 -842
- package/dist/plugins/index.d.cts +489 -7566
- package/dist/plugins/index.d.mts +489 -7566
- package/dist/plugins/index.mjs +1118 -576
- package/dist/plugins/passkey/index.cjs +551 -15
- package/dist/plugins/passkey/index.d.cts +123 -4
- package/dist/plugins/passkey/index.d.mts +123 -4
- package/dist/plugins/passkey/index.mjs +547 -15
- package/dist/{chunk-BFnQceUY.mjs → rolldown-runtime-BKpuH2hG.mjs} +6 -7
- package/dist/{chunk-fPmz2rbM.cjs → rolldown-runtime-C_Pgydhf.cjs} +22 -24
- package/dist/{schema-DTIwLLmf.mjs → schema-CFCpv0tK.mjs} +3 -6
- package/dist/{schema-CirKflVs.cjs → schema-b-lKhMkG.cjs} +51 -55
- package/dist/{session-CM3rmOYF.mjs → session-BGjJgihS.mjs} +51 -74
- package/dist/{session-Cwrj4GfV.cjs → session-CzZSMmQC.cjs} +197 -219
- package/dist/shared.d.cts +1581 -0
- package/dist/shared.d.mts +1581 -0
- package/dist/social-providers/index.cjs +9 -9
- package/dist/social-providers/index.d.cts +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/dist/social-providers/index.mjs +3 -5
- package/dist/social-providers-CjPww-qf.mjs +6 -0
- package/dist/social-providers-D7w_7Ym8.cjs +10 -0
- package/dist/{state-CvSihlVT.cjs → state-2OrNjOO-.cjs} +24 -24
- package/dist/{state-CQghgH9I.mjs → state-Dooeisfq.mjs} +17 -17
- package/dist/{bun-sqlite-dialect-DPgTzc0w.cjs → test-utils/bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
- package/dist/{bun-sqlite-dialect-6NqeV3px.mjs → test-utils/bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
- package/dist/test-utils/index.cjs +8831 -7941
- package/dist/test-utils/index.d.cts +310 -12440
- package/dist/test-utils/index.d.mts +313 -12440
- package/dist/test-utils/index.mjs +8591 -7701
- package/dist/test-utils/{node-sqlite-dialect-DAQXiobH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
- package/dist/{node-sqlite-dialect-DP11CB0y.cjs → test-utils/node-sqlite-dialect-D3QPFROH.cjs} +5 -9
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.mts +2 -3
- package/dist/types/index.mjs +1 -1
- package/dist/{url-BoUuoIwZ.mjs → url-CJtdrrUu.mjs} +12 -13
- package/dist/{url-Ce7CVaQD.cjs → url-DjCmCUHS.cjs} +42 -44
- package/dist/utils/cookies.cjs +29 -30
- package/dist/utils/cookies.d.cts +21 -25
- package/dist/utils/cookies.d.mts +20 -24
- package/dist/utils/cookies.mjs +2 -7
- package/dist/utils-C7OHyfHa.mjs +4 -0
- package/dist/utils-iX0Vy_UL.cjs +3 -0
- package/package.json +40 -30
- package/dist/access-BZ7-AbTM.cjs +0 -51
- package/dist/access-D0DRqUKC.mjs +0 -39
- package/dist/bearer-DDzrp5M7.cjs +0 -60
- package/dist/bearer-WZcs7gxL.mjs +0 -54
- package/dist/db-4tUsQJXd.mjs +0 -1119
- package/dist/db-ChMbb_U-.cjs +0 -1180
- package/dist/defu-BmOYq4PU.cjs +0 -34
- package/dist/defu-D9ZTXqlo.mjs +0 -28
- package/dist/hono-C14rpOEa.cjs +0 -13
- package/dist/hono-CoKYWnXA.mjs +0 -7
- package/dist/hono-D0VqxVy1.d.mts +0 -18
- package/dist/hono-DOM31WQz.d.cts +0 -18
- package/dist/index--DLiUhEn.d.mts +0 -33
- package/dist/index-B4bqEDYG.d.mts +0 -992
- package/dist/index-BDhhaE6Y.d.cts +0 -3
- package/dist/index-Boa0SV4h.d.cts +0 -13350
- package/dist/index-Bykgiq3o.d.cts +0 -13350
- package/dist/index-CF9iq55a.d.mts +0 -3
- package/dist/index-CRt_fppq.d.mts +0 -41
- package/dist/index-CdLyn7qP.d.cts +0 -41
- package/dist/index-ClFGA8tb.d.mts +0 -33
- package/dist/index-ClOM0wFf.d.cts +0 -992
- package/dist/index-CsxNfGAV.d.mts +0 -13350
- package/dist/index-DKnO_Zfm.d.cts +0 -992
- package/dist/index-DRYO4mGd.d.cts +0 -33
- package/dist/index-Dsua4U8w.d.cts +0 -33
- package/dist/index-DxXFCG2_.d.mts +0 -13350
- package/dist/index-gtCVvDvC.d.mts +0 -992
- package/dist/kysely-adapter-CtIdoHa8.mjs +0 -270
- package/dist/kysely-adapter-QZTx077T.cjs +0 -288
- package/dist/memory-adapter-17RZd5df.cjs +0 -154
- package/dist/memory-adapter-Dp4XdCZK.mjs +0 -148
- package/dist/oauth2-5RL4cVNS.cjs +0 -177
- package/dist/oauth2-C56wz-n9.mjs +0 -159
- package/dist/passkey-BTT-v5c-.cjs +0 -512
- package/dist/passkey-CzY_W2us.mjs +0 -505
- package/dist/request-1NL_1lyJ.mjs +0 -58
- package/dist/request-CPNlp-DK.cjs +0 -100
- package/dist/social-providers-B8RK5yqI.mjs +0 -9
- package/dist/social-providers-BmFOIIPk.cjs +0 -13
- package/dist/utils-44aDDP8f.cjs +0 -2
- package/dist/utils-D4vZd1-9.mjs +0 -4
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { t as getBaseURL } from "./url-
|
|
2
|
-
import { a as
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as parseJSON } from "./parser-B25ylT5u.mjs";
|
|
1
|
+
import { t as getBaseURL } from "./url-CJtdrrUu.mjs";
|
|
2
|
+
import { a as normaliseHeaders, c as replaceUrlProtocol, i as mergePath, n as buildSearchParams, o as removeIndexString, r as mergeHeaders, s as replaceUrlParam, t as defu } from "./defu-D2h4S3X-.mjs";
|
|
3
|
+
import { t as parseJSON } from "./parser-DcKDjjHO.mjs";
|
|
5
4
|
import { serialize } from "hono/utils/cookie";
|
|
6
5
|
import { createFetch } from "@better-fetch/fetch";
|
|
7
6
|
import { atom, onMount } from "nanostores";
|
|
8
|
-
|
|
9
|
-
//#region src/client/fetch-plugins.ts
|
|
7
|
+
// src/client/fetch-plugins.ts
|
|
10
8
|
const redirectPlugin = {
|
|
11
9
|
id: "redirect",
|
|
12
10
|
name: "Redirect",
|
|
@@ -20,9 +18,7 @@ const redirectPlugin = {
|
|
|
20
18
|
}
|
|
21
19
|
} }
|
|
22
20
|
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/client/plugins/lifecycle.ts
|
|
21
|
+
// src/client/plugins/lifecycle.ts
|
|
26
22
|
const lifecycle = (options) => ({
|
|
27
23
|
id: "lifecycle-hooks",
|
|
28
24
|
name: "lifecycle-hooks",
|
|
@@ -33,9 +29,7 @@ const lifecycle = (options) => ({
|
|
|
33
29
|
...options?.fetchOptions?.onResponse && { onResponse: options.fetchOptions.onResponse }
|
|
34
30
|
}
|
|
35
31
|
});
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/client/query.ts
|
|
32
|
+
// src/client/query.ts
|
|
39
33
|
const isServer = typeof window === "undefined";
|
|
40
34
|
const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
41
35
|
const value = atom({
|
|
@@ -108,9 +102,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
108
102
|
});
|
|
109
103
|
return value;
|
|
110
104
|
};
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/client/broadcast-channel.ts
|
|
105
|
+
// src/client/broadcast-channel.ts
|
|
114
106
|
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
115
107
|
function createBroadcastChannel(name = "faire-auth.message") {
|
|
116
108
|
return {
|
|
@@ -135,9 +127,7 @@ function createBroadcastChannel(name = "faire-auth.message") {
|
|
|
135
127
|
}
|
|
136
128
|
};
|
|
137
129
|
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/client/session-refresh.ts
|
|
130
|
+
// src/client/session-refresh.ts
|
|
141
131
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
142
132
|
function createSessionRefreshManager(opts) {
|
|
143
133
|
const { sessionAtom, sessionSignal, options = {} } = opts;
|
|
@@ -245,9 +235,7 @@ function createSessionRefreshManager(opts) {
|
|
|
245
235
|
broadcastSessionUpdate
|
|
246
236
|
};
|
|
247
237
|
}
|
|
248
|
-
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/client/session-atom.ts
|
|
238
|
+
// src/client/session-atom.ts
|
|
251
239
|
const getSessionAtom = ($fetch, options) => {
|
|
252
240
|
const $signal = atom(false);
|
|
253
241
|
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
@@ -268,15 +256,13 @@ const getSessionAtom = ($fetch, options) => {
|
|
|
268
256
|
$sessionSignal: $signal
|
|
269
257
|
};
|
|
270
258
|
};
|
|
271
|
-
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/client/config.ts
|
|
259
|
+
// src/client/config.ts
|
|
274
260
|
const getClientConfig = (options) => {
|
|
275
261
|
const baseURL = () => getBaseURL(options?.baseURL, options?.basePath) ?? "/api/auth";
|
|
276
262
|
const plugins = options?.plugins ?? [];
|
|
277
263
|
const pluginsFetchPlugins = plugins.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0);
|
|
278
|
-
const { onSuccess: _, onError: __, onRequest: ___, onResponse: ____
|
|
279
|
-
const
|
|
264
|
+
const { onSuccess: _, onError: __, onRequest: ___, onResponse: ____, ...restOfFetchOptions } = options?.fetchOptions ?? {};
|
|
265
|
+
const fetchOptions = {
|
|
280
266
|
get baseURL() {
|
|
281
267
|
return baseURL();
|
|
282
268
|
},
|
|
@@ -294,7 +280,8 @@ const getClientConfig = (options) => {
|
|
|
294
280
|
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
295
281
|
...pluginsFetchPlugins
|
|
296
282
|
]
|
|
297
|
-
}
|
|
283
|
+
};
|
|
284
|
+
const $fetch = createFetch(fetchOptions);
|
|
298
285
|
const sessionAtom = getSessionAtom($fetch);
|
|
299
286
|
const pluginsActions = {};
|
|
300
287
|
const pluginsAtoms = sessionAtom;
|
|
@@ -337,9 +324,7 @@ const getClientConfig = (options) => {
|
|
|
337
324
|
$store
|
|
338
325
|
};
|
|
339
326
|
};
|
|
340
|
-
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region src/client/hono.ts
|
|
327
|
+
// src/client/hono.ts
|
|
343
328
|
const isPromise = (value) => value != null && typeof value.then === "function";
|
|
344
329
|
const isHonoRequestLike = (value) => value != null && typeof value === "object" && "raw" in value && value.raw instanceof Request && "header" in value && typeof value.header === "function" && "query" in value && typeof value.query === "function" && "param" in value && typeof value.param === "function" && "json" in value && typeof value.json === "function" && "path" in value && typeof value.path === "string";
|
|
345
330
|
const isInputOpts = (value) => value == null || typeof value === "object" && Object.keys(value).every((k) => k !== "fetchOptions" && k !== "fetch" && k !== "websocket" && k !== "init" && k !== "headers");
|
|
@@ -503,6 +488,4 @@ const createHonoClient = (options, routes, $fetch, atoms, atomListeners) => crea
|
|
|
503
488
|
clientOpts.fetchOptions = defu(clientOpts.fetchOptions, options.createFetchOptions);
|
|
504
489
|
return req.fetch(input, clientOpts);
|
|
505
490
|
}, [], routes);
|
|
506
|
-
|
|
507
|
-
//#endregion
|
|
508
|
-
export { getClientConfig as n, useAuthQuery as r, createHonoClient as t };
|
|
491
|
+
export { getClientConfig as n, useAuthQuery as r, createHonoClient as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
let hono_context_storage = require("hono/context-storage");
|
|
2
|
+
// src/context/hono.ts
|
|
3
|
+
const getContext = () => (0, hono_context_storage.getContext)();
|
|
4
|
+
Object.defineProperty(exports, "getContext", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return getContext;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_defu = require('./defu-BmOYq4PU.cjs');
|
|
5
|
-
const require_parser = require('./parser-B_wxvaAr.cjs');
|
|
1
|
+
const require_url = require("./url-DjCmCUHS.cjs");
|
|
2
|
+
const require_defu = require("./defu-DWS5RPWt.cjs");
|
|
3
|
+
const require_parser = require("./parser-CqwvpF6l.cjs");
|
|
6
4
|
let hono_utils_cookie = require("hono/utils/cookie");
|
|
7
|
-
let
|
|
5
|
+
let _better_fetch_fetch = require("@better-fetch/fetch");
|
|
8
6
|
let nanostores = require("nanostores");
|
|
9
|
-
|
|
10
|
-
//#region src/client/fetch-plugins.ts
|
|
7
|
+
// src/client/fetch-plugins.ts
|
|
11
8
|
const redirectPlugin = {
|
|
12
9
|
id: "redirect",
|
|
13
10
|
name: "Redirect",
|
|
@@ -21,9 +18,7 @@ const redirectPlugin = {
|
|
|
21
18
|
}
|
|
22
19
|
} }
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/client/plugins/lifecycle.ts
|
|
21
|
+
// src/client/plugins/lifecycle.ts
|
|
27
22
|
const lifecycle = (options) => ({
|
|
28
23
|
id: "lifecycle-hooks",
|
|
29
24
|
name: "lifecycle-hooks",
|
|
@@ -34,9 +29,7 @@ const lifecycle = (options) => ({
|
|
|
34
29
|
...options?.fetchOptions?.onResponse && { onResponse: options.fetchOptions.onResponse }
|
|
35
30
|
}
|
|
36
31
|
});
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/client/query.ts
|
|
32
|
+
// src/client/query.ts
|
|
40
33
|
const isServer = typeof window === "undefined";
|
|
41
34
|
const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
42
35
|
const value = (0, nanostores.atom)({
|
|
@@ -109,9 +102,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
109
102
|
});
|
|
110
103
|
return value;
|
|
111
104
|
};
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region src/client/broadcast-channel.ts
|
|
105
|
+
// src/client/broadcast-channel.ts
|
|
115
106
|
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
116
107
|
function createBroadcastChannel(name = "faire-auth.message") {
|
|
117
108
|
return {
|
|
@@ -136,9 +127,7 @@ function createBroadcastChannel(name = "faire-auth.message") {
|
|
|
136
127
|
}
|
|
137
128
|
};
|
|
138
129
|
}
|
|
139
|
-
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/client/session-refresh.ts
|
|
130
|
+
// src/client/session-refresh.ts
|
|
142
131
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
143
132
|
function createSessionRefreshManager(opts) {
|
|
144
133
|
const { sessionAtom, sessionSignal, options = {} } = opts;
|
|
@@ -246,9 +235,7 @@ function createSessionRefreshManager(opts) {
|
|
|
246
235
|
broadcastSessionUpdate
|
|
247
236
|
};
|
|
248
237
|
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/client/session-atom.ts
|
|
238
|
+
// src/client/session-atom.ts
|
|
252
239
|
const getSessionAtom = ($fetch, options) => {
|
|
253
240
|
const $signal = (0, nanostores.atom)(false);
|
|
254
241
|
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
@@ -269,15 +256,13 @@ const getSessionAtom = ($fetch, options) => {
|
|
|
269
256
|
$sessionSignal: $signal
|
|
270
257
|
};
|
|
271
258
|
};
|
|
272
|
-
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/client/config.ts
|
|
259
|
+
// src/client/config.ts
|
|
275
260
|
const getClientConfig = (options) => {
|
|
276
261
|
const baseURL = () => require_url.getBaseURL(options?.baseURL, options?.basePath) ?? "/api/auth";
|
|
277
262
|
const plugins = options?.plugins ?? [];
|
|
278
263
|
const pluginsFetchPlugins = plugins.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0);
|
|
279
|
-
const { onSuccess: _, onError: __, onRequest: ___, onResponse: ____
|
|
280
|
-
const
|
|
264
|
+
const { onSuccess: _, onError: __, onRequest: ___, onResponse: ____, ...restOfFetchOptions } = options?.fetchOptions ?? {};
|
|
265
|
+
const fetchOptions = {
|
|
281
266
|
get baseURL() {
|
|
282
267
|
return baseURL();
|
|
283
268
|
},
|
|
@@ -295,7 +280,8 @@ const getClientConfig = (options) => {
|
|
|
295
280
|
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
296
281
|
...pluginsFetchPlugins
|
|
297
282
|
]
|
|
298
|
-
}
|
|
283
|
+
};
|
|
284
|
+
const $fetch = (0, _better_fetch_fetch.createFetch)(fetchOptions);
|
|
299
285
|
const sessionAtom = getSessionAtom($fetch);
|
|
300
286
|
const pluginsActions = {};
|
|
301
287
|
const pluginsAtoms = sessionAtom;
|
|
@@ -338,9 +324,7 @@ const getClientConfig = (options) => {
|
|
|
338
324
|
$store
|
|
339
325
|
};
|
|
340
326
|
};
|
|
341
|
-
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/client/hono.ts
|
|
327
|
+
// src/client/hono.ts
|
|
344
328
|
const isPromise = (value) => value != null && typeof value.then === "function";
|
|
345
329
|
const isHonoRequestLike = (value) => value != null && typeof value === "object" && "raw" in value && value.raw instanceof Request && "header" in value && typeof value.header === "function" && "query" in value && typeof value.query === "function" && "param" in value && typeof value.param === "function" && "json" in value && typeof value.json === "function" && "path" in value && typeof value.path === "string";
|
|
346
330
|
const isInputOpts = (value) => value == null || typeof value === "object" && Object.keys(value).every((k) => k !== "fetchOptions" && k !== "fetch" && k !== "websocket" && k !== "init" && k !== "headers");
|
|
@@ -392,7 +376,7 @@ var ClientRequestImpl = class {
|
|
|
392
376
|
fetch = async (args, opt) => {
|
|
393
377
|
if (isHonoRequestLike(opt.fetch)) return this.$fetch(opt.fetch.url, opt.fetch.raw);
|
|
394
378
|
if (args) {
|
|
395
|
-
if (args.query) this.queryParams =
|
|
379
|
+
if (args.query) this.queryParams = require_defu.buildSearchParams(args.query);
|
|
396
380
|
if (args.form) {
|
|
397
381
|
const form = new FormData();
|
|
398
382
|
for (const [k, v] of Object.entries(args.form)) if (Array.isArray(v)) for (const v2 of v) form.append(k, v2);
|
|
@@ -406,7 +390,7 @@ var ClientRequestImpl = class {
|
|
|
406
390
|
if (args.param) this.pathParams = args.param;
|
|
407
391
|
}
|
|
408
392
|
let methodUpperCase = this.method.toUpperCase();
|
|
409
|
-
let headers =
|
|
393
|
+
let headers = require_defu.normaliseHeaders(opt.headers);
|
|
410
394
|
if (isPromise(headers)) headers = await headers;
|
|
411
395
|
if (args?.header) Object.entries(args.header).forEach(([k, v]) => headers.set(k, v));
|
|
412
396
|
if (args?.cookie) {
|
|
@@ -416,8 +400,8 @@ var ClientRequestImpl = class {
|
|
|
416
400
|
}
|
|
417
401
|
if (this.cType) headers.set("Content-Type", this.cType);
|
|
418
402
|
let url = this.url;
|
|
419
|
-
url =
|
|
420
|
-
url =
|
|
403
|
+
url = require_defu.removeIndexString(url);
|
|
404
|
+
url = require_defu.replaceUrlParam(url, this.pathParams);
|
|
421
405
|
if (this.queryParams && this.queryParams.size > 0) url = url + "?" + this.queryParams.toString();
|
|
422
406
|
methodUpperCase = this.method.toUpperCase();
|
|
423
407
|
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
@@ -472,22 +456,22 @@ const createHonoClient = (options, routes, $fetch, atoms, atomListeners) => crea
|
|
|
472
456
|
clientOpts: opts.args[0] ?? {}
|
|
473
457
|
};
|
|
474
458
|
const path = `/${parts.join("/")}`;
|
|
475
|
-
const url =
|
|
476
|
-
clientOpts.headers =
|
|
459
|
+
const url = require_defu.mergePath(options.baseURL, path);
|
|
460
|
+
clientOpts.headers = require_defu.mergeHeaders(options?.createFetchOptions?.headers, clientOpts.fetchOptions?.headers, clientOpts.headers);
|
|
477
461
|
if (method === "url" || method === "path") {
|
|
478
462
|
let result = url;
|
|
479
|
-
if (input.param) result =
|
|
463
|
+
if (input.param) result = require_defu.replaceUrlParam(url, input.param);
|
|
480
464
|
if (input.query) {
|
|
481
|
-
const sp =
|
|
465
|
+
const sp = require_defu.buildSearchParams(input.query);
|
|
482
466
|
if (sp.size > 0) result += "?" + sp.toString();
|
|
483
467
|
}
|
|
484
|
-
result =
|
|
468
|
+
result = require_defu.removeIndexString(result);
|
|
485
469
|
if (method === "url") return new URL(result);
|
|
486
470
|
const base = (options.baseURL ?? "").replace(/\/+$/, "");
|
|
487
471
|
return result.slice(base.length).replace(/^\/?/, "/");
|
|
488
472
|
}
|
|
489
473
|
if (method === "ws") {
|
|
490
|
-
const webSocketUrl =
|
|
474
|
+
const webSocketUrl = require_defu.replaceUrlProtocol(input.param ? require_defu.replaceUrlParam(url, input.param) : url, "ws");
|
|
491
475
|
const targetUrl = new URL(webSocketUrl);
|
|
492
476
|
const queryParams = input.query;
|
|
493
477
|
if (queryParams) Object.entries(queryParams).forEach(([key, value]) => {
|
|
@@ -504,23 +488,21 @@ const createHonoClient = (options, routes, $fetch, atoms, atomListeners) => crea
|
|
|
504
488
|
clientOpts.fetchOptions = require_defu.defu(clientOpts.fetchOptions, options.createFetchOptions);
|
|
505
489
|
return req.fetch(input, clientOpts);
|
|
506
490
|
}, [], routes);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
return createHonoClient;
|
|
513
|
-
}
|
|
491
|
+
Object.defineProperty(exports, "createHonoClient", {
|
|
492
|
+
enumerable: true,
|
|
493
|
+
get: function() {
|
|
494
|
+
return createHonoClient;
|
|
495
|
+
}
|
|
514
496
|
});
|
|
515
|
-
Object.defineProperty(exports,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
497
|
+
Object.defineProperty(exports, "getClientConfig", {
|
|
498
|
+
enumerable: true,
|
|
499
|
+
get: function() {
|
|
500
|
+
return getClientConfig;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
Object.defineProperty(exports, "useAuthQuery", {
|
|
504
|
+
enumerable: true,
|
|
505
|
+
get: function() {
|
|
506
|
+
return useAuthQuery;
|
|
507
|
+
}
|
|
520
508
|
});
|
|
521
|
-
Object.defineProperty(exports, 'useAuthQuery', {
|
|
522
|
-
enumerable: true,
|
|
523
|
-
get: function () {
|
|
524
|
-
return useAuthQuery;
|
|
525
|
-
}
|
|
526
|
-
});
|