abckit 0.0.17 → 0.0.18

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.
@@ -1,13 +1,3 @@
1
- declare let capacitorTokenHandlers: {
2
- onSuccess: (authToken: string) => Promise<void>;
3
- getToken: () => Promise<string>;
4
- clearToken: () => Promise<void>;
5
- } | null;
6
- /**
7
- * Register Capacitor token handlers for mobile apps
8
- * Call this from useAuthMobile before using useAuth
9
- */
10
- export declare function registerCapacitorHandlers(handlers: typeof capacitorTokenHandlers): void;
11
1
  /**
12
2
  * Main authentication composable for Better Auth
13
3
  */
@@ -74,8 +64,6 @@ export declare function useAuth(): {
74
64
  readonly name: string;
75
65
  readonly image?: string | null | undefined;
76
66
  } | null>;
77
- login: (returnTo?: string) => void;
78
- register: (returnTo?: string) => void;
79
67
  logout: () => Promise<void>;
80
68
  refreshSession: () => Promise<{
81
69
  data: {
@@ -1896,4 +1884,3 @@ export declare function getAuthClientExports(): {
1896
1884
  };
1897
1885
  };
1898
1886
  };
1899
- export {};
@@ -1,11 +1,19 @@
1
1
  import { navigateTo, useRuntimeConfig } from "#app";
2
+ import { Preferences } from "@capacitor/preferences";
2
3
  import { adminClient } from "better-auth/client/plugins";
3
4
  import { createAuthClient } from "better-auth/vue";
4
5
  import { computed, watch } from "vue";
6
+ const AUTH_TOKEN_KEY = "auth_token";
5
7
  let authClient = null;
