@fonderie/vue-auth 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,23 @@
1
- import { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IMfaRequiredResult, IRegisterInput, IRegisterResult, IResetPasswordInput, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
2
- export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IMfaRequiredResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult, isMfaRequired } from '@fonderie/client';
1
+ import { FonderieApiError, AuthClient, IChangePasswordInput, ILoginInput, ILoginResult, IMfaRequiredResult, IMfaSetupResult, IMfaEnabledResult, IUserDTO, IUpdateProfileInput, IUpdatePreferencesInput, IRegisterInput, IRegisterResult, IResetPasswordInput, IVerifyEmailResult } from '@fonderie/client';
2
+ export { AuthClient, FonderieApiError, IChangePasswordInput, ILoginInput, ILoginResult, IMfaEnabledResult, IMfaRequiredResult, IMfaSetupResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUpdatePreferencesInput, IUpdateProfileInput, IUserDTO, IVerifyEmailResult, isMfaRequired } from '@fonderie/client';
3
3
  import * as vue from 'vue';
4
+ import { Ref } from 'vue';
5
+
6
+ interface IUseAccountDataReturn {
7
+ exportData: () => Promise<unknown>;
8
+ deleteUser: () => Promise<void>;
9
+ isLoading: Ref<boolean>;
10
+ error: Ref<FonderieApiError | null>;
11
+ }
12
+ declare function useAccountData(client?: AuthClient): IUseAccountDataReturn;
13
+
14
+ interface IUseChangePasswordReturn {
15
+ changePassword: (input: IChangePasswordInput) => Promise<void>;
16
+ isLoading: Ref<boolean>;
17
+ error: Ref<FonderieApiError | null>;
18
+ done: Ref<boolean>;
19
+ }
20
+ declare function useChangePassword(client?: AuthClient): IUseChangePasswordReturn;
4
21
 
