@sqrzro/auth 2.0.0-bz.4 → 2.0.0-bz.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
 
2
- > @sqrzro/auth@2.0.0-bz.2 build /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
2
+ > @sqrzro/auth@2.0.0-bz.5 build /Users/richardcarter/Sites/@sqrzro/sqrzro/packages/auth
3
3
  > tsc -p tsconfig.json
4
4
 
@@ -1,640 +1,28 @@
1
1
 
2
- > @sqrzro/auth@2.0.0-bz.3 dev /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
2
+ > @sqrzro/auth@2.0.0-bz.4 dev /Users/richardcarter/Sites/@sqrzro/sqrzro/packages/auth
3
3
  > tsc -p tsconfig.json --watch
4
4
 
5
- c[8:24:00 AM] Starting compilation in watch mode...
5
+ c[2:25:34 PM] Starting compilation in watch mode...
6
6
 
7
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
8
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
7
+ [2:25:38 PM] Found 0 errors. Watching for file changes.
9
8
 
10
- 90 return handlePasswordResetForm(formData);
11
-    ~~~~~~~~
9
+ c[2:25:43 PM] File change detected. Starting incremental compilation...
12
10
 
13
- ../server/dist/auth/index.d.ts:18:5
14
- 18 old: string;
15
-    ~~~
16
- 'old' is declared here.
11
+ [2:25:44 PM] Found 0 errors. Watching for file changes.
17
12
 
18
- [8:24:02 AM] Found 1 error. Watching for file changes.
13
+ c[2:25:49 PM] File change detected. Starting incremental compilation...
19
14
 
20
- c[8:24:05 AM] File change detected. Starting incremental compilation...
15
+ [2:25:50 PM] Found 0 errors. Watching for file changes.
21
16
 
22
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
23
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
17
+ c[2:29:41 PM] File change detected. Starting incremental compilation...
24
18
 
25
- 90 return handlePasswordResetForm(formData);
26
-    ~~~~~~~~
19
+ [2:29:42 PM] Found 0 errors. Watching for file changes.
27
20
 
28
- ../server/dist/auth/index.d.ts:18:5
29
- 18 old: string;
30
-    ~~~
31
- 'old' is declared here.
21
+ c[2:29:43 PM] File change detected. Starting incremental compilation...
32
22
 
33
- [8:24:05 AM] Found 1 error. Watching for file changes.
23
+ [2:29:43 PM] Found 0 errors. Watching for file changes.
34
24
 
35
- c[8:24:09 AM] File change detected. Starting incremental compilation...
25
+ c[2:29:56 PM] File change detected. Starting incremental compilation...
36
26
 
