@sqrzro/auth 2.0.0-bz.3 → 2.0.0-bz.5

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.4 build /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
3
3
  > tsc -p tsconfig.json
4
4
 
@@ -0,0 +1,592 @@
1
+
2
+ > @sqrzro/auth@2.0.0-bz.4 dev /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
3
+ > tsc -p tsconfig.json --watch
4
+
5
+ c[8:09:02 AM] Starting compilation in watch mode...
6
+
7
+ [8:09:04 AM] Found 0 errors. Watching for file changes.
8
+
9
+ c[8:09:07 AM] File change detected. Starting incremental compilation...
10
+
11
+ [8:09:07 AM] Found 0 errors. Watching for file changes.
12
+
13
+ c[8:09:11 AM] File change detected. Starting incremental compilation...
14
+
15
+ [8:09:11 AM] Found 0 errors. Watching for file changes.
16
+
17
+ c[8:14:09 AM] File change detected. Starting incremental compilation...
18
+
19
+ [8:14:09 AM] Found 0 errors. Watching for file changes.
20
+
21
+ c[8:14:25 AM] File change detected. Starting incremental compilation...
22
+
23
+ src/components/MFASetupForm/index.tsx:18:18 - error TS2322: Type '({ hasAssistiveSubmit }: Readonly<MFAFormProps>) => ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
24
+
25
+ 18 renderForm = MFAForm,
26
+    ~~~~~~~
27
+
28
+ src/components/MFASetupForm/index.tsx:18:18
29
+ 18 renderForm = MFAForm,
30
+    ~~~~~~~
31
+ Did you mean to call this expression?
32
+
33
+ [8:14:25 AM] Found 1 error. Watching for file changes.
34
+
35
+ c[8:15:09 AM] File change detected. Starting incremental compilation...
36
+
37
+ [8:15:09 AM] Found 0 errors. Watching for file changes.
38
+
39
+ c[8:15:39 AM] File change detected. Starting incremental compilation...
40
+
41
+ src/components/MFASetupForm/index.tsx:60:14 - error TS2554: Expected 1 arguments, but got 0.
42
+
43
+ 60 {renderForm()}
44
+    ~~~~~~~~~~
45
+
46
+ src/components/MFASetupForm/index.tsx:13:19
47
+ 13 renderForm?: (props: MFAFormProps) => React.ReactElement;
48
+    ~~~~~~~~~~~~~~~~~~~
49
+ An argument for 'props' was not provided.
50
+
51
+ [8:15:39 AM] Found 1 error. Watching for file changes.
52
+
53
+ c[8:16:05 AM] File change detected. Starting incremental compilation...
54
+
55
+ src/components/MFASetupForm/index.tsx:60:14 - error TS2554: Expected 1 arguments, but got 0.
56
+
57
+ 60 {renderForm()}
58
+    ~~~~~~~~~~
59
+
60
+ src/components/MFASetupForm/index.tsx:13:19
61
+ 13 renderForm?: (props: MFAFormProps) => React.ReactElement;
62
+    ~~~~~~~~~~~~~~~~~~~
63
+ An argument for 'props' was not provided.
64
+
65
+ [8:16:05 AM] Found 1 error. Watching for file changes.
66
+
67
+ c[8:16:22 AM] File change detected. Starting incremental compilation...
68
+
69
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
70
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
71
+
72
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
73
+    ~~~~~~~~~~
74
+
75
+ src/components/MFASetupForm/index.tsx:60:14 - error TS2554: Expected 1 arguments, but got 0.
76
+
77
+ 60 {renderForm()}
78
+    ~~~~~~~~~~
79
+
80
+ src/components/MFASetupForm/index.tsx:13:19
81
+ 13 renderForm?: (props: MFAFormProps) => React.ReactElement;
82
+    ~~~~~~~~~~~~~~~~~~~
83
+ An argument for 'props' was not provided.
84
+
85
+ [8:16:22 AM] Found 2 errors. Watching for file changes.
86
+
87
+ c[8:16:26 AM] File change detected. Starting incremental compilation...
88
+
89
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
90
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
91
+
92
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
93
+    ~~~~~~~~~~
94
+
95
+ src/components/MFASetupForm/index.tsx:60:14 - error TS2554: Expected 1 arguments, but got 0.
96
+
97
+ 60 {renderForm()}
98
+    ~~~~~~~~~~
99
+
100
+ src/components/MFASetupForm/index.tsx:13:19
101
+ 13 renderForm?: (props: MFAFormProps) => React.ReactElement;
102
+    ~~~~~~~~~~~~~~~~~~~
103
+ An argument for 'props' was not provided.
104
+
105
+ [8:16:26 AM] Found 2 errors. Watching for file changes.
106
+
107
+ c[8:16:26 AM] File change detected. Starting incremental compilation...
108
+
109
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
110
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
111
+
112
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
113
+    ~~~~~~~~~~
114
+
115
+ src/components/MFASetupForm/index.tsx:60:14 - error TS2554: Expected 1 arguments, but got 0.
116
+
117
+ 60 {renderForm()}
118
+    ~~~~~~~~~~
119
+
120
+ src/components/MFASetupForm/index.tsx:13:19
121
+ 13 renderForm?: (props: MFAFormProps) => React.ReactElement;
122
+    ~~~~~~~~~~~~~~~~~~~
123
+ An argument for 'props' was not provided.
124
+
125
+ [8:16:26 AM] Found 2 errors. Watching for file changes.
126
+
127
+ c[8:16:36 AM] File change detected. Starting incremental compilation...
128
+
129
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
130
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
131
+
132
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
133
+    ~~~~~~~~~~
134
+
135
+ [8:16:36 AM] Found 1 error. Watching for file changes.
136
+
137
+ c[8:19:59 AM] File change detected. Starting incremental compilation...
138
+
139
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
140
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
141
+
142
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
143
+    ~~~~~~~~~~
144
+
145
+ [8:20:00 AM] Found 1 error. Watching for file changes.
146
+
147
+ c[8:20:32 AM] File change detected. Starting incremental compilation...
148
+
149
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
150
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
151
+
152
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
153
+    ~~~~~~~~~~
154
+
155
+ [8:20:32 AM] Found 1 error. Watching for file changes.
156
+
157
+ c[8:24:31 AM] File change detected. Starting incremental compilation...
158
+
159
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
160
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
161
+
162
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
163
+    ~~~~~~~~~~
164
+
165
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
166
+
167
+ 6 import type { UseFormArgs } from '@sqrzro/hooks';
168
+    ~~~~~~~~~~~
169
+
170
+ ../hooks/dist/index.d.ts:423:11
171
+ 423 interface UseFormArgs<Request, Response> {
172
+    ~~~~~~~~~~~
173
+ 'UseFormArgs' is declared here.
174
+
175
+ src/hooks/useMFAForm.ts:38:9 - error TS2304: Cannot find name 'resetForm'.
176
+
177
+ 38 resetForm();
178
+    ~~~~~~~~~
179
+
180
+ [8:24:31 AM] Found 3 errors. Watching for file changes.
181
+
182
+ c[8:24:44 AM] File change detected. Starting incremental compilation...
183
+
184
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
185
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
186
+
187
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
188
+    ~~~~~~~~~~
189
+
190
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
191
+
192
+ 6 import type { UseFormArgs } from '@sqrzro/hooks';
193
+    ~~~~~~~~~~~
194
+
195
+ ../hooks/dist/index.d.ts:423:11
196
+ 423 interface UseFormArgs<Request, Response> {
197
+    ~~~~~~~~~~~
198
+ 'UseFormArgs' is declared here.
199
+
200
+ [8:24:44 AM] Found 2 errors. Watching for file changes.
201
+
202
+ c[8:25:06 AM] File change detected. Starting incremental compilation...
203
+
204
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
205
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
206
+
207
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
208
+    ~~~~~~~~~~
209
+
210
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
211
+
212
+ 6 import type { UseFormArgs } from '@sqrzro/hooks';
213
+    ~~~~~~~~~~~
214
+
215
+ ../hooks/dist/index.d.ts:423:11
216
+ 423 interface UseFormArgs<Request, Response> {
217
+    ~~~~~~~~~~~
218
+ 'UseFormArgs' is declared here.
219
+
220
+ [8:25:07 AM] Found 2 errors. Watching for file changes.
221
+
222
+ c[8:26:10 AM] File change detected. Starting incremental compilation...
223
+
224
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
225
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
226
+
227
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
228
+    ~~~~~~~~~~
229
+
230
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
231
+
232
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
233
+    ~~~~~~~~~~~
234
+
235
+ ../hooks/dist/index.d.ts:423:11
236
+ 423 interface UseFormArgs<Request, Response> {
237
+    ~~~~~~~~~~~
238
+ 'UseFormArgs' is declared here.
239
+
240
+ [8:26:10 AM] Found 2 errors. Watching for file changes.
241
+
242
+ c[8:26:30 AM] File change detected. Starting incremental compilation...
243
+
244
+ src/components/MFAForm/index.tsx:10:19 - error TS2304: Cannot find name 'formProps'.
245
+
246
+ 10 <Form {...formProps}>
247
+    ~~~~~~~~~
248
+
249
+ src/components/MFAForm/index.tsx:12:22 - error TS2304: Cannot find name 'errorCount'.
250
+
251
+ 12 key={errorCount}
252
+    ~~~~~~~~~~
253
+
254
+ src/components/MFAForm/index.tsx:13:21 - error TS2304: Cannot find name 'fieldProps'.
255
+
256
+ 13 {...fieldProps('token')}
257
+    ~~~~~~~~~~
258
+
259
+ src/components/MFAForm/index.tsx:14:32 - error TS2552: Cannot find name 'submitForm'. Did you mean 'submitMFAForm'?
260
+
261
+ 14 onFinalChange={submitForm}
262
+    ~~~~~~~~~~
263
+
264
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
265
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
266
+
267
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
268
+    ~~~~~~~~~~
269
+
270
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
271
+
272
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
273
+    ~~~~~~~~~~~
274
+
275
+ ../hooks/dist/index.d.ts:423:11
276
+ 423 interface UseFormArgs<Request, Response> {
277
+    ~~~~~~~~~~~
278
+ 'UseFormArgs' is declared here.
279
+
280
+ [8:26:30 AM] Found 6 errors. Watching for file changes.
281
+
282
+ c[8:26:54 AM] File change detected. Starting incremental compilation...
283
+
284
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
285
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
286
+
287
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
288
+    ~~~~~~~~~~
289
+
290
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
291
+
292
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
293
+    ~~~~~~~~~~~
294
+
295
+ ../hooks/dist/index.d.ts:423:11
296
+ 423 interface UseFormArgs<Request, Response> {
297
+    ~~~~~~~~~~~
298
+ 'UseFormArgs' is declared here.
299
+
300
+ [8:26:54 AM] Found 2 errors. Watching for file changes.
301
+
302
+ c[8:27:40 AM] File change detected. Starting incremental compilation...
303
+
304
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
305
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
306
+
307
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
308
+    ~~~~~~~~~~
309
+
310
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
311
+
312
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
313
+    ~~~~~~~~~~~
314
+
315
+ ../hooks/dist/index.d.ts:423:11
316
+ 423 interface UseFormArgs<Request, Response> {
317
+    ~~~~~~~~~~~
318
+ 'UseFormArgs' is declared here.
319
+
320
+ [8:27:40 AM] Found 2 errors. Watching for file changes.
321
+
322
+ c[8:27:56 AM] File change detected. Starting incremental compilation...
323
+
324
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
325
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
326
+
327
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
328
+    ~~~~~~~~~~
329
+
330
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
331
+
332
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
333
+    ~~~~~~~~~~~
334
+
335
+ ../hooks/dist/index.d.ts:423:11
336
+ 423 interface UseFormArgs<Request, Response> {
337
+    ~~~~~~~~~~~
338
+ 'UseFormArgs' is declared here.
339
+
340
+ src/index.ts:7:15 - error TS2724: '"./components/MFASetupForm"' has no exported member named 'MFASetupFormProps'. Did you mean 'MFASetupProps'?
341
+
342
+ 7 export type { MFASetupFormProps } from './components/MFASetupForm';
343
+    ~~~~~~~~~~~~~~~~~
344
+
345
+ [8:27:56 AM] Found 3 errors. Watching for file changes.
346
+
347
+ c[8:28:14 AM] File change detected. Starting incremental compilation...
348
+
349
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
350
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
351
+
352
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
353
+    ~~~~~~~~~~
354
+
355
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
356
+
357
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
358
+    ~~~~~~~~~~~
359
+
360
+ ../hooks/dist/index.d.ts:423:11
361
+ 423 interface UseFormArgs<Request, Response> {
362
+    ~~~~~~~~~~~
363
+ 'UseFormArgs' is declared here.
364
+
365
+ [8:28:14 AM] Found 2 errors. Watching for file changes.
366
+
367
+ c[8:29:38 AM] File change detected. Starting incremental compilation...
368
+
369
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
370
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
371
+
372
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
373
+    ~~~~~~~~~~
374
+
375
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
376
+
377
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
378
+    ~~~~~~~~~~~
379
+
380
+ ../hooks/dist/index.d.ts:423:11
381
+ 423 interface UseFormArgs<Request, Response> {
382
+    ~~~~~~~~~~~
383
+ 'UseFormArgs' is declared here.
384
+
385
+ [8:29:38 AM] Found 2 errors. Watching for file changes.
386
+
387
+ c[8:29:49 AM] File change detected. Starting incremental compilation...
388
+
389
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
390
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
391
+
392
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
393
+    ~~~~~~~~~~
394
+
395
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
396
+
397
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
398
+    ~~~~~~~~~~~
399
+
400
+ ../hooks/dist/index.d.ts:423:11
401
+ 423 interface UseFormArgs<Request, Response> {
402
+    ~~~~~~~~~~~
403
+ 'UseFormArgs' is declared here.
404
+
405
+ [8:29:49 AM] Found 2 errors. Watching for file changes.
406
+
407
+ c[8:33:29 AM] File change detected. Starting incremental compilation...
408
+
409
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
410
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
411
+
412
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
413
+    ~~~~~~~~~~
414
+
415
+ src/components/MFASetupForm/index.tsx:56:18 - error TS2322: Type '(props: MFAFormProps) => ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
416
+
417
+ 56 {renderForm}
418
+    ~~~~~~~~~~
419
+
420
+ src/components/MFASetupForm/index.tsx:56:18
421
+ 56 {renderForm}
422
+    ~~~~~~~~~~
423
+ Did you mean to call this expression?
424
+
425
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
426
+
427
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
428
+    ~~~~~~~~~~~
429
+
430
+ ../hooks/dist/index.d.ts:423:11
431
+ 423 interface UseFormArgs<Request, Response> {
432
+    ~~~~~~~~~~~
433
+ 'UseFormArgs' is declared here.
434
+
435
+ [8:33:29 AM] Found 3 errors. Watching for file changes.
436
+
437
+ c[8:33:53 AM] File change detected. Starting incremental compilation...
438
+
439
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
440
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
441
+
442
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
443
+    ~~~~~~~~~~
444
+
445
+ src/components/MFASetup/index.tsx:39:62 - error TS2322: Type '(props: MFAFormProps) => ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
446
+
447
+ 39 <MFASetupForm classNames={classNames} renderForm={renderForm} url={url} />
448
+    ~~~~~~~~~~~~
449
+
450
+ src/components/MFASetup/index.tsx:39:62
451
+ 39 <MFASetupForm classNames={classNames} renderForm={renderForm} url={url} />
452
+    ~~~~~~~~~~~~
453
+ Did you mean to call this expression?
454
+
455
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
456
+
457
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
458
+    ~~~~~~~~~~~
459
+
460
+ ../hooks/dist/index.d.ts:423:11
461
+ 423 interface UseFormArgs<Request, Response> {
462
+    ~~~~~~~~~~~
463
+ 'UseFormArgs' is declared here.
464
+
465
+ [8:33:53 AM] Found 3 errors. Watching for file changes.
466
+
467
+ c[8:34:00 AM] File change detected. Starting incremental compilation...
468
+
469
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
470
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
471
+
472
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
473
+    ~~~~~~~~~~
474
+
475
+ src/components/MFASetup/index.tsx:39:62 - error TS2322: Type '(props: MFAFormProps) => ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
476
+
477
+ 39 <MFASetupForm classNames={classNames} renderForm={renderForm} url={url} />
478
+    ~~~~~~~~~~~~
479
+
480
+ src/components/MFASetup/index.tsx:39:62
481
+ 39 <MFASetupForm classNames={classNames} renderForm={renderForm} url={url} />
482
+    ~~~~~~~~~~~~
483
+ Did you mean to call this expression?
484
+
485
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
486
+
487
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
488
+    ~~~~~~~~~~~
489
+
490
+ ../hooks/dist/index.d.ts:423:11
491
+ 423 interface UseFormArgs<Request, Response> {
492
+    ~~~~~~~~~~~
493
+ 'UseFormArgs' is declared here.
494
+
495
+ [8:34:00 AM] Found 3 errors. Watching for file changes.
496
+
497
+ c[8:38:09 AM] File change detected. Starting incremental compilation...
498
+
499
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
500
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
501
+
502
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
503
+    ~~~~~~~~~~
504
+
505
+ src/components/MFASetup/index.tsx:39:64 - error TS2604: JSX element type 'RenderedForm' does not have any construct or call signatures.
506
+
507
+ 39 <MFASetupForm classNames={classNames} renderForm={<RenderedForm />} url={url} />
508
+    ~~~~~~~~~~~~
509
+
510
+ src/components/MFASetup/index.tsx:39:64 - error TS2786: 'RenderedForm' cannot be used as a JSX component.
511
+ Its type 'ReactElement<any, string | JSXElementConstructor<any>>' is not a valid JSX element type.
512
+
513
+ 39 <MFASetupForm classNames={classNames} renderForm={<RenderedForm />} url={url} />
514
+    ~~~~~~~~~~~~
515
+
516
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
517
+
518
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
519
+    ~~~~~~~~~~~
520
+
521
+ ../hooks/dist/index.d.ts:423:11
522
+ 423 interface UseFormArgs<Request, Response> {
523
+    ~~~~~~~~~~~
524
+ 'UseFormArgs' is declared here.
525
+
526
+ [8:38:09 AM] Found 4 errors. Watching for file changes.
527
+
528
+ c[8:40:07 AM] File change detected. Starting incremental compilation...
529
+
530
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
531
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
532
+
533
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
534
+    ~~~~~~~~~~
535
+
536
+ src/components/MFASetup/index.tsx:39:51 - error TS2322: Type 'ComponentType<{}>' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
537
+ Type 'ComponentClass<{}, any>' is missing the following properties from type 'ReactElement<any, string | JSXElementConstructor<any>>': type, props, key
538
+
539
+ 39 <MFASetupForm classNames={classNames} renderForm={renderForm} url={url} />
540
+    ~~~~~~~~~~
541
+
542
+ src/components/MFASetupForm/index.tsx:12:5
543
+ 12 renderForm?: React.ReactElement;
544
+    ~~~~~~~~~~
545
+ The expected type comes from property 'renderForm' which is declared here on type 'IntrinsicAttributes & Readonly<MFASetupFormProps>'
546
+
547
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
548
+
549
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
550
+    ~~~~~~~~~~~
551
+
552
+ ../hooks/dist/index.d.ts:423:11
553
+ 423 interface UseFormArgs<Request, Response> {
554
+    ~~~~~~~~~~~
555
+ 'UseFormArgs' is declared here.
556
+
557
+ [8:40:07 AM] Found 3 errors. Watching for file changes.
558
+
559
+ c[8:40:47 AM] File change detected. Starting incremental compilation...
560
+
561
+ src/components/MFAPage/index.tsx:37:22 - error TS2322: Type '{ classNames: Partial<AuthClassNames>; hasAssistiveSubmit: true; }' is not assignable to type 'IntrinsicAttributes'.
562
+ Property 'classNames' does not exist on type 'IntrinsicAttributes'.
563
+
564
+ 37 <MFAForm classNames={classNames} hasAssistiveSubmit />
565
+    ~~~~~~~~~~
566
+
567
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
568
+
569
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
570
+    ~~~~~~~~~~~
571
+
572
+ ../hooks/dist/index.d.ts:423:11
573
+ 423 interface UseFormArgs<Request, Response> {
574
+    ~~~~~~~~~~~
575
+ 'UseFormArgs' is declared here.
576
+
577
+ [8:40:47 AM] Found 2 errors. Watching for file changes.
578
+
579
+ c[8:41:41 AM] File change detected. Starting incremental compilation...
580
+
581
+ src/hooks/useMFAForm.ts:6:15 - error TS2459: Module '"@sqrzro/hooks"' declares 'UseFormArgs' locally, but it is not exported.
582
+
583
+ 6 import type { UseFormArgs, UseFormReturn } from '@sqrzro/hooks';
584
+    ~~~~~~~~~~~
585
+
586
+ ../hooks/dist/index.d.ts:423:11
587
+ 423 interface UseFormArgs<Request, Response> {
588
+    ~~~~~~~~~~~
589
+ 'UseFormArgs' is declared here.
590
+
591
+ [8:41:41 AM] Found 1 error. Watching for file changes.
592
+
@@ -34,7 +34,6 @@ function getPage(route, props) {
34
34
  * client components. So we have to pass the classNames directly to the component.
35
35
  */
36
36
  async function Auth({ classNames, logo, onLogin, onPassword, params: { auth }, searchParams, }) {
37
- console.log('auth', auth);
38
37
  if (auth.length > 1) {
39
38
  return notFound();
40
39
  }
@@ -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 Authentictor 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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,20 @@
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;
@@ -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/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use server';
2
- import { handleLoginForm, handleLogout, handleMFAForm, handlePasswordForm, handlePasswordResetForm, checkUserHasMFA as serverCheckUserHasMFA, generateMFA as serverGenerateMFA, getSessionUser as serverGetSessionUser, checkMFAEnabled as syncCheckMFAEnabled, } from '@sqrzro/server/auth';
2
+ import { handleLoginForm, handleLogout, handleMFAForm, handlePasswordForm, handlePasswordResetWithTokenForm, checkUserHasMFA as serverCheckUserHasMFA, generateMFA as serverGenerateMFA, getSessionUser as serverGetSessionUser, checkMFAEnabled as syncCheckMFAEnabled, } from '@sqrzro/server/auth';
3
3
  const authEvents = {};
4
4
  export async function registerAuthEvents(events) {
5
5
  if (events.login) {
@@ -42,7 +42,7 @@ export async function submitPasswordForm(formData) {
42
42
  return handlePasswordForm(formData, sendPasswordResetMail);
43
43
  }
44
44
  export async function submitPasswordResetForm(formData) {
45
- return handlePasswordResetForm(formData);
45
+ return handlePasswordResetWithTokenForm(formData);
46
46
  }
47
47
  export async function logout() {
48
48
  return handleLogout();
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.3",
4
+ "version": "2.0.0-bz.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
@@ -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
  }
@@ -8,11 +8,6 @@ import { submitPasswordResetForm } from '../../server';
8
8
 
9
9
  import type { AuthClassNames } from '../Auth';
10
10
 
11
- interface PasswordResetFormFields {
12
- password: string;
13
- token: string;
14
- }
15
-
16
11
  interface PasswordResetFormProps {
17
12
  classNames?: Partial<AuthClassNames>;
18
13
  token: string;
@@ -24,7 +19,7 @@ function PasswordResetForm({
24
19
  }: Readonly<PasswordResetFormProps>): React.ReactElement {
25
20
  const router = useRouter();
26
21
 
27
- const { fieldProps, formProps } = useForm<PasswordResetFormFields, string | null>({
22
+ const { fieldProps, formProps } = useForm({
28
23
  defaults: { token },
29
24
  hiddenFields: ['token'],
30
25
  onSubmit: submitPasswordResetForm,
@@ -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';
package/src/server.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  handleLogout,
6
6
  handleMFAForm,
7
7
  handlePasswordForm,
8
- handlePasswordResetForm,
8
+ handlePasswordResetWithTokenForm,
9
9
  checkUserHasMFA as serverCheckUserHasMFA,
10
10
  generateMFA as serverGenerateMFA,
11
11
  getSessionUser as serverGetSessionUser,
@@ -87,7 +87,7 @@ export async function submitPasswordForm(
87
87
  export async function submitPasswordResetForm(
88
88
  formData: PasswordResetFormFields
89
89
  ): Promise<Errorable<string | null>> {
90
- return handlePasswordResetForm(formData);
90
+ return handlePasswordResetWithTokenForm(formData);
91
91
  }
92
92
 
93
93
  export async function logout(): Promise<void> {
@@ -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;