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,156 @@
|
|
|
1
|
+
import { $ as Client, B as DefaultApp, dt as IsSignal, et as ClientOptions, it as InferActions, nt as FaireAuthClientPlugin, pt as SessionQueryParams, 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 hono38 from "hono";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import * as _faire_auth_core_db1 from "@faire-auth/core/db";
|
|
7
|
+
import * as _better_fetch_fetch9 from "@better-fetch/fetch";
|
|
8
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
9
|
+
import * as nanostores2 from "nanostores";
|
|
10
|
+
import { Store, StoreValue } from "nanostores";
|
|
11
|
+
import { DependencyList } from "react";
|
|
12
|
+
import * as _faire_auth_core_types35 from "@faire-auth/core/types";
|
|
13
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
14
|
+
export * from "@better-fetch/fetch";
|
|
15
|
+
export * from "nanostores";
|
|
16
|
+
|
|
17
|
+
//#region src/client/react/react-store.d.ts
|
|
18
|
+
type StoreKeys<T> = T extends {
|
|
19
|
+
setKey: (k: infer K, v: any) => unknown;
|
|
20
|
+
} ? K : never;
|
|
21
|
+
interface UseStoreOptions<SomeStore> {
|
|
22
|
+
/**
|
|
23
|
+
* @default
|
|
24
|
+
* ```ts
|
|
25
|
+
* [store, options.keys]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
deps?: DependencyList;
|
|
29
|
+
/**
|
|
30
|
+
* Will re-render components only on specific key changes.
|
|
31
|
+
*/
|
|
32
|
+
keys?: StoreKeys<SomeStore>[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to store changes and get store's value.
|
|
36
|
+
*
|
|
37
|
+
* Can be used with store builder too.
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* import { useStore } from 'nanostores/react'
|
|
41
|
+
*
|
|
42
|
+
* import { router } from '../store/router'
|
|
43
|
+
*
|
|
44
|
+
* export const Layout = () => {
|
|
45
|
+
* let page = useStore(router)
|
|
46
|
+
* if (page.route === 'home') {
|
|
47
|
+
* return <HomePage />
|
|
48
|
+
* } else {
|
|
49
|
+
* return <Error404 />
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param store Store instance.
|
|
55
|
+
* @returns Store value.
|
|
56
|
+
*/
|
|
57
|
+
declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/client/react/index.d.ts
|
|
60
|
+
declare function capitalizeFirstLetter(str: string): string;
|
|
61
|
+
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]: () => ReturnType<Atoms[key]["get"]> } : {} : {} : {} : {};
|
|
62
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono38.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
63
|
+
useSession: () => {
|
|
64
|
+
data: (App extends Hono<any, infer S_1 extends hono38.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
65
|
+
success: true;
|
|
66
|
+
})["data"] : never) | null;
|
|
67
|
+
isPending: boolean;
|
|
68
|
+
error: BetterFetchError | null;
|
|
69
|
+
refetch: (queryParams?: {
|
|
70
|
+
query?: SessionQueryParams;
|
|
71
|
+
}) => void;
|
|
72
|
+
};
|
|
73
|
+
$Infer: {
|
|
74
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono38.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
75
|
+
success: true;
|
|
76
|
+
})["data"] : never>;
|
|
77
|
+
};
|
|
78
|
+
$fetch: _better_fetch_fetch9.BetterFetch<{
|
|
79
|
+
plugins: (_better_fetch_fetch9.BetterFetchPlugin | {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
hooks: {};
|
|
83
|
+
})[];
|
|
84
|
+
method: string;
|
|
85
|
+
output?: _better_fetch_fetch9.StandardSchemaV1 | typeof Blob | typeof File;
|
|
86
|
+
query?: any;
|
|
87
|
+
baseURL: string;
|
|
88
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
89
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
90
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
91
|
+
authorization: "Bearer" | "Basic";
|
|
92
|
+
});
|
|
93
|
+
redirect?: RequestRedirect;
|
|
94
|
+
params?: any;
|
|
95
|
+
body?: any;
|
|
96
|
+
throw?: boolean;
|
|
97
|
+
auth?: {
|
|
98
|
+
type: "Bearer";
|
|
99
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
100
|
+
} | {
|
|
101
|
+
type: "Basic";
|
|
102
|
+
username: string | (() => string | undefined) | undefined;
|
|
103
|
+
password: string | (() => string | undefined) | undefined;
|
|
104
|
+
} | {
|
|
105
|
+
type: "Custom";
|
|
106
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
107
|
+
value: string | (() => string | undefined) | undefined;
|
|
108
|
+
};
|
|
109
|
+
window?: null;
|
|
110
|
+
cache?: RequestCache;
|
|
111
|
+
credentials?: RequestCredentials;
|
|
112
|
+
integrity?: string;
|
|
113
|
+
keepalive?: boolean;
|
|
114
|
+
mode?: RequestMode;
|
|
115
|
+
priority?: RequestPriority;
|
|
116
|
+
referrer?: string;
|
|
117
|
+
referrerPolicy?: ReferrerPolicy;
|
|
118
|
+
signal?: AbortSignal | null;
|
|
119
|
+
onRetry?: (response: _better_fetch_fetch9.ResponseContext) => Promise<void> | void;
|
|
120
|
+
hookOptions?: {
|
|
121
|
+
cloneResponse?: boolean;
|
|
122
|
+
};
|
|
123
|
+
timeout?: number;
|
|
124
|
+
duplex?: "full" | "half";
|
|
125
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
126
|
+
retry?: _better_fetch_fetch9.RetryOptions;
|
|
127
|
+
retryAttempt?: number;
|
|
128
|
+
errorSchema?: _better_fetch_fetch9.StandardSchemaV1;
|
|
129
|
+
disableValidation?: boolean;
|
|
130
|
+
catchAllError?: boolean;
|
|
131
|
+
defaultOutput?: _better_fetch_fetch9.StandardSchemaV1;
|
|
132
|
+
defaultError?: _better_fetch_fetch9.StandardSchemaV1;
|
|
133
|
+
schema?: _better_fetch_fetch9.Schema;
|
|
134
|
+
customFetchImpl: any;
|
|
135
|
+
}, unknown, unknown, _better_fetch_fetch9.Schema>;
|
|
136
|
+
$store: {
|
|
137
|
+
notify: (signal?: _faire_auth_core_types35.LiteralStringUnion<"$sessionSignal">) => void;
|
|
138
|
+
listen: (signal: _faire_auth_core_types35.LiteralStringUnion<"$sessionSignal">, listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
139
|
+
atoms: {
|
|
140
|
+
session: nanostores2.PreinitializedWritableAtom<{
|
|
141
|
+
data: {
|
|
142
|
+
user: _faire_auth_core_db1.User;
|
|
143
|
+
session: _faire_auth_core_db1.Session;
|
|
144
|
+
} | null;
|
|
145
|
+
error: BetterFetchError | null;
|
|
146
|
+
isPending: boolean;
|
|
147
|
+
isRefetching: boolean;
|
|
148
|
+
refetch: () => void;
|
|
149
|
+
}> & object;
|
|
150
|
+
$sessionSignal: nanostores2.PreinitializedWritableAtom<boolean> & object;
|
|
151
|
+
} & Record<string, nanostores2.WritableAtom<any>>;
|
|
152
|
+
};
|
|
153
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { capitalizeFirstLetter, createAuthClient, useStore };
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { listenKeys } from "nanostores";
|
|
7
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
8
|
+
|
|
9
|
+
//#region src/client/react/react-store.ts
|
|
10
|
+
/**
|
|
11
|
+
* Subscribe to store changes and get store's value.
|
|
12
|
+
*
|
|
13
|
+
* Can be used with store builder too.
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* import { useStore } from 'nanostores/react'
|
|
17
|
+
*
|
|
18
|
+
* import { router } from '../store/router'
|
|
19
|
+
*
|
|
20
|
+
* export const Layout = () => {
|
|
21
|
+
* let page = useStore(router)
|
|
22
|
+
* if (page.route === 'home') {
|
|
23
|
+
* return <HomePage />
|
|
24
|
+
* } else {
|
|
25
|
+
* return <Error404 />
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param store Store instance.
|
|
31
|
+
* @returns Store value.
|
|
32
|
+
*/
|
|
33
|
+
function useStore(store, options = {}) {
|
|
34
|
+
let snapshotRef = useRef(store.get());
|
|
35
|
+
const { keys, deps = [store, keys] } = options;
|
|
36
|
+
let subscribe = useCallback((onChange) => {
|
|
37
|
+
const emitChange = (value) => {
|
|
38
|
+
if (snapshotRef.current === value) return;
|
|
39
|
+
snapshotRef.current = value;
|
|
40
|
+
onChange();
|
|
41
|
+
};
|
|
42
|
+
emitChange(store.value);
|
|
43
|
+
if (keys?.length) return listenKeys(store, keys, emitChange);
|
|
44
|
+
return store.listen(emitChange);
|
|
45
|
+
}, deps);
|
|
46
|
+
let get = () => snapshotRef.current;
|
|
47
|
+
return useSyncExternalStore(subscribe, get, get);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/client/react/index.ts
|
|
52
|
+
function getAtomKey(str) {
|
|
53
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
54
|
+
}
|
|
55
|
+
function capitalizeFirstLetter(str) {
|
|
56
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
57
|
+
}
|
|
58
|
+
const createAuthClient = () => (options) => {
|
|
59
|
+
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
|
60
|
+
const { pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
61
|
+
let resolvedHooks = {};
|
|
62
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
63
|
+
const routes = {
|
|
64
|
+
...pluginsActions,
|
|
65
|
+
...resolvedHooks,
|
|
66
|
+
$fetch,
|
|
67
|
+
$store
|
|
68
|
+
};
|
|
69
|
+
return createHonoClient({
|
|
70
|
+
baseURL,
|
|
71
|
+
createFetchOptions: options.fetchOptions
|
|
72
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { capitalizeFirstLetter, createAuthClient, useStore };
|
|
@@ -0,0 +1,51 @@
|
|
|
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 solid_js_store = require("solid-js/store");
|
|
8
|
+
let solid_js = require("solid-js");
|
|
9
|
+
|
|
10
|
+
//#region src/client/solid/solid-store.ts
|
|
11
|
+
/**
|
|
12
|
+
* Subscribes to store changes and gets store’s value.
|
|
13
|
+
*
|
|
14
|
+
* @param store Store instance.
|
|
15
|
+
* @returns Store value.
|
|
16
|
+
*/
|
|
17
|
+
function useStore(store) {
|
|
18
|
+
const unbindActivation = store.listen(() => {});
|
|
19
|
+
const [state, setState] = (0, solid_js_store.createStore)({ value: store.get() });
|
|
20
|
+
const unsubscribe = store.subscribe((newValue) => {
|
|
21
|
+
setState("value", (0, solid_js_store.reconcile)(newValue));
|
|
22
|
+
});
|
|
23
|
+
(0, solid_js.onCleanup)(() => unsubscribe());
|
|
24
|
+
unbindActivation();
|
|
25
|
+
return () => state.value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/client/solid/index.ts
|
|
30
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
31
|
+
function getAtomKey(str) {
|
|
32
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
33
|
+
}
|
|
34
|
+
const createAuthClient = () => (options) => {
|
|
35
|
+
const baseURL = require_url.getBaseURL(options.baseURL, options.basePath);
|
|
36
|
+
const { pluginsActions, pluginsAtoms, $fetch, atomListeners } = require_hono.getClientConfig(options);
|
|
37
|
+
const resolvedHooks = {};
|
|
38
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
39
|
+
const routes = {
|
|
40
|
+
...pluginsActions,
|
|
41
|
+
...resolvedHooks
|
|
42
|
+
};
|
|
43
|
+
routes.useSession = () => useStore(pluginsAtoms.session);
|
|
44
|
+
return require_hono.createHonoClient({
|
|
45
|
+
baseURL,
|
|
46
|
+
createFetchOptions: options.fetchOptions
|
|
47
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.createAuthClient = createAuthClient;
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
4
|
+
import * as hono43 from "hono";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import { BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
7
|
+
import * as _better_fetch_fetch19 from "@better-fetch/fetch";
|
|
8
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
9
|
+
import { Accessor } from "solid-js";
|
|
10
|
+
export * from "@better-fetch/fetch";
|
|
11
|
+
export * from "nanostores";
|
|
12
|
+
|
|
13
|
+
//#region src/client/solid/index.d.ts
|
|
14
|
+
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]: () => Accessor<ReturnType<Atoms[key]["get"]>> } : {} : {} : {} : {};
|
|
15
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono43.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
16
|
+
useSession: () => Accessor<{
|
|
17
|
+
data: App extends Hono<any, infer S_1 extends hono43.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
18
|
+
success: true;
|
|
19
|
+
})["data"] : never;
|
|
20
|
+
isPending: boolean;
|
|
21
|
+
isRefetching: boolean;
|
|
22
|
+
error: BetterFetchError | null;
|
|
23
|
+
}>;
|
|
24
|
+
$Infer: {
|
|
25
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono43.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
26
|
+
success: true;
|
|
27
|
+
})["data"] : never>;
|
|
28
|
+
};
|
|
29
|
+
$fetch: _better_fetch_fetch19.BetterFetch<{
|
|
30
|
+
plugins: (_better_fetch_fetch19.BetterFetchPlugin | {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
hooks: {};
|
|
34
|
+
})[];
|
|
35
|
+
method: string;
|
|
36
|
+
output?: _better_fetch_fetch19.StandardSchemaV1 | typeof Blob | typeof File;
|
|
37
|
+
query?: any;
|
|
38
|
+
baseURL: string;
|
|
39
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
40
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
41
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
42
|
+
authorization: "Bearer" | "Basic";
|
|
43
|
+
});
|
|
44
|
+
redirect?: RequestRedirect;
|
|
45
|
+
params?: any;
|
|
46
|
+
body?: any;
|
|
47
|
+
throw?: boolean;
|
|
48
|
+
auth?: {
|
|
49
|
+
type: "Bearer";
|
|
50
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
type: "Basic";
|
|
53
|
+
username: string | (() => string | undefined) | undefined;
|
|
54
|
+
password: string | (() => string | undefined) | undefined;
|
|
55
|
+
} | {
|
|
56
|
+
type: "Custom";
|
|
57
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
58
|
+
value: string | (() => string | undefined) | undefined;
|
|
59
|
+
};
|
|
60
|
+
window?: null;
|
|
61
|
+
cache?: RequestCache;
|
|
62
|
+
credentials?: RequestCredentials;
|
|
63
|
+
integrity?: string;
|
|
64
|
+
keepalive?: boolean;
|
|
65
|
+
mode?: RequestMode;
|
|
66
|
+
priority?: RequestPriority;
|
|
67
|
+
referrer?: string;
|
|
68
|
+
referrerPolicy?: ReferrerPolicy;
|
|
69
|
+
signal?: AbortSignal | null;
|
|
70
|
+
onRetry?: (response: _better_fetch_fetch19.ResponseContext) => Promise<void> | void;
|
|
71
|
+
hookOptions?: {
|
|
72
|
+
cloneResponse?: boolean;
|
|
73
|
+
};
|
|
74
|
+
timeout?: number;
|
|
75
|
+
duplex?: "full" | "half";
|
|
76
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
77
|
+
retry?: _better_fetch_fetch19.RetryOptions;
|
|
78
|
+
retryAttempt?: number;
|
|
79
|
+
errorSchema?: _better_fetch_fetch19.StandardSchemaV1;
|
|
80
|
+
disableValidation?: boolean;
|
|
81
|
+
catchAllError?: boolean;
|
|
82
|
+
defaultOutput?: _better_fetch_fetch19.StandardSchemaV1;
|
|
83
|
+
defaultError?: _better_fetch_fetch19.StandardSchemaV1;
|
|
84
|
+
schema?: _better_fetch_fetch19.Schema;
|
|
85
|
+
customFetchImpl: any;
|
|
86
|
+
}, unknown, unknown, _better_fetch_fetch19.Schema>;
|
|
87
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,90 @@
|
|
|
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 hono48 from "hono";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import * as _better_fetch_fetch29 from "@better-fetch/fetch";
|
|
7
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
8
|
+
import { Accessor } from "solid-js";
|
|
9
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
10
|
+
export * from "@better-fetch/fetch";
|
|
11
|
+
export * from "nanostores";
|
|
12
|
+
|
|
13
|
+
//#region src/client/solid/index.d.ts
|
|
14
|
+
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]: () => Accessor<ReturnType<Atoms[key]["get"]>> } : {} : {} : {} : {};
|
|
15
|
+
declare const createAuthClient: <App extends AnyHono = DefaultApp>() => <Option extends ClientOptions>(options: Option) => UnionToIntersection<InferResolvedHooks<Option>> & (App extends Hono<any, infer S extends hono48.Schema, infer P extends string> ? Client<S, P, Option> : never) & InferActions<Option> & {
|
|
16
|
+
useSession: () => Accessor<{
|
|
17
|
+
data: App extends Hono<any, infer S_1 extends hono48.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
18
|
+
success: true;
|
|
19
|
+
})["data"] : never;
|
|
20
|
+
isPending: boolean;
|
|
21
|
+
isRefetching: boolean;
|
|
22
|
+
error: BetterFetchError | null;
|
|
23
|
+
}>;
|
|
24
|
+
$Infer: {
|
|
25
|
+
Session: NonNullable<App extends Hono<any, infer S_1 extends hono48.Schema, infer P_1 extends string> ? (S_1[`${P_1}/get-session`]["$get"]["output"] & {
|
|
26
|
+
success: true;
|
|
27
|
+
})["data"] : never>;
|
|
28
|
+
};
|
|
29
|
+
$fetch: _better_fetch_fetch29.BetterFetch<{
|
|
30
|
+
plugins: (_better_fetch_fetch29.BetterFetchPlugin | {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
hooks: {};
|
|
34
|
+
})[];
|
|
35
|
+
method: string;
|
|
36
|
+
output?: _better_fetch_fetch29.StandardSchemaV1 | typeof Blob | typeof File;
|
|
37
|
+
query?: any;
|
|
38
|
+
baseURL: string;
|
|
39
|
+
headers?: HeadersInit & (HeadersInit | {
|
|
40
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
41
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
42
|
+
authorization: "Bearer" | "Basic";
|
|
43
|
+
});
|
|
44
|
+
redirect?: RequestRedirect;
|
|
45
|
+
params?: any;
|
|
46
|
+
body?: any;
|
|
47
|
+
throw?: boolean;
|
|
48
|
+
auth?: {
|
|
49
|
+
type: "Bearer";
|
|
50
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
type: "Basic";
|
|
53
|
+
username: string | (() => string | undefined) | undefined;
|
|
54
|
+
password: string | (() => string | undefined) | undefined;
|
|
55
|
+
} | {
|
|
56
|
+
type: "Custom";
|
|
57
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
58
|
+
value: string | (() => string | undefined) | undefined;
|
|
59
|
+
};
|
|
60
|
+
window?: null;
|
|
61
|
+
cache?: RequestCache;
|
|
62
|
+
credentials?: RequestCredentials;
|
|
63
|
+
integrity?: string;
|
|
64
|
+
keepalive?: boolean;
|
|
65
|
+
mode?: RequestMode;
|
|
66
|
+
priority?: RequestPriority;
|
|
67
|
+
referrer?: string;
|
|
68
|
+
referrerPolicy?: ReferrerPolicy;
|
|
69
|
+
signal?: AbortSignal | null;
|
|
70
|
+
onRetry?: (response: _better_fetch_fetch29.ResponseContext) => Promise<void> | void;
|
|
71
|
+
hookOptions?: {
|
|
72
|
+
cloneResponse?: boolean;
|
|
73
|
+
};
|
|
74
|
+
timeout?: number;
|
|
75
|
+
duplex?: "full" | "half";
|
|
76
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
77
|
+
retry?: _better_fetch_fetch29.RetryOptions;
|
|
78
|
+
retryAttempt?: number;
|
|
79
|
+
errorSchema?: _better_fetch_fetch29.StandardSchemaV1;
|
|
80
|
+
disableValidation?: boolean;
|
|
81
|
+
catchAllError?: boolean;
|
|
82
|
+
defaultOutput?: _better_fetch_fetch29.StandardSchemaV1;
|
|
83
|
+
defaultError?: _better_fetch_fetch29.StandardSchemaV1;
|
|
84
|
+
schema?: _better_fetch_fetch29.Schema;
|
|
85
|
+
customFetchImpl: any;
|
|
86
|
+
}, unknown, unknown, _better_fetch_fetch29.Schema>;
|
|
87
|
+
$ERROR_CODES: Prettify<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { createStore, reconcile } from "solid-js/store";
|
|
7
|
+
import { onCleanup } from "solid-js";
|
|
8
|
+
|
|
9
|
+
//#region src/client/solid/solid-store.ts
|
|
10
|
+
/**
|
|
11
|
+
* Subscribes to store changes and gets store’s value.
|
|
12
|
+
*
|
|
13
|
+
* @param store Store instance.
|
|
14
|
+
* @returns Store value.
|
|
15
|
+
*/
|
|
16
|
+
function useStore(store) {
|
|
17
|
+
const unbindActivation = store.listen(() => {});
|
|
18
|
+
const [state, setState] = createStore({ value: store.get() });
|
|
19
|
+
const unsubscribe = store.subscribe((newValue) => {
|
|
20
|
+
setState("value", reconcile(newValue));
|
|
21
|
+
});
|
|
22
|
+
onCleanup(() => unsubscribe());
|
|
23
|
+
unbindActivation();
|
|
24
|
+
return () => state.value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/client/solid/index.ts
|
|
29
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
30
|
+
function getAtomKey(str) {
|
|
31
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
32
|
+
}
|
|
33
|
+
const createAuthClient = () => (options) => {
|
|
34
|
+
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
|
35
|
+
const { pluginsActions, pluginsAtoms, $fetch, atomListeners } = getClientConfig(options);
|
|
36
|
+
const resolvedHooks = {};
|
|
37
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
38
|
+
const routes = {
|
|
39
|
+
...pluginsActions,
|
|
40
|
+
...resolvedHooks
|
|
41
|
+
};
|
|
42
|
+
routes.useSession = () => useStore(pluginsAtoms.session);
|
|
43
|
+
return createHonoClient({
|
|
44
|
+
baseURL,
|
|
45
|
+
createFetchOptions: options.fetchOptions
|
|
46
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { createAuthClient };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_url = require('../../url-D2yvKaM7.cjs');
|
|
2
|
+
require('../../request-CPNlp-DK.cjs');
|
|
3
|
+
require('../../defu-B0Svx_x4.cjs');
|
|
4
|
+
const require_hono = require('../../hono-BEq1NYVX.cjs');
|
|
5
|
+
require('../../parser-CdncAl9i.cjs');
|
|
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 = require_url.getBaseURL(options.baseURL, options.basePath);
|
|
11
|
+
const { pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = require_hono.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 require_hono.createHonoClient({
|
|
22
|
+
baseURL,
|
|
23
|
+
createFetchOptions: options.fetchOptions
|
|
24
|
+
}, routes, $fetch, pluginsAtoms, atomListeners);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.createAuthClient = createAuthClient;
|
|
@@ -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-B-WeOMzg.cjs";
|
|
2
|
+
import "../../hono-DOM31WQz.cjs";
|
|
3
|
+
import * as _faire_auth_core_types38 from "@faire-auth/core/types";
|
|
4
|
+
import { AnyHono, Prettify, UnionToIntersection } from "@faire-auth/core/types";
|
|
5
|
+
import * as hono46 from "hono";
|
|
6
|
+
import { Hono } from "hono";
|
|
7
|
+
import * as _faire_auth_core_db3 from "@faire-auth/core/db";
|
|
8
|
+
import { BASE_ERROR_CODES } from "@faire-auth/core/error";
|
|
9
|
+
import * as _better_fetch_fetch29 from "@better-fetch/fetch";
|
|
10
|
+
import { BetterFetchError } from "@better-fetch/fetch";
|
|
11
|
+
import * as nanostores5 from "nanostores";
|
|
12
|
+
import { Atom } from "nanostores";
|
|
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 hono46.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 hono46.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_fetch29.BetterFetch<{
|
|
28
|
+
plugins: (_better_fetch_fetch29.BetterFetchPlugin | {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
hooks: {};
|
|
32
|
+
})[];
|
|
33
|
+
method: string;
|
|
34
|
+
output?: _better_fetch_fetch29.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_fetch29.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_fetch29.RetryOptions;
|
|
76
|
+
retryAttempt?: number;
|
|
77
|
+
errorSchema?: _better_fetch_fetch29.StandardSchemaV1;
|
|
78
|
+
disableValidation?: boolean;
|
|
79
|
+
catchAllError?: boolean;
|
|
80
|
+
defaultOutput?: _better_fetch_fetch29.StandardSchemaV1;
|
|
81
|
+
defaultError?: _better_fetch_fetch29.StandardSchemaV1;
|
|
82
|
+
schema?: _better_fetch_fetch29.Schema;
|
|
83
|
+
customFetchImpl: any;
|
|
84
|
+
}, unknown, unknown, _better_fetch_fetch29.Schema>;
|
|
85
|
+
$store: {
|
|
86
|
+
notify: (signal?: _faire_auth_core_types38.LiteralStringUnion<"$sessionSignal">) => void;
|
|
87
|
+
listen: (signal: _faire_auth_core_types38.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 hono46.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 };
|