@fonderie/vue-auth 0.1.0 → 0.2.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/README.md +22 -4
- package/dist/index.cjs +55 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Vue 3 composables for Fonderie auth — `useLogin`, `useRegister`,
|
|
4
4
|
`useSession`, `useLogout`, `useForgotPassword`, `useResetPassword`, and
|
|
5
5
|
`useVerifyEmail`. Thin bindings over
|
|
6
|
-
[`@fonderie/client`](https://github.com/
|
|
6
|
+
[`@fonderie/client`](https://github.com/fonderiejs/sdk/tree/main/packages/client):
|
|
7
7
|
reactive `ref`s for loading/error/data state and the request itself, nothing
|
|
8
8
|
else. Bring your own UI.
|
|
9
9
|
|
|
@@ -13,6 +13,24 @@ else. Bring your own UI.
|
|
|
13
13
|
npm install @fonderie/vue-auth
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## One client at the root (recommended)
|
|
17
|
+
|
|
18
|
+
Install the plugin from [`@fonderie/vue`](../vue) once (or call
|
|
19
|
+
`provideFonderie(client)` in a root `setup()`) and every composable resolves
|
|
20
|
+
the client by injection — no client argument at call sites:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { FonderiePlugin } from "@fonderie/vue";
|
|
24
|
+
|
|
25
|
+
createApp(App).use(FonderiePlugin, client).mount("#app");
|
|
26
|
+
|
|
27
|
+
// in any component setup():
|
|
28
|
+
const { ...state } = useLogin();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Passing a client explicitly (as below) still works everywhere and takes
|
|
32
|
+
precedence over injection — handy in tests and multi-client apps.
|
|
33
|
+
|
|
16
34
|
## Use
|
|
17
35
|
|
|
18
36
|
```vue
|
|
@@ -39,14 +57,14 @@ or a prop). The access token is persisted to `localStorage` and restored
|
|
|
39
57
|
automatically by `useSession` on setup; don't re-implement that in app code.
|
|
40
58
|
|
|
41
59
|
Want pre-built screens instead of wiring your own form?
|
|
42
|
-
See [`@fonderie/vue-auth-screens`](https://github.com/
|
|
60
|
+
See [`@fonderie/vue-auth-screens`](https://github.com/fonderiejs/sdk/tree/main/packages/vue-auth-screens).
|
|
43
61
|
|
|
44
62
|
## Why this exists
|
|
45
63
|
|
|
46
64
|
You've shipped this plumbing before — auth, teams, billing, messaging —
|
|
47
65
|
and the next project will ask for it again. Fonderie packages it once:
|
|
48
66
|
plain TypeScript modules for
|
|
49
|
-
[`@fonderie/core`](https://github.com/
|
|
67
|
+
[`@fonderie/core`](https://github.com/fonderiejs/sdk/tree/main/packages/core),
|
|
50
68
|
PostgreSQL-backed, self-hosted, MIT. No external control plane, no
|
|
51
69
|
per-seat anything. Register the modules you need; skip the ones you don't.
|
|
52
70
|
|
|
@@ -55,7 +73,7 @@ around `@fonderie/client`, nothing more. No business logic lives here; it
|
|
|
55
73
|
lives in `@fonderie/auth` on the server.
|
|
56
74
|
|
|
57
75
|
Browse the whole set at
|
|
58
|
-
[
|
|
76
|
+
[fonderiejs/sdk](https://github.com/fonderiejs/sdk) · follow
|
|
59
77
|
[@fonderiejs](https://x.com/fonderiejs)
|
|
60
78
|
|
|
61
79
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -34,16 +34,18 @@ var import_client7 = require("@fonderie/client");
|
|
|
34
34
|
|
|
35
35
|
// src/composables/useForgotPassword.ts
|
|
36
36
|
var import_client = require("@fonderie/client");
|
|
37
|
-
var import_vue = require("vue");
|
|
37
|
+
var import_vue = require("@fonderie/vue");
|
|
38
|
+
var import_vue2 = require("vue");
|
|
38
39
|
function useForgotPassword(client) {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const auth = (0, import_vue.useFonderieSubClient)(client, (c) => c.auth, "useForgotPassword");
|
|
41
|
+
const isLoading = (0, import_vue2.ref)(false);
|
|
42
|
+
const error = (0, import_vue2.ref)(null);
|
|
43
|
+
const sent = (0, import_vue2.ref)(false);
|
|
42
44
|
async function forgotPassword(email) {
|
|
43
45
|
isLoading.value = true;
|
|
44
46
|
error.value = null;
|
|
45
47
|
try {
|
|
46
|
-
await
|
|
48
|
+
await auth.forgotPassword(email);
|
|
47
49
|
sent.value = true;
|
|
48
50
|
} catch (err) {
|
|
49
51
|
const apiError = err instanceof import_client.FonderieApiError ? err : new import_client.FonderieApiError("unknown", String(err), 0);
|
|
@@ -58,7 +60,8 @@ function useForgotPassword(client) {
|
|
|
58
60
|
|
|
59
61
|
// src/composables/useLogin.ts
|
|
60
62
|
var import_client2 = require("@fonderie/client");
|
|
61
|
-
var
|
|
63
|
+
var import_vue3 = require("@fonderie/vue");
|
|
64
|
+
var import_vue4 = require("vue");
|
|
62
65
|
|
|
63
66
|
// src/storage.ts
|
|
64
67
|
var TOKEN_KEY = "fonderie_access_token";
|
|
@@ -74,15 +77,16 @@ function readToken() {
|
|
|
74
77
|
|
|
75
78
|
// src/composables/useLogin.ts
|
|
76
79
|
function useLogin(client) {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
+
const auth = (0, import_vue3.useFonderieSubClient)(client, (c) => c.auth, "useLogin");
|
|
81
|
+
const isLoading = (0, import_vue4.ref)(false);
|
|
82
|
+
const error = (0, import_vue4.ref)(null);
|
|
83
|
+
const data = (0, import_vue4.ref)(null);
|
|
80
84
|
async function login(input) {
|
|
81
85
|
isLoading.value = true;
|
|
82
86
|
error.value = null;
|
|
83
87
|
try {
|
|
84
|
-
const { result } = await
|
|
85
|
-
|
|
88
|
+
const { result } = await auth.login(input);
|
|
89
|
+
auth.setAccessToken(result.tokens.access);
|
|
86
90
|
persistToken(result.tokens.access);
|
|
87
91
|
data.value = result;
|
|
88
92
|
return result;
|
|
@@ -99,20 +103,22 @@ function useLogin(client) {
|
|
|
99
103
|
|
|
100
104
|
// src/composables/useLogout.ts
|
|
101
105
|
var import_client3 = require("@fonderie/client");
|
|
102
|
-
var
|
|
106
|
+
var import_vue5 = require("@fonderie/vue");
|
|
107
|
+
var import_vue6 = require("vue");
|
|
103
108
|
function useLogout(client) {
|
|
104
|
-
const
|
|
105
|
-
const
|
|
109
|
+
const auth = (0, import_vue5.useFonderieSubClient)(client, (c) => c.auth, "useLogout");
|
|
110
|
+
const isLoading = (0, import_vue6.ref)(false);
|
|
111
|
+
const error = (0, import_vue6.ref)(null);
|
|
106
112
|
async function logout() {
|
|
107
113
|
isLoading.value = true;
|
|
108
114
|
error.value = null;
|
|
109
115
|
try {
|
|
110
|
-
await
|
|
116
|
+
await auth.logout();
|
|
111
117
|
} catch (err) {
|
|
112
118
|
const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
|
|
113
119
|
error.value = apiError;
|
|
114
120
|
} finally {
|
|
115
|
-
|
|
121
|
+
auth.setAccessToken(void 0);
|
|
116
122
|
clearToken();
|
|
117
123
|
isLoading.value = false;
|
|
118
124
|
}
|
|
@@ -122,17 +128,19 @@ function useLogout(client) {
|
|
|
122
128
|
|
|
123
129
|
// src/composables/useRegister.ts
|
|
124
130
|
var import_client4 = require("@fonderie/client");
|
|
125
|
-
var
|
|
131
|
+
var import_vue7 = require("@fonderie/vue");
|
|
132
|
+
var import_vue8 = require("vue");
|
|
126
133
|
function useRegister(client) {
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
134
|
+
const auth = (0, import_vue7.useFonderieSubClient)(client, (c) => c.auth, "useRegister");
|
|
135
|
+
const isLoading = (0, import_vue8.ref)(false);
|
|
136
|
+
const error = (0, import_vue8.ref)(null);
|
|
137
|
+
const data = (0, import_vue8.ref)(null);
|
|
130
138
|
async function register(input) {
|
|
131
139
|
isLoading.value = true;
|
|
132
140
|
error.value = null;
|
|
133
141
|
try {
|
|
134
|
-
const { result } = await
|
|
135
|
-
|
|
142
|
+
const { result } = await auth.register(input);
|
|
143
|
+
auth.setAccessToken(result.tokens.access);
|
|
136
144
|
persistToken(result.tokens.access);
|
|
137
145
|
data.value = result;
|
|
138
146
|
return result;
|
|
@@ -149,16 +157,18 @@ function useRegister(client) {
|
|
|
149
157
|
|
|
150
158
|
// src/composables/useResetPassword.ts
|
|
151
159
|
var import_client5 = require("@fonderie/client");
|
|
152
|
-
var
|
|
160
|
+
var import_vue9 = require("@fonderie/vue");
|
|
161
|
+
var import_vue10 = require("vue");
|
|
153
162
|
function useResetPassword(client) {
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
163
|
+
const auth = (0, import_vue9.useFonderieSubClient)(client, (c) => c.auth, "useResetPassword");
|
|
164
|
+
const isLoading = (0, import_vue10.ref)(false);
|
|
165
|
+
const error = (0, import_vue10.ref)(null);
|
|
166
|
+
const done = (0, import_vue10.ref)(false);
|
|
157
167
|
async function resetPassword(input) {
|
|
158
168
|
isLoading.value = true;
|
|
159
169
|
error.value = null;
|
|
160
170
|
try {
|
|
161
|
-
await
|
|
171
|
+
await auth.resetPassword(input);
|
|
162
172
|
done.value = true;
|
|
163
173
|
} catch (err) {
|
|
164
174
|
const apiError = err instanceof import_client5.FonderieApiError ? err : new import_client5.FonderieApiError("unknown", String(err), 0);
|
|
@@ -172,21 +182,23 @@ function useResetPassword(client) {
|
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
// src/composables/useSession.ts
|
|
175
|
-
var
|
|
185
|
+
var import_vue11 = require("@fonderie/vue");
|
|
186
|
+
var import_vue12 = require("vue");
|
|
176
187
|
function useSession(client) {
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const
|
|
188
|
+
const auth = (0, import_vue11.useFonderieSubClient)(client, (c) => c.auth, "useSession");
|
|
189
|
+
const user = (0, import_vue12.ref)(null);
|
|
190
|
+
const isLoading = (0, import_vue12.ref)(true);
|
|
191
|
+
const isAuthenticated = (0, import_vue12.ref)(false);
|
|
180
192
|
async function refresh() {
|
|
181
193
|
isLoading.value = true;
|
|
182
194
|
try {
|
|
183
|
-
const { result } = await
|
|
195
|
+
const { result } = await auth.getUser();
|
|
184
196
|
user.value = result.user;
|
|
185
197
|
isAuthenticated.value = true;
|
|
186
198
|
} catch {
|
|
187
199
|
user.value = null;
|
|
188
200
|
isAuthenticated.value = false;
|
|
189
|
-
|
|
201
|
+
auth.setAccessToken(void 0);
|
|
190
202
|
clearToken();
|
|
191
203
|
} finally {
|
|
192
204
|
isLoading.value = false;
|
|
@@ -194,32 +206,34 @@ function useSession(client) {
|
|
|
194
206
|
}
|
|
195
207
|
async function logout() {
|
|
196
208
|
try {
|
|
197
|
-
await
|
|
209
|
+
await auth.logout();
|
|
198
210
|
} catch {
|
|
199
211
|
}
|
|
200
|
-
|
|
212
|
+
auth.setAccessToken(void 0);
|
|
201
213
|
clearToken();
|
|
202
214
|
user.value = null;
|
|
203
215
|
isAuthenticated.value = false;
|
|
204
216
|
}
|
|
205
217
|
const token = readToken();
|
|
206
|
-
if (token)
|
|
218
|
+
if (token) auth.setAccessToken(token);
|
|
207
219
|
void refresh();
|
|
208
220
|
return { user, isLoading, isAuthenticated, refresh, logout };
|
|
209
221
|
}
|
|
210
222
|
|
|
211
223
|
// src/composables/useVerifyEmail.ts
|
|
212
224
|
var import_client6 = require("@fonderie/client");
|
|
213
|
-
var
|
|
225
|
+
var import_vue13 = require("@fonderie/vue");
|
|
226
|
+
var import_vue14 = require("vue");
|
|
214
227
|
function useVerifyEmail(client) {
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
228
|
+
const auth = (0, import_vue13.useFonderieSubClient)(client, (c) => c.auth, "useVerifyEmail");
|
|
229
|
+
const isLoading = (0, import_vue14.ref)(false);
|
|
230
|
+
const error = (0, import_vue14.ref)(null);
|
|
231
|
+
const data = (0, import_vue14.ref)(null);
|
|
218
232
|
async function verifyEmail(pin) {
|
|
219
233
|
isLoading.value = true;
|
|
220
234
|
error.value = null;
|
|
221
235
|
try {
|
|
222
|
-
const { result } = await
|
|
236
|
+
const { result } = await auth.verifyEmail(pin);
|
|
223
237
|
data.value = result;
|
|
224
238
|
return result;
|
|
225
239
|
} catch (err) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/useForgotPassword.ts","../src/composables/useLogin.ts","../src/storage.ts","../src/composables/useLogout.ts","../src/composables/useRegister.ts","../src/composables/useResetPassword.ts","../src/composables/useSession.ts","../src/composables/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\n\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './composables';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useForgotPassword(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst sent = ref(false);\n\n\tasync function forgotPassword(email: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.forgotPassword(email);\n\t\t\tsent.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useLogin(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<ILoginResult | null>(null);\n\n\tasync function login(input: ILoginInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.login(input);\n\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { login, isLoading, error, data };\n}\n","export const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\tlocalStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\tlocalStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken(): string | null {\n\treturn localStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { clearToken } from '../storage';\n\nexport function useLogout(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function logout() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useRegister(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IRegisterResult | null>(null);\n\n\tasync function register(input: IRegisterInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.register(input);\n\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useResetPassword(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst done = ref(false);\n\n\tasync function resetPassword(input: IResetPasswordInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.resetPassword(input);\n\t\t\tdone.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { clearToken, readToken } from '../storage';\n\nexport function useSession(client: AuthClient) {\n\tconst user = ref<IUserDTO | null>(null);\n\tconst isLoading = ref(true);\n\tconst isAuthenticated = ref(false);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\ttry {\n\t\t\tconst { result } = await client.getUser();\n\t\t\tuser.value = result.user;\n\t\t\tisAuthenticated.value = true;\n\t\t} catch {\n\t\t\tuser.value = null;\n\t\t\tisAuthenticated.value = false;\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function logout() {\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tclient.setAccessToken(undefined);\n\t\tclearToken();\n\t\tuser.value = null;\n\t\tisAuthenticated.value = false;\n\t}\n\n\tconst token = readToken();\n\tif (token) client.setAccessToken(token);\n\tvoid refresh();\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useVerifyEmail(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IVerifyEmailResult | null>(null);\n\n\tasync function verifyEmail(pin: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.verifyEmail(pin);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,IAAAA,iBAAiC;;;ACXjC,oBAAiC;AACjC,iBAAoB;AAEb,SAAS,kBAAkB,QAAoB;AACrD,QAAM,gBAAY,gBAAI,KAAK;AAC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S,OAAO;AAC5D;;;ACzCA,IAAAC,iBAAiC;AACjC,IAAAC,cAAoB;AAEb,SAAS,eAAe,QAAoB;AAClD,QAAM,gBAAY,iBAAI,KAAK;AAC3B,QAAM,YAAQ,iBAA6B,IAAI;AAC/C,QAAM,WAAO,iBAA+B,IAAI;AAEhD,iBAAe,YAAY,KAAa;AACvC,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,GAAG;AAC/C,WAAK,QAAQ;AACb,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,SAAO,EAAE,aAAa,WAAW,OAAO,KAAK;AAC9C;","names":["import_client","import_client","import_vue","import_client","import_vue","import_client","import_vue","import_client","import_vue","import_vue","import_client","import_vue"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/composables/useForgotPassword.ts","../src/composables/useLogin.ts","../src/storage.ts","../src/composables/useLogout.ts","../src/composables/useRegister.ts","../src/composables/useResetPassword.ts","../src/composables/useSession.ts","../src/composables/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\n\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './composables';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useForgotPassword(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useForgotPassword');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst sent = ref(false);\n\n\tasync function forgotPassword(email: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.forgotPassword(email);\n\t\t\tsent.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useLogin(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useLogin');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<ILoginResult | null>(null);\n\n\tasync function login(input: ILoginInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.login(input);\n\t\t\tauth.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { login, isLoading, error, data };\n}\n","export const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\tlocalStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\tlocalStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken(): string | null {\n\treturn localStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { clearToken } from '../storage';\n\nexport function useLogout(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useLogout');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function logout() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tauth.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useRegister(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useRegister');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IRegisterResult | null>(null);\n\n\tasync function register(input: IRegisterInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.register(input);\n\t\t\tauth.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useResetPassword(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useResetPassword');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst done = ref(false);\n\n\tasync function resetPassword(input: IResetPasswordInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.resetPassword(input);\n\t\t\tdone.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { clearToken, readToken } from '../storage';\n\nexport function useSession(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useSession');\n\tconst user = ref<IUserDTO | null>(null);\n\tconst isLoading = ref(true);\n\tconst isAuthenticated = ref(false);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\ttry {\n\t\t\tconst { result } = await auth.getUser();\n\t\t\tuser.value = result.user;\n\t\t\tisAuthenticated.value = true;\n\t\t} catch {\n\t\t\tuser.value = null;\n\t\t\tisAuthenticated.value = false;\n\t\t\tauth.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function logout() {\n\t\ttry {\n\t\t\tawait auth.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tauth.setAccessToken(undefined);\n\t\tclearToken();\n\t\tuser.value = null;\n\t\tisAuthenticated.value = false;\n\t}\n\n\tconst token = readToken();\n\tif (token) auth.setAccessToken(token);\n\tvoid refresh();\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useVerifyEmail(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useVerifyEmail');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IVerifyEmailResult | null>(null);\n\n\tasync function verifyEmail(pin: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.verifyEmail(pin);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,IAAAA,iBAAiC;;;ACXjC,oBAAiC;AACjC,iBAAqC;AACrC,IAAAC,cAAoB;AAEb,SAAS,kBAAkB,QAAqB;AACtD,QAAM,WAAO,iCAAqB,QAAQ,CAAC,MAAM,EAAE,MAAM,mBAAmB;AAC5E,QAAM,gBAAY,iBAAI,KAAK;AAC3B,QAAM,YAAQ,iBAA6B,IAAI;AAC/C,QAAM,WAAO,iBAAI,KAAK;AAEtB,iBAAe,eAAe,OAAe;AAC5C,cA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AAQ;AAAA,IACnB;AAAA,EACD;AAEA,iBAAe,SAAS;AACvB,QAAI;AACH,YAAM,KAAK,OAAO;AAAA,IACnB,QAAQ;AAAA,IAER;AACA,SAAK,eAAe,MAAS;AAC7B,eAAW;AACX,SAAK,QAAQ;AACb,oBAAgB,QAAQ;AAAA,EACzB;AAEA,QAAM,QAAQ,UAAU;AACxB,MAAI,MAAO,MAAK,eAAe,KAAK;AACpC,OAAK,QAAQ;AAEb,SAAO,EAAE,MAAM,WAAW,iBAAiB,SAAS,OAAO;AAC5D;;;AC3CA,IAAAC,iBAAiC;AACjC,IAAAC,eAAqC;AACrC,IAAAA,eAAoB;AAEb,SAAS,eAAe,QAAqB;AACnD,QAAM,WAAO,mCAAqB,QAAQ,CAAC,MAAM,EAAE,MAAM,gBAAgB;AACzE,QAAM,gBAAY,kBAAI,KAAK;AAC3B,QAAM,YAAQ,kBAA6B,IAAI;AAC/C,QAAM,WAAO,kBAA+B,IAAI;AAEhD,iBAAe,YAAY,KAAa;AACvC,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,KAAK,YAAY,GAAG;AAC7C,WAAK,QAAQ;AACb,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,SAAO,EAAE,aAAa,WAAW,OAAO,KAAK;AAC9C;","names":["import_client","import_vue","import_client","import_vue","import_client","import_vue","import_client","import_vue","import_client","import_vue","import_vue","import_client","import_vue"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,14 +2,14 @@ import { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput
|
|
|
2
2
|
export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
|
|
5
|
-
declare function useForgotPassword(client
|
|
5
|
+
declare function useForgotPassword(client?: AuthClient): {
|
|
6
6
|
forgotPassword: (email: string) => Promise<void>;
|
|
7
7
|
isLoading: vue.Ref<boolean, boolean>;
|
|
8
8
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
9
9
|
sent: vue.Ref<boolean, boolean>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
declare function useLogin(client
|
|
12
|
+
declare function useLogin(client?: AuthClient): {
|
|
13
13
|
login: (input: ILoginInput) => Promise<ILoginResult>;
|
|
14
14
|
isLoading: vue.Ref<boolean, boolean>;
|
|
15
15
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
@@ -94,13 +94,13 @@ declare function useLogin(client: AuthClient): {
|
|
|
94
94
|
} | null>;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
declare function useLogout(client
|
|
97
|
+
declare function useLogout(client?: AuthClient): {
|
|
98
98
|
logout: () => Promise<void>;
|
|
99
99
|
isLoading: vue.Ref<boolean, boolean>;
|
|
100
100
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
declare function useRegister(client
|
|
103
|
+
declare function useRegister(client?: AuthClient): {
|
|
104
104
|
register: (input: IRegisterInput) => Promise<IRegisterResult>;
|
|
105
105
|
isLoading: vue.Ref<boolean, boolean>;
|
|
106
106
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
@@ -185,14 +185,14 @@ declare function useRegister(client: AuthClient): {
|
|
|
185
185
|
} | null>;
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
declare function useResetPassword(client
|
|
188
|
+
declare function useResetPassword(client?: AuthClient): {
|
|
189
189
|
resetPassword: (input: IResetPasswordInput) => Promise<void>;
|
|
190
190
|
isLoading: vue.Ref<boolean, boolean>;
|
|
191
191
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
192
192
|
done: vue.Ref<boolean, boolean>;
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
declare function useSession(client
|
|
195
|
+
declare function useSession(client?: AuthClient): {
|
|
196
196
|
user: vue.Ref<{
|
|
197
197
|
id: string;
|
|
198
198
|
email: string;
|
|
@@ -266,7 +266,7 @@ declare function useSession(client: AuthClient): {
|
|
|
266
266
|
logout: () => Promise<void>;
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
declare function useVerifyEmail(client
|
|
269
|
+
declare function useVerifyEmail(client?: AuthClient): {
|
|
270
270
|
verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
|
|
271
271
|
isLoading: vue.Ref<boolean, boolean>;
|
|
272
272
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput
|
|
|
2
2
|
export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
|
|
5
|
-
declare function useForgotPassword(client
|
|
5
|
+
declare function useForgotPassword(client?: AuthClient): {
|
|
6
6
|
forgotPassword: (email: string) => Promise<void>;
|
|
7
7
|
isLoading: vue.Ref<boolean, boolean>;
|
|
8
8
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
9
9
|
sent: vue.Ref<boolean, boolean>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
declare function useLogin(client
|
|
12
|
+
declare function useLogin(client?: AuthClient): {
|
|
13
13
|
login: (input: ILoginInput) => Promise<ILoginResult>;
|
|
14
14
|
isLoading: vue.Ref<boolean, boolean>;
|
|
15
15
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
@@ -94,13 +94,13 @@ declare function useLogin(client: AuthClient): {
|
|
|
94
94
|
} | null>;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
declare function useLogout(client
|
|
97
|
+
declare function useLogout(client?: AuthClient): {
|
|
98
98
|
logout: () => Promise<void>;
|
|
99
99
|
isLoading: vue.Ref<boolean, boolean>;
|
|
100
100
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
declare function useRegister(client
|
|
103
|
+
declare function useRegister(client?: AuthClient): {
|
|
104
104
|
register: (input: IRegisterInput) => Promise<IRegisterResult>;
|
|
105
105
|
isLoading: vue.Ref<boolean, boolean>;
|
|
106
106
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
@@ -185,14 +185,14 @@ declare function useRegister(client: AuthClient): {
|
|
|
185
185
|
} | null>;
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
declare function useResetPassword(client
|
|
188
|
+
declare function useResetPassword(client?: AuthClient): {
|
|
189
189
|
resetPassword: (input: IResetPasswordInput) => Promise<void>;
|
|
190
190
|
isLoading: vue.Ref<boolean, boolean>;
|
|
191
191
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
|
192
192
|
done: vue.Ref<boolean, boolean>;
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
declare function useSession(client
|
|
195
|
+
declare function useSession(client?: AuthClient): {
|
|
196
196
|
user: vue.Ref<{
|
|
197
197
|
id: string;
|
|
198
198
|
email: string;
|
|
@@ -266,7 +266,7 @@ declare function useSession(client: AuthClient): {
|
|
|
266
266
|
logout: () => Promise<void>;
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
declare function useVerifyEmail(client
|
|
269
|
+
declare function useVerifyEmail(client?: AuthClient): {
|
|
270
270
|
verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
|
|
271
271
|
isLoading: vue.Ref<boolean, boolean>;
|
|
272
272
|
error: vue.Ref<FonderieApiError | null, FonderieApiError | null>;
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
|
|
|
3
3
|
|
|
4
4
|
// src/composables/useForgotPassword.ts
|
|
5
5
|
import { FonderieApiError } from "@fonderie/client";
|
|
6
|
+
import { useFonderieSubClient } from "@fonderie/vue";
|
|
6
7
|
import { ref } from "vue";
|
|
7
8
|
function useForgotPassword(client) {
|
|
9
|
+
const auth = useFonderieSubClient(client, (c) => c.auth, "useForgotPassword");
|
|
8
10
|
const isLoading = ref(false);
|
|
9
11
|
const error = ref(null);
|
|
10
12
|
const sent = ref(false);
|
|
@@ -12,7 +14,7 @@ function useForgotPassword(client) {
|
|
|
12
14
|
isLoading.value = true;
|
|
13
15
|
error.value = null;
|
|
14
16
|
try {
|
|
15
|
-
await
|
|
17
|
+
await auth.forgotPassword(email);
|
|
16
18
|
sent.value = true;
|
|
17
19
|
} catch (err) {
|
|
18
20
|
const apiError = err instanceof FonderieApiError ? err : new FonderieApiError("unknown", String(err), 0);
|
|
@@ -27,6 +29,7 @@ function useForgotPassword(client) {
|
|
|
27
29
|
|
|
28
30
|
// src/composables/useLogin.ts
|
|
29
31
|
import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
|
|
32
|
+
import { useFonderieSubClient as useFonderieSubClient2 } from "@fonderie/vue";
|
|
30
33
|
import { ref as ref2 } from "vue";
|
|
31
34
|
|
|
32
35
|
// src/storage.ts
|
|
@@ -43,6 +46,7 @@ function readToken() {
|
|
|
43
46
|
|
|
44
47
|
// src/composables/useLogin.ts
|
|
45
48
|
function useLogin(client) {
|
|
49
|
+
const auth = useFonderieSubClient2(client, (c) => c.auth, "useLogin");
|
|
46
50
|
const isLoading = ref2(false);
|
|
47
51
|
const error = ref2(null);
|
|
48
52
|
const data = ref2(null);
|
|
@@ -50,8 +54,8 @@ function useLogin(client) {
|
|
|
50
54
|
isLoading.value = true;
|
|
51
55
|
error.value = null;
|
|
52
56
|
try {
|
|
53
|
-
const { result } = await
|
|
54
|
-
|
|
57
|
+
const { result } = await auth.login(input);
|
|
58
|
+
auth.setAccessToken(result.tokens.access);
|
|
55
59
|
persistToken(result.tokens.access);
|
|
56
60
|
data.value = result;
|
|
57
61
|
return result;
|
|
@@ -68,20 +72,22 @@ function useLogin(client) {
|
|
|
68
72
|
|
|
69
73
|
// src/composables/useLogout.ts
|
|
70
74
|
import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
|
|
75
|
+
import { useFonderieSubClient as useFonderieSubClient3 } from "@fonderie/vue";
|
|
71
76
|
import { ref as ref3 } from "vue";
|
|
72
77
|
function useLogout(client) {
|
|
78
|
+
const auth = useFonderieSubClient3(client, (c) => c.auth, "useLogout");
|
|
73
79
|
const isLoading = ref3(false);
|
|
74
80
|
const error = ref3(null);
|
|
75
81
|
async function logout() {
|
|
76
82
|
isLoading.value = true;
|
|
77
83
|
error.value = null;
|
|
78
84
|
try {
|
|
79
|
-
await
|
|
85
|
+
await auth.logout();
|
|
80
86
|
} catch (err) {
|
|
81
87
|
const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
|
|
82
88
|
error.value = apiError;
|
|
83
89
|
} finally {
|
|
84
|
-
|
|
90
|
+
auth.setAccessToken(void 0);
|
|
85
91
|
clearToken();
|
|
86
92
|
isLoading.value = false;
|
|
87
93
|
}
|
|
@@ -91,8 +97,10 @@ function useLogout(client) {
|
|
|
91
97
|
|
|
92
98
|
// src/composables/useRegister.ts
|
|
93
99
|
import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
|
|
100
|
+
import { useFonderieSubClient as useFonderieSubClient4 } from "@fonderie/vue";
|
|
94
101
|
import { ref as ref4 } from "vue";
|
|
95
102
|
function useRegister(client) {
|
|
103
|
+
const auth = useFonderieSubClient4(client, (c) => c.auth, "useRegister");
|
|
96
104
|
const isLoading = ref4(false);
|
|
97
105
|
const error = ref4(null);
|
|
98
106
|
const data = ref4(null);
|
|
@@ -100,8 +108,8 @@ function useRegister(client) {
|
|
|
100
108
|
isLoading.value = true;
|
|
101
109
|
error.value = null;
|
|
102
110
|
try {
|
|
103
|
-
const { result } = await
|
|
104
|
-
|
|
111
|
+
const { result } = await auth.register(input);
|
|
112
|
+
auth.setAccessToken(result.tokens.access);
|
|
105
113
|
persistToken(result.tokens.access);
|
|
106
114
|
data.value = result;
|
|
107
115
|
return result;
|
|
@@ -118,8 +126,10 @@ function useRegister(client) {
|
|
|
118
126
|
|
|
119
127
|
// src/composables/useResetPassword.ts
|
|
120
128
|
import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
|
|
129
|
+
import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/vue";
|
|
121
130
|
import { ref as ref5 } from "vue";
|
|
122
131
|
function useResetPassword(client) {
|
|
132
|
+
const auth = useFonderieSubClient5(client, (c) => c.auth, "useResetPassword");
|
|
123
133
|
const isLoading = ref5(false);
|
|
124
134
|
const error = ref5(null);
|
|
125
135
|
const done = ref5(false);
|
|
@@ -127,7 +137,7 @@ function useResetPassword(client) {
|
|
|
127
137
|
isLoading.value = true;
|
|
128
138
|
error.value = null;
|
|
129
139
|
try {
|
|
130
|
-
await
|
|
140
|
+
await auth.resetPassword(input);
|
|
131
141
|
done.value = true;
|
|
132
142
|
} catch (err) {
|
|
133
143
|
const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
|
|
@@ -141,21 +151,23 @@ function useResetPassword(client) {
|
|
|
141
151
|
}
|
|
142
152
|
|
|
143
153
|
// src/composables/useSession.ts
|
|
154
|
+
import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/vue";
|
|
144
155
|
import { ref as ref6 } from "vue";
|
|
145
156
|
function useSession(client) {
|
|
157
|
+
const auth = useFonderieSubClient6(client, (c) => c.auth, "useSession");
|
|
146
158
|
const user = ref6(null);
|
|
147
159
|
const isLoading = ref6(true);
|
|
148
160
|
const isAuthenticated = ref6(false);
|
|
149
161
|
async function refresh() {
|
|
150
162
|
isLoading.value = true;
|
|
151
163
|
try {
|
|
152
|
-
const { result } = await
|
|
164
|
+
const { result } = await auth.getUser();
|
|
153
165
|
user.value = result.user;
|
|
154
166
|
isAuthenticated.value = true;
|
|
155
167
|
} catch {
|
|
156
168
|
user.value = null;
|
|
157
169
|
isAuthenticated.value = false;
|
|
158
|
-
|
|
170
|
+
auth.setAccessToken(void 0);
|
|
159
171
|
clearToken();
|
|
160
172
|
} finally {
|
|
161
173
|
isLoading.value = false;
|
|
@@ -163,24 +175,26 @@ function useSession(client) {
|
|
|
163
175
|
}
|
|
164
176
|
async function logout() {
|
|
165
177
|
try {
|
|
166
|
-
await
|
|
178
|
+
await auth.logout();
|
|
167
179
|
} catch {
|
|
168
180
|
}
|
|
169
|
-
|
|
181
|
+
auth.setAccessToken(void 0);
|
|
170
182
|
clearToken();
|
|
171
183
|
user.value = null;
|
|
172
184
|
isAuthenticated.value = false;
|
|
173
185
|
}
|
|
174
186
|
const token = readToken();
|
|
175
|
-
if (token)
|
|
187
|
+
if (token) auth.setAccessToken(token);
|
|
176
188
|
void refresh();
|
|
177
189
|
return { user, isLoading, isAuthenticated, refresh, logout };
|
|
178
190
|
}
|
|
179
191
|
|
|
180
192
|
// src/composables/useVerifyEmail.ts
|
|
181
193
|
import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
|
|
194
|
+
import { useFonderieSubClient as useFonderieSubClient7 } from "@fonderie/vue";
|
|
182
195
|
import { ref as ref7 } from "vue";
|
|
183
196
|
function useVerifyEmail(client) {
|
|
197
|
+
const auth = useFonderieSubClient7(client, (c) => c.auth, "useVerifyEmail");
|
|
184
198
|
const isLoading = ref7(false);
|
|
185
199
|
const error = ref7(null);
|
|
186
200
|
const data = ref7(null);
|
|
@@ -188,7 +202,7 @@ function useVerifyEmail(client) {
|
|
|
188
202
|
isLoading.value = true;
|
|
189
203
|
error.value = null;
|
|
190
204
|
try {
|
|
191
|
-
const { result } = await
|
|
205
|
+
const { result } = await auth.verifyEmail(pin);
|
|
192
206
|
data.value = result;
|
|
193
207
|
return result;
|
|
194
208
|
} catch (err) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/composables/useForgotPassword.ts","../src/composables/useLogin.ts","../src/storage.ts","../src/composables/useLogout.ts","../src/composables/useRegister.ts","../src/composables/useResetPassword.ts","../src/composables/useSession.ts","../src/composables/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\n\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './composables';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useForgotPassword(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst sent = ref(false);\n\n\tasync function forgotPassword(email: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.forgotPassword(email);\n\t\t\tsent.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useLogin(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<ILoginResult | null>(null);\n\n\tasync function login(input: ILoginInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.login(input);\n\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { login, isLoading, error, data };\n}\n","export const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\tlocalStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\tlocalStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken(): string | null {\n\treturn localStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { clearToken } from '../storage';\n\nexport function useLogout(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function logout() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useRegister(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IRegisterResult | null>(null);\n\n\tasync function register(input: IRegisterInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.register(input);\n\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useResetPassword(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst done = ref(false);\n\n\tasync function resetPassword(input: IResetPasswordInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait client.resetPassword(input);\n\t\t\tdone.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { ref } from 'vue';\nimport { clearToken, readToken } from '../storage';\n\nexport function useSession(client: AuthClient) {\n\tconst user = ref<IUserDTO | null>(null);\n\tconst isLoading = ref(true);\n\tconst isAuthenticated = ref(false);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\ttry {\n\t\t\tconst { result } = await client.getUser();\n\t\t\tuser.value = result.user;\n\t\t\tisAuthenticated.value = true;\n\t\t} catch {\n\t\t\tuser.value = null;\n\t\t\tisAuthenticated.value = false;\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function logout() {\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tclient.setAccessToken(undefined);\n\t\tclearToken();\n\t\tuser.value = null;\n\t\tisAuthenticated.value = false;\n\t}\n\n\tconst token = readToken();\n\tif (token) client.setAccessToken(token);\n\tvoid refresh();\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { ref } from 'vue';\n\nexport function useVerifyEmail(client: AuthClient) {\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IVerifyEmailResult | null>(null);\n\n\tasync function verifyEmail(pin: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await client.verifyEmail(pin);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";AAYA,SAAS,oBAAAA,yBAAwB;;;ACXjC,SAAS,wBAAwB;AACjC,SAAS,WAAW;AAEb,SAAS,kBAAkB,QAAoB;AACrD,QAAM,YAAY,IAAI,KAAK;AAC3B,QAAM,QAAQ,IAA6B,IAAI;AAC/C,QAAM,OAAO,IAAI,KAAK;AAEtB,iBAAe,eAAe,OAAe;AAC5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AwB;AACjC,SAAS,OAAAC,YAAW;AAEb,SAAS,eAAe,QAAoB;AAClD,QAAM,YAAYA,KAAI,KAAK;AAC3B,QAAM,QAAQA,KAA6B,IAAI;AAC/C,QAAM,OAAOA,KAA+B,IAAI;AAEhD,iBAAe,YAAY,KAAa;AACvC,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,GAAG;AAC/C,WAAK,QAAQ;AACb,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,WACL,eAAeD,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,SAAO,EAAE,aAAa,WAAW,OAAO,KAAK;AAC9C;","names":["FonderieApiError","FonderieApiError","ref","ref","FonderieApiError","FonderieApiError","ref","ref","FonderieApiError","FonderieApiError","ref","ref","FonderieApiError","FonderieApiError","ref","ref","ref","FonderieApiError","ref"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/composables/useForgotPassword.ts","../src/composables/useLogin.ts","../src/storage.ts","../src/composables/useLogout.ts","../src/composables/useRegister.ts","../src/composables/useResetPassword.ts","../src/composables/useSession.ts","../src/composables/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\n\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './composables';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useForgotPassword(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useForgotPassword');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst sent = ref(false);\n\n\tasync function forgotPassword(email: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.forgotPassword(email);\n\t\t\tsent.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useLogin(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useLogin');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<ILoginResult | null>(null);\n\n\tasync function login(input: ILoginInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.login(input);\n\t\t\tauth.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { login, isLoading, error, data };\n}\n","export const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\tlocalStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\tlocalStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken(): string | null {\n\treturn localStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { clearToken } from '../storage';\n\nexport function useLogout(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useLogout');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\n\tasync function logout() {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t} finally {\n\t\t\tauth.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { persistToken } from '../storage';\n\nexport function useRegister(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useRegister');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IRegisterResult | null>(null);\n\n\tasync function register(input: IRegisterInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.register(input);\n\t\t\tauth.setAccessToken(result.tokens.access);\n\t\t\tpersistToken(result.tokens.access);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useResetPassword(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useResetPassword');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst done = ref(false);\n\n\tasync function resetPassword(input: IResetPasswordInput) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tawait auth.resetPassword(input);\n\t\t\tdone.value = true;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\nimport { clearToken, readToken } from '../storage';\n\nexport function useSession(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useSession');\n\tconst user = ref<IUserDTO | null>(null);\n\tconst isLoading = ref(true);\n\tconst isAuthenticated = ref(false);\n\n\tasync function refresh() {\n\t\tisLoading.value = true;\n\t\ttry {\n\t\t\tconst { result } = await auth.getUser();\n\t\t\tuser.value = result.user;\n\t\t\tisAuthenticated.value = true;\n\t\t} catch {\n\t\t\tuser.value = null;\n\t\t\tisAuthenticated.value = false;\n\t\t\tauth.setAccessToken(undefined);\n\t\t\tclearToken();\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\tasync function logout() {\n\t\ttry {\n\t\t\tawait auth.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tauth.setAccessToken(undefined);\n\t\tclearToken();\n\t\tuser.value = null;\n\t\tisAuthenticated.value = false;\n\t}\n\n\tconst token = readToken();\n\tif (token) auth.setAccessToken(token);\n\tvoid refresh();\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/vue';\nimport { ref } from 'vue';\n\nexport function useVerifyEmail(client?: AuthClient) {\n\tconst auth = useFonderieSubClient(client, (c) => c.auth, 'useVerifyEmail');\n\tconst isLoading = ref(false);\n\tconst error = ref<FonderieApiError | null>(null);\n\tconst data = ref<IVerifyEmailResult | null>(null);\n\n\tasync function verifyEmail(pin: string) {\n\t\tisLoading.value = true;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tconst { result } = await auth.verifyEmail(pin);\n\t\t\tdata.value = result;\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\terror.value = apiError;\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tisLoading.value = false;\n\t\t}\n\t}\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";AAYA,SAAS,oBAAAA,yBAAwB;;;ACXjC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,WAAW;AAEb,SAAS,kBAAkB,QAAqB;AACtD,QAAM,OAAO,qBAAqB,QAAQ,CAAC,MAAM,EAAE,MAAM,mBAAmB;AAC5E,QAAM,YAAY,IAAI,KAAK;AAC3B,QAAM,QAAQ,IAA6B,IAAI;AAC/C,QAAM,OAAO,IAAI,KAAK;AAEtB,iBAAe,eAAe,OAAe;AAC5C,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,KAAK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C7B,iBAAW;AAAA,IACZ,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,iBAAe,SAAS;AACvB,QAAI;AACH,YAAM,KAAK,OAAO;AAAA,IACnB,QAAQ;AAAA,IAER;AACA,SAAK,eAAe,MAAS;AAC7B,eAAW;AACX,SAAK,QAAQ;AACb,oBAAgB,QAAQ;AAAA,EACzB;AAEA,QAAM,QAAQ,UAAU;AACxB,MAAI,MAAO,MAAK,eAAe,KAAK;AACpC,OAAK,QAAQ;AAEb,SAAO,EAAE,MAAM,WAAW,iBAAiB,SAAS,OAAO;AAC5D;;;AC3CA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,OAAAC,YAAW;AAEb,SAAS,eAAe,QAAqB;AACnD,QAAM,OAAOD,sBAAqB,QAAQ,CAAC,MAAM,EAAE,MAAM,gBAAgB;AACzE,QAAM,YAAYC,KAAI,KAAK;AAC3B,QAAM,QAAQA,KAA6B,IAAI;AAC/C,QAAM,OAAOA,KAA+B,IAAI;AAEhD,iBAAe,YAAY,KAAa;AACvC,cAAU,QAAQ;AAClB,UAAM,QAAQ;AACd,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,KAAK,YAAY,GAAG;AAC7C,WAAK,QAAQ;AACb,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,WACL,eAAeF,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,YAAM,QAAQ;AACd,YAAM;AAAA,IACP,UAAE;AACD,gBAAU,QAAQ;AAAA,IACnB;AAAA,EACD;AAEA,SAAO,EAAE,aAAa,WAAW,OAAO,KAAK;AAC9C;","names":["FonderieApiError","FonderieApiError","useFonderieSubClient","ref","useFonderieSubClient","ref","FonderieApiError","FonderieApiError","useFonderieSubClient","ref","useFonderieSubClient","ref","FonderieApiError","FonderieApiError","useFonderieSubClient","ref","useFonderieSubClient","ref","FonderieApiError","FonderieApiError","useFonderieSubClient","ref","useFonderieSubClient","ref","useFonderieSubClient","ref","FonderieApiError","useFonderieSubClient","ref"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/vue-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Vue composables for Fonderie auth — thin bindings over @fonderie/client.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"fonderiejs",
|
|
7
7
|
"vue",
|
|
8
8
|
"auth",
|
|
9
9
|
"composables",
|
|
@@ -28,19 +28,22 @@
|
|
|
28
28
|
"build": "tsup",
|
|
29
29
|
"dev": "tsup --watch",
|
|
30
30
|
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "tsx --test src/__tests__/*.test.ts",
|
|
31
32
|
"lint": "biome lint src",
|
|
32
33
|
"format": "biome format --write src",
|
|
33
34
|
"check": "biome check --write src"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@fonderie/client": "*"
|
|
37
|
+
"@fonderie/client": "*",
|
|
38
|
+
"@fonderie/vue": "*"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"vue": ">=3.0.0"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@types/node": "^
|
|
44
|
+
"@types/node": "^26.2.0",
|
|
43
45
|
"tsup": "^8.5.1",
|
|
46
|
+
"tsx": "^4.21.0",
|
|
44
47
|
"typescript": "^6.0.3",
|
|
45
48
|
"vue": "^3.5.0"
|
|
46
49
|
},
|