6
- let capacitorTokenHandlers = null;
7
- export function registerCapacitorHandlers(handlers) {
8
- capacitorTokenHandlers = handlers;
8
+ async function getStoredToken() {
9
+ const result = await Preferences.get({ key: AUTH_TOKEN_KEY });
10
+ return result?.value || "";
11
+ }
12
+ async function setStoredToken(token) {
13
+ await Preferences.set({ key: AUTH_TOKEN_KEY, value: token });
14
+ }
15
+ async function clearStoredToken() {
16
+ await Preferences.remove({ key: AUTH_TOKEN_KEY });
9
17
  }
10
18
  function getAuthClient() {
11
19
  if (authClient)
@@ -14,27 +22,24 @@ function getAuthClient() {
14
22
  const authConfig = config.public.abckit?.auth;
15
23
  const baseURL = authConfig?.baseURL;
16
24
  const basePath = authConfig?.basePath;
25
+ const isCapacitor = authConfig?.capacitor ?? false;
17
26
  const clientOptions = {
18
27
  baseURL,
19
28
  basePath,
20
29
  plugins: [adminClient()]
21
30
  };
22
- if (capacitorTokenHandlers) {
31
+ if (isCapacitor) {
23
32
  clientOptions.fetchOptions = {
24
33
  credentials: "include",
25
34
  onSuccess: async (ctx) => {
26
35
  const authToken = ctx.response.headers.get("set-auth-token");
27
- if (authToken && capacitorTokenHandlers) {
28
- await capacitorTokenHandlers.onSuccess(authToken);
36
+ if (authToken) {
37
+ await setStoredToken(authToken);
29
38
  }
30
39
  },
31
40
  auth: {
32
41
  type: "Bearer",
33
- token: async () => {
34
- if (!capacitorTokenHandlers)
35
- return "";
36
- return capacitorTokenHandlers.getToken();
37
- }
42
+ token: getStoredToken
38
43
  }
39
44
  };
40
45
  }
@@ -58,18 +63,10 @@ export function useAuth() {
58
63
  }
59
64
  }, { immediate: true });
60
65
  }
61
- function login(returnTo) {
62
- const query = returnTo ? `?return_to=${encodeURIComponent(returnTo)}` : "";
63
- navigateTo(`/auth/login${query}`);
64
- }
65
- function register(returnTo) {
66
- const query = returnTo ? `?return_to=${encodeURIComponent(returnTo)}` : "";
67
- navigateTo(`/auth/register${query}`);
68
- }
69
66
  async function logout() {
70
67
  await client.signOut();
71
- if (capacitorTokenHandlers) {
72
- await capacitorTokenHandlers.clearToken();
68
+ if (config.public.abckit?.auth?.capacitor) {
69
+ await clearStoredToken();
73
70
  }
74
71
  navigateTo("/");
75
72
  }
@@ -82,8 +79,6 @@ export function useAuth() {
82
79
  isLoading,
83
80
  isAuthenticated,
84
81
  user,
85
- login,
86
- register,
87
82
  logout,
88
83
  refreshSession,
89
84
  authClient: client
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtRouteMiddleware, navigateTo } from "#app";
2
- import { useAuth } from "../composables/useAuth.js";
2
+ import { useAuth } from "abckit/composables/useAuth";
3
3
  export default defineNuxtRouteMiddleware(async (to) => {
4
4
  if (import.meta.server) {
5
5
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "abckit",
3
3
  "type": "module",
4
- "version": "0.0.17",
4
+ "version": "0.0.18",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -1,871 +0,0 @@
1
- import { Capacitor } from '@capacitor/core';
2
- import { Preferences } from '@capacitor/preferences';
3
- /**
4
- * Initialize auth for Capacitor/mobile apps
5
- * Call this once in your app's setup (e.g., app.vue or a plugin)
6
- *
7
- * @example
8
- * ```ts
9
- * // app.vue or plugins/auth.client.ts
10
- * import { useAuthMobile } from 'abckit/composables/useAuthMobile'
11
- *
12
- * if (Capacitor.isNativePlatform()) {
13
- * useAuthMobile()
14
- * }
15
- * ```
16
- */
17
- export declare function useAuthMobile(): {
18
- session: Readonly<import("vue").Ref<{
19
- readonly data: {
20
- readonly user: {
21
- readonly id: string;
22
- readonly createdAt: Date;
23
- readonly updatedAt: Date;
24
- readonly email: string;
25
- readonly emailVerified: boolean;
26
- readonly name: string;
27
- readonly image?: string | null | undefined;
28
- };
29
- readonly session: {
30
- readonly id: string;
31
- readonly createdAt: Date;
32
- readonly updatedAt: Date;
33
- readonly userId: string;
34
- readonly expiresAt: Date;
35
- readonly token: string;
36
- readonly ipAddress?: string | null | undefined;
37
- readonly userAgent?: string | null | undefined;
38
- };
39
- } | null;
40
- readonly isPending: boolean;
41
- readonly isRefetching: boolean;
42
- readonly error: import("better-auth/vue").BetterFetchError | null;
43
- }, {
44
- readonly data: {
45
- readonly user: {
46
- readonly id: string;
47
- readonly createdAt: Date;
48
- readonly updatedAt: Date;
49
- readonly email: string;
50
- readonly emailVerified: boolean;
51
- readonly name: string;
52
- readonly image?: string | null | undefined;
53
- };
54
- readonly session: {
55
- readonly id: string;
56
- readonly createdAt: Date;
57
- readonly updatedAt: Date;
58
- readonly userId: string;
59
- readonly expiresAt: Date;
60
- readonly token: string;
61
- readonly ipAddress?: string | null | undefined;
62
- readonly userAgent?: string | null | undefined;
63
- };
64
- } | null;
65
- readonly isPending: boolean;
66
- readonly isRefetching: boolean;
67
- readonly error: import("better-auth/vue").BetterFetchError | null;
68
- }>>;
69
- isLoading: import("vue").ComputedRef<boolean>;
70
- isAuthenticated: import("vue").ComputedRef<boolean>;
71
- user: import("vue").ComputedRef<{
72
- readonly id: string;
73
- readonly createdAt: Date;
74
- readonly updatedAt: Date;
75
- readonly email: string;
76
- readonly emailVerified: boolean;
77
- readonly name: string;
78
- readonly image?: string | null | undefined;
79
- } | null>;
80
- login: (returnTo?: string) => void;
81
- register: (returnTo?: string) => void;
82
- logout: () => Promise<void>;
83
- refreshSession: () => Promise<{
84
- data: {
85
- user: {
86
- id: string;
87
- createdAt: Date;
88
- updatedAt: Date;
89
- email: string;
90
- emailVerified: boolean;
91
- name: string;
92
- image?: string | null | undefined;
93
- };
94
- session: {
95
- id: string;
96
- createdAt: Date;
97
- updatedAt: Date;
98
- userId: string;
99
- expiresAt: Date;
100
- token: string;
101
- ipAddress?: string | null | undefined;
102
- userAgent?: string | null | undefined;
103
- };
104
- } | null;
105
- error: null;
106
- } | {
107
- data: null;
108
- error: {
109
- code?: string | undefined | undefined;
110
- message?: string | undefined | undefined;
111
- status: number;
112
- statusText: string;
113
- };
114
- }>;
115
- authClient: {
116
- signIn: {
117
- social: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
118
- provider: "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" | (string & {});
119
- callbackURL?: string | undefined;
120
- newUserCallbackURL?: string | undefined;
121
- errorCallbackURL?: string | undefined;
122
- disableRedirect?: boolean | undefined;
123
- idToken?: {
124
- token: string;
125
- nonce?: string | undefined;
126
- accessToken?: string | undefined;
127
- refreshToken?: string | undefined;
128
- expiresAt?: number | undefined;
129
- } | undefined;
130
- scopes?: string[] | undefined;
131
- requestSignUp?: boolean | undefined;
132
- loginHint?: string | undefined;
133
- additionalData?: Record<string, any> | undefined;
134
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
135
- provider: "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" | (string & {});
136
- callbackURL?: string | undefined;
137
- newUserCallbackURL?: string | undefined;
138
- errorCallbackURL?: string | undefined;
139
- disableRedirect?: boolean | undefined;
140
- idToken?: {
141
- token: string;
142
- nonce?: string | undefined;
143
- accessToken?: string | undefined;
144
- refreshToken?: string | undefined;
145
- expiresAt?: number | undefined;
146
- } | undefined;
147
- scopes?: string[] | undefined;
148
- requestSignUp?: boolean | undefined;
149
- loginHint?: string | undefined;
150
- additionalData?: Record<string, any> | undefined;
151
- } & {
152
- fetchOptions?: FetchOptions | undefined;
153
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<NonNullable<{
154
- redirect: boolean;
155
- url: string;
156
- } | {
157
- redirect: boolean;
158
- token: string;
159
- url: undefined;
160
- user: {
161
- id: string;
162
- createdAt: Date;
163
- updatedAt: Date;
164
- email: string;
165
- emailVerified: boolean;
166
- name: string;
167
- image?: string | null | undefined | undefined;
168
- };
169
- }>, {
170
- code?: string | undefined;
171
- message?: string | undefined;
172
- }, FetchOptions["throw"] extends true ? true : false>>;
173
- };
174
- } & {
175
- signOut: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
176
- query?: Record<string, any> | undefined;
177
- fetchOptions?: FetchOptions | undefined;
178
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
179
- success: boolean;
180
- }, {
181
- code?: string | undefined;
182
- message?: string | undefined;
183
- }, FetchOptions["throw"] extends true ? true : false>>;
184
- } & {
185
- signUp: {
186
- email: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
187
- name: string;
188
- email: string;
189
- password: string;
190
- image?: string | undefined;
191
- callbackURL?: string | undefined;
192
- rememberMe?: boolean | undefined;
193
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
194
- email: string;
195
- name: string;
196
- password: string;
197
- image?: string | undefined;
198
- callbackURL?: string | undefined;
199
- fetchOptions?: FetchOptions | undefined;
200
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<NonNullable<{
201
- token: null;
202
- user: {
203
- id: string;
204
- createdAt: Date;
205
- updatedAt: Date;
206
- email: string;
207
- emailVerified: boolean;
208
- name: string;
209
- image?: string | null | undefined | undefined;
210
- };
211
- } | {
212
- token: string;
213
- user: {
214
- id: string;
215
- createdAt: Date;
216
- updatedAt: Date;
217
- email: string;
218
- emailVerified: boolean;
219
- name: string;
220
- image?: string | null | undefined | undefined;
221
- };
222
- }>, {
223
- code?: string | undefined;
224
- message?: string | undefined;
225
- }, FetchOptions["throw"] extends true ? true : false>>;
226
- };
227
- } & {
228
- signIn: {
229
- email: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
230
- email: string;
231
- password: string;
232
- callbackURL?: string | undefined;
233
- rememberMe?: boolean | undefined;
234
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
235
- email: string;
236
- password: string;
237
- callbackURL?: string | undefined;
238
- rememberMe?: boolean | undefined;
239
- } & {
240
- fetchOptions?: FetchOptions | undefined;
241
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
242
- redirect: boolean;
243
- token: string;
244
- url?: string | undefined;
245
- user: {
246
- id: string;
247
- createdAt: Date;
248
- updatedAt: Date;
249
- email: string;
250
- emailVerified: boolean;
251
- name: string;
252
- image?: string | null | undefined | undefined;
253
- };
254
- }, {
255
- code?: string | undefined;
256
- message?: string | undefined;
257
- }, FetchOptions["throw"] extends true ? true : false>>;
258
- };
259
- } & {
260
- resetPassword: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
261
- newPassword: string;
262
- token?: string | undefined;
263
- }> & Record<string, any>, Partial<{
264
- token?: string | undefined;
265
- }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
266
- newPassword: string;
267
- token?: string | undefined;
268
- } & {
269
- fetchOptions?: FetchOptions | undefined;
270
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
271
- status: boolean;
272
- }, {
273
- code?: string | undefined;
274
- message?: string | undefined;
275
- }, FetchOptions["throw"] extends true ? true : false>>;
276
- } & {
277
- verifyEmail: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
278
- token: string;
279
- callbackURL?: string | undefined;
280
- }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
281
- query: {
282
- token: string;
283
- callbackURL?: string | undefined;
284
- };
285
- fetchOptions?: FetchOptions | undefined;
286
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<NonNullable<void | {
287
- status: boolean;
288
- }>, {
289
- code?: string | undefined;
290
- message?: string | undefined;
291
- }, FetchOptions["throw"] extends true ? true : false>>;
292
- } & {
293
- sendVerificationEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
294
- email: string;
295
- callbackURL?: string | undefined;
296
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
297
- email: string;
298
- callbackURL?: string | undefined;
299
- } & {
300
- fetchOptions?: FetchOptions | undefined;
301
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
302
- status: boolean;
303
- }, {
304
- code?: string | undefined;
305
- message?: string | undefined;
306
- }, FetchOptions["throw"] extends true ? true : false>>;
307
- } & {
308
- changeEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
309
- newEmail: string;
310
- callbackURL?: string | undefined;
311
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
312
- newEmail: string;
313
- callbackURL?: string | undefined;
314
- } & {
315
- fetchOptions?: FetchOptions | undefined;
316
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
317
- status: boolean;
318
- }, {
319
- code?: string | undefined;
320
- message?: string | undefined;
321
- }, FetchOptions["throw"] extends true ? true : false>>;
322
- } & {
323
- changePassword: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
324
- newPassword: string;
325
- currentPassword: string;
326
- revokeOtherSessions?: boolean | undefined;
327
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
328
- newPassword: string;
329
- currentPassword: string;
330
- revokeOtherSessions?: boolean | undefined;
331
- } & {
332
- fetchOptions?: FetchOptions | undefined;
333
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
334
- token: string | null;
335
- user: {
336
- id: string;
337
- email: string;
338
- name: string;
339
- image: string | null | undefined;
340
- emailVerified: boolean;
341
- createdAt: Date;
342
- updatedAt: Date;
343
- };
344
- }, {
345
- code?: string | undefined;
346
- message?: string | undefined;
347
- }, FetchOptions["throw"] extends true ? true : false>>;
348
- } & {
349
- updateUser: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<Partial<{}> & {
350
- name?: string | undefined;
351
- image?: string | undefined | null;
352
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
353
- image?: (string | null) | undefined;
354
- name?: string | undefined;
355
- fetchOptions?: FetchOptions | undefined;
356
- } & Partial<{}>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
357
- status: boolean;
358
- }, {
359
- code?: string | undefined;
360
- message?: string | undefined;
361
- }, FetchOptions["throw"] extends true ? true : false>>;
362
- } & {
363
- deleteUser: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
364
- callbackURL?: string | undefined;
365
- password?: string | undefined;
366
- token?: string | undefined;
367
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
368
- callbackURL?: string | undefined;
369
- password?: string | undefined;
370
- token?: string | undefined;
371
- } & {
372
- fetchOptions?: FetchOptions | undefined;
373
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
374
- success: boolean;
375
- message: string;
376
- }, {
377
- code?: string | undefined;
378
- message?: string | undefined;
379
- }, FetchOptions["throw"] extends true ? true : false>>;
380
- } & {
381
- requestPasswordReset: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
382
- email: string;
383
- redirectTo?: string | undefined;
384
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
385
- email: string;
386
- redirectTo?: string | undefined;
387
- } & {
388
- fetchOptions?: FetchOptions | undefined;
389
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
390
- status: boolean;
391
- message: string;
392
- }, {
393
- code?: string | undefined;
394
- message?: string | undefined;
395
- }, FetchOptions["throw"] extends true ? true : false>>;
396
- } & {
397
- resetPassword: {
398
- ":token": <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
399
- callbackURL: string;
400
- }> & Record<string, any>, {
401
- token: string;
402
- }>>(data_0: import("better-auth").Prettify<{
403
- query: {
404
- callbackURL: string;
405
- };
406
- fetchOptions?: FetchOptions | undefined;
407
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<never, {
408
- code?: string | undefined;
409
- message?: string | undefined;
410
- }, FetchOptions["throw"] extends true ? true : false>>;
411
- };
412
- } & {
413
- listSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
414
- query?: Record<string, any> | undefined;
415
- fetchOptions?: FetchOptions | undefined;
416
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<import("better-auth").Prettify<{
417
- id: string;
418
- createdAt: Date;
419
- updatedAt: Date;
420
- userId: string;
421
- expiresAt: Date;
422
- token: string;
423
- ipAddress?: string | null | undefined | undefined;
424
- userAgent?: string | null | undefined | undefined;
425
- }>[], {
426
- code?: string | undefined;
427
- message?: string | undefined;
428
- }, FetchOptions["throw"] extends true ? true : false>>;
429
- } & {
430
- revokeSession: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
431
- token: string;
432
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
433
- token: string;
434
- } & {
435
- fetchOptions?: FetchOptions | undefined;
436
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
437
- status: boolean;
438
- }, {
439
- code?: string | undefined;
440
- message?: string | undefined;
441
- }, FetchOptions["throw"] extends true ? true : false>>;
442
- } & {
443
- revokeSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
444
- query?: Record<string, any> | undefined;
445
- fetchOptions?: FetchOptions | undefined;
446
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
447
- status: boolean;
448
- }, {
449
- code?: string | undefined;
450
- message?: string | undefined;
451
- }, FetchOptions["throw"] extends true ? true : false>>;
452
- } & {
453
- revokeOtherSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
454
- query?: Record<string, any> | undefined;
455
- fetchOptions?: FetchOptions | undefined;
456
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
457
- status: boolean;
458
- }, {
459
- code?: string | undefined;
460
- message?: string | undefined;
461
- }, FetchOptions["throw"] extends true ? true : false>>;
462
- } & {
463
- linkSocial: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
464
- provider: unknown;
465
- callbackURL?: string | undefined;
466
- idToken?: {
467
- token: string;
468
- nonce?: string | undefined;
469
- accessToken?: string | undefined;
470
- refreshToken?: string | undefined;
471
- scopes?: string[] | undefined;
472
- } | undefined;
473
- requestSignUp?: boolean | undefined;
474
- scopes?: string[] | undefined;
475
- errorCallbackURL?: string | undefined;
476
- disableRedirect?: boolean | undefined;
477
- additionalData?: Record<string, any> | undefined;
478
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
479
- provider: unknown;
480
- callbackURL?: string | undefined;
481
- idToken?: {
482
- token: string;
483
- nonce?: string | undefined;
484
- accessToken?: string | undefined;
485
- refreshToken?: string | undefined;
486
- scopes?: string[] | undefined;
487
- } | undefined;
488
- requestSignUp?: boolean | undefined;
489
- scopes?: string[] | undefined;
490
- errorCallbackURL?: string | undefined;
491
- disableRedirect?: boolean | undefined;
492
- additionalData?: Record<string, any> | undefined;
493
- } & {
494
- fetchOptions?: FetchOptions | undefined;
495
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
496
- url: string;
497
- redirect: boolean;
498
- }, {
499
- code?: string | undefined;
500
- message?: string | undefined;
501
- }, FetchOptions["throw"] extends true ? true : false>>;
502
- } & {
503
- listAccounts: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
504
- query?: Record<string, any> | undefined;
505
- fetchOptions?: FetchOptions | undefined;
506
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
507
- id: string;
508
- providerId: string;
509
- createdAt: Date;
510
- updatedAt: Date;
511
- accountId: string;
512
- userId: string;
513
- scopes: string[];
514
- }[], {
515
- code?: string | undefined;
516
- message?: string | undefined;
517
- }, FetchOptions["throw"] extends true ? true : false>>;
518
- } & {
519
- deleteUser: {
520
- callback: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
521
- token: string;
522
- callbackURL?: string | undefined;
523
- }> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
524
- query: {
525
- token: string;
526
- callbackURL?: string | undefined;
527
- };
528
- fetchOptions?: FetchOptions | undefined;
529
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
530
- success: boolean;
531
- message: string;
532
- }, {
533
- code?: string | undefined;
534
- message?: string | undefined;
535
- }, FetchOptions["throw"] extends true ? true : false>>;
536
- };
537
- } & {
538
- unlinkAccount: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
539
- providerId: string;
540
- accountId?: string | undefined;
541
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
542
- providerId: string;
543
- accountId?: string | undefined;
544
- } & {
545
- fetchOptions?: FetchOptions | undefined;
546
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
547
- status: boolean;
548
- }, {
549
- code?: string | undefined;
550
- message?: string | undefined;
551
- }, FetchOptions["throw"] extends true ? true : false>>;
552
- } & {
553
- refreshToken: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
554
- providerId: string;
555
- accountId?: string | undefined;
556
- userId?: string | undefined;
557
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
558
- providerId: string;
559
- accountId?: string | undefined;
560
- userId?: string | undefined;
561
- } & {
562
- fetchOptions?: FetchOptions | undefined;
563
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
564
- accessToken: string | undefined;
565
- refreshToken: string | undefined;
566
- accessTokenExpiresAt: Date | undefined;
567
- refreshTokenExpiresAt: Date | undefined;
568
- scope: string | null | undefined;
569
- idToken: string | null | undefined;
570
- providerId: string;
571
- accountId: string;
572
- }, {
573
- code?: string | undefined;
574
- message?: string | undefined;
575
- }, FetchOptions["throw"] extends true ? true : false>>;
576
- } & {
577
- getAccessToken: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
578
- providerId: string;
579
- accountId?: string | undefined;
580
- userId?: string | undefined;
581
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
582
- providerId: string;
583
- accountId?: string | undefined;
584
- userId?: string | undefined;
585
- } & {
586
- fetchOptions?: FetchOptions | undefined;
587
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
588
- accessToken: string;
589
- accessTokenExpiresAt: Date | undefined;
590
- scopes: string[];
591
- idToken: string | undefined;
592
- }, {
593
- code?: string | undefined;
594
- message?: string | undefined;
595
- }, FetchOptions["throw"] extends true ? true : false>>;
596
- } & {
597
- accountInfo: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
598
- accountId?: string | undefined;
599
- }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
600
- query?: {
601
- accountId?: string | undefined;
602
- } | undefined;
603
- fetchOptions?: FetchOptions | undefined;
604
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
605
- user: import("better-auth").OAuth2UserInfo;
606
- data: Record<string, any>;
607
- }, {
608
- code?: string | undefined;
609
- message?: string | undefined;
610
- }, FetchOptions["throw"] extends true ? true : false>>;
611
- } & {
612
- getSession: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
613
- disableCookieCache?: unknown;
614
- disableRefresh?: unknown;
615
- }> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
616
- query?: {
617
- disableCookieCache?: unknown;
618
- disableRefresh?: unknown;
619
- } | undefined;
620
- fetchOptions?: FetchOptions | undefined;
621
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/vue").BetterFetchResponse<{
622
- user: {
623
- id: string;
624
- createdAt: Date;
625
- updatedAt: Date;
626
- email: string;
627
- emailVerified: boolean;
628
- name: string;
629
- image?: string | null | undefined;
630
- };
631
- session: {
632
- id: string;
633
- createdAt: Date;
634
- updatedAt: Date;
635
- userId: string;
636
- expiresAt: Date;
637
- token: string;
638
- ipAddress?: string | null | undefined;
639
- userAgent?: string | null | undefined;
640
- };
641
- } | null, {
642
- code?: string | undefined;
643
- message?: string | undefined;
644
- }, FetchOptions["throw"] extends true ? true : false>>;
645
- } & {
646
- useSession: {
647
- (): Readonly<import("vue").Ref<{
648
- readonly data: {
649
- readonly user: {
650
- readonly id: string;
651
- readonly createdAt: Date;
652
- readonly updatedAt: Date;
653
- readonly email: string;
654
- readonly emailVerified: boolean;
655
- readonly name: string;
656
- readonly image?: string | null | undefined;
657
- };
658
- readonly session: {
659
- readonly id: string;
660
- readonly createdAt: Date;
661
- readonly updatedAt: Date;
662
- readonly userId: string;
663
- readonly expiresAt: Date;
664
- readonly token: string;
665
- readonly ipAddress?: string | null | undefined;
666
- readonly userAgent?: string | null | undefined;
667
- };
668
- } | null;
669
- readonly isPending: boolean;
670
- readonly isRefetching: boolean;
671
- readonly error: import("better-auth/vue").BetterFetchError | null;
672
- }, {
673
- readonly data: {
674
- readonly user: {
675
- readonly id: string;
676
- readonly createdAt: Date;
677
- readonly updatedAt: Date;
678
- readonly email: string;
679
- readonly emailVerified: boolean;
680
- readonly name: string;
681
- readonly image?: string | null | undefined;
682
- };
683
- readonly session: {
684
- readonly id: string;
685
- readonly createdAt: Date;
686
- readonly updatedAt: Date;
687
- readonly userId: string;
688
- readonly expiresAt: Date;
689
- readonly token: string;
690
- readonly ipAddress?: string | null | undefined;
691
- readonly userAgent?: string | null | undefined;
692
- };
693
- } | null;
694
- readonly isPending: boolean;
695
- readonly isRefetching: boolean;
696
- readonly error: import("better-auth/vue").BetterFetchError | null;
697
- }>>;
698
- <F extends (...args: any) => any>(useFetch: F): Promise<{
699
- data: import("vue").Ref<{
700
- user: {
701
- id: string;
702
- createdAt: Date;
703
- updatedAt: Date;
704
- email: string;
705
- emailVerified: boolean;
706
- name: string;
707
- image?: string | null | undefined;
708
- };
709
- session: {
710
- id: string;
711
- createdAt: Date;
712
- updatedAt: Date;
713
- userId: string;
714
- expiresAt: Date;
715
- token: string;
716
- ipAddress?: string | null | undefined;
717
- userAgent?: string | null | undefined;
718
- };
719
- } | null, {
720
- user: {
721
- id: string;
722
- createdAt: Date;
723
- updatedAt: Date;
724
- email: string;
725
- emailVerified: boolean;
726
- name: string;
727
- image?: string | null | undefined;
728
- };
729
- session: {
730
- id: string;
731
- createdAt: Date;
732
- updatedAt: Date;
733
- userId: string;
734
- expiresAt: Date;
735
- token: string;
736
- ipAddress?: string | null | undefined;
737
- userAgent?: string | null | undefined;
738
- };
739
- } | null>;
740
- isPending: false;
741
- error: import("vue").Ref<{
742
- message?: string | undefined;
743
- status: number;
744
- statusText: string;
745
- }>;
746
- }>;
747
- };
748
- $Infer: {
749
- Session: {
750
- user: {
751
- id: string;
752
- createdAt: Date;
753
- updatedAt: Date;
754
- email: string;
755
- emailVerified: boolean;
756
- name: string;
757
- image?: string | null | undefined;
758
- };
759
- session: {
760
- id: string;
761
- createdAt: Date;
762
- updatedAt: Date;
763
- userId: string;
764
- expiresAt: Date;
765
- token: string;
766
- ipAddress?: string | null | undefined;
767
- userAgent?: string | null | undefined;
768
- };
769
- };
770
- };
771
- $fetch: import("better-auth/vue").BetterFetch<{
772
- plugins: (import("better-auth/vue").BetterFetchPlugin | {
773
- id: string;
774
- name: string;
775
- hooks: {
776
- onSuccess(context: import("better-auth/vue").SuccessContext<any>): void;
777
- };
778
- } | {
779
- id: string;
780
- name: string;
781
- hooks: {
782
- onSuccess: ((context: import("better-auth/vue").SuccessContext<any>) => Promise<void> | void) | undefined;
783
- onError: ((context: import("better-auth/vue").ErrorContext) => Promise<void> | void) | undefined;
784
- onRequest: (<T extends Record<string, any>>(context: import("better-auth/vue").RequestContext<T>) => Promise<import("better-auth/vue").RequestContext | void> | import("better-auth/vue").RequestContext | void) | undefined;
785
- onResponse: ((context: import("better-auth/vue").ResponseContext) => Promise<Response | void | import("better-auth/vue").ResponseContext> | Response | import("better-auth/vue").ResponseContext | void) | undefined;
786
- };
787
- })[];
788
- cache?: RequestCache | undefined;
789
- method: string;
790
- headers?: (HeadersInit & (HeadersInit | {
791
- accept: "application/json" | "text/plain" | "application/octet-stream";
792
- "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
793
- authorization: "Bearer" | "Basic";
794
- })) | undefined;
795
- redirect?: RequestRedirect | undefined;
796
- credentials?: RequestCredentials;
797
- integrity?: string | undefined;
798
- keepalive?: boolean | undefined;
799
- mode?: RequestMode | undefined;
800
- priority?: RequestPriority | undefined;
801
- referrer?: string | undefined;
802
- referrerPolicy?: ReferrerPolicy | undefined;
803
- signal?: (AbortSignal | null) | undefined;
804
- window?: null | undefined;
805
- onRetry?: ((response: import("better-auth/vue").ResponseContext) => Promise<void> | void) | undefined;
806
- hookOptions?: {
807
- cloneResponse?: boolean;
808
- } | undefined;
809
- timeout?: number | undefined;
810
- customFetchImpl: import("better-auth/vue").FetchEsque;
811
- baseURL: string;
812
- throw?: boolean | undefined;
813
- auth?: ({
814
- type: "Bearer";
815
- token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
816
- } | {
817
- type: "Basic";
818
- username: string | (() => string | undefined) | undefined;
819
- password: string | (() => string | undefined) | undefined;
820
- } | {
821
- type: "Custom";
822
- prefix: string | (() => string | undefined) | undefined;
823
- value: string | (() => string | undefined) | undefined;
824
- }) | undefined;
825
- body?: any;
826
- query?: any;
827
- params?: any;
828
- duplex?: "full" | "half" | undefined;
829
- jsonParser: (text: string) => Promise<any> | any;
830
- retry?: import("better-auth/vue").RetryOptions | undefined;
831
- retryAttempt?: number | undefined;
832
- output?: (import("better-auth/vue").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
833
- errorSchema?: import("better-auth/vue").StandardSchemaV1 | undefined;
834
- disableValidation?: boolean | undefined;
835
- disableSignal?: boolean | undefined;
836
- }, unknown, unknown, {}>;
837
- $store: {
838
- notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
839
- listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
840
- atoms: Record<string, import("better-auth/vue").WritableAtom<any>>;
841
- };
842
- $ERROR_CODES: {
843
- readonly USER_NOT_FOUND: "User not found";
844
- readonly FAILED_TO_CREATE_USER: "Failed to create user";
845
- readonly FAILED_TO_CREATE_SESSION: "Failed to create session";
846
- readonly FAILED_TO_UPDATE_USER: "Failed to update user";
847
- readonly FAILED_TO_GET_SESSION: "Failed to get session";
848
- readonly INVALID_PASSWORD: "Invalid password";
849
- readonly INVALID_EMAIL: "Invalid email";
850
- readonly INVALID_EMAIL_OR_PASSWORD: "Invalid email or password";
851
- readonly SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked";
852
- readonly PROVIDER_NOT_FOUND: "Provider not found";
853
- readonly INVALID_TOKEN: "Invalid token";
854
- readonly ID_TOKEN_NOT_SUPPORTED: "id_token not supported";
855
- readonly FAILED_TO_GET_USER_INFO: "Failed to get user info";
856
- readonly USER_EMAIL_NOT_FOUND: "User email not found";
857
- readonly EMAIL_NOT_VERIFIED: "Email not verified";
858
- readonly PASSWORD_TOO_SHORT: "Password too short";
859
- readonly PASSWORD_TOO_LONG: "Password too long";
860
- readonly USER_ALREADY_EXISTS: "User already exists.";
861
- readonly USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.";
862
- readonly EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated";
863
- readonly CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found";
864
- readonly SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.";
865
- readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
866
- readonly ACCOUNT_NOT_FOUND: "Account not found";
867
- readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
868
- };
869
- };
870
- };
871
- export { Capacitor, Preferences };
@@ -1,23 +0,0 @@
1
- import { Capacitor } from "@capacitor/core";
2
- import { Preferences } from "@capacitor/preferences";
3
- import { registerCapacitorHandlers, useAuth } from "./useAuth.js";
4
- const AUTH_TOKEN_KEY = "auth_token";
5
- export function useAuthMobile() {
6
- if (!Capacitor.isNativePlatform()) {
7
- return useAuth();
8
- }
9
- registerCapacitorHandlers({
10
- onSuccess: async (authToken) => {
11
- await Preferences.set({ key: AUTH_TOKEN_KEY, value: authToken });
12
- },
13
- getToken: async () => {
14
- const result = await Preferences.get({ key: AUTH_TOKEN_KEY });
15
- return result?.value || "";
16
- },
17
- clearToken: async () => {
18
- await Preferences.remove({ key: AUTH_TOKEN_KEY });
19
- }
20
- });
21
- return useAuth();
22
- }
23
- export { Capacitor, Preferences };