37
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
38
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
39
-
40
- 90 return handlePasswordResetForm(formData);
41
-    ~~~~~~~~
42
-
43
- ../server/dist/auth/index.d.ts:18:5
44
- 18 old: string;
45
-    ~~~
46
- 'old' is declared here.
47
-
48
- [8:24:09 AM] Found 1 error. Watching for file changes.
49
-
50
- c[8:25:15 AM] File change detected. Starting incremental compilation...
51
-
52
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
53
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
54
-
55
- 90 return handlePasswordResetForm(formData);
56
-    ~~~~~~~~
57
-
58
- ../server/dist/auth/index.d.ts:18:5
59
- 18 old: string;
60
-    ~~~
61
- 'old' is declared here.
62
-
63
- [8:25:15 AM] Found 1 error. Watching for file changes.
64
-
65
- c[8:25:16 AM] File change detected. Starting incremental compilation...
66
-
67
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
68
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
69
-
70
- 90 return handlePasswordResetForm(formData);
71
-    ~~~~~~~~
72
-
73
- ../server/dist/auth/index.d.ts:18:5
74
- 18 old: string;
75
-    ~~~
76
- 'old' is declared here.
77
-
78
- [8:25:16 AM] Found 1 error. Watching for file changes.
79
-
80
- c[8:26:29 AM] File change detected. Starting incremental compilation...
81
-
82
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
83
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
84
-
85
- 90 return handlePasswordResetForm(formData);
86
-    ~~~~~~~~
87
-
88
- ../server/dist/auth/index.d.ts:18:5
89
- 18 old: string;
90
-    ~~~
91
- 'old' is declared here.
92
-
93
- [8:26:29 AM] Found 1 error. Watching for file changes.
94
-
95
- c[8:26:31 AM] File change detected. Starting incremental compilation...
96
-
97
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
98
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
99
-
100
- 90 return handlePasswordResetForm(formData);
101
-    ~~~~~~~~
102
-
103
- ../server/dist/auth/index.d.ts:18:5
104
- 18 old: string;
105
-    ~~~
106
- 'old' is declared here.
107
-
108
- [8:26:31 AM] Found 1 error. Watching for file changes.
109
-
110
- c[8:59:42 AM] File change detected. Starting incremental compilation...
111
-
112
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
113
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
114
-
115
- 90 return handlePasswordResetForm(formData);
116
-    ~~~~~~~~
117
-
118
- ../server/dist/auth/index.d.ts:18:5
119
- 18 old: string;
120
-    ~~~
121
- 'old' is declared here.
122
-
123
- [8:59:42 AM] Found 1 error. Watching for file changes.
124
-
125
- c[9:01:14 AM] File change detected. Starting incremental compilation...
126
-
127
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
128
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
129
-
130
- 90 return handlePasswordResetForm(formData);
131
-    ~~~~~~~~
132
-
133
- ../server/dist/auth/index.d.ts:18:5
134
- 18 old: string;
135
-    ~~~
136
- 'old' is declared here.
137
-
138
- [9:01:14 AM] Found 1 error. Watching for file changes.
139
-
140
- c[9:03:32 AM] File change detected. Starting incremental compilation...
141
-
142
- src/components/PasswordPage/index.tsx:3:31 - error TS2307: Cannot find module '../PasswordResetForm' or its corresponding type declarations.
143
-
144
- 3 import PasswordResetForm from '../PasswordResetForm';
145
-    ~~~~~~~~~~~~~~~~~~~~~~
146
-
147
- src/components/TokenPasswordResetForm/index.tsx:6:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'TokenPasswordResetFormFields'.
148
-
149
- 6 import type { TokenPasswordResetFormFields } from '@sqrzro/server/auth';
150
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151
-
152
- src/components/TokenPasswordResetForm/index.tsx:31:19 - error TS2552: Cannot find name 'submitTokenPasswordResetForm'. Did you mean 'submitPasswordResetForm'?
153
-
154
- 31 onSubmit: submitTokenPasswordResetForm,
155
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156
-
157
- src/components/TokenPasswordResetForm/index.tsx:51:16 - error TS2552: Cannot find name 'PasswordResetForm'. Did you mean 'TokenPasswordResetForm'?
158
-
159
- 51 export default PasswordResetForm;
160
-    ~~~~~~~~~~~~~~~~~
161
-
162
- src/components/TokenPasswordResetForm/index.tsx:22:10
163
- 22 function TokenPasswordResetForm({
164
-    ~~~~~~~~~~~~~~~~~~~~~~
165
- 'TokenPasswordResetForm' is declared here.
166
-
167
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
168
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
169
-
170
- 90 return handlePasswordResetForm(formData);
171
-    ~~~~~~~~
172
-
173
- ../server/dist/auth/index.d.ts:18:5
174
- 18 old: string;
175
-    ~~~
176
- 'old' is declared here.
177
-
178
- [9:03:32 AM] Found 5 errors. Watching for file changes.
179
-
180
- c[9:03:45 AM] File change detected. Starting incremental compilation...
181
-
182
- src/components/PasswordPage/index.tsx:3:31 - error TS2307: Cannot find module '../PasswordResetForm' or its corresponding type declarations.
183
-
184
- 3 import PasswordResetForm from '../PasswordResetForm';
185
-    ~~~~~~~~~~~~~~~~~~~~~~
186
-
187
- src/components/TokenPasswordResetForm/index.tsx:6:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'TokenPasswordResetFormFields'.
188
-
189
- 6 import type { TokenPasswordResetFormFields } from '@sqrzro/server/auth';
190
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191
-
192
- src/components/TokenPasswordResetForm/index.tsx:8:10 - error TS2724: '"../../server"' has no exported member named 'submitTokenPasswordResetForm'. Did you mean 'submitPasswordResetForm'?
193
-
194
- 8 import { submitTokenPasswordResetForm } from '../../server';
195
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196
-
197
- src/server.ts:87:23
198
- 87 export async function submitPasswordResetForm(
199
-    ~~~~~~~~~~~~~~~~~~~~~~~
200
- 'submitPasswordResetForm' is declared here.
201
-
202
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
203
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
204
-
205
- 90 return handlePasswordResetForm(formData);
206
-    ~~~~~~~~
207
-
208
- ../server/dist/auth/index.d.ts:18:5
209
- 18 old: string;
210
-    ~~~
211
- 'old' is declared here.
212
-
213
- [9:03:45 AM] Found 4 errors. Watching for file changes.
214
-
215
- c[9:04:10 AM] File change detected. Starting incremental compilation...
216
-
217
- src/components/PasswordResetForm/index.tsx:6:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'TokenPasswordResetFormFields'.
218
-
219
- 6 import type { TokenPasswordResetFormFields } from '@sqrzro/server/auth';
220
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
-
222
- src/components/PasswordResetForm/index.tsx:8:10 - error TS2724: '"../../server"' has no exported member named 'submitTokenPasswordResetForm'. Did you mean 'submitPasswordResetForm'?
223
-
224
- 8 import { submitTokenPasswordResetForm } from '../../server';
225
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226
-
227
- src/server.ts:87:23
228
- 87 export async function submitPasswordResetForm(
229
-    ~~~~~~~~~~~~~~~~~~~~~~~
230
- 'submitPasswordResetForm' is declared here.
231
-
232
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
233
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
234
-
235
- 90 return handlePasswordResetForm(formData);
236
-    ~~~~~~~~
237
-
238
- ../server/dist/auth/index.d.ts:18:5
239
- 18 old: string;
240
-    ~~~
241
- 'old' is declared here.
242
-
243
- [9:04:10 AM] Found 3 errors. Watching for file changes.
244
-
245
- c[9:04:43 AM] File change detected. Starting incremental compilation...
246
-
247
- src/components/PasswordResetForm/index.tsx:7:10 - error TS2724: '"../../server"' has no exported member named 'submitTokenPasswordResetForm'. Did you mean 'submitPasswordResetForm'?
248
-
249
- 7 import { submitTokenPasswordResetForm } from '../../server';
250
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251
-
252
- src/server.ts:87:23
253
- 87 export async function submitPasswordResetForm(
254
-    ~~~~~~~~~~~~~~~~~~~~~~~
255
- 'submitPasswordResetForm' is declared here.
256
-
257
- src/components/PasswordResetForm/index.tsx:27:25 - error TS2345: Argument of type '{ token: string; } | "/"' is not assignable to parameter of type 'string'.
258
- Type '{ token: string; }' is not assignable to type 'string'.
259
-
260
- 27 router.push(response || '/');
261
-    ~~~~~~~~~~~~~~~
262
-
263
- src/components/PasswordResetForm/index.tsx:36:51 - error TS2345: Argument of type '"password"' is not assignable to parameter of type '"token"'.
264
-
265
- 36 <PasswordFormField {...fieldProps('password', 'New Password')} />
266
-    ~~~~~~~~~~
267
-
268
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
269
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
270
-
271
- 90 return handlePasswordResetForm(formData);
272
-    ~~~~~~~~
273
-
274
- ../server/dist/auth/index.d.ts:18:5
275
- 18 old: string;
276
-    ~~~
277
- 'old' is declared here.
278
-
279
- [9:04:43 AM] Found 4 errors. Watching for file changes.
280
-
281
- c[9:04:51 AM] File change detected. Starting incremental compilation...
282
-
283
- src/server.ts:90:36 - error TS2345: Argument of type 'PasswordResetFormFields' is not assignable to parameter of type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
284
- Property 'old' is missing in type 'PasswordResetFormFields' but required in type 'import("/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index").PasswordResetFormFields'.
285
-
286
- 90 return handlePasswordResetForm(formData);
287
-    ~~~~~~~~
288
-
289
- ../server/dist/auth/index.d.ts:18:5
290
- 18 old: string;
291
-    ~~~
292
- 'old' is declared here.
293
-
294
- [9:04:51 AM] Found 1 error. Watching for file changes.
295
-
296
- c[9:05:06 AM] File change detected. Starting incremental compilation...
297
-
298
- src/server.ts:4:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleLoginForm'.
299
-
300
- 4 handleLoginForm,
301
-    ~~~~~~~~~~~~~~~
302
-
303
- src/server.ts:5:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleLogout'.
304
-
305
- 5 handleLogout,
306
-    ~~~~~~~~~~~~
307
-
308
- src/server.ts:6:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleMFAForm'.
309
-
310
- 6 handleMFAForm,
311
-    ~~~~~~~~~~~~~
312
-
313
- src/server.ts:7:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handlePasswordForm'.
314
-
315
- 7 handlePasswordForm,
316
-    ~~~~~~~~~~~~~~~~~~
317
-
318
- src/server.ts:8:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleTokenPasswordResetForm'.
319
-
320
- 8 handleTokenPasswordResetForm,
321
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322
-
323
- src/server.ts:9:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'checkUserHasMFA'.
324
-
325
- 9 checkUserHasMFA as serverCheckUserHasMFA,
326
-    ~~~~~~~~~~~~~~~
327
-
328
- src/server.ts:10:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'generateMFA'.
329
-
330
- 10 generateMFA as serverGenerateMFA,
331
-    ~~~~~~~~~~~
332
-
333
- src/server.ts:11:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'getSessionUser'.
334
-
335
- 11 getSessionUser as serverGetSessionUser,
336
-    ~~~~~~~~~~~~~~
337
-
338
- src/server.ts:12:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'checkMFAEnabled'.
339
-
340
- 12 checkMFAEnabled as syncCheckMFAEnabled,
341
-    ~~~~~~~~~~~~~~~
342
-
343
- src/server.ts:14:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'LoginFormFields'.
344
-
345
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
346
-    ~~~~~~~~~~~~~~~
347
-
348
- src/server.ts:14:32 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'MFAFormFields'.
349
-
350
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
351
-    ~~~~~~~~~~~~~
352
-
353
- src/server.ts:14:47 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'UserObject'.
354
-
355
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
356
-    ~~~~~~~~~~
357
-
358
- src/server.ts:17:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'MFAFormFields'.
359
-
360
- 17 export type { MFAFormFields, ScopeObject } from '@sqrzro/server/auth';
361
-    ~~~~~~~~~~~~~
362
-
363
- src/server.ts:17:30 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'ScopeObject'.
364
-
365
- 17 export type { MFAFormFields, ScopeObject } from '@sqrzro/server/auth';
366
-    ~~~~~~~~~~~
367
-
368
- [9:05:06 AM] Found 14 errors. Watching for file changes.
369
-
370
- c[9:05:29 AM] File change detected. Starting incremental compilation...
371
-
372
- src/server.ts:4:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleLoginForm'.
373
-
374
- 4 handleLoginForm,
375
-    ~~~~~~~~~~~~~~~
376
-
377
- src/server.ts:5:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleLogout'.
378
-
379
- 5 handleLogout,
380
-    ~~~~~~~~~~~~
381
-
382
- src/server.ts:6:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handleMFAForm'.
383
-
384
- 6 handleMFAForm,
385
-    ~~~~~~~~~~~~~
386
-
387
- src/server.ts:7:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handlePasswordForm'.
388
-
389
- 7 handlePasswordForm,
390
-    ~~~~~~~~~~~~~~~~~~
391
-
392
- src/server.ts:8:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'handlePasswordResetFormWithToken'.
393
-
394
- 8 handlePasswordResetFormWithToken,
395
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396
-
397
- src/server.ts:9:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'checkUserHasMFA'.
398
-
399
- 9 checkUserHasMFA as serverCheckUserHasMFA,
400
-    ~~~~~~~~~~~~~~~
401
-
402
- src/server.ts:10:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'generateMFA'.
403
-
404
- 10 generateMFA as serverGenerateMFA,
405
-    ~~~~~~~~~~~
406
-
407
- src/server.ts:11:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'getSessionUser'.
408
-
409
- 11 getSessionUser as serverGetSessionUser,
410
-    ~~~~~~~~~~~~~~
411
-
412
- src/server.ts:12:5 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'checkMFAEnabled'.
413
-
414
- 12 checkMFAEnabled as syncCheckMFAEnabled,
415
-    ~~~~~~~~~~~~~~~
416
-
417
- src/server.ts:14:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'LoginFormFields'.
418
-
419
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
420
-    ~~~~~~~~~~~~~~~
421
-
422
- src/server.ts:14:32 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'MFAFormFields'.
423
-
424
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
425
-    ~~~~~~~~~~~~~
426
-
427
- src/server.ts:14:47 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'UserObject'.
428
-
429
- 14 import type { LoginFormFields, MFAFormFields, UserObject } from '@sqrzro/server/auth';
430
-    ~~~~~~~~~~
431
-
432
- src/server.ts:17:15 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'MFAFormFields'.
433
-
434
- 17 export type { MFAFormFields, ScopeObject } from '@sqrzro/server/auth';
435
-    ~~~~~~~~~~~~~
436
-
437
- src/server.ts:17:30 - error TS2305: Module '"@sqrzro/server/auth"' has no exported member 'ScopeObject'.
438
-
439
- 17 export type { MFAFormFields, ScopeObject } from '@sqrzro/server/auth';
440
-    ~~~~~~~~~~~
441
-
442
- [9:05:29 AM] Found 14 errors. Watching for file changes.
443
-
444
- c[9:08:07 AM] File change detected. Starting incremental compilation...
445
-
446
- [9:08:08 AM] Found 0 errors. Watching for file changes.
447
-
448
- c[9:08:26 AM] File change detected. Starting incremental compilation...
449
-
450
- [9:08:26 AM] Found 0 errors. Watching for file changes.
451
-
452
- c[9:08:28 AM] File change detected. Starting incremental compilation...
453
-
454
- [9:08:28 AM] Found 0 errors. Watching for file changes.
455
-
456
- c[9:08:51 AM] File change detected. Starting incremental compilation...
457
-
458
- [9:08:51 AM] Found 0 errors. Watching for file changes.
459
-
460
- c[9:08:53 AM] File change detected. Starting incremental compilation...
461
-
462
- src/server.ts:8:5 - error TS2724: '"@sqrzro/server/auth"' has no exported member named 'handlePasswordResetFormWithToken'. Did you mean 'handlePasswordResetWithTokenForm'?
463
-
464
- 8 handlePasswordResetFormWithToken,
465
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
466
-
467
- [9:08:53 AM] Found 1 error. Watching for file changes.
468
-
469
- c[9:09:17 AM] File change detected. Starting incremental compilation...
470
-
471
- [9:09:17 AM] Found 0 errors. Watching for file changes.
472
-
473
- c[9:10:53 AM] File change detected. Starting incremental compilation...
474
-
475
- [9:10:53 AM] Found 0 errors. Watching for file changes.
476
-
477
- c[9:10:54 AM] File change detected. Starting incremental compilation...
478
-
479
- [9:10:55 AM] Found 0 errors. Watching for file changes.
480
-
481
- c[9:11:14 AM] File change detected. Starting incremental compilation...
482
-
483
- [9:11:14 AM] Found 0 errors. Watching for file changes.
484
-
485
- c[9:11:16 AM] File change detected. Starting incremental compilation...
486
-
487
- [9:11:16 AM] Found 0 errors. Watching for file changes.
488
-
489
- c[9:12:41 AM] File change detected. Starting incremental compilation...
490
-
491
- [9:12:41 AM] Found 0 errors. Watching for file changes.
492
-
493
- c[9:12:42 AM] File change detected. Starting incremental compilation...
494
-
495
- [9:12:42 AM] Found 0 errors. Watching for file changes.
496
-
497
- c[9:13:23 AM] File change detected. Starting incremental compilation...
498
-
499
- [9:13:23 AM] Found 0 errors. Watching for file changes.
500
-
501
- c[9:13:24 AM] File change detected. Starting incremental compilation...
502
-
503
- [9:13:25 AM] Found 0 errors. Watching for file changes.
504
-
505
- c[9:42:55 AM] File change detected. Starting incremental compilation...
506
-
507
- [9:42:55 AM] Found 0 errors. Watching for file changes.
508
-
509
- c[9:42:57 AM] File change detected. Starting incremental compilation...
510
-
511
- [9:42:57 AM] Found 0 errors. Watching for file changes.
512
-
513
- c[9:43:01 AM] File change detected. Starting incremental compilation...
514
-
515
- [9:43:01 AM] Found 0 errors. Watching for file changes.
516
-
517
- c[9:43:02 AM] File change detected. Starting incremental compilation...
518
-
519
- [9:43:03 AM] Found 0 errors. Watching for file changes.
520
-
521
- c[9:43:25 AM] File change detected. Starting incremental compilation...
522
-
523
- [9:43:25 AM] Found 0 errors. Watching for file changes.
524
-
525
- c[9:43:27 AM] File change detected. Starting incremental compilation...
526
-
527
- [9:43:27 AM] Found 0 errors. Watching for file changes.
528
-
529
- c[11:38:35 AM] File change detected. Starting incremental compilation...
530
-
531
- [11:38:35 AM] Found 0 errors. Watching for file changes.
532
-
533
- c[11:39:22 AM] File change detected. Starting incremental compilation...
534
-
535
- [11:39:23 AM] Found 0 errors. Watching for file changes.
536
-
537
- c[11:39:40 AM] File change detected. Starting incremental compilation...
538
-
539
- [11:39:40 AM] Found 0 errors. Watching for file changes.
540
-
541
- c[11:40:02 AM] File change detected. Starting incremental compilation...
542
-
543
- [11:40:02 AM] Found 0 errors. Watching for file changes.
544
-
545
- c[11:40:46 AM] File change detected. Starting incremental compilation...
546
-
547
- [11:40:46 AM] Found 0 errors. Watching for file changes.
548
-
549
- c[11:40:52 AM] File change detected. Starting incremental compilation...
550
-
551
- [11:40:53 AM] Found 0 errors. Watching for file changes.
552
-
553
- c[11:48:43 AM] File change detected. Starting incremental compilation...
554
-
555
- [11:48:43 AM] Found 0 errors. Watching for file changes.
556
-
557
- c[2:00:33 PM] File change detected. Starting incremental compilation...
558
-
559
- [2:00:33 PM] Found 0 errors. Watching for file changes.
560
-
561
- c[2:01:10 PM] File change detected. Starting incremental compilation...
562
-
563
- [2:01:11 PM] Found 0 errors. Watching for file changes.
564
-
565
- c[2:01:30 PM] File change detected. Starting incremental compilation...
566
-
567
- [2:01:30 PM] Found 0 errors. Watching for file changes.
568
-
569
- c[2:01:32 PM] File change detected. Starting incremental compilation...
570
-
571
- [2:01:32 PM] Found 0 errors. Watching for file changes.
572
-
573
- c[2:02:21 PM] File change detected. Starting incremental compilation...
574
-
575
- [2:02:21 PM] Found 0 errors. Watching for file changes.
576
-
577
- c[2:02:23 PM] File change detected. Starting incremental compilation...
578
-
579
- [2:02:23 PM] Found 0 errors. Watching for file changes.
580
-
581
- c[2:04:32 PM] File change detected. Starting incremental compilation...
582
-
583
- [2:04:32 PM] Found 0 errors. Watching for file changes.
584
-
585
- c[2:04:34 PM] File change detected. Starting incremental compilation...
586
-
587
- [2:04:34 PM] Found 0 errors. Watching for file changes.
588
-
589
- c[2:04:58 PM] File change detected. Starting incremental compilation...
590
-
591
- [2:04:59 PM] Found 0 errors. Watching for file changes.
592
-
593
- c[2:05:05 PM] File change detected. Starting incremental compilation...
594
-
595
- [2:05:05 PM] Found 0 errors. Watching for file changes.
596
-
597
- c[2:05:41 PM] File change detected. Starting incremental compilation...
598
-
599
- [2:05:41 PM] Found 0 errors. Watching for file changes.
600
-
601
- c[2:05:55 PM] File change detected. Starting incremental compilation...
602
-
603
- [2:05:55 PM] Found 0 errors. Watching for file changes.
604
-
605
- c[2:08:37 PM] File change detected. Starting incremental compilation...
606
-
607
- [2:08:37 PM] Found 0 errors. Watching for file changes.
608
-
609
- c[2:08:39 PM] File change detected. Starting incremental compilation...
610
-
611
- [2:08:39 PM] Found 0 errors. Watching for file changes.
612
-
613
- c[2:37:30 PM] File change detected. Starting incremental compilation...
614
-
615
- [2:37:30 PM] Found 0 errors. Watching for file changes.
616
-
617
- c[2:37:54 PM] File change detected. Starting incremental compilation...
618
-
619
- [2:37:54 PM] Found 0 errors. Watching for file changes.
620
-
621
- c[2:38:58 PM] File change detected. Starting incremental compilation...
622
-
623
- [2:38:58 PM] Found 0 errors. Watching for file changes.
624
-
625
- c[2:39:00 PM] File change detected. Starting incremental compilation...
626
-
627
- [2:39:00 PM] Found 0 errors. Watching for file changes.
628
-
629
- c[2:39:36 PM] File change detected. Starting incremental compilation...
630
-
631
- [2:39:36 PM] Found 0 errors. Watching for file changes.
632
-
633
- c[2:39:38 PM] File change detected. Starting incremental compilation...
634
-
635
- [2:39:38 PM] Found 0 errors. Watching for file changes.
636
-
637
- c[2:55:34 PM] File change detected. Starting incremental compilation...
638
-
639
- [2:55:34 PM] Found 0 errors. Watching for file changes.
27
+ [2:29:56 PM] Found 0 errors. Watching for file changes.
640
28
 
@@ -4,6 +4,7 @@ import type { ScopeObject } from '../../server';
4
4
  export interface AuthClassNames {
5
5
  actions: string;
6
6
  footer: string;
7
+ form: string;
7
8
  link: string;
8
9
  logo: string;
9
10
  root: string;
@@ -8,6 +8,6 @@ function LoginForm({ classNames, searchParams }) {
8
8
  const { fieldProps, formData, formProps } = useLoginForm(submitLoginForm, {
9
9
  redirect: searchParams.r,
10
10
  });
11
- return (_jsxs(Fragment, { children: [_jsx("h1", { className: tw('text-center', classNames?.title), children: "Sign in to continue" }), _jsxs(Form, { ...formProps, children: [_jsx(TextFormField, { ...fieldProps('email'), hasAssistiveError: true }), _jsx(PasswordFormField, { ...fieldProps('password'), hasAssistiveError: true }), _jsx("div", { className: tw('', classNames?.actions), children: _jsx(FormSubmit, { children: "Sign In" }) }), _jsx("footer", { className: tw('text-center', classNames?.footer), children: _jsx(Link, { className: classNames?.link, href: `/auth/password${formData.email ? `?email=${formData.email}` : ''}`, children: "Forgot Password?" }) })] })] }));
11
+ return (_jsxs(Fragment, { children: [_jsx("h1", { className: tw('text-center', classNames?.title), children: "Sign in to continue" }), _jsxs(Form, { ...formProps, classNames: { root: classNames?.form }, children: [_jsx(TextFormField, { ...fieldProps('email'), hasAssistiveError: true }), _jsx(PasswordFormField, { ...fieldProps('password'), hasAssistiveError: true }), _jsx("div", { className: tw('', classNames?.actions), children: _jsx(FormSubmit, { children: "Sign In" }) }), _jsx("footer", { className: tw('text-center', classNames?.footer), children: _jsx(Link, { className: classNames?.link, href: `/auth/password${formData.email ? `?email=${formData.email}` : ''}`, children: "Forgot Password?" }) })] })] }));
12
12
  }
13
13
  export default LoginForm;
@@ -1,8 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { AuthClassNames } from '../Auth';
3
2
  export interface MFAFormProps {
4
- classNames?: Partial<AuthClassNames>;
5
- hasAssistiveSubmit?: boolean;
6
3
  }
7
- declare function MFAForm({ hasAssistiveSubmit }: Readonly<MFAFormProps>): React.ReactElement;
4
+ declare function MFAForm(): React.ReactElement;
8
5
  export default MFAForm;
@@ -1,29 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect, useState } from 'react';
4
- import { CodeFormField, Form, FormSubmit, tw } from '@sqrzro/components';
5
- import { useForm } from '@sqrzro/hooks';
6
- import { useRouter } from 'next/navigation';
3
+ import { CodeFormField, Form, FormSubmit } from '@sqrzro/components';
4
+ import useMFAForm from '../../hooks/useMFAForm';
7
5
  import { submitMFAForm } from '../../server';
8
- function MFAForm({ hasAssistiveSubmit }) {
9
- const router = useRouter();
10
- const [errorCount, setErrorCount] = useState(0);
11
- const { fieldProps, formProps, resetForm, submitForm } = useForm({
12
- onSubmit: submitMFAForm,
13
- onSuccess: () => {
14
- router.push('/');
15
- },
16
- onValidationError: () => {
17
- setErrorCount((count) => count + 1);
18
- },
19
- toasts: {
20
- success: false,
21
- validation: "There seems to be an issue with the code you've entered. Please try again.",
22
- },
23
- });
24
- useEffect(() => {
25
- resetForm();
26
- }, [errorCount]);
27
- return (_jsxs(Form, { ...formProps, children: [_jsx(CodeFormField, { ...fieldProps('token'), onFinalChange: submitForm, hasAssistiveLabel: true, isAutoFocus: true }, errorCount), _jsx("div", { className: tw(hasAssistiveSubmit ? 'sr-only' : ''), children: _jsx(FormSubmit, { children: "Verify" }) })] }));
6
+ function MFAForm() {
7
+ const { formProps, fieldProps, key, submitForm } = useMFAForm({ onSubmit: submitMFAForm });
8
+ return (_jsxs(Form, { ...formProps, children: [_jsx(CodeFormField, { ...fieldProps('token'), onFinalChange: submitForm, hasAssistiveLabel: true, isAutoFocus: true }, key), _jsx(FormSubmit, { children: "Verify" })] }));
28
9
  }
29
10
  export default MFAForm;
@@ -16,6 +16,6 @@ async function MFAPage({ classNames }) {
16
16
  if (!userHasMFA) {
17
17
  return _jsx(MFASetup, { classNames: classNames });
18
18
  }
19
- return (_jsxs("div", { children: [_jsx("h1", { className: tw('text-center', classNames?.title), children: "Multi-Factor Authentication" }), _jsx("p", { className: "mb-6 text-center", children: "Enter the 6-digit code listed in your authentication app:" }), _jsx(MFAForm, { classNames: classNames, hasAssistiveSubmit: true })] }));
19
+ return (_jsxs("div", { children: [_jsx("h1", { className: tw('text-center', classNames?.title), children: "Multi-Factor Authentication" }), _jsx("p", { className: "mb-6 text-center", children: "Enter the 6-digit code listed in your authentication app:" }), _jsx(MFAForm, {})] }));
20
20
  }
21
21
  export default MFAPage;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { AuthClassNames } from '../Auth';
3
- export interface MFASetupProps {
3
+ export interface MFASetupFormProps {
4
4
  classNames?: Partial<AuthClassNames>;
5
5
  url: string;
6
6
  }
7
- declare function MFASetupForm({ classNames, url }: Readonly<MFASetupProps>): React.ReactElement;
7
+ declare function MFASetupForm({ classNames, url }: Readonly<MFASetupFormProps>): React.ReactElement;
8
8
  export default MFASetupForm;
@@ -12,9 +12,6 @@ function MFASetupForm({ classNames, url }) {
12
12
  event.preventDefault();
13
13
  setStep(1);
14
14
  }
15
- if (step === 1) {
16
- return (_jsxs(Fragment, { children: [_jsx("p", { className: "mb-4", children: "You'll need to setup an additional authentication step before you can continue." }), _jsx("figure", { className: "flex justify-center rounded border p-2", children: _jsx("img", { alt: "qrcode", src: url }) }), _jsxs("p", { className: "mb-4", children: [_jsx("strong", { children: "Step 1:" }), " Scan the QR code, or enter the secret below, in the Google Authentictor app."] }), _jsx(Button, { onClick: nextStep, variant: "primary", isFullWidth: true, children: "Continue" })] }));
17
- }
18
- return (_jsxs(Fragment, { children: [_jsxs("p", { className: "mb-4", children: [_jsx("strong", { children: "Step 2:" }), " Enter the 6-digit code listed in the Google Authenticator app:"] }), _jsx(MFAForm, {}), _jsx(Link, { className: classNames?.link, onClick: previousStep, children: "Scan QRcode again" })] }));
15
+ return (_jsxs(Fragment, { children: [_jsxs("div", { className: step === 1 ? null : 'sr-only', children: [_jsx("p", { className: "mb-4", children: "You'll need to setup an additional authentication step before you can continue." }), _jsx("figure", { className: "flex justify-center rounded border p-2", children: _jsx("img", { alt: "qrcode", src: url }) }), _jsxs("p", { className: "mb-4", children: [_jsx("strong", { children: "Step 1:" }), " Scan the QR code, or enter the secret below, in the Google Authenticator app."] }), _jsx(Button, { onClick: nextStep, variant: "primary", isFullWidth: true, children: "Continue" })] }), _jsxs("div", { className: step === 2 ? null : 'sr-only', children: [_jsxs("p", { className: "mb-4", children: [_jsx("strong", { children: "Step 2:" }), " Enter the 6-digit code listed in the Google Authenticator app:"] }), _jsx(MFAForm, {}), _jsx(Link, { className: classNames?.link, onClick: previousStep, children: "Scan QRcode again" })] })] }));
19
16
  }
20
17
  export default MFASetupForm;
@@ -23,6 +23,6 @@ function PasswordForm({ classNames, email }) {
23
23
  setFormData('email', '');
24
24
  setSentCount(0);
25
25
  }
26
- return (_jsxs(Fragment, { children: [_jsx("div", { className: tw('', sentCount === 0 ? 'block' : 'hidden'), children: _jsxs(Form, { ...formProps, children: [_jsxs("div", { children: [_jsx("h1", { className: classNames?.title, children: "Reset Your Password" }), _jsx("p", { className: "text-sm", children: "Enter the email address associated with your account and we'll send you a link to reset your password." })] }), _jsx(TextFormField, { ...fieldProps('email'), hasAssistiveLabel: true }), _jsx("div", { className: tw('', classNames?.actions), children: _jsx(FormSubmit, { children: "Send Email" }) })] }) }), _jsxs("div", { className: tw('-mt-1 text-sm', sentCount > 0 ? 'block' : 'hidden'), children: [_jsx("h1", { className: classNames?.title, children: "Check Your Email" }), sentCount === 1 ? (_jsxs(Fragment, { children: [_jsxs("p", { className: "mb-4", children: ["If ", formData.email, " matches an email we have on file, then we've sent you an email containing further instructions for resetting your password."] }), _jsxs("p", { children: ["If you haven't received an email in 5 minutes, check your spam,", ' ', _jsx(Link, { className: classNames?.link, onClick: handleResend, children: "resend" }), ", or", ' ', _jsx(Link, { className: classNames?.link, onClick: handleReset, children: "try a different email address" }), "."] })] })) : (_jsxs(Fragment, { children: [_jsxs("p", { className: "mb-4", children: ["We've resent password reset instructions to ", formData.email, ", if it is an email we have on file."] }), _jsxs("p", { children: ["Please check again. If you still haven't received an email,", ' ', _jsx(Link, { className: classNames?.link, onClick: handleReset, children: "try a different email address" }), "."] })] }))] })] }));
26
+ return (_jsxs(Fragment, { children: [_jsx("div", { className: tw('', sentCount === 0 ? 'block' : 'hidden'), children: _jsxs(Form, { ...formProps, classNames: { root: classNames?.form }, children: [_jsxs("div", { children: [_jsx("h1", { className: classNames?.title, children: "Reset Your Password" }), _jsx("p", { className: "text-sm", children: "Enter the email address associated with your account and we'll send you a link to reset your password." })] }), _jsx(TextFormField, { ...fieldProps('email'), hasAssistiveLabel: true }), _jsx("div", { className: tw('', classNames?.actions), children: _jsx(FormSubmit, { children: "Send Email" }) })] }) }), _jsxs("div", { className: tw('-mt-1 text-sm', sentCount > 0 ? 'block' : 'hidden'), children: [_jsx("h1", { className: classNames?.title, children: "Check Your Email" }), sentCount === 1 ? (_jsxs(Fragment, { children: [_jsxs("p", { className: "mb-4", children: ["If ", formData.email, " matches an email we have on file, then we've sent you an email containing further instructions for resetting your password."] }), _jsxs("p", { children: ["If you haven't received an email in 5 minutes, check your spam,", ' ', _jsx(Link, { className: classNames?.link, onClick: handleResend, children: "resend" }), ", or", ' ', _jsx(Link, { className: classNames?.link, onClick: handleReset, children: "try a different email address" }), "."] })] })) : (_jsxs(Fragment, { children: [_jsxs("p", { className: "mb-4", children: ["We've resent password reset instructions to ", formData.email, ", if it is an email we have on file."] }), _jsxs("p", { children: ["Please check again. If you still haven't received an email,", ' ', _jsx(Link, { className: classNames?.link, onClick: handleReset, children: "try a different email address" }), "."] })] }))] })] }));
27
27
  }
28
28
  export default PasswordForm;
@@ -15,6 +15,6 @@ function PasswordResetForm({ classNames, token, }) {
15
15
  },
16
16
  toasts: { success: false },
17
17
  });
18
- return (_jsxs(Form, { ...formProps, children: [_jsx("h1", { className: classNames?.title, children: "Reset Your Password" }), _jsx("div", { className: "relative", children: _jsx(PasswordFormField, { ...fieldProps('password', 'New Password') }) }), _jsx("div", { className: "mt-8", children: _jsx(FormSubmit, { children: "Reset Password" }) })] }));
18
+ return (_jsxs(Form, { ...formProps, classNames: { root: classNames?.form }, children: [_jsx("h1", { className: classNames?.title, children: "Reset Your Password" }), _jsx("div", { className: "relative", children: _jsx(PasswordFormField, { ...fieldProps('password', 'New Password') }) }), _jsx("div", { className: "mt-8", children: _jsx(FormSubmit, { children: "Reset Password" }) })] }));
19
19
  }
20
20
  export default PasswordResetForm;
@@ -0,0 +1,10 @@
1
+ import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
2
+ import type { MFAFormFields } from '../server';
3
+ export interface UseMFAFormArgs {
4
+ onSubmit: UseFormArgs<MFAFormFields, boolean>['onSubmit'];
5
+ }
6
+ export interface UseMFAFormReturn extends UseFormReturn<MFAFormFields> {
7
+ key: number;
8
+ }
9
+ declare function useMFAForm({ onSubmit }: UseMFAFormArgs): UseMFAFormReturn;
10
+ export default useMFAForm;
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { useEffect, useState } from 'react';
3
+ import { useForm } from '@sqrzro/hooks';
4
+ import { useRouter } from 'next/navigation';
5
+ function useMFAForm({ onSubmit }) {
6
+ const router = useRouter();
7
+ const [errorCount, setErrorCount] = useState(0);
8
+ const form = useForm({
9
+ onSubmit,
10
+ onSuccess: () => {
11
+ router.push('/');
12
+ },
13
+ onValidationError: () => {
14
+ setErrorCount((count) => count + 1);
15
+ },
16
+ toasts: {
17
+ success: false,
18
+ validation: "There seems to be an issue with the code you've entered. Please try again.",
19
+ },
20
+ });
21
+ useEffect(() => {
22
+ form.resetForm();
23
+ }, [errorCount]);
24
+ return { ...form, key: errorCount };
25
+ }
26
+ export default useMFAForm;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  export { default as Auth } from './components/Auth';
2
2
  export type { AuthClassNames, AuthProps } from './components/Auth';
3
+ export type { MFASetupProps } from './components/MFASetup';
4
+ export { default as MFASetup } from './components/MFASetup';
3
5
  export { default as LogoutButton } from './components/LogoutButton';
6
+ export type { UseMFAFormArgs, UseMFAFormReturn } from './hooks/useMFAForm';
7
+ export { default as useMFAForm } from './hooks/useMFAForm';
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default as Auth } from './components/Auth';
2
+ export { default as MFASetup } from './components/MFASetup';
2
3
  export { default as LogoutButton } from './components/LogoutButton';
4
+ export { default as useMFAForm } from './hooks/useMFAForm';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/auth",
3
3
  "type": "module",
4
- "version": "2.0.0-bz.4",
4
+ "version": "2.0.0-bz.6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
@@ -12,6 +12,7 @@ import type { ScopeObject } from '../../server';
12
12
  export interface AuthClassNames {
13
13
  actions: string;
14
14
  footer: string;
15
+ form: string;
15
16
  link: string;
16
17
  logo: string;
17
18
  root: string;
@@ -22,7 +22,7 @@ function LoginForm({ classNames, searchParams }: Readonly<LoginFormProps>): Reac
22
22
  return (
23
23
  <Fragment>
24
24
  <h1 className={tw('text-center', classNames?.title)}>Sign in to continue</h1>
25
- <Form {...formProps}>
25
+ <Form {...formProps} classNames={{ root: classNames?.form }}>
26
26
  <TextFormField {...fieldProps('email')} hasAssistiveError />
27
27
  <PasswordFormField {...fieldProps('password')} hasAssistiveError />
28
28
  <div className={tw('', classNames?.actions)}>
@@ -1,57 +1,25 @@
1
1
  'use client';
2
2
 
3
- import { useEffect, useState } from 'react';
4
-
5
- import { CodeFormField, Form, FormSubmit, tw } from '@sqrzro/components';
6
- import { useForm } from '@sqrzro/hooks';
7
- import { useRouter } from 'next/navigation';
3
+ import { CodeFormField, Form, FormSubmit } from '@sqrzro/components';
8
4
 
5
+ import useMFAForm from '../../hooks/useMFAForm';
9
6
  import { submitMFAForm } from '../../server';
10
- import type { MFAFormFields } from '../../server';
11
-
12
- import type { AuthClassNames } from '../Auth';
13
-
14
- export interface MFAFormProps {
15
- classNames?: Partial<AuthClassNames>;
16
- hasAssistiveSubmit?: boolean;
17
- }
18
-
19
- function MFAForm({ hasAssistiveSubmit }: Readonly<MFAFormProps>): React.ReactElement {
20
- const router = useRouter();
21
-
22
- const [errorCount, setErrorCount] = useState(0);
23
7
 
24
- const { fieldProps, formProps, resetForm, submitForm } = useForm<MFAFormFields, boolean>({
25
- onSubmit: submitMFAForm,
26
- onSuccess: () => {
27
- router.push('/');
28
- },
29
- onValidationError: () => {
30
- setErrorCount((count) => count + 1);
31
- },
32
- toasts: {
33
- success: false,
34
- validation:
35
- "There seems to be an issue with the code you've entered. Please try again.",
36
- },
37
- });
8
+ export interface MFAFormProps {}
38
9
 
39
- useEffect(() => {
40
- resetForm();
41
- }, [errorCount]);
10
+ function MFAForm(): React.ReactElement {
11
+ const { formProps, fieldProps, key, submitForm } = useMFAForm({ onSubmit: submitMFAForm });
42
12
 
43
13
  return (
44
14
  <Form {...formProps}>
45
15
  <CodeFormField
46
- key={errorCount}
16
+ key={key}
47
17
  {...fieldProps('token')}
48
18
  onFinalChange={submitForm}
49
19
  hasAssistiveLabel
50
20
  isAutoFocus
51
21
  />
52
- <div className={tw(hasAssistiveSubmit ? 'sr-only' : '')}>
53
- <FormSubmit>Verify</FormSubmit>
54
- </div>
22
+ <FormSubmit>Verify</FormSubmit>
55
23
  </Form>
56
24
  );
57
25
  }
@@ -34,7 +34,7 @@ async function MFAPage({ classNames }: Readonly<MFAPageProps>): Promise<React.Re
34
34
  <p className="mb-6 text-center">
35
35
  Enter the 6-digit code listed in your authentication app:
36
36
  </p>
37
- <MFAForm classNames={classNames} hasAssistiveSubmit />
37
+ <MFAForm />
38
38
  </div>
39
39
  );
40
40
  }
@@ -7,12 +7,12 @@ import { Button, Link } from '@sqrzro/components';
7
7
  import type { AuthClassNames } from '../Auth';
8
8
  import MFAForm from '../MFAForm';
9
9
 
10
- export interface MFASetupProps {
10
+ export interface MFASetupFormProps {
11
11
  classNames?: Partial<AuthClassNames>;
12
12
  url: string;
13
13
  }
14
14
 
15
- function MFASetupForm({ classNames, url }: Readonly<MFASetupProps>): React.ReactElement {
15
+ function MFASetupForm({ classNames, url }: Readonly<MFASetupFormProps>): React.ReactElement {
16
16
  const [step, setStep] = useState(1);
17
17
 
18
18
  function nextStep(): void {
@@ -24,9 +24,9 @@ function MFASetupForm({ classNames, url }: Readonly<MFASetupProps>): React.React
24
24
  setStep(1);
25
25
  }
26
26
 
27
- if (step === 1) {
28
- return (
29
- <Fragment>
27
+ return (
28
+ <Fragment>
29
+ <div className={step === 1 ? null : 'sr-only'}>
30
30
  <p className="mb-4">
31
31
  You&#39;ll need to setup an additional authentication step before you can
32
32
  continue.
@@ -36,25 +36,22 @@ function MFASetupForm({ classNames, url }: Readonly<MFASetupProps>): React.React
36
36
  </figure>
37
37
  <p className="mb-4">
38
38
  <strong>Step 1:</strong> Scan the QR code, or enter the secret below, in the
39
- Google Authentictor app.
39
+ Google Authenticator app.
40
40
  </p>
41
41
  <Button onClick={nextStep} variant="primary" isFullWidth>
42
42
  Continue
43
43
  </Button>
44
- </Fragment>
45
- );
46
- }
47
-
48
- return (
49
- <Fragment>
50
- <p className="mb-4">
51
- <strong>Step 2:</strong> Enter the 6-digit code listed in the Google Authenticator
52
- app:
53
- </p>
54
- <MFAForm />
55
- <Link className={classNames?.link} onClick={previousStep}>
56
- Scan QRcode again
57
- </Link>
44
+ </div>
45
+ <div className={step === 2 ? null : 'sr-only'}>
46
+ <p className="mb-4">
47
+ <strong>Step 2:</strong> Enter the 6-digit code listed in the Google
48
+ Authenticator app:
49
+ </p>
50
+ <MFAForm />
51
+ <Link className={classNames?.link} onClick={previousStep}>
52
+ Scan QRcode again
53
+ </Link>
54
+ </div>
58
55
  </Fragment>
59
56
  );
60
57
  }
@@ -48,7 +48,7 @@ function PasswordForm({ classNames, email }: Readonly<PasswordFormProps>): React
48
48
  return (
49
49
  <Fragment>
50
50
  <div className={tw('', sentCount === 0 ? 'block' : 'hidden')}>
51
- <Form {...formProps}>
51
+ <Form {...formProps} classNames={{ root: classNames?.form }}>
52
52
  <div>
53
53
  <h1 className={classNames?.title}>Reset Your Password</h1>
54
54
  <p className="text-sm">
@@ -30,7 +30,7 @@ function PasswordResetForm({
30
30
  });
31
31
 
32
32
  return (
33
- <Form {...formProps}>
33
+ <Form {...formProps} classNames={{ root: classNames?.form }}>
34
34
  <h1 className={classNames?.title}>Reset Your Password</h1>
35
35
  <div className="relative">
36
36
  <PasswordFormField {...fieldProps('password', 'New Password')} />
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from 'react';
4
+
5
+ import { useForm } from '@sqrzro/hooks';
6
+ import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
7
+ import { useRouter } from 'next/navigation';
8
+
9
+ import type { MFAFormFields } from '../server';
10
+
11
+ export interface UseMFAFormArgs {
12
+ onSubmit: UseFormArgs<MFAFormFields, boolean>['onSubmit'];
13
+ }
14
+
15
+ export interface UseMFAFormReturn extends UseFormReturn<MFAFormFields> {
16
+ key: number;
17
+ }
18
+
19
+ function useMFAForm({ onSubmit }: UseMFAFormArgs): UseMFAFormReturn {
20
+ const router = useRouter();
21
+
22
+ const [errorCount, setErrorCount] = useState(0);
23
+
24
+ const form = useForm<MFAFormFields, boolean>({
25
+ onSubmit,
26
+ onSuccess: () => {
27
+ router.push('/');
28
+ },
29
+ onValidationError: () => {
30
+ setErrorCount((count) => count + 1);
31
+ },
32
+ toasts: {
33
+ success: false,
34
+ validation:
35
+ "There seems to be an issue with the code you've entered. Please try again.",
36
+ },
37
+ });
38
+
39
+ useEffect(() => {
40
+ form.resetForm();
41
+ }, [errorCount]);
42
+
43
+ return { ...form, key: errorCount };
44
+ }
45
+
46
+ export default useMFAForm;
package/src/index.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  export { default as Auth } from './components/Auth';
2
2
  export type { AuthClassNames, AuthProps } from './components/Auth';
3
+
4
+ export type { MFASetupProps } from './components/MFASetup';
5
+ export { default as MFASetup } from './components/MFASetup';
6
+
3
7
  export { default as LogoutButton } from './components/LogoutButton';
8
+
9
+ export type { UseMFAFormArgs, UseMFAFormReturn } from './hooks/useMFAForm';
10
+ export { default as useMFAForm } from './hooks/useMFAForm';
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { AuthClassNames } from '../Auth';
3
- interface TokenPasswordResetFormProps {
4
- classNames?: Partial<AuthClassNames>;
5
- token: string;
6
- }
7
- declare function TokenPasswordResetForm({ classNames, token, }: Readonly<TokenPasswordResetFormProps>): React.ReactElement;
8
- export default TokenPasswordResetForm;
@@ -1,20 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Form, FormSubmit, PasswordFormField } from '@sqrzro/components';
4
- import { useForm } from '@sqrzro/hooks';
5
- import { useRouter } from 'next/navigation';
6
- import { submitTokenPasswordResetForm } from '../../server';
7
- function TokenPasswordResetForm({ classNames, token, }) {
8
- const router = useRouter();
9
- const { fieldProps, formProps } = useForm({
10
- defaults: { token },
11
- hiddenFields: ['token'],
12
- onSubmit: submitTokenPasswordResetForm,
13
- onSuccess: (response) => {
14
- router.push(response || '/');
15
- },
16
- toasts: { success: false },
17
- });
18
- return (_jsxs(Form, { ...formProps, children: [_jsx("h1", { className: classNames?.title, children: "Reset Your Password" }), _jsx("div", { className: "relative", children: _jsx(PasswordFormField, { ...fieldProps('password', 'New Password') }) }), _jsx("div", { className: "mt-8", children: _jsx(FormSubmit, { children: "Reset Password" }) })] }));
19
- }
20
- export default TokenPasswordResetForm;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var components_1 = require("@sqrzro/components");
40
- var navigation_1 = require("next/navigation");
41
- var MFAForm_1 = require("../MFAForm");
42
- var MFASetup_1 = require("../MFASetup");
43
- var server_1 = require("../../server");
44
- function MFAPage(_a) {
45
- return __awaiter(this, arguments, void 0, function (_b) {
46
- var user, userHasMFA;
47
- var classNames = _b.classNames;
48
- return __generator(this, function (_c) {
49
- switch (_c.label) {
50
- case 0: return [4 /*yield*/, (0, server_1.checkMFAEnabled)()];
51
- case 1:
52
- if (!(_c.sent())) {
53
- return [2 /*return*/, (0, navigation_1.notFound)()];
54
- }
55
- return [4 /*yield*/, (0, server_1.getSessionUser)()];
56
- case 2:
57
- user = _c.sent();
58
- if (!user) {
59
- return [2 /*return*/, <div>Error</div>];
60
- }
61
- return [4 /*yield*/, (0, server_1.checkUserHasMFA)(user)];
62
- case 3:
63
- userHasMFA = _c.sent();
64
- if (!userHasMFA) {
65
- return [2 /*return*/, <MFASetup_1.default classNames={classNames}/>];
66
- }
67
- return [2 /*return*/, (<div>
68
- <h1 className={(0, components_1.tw)('text-center', classNames === null || classNames === void 0 ? void 0 : classNames.title)}>Multi-Factor Authentication</h1>
69
- <p className="mb-6 text-center">
70
- Enter the 6-digit code listed in your authentication app:
71
- </p>
72
- <MFAForm_1.default classNames={classNames} hasAssistiveSubmit/>
73
- </div>)];
74
- }
75
- });
76
- });
77
- }
78
- exports.default = MFAPage;