5
22
  declare function useForgotPassword(client?: AuthClient): {
6
23
  forgotPassword: (email: string) => Promise<void>;
@@ -105,6 +122,37 @@ declare function useLogout(client?: AuthClient): {
105
122
  error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
106
123
  };
107
124
 
125
+ interface IUseMfaLoginReturn {
126
+ verifyLogin: (mfaToken: string, code: string) => Promise<ILoginResult>;
127
+ isLoading: Ref<boolean>;
128
+ error: Ref<FonderieApiError | null>;
129
+ data: Ref<ILoginResult | null>;
130
+ }
131
+ declare function useMfaLogin(client?: AuthClient): IUseMfaLoginReturn;
132
+
133
+ interface IUseMfaSetupReturn {
134
+ setup: () => Promise<IMfaSetupResult>;
135
+ setupData: Ref<IMfaSetupResult | null>;
136
+ verify: (code: string) => Promise<IMfaEnabledResult>;
137
+ disable: (code: string) => Promise<void>;
138
+ regenerateBackupCodes: (code: string) => Promise<string[]>;
139
+ isLoading: Ref<boolean>;
140
+ error: Ref<FonderieApiError | null>;
141
+ }
142
+ declare function useMfaSetup(client?: AuthClient): IUseMfaSetupReturn;
143
+
144
+ interface IUseProfileReturn {
145
+ user: Ref<IUserDTO | null>;
146
+ refresh: () => Promise<void>;
147
+ updateProfile: (input: IUpdateProfileInput) => Promise<IUserDTO>;
148
+ updatePreferences: (input: IUpdatePreferencesInput) => Promise<IUserDTO>;
149
+ updateEmail: (email: string) => Promise<void>;
150
+ updatePhone: (phone: string) => Promise<void>;
151
+ isLoading: Ref<boolean>;
152
+ error: Ref<FonderieApiError | null>;
153
+ }
154
+ declare function useProfile(client?: AuthClient): IUseProfileReturn;
155
+
108
156
  declare function useRegister(client?: AuthClient): {
109
157
  register: (input: IRegisterInput) => Promise<IRegisterResult>;
110
158
  isLoading: vue.Ref<boolean, boolean>;
@@ -273,6 +321,8 @@ declare function useSession(client?: AuthClient): {
273
321
 
274
322
  declare function useVerifyEmail(client?: AuthClient): {
275
323
  verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
324
+ resend: () => Promise<void>;
325
+ resent: vue.Ref<boolean, boolean>;
276
326
  isLoading: vue.Ref<boolean, boolean>;
277
327
  error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
278
328
  data: vue.Ref<{
@@ -284,4 +334,9 @@ declare function useVerifyEmail(client?: AuthClient): {
284
334
  } | null>;
285
335
  };
286
336
 
287
- export { useForgotPassword, useLogin, useLogout, useRegister, useResetPassword, useSession, useVerifyEmail };
337
+ declare const TOKEN_KEY = "fonderie_access_token";
338
+ declare function persistToken(token: string): void;
339
+ declare function clearToken(): void;
340
+ declare function readToken(): string | null;
341
+
342
+ export { type IUseAccountDataReturn, type IUseChangePasswordReturn, type IUseMfaLoginReturn, type IUseMfaSetupReturn, type IUseProfileReturn, TOKEN_KEY, clearToken, persistToken, readToken, useAccountData, useChangePassword, useForgotPassword, useLogin, useLogout, useMfaLogin, useMfaSetup, useProfile, useRegister, useResetPassword, useSession, useVerifyEmail };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,23 @@
1
- import { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IMfaRequiredResult, IRegisterInput, IRegisterResult, IResetPasswordInput, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
2
- export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IMfaRequiredResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult, isMfaRequired } from '@fonderie/client';
1
+ import { FonderieApiError, AuthClient, IChangePasswordInput, ILoginInput, ILoginResult, IMfaRequiredResult, IMfaSetupResult, IMfaEnabledResult, IUserDTO, IUpdateProfileInput, IUpdatePreferencesInput, IRegisterInput, IRegisterResult, IResetPasswordInput, IVerifyEmailResult } from '@fonderie/client';
2
+ export { AuthClient, FonderieApiError, IChangePasswordInput, ILoginInput, ILoginResult, IMfaEnabledResult, IMfaRequiredResult, IMfaSetupResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUpdatePreferencesInput, IUpdateProfileInput, IUserDTO, IVerifyEmailResult, isMfaRequired } from '@fonderie/client';
3
3
  import * as vue from 'vue';
4
+ import { Ref } from 'vue';
5
+
6
+ interface IUseAccountDataReturn {
7
+ exportData: () => Promise<unknown>;
8
+ deleteUser: () => Promise<void>;
9
+ isLoading: Ref<boolean>;
10
+ error: Ref<FonderieApiError | null>;
11
+ }
12
+ declare function useAccountData(client?: AuthClient): IUseAccountDataReturn;
13
+
14
+ interface IUseChangePasswordReturn {
15
+ changePassword: (input: IChangePasswordInput) => Promise<void>;
16
+ isLoading: Ref<boolean>;
17
+ error: Ref<FonderieApiError | null>;
18
+ done: Ref<boolean>;
19
+ }
20
+ declare function useChangePassword(client?: AuthClient): IUseChangePasswordReturn;
4
21
 
5
22
  declare function useForgotPassword(client?: AuthClient): {
6
23
  forgotPassword: (email: string) => Promise<void>;
@@ -105,6 +122,37 @@ declare function useLogout(client?: AuthClient): {
105
122
  error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
106
123
  };
107
124
 
125
+ interface IUseMfaLoginReturn {
126
+ verifyLogin: (mfaToken: string, code: string) => Promise<ILoginResult>;
127
+ isLoading: Ref<boolean>;
128
+ error: Ref<FonderieApiError | null>;
129
+ data: Ref<ILoginResult | null>;
130
+ }
131
+ declare function useMfaLogin(client?: AuthClient): IUseMfaLoginReturn;
132
+
133
+ interface IUseMfaSetupReturn {
134
+ setup: () => Promise<IMfaSetupResult>;
135
+ setupData: Ref<IMfaSetupResult | null>;
136
+ verify: (code: string) => Promise<IMfaEnabledResult>;
137
+ disable: (code: string) => Promise<void>;
138
+ regenerateBackupCodes: (code: string) => Promise<string[]>;
139
+ isLoading: Ref<boolean>;
140
+ error: Ref<FonderieApiError | null>;
141
+ }
142
+ declare function useMfaSetup(client?: AuthClient): IUseMfaSetupReturn;
143
+
144
+ interface IUseProfileReturn {
145
+ user: Ref<IUserDTO | null>;
146
+ refresh: () => Promise<void>;
147
+ updateProfile: (input: IUpdateProfileInput) => Promise<IUserDTO>;
148
+ updatePreferences: (input: IUpdatePreferencesInput) => Promise<IUserDTO>;
149
+ updateEmail: (email: string) => Promise<void>;
150
+ updatePhone: (phone: string) => Promise<void>;
151
+ isLoading: Ref<boolean>;
152
+ error: Ref<FonderieApiError | null>;
153
+ }
154
+ declare function useProfile(client?: AuthClient): IUseProfileReturn;
155
+
108
156
  declare function useRegister(client?: AuthClient): {
109
157
  register: (input: IRegisterInput) => Promise<IRegisterResult>;
110
158
  isLoading: vue.Ref<boolean, boolean>;
@@ -273,6 +321,8 @@ declare function useSession(client?: AuthClient): {
273
321
 
274
322
  declare function useVerifyEmail(client?: AuthClient): {
275
323
  verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
324
+ resend: () => Promise<void>;
325
+ resent: vue.Ref<boolean, boolean>;
276
326
  isLoading: vue.Ref<boolean, boolean>;
277
327
  error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
278
328
  data: vue.Ref<{
@@ -284,4 +334,9 @@ declare function useVerifyEmail(client?: AuthClient): {
284
334
  } | null>;
285
335
  };
286
336
 
287
- export { useForgotPassword, useLogin, useLogout, useRegister, useResetPassword, useSession, useVerifyEmail };
337
+ declare const TOKEN_KEY = "fonderie_access_token";
338
+ declare function persistToken(token: string): void;
339
+ declare function clearToken(): void;
340
+ declare function readToken(): string | null;
341
+
342
+ export { type IUseAccountDataReturn, type IUseChangePasswordReturn, type IUseMfaLoginReturn, type IUseMfaSetupReturn, type IUseProfileReturn, TOKEN_KEY, clearToken, persistToken, readToken, useAccountData, useChangePassword, useForgotPassword, useLogin, useLogout, useMfaLogin, useMfaSetup, useProfile, useRegister, useResetPassword, useSession, useVerifyEmail };
package/dist/index.js CHANGED
@@ -1,21 +1,33 @@
1
1
  // src/index.ts
2
- import { FonderieApiError as FonderieApiError7, isMfaRequired as isMfaRequired2 } from "@fonderie/client";
2
+ import { FonderieApiError as FonderieApiError12, isMfaRequired as isMfaRequired2 } from "@fonderie/client";
3
3
 
4
- // src/composables/useForgotPassword.ts
4
+ // src/composables/useAccountData.ts
5
5
  import { FonderieApiError } from "@fonderie/client";
6
6
  import { useFonderieSubClient } from "@fonderie/vue";
7
7
  import { ref } from "vue";
8
- function useForgotPassword(client) {
9
- const auth = useFonderieSubClient(client, (c) => c.auth, "useForgotPassword");
8
+
9
+ // src/storage.ts
10
+ var TOKEN_KEY = "fonderie_access_token";
11
+ function persistToken(token) {
12
+ localStorage.setItem(TOKEN_KEY, token);
13
+ }
14
+ function clearToken() {
15
+ localStorage.removeItem(TOKEN_KEY);
16
+ }
17
+ function readToken() {
18
+ return localStorage.getItem(TOKEN_KEY);
19
+ }
20
+
21
+ // src/composables/useAccountData.ts
22
+ function useAccountData(client) {
23
+ const auth = useFonderieSubClient(client, (c) => c.auth, "useAccountData");
10
24
  const isLoading = ref(false);
11
25
  const error = ref(null);
12
- const sent = ref(false);
13
- async function forgotPassword(email) {
26
+ async function run(op) {
14
27
  isLoading.value = true;
15
28
  error.value = null;
16
29
  try {
17
- await auth.forgotPassword(email);
18
- sent.value = true;
30
+ return await op();
19
31
  } catch (err) {
20
32
  const apiError = err instanceof FonderieApiError ? err : new FonderieApiError("unknown", String(err), 0);
21
33
  error.value = apiError;
@@ -24,33 +36,85 @@ function useForgotPassword(client) {
24
36
  isLoading.value = false;
25
37
  }
26
38
  }
27
- return { forgotPassword, isLoading, error, sent };
39
+ function exportData() {
40
+ return run(async () => {
41
+ const { result } = await auth.exportData();
42
+ return result;
43
+ });
44
+ }
45
+ function deleteUser() {
46
+ return run(async () => {
47
+ await auth.deleteUser();
48
+ auth.setAccessToken(void 0);
49
+ clearToken();
50
+ });
51
+ }
52
+ return { exportData, deleteUser, isLoading, error };
28
53
  }
29
54
 
30
- // src/composables/useLogin.ts
31
- import { FonderieApiError as FonderieApiError2, isMfaRequired } from "@fonderie/client";
55
+ // src/composables/useChangePassword.ts
56
+ import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
32
57
  import { useFonderieSubClient as useFonderieSubClient2 } from "@fonderie/vue";
33
58
  import { ref as ref2 } from "vue";
34
-
35
- // src/storage.ts
36
- var TOKEN_KEY = "fonderie_access_token";
37
- function persistToken(token) {
38
- localStorage.setItem(TOKEN_KEY, token);
39
- }
40
- function clearToken() {
41
- localStorage.removeItem(TOKEN_KEY);
59
+ function useChangePassword(client) {
60
+ const auth = useFonderieSubClient2(client, (c) => c.auth, "useChangePassword");
61
+ const isLoading = ref2(false);
62
+ const error = ref2(null);
63
+ const done = ref2(false);
64
+ async function changePassword(input) {
65
+ isLoading.value = true;
66
+ error.value = null;
67
+ done.value = false;
68
+ try {
69
+ await auth.changePassword(input);
70
+ done.value = true;
71
+ } catch (err) {
72
+ const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
73
+ error.value = apiError;
74
+ throw apiError;
75
+ } finally {
76
+ isLoading.value = false;
77
+ }
78
+ }
79
+ return { changePassword, isLoading, error, done };
42
80
  }
43
- function readToken() {
44
- return localStorage.getItem(TOKEN_KEY);
81
+
82
+ // src/composables/useForgotPassword.ts
83
+ import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
84
+ import { useFonderieSubClient as useFonderieSubClient3 } from "@fonderie/vue";
85
+ import { ref as ref3 } from "vue";
86
+ function useForgotPassword(client) {
87
+ const auth = useFonderieSubClient3(client, (c) => c.auth, "useForgotPassword");
88
+ const isLoading = ref3(false);
89
+ const error = ref3(null);
90
+ const sent = ref3(false);
91
+ async function forgotPassword(email) {
92
+ isLoading.value = true;
93
+ error.value = null;
94
+ try {
95
+ await auth.forgotPassword(email);
96
+ sent.value = true;
97
+ } catch (err) {
98
+ const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
99
+ error.value = apiError;
100
+ throw apiError;
101
+ } finally {
102
+ isLoading.value = false;
103
+ }
104
+ }
105
+ return { forgotPassword, isLoading, error, sent };
45
106
  }
46
107
 
47
108
  // src/composables/useLogin.ts
109
+ import { FonderieApiError as FonderieApiError4, isMfaRequired } from "@fonderie/client";
110
+ import { useFonderieSubClient as useFonderieSubClient4 } from "@fonderie/vue";
111
+ import { ref as ref4 } from "vue";
48
112
  function useLogin(client) {
49
- const auth = useFonderieSubClient2(client, (c) => c.auth, "useLogin");
50
- const isLoading = ref2(false);
51
- const error = ref2(null);
52
- const data = ref2(null);
53
- const mfaPending = ref2(null);
113
+ const auth = useFonderieSubClient4(client, (c) => c.auth, "useLogin");
114
+ const isLoading = ref4(false);
115
+ const error = ref4(null);
116
+ const data = ref4(null);
117
+ const mfaPending = ref4(null);
54
118
  async function login(input) {
55
119
  isLoading.value = true;
56
120
  error.value = null;
@@ -66,7 +130,7 @@ function useLogin(client) {
66
130
  data.value = result;
67
131
  return result;
68
132
  } catch (err) {
69
- const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
133
+ const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
70
134
  error.value = apiError;
71
135
  throw apiError;
72
136
  } finally {
@@ -77,20 +141,20 @@ function useLogin(client) {
77
141
  }
78
142
 
79
143
  // src/composables/useLogout.ts
80
- import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
81
- import { useFonderieSubClient as useFonderieSubClient3 } from "@fonderie/vue";
82
- import { ref as ref3 } from "vue";
144
+ import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
145
+ import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/vue";
146
+ import { ref as ref5 } from "vue";
83
147
  function useLogout(client) {
84
- const auth = useFonderieSubClient3(client, (c) => c.auth, "useLogout");
85
- const isLoading = ref3(false);
86
- const error = ref3(null);
148
+ const auth = useFonderieSubClient5(client, (c) => c.auth, "useLogout");
149
+ const isLoading = ref5(false);
150
+ const error = ref5(null);
87
151
  async function logout(refreshToken) {
88
152
  isLoading.value = true;
89
153
  error.value = null;
90
154
  try {
91
155
  await auth.logout(refreshToken);
92
156
  } catch (err) {
93
- const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
157
+ const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
94
158
  error.value = apiError;
95
159
  } finally {
96
160
  auth.setAccessToken(void 0);
@@ -101,15 +165,157 @@ function useLogout(client) {
101
165
  return { logout, isLoading, error };
102
166
  }
103
167
 
168
+ // src/composables/useMfaLogin.ts
169
+ import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
170
+ import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/vue";
171
+ import { ref as ref6 } from "vue";
172
+ function useMfaLogin(client) {
173
+ const auth = useFonderieSubClient6(client, (c) => c.auth, "useMfaLogin");
174
+ const isLoading = ref6(false);
175
+ const error = ref6(null);
176
+ const data = ref6(null);
177
+ async function verifyLogin(mfaToken, code) {
178
+ isLoading.value = true;
179
+ error.value = null;
180
+ try {
181
+ const { result } = await auth.mfa.verifyLogin(mfaToken, code);
182
+ auth.setAccessToken(result.tokens.access);
183
+ persistToken(result.tokens.access);
184
+ data.value = result;
185
+ return result;
186
+ } catch (err) {
187
+ const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
188
+ error.value = apiError;
189
+ throw apiError;
190
+ } finally {
191
+ isLoading.value = false;
192
+ }
193
+ }
194
+ return { verifyLogin, isLoading, error, data };
195
+ }
196
+
197
+ // src/composables/useMfaSetup.ts
198
+ import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
199
+ import { useFonderieSubClient as useFonderieSubClient7 } from "@fonderie/vue";
200
+ import { ref as ref7 } from "vue";
201
+ function useMfaSetup(client) {
202
+ const auth = useFonderieSubClient7(client, (c) => c.auth, "useMfaSetup");
203
+ const setupData = ref7(null);
204
+ const isLoading = ref7(false);
205
+ const error = ref7(null);
206
+ async function run(op) {
207
+ isLoading.value = true;
208
+ error.value = null;
209
+ try {
210
+ return await op();
211
+ } catch (err) {
212
+ const apiError = err instanceof FonderieApiError7 ? err : new FonderieApiError7("unknown", String(err), 0);
213
+ error.value = apiError;
214
+ throw apiError;
215
+ } finally {
216
+ isLoading.value = false;
217
+ }
218
+ }
219
+ function setup() {
220
+ return run(async () => {
221
+ const { result } = await auth.mfa.setup();
222
+ setupData.value = result;
223
+ return result;
224
+ });
225
+ }
226
+ function verify(code) {
227
+ return run(async () => {
228
+ const { result } = await auth.mfa.verify(code);
229
+ auth.setAccessToken(result.tokens.access);
230
+ persistToken(result.tokens.access);
231
+ return result;
232
+ });
233
+ }
234
+ function disable(code) {
235
+ return run(async () => {
236
+ await auth.mfa.disable(code);
237
+ });
238
+ }
239
+ function regenerateBackupCodes(code) {
240
+ return run(async () => {
241
+ const { result } = await auth.mfa.regenerateBackupCodes(code);
242
+ return result.backupCodes;
243
+ });
244
+ }
245
+ return { setup, setupData, verify, disable, regenerateBackupCodes, isLoading, error };
246
+ }
247
+
248
+ // src/composables/useProfile.ts
249
+ import { FonderieApiError as FonderieApiError8 } from "@fonderie/client";
250
+ import { useFonderieSubClient as useFonderieSubClient8 } from "@fonderie/vue";
251
+ import { ref as ref8 } from "vue";
252
+ function useProfile(client) {
253
+ const auth = useFonderieSubClient8(client, (c) => c.auth, "useProfile");
254
+ const user = ref8(null);
255
+ const isLoading = ref8(true);
256
+ const error = ref8(null);
257
+ async function refresh() {
258
+ isLoading.value = true;
259
+ error.value = null;
260
+ try {
261
+ const { result } = await auth.getUser();
262
+ user.value = result.user;
263
+ } catch (err) {
264
+ const apiError = err instanceof FonderieApiError8 ? err : new FonderieApiError8("unknown", String(err), 0);
265
+ error.value = apiError;
266
+ } finally {
267
+ isLoading.value = false;
268
+ }
269
+ }
270
+ async function mutate(op) {
271
+ error.value = null;
272
+ try {
273
+ return await op();
274
+ } catch (err) {
275
+ const apiError = err instanceof FonderieApiError8 ? err : new FonderieApiError8("unknown", String(err), 0);
276
+ error.value = apiError;
277
+ throw apiError;
278
+ }
279
+ }
280
+ function updateProfile(input) {
281
+ return mutate(async () => {
282
+ const { result } = await auth.updateProfile(input);
283
+ user.value = result.user;
284
+ return result.user;
285
+ });
286
+ }
287
+ function updatePreferences(input) {
288
+ return mutate(async () => {
289
+ const { result } = await auth.updatePreferences(input);
290
+ user.value = result.user;
291
+ return result.user;
292
+ });
293
+ }
294
+ function updateEmail(email) {
295
+ return mutate(async () => {
296
+ await auth.updateEmail(email);
297
+ await refresh();
298
+ });
299
+ }
300
+ function updatePhone(phone) {
301
+ return mutate(async () => {
302
+ await auth.updatePhone(phone);
303
+ await refresh();
304
+ });
305
+ }
306
+ void refresh();
307
+ return { user, refresh, updateProfile, updatePreferences, updateEmail, updatePhone, isLoading, error };
308
+ }
309
+
104
310
  // src/composables/useRegister.ts
105
- import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
106
- import { useFonderieSubClient as useFonderieSubClient4 } from "@fonderie/vue";
107
- import { ref as ref4 } from "vue";
311
+ import { FonderieApiError as FonderieApiError9 } from "@fonderie/client";
312
+ import { useFonderieSubClient as useFonderieSubClient9 } from "@fonderie/vue";
313
+ import { ref as ref9 } from "vue";
108
314
  function useRegister(client) {
109
- const auth = useFonderieSubClient4(client, (c) => c.auth, "useRegister");
110
- const isLoading = ref4(false);
111
- const error = ref4(null);
112
- const data = ref4(null);
315
+ const auth = useFonderieSubClient9(client, (c) => c.auth, "useRegister");
316
+ const isLoading = ref9(false);
317
+ const error = ref9(null);
318
+ const data = ref9(null);
113
319
  async function register(input) {
114
320
  isLoading.value = true;
115
321
  error.value = null;
@@ -120,7 +326,7 @@ function useRegister(client) {
120
326
  data.value = result;
121
327
  return result;
122
328
  } catch (err) {
123
- const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
329
+ const apiError = err instanceof FonderieApiError9 ? err : new FonderieApiError9("unknown", String(err), 0);
124
330
  error.value = apiError;
125
331
  throw apiError;
126
332
  } finally {
@@ -131,14 +337,14 @@ function useRegister(client) {
131
337
  }
132
338
 
133
339
  // src/composables/useResetPassword.ts
134
- import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
135
- import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/vue";
136
- import { ref as ref5 } from "vue";
340
+ import { FonderieApiError as FonderieApiError10 } from "@fonderie/client";
341
+ import { useFonderieSubClient as useFonderieSubClient10 } from "@fonderie/vue";
342
+ import { ref as ref10 } from "vue";
137
343
  function useResetPassword(client) {
138
- const auth = useFonderieSubClient5(client, (c) => c.auth, "useResetPassword");
139
- const isLoading = ref5(false);
140
- const error = ref5(null);
141
- const done = ref5(false);
344
+ const auth = useFonderieSubClient10(client, (c) => c.auth, "useResetPassword");
345
+ const isLoading = ref10(false);
346
+ const error = ref10(null);
347
+ const done = ref10(false);
142
348
  async function resetPassword(input) {
143
349
  isLoading.value = true;
144
350
  error.value = null;
@@ -146,7 +352,7 @@ function useResetPassword(client) {
146
352
  await auth.resetPassword(input);
147
353
  done.value = true;
148
354
  } catch (err) {
149
- const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
355
+ const apiError = err instanceof FonderieApiError10 ? err : new FonderieApiError10("unknown", String(err), 0);
150
356
  error.value = apiError;
151
357
  throw apiError;
152
358
  } finally {
@@ -157,13 +363,13 @@ function useResetPassword(client) {
157
363
  }
158
364
 
159
365
  // src/composables/useSession.ts
160
- import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/vue";
161
- import { ref as ref6 } from "vue";
366
+ import { useFonderieSubClient as useFonderieSubClient11 } from "@fonderie/vue";
367
+ import { ref as ref11 } from "vue";
162
368
  function useSession(client) {
163
- const auth = useFonderieSubClient6(client, (c) => c.auth, "useSession");
164
- const user = ref6(null);
165
- const isLoading = ref6(true);
166
- const isAuthenticated = ref6(false);
369
+ const auth = useFonderieSubClient11(client, (c) => c.auth, "useSession");
370
+ const user = ref11(null);
371
+ const isLoading = ref11(true);
372
+ const isAuthenticated = ref11(false);
167
373
  async function refresh() {
168
374
  isLoading.value = true;
169
375
  try {
@@ -196,14 +402,30 @@ function useSession(client) {
196
402
  }
197
403
 
198
404
  // src/composables/useVerifyEmail.ts
199
- import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
200
- import { useFonderieSubClient as useFonderieSubClient7 } from "@fonderie/vue";
201
- import { ref as ref7 } from "vue";
405
+ import { FonderieApiError as FonderieApiError11 } from "@fonderie/client";
406
+ import { useFonderieSubClient as useFonderieSubClient12 } from "@fonderie/vue";
407
+ import { ref as ref12 } from "vue";
202
408
  function useVerifyEmail(client) {
203
- const auth = useFonderieSubClient7(client, (c) => c.auth, "useVerifyEmail");
204
- const isLoading = ref7(false);
205
- const error = ref7(null);
206
- const data = ref7(null);
409
+ const auth = useFonderieSubClient12(client, (c) => c.auth, "useVerifyEmail");
410
+ const isLoading = ref12(false);
411
+ const error = ref12(null);
412
+ const data = ref12(null);
413
+ const resent = ref12(false);
414
+ async function resend() {
415
+ isLoading.value = true;
416
+ error.value = null;
417
+ resent.value = false;
418
+ try {
419
+ await auth.sendVerificationEmail();
420
+ resent.value = true;
421
+ } catch (err) {
422
+ const apiError = err instanceof FonderieApiError11 ? err : new FonderieApiError11("unknown", String(err), 0);
423
+ error.value = apiError;
424
+ throw apiError;
425
+ } finally {
426
+ isLoading.value = false;
427
+ }
428
+ }
207
429
  async function verifyEmail(pin) {
208
430
  isLoading.value = true;
209
431
  error.value = null;
@@ -212,21 +434,30 @@ function useVerifyEmail(client) {
212
434
  data.value = result;
213
435
  return result;
214
436
  } catch (err) {
215
- const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
437
+ const apiError = err instanceof FonderieApiError11 ? err : new FonderieApiError11("unknown", String(err), 0);
216
438
  error.value = apiError;
217
439
  throw apiError;
218
440
  } finally {
219
441
  isLoading.value = false;
220
442
  }
221
443
  }
222
- return { verifyEmail, isLoading, error, data };
444
+ return { verifyEmail, resend, resent, isLoading, error, data };
223
445
  }
224
446
  export {
225
- FonderieApiError7 as FonderieApiError,
447
+ FonderieApiError12 as FonderieApiError,
448
+ TOKEN_KEY,
449
+ clearToken,
226
450
  isMfaRequired2 as isMfaRequired,
451
+ persistToken,
452
+ readToken,
453
+ useAccountData,
454
+ useChangePassword,
227
455
  useForgotPassword,
228
456
  useLogin,
229
457
  useLogout,
458
+ useMfaLogin,
459
+ useMfaSetup,
460
+ useProfile,
230
461
  useRegister,
231
462
  useResetPassword,
232
463
  useSession,