@razakalpha/convngx 0.2.4 → 0.2.6
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/fesm2022/razakalpha-convngx.mjs +761 -0
- package/fesm2022/razakalpha-convngx.mjs.map +1 -0
- package/package.json +26 -26
- package/types/razakalpha-convngx.d.ts +990 -0
- package/ng-package.json +0 -7
- package/src/lib/auth/auth-client.provider.ts +0 -35
- package/src/lib/auth/convex-better-auth.provider.ts +0 -110
- package/src/lib/convex-angular.spec.ts +0 -23
- package/src/lib/convex-angular.ts +0 -15
- package/src/lib/core/convex-angular-client.ts +0 -351
- package/src/lib/core/helpers.ts +0 -60
- package/src/lib/core/inject-convex.token.ts +0 -12
- package/src/lib/core/types.ts +0 -14
- package/src/lib/resources/action.resource.ts +0 -153
- package/src/lib/resources/live.resource.ts +0 -149
- package/src/lib/resources/mutation.resource.ts +0 -171
- package/src/lib/setup/convex-angular.providers.ts +0 -66
- package/src/public-api.ts +0 -19
- package/tsconfig.lib.json +0 -20
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -14
|
@@ -0,0 +1,990 @@
|
|
|
1
|
+
import { BaseConvexClientOptions, OptimisticUpdate } from 'convex/browser';
|
|
2
|
+
import { FunctionReference, FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
3
|
+
import * as _angular_core from '@angular/core';
|
|
4
|
+
import { InjectionToken, Provider, ResourceRef, Signal } from '@angular/core';
|
|
5
|
+
import * as nanostores from 'nanostores';
|
|
6
|
+
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
7
|
+
import * as jose from 'jose';
|
|
8
|
+
import * as better_auth from 'better-auth';
|
|
9
|
+
import { createAuthClient } from 'better-auth/client';
|
|
10
|
+
import { convexClient, crossDomainClient } from '@convex-dev/better-auth/client/plugins';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Shared types for Convex Angular core.
|
|
14
|
+
* Pure extraction for readability; no behavior changes.
|
|
15
|
+
*/
|
|
16
|
+
/** Auth token fetcher used by ConvexAngularClient.setAuth */
|
|
17
|
+
type FetchAccessToken = (o: {
|
|
18
|
+
forceRefreshToken: boolean;
|
|
19
|
+
}) => Promise<string | null>;
|
|
20
|
+
/** Snapshot of current auth state (token presence-based) */
|
|
21
|
+
type AuthSnapshot = {
|
|
22
|
+
isAuthenticated: boolean;
|
|
23
|
+
token: string | null;
|
|
24
|
+
exp?: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ConvexAngularClient
|
|
29
|
+
* - Wraps Convex BaseConvexClient + ConvexHttpClient
|
|
30
|
+
* - Integrates Better Auth via pluggable fetcher (setAuth)
|
|
31
|
+
* - Caches JWT in sessionStorage with BroadcastChannel sync
|
|
32
|
+
* - Auto-refreshes auth token ahead of expiry with jitter
|
|
33
|
+
* - Provides:
|
|
34
|
+
* - watchQuery: live subscription with localQueryResult + onUpdate
|
|
35
|
+
* - query: HTTP one-shot with in-flight de-dupe + 401 retry
|
|
36
|
+
* - mutation: supports optimisticUpdate passthrough
|
|
37
|
+
* - action: HTTP call with 401 retry
|
|
38
|
+
* - Does not change any runtime behavior – documentation and structure only.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type WatchHandle<Q extends FunctionReference<'query'>> = {
|
|
42
|
+
localQueryResult(): FunctionReturnType<Q> | undefined;
|
|
43
|
+
onUpdate(cb: () => void): () => void;
|
|
44
|
+
unsubscribe(): void;
|
|
45
|
+
};
|
|
46
|
+
declare class ConvexAngularClient {
|
|
47
|
+
private authListeners;
|
|
48
|
+
private lastSnap?;
|
|
49
|
+
private emitAuth;
|
|
50
|
+
private base;
|
|
51
|
+
private http;
|
|
52
|
+
private byToken;
|
|
53
|
+
private fetchToken?;
|
|
54
|
+
private inflightToken?;
|
|
55
|
+
private token?;
|
|
56
|
+
private refreshTimer?;
|
|
57
|
+
private inflightHttp;
|
|
58
|
+
private authLocked;
|
|
59
|
+
private readonly skewMs;
|
|
60
|
+
constructor(url: string, opts?: BaseConvexClientOptions & {
|
|
61
|
+
authSkewMs?: number;
|
|
62
|
+
});
|
|
63
|
+
setAuth(fetcher: FetchAccessToken): void;
|
|
64
|
+
/** Optional: call once on app start */
|
|
65
|
+
warmAuth(): Promise<void>;
|
|
66
|
+
private freshTokenInCache;
|
|
67
|
+
onAuth(cb: (s: AuthSnapshot) => void): () => void;
|
|
68
|
+
logoutLocal(lock?: boolean): void;
|
|
69
|
+
getAuthSnapshot(): {
|
|
70
|
+
isAuthenticated: boolean;
|
|
71
|
+
token: string | null;
|
|
72
|
+
exp: number | undefined;
|
|
73
|
+
};
|
|
74
|
+
/** Allow re-auth then fetch a fresh token (use after successful sign-in) */
|
|
75
|
+
refreshAuth(): Promise<void>;
|
|
76
|
+
private applyToken;
|
|
77
|
+
private scheduleRefresh;
|
|
78
|
+
private getToken;
|
|
79
|
+
private ensureHttpAuth;
|
|
80
|
+
watchQuery<Q extends FunctionReference<'query'>>(q: Q, args: FunctionArgs<Q>): WatchHandle<Q>;
|
|
81
|
+
mutation<M extends FunctionReference<'mutation'>>(m: M, args: FunctionArgs<M>, opts?: {
|
|
82
|
+
optimisticUpdate?: OptimisticUpdate<FunctionArgs<M>>;
|
|
83
|
+
}): Promise<FunctionReturnType<M>>;
|
|
84
|
+
action<A extends FunctionReference<'action'> & {
|
|
85
|
+
_args: Record<string, never>;
|
|
86
|
+
}>(a: A): Promise<FunctionReturnType<A>>;
|
|
87
|
+
action<A extends FunctionReference<'action'>>(a: A, args: FunctionArgs<A>): Promise<FunctionReturnType<A>>;
|
|
88
|
+
query<Q extends FunctionReference<'query'> & {
|
|
89
|
+
_args: Record<string, never>;
|
|
90
|
+
}>(q: Q): Promise<FunctionReturnType<Q>>;
|
|
91
|
+
query<Q extends FunctionReference<'query'>>(q: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Injection token and helper for accessing the Convex client from DI.
|
|
96
|
+
* Keep this tiny and stable — many helpers rely on it.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/** DI token for the configured ConvexAngularClient instance */
|
|
100
|
+
declare const CONVEX: InjectionToken<ConvexAngularClient>;
|
|
101
|
+
/** Convenience helper to inject the Convex client */
|
|
102
|
+
declare const injectConvex: () => ConvexAngularClient;
|
|
103
|
+
|
|
104
|
+
type AuthConfig = {
|
|
105
|
+
baseURL: string;
|
|
106
|
+
plugins: [ReturnType<typeof convexClient>, ReturnType<typeof crossDomainClient>];
|
|
107
|
+
fetchOptions: {
|
|
108
|
+
credentials: 'include';
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
type AuthClient = ReturnType<typeof createAuthClient<AuthConfig>>;
|
|
112
|
+
interface ProvideAuthClientOptions {
|
|
113
|
+
baseURL: string;
|
|
114
|
+
fetchOptions?: RequestInit;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Un-typed DI token. We don't re-export types; callers who create the client
|
|
118
|
+
* get full type safety from better-auth directly.
|
|
119
|
+
*/
|
|
120
|
+
declare const AUTH_CLIENT: InjectionToken<{
|
|
121
|
+
convex: {
|
|
122
|
+
jwks: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
123
|
+
query?: Record<string, any> | undefined;
|
|
124
|
+
fetchOptions?: FetchOptions | undefined;
|
|
125
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<jose.JSONWebKeySet, {
|
|
126
|
+
code?: string | undefined;
|
|
127
|
+
message?: string | undefined;
|
|
128
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
129
|
+
};
|
|
130
|
+
} & {
|
|
131
|
+
convex: {
|
|
132
|
+
token: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
133
|
+
query?: Record<string, any> | undefined;
|
|
134
|
+
fetchOptions?: FetchOptions | undefined;
|
|
135
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
136
|
+
token: string;
|
|
137
|
+
}, {
|
|
138
|
+
code?: string | undefined;
|
|
139
|
+
message?: string | undefined;
|
|
140
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
141
|
+
};
|
|
142
|
+
} & {
|
|
143
|
+
crossDomain: {
|
|
144
|
+
oneTimeToken: {
|
|
145
|
+
verify: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
146
|
+
token: string;
|
|
147
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
148
|
+
token: string;
|
|
149
|
+
} & {
|
|
150
|
+
fetchOptions?: FetchOptions | undefined;
|
|
151
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
152
|
+
session: better_auth.Session & Record<string, any>;
|
|
153
|
+
user: better_auth.User & Record<string, any>;
|
|
154
|
+
}, {
|
|
155
|
+
code?: string | undefined;
|
|
156
|
+
message?: string | undefined;
|
|
157
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
} & {
|
|
161
|
+
signIn: {
|
|
162
|
+
social: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
163
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
164
|
+
callbackURL?: string | undefined;
|
|
165
|
+
newUserCallbackURL?: string | undefined;
|
|
166
|
+
errorCallbackURL?: string | undefined;
|
|
167
|
+
disableRedirect?: boolean | undefined;
|
|
168
|
+
idToken?: {
|
|
169
|
+
token: string;
|
|
170
|
+
nonce?: string | undefined;
|
|
171
|
+
accessToken?: string | undefined;
|
|
172
|
+
refreshToken?: string | undefined;
|
|
173
|
+
expiresAt?: number | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
scopes?: string[] | undefined;
|
|
176
|
+
requestSignUp?: boolean | undefined;
|
|
177
|
+
loginHint?: string | undefined;
|
|
178
|
+
additionalData?: Record<string, any> | undefined;
|
|
179
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
180
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
181
|
+
callbackURL?: string | undefined;
|
|
182
|
+
newUserCallbackURL?: string | undefined;
|
|
183
|
+
errorCallbackURL?: string | undefined;
|
|
184
|
+
disableRedirect?: boolean | undefined;
|
|
185
|
+
idToken?: {
|
|
186
|
+
token: string;
|
|
187
|
+
nonce?: string | undefined;
|
|
188
|
+
accessToken?: string | undefined;
|
|
189
|
+
refreshToken?: string | undefined;
|
|
190
|
+
expiresAt?: number | undefined;
|
|
191
|
+
} | undefined;
|
|
192
|
+
scopes?: string[] | undefined;
|
|
193
|
+
requestSignUp?: boolean | undefined;
|
|
194
|
+
loginHint?: string | undefined;
|
|
195
|
+
additionalData?: Record<string, any> | undefined;
|
|
196
|
+
} & {
|
|
197
|
+
fetchOptions?: FetchOptions | undefined;
|
|
198
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<NonNullable<{
|
|
199
|
+
redirect: boolean;
|
|
200
|
+
url: string;
|
|
201
|
+
} | {
|
|
202
|
+
redirect: boolean;
|
|
203
|
+
token: string;
|
|
204
|
+
url: undefined;
|
|
205
|
+
user: {
|
|
206
|
+
id: string;
|
|
207
|
+
createdAt: Date;
|
|
208
|
+
updatedAt: Date;
|
|
209
|
+
email: string;
|
|
210
|
+
emailVerified: boolean;
|
|
211
|
+
name: string;
|
|
212
|
+
image?: string | null | undefined | undefined;
|
|
213
|
+
};
|
|
214
|
+
}>, {
|
|
215
|
+
code?: string | undefined;
|
|
216
|
+
message?: string | undefined;
|
|
217
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
218
|
+
};
|
|
219
|
+
} & {
|
|
220
|
+
signOut: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
221
|
+
query?: Record<string, any> | undefined;
|
|
222
|
+
fetchOptions?: FetchOptions | undefined;
|
|
223
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
224
|
+
success: boolean;
|
|
225
|
+
}, {
|
|
226
|
+
code?: string | undefined;
|
|
227
|
+
message?: string | undefined;
|
|
228
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
229
|
+
} & {
|
|
230
|
+
signUp: {
|
|
231
|
+
email: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
232
|
+
name: string;
|
|
233
|
+
email: string;
|
|
234
|
+
password: string;
|
|
235
|
+
image?: string | undefined;
|
|
236
|
+
callbackURL?: string | undefined;
|
|
237
|
+
rememberMe?: boolean | undefined;
|
|
238
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
239
|
+
email: string;
|
|
240
|
+
name: string;
|
|
241
|
+
password: string;
|
|
242
|
+
image?: string | undefined;
|
|
243
|
+
callbackURL?: string | undefined;
|
|
244
|
+
fetchOptions?: FetchOptions | undefined;
|
|
245
|
+
} & {} & {}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<NonNullable<{
|
|
246
|
+
token: null;
|
|
247
|
+
user: {
|
|
248
|
+
id: string;
|
|
249
|
+
createdAt: Date;
|
|
250
|
+
updatedAt: Date;
|
|
251
|
+
email: string;
|
|
252
|
+
emailVerified: boolean;
|
|
253
|
+
name: string;
|
|
254
|
+
image?: string | null | undefined | undefined;
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
token: string;
|
|
258
|
+
user: {
|
|
259
|
+
id: string;
|
|
260
|
+
createdAt: Date;
|
|
261
|
+
updatedAt: Date;
|
|
262
|
+
email: string;
|
|
263
|
+
emailVerified: boolean;
|
|
264
|
+
name: string;
|
|
265
|
+
image?: string | null | undefined | undefined;
|
|
266
|
+
};
|
|
267
|
+
}>, {
|
|
268
|
+
code?: string | undefined;
|
|
269
|
+
message?: string | undefined;
|
|
270
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
271
|
+
};
|
|
272
|
+
} & {
|
|
273
|
+
signIn: {
|
|
274
|
+
email: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
275
|
+
email: string;
|
|
276
|
+
password: string;
|
|
277
|
+
callbackURL?: string | undefined;
|
|
278
|
+
rememberMe?: boolean | undefined;
|
|
279
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
280
|
+
email: string;
|
|
281
|
+
password: string;
|
|
282
|
+
callbackURL?: string | undefined;
|
|
283
|
+
rememberMe?: boolean | undefined;
|
|
284
|
+
} & {
|
|
285
|
+
fetchOptions?: FetchOptions | undefined;
|
|
286
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
287
|
+
redirect: boolean;
|
|
288
|
+
token: string;
|
|
289
|
+
url?: string | undefined;
|
|
290
|
+
user: {
|
|
291
|
+
id: string;
|
|
292
|
+
createdAt: Date;
|
|
293
|
+
updatedAt: Date;
|
|
294
|
+
email: string;
|
|
295
|
+
emailVerified: boolean;
|
|
296
|
+
name: string;
|
|
297
|
+
image?: string | null | undefined | undefined;
|
|
298
|
+
};
|
|
299
|
+
}, {
|
|
300
|
+
code?: string | undefined;
|
|
301
|
+
message?: string | undefined;
|
|
302
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
303
|
+
};
|
|
304
|
+
} & {
|
|
305
|
+
resetPassword: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
306
|
+
newPassword: string;
|
|
307
|
+
token?: string | undefined;
|
|
308
|
+
}> & Record<string, any>, Partial<{
|
|
309
|
+
token?: string | undefined;
|
|
310
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
311
|
+
newPassword: string;
|
|
312
|
+
token?: string | undefined;
|
|
313
|
+
} & {
|
|
314
|
+
fetchOptions?: FetchOptions | undefined;
|
|
315
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
316
|
+
status: boolean;
|
|
317
|
+
}, {
|
|
318
|
+
code?: string | undefined;
|
|
319
|
+
message?: string | undefined;
|
|
320
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
321
|
+
} & {
|
|
322
|
+
verifyEmail: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<{
|
|
323
|
+
token: string;
|
|
324
|
+
callbackURL?: string | undefined;
|
|
325
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
326
|
+
query: {
|
|
327
|
+
token: string;
|
|
328
|
+
callbackURL?: string | undefined;
|
|
329
|
+
};
|
|
330
|
+
fetchOptions?: FetchOptions | undefined;
|
|
331
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<NonNullable<void | {
|
|
332
|
+
status: boolean;
|
|
333
|
+
}>, {
|
|
334
|
+
code?: string | undefined;
|
|
335
|
+
message?: string | undefined;
|
|
336
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
337
|
+
} & {
|
|
338
|
+
sendVerificationEmail: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
339
|
+
email: string;
|
|
340
|
+
callbackURL?: string | undefined;
|
|
341
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
342
|
+
email: string;
|
|
343
|
+
callbackURL?: string | undefined;
|
|
344
|
+
} & {
|
|
345
|
+
fetchOptions?: FetchOptions | undefined;
|
|
346
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
347
|
+
status: boolean;
|
|
348
|
+
}, {
|
|
349
|
+
code?: string | undefined;
|
|
350
|
+
message?: string | undefined;
|
|
351
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
352
|
+
} & {
|
|
353
|
+
changeEmail: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
354
|
+
newEmail: string;
|
|
355
|
+
callbackURL?: string | undefined;
|
|
356
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
357
|
+
newEmail: string;
|
|
358
|
+
callbackURL?: string | undefined;
|
|
359
|
+
} & {
|
|
360
|
+
fetchOptions?: FetchOptions | undefined;
|
|
361
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
362
|
+
status: boolean;
|
|
363
|
+
}, {
|
|
364
|
+
code?: string | undefined;
|
|
365
|
+
message?: string | undefined;
|
|
366
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
367
|
+
} & {
|
|
368
|
+
changePassword: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
369
|
+
newPassword: string;
|
|
370
|
+
currentPassword: string;
|
|
371
|
+
revokeOtherSessions?: boolean | undefined;
|
|
372
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
373
|
+
newPassword: string;
|
|
374
|
+
currentPassword: string;
|
|
375
|
+
revokeOtherSessions?: boolean | undefined;
|
|
376
|
+
} & {
|
|
377
|
+
fetchOptions?: FetchOptions | undefined;
|
|
378
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
379
|
+
token: string | null;
|
|
380
|
+
user: {
|
|
381
|
+
id: string;
|
|
382
|
+
email: string;
|
|
383
|
+
name: string;
|
|
384
|
+
image: string | null | undefined;
|
|
385
|
+
emailVerified: boolean;
|
|
386
|
+
createdAt: Date;
|
|
387
|
+
updatedAt: Date;
|
|
388
|
+
};
|
|
389
|
+
}, {
|
|
390
|
+
code?: string | undefined;
|
|
391
|
+
message?: string | undefined;
|
|
392
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
393
|
+
} & {
|
|
394
|
+
updateUser: <FetchOptions extends better_auth.ClientFetchOption<Partial<Partial<{}> & {
|
|
395
|
+
name?: string | undefined;
|
|
396
|
+
image?: string | undefined | null;
|
|
397
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
398
|
+
image?: (string | null) | undefined;
|
|
399
|
+
name?: string | undefined;
|
|
400
|
+
fetchOptions?: FetchOptions | undefined;
|
|
401
|
+
} & Partial<{} & {}>> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
402
|
+
status: boolean;
|
|
403
|
+
}, {
|
|
404
|
+
code?: string | undefined;
|
|
405
|
+
message?: string | undefined;
|
|
406
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
407
|
+
} & {
|
|
408
|
+
deleteUser: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
409
|
+
callbackURL?: string | undefined;
|
|
410
|
+
password?: string | undefined;
|
|
411
|
+
token?: string | undefined;
|
|
412
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
413
|
+
callbackURL?: string | undefined;
|
|
414
|
+
password?: string | undefined;
|
|
415
|
+
token?: string | undefined;
|
|
416
|
+
} & {
|
|
417
|
+
fetchOptions?: FetchOptions | undefined;
|
|
418
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
419
|
+
success: boolean;
|
|
420
|
+
message: string;
|
|
421
|
+
}, {
|
|
422
|
+
code?: string | undefined;
|
|
423
|
+
message?: string | undefined;
|
|
424
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
425
|
+
} & {
|
|
426
|
+
requestPasswordReset: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
427
|
+
email: string;
|
|
428
|
+
redirectTo?: string | undefined;
|
|
429
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
430
|
+
email: string;
|
|
431
|
+
redirectTo?: string | undefined;
|
|
432
|
+
} & {
|
|
433
|
+
fetchOptions?: FetchOptions | undefined;
|
|
434
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
435
|
+
status: boolean;
|
|
436
|
+
message: string;
|
|
437
|
+
}, {
|
|
438
|
+
code?: string | undefined;
|
|
439
|
+
message?: string | undefined;
|
|
440
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
441
|
+
} & {
|
|
442
|
+
resetPassword: {
|
|
443
|
+
":token": <FetchOptions extends better_auth.ClientFetchOption<never, Partial<{
|
|
444
|
+
callbackURL: string;
|
|
445
|
+
}> & Record<string, any>, {
|
|
446
|
+
token: string;
|
|
447
|
+
}>>(data_0: better_auth.Prettify<{
|
|
448
|
+
query: {
|
|
449
|
+
callbackURL: string;
|
|
450
|
+
};
|
|
451
|
+
fetchOptions?: FetchOptions | undefined;
|
|
452
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<never, {
|
|
453
|
+
code?: string | undefined;
|
|
454
|
+
message?: string | undefined;
|
|
455
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
456
|
+
};
|
|
457
|
+
} & {
|
|
458
|
+
listSessions: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
459
|
+
query?: Record<string, any> | undefined;
|
|
460
|
+
fetchOptions?: FetchOptions | undefined;
|
|
461
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<better_auth.Prettify<{
|
|
462
|
+
id: string;
|
|
463
|
+
createdAt: Date;
|
|
464
|
+
updatedAt: Date;
|
|
465
|
+
userId: string;
|
|
466
|
+
expiresAt: Date;
|
|
467
|
+
token: string;
|
|
468
|
+
ipAddress?: string | null | undefined | undefined;
|
|
469
|
+
userAgent?: string | null | undefined | undefined;
|
|
470
|
+
}>[], {
|
|
471
|
+
code?: string | undefined;
|
|
472
|
+
message?: string | undefined;
|
|
473
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
474
|
+
} & {
|
|
475
|
+
revokeSession: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
476
|
+
token: string;
|
|
477
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
478
|
+
token: string;
|
|
479
|
+
} & {
|
|
480
|
+
fetchOptions?: FetchOptions | undefined;
|
|
481
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
482
|
+
status: boolean;
|
|
483
|
+
}, {
|
|
484
|
+
code?: string | undefined;
|
|
485
|
+
message?: string | undefined;
|
|
486
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
487
|
+
} & {
|
|
488
|
+
revokeSessions: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
489
|
+
query?: Record<string, any> | undefined;
|
|
490
|
+
fetchOptions?: FetchOptions | undefined;
|
|
491
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
492
|
+
status: boolean;
|
|
493
|
+
}, {
|
|
494
|
+
code?: string | undefined;
|
|
495
|
+
message?: string | undefined;
|
|
496
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
497
|
+
} & {
|
|
498
|
+
revokeOtherSessions: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
499
|
+
query?: Record<string, any> | undefined;
|
|
500
|
+
fetchOptions?: FetchOptions | undefined;
|
|
501
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
502
|
+
status: boolean;
|
|
503
|
+
}, {
|
|
504
|
+
code?: string | undefined;
|
|
505
|
+
message?: string | undefined;
|
|
506
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
507
|
+
} & {
|
|
508
|
+
linkSocial: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
509
|
+
provider: unknown;
|
|
510
|
+
callbackURL?: string | undefined;
|
|
511
|
+
idToken?: {
|
|
512
|
+
token: string;
|
|
513
|
+
nonce?: string | undefined;
|
|
514
|
+
accessToken?: string | undefined;
|
|
515
|
+
refreshToken?: string | undefined;
|
|
516
|
+
scopes?: string[] | undefined;
|
|
517
|
+
} | undefined;
|
|
518
|
+
requestSignUp?: boolean | undefined;
|
|
519
|
+
scopes?: string[] | undefined;
|
|
520
|
+
errorCallbackURL?: string | undefined;
|
|
521
|
+
disableRedirect?: boolean | undefined;
|
|
522
|
+
additionalData?: Record<string, any> | undefined;
|
|
523
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
524
|
+
provider: unknown;
|
|
525
|
+
callbackURL?: string | undefined;
|
|
526
|
+
idToken?: {
|
|
527
|
+
token: string;
|
|
528
|
+
nonce?: string | undefined;
|
|
529
|
+
accessToken?: string | undefined;
|
|
530
|
+
refreshToken?: string | undefined;
|
|
531
|
+
scopes?: string[] | undefined;
|
|
532
|
+
} | undefined;
|
|
533
|
+
requestSignUp?: boolean | undefined;
|
|
534
|
+
scopes?: string[] | undefined;
|
|
535
|
+
errorCallbackURL?: string | undefined;
|
|
536
|
+
disableRedirect?: boolean | undefined;
|
|
537
|
+
additionalData?: Record<string, any> | undefined;
|
|
538
|
+
} & {
|
|
539
|
+
fetchOptions?: FetchOptions | undefined;
|
|
540
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
541
|
+
url: string;
|
|
542
|
+
redirect: boolean;
|
|
543
|
+
}, {
|
|
544
|
+
code?: string | undefined;
|
|
545
|
+
message?: string | undefined;
|
|
546
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
547
|
+
} & {
|
|
548
|
+
listAccounts: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
549
|
+
query?: Record<string, any> | undefined;
|
|
550
|
+
fetchOptions?: FetchOptions | undefined;
|
|
551
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
552
|
+
id: string;
|
|
553
|
+
providerId: string;
|
|
554
|
+
createdAt: Date;
|
|
555
|
+
updatedAt: Date;
|
|
556
|
+
accountId: string;
|
|
557
|
+
userId: string;
|
|
558
|
+
scopes: string[];
|
|
559
|
+
}[], {
|
|
560
|
+
code?: string | undefined;
|
|
561
|
+
message?: string | undefined;
|
|
562
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
563
|
+
} & {
|
|
564
|
+
deleteUser: {
|
|
565
|
+
callback: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<{
|
|
566
|
+
token: string;
|
|
567
|
+
callbackURL?: string | undefined;
|
|
568
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
569
|
+
query: {
|
|
570
|
+
token: string;
|
|
571
|
+
callbackURL?: string | undefined;
|
|
572
|
+
};
|
|
573
|
+
fetchOptions?: FetchOptions | undefined;
|
|
574
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
575
|
+
success: boolean;
|
|
576
|
+
message: string;
|
|
577
|
+
}, {
|
|
578
|
+
code?: string | undefined;
|
|
579
|
+
message?: string | undefined;
|
|
580
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
581
|
+
};
|
|
582
|
+
} & {
|
|
583
|
+
unlinkAccount: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
584
|
+
providerId: string;
|
|
585
|
+
accountId?: string | undefined;
|
|
586
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
587
|
+
providerId: string;
|
|
588
|
+
accountId?: string | undefined;
|
|
589
|
+
} & {
|
|
590
|
+
fetchOptions?: FetchOptions | undefined;
|
|
591
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
592
|
+
status: boolean;
|
|
593
|
+
}, {
|
|
594
|
+
code?: string | undefined;
|
|
595
|
+
message?: string | undefined;
|
|
596
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
597
|
+
} & {
|
|
598
|
+
refreshToken: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
599
|
+
providerId: string;
|
|
600
|
+
accountId?: string | undefined;
|
|
601
|
+
userId?: string | undefined;
|
|
602
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
603
|
+
providerId: string;
|
|
604
|
+
accountId?: string | undefined;
|
|
605
|
+
userId?: string | undefined;
|
|
606
|
+
} & {
|
|
607
|
+
fetchOptions?: FetchOptions | undefined;
|
|
608
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
609
|
+
accessToken: string | undefined;
|
|
610
|
+
refreshToken: string | undefined;
|
|
611
|
+
accessTokenExpiresAt: Date | undefined;
|
|
612
|
+
refreshTokenExpiresAt: Date | undefined;
|
|
613
|
+
scope: string | null | undefined;
|
|
614
|
+
idToken: string | null | undefined;
|
|
615
|
+
providerId: string;
|
|
616
|
+
accountId: string;
|
|
617
|
+
}, {
|
|
618
|
+
code?: string | undefined;
|
|
619
|
+
message?: string | undefined;
|
|
620
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
621
|
+
} & {
|
|
622
|
+
getAccessToken: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
623
|
+
providerId: string;
|
|
624
|
+
accountId?: string | undefined;
|
|
625
|
+
userId?: string | undefined;
|
|
626
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
627
|
+
providerId: string;
|
|
628
|
+
accountId?: string | undefined;
|
|
629
|
+
userId?: string | undefined;
|
|
630
|
+
} & {
|
|
631
|
+
fetchOptions?: FetchOptions | undefined;
|
|
632
|
+
}>, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
633
|
+
accessToken: string;
|
|
634
|
+
accessTokenExpiresAt: Date | undefined;
|
|
635
|
+
scopes: string[];
|
|
636
|
+
idToken: string | undefined;
|
|
637
|
+
}, {
|
|
638
|
+
code?: string | undefined;
|
|
639
|
+
message?: string | undefined;
|
|
640
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
641
|
+
} & {
|
|
642
|
+
accountInfo: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<{
|
|
643
|
+
accountId?: string | undefined;
|
|
644
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
645
|
+
query?: {
|
|
646
|
+
accountId?: string | undefined;
|
|
647
|
+
} | undefined;
|
|
648
|
+
fetchOptions?: FetchOptions | undefined;
|
|
649
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
650
|
+
user: better_auth.OAuth2UserInfo;
|
|
651
|
+
data: Record<string, any>;
|
|
652
|
+
}, {
|
|
653
|
+
code?: string | undefined;
|
|
654
|
+
message?: string | undefined;
|
|
655
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
656
|
+
} & {
|
|
657
|
+
getSession: <FetchOptions extends better_auth.ClientFetchOption<never, Partial<{
|
|
658
|
+
disableCookieCache?: unknown;
|
|
659
|
+
disableRefresh?: unknown;
|
|
660
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
661
|
+
query?: {
|
|
662
|
+
disableCookieCache?: unknown;
|
|
663
|
+
disableRefresh?: unknown;
|
|
664
|
+
} | undefined;
|
|
665
|
+
fetchOptions?: FetchOptions | undefined;
|
|
666
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
667
|
+
user: {
|
|
668
|
+
id: string;
|
|
669
|
+
createdAt: Date;
|
|
670
|
+
updatedAt: Date;
|
|
671
|
+
email: string;
|
|
672
|
+
emailVerified: boolean;
|
|
673
|
+
name: string;
|
|
674
|
+
image?: string | null | undefined;
|
|
675
|
+
userId?: string | null | undefined;
|
|
676
|
+
};
|
|
677
|
+
session: {
|
|
678
|
+
id: string;
|
|
679
|
+
createdAt: Date;
|
|
680
|
+
updatedAt: Date;
|
|
681
|
+
userId: string;
|
|
682
|
+
expiresAt: Date;
|
|
683
|
+
token: string;
|
|
684
|
+
ipAddress?: string | null | undefined;
|
|
685
|
+
userAgent?: string | null | undefined;
|
|
686
|
+
};
|
|
687
|
+
} | null, {
|
|
688
|
+
code?: string | undefined;
|
|
689
|
+
message?: string | undefined;
|
|
690
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
691
|
+
} & {
|
|
692
|
+
getCookie: () => string;
|
|
693
|
+
updateSession: () => void;
|
|
694
|
+
getSessionData: () => any;
|
|
695
|
+
} & {
|
|
696
|
+
useSession: nanostores.Atom<{
|
|
697
|
+
data: {
|
|
698
|
+
user: {
|
|
699
|
+
id: string;
|
|
700
|
+
createdAt: Date;
|
|
701
|
+
updatedAt: Date;
|
|
702
|
+
email: string;
|
|
703
|
+
emailVerified: boolean;
|
|
704
|
+
name: string;
|
|
705
|
+
image?: string | null | undefined;
|
|
706
|
+
userId?: string | null | undefined;
|
|
707
|
+
};
|
|
708
|
+
session: {
|
|
709
|
+
id: string;
|
|
710
|
+
createdAt: Date;
|
|
711
|
+
updatedAt: Date;
|
|
712
|
+
userId: string;
|
|
713
|
+
expiresAt: Date;
|
|
714
|
+
token: string;
|
|
715
|
+
ipAddress?: string | null | undefined;
|
|
716
|
+
userAgent?: string | null | undefined;
|
|
717
|
+
};
|
|
718
|
+
} | null;
|
|
719
|
+
error: _better_fetch_fetch.BetterFetchError | null;
|
|
720
|
+
isPending: boolean;
|
|
721
|
+
}>;
|
|
722
|
+
$fetch: _better_fetch_fetch.BetterFetch<{
|
|
723
|
+
plugins: (_better_fetch_fetch.BetterFetchPlugin<Record<string, any>> | {
|
|
724
|
+
id: string;
|
|
725
|
+
name: string;
|
|
726
|
+
hooks: {
|
|
727
|
+
onSuccess(context: _better_fetch_fetch.SuccessContext<any>): void;
|
|
728
|
+
};
|
|
729
|
+
} | {
|
|
730
|
+
id: string;
|
|
731
|
+
name: string;
|
|
732
|
+
hooks: {
|
|
733
|
+
onSuccess: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
734
|
+
onError: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
|
|
735
|
+
onRequest: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
|
|
736
|
+
onResponse: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
|
|
737
|
+
};
|
|
738
|
+
})[];
|
|
739
|
+
cache?: RequestCache | undefined;
|
|
740
|
+
method: string;
|
|
741
|
+
headers?: (HeadersInit & (HeadersInit | {
|
|
742
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
743
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
744
|
+
authorization: "Bearer" | "Basic";
|
|
745
|
+
})) | undefined;
|
|
746
|
+
redirect?: RequestRedirect | undefined;
|
|
747
|
+
credentials?: RequestCredentials;
|
|
748
|
+
integrity?: string | undefined;
|
|
749
|
+
keepalive?: boolean | undefined;
|
|
750
|
+
mode?: RequestMode | undefined;
|
|
751
|
+
priority?: RequestPriority | undefined;
|
|
752
|
+
referrer?: string | undefined;
|
|
753
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
754
|
+
signal?: (AbortSignal | null) | undefined;
|
|
755
|
+
window?: null | undefined;
|
|
756
|
+
onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
|
|
757
|
+
hookOptions?: {
|
|
758
|
+
cloneResponse?: boolean;
|
|
759
|
+
} | undefined;
|
|
760
|
+
timeout?: number | undefined;
|
|
761
|
+
customFetchImpl: _better_fetch_fetch.FetchEsque;
|
|
762
|
+
baseURL: string;
|
|
763
|
+
throw?: boolean | undefined;
|
|
764
|
+
auth?: ({
|
|
765
|
+
type: "Bearer";
|
|
766
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
767
|
+
} | {
|
|
768
|
+
type: "Basic";
|
|
769
|
+
username: string | (() => string | undefined) | undefined;
|
|
770
|
+
password: string | (() => string | undefined) | undefined;
|
|
771
|
+
} | {
|
|
772
|
+
type: "Custom";
|
|
773
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
774
|
+
value: string | (() => string | undefined) | undefined;
|
|
775
|
+
}) | undefined;
|
|
776
|
+
body?: any;
|
|
777
|
+
query?: any;
|
|
778
|
+
params?: any;
|
|
779
|
+
duplex?: "full" | "half" | undefined;
|
|
780
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
781
|
+
retry?: _better_fetch_fetch.RetryOptions | undefined;
|
|
782
|
+
retryAttempt?: number | undefined;
|
|
783
|
+
output?: (_better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
784
|
+
errorSchema?: _better_fetch_fetch.StandardSchemaV1 | undefined;
|
|
785
|
+
disableValidation?: boolean | undefined;
|
|
786
|
+
disableSignal?: boolean | undefined;
|
|
787
|
+
}, unknown, unknown, {}>;
|
|
788
|
+
$store: {
|
|
789
|
+
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
790
|
+
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
791
|
+
atoms: Record<string, nanostores.WritableAtom<any>>;
|
|
792
|
+
};
|
|
793
|
+
$Infer: {
|
|
794
|
+
Session: {
|
|
795
|
+
user: {
|
|
796
|
+
id: string;
|
|
797
|
+
createdAt: Date;
|
|
798
|
+
updatedAt: Date;
|
|
799
|
+
email: string;
|
|
800
|
+
emailVerified: boolean;
|
|
801
|
+
name: string;
|
|
802
|
+
image?: string | null | undefined;
|
|
803
|
+
userId?: string | null | undefined;
|
|
804
|
+
};
|
|
805
|
+
session: {
|
|
806
|
+
id: string;
|
|
807
|
+
createdAt: Date;
|
|
808
|
+
updatedAt: Date;
|
|
809
|
+
userId: string;
|
|
810
|
+
expiresAt: Date;
|
|
811
|
+
token: string;
|
|
812
|
+
ipAddress?: string | null | undefined;
|
|
813
|
+
userAgent?: string | null | undefined;
|
|
814
|
+
};
|
|
815
|
+
};
|
|
816
|
+
};
|
|
817
|
+
$ERROR_CODES: {
|
|
818
|
+
readonly USER_NOT_FOUND: "User not found";
|
|
819
|
+
readonly FAILED_TO_CREATE_USER: "Failed to create user";
|
|
820
|
+
readonly FAILED_TO_CREATE_SESSION: "Failed to create session";
|
|
821
|
+
readonly FAILED_TO_UPDATE_USER: "Failed to update user";
|
|
822
|
+
readonly FAILED_TO_GET_SESSION: "Failed to get session";
|
|
823
|
+
readonly INVALID_PASSWORD: "Invalid password";
|
|
824
|
+
readonly INVALID_EMAIL: "Invalid email";
|
|
825
|
+
readonly INVALID_EMAIL_OR_PASSWORD: "Invalid email or password";
|
|
826
|
+
readonly SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked";
|
|
827
|
+
readonly PROVIDER_NOT_FOUND: "Provider not found";
|
|
828
|
+
readonly INVALID_TOKEN: "Invalid token";
|
|
829
|
+
readonly ID_TOKEN_NOT_SUPPORTED: "id_token not supported";
|
|
830
|
+
readonly FAILED_TO_GET_USER_INFO: "Failed to get user info";
|
|
831
|
+
readonly USER_EMAIL_NOT_FOUND: "User email not found";
|
|
832
|
+
readonly EMAIL_NOT_VERIFIED: "Email not verified";
|
|
833
|
+
readonly PASSWORD_TOO_SHORT: "Password too short";
|
|
834
|
+
readonly PASSWORD_TOO_LONG: "Password too long";
|
|
835
|
+
readonly USER_ALREADY_EXISTS: "User already exists.";
|
|
836
|
+
readonly USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.";
|
|
837
|
+
readonly EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated";
|
|
838
|
+
readonly CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found";
|
|
839
|
+
readonly SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.";
|
|
840
|
+
readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
|
|
841
|
+
readonly ACCOUNT_NOT_FOUND: "Account not found";
|
|
842
|
+
readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
|
|
843
|
+
};
|
|
844
|
+
}>;
|
|
845
|
+
/** Provide a configured Better Auth client via DI (default convex+crossDomain plugins) */
|
|
846
|
+
declare function provideAuthClient(opts: ProvideAuthClientOptions): Provider;
|
|
847
|
+
|
|
848
|
+
type QueryRef = FunctionReference<'query'>;
|
|
849
|
+
type KeepMode = 'none' | 'last';
|
|
850
|
+
interface ConvexResourceOptions {
|
|
851
|
+
keep?: KeepMode;
|
|
852
|
+
}
|
|
853
|
+
declare const CONVEX_RESOURCE_OPTIONS: InjectionToken<Required<ConvexResourceOptions>>;
|
|
854
|
+
declare function provideConvexResourceOptions(opts: Partial<ConvexResourceOptions>): Provider;
|
|
855
|
+
type NoArgsQuery = QueryRef & {
|
|
856
|
+
_args: Record<string, never>;
|
|
857
|
+
};
|
|
858
|
+
/** Overloads */
|
|
859
|
+
declare function convexLiveResource<Q extends NoArgsQuery>(query: Q, opts?: ConvexResourceOptions): ResourceRef<FunctionReturnType<Q> | undefined>;
|
|
860
|
+
declare function convexLiveResource<Q extends NoArgsQuery>(query: Q, params: () => {} | undefined, opts?: ConvexResourceOptions): ResourceRef<FunctionReturnType<Q> | undefined>;
|
|
861
|
+
declare function convexLiveResource<Q extends QueryRef>(query: Q, params: () => Q['_args'] | undefined, opts?: ConvexResourceOptions): ResourceRef<FunctionReturnType<Q> | undefined>;
|
|
862
|
+
|
|
863
|
+
interface ConvexAngularOptions {
|
|
864
|
+
/** Convex deployment URL, e.g. https://xxx.convex.cloud */
|
|
865
|
+
convexUrl: string;
|
|
866
|
+
/** Better Auth base URL (convex site url), e.g. https://xxx.convex.site */
|
|
867
|
+
authBaseURL: string;
|
|
868
|
+
/** Skew before JWT expiry to refresh token */
|
|
869
|
+
authSkewMs?: number;
|
|
870
|
+
/** Default keep mode for live resources ('last' | 'none') */
|
|
871
|
+
keep?: KeepMode;
|
|
872
|
+
/**
|
|
873
|
+
* Optional: user-provided Better Auth client.
|
|
874
|
+
* Must include convexClient() and crossDomainClient() plugins.
|
|
875
|
+
*/
|
|
876
|
+
authClient?: AuthClient;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Single entry-point provider to wire Convex + Better Auth + resource defaults.
|
|
880
|
+
* Behavior:
|
|
881
|
+
* - If opts.authClient is provided, we use it (and verify required plugins).
|
|
882
|
+
* - Else we create a default Better Auth client using authBaseURL with required plugins.
|
|
883
|
+
*/
|
|
884
|
+
declare function provideConvexAngular(opts: ConvexAngularOptions): Provider[];
|
|
885
|
+
|
|
886
|
+
/** Minimal surface this library relies on from Better Auth client */
|
|
887
|
+
interface AuthClientRequired {
|
|
888
|
+
convex: {
|
|
889
|
+
token: () => Promise<{
|
|
890
|
+
data?: {
|
|
891
|
+
token?: string;
|
|
892
|
+
} | null;
|
|
893
|
+
}>;
|
|
894
|
+
};
|
|
895
|
+
crossDomain: {
|
|
896
|
+
oneTimeToken: {
|
|
897
|
+
verify: (args: {
|
|
898
|
+
token: string;
|
|
899
|
+
}) => Promise<{
|
|
900
|
+
data?: {
|
|
901
|
+
session?: {
|
|
902
|
+
token?: string;
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
}>;
|
|
906
|
+
};
|
|
907
|
+
};
|
|
908
|
+
getSession: (o?: {
|
|
909
|
+
fetchOptions?: RequestInit;
|
|
910
|
+
}) => Promise<unknown>;
|
|
911
|
+
updateSession: () => void;
|
|
912
|
+
}
|
|
913
|
+
interface ConvexBetterAuthOptions {
|
|
914
|
+
/** Convex deployment URL, e.g. https://xxx.convex.cloud */
|
|
915
|
+
convexUrl: string;
|
|
916
|
+
/** Milliseconds before JWT expiry to refresh (default 45s in this provider) */
|
|
917
|
+
authSkewMs?: number;
|
|
918
|
+
authClient?: AuthClientRequired;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Registers the Convex client in DI and connects it to Better Auth for JWT retrieval.
|
|
922
|
+
* Consumers still need to provide the Better Auth HTTP client via provideAuthClient().
|
|
923
|
+
*/
|
|
924
|
+
declare function provideConvexBetterAuth(opts: ConvexBetterAuthOptions): Provider[];
|
|
925
|
+
/**
|
|
926
|
+
* Optional environment initializer to handle OTT (?ott=...) once and upgrade to a cookie session.
|
|
927
|
+
* Keep separate from main provider for explicit opt-in.
|
|
928
|
+
*/
|
|
929
|
+
declare function provideBetterAuthOttBootstrap(): _angular_core.EnvironmentProviders;
|
|
930
|
+
|
|
931
|
+
type MutationRef = FunctionReference<'mutation'>;
|
|
932
|
+
type NoArgsMutation = MutationRef & {
|
|
933
|
+
_args: Record<string, never>;
|
|
934
|
+
};
|
|
935
|
+
type IfEmptyArgs$1<M extends MutationRef, TIfEmpty, TIfNot> = keyof M['_args'] extends never ? TIfEmpty : TIfNot;
|
|
936
|
+
interface ConvexMutationOptions<M extends MutationRef> {
|
|
937
|
+
optimisticUpdate?: OptimisticUpdate<FunctionArgs<M>>;
|
|
938
|
+
onSuccess?: (data: FunctionReturnType<M>) => void;
|
|
939
|
+
onError?: (err: Error) => void;
|
|
940
|
+
/** concurrency: queue = sequential, drop = ignore while inflight, replace = prefer latest */
|
|
941
|
+
mode?: 'queue' | 'drop' | 'replace';
|
|
942
|
+
/** simple retry */
|
|
943
|
+
retries?: number;
|
|
944
|
+
retryDelayMs?: (attempt: number) => number;
|
|
945
|
+
}
|
|
946
|
+
type RunFn$1<M extends MutationRef> = IfEmptyArgs$1<M, (args?: FunctionArgs<M>) => Promise<FunctionReturnType<M>>, (args: FunctionArgs<M>) => Promise<FunctionReturnType<M>>>;
|
|
947
|
+
interface ConvexMutationResource<M extends MutationRef> {
|
|
948
|
+
/** imperative trigger */
|
|
949
|
+
run: RunFn$1<M>;
|
|
950
|
+
/** resource-shaped state (bind in templates if you like) */
|
|
951
|
+
state: ResourceRef<FunctionReturnType<M> | undefined>;
|
|
952
|
+
/** convenience signals */
|
|
953
|
+
data: Signal<FunctionReturnType<M> | undefined>;
|
|
954
|
+
error: Signal<Error | undefined>;
|
|
955
|
+
isRunning: Signal<boolean>;
|
|
956
|
+
reset(): void;
|
|
957
|
+
}
|
|
958
|
+
/** Overloads for nice run() arg ergonomics */
|
|
959
|
+
declare function convexMutationResource<M extends NoArgsMutation>(mutation: M, opts?: ConvexMutationOptions<M>): ConvexMutationResource<M>;
|
|
960
|
+
declare function convexMutationResource<M extends MutationRef>(mutation: M, opts?: ConvexMutationOptions<M>): ConvexMutationResource<M>;
|
|
961
|
+
|
|
962
|
+
type ActionRef = FunctionReference<'action'>;
|
|
963
|
+
type NoArgsAction = ActionRef & {
|
|
964
|
+
_args: Record<string, never>;
|
|
965
|
+
};
|
|
966
|
+
type IfEmptyArgs<A extends ActionRef, TIfEmpty, TIfNot> = keyof A['_args'] extends never ? TIfEmpty : TIfNot;
|
|
967
|
+
interface ConvexActionOptions<A extends ActionRef> {
|
|
968
|
+
onSuccess?: (data: FunctionReturnType<A>) => void;
|
|
969
|
+
onError?: (err: Error) => void;
|
|
970
|
+
/** concurrency: queue = sequential, drop = ignore while inflight, replace = prefer latest */
|
|
971
|
+
mode?: 'queue' | 'drop' | 'replace';
|
|
972
|
+
/** simple retry */
|
|
973
|
+
retries?: number;
|
|
974
|
+
retryDelayMs?: (attempt: number) => number;
|
|
975
|
+
}
|
|
976
|
+
type RunFn<A extends ActionRef> = IfEmptyArgs<A, (args?: FunctionArgs<A>) => Promise<FunctionReturnType<A>>, (args: FunctionArgs<A>) => Promise<FunctionReturnType<A>>>;
|
|
977
|
+
interface ConvexActionResource<A extends ActionRef> {
|
|
978
|
+
run: RunFn<A>;
|
|
979
|
+
state: ResourceRef<FunctionReturnType<A> | undefined>;
|
|
980
|
+
data: Signal<FunctionReturnType<A> | undefined>;
|
|
981
|
+
error: Signal<Error | undefined>;
|
|
982
|
+
isRunning: Signal<boolean>;
|
|
983
|
+
reset(): void;
|
|
984
|
+
}
|
|
985
|
+
/** Overloads for nice run() arg ergonomics */
|
|
986
|
+
declare function convexActionResource<A extends NoArgsAction>(action: A, opts?: ConvexActionOptions<A>): ConvexActionResource<A>;
|
|
987
|
+
declare function convexActionResource<A extends ActionRef>(action: A, opts?: ConvexActionOptions<A>): ConvexActionResource<A>;
|
|
988
|
+
|
|
989
|
+
export { AUTH_CLIENT, CONVEX, CONVEX_RESOURCE_OPTIONS, ConvexAngularClient, convexActionResource, convexLiveResource, convexMutationResource, injectConvex, provideAuthClient, provideBetterAuthOttBootstrap, provideConvexAngular, provideConvexBetterAuth, provideConvexResourceOptions };
|
|
990
|
+
export type { ActionRef, AuthClient, AuthSnapshot, ConvexActionOptions, ConvexActionResource, ConvexAngularOptions, ConvexBetterAuthOptions, ConvexMutationOptions, ConvexMutationResource, ConvexResourceOptions, FetchAccessToken, KeepMode, MutationRef, ProvideAuthClientOptions, QueryRef };
|