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,110 @@
|
|
|
1
|
+
import { $ as Client, B as DefaultApp, dt as IsSignal, et as ClientOptions, it as InferActions, nt as FaireAuthClientPlugin, st as InferErrorCodes } from "../../index-jlessPI0.mjs";
|
|
2
|
+
import "../../hono-DuE14mmj.mjs";
|
|
3
|
+
import { BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
4
|
+
import * as hono41 from "hono";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import * as _faire_auth_core_db3 from "@faire-auth/core/db";
|
|
7
|
+
import * as _better_fetch_fetch19 from "@better-fetch/fetch";
|
|
8
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
9
|
+
import * as nanostores5 from "nanostores";
|
|
10
|
+
import { Atom } from "nanostores";
|
|
11
|
+
import * as _faire_auth_core_types37 from "@faire-auth/core/types";
|
|
12
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
13
|
+
export * from "@better-fetch/fetch";
|
|
14
|
+
export * from "nanostores";
|
|
15
|
+
|
|
16
|
+
//#region src/client/svelte/index.d.ts
|
|
17
|
+
type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends FaireAuthClientPlugin ? Plugin["getAtoms"] extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {} : {};
|
|
18
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono41.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
19
|
+
useSession: () => Atom<{
|
|
20
|
+
data: App extends Hono<any, infer S_1 extends hono41.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
21
|
+
success: true;
|
|
22
|
+
})["data"] : never;
|
|
23
|
+
error: BetterFetchError | null;
|
|
24
|
+
isPending: boolean;
|
|
25
|
+
isRefetching: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
$fetch: _better_fetch_fetch19.BetterFetch<{
|
|
28
|
+
plugins: (_better_fetch_fetch19.BetterFetchPlugin | {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
hooks: {};
|
|
32
|
+
})[];
|
|
33
|
+
method: string;
|
|
34
|
+
output?: _better_fetch_fetch19.StandardSchemaV1 | typeof Blob | typeof File;
|
|
35
|
+
query?: any;
|
|
36
|
+
baseURL: string;
|
|
37
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
38
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
39
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
40
|
+
authorization: "Bearer" | "Basic";
|
|
41
|
+
});
|
|
42
|
+
redirect?: RequestRedirect;
|
|
43
|
+
params?: any;
|
|
44
|
+
body?: any;
|
|
45
|
+
throw?: boolean;
|
|
46
|
+
auth?: {
|
|
47
|
+
type: "Bearer";
|
|
48
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
type: "Basic";
|
|
51
|
+
username: string | (() => string | undefined) | undefined;
|
|
52
|
+
password: string | (() => string | undefined) | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
type: "Custom";
|
|
55
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
56
|
+
value: string | (() => string | undefined) | undefined;
|
|
57
|
+
};
|
|
58
|
+
window?: null;
|
|
59
|
+
cache?: RequestCache;
|
|
60
|
+
credentials?: RequestCredentials;
|
|
61
|
+
integrity?: string;
|
|
62
|
+
keepalive?: boolean;
|
|
63
|
+
mode?: RequestMode;
|
|
64
|
+
priority?: RequestPriority;
|
|
65
|
+
referrer?: string;
|
|
66
|
+
referrerPolicy?: ReferrerPolicy;
|
|
67
|
+
signal?: AbortSignal | null;
|
|
68
|
+
onRetry?: (response: _better_fetch_fetch19.ResponseContext) => Promise<void> | void;
|
|
69
|
+
hookOptions?: {
|
|
70
|
+
cloneResponse?: boolean;
|
|
71
|
+
};
|
|
72
|
+
timeout?: number;
|
|
73
|
+
duplex?: "full" | "half";
|
|
74
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
75
|
+
retry?: _better_fetch_fetch19.RetryOptions;
|
|
76
|
+
retryAttempt?: number;
|
|
77
|
+
errorSchema?: _better_fetch_fetch19.StandardSchemaV1;
|
|
78
|
+
disableValidation?: boolean;
|
|
79
|
+
catchAllError?: boolean;
|
|
80
|
+
defaultOutput?: _better_fetch_fetch19.StandardSchemaV1;
|
|
81
|
+
defaultError?: _better_fetch_fetch19.StandardSchemaV1;
|
|
82
|
+
schema?: _better_fetch_fetch19.Schema;
|
|
83
|
+
customFetchImpl: any;
|
|
84
|
+
}, unknown, unknown, _better_fetch_fetch19.Schema>;
|
|
85
|
+
$store: {
|
|
86
|
+
notify: (signal?: _faire_auth_core_types37.LiteralStringUnion<"$sessionSignal">) => void;
|
|
87
|
+
listen: (signal: _faire_auth_core_types37.LiteralStringUnion<"$sessionSignal">, listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
88
|
+
atoms: {
|
|
89
|
+
session: nanostores5.PreinitializedWritableAtom<{
|
|
90
|
+
data: {
|
|
91
|
+
user: _faire_auth_core_db3.User;
|
|
92
|
+
session: _faire_auth_core_db3.Session;
|
|
93
|
+
} | null;
|
|
94
|
+
error: BetterFetchError | null;
|
|
95
|
+
isPending: boolean;
|
|
96
|
+
isRefetching: boolean;
|
|
97
|
+
refetch: () => void;
|
|
98
|
+
}> & object;
|
|
99
|
+
$sessionSignal: nanostores5.PreinitializedWritableAtom<boolean> & object;
|
|
100
|
+
} & Record<string, nanostores5.WritableAtom<any>>;
|
|
101
|
+
};
|
|
102
|
+
$Infer: {
|
|
103
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono41.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
104
|
+
success: true;
|
|
105
|
+
})["data"] : never>;
|
|
106
|
+
};
|
|
107
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { t as getBaseURL } from "../../url-BoUuoIwZ.mjs";
|
|
2
|
+
import "../../request-1NL_1lyJ.mjs";
|
|
3
|
+
import "../../defu-SZkpHhbR.mjs";
|
|
4
|
+
import { n as getClientConfig, t as createHonoClient } from "../../hono-Covz10jU.mjs";
|
|
5
|
+
import "../../parser-CeAer-RM.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/client/svelte/index.ts
|
|
8
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
9
|
+
const createAuthClient = () => (options) => {
|
|
10
|
+
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
|
11
|
+
const { pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
12
|
+
let resolvedHooks = {};
|
|
13
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = () => value;
|
|
14
|
+
const routes = {
|
|
15
|
+
...pluginsActions,
|
|
16
|
+
...resolvedHooks,
|
|
17
|
+
$fetch,
|
|
18
|
+
$store
|
|
19
|
+
};
|
|
20
|
+
routes.useSession = () => pluginsAtoms.session;
|
|
21
|
+
return createHonoClient({
|
|
22
|
+
baseURL,
|
|
23
|
+
createFetchOptions: options.fetchOptions
|
|
24
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-oakRccI5.cjs');
|
|
2
|
+
const require_url = require('../../url-D2yvKaM7.cjs');
|
|
3
|
+
require('../../request-CPNlp-DK.cjs');
|
|
4
|
+
require('../../defu-B0Svx_x4.cjs');
|
|
5
|
+
const require_hono = require('../../hono-BEq1NYVX.cjs');
|
|
6
|
+
require('../../parser-CdncAl9i.cjs');
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
|
|
9
|
+
//#region src/client/vue/vue-store.ts
|
|
10
|
+
function registerStore(store) {
|
|
11
|
+
let instance = (0, vue.getCurrentInstance)();
|
|
12
|
+
if (instance && instance.proxy) {
|
|
13
|
+
let vm = instance.proxy;
|
|
14
|
+
("_nanostores" in vm ? vm._nanostores : vm._nanostores = []).push(store);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function useStore(store) {
|
|
18
|
+
let state = (0, vue.shallowRef)();
|
|
19
|
+
let unsubscribe = store.subscribe((value) => {
|
|
20
|
+
state.value = value;
|
|
21
|
+
});
|
|
22
|
+
(0, vue.getCurrentScope)() && (0, vue.onScopeDispose)(unsubscribe);
|
|
23
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24
|
+
registerStore(store);
|
|
25
|
+
return (0, vue.readonly)(state);
|
|
26
|
+
}
|
|
27
|
+
return state;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/client/vue/index.ts
|
|
32
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
33
|
+
function getAtomKey(str) {
|
|
34
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
35
|
+
}
|
|
36
|
+
const createAuthClient = () => (options) => {
|
|
37
|
+
const baseURL = require_url.getBaseURL(options.baseURL, options.basePath);
|
|
38
|
+
const { pluginsActions, pluginsAtoms, $fetch, $store, atomListeners } = require_hono.getClientConfig(options);
|
|
39
|
+
let resolvedHooks = {};
|
|
40
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
41
|
+
function useSession(useFetch) {
|
|
42
|
+
if (useFetch) {
|
|
43
|
+
const ref = useStore(pluginsAtoms.$sessionSignal);
|
|
44
|
+
return useFetch(`${baseURL}/get-session`, { ref }).then((res) => {
|
|
45
|
+
return {
|
|
46
|
+
data: res.data,
|
|
47
|
+
isPending: false,
|
|
48
|
+
error: res.error
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return resolvedHooks.useSession();
|
|
53
|
+
}
|
|
54
|
+
const routes = {
|
|
55
|
+
...pluginsActions,
|
|
56
|
+
...resolvedHooks,
|
|
57
|
+
useSession,
|
|
58
|
+
$fetch,
|
|
59
|
+
$store
|
|
60
|
+
};
|
|
61
|
+
return require_hono.createHonoClient({
|
|
62
|
+
baseURL,
|
|
63
|
+
createFetchOptions: options.fetchOptions
|
|
64
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
exports.createAuthClient = createAuthClient;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { $ as Client, B as DefaultApp, dt as IsSignal, et as ClientOptions, it as InferActions, nt as FaireAuthClientPlugin, st as InferErrorCodes } from "../../index-B-WeOMzg.cjs";
|
|
2
|
+
import "../../hono-DOM31WQz.cjs";
|
|
3
|
+
import * as _faire_auth_core_types40 from "@faire-auth/core/types";
|
|
4
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
5
|
+
import * as hono49 from "hono";
|
|
6
|
+
import { Hono } from "hono";
|
|
7
|
+
import * as _faire_auth_core_db5 from "@faire-auth/core/db";
|
|
8
|
+
import { BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
9
|
+
import * as _better_fetch_fetch39 from "@better-fetch/fetch";
|
|
10
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
11
|
+
import * as nanostores8 from "nanostores";
|
|
12
|
+
import { DeepReadonly, Ref } from "vue";
|
|
13
|
+
export * from "@better-fetch/fetch";
|
|
14
|
+
export * from "nanostores";
|
|
15
|
+
|
|
16
|
+
//#region src/client/vue/index.d.ts
|
|
17
|
+
type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends FaireAuthClientPlugin ? Plugin["getAtoms"] extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>> } : {} : {} : {} : {};
|
|
18
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono49.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
19
|
+
useSession: {
|
|
20
|
+
(): DeepReadonly<Ref<{
|
|
21
|
+
data: App extends Hono<any, infer S_1 extends hono49.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
22
|
+
success: true;
|
|
23
|
+
})["data"] : never;
|
|
24
|
+
isPending: boolean;
|
|
25
|
+
isRefetching: boolean;
|
|
26
|
+
error: BetterFetchError | null;
|
|
27
|
+
}>>;
|
|
28
|
+
<F extends (...args: any) => any>(useFetch: F): Promise<{
|
|
29
|
+
data: Ref<App extends Hono<any, infer S_1 extends hono49.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
30
|
+
success: true;
|
|
31
|
+
})["data"] : never>;
|
|
32
|
+
isPending: false;
|
|
33
|
+
error: Ref<{
|
|
34
|
+
message?: string;
|
|
35
|
+
status: number;
|
|
36
|
+
statusText: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
$Infer: {
|
|
41
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono49.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
42
|
+
success: true;
|
|
43
|
+
})["data"] : never>;
|
|
44
|
+
};
|
|
45
|
+
$fetch: _better_fetch_fetch39.BetterFetch<{
|
|
46
|
+
plugins: (_better_fetch_fetch39.BetterFetchPlugin | {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
hooks: {};
|
|
50
|
+
})[];
|
|
51
|
+
method: string;
|
|
52
|
+
output?: _better_fetch_fetch39.StandardSchemaV1 | typeof Blob | typeof File;
|
|
53
|
+
query?: any;
|
|
54
|
+
baseURL: string;
|
|
55
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
56
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
57
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
58
|
+
authorization: "Bearer" | "Basic";
|
|
59
|
+
});
|
|
60
|
+
redirect?: RequestRedirect;
|
|
61
|
+
params?: any;
|
|
62
|
+
body?: any;
|
|
63
|
+
throw?: boolean;
|
|
64
|
+
auth?: {
|
|
65
|
+
type: "Bearer";
|
|
66
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
type: "Basic";
|
|
69
|
+
username: string | (() => string | undefined) | undefined;
|
|
70
|
+
password: string | (() => string | undefined) | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
type: "Custom";
|
|
73
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
74
|
+
value: string | (() => string | undefined) | undefined;
|
|
75
|
+
};
|
|
76
|
+
window?: null;
|
|
77
|
+
cache?: RequestCache;
|
|
78
|
+
credentials?: RequestCredentials;
|
|
79
|
+
integrity?: string;
|
|
80
|
+
keepalive?: boolean;
|
|
81
|
+
mode?: RequestMode;
|
|
82
|
+
priority?: RequestPriority;
|
|
83
|
+
referrer?: string;
|
|
84
|
+
referrerPolicy?: ReferrerPolicy;
|
|
85
|
+
signal?: AbortSignal | null;
|
|
86
|
+
onRetry?: (response: _better_fetch_fetch39.ResponseContext) => Promise<void> | void;
|
|
87
|
+
hookOptions?: {
|
|
88
|
+
cloneResponse?: boolean;
|
|
89
|
+
};
|
|
90
|
+
timeout?: number;
|
|
91
|
+
duplex?: "full" | "half";
|
|
92
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
93
|
+
retry?: _better_fetch_fetch39.RetryOptions;
|
|
94
|
+
retryAttempt?: number;
|
|
95
|
+
errorSchema?: _better_fetch_fetch39.StandardSchemaV1;
|
|
96
|
+
disableValidation?: boolean;
|
|
97
|
+
catchAllError?: boolean;
|
|
98
|
+
defaultOutput?: _better_fetch_fetch39.StandardSchemaV1;
|
|
99
|
+
defaultError?: _better_fetch_fetch39.StandardSchemaV1;
|
|
100
|
+
schema?: _better_fetch_fetch39.Schema;
|
|
101
|
+
customFetchImpl: any;
|
|
102
|
+
}, unknown, unknown, _better_fetch_fetch39.Schema>;
|
|
103
|
+
$store: {
|
|
104
|
+
notify: (signal?: _faire_auth_core_types40.LiteralStringUnion<"$sessionSignal">) => void;
|
|
105
|
+
listen: (signal: _faire_auth_core_types40.LiteralStringUnion<"$sessionSignal">, listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
106
|
+
atoms: {
|
|
107
|
+
session: nanostores8.PreinitializedWritableAtom<{
|
|
108
|
+
data: {
|
|
109
|
+
user: _faire_auth_core_db5.User;
|
|
110
|
+
session: _faire_auth_core_db5.Session;
|
|
111
|
+
} | null;
|
|
112
|
+
error: BetterFetchError | null;
|
|
113
|
+
isPending: boolean;
|
|
114
|
+
isRefetching: boolean;
|
|
115
|
+
refetch: () => void;
|
|
116
|
+
}> & object;
|
|
117
|
+
$sessionSignal: nanostores8.PreinitializedWritableAtom<boolean> & object;
|
|
118
|
+
} & Record<string, nanostores8.WritableAtom<any>>;
|
|
119
|
+
};
|
|
120
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { $ as Client, B as DefaultApp, dt as IsSignal, et as ClientOptions, it as InferActions, nt as FaireAuthClientPlugin, st as InferErrorCodes } from "../../index-jlessPI0.mjs";
|
|
2
|
+
import "../../hono-DuE14mmj.mjs";
|
|
3
|
+
import { BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
4
|
+
import * as hono51 from "hono";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import * as _faire_auth_core_db5 from "@faire-auth/core/db";
|
|
7
|
+
import * as _better_fetch_fetch39 from "@better-fetch/fetch";
|
|
8
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
9
|
+
import * as nanostores8 from "nanostores";
|
|
10
|
+
import { DeepReadonly, Ref } from "vue";
|
|
11
|
+
import * as _faire_auth_core_types41 from "@faire-auth/core/types";
|
|
12
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
13
|
+
export * from "@better-fetch/fetch";
|
|
14
|
+
export * from "nanostores";
|
|
15
|
+
|
|
16
|
+
//#region src/client/vue/index.d.ts
|
|
17
|
+
type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends FaireAuthClientPlugin ? Plugin["getAtoms"] extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>> } : {} : {} : {} : {};
|
|
18
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono51.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
19
|
+
useSession: {
|
|
20
|
+
(): DeepReadonly<Ref<{
|
|
21
|
+
data: App extends Hono<any, infer S_1 extends hono51.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
22
|
+
success: true;
|
|
23
|
+
})["data"] : never;
|
|
24
|
+
isPending: boolean;
|
|
25
|
+
isRefetching: boolean;
|
|
26
|
+
error: BetterFetchError | null;
|
|
27
|
+
}>>;
|
|
28
|
+
<F extends (...args: any) => any>(useFetch: F): Promise<{
|
|
29
|
+
data: Ref<App extends Hono<any, infer S_1 extends hono51.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
30
|
+
success: true;
|
|
31
|
+
})["data"] : never>;
|
|
32
|
+
isPending: false;
|
|
33
|
+
error: Ref<{
|
|
34
|
+
message?: string;
|
|
35
|
+
status: number;
|
|
36
|
+
statusText: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
$Infer: {
|
|
41
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono51.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
42
|
+
success: true;
|
|
43
|
+
})["data"] : never>;
|
|
44
|
+
};
|
|
45
|
+
$fetch: _better_fetch_fetch39.BetterFetch<{
|
|
46
|
+
plugins: (_better_fetch_fetch39.BetterFetchPlugin | {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
hooks: {};
|
|
50
|
+
})[];
|
|
51
|
+
method: string;
|
|
52
|
+
output?: _better_fetch_fetch39.StandardSchemaV1 | typeof Blob | typeof File;
|
|
53
|
+
query?: any;
|
|
54
|
+
baseURL: string;
|
|
55
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
56
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
57
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
58
|
+
authorization: "Bearer" | "Basic";
|
|
59
|
+
});
|
|
60
|
+
redirect?: RequestRedirect;
|
|
61
|
+
params?: any;
|
|
62
|
+
body?: any;
|
|
63
|
+
throw?: boolean;
|
|
64
|
+
auth?: {
|
|
65
|
+
type: "Bearer";
|
|
66
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
type: "Basic";
|
|
69
|
+
username: string | (() => string | undefined) | undefined;
|
|
70
|
+
password: string | (() => string | undefined) | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
type: "Custom";
|
|
73
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
74
|
+
value: string | (() => string | undefined) | undefined;
|
|
75
|
+
};
|
|
76
|
+
window?: null;
|
|
77
|
+
cache?: RequestCache;
|
|
78
|
+
credentials?: RequestCredentials;
|
|
79
|
+
integrity?: string;
|
|
80
|
+
keepalive?: boolean;
|
|
81
|
+
mode?: RequestMode;
|
|
82
|
+
priority?: RequestPriority;
|
|
83
|
+
referrer?: string;
|
|
84
|
+
referrerPolicy?: ReferrerPolicy;
|
|
85
|
+
signal?: AbortSignal | null;
|
|
86
|
+
onRetry?: (response: _better_fetch_fetch39.ResponseContext) => Promise<void> | void;
|
|
87
|
+
hookOptions?: {
|
|
88
|
+
cloneResponse?: boolean;
|
|
89
|
+
};
|
|
90
|
+
timeout?: number;
|
|
91
|
+
duplex?: "full" | "half";
|
|
92
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
93
|
+
retry?: _better_fetch_fetch39.RetryOptions;
|
|
94
|
+
retryAttempt?: number;
|
|
95
|
+
errorSchema?: _better_fetch_fetch39.StandardSchemaV1;
|
|
96
|
+
disableValidation?: boolean;
|
|
97
|
+
catchAllError?: boolean;
|
|
98
|
+
defaultOutput?: _better_fetch_fetch39.StandardSchemaV1;
|
|
99
|
+
defaultError?: _better_fetch_fetch39.StandardSchemaV1;
|
|
100
|
+
schema?: _better_fetch_fetch39.Schema;
|
|
101
|
+
customFetchImpl: any;
|
|
102
|
+
}, unknown, unknown, _better_fetch_fetch39.Schema>;
|
|
103
|
+
$store: {
|
|
104
|
+
notify: (signal?: _faire_auth_core_types41.LiteralStringUnion<"$sessionSignal">) => void;
|
|
105
|
+
listen: (signal: _faire_auth_core_types41.LiteralStringUnion<"$sessionSignal">, listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
106
|
+
atoms: {
|
|
107
|
+
session: nanostores8.PreinitializedWritableAtom<{
|
|
108
|
+
data: {
|
|
109
|
+
user: _faire_auth_core_db5.User;
|
|
110
|
+
session: _faire_auth_core_db5.Session;
|
|
111
|
+
} | null;
|
|
112
|
+
error: BetterFetchError | null;
|
|
113
|
+
isPending: boolean;
|
|
114
|
+
isRefetching: boolean;
|
|
115
|
+
refetch: () => void;
|
|
116
|
+
}> & object;
|
|
117
|
+
$sessionSignal: nanostores8.PreinitializedWritableAtom<boolean> & object;
|
|
118
|
+
} & Record<string, nanostores8.WritableAtom<any>>;
|
|
119
|
+
};
|
|
120
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { t as getBaseURL } from "../../url-BoUuoIwZ.mjs";
|
|
2
|
+
import "../../request-1NL_1lyJ.mjs";
|
|
3
|
+
import "../../defu-SZkpHhbR.mjs";
|
|
4
|
+
import { n as getClientConfig, t as createHonoClient } from "../../hono-Covz10jU.mjs";
|
|
5
|
+
import "../../parser-CeAer-RM.mjs";
|
|
6
|
+
import { getCurrentInstance, getCurrentScope, onScopeDispose, readonly, shallowRef } from "vue";
|
|
7
|
+
|
|
8
|
+
//#region src/client/vue/vue-store.ts
|
|
9
|
+
function registerStore(store) {
|
|
10
|
+
let instance = getCurrentInstance();
|
|
11
|
+
if (instance && instance.proxy) {
|
|
12
|
+
let vm = instance.proxy;
|
|
13
|
+
("_nanostores" in vm ? vm._nanostores : vm._nanostores = []).push(store);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function useStore(store) {
|
|
17
|
+
let state = shallowRef();
|
|
18
|
+
let unsubscribe = store.subscribe((value) => {
|
|
19
|
+
state.value = value;
|
|
20
|
+
});
|
|
21
|
+
getCurrentScope() && onScopeDispose(unsubscribe);
|
|
22
|
+
if (process.env.NODE_ENV !== "production") {
|
|
23
|
+
registerStore(store);
|
|
24
|
+
return readonly(state);
|
|
25
|
+
}
|
|
26
|
+
return state;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/client/vue/index.ts
|
|
31
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
32
|
+
function getAtomKey(str) {
|
|
33
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
34
|
+
}
|
|
35
|
+
const createAuthClient = () => (options) => {
|
|
36
|
+
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
|
37
|
+
const { pluginsActions, pluginsAtoms, $fetch, $store, atomListeners } = getClientConfig(options);
|
|
38
|
+
let resolvedHooks = {};
|
|
39
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
40
|
+
function useSession(useFetch) {
|
|
41
|
+
if (useFetch) {
|
|
42
|
+
const ref = useStore(pluginsAtoms.$sessionSignal);
|
|
43
|
+
return useFetch(`${baseURL}/get-session`, { ref }).then((res) => {
|
|
44
|
+
return {
|
|
45
|
+
data: res.data,
|
|
46
|
+
isPending: false,
|
|
47
|
+
error: res.error
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return resolvedHooks.useSession();
|
|
52
|
+
}
|
|
53
|
+
const routes = {
|
|
54
|
+
...pluginsActions,
|
|
55
|
+
...resolvedHooks,
|
|
56
|
+
useSession,
|
|
57
|
+
$fetch,
|
|
58
|
+
$store
|
|
59
|
+
};
|
|
60
|
+
return createHonoClient({
|
|
61
|
+
baseURL,
|
|
62
|
+
createFetchOptions: options.fetchOptions
|
|
63
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { createAuthClient };
|