authula 0.7.16 → 0.8.0-beta.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.
Potentially problematic release.
This version of authula might be problematic. Click here for more details.
- package/README.md +196 -40
- package/dist/{index.js → core-Csdt31Tx.js} +6 -17
- package/dist/core-Csdt31Tx.js.map +1 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.js +4 -0
- package/dist/{custom-fetch-CXJ4-i7I.js → custom-fetch-DJxn7nVP.js} +26 -10
- package/dist/custom-fetch-DJxn7nVP.js.map +1 -0
- package/dist/framework-client-CsGjKPXl.d.ts +8 -0
- package/dist/framework-client-D-yGjqAx.js +50 -0
- package/dist/framework-client-D-yGjqAx.js.map +1 -0
- package/dist/{index-xeVPFZn7.d.ts → index-Cuok0NWW.d.ts} +2 -448
- package/dist/models.d.ts +2 -0
- package/dist/models.js +11 -0
- package/dist/models.js.map +1 -0
- package/dist/plugins.d.ts +513 -0
- package/dist/plugins.js +2472 -0
- package/dist/plugins.js.map +1 -0
- package/dist/react.d.ts +3728 -0
- package/dist/{plugins/index.js → react.js} +975 -1256
- package/dist/react.js.map +1 -0
- package/dist/{rolldown-runtime-w6R9maHv.js → rolldown-runtime-CNh9ExCG.js} +1 -2
- package/dist/sdk-Cu28BXFh.d.ts +102 -0
- package/dist/solid.d.ts +3955 -0
- package/dist/solid.js +5461 -0
- package/dist/solid.js.map +1 -0
- package/dist/svelte.d.ts +3368 -0
- package/dist/svelte.js +5500 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.d.ts +3289 -0
- package/dist/vue.js +5644 -0
- package/dist/vue.js.map +1 -0
- package/dist/zod.d.ts +3862 -0
- package/dist/zod.js +1480 -0
- package/dist/zod.js.map +1 -0
- package/package.json +61 -9
- package/dist/custom-fetch-CXJ4-i7I.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -4908
- package/dist/plugins/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __exportAll = (all, no_symbols) => {
|
|
4
4
|
let target = {};
|
|
@@ -14,5 +14,4 @@ var __exportAll = (all, no_symbols) => {
|
|
|
14
14
|
return target;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
export { __exportAll as t };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
type FetchContext = {
|
|
2
|
+
url: string;
|
|
3
|
+
init: RequestInit;
|
|
4
|
+
/** internal metadata for plugins */
|
|
5
|
+
meta: {
|
|
6
|
+
retry?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** resolved cookies available during the request lifecycle */
|
|
9
|
+
cookies?: Record<string, string | undefined>;
|
|
10
|
+
};
|
|
11
|
+
type BeforeFetchHook = (ctx: FetchContext) => Promise<void> | void;
|
|
12
|
+
type AfterFetchHook = (ctx: FetchContext, res: Response) => Promise<"retry" | void> | "retry" | void;
|
|
13
|
+
declare class AuthulaClient {
|
|
14
|
+
readonly config: AuthulaClientConfig;
|
|
15
|
+
private readonly plugins;
|
|
16
|
+
private readonly beforeFetchHooks;
|
|
17
|
+
private readonly afterFetchHooks;
|
|
18
|
+
constructor(options: AuthulaClientOptions);
|
|
19
|
+
registerBeforeFetch(hook: BeforeFetchHook): void;
|
|
20
|
+
registerAfterFetch(hook: AfterFetchHook): void;
|
|
21
|
+
runBeforeFetch(ctx: FetchContext): Promise<void>;
|
|
22
|
+
runAfterFetch(ctx: FetchContext, res: Response): Promise<"retry" | undefined>;
|
|
23
|
+
getPlugin<T extends Plugin>(id: string): T | undefined;
|
|
24
|
+
getCookie(name: string): Promise<string | undefined>;
|
|
25
|
+
getAllCookies(): Promise<Record<string, string | undefined> | undefined>;
|
|
26
|
+
}
|
|
27
|
+
interface Plugin {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
init(client: AuthulaClient): any;
|
|
30
|
+
}
|
|
31
|
+
type FetchOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Additional headers to include in every request made by the client
|
|
34
|
+
*/
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* The abort timeout in seconds
|
|
38
|
+
*/
|
|
39
|
+
abortTimeout?: number;
|
|
40
|
+
};
|
|
41
|
+
type CookieAttributes = {
|
|
42
|
+
path?: string;
|
|
43
|
+
domain?: string;
|
|
44
|
+
expires?: Date;
|
|
45
|
+
maxAge?: number;
|
|
46
|
+
httpOnly?: boolean;
|
|
47
|
+
secure?: boolean;
|
|
48
|
+
sameSite?: "lax" | "strict" | "none";
|
|
49
|
+
};
|
|
50
|
+
interface CookieStore {
|
|
51
|
+
getAll(): {
|
|
52
|
+
name: string;
|
|
53
|
+
value: string;
|
|
54
|
+
}[];
|
|
55
|
+
set(name: string, value: string, options?: CookieAttributes): void;
|
|
56
|
+
}
|
|
57
|
+
type AuthulaClientConfig = {
|
|
58
|
+
/**
|
|
59
|
+
* The URL of your Authula server
|
|
60
|
+
* @example 'http://localhost:8080/api/auth'
|
|
61
|
+
*/
|
|
62
|
+
url: string;
|
|
63
|
+
fetchOptions?: FetchOptions;
|
|
64
|
+
/**
|
|
65
|
+
* Optional cookie store for SSR environments.
|
|
66
|
+
* In the browser, cookies are handled automatically via document.cookie.
|
|
67
|
+
* In SSR (Next.js, Tanstack Start, etc.), provide a function that returns a CookieStore
|
|
68
|
+
* compatible with the framework's cookies API.
|
|
69
|
+
*
|
|
70
|
+
* @example Next.js
|
|
71
|
+
* cookies: () => import('next/headers').then(m => m.cookies())
|
|
72
|
+
*/
|
|
73
|
+
cookies?: () => CookieStore | Promise<CookieStore>;
|
|
74
|
+
};
|
|
75
|
+
type AuthulaClientOptions = AuthulaClientConfig & {
|
|
76
|
+
/**
|
|
77
|
+
* The list of plugins to use
|
|
78
|
+
*/
|
|
79
|
+
plugins: Array<Plugin>;
|
|
80
|
+
};
|
|
81
|
+
declare class ApiError extends Error {
|
|
82
|
+
status: number;
|
|
83
|
+
data: any;
|
|
84
|
+
headers: Headers;
|
|
85
|
+
constructor(message: string, status: number, data: any, headers: Headers);
|
|
86
|
+
}
|
|
87
|
+
declare function customFetch<T>(url: string, options?: RequestInit & {
|
|
88
|
+
method?: string;
|
|
89
|
+
baseUrl?: string;
|
|
90
|
+
cookies?: () => CookieStore | Promise<CookieStore>;
|
|
91
|
+
onBeforeFetch?: (ctx: FetchContext) => Promise<void>;
|
|
92
|
+
onAfterFetch?: (ctx: FetchContext, res: Response) => Promise<"retry" | void>;
|
|
93
|
+
}): Promise<T>;
|
|
94
|
+
type InferPluginMethods<P> = P extends {
|
|
95
|
+
init: (client: any) => infer M;
|
|
96
|
+
} ? M : never;
|
|
97
|
+
type ClientWithPlugins<T extends readonly Plugin[]> = AuthulaClient & { [P in T[number] as P["id"]]: InferPluginMethods<P>; };
|
|
98
|
+
declare function createClient<const T extends readonly Plugin[]>(options: Omit<AuthulaClientOptions, "plugins"> & {
|
|
99
|
+
plugins: T;
|
|
100
|
+
}): ClientWithPlugins<T>;
|
|
101
|
+
export { customFetch as a, CookieAttributes as c, Plugin as d, AuthulaClient as f, FetchContext as h, ApiError as i, CookieStore as l, BeforeFetchHook as m, InferPluginMethods as n, AuthulaClientConfig as o, AfterFetchHook as p, createClient as r, AuthulaClientOptions as s, ClientWithPlugins as t, FetchOptions as u };
|
|
102
|
+
//# sourceMappingURL=sdk-Cu28BXFh.d.ts.map
|