@selfauth/conformance 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -2
  3. package/cases/admin.json +326 -0
  4. package/cases/audit-and-errors.json +233 -0
  5. package/cases/csrf.json +413 -0
  6. package/cases/email-verification.json +567 -0
  7. package/cases/identity.json +546 -0
  8. package/cases/login.json +446 -0
  9. package/cases/logout.json +213 -0
  10. package/cases/password-change.json +270 -0
  11. package/cases/password-reset.json +698 -0
  12. package/cases/rate-limits.json +667 -0
  13. package/cases/rbac.json +575 -0
  14. package/cases/registration.json +782 -0
  15. package/cases/resources.json +373 -0
  16. package/cases/sessions.json +308 -0
  17. package/dist/coverage.d.ts +26 -0
  18. package/dist/coverage.d.ts.map +1 -0
  19. package/dist/coverage.js +105 -0
  20. package/dist/coverage.js.map +1 -0
  21. package/dist/index.d.ts +7 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +7 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/load.d.ts +12 -0
  26. package/dist/load.d.ts.map +1 -0
  27. package/dist/load.js +26 -0
  28. package/dist/load.js.map +1 -0
  29. package/dist/report.d.ts +3 -0
  30. package/dist/report.d.ts.map +1 -0
  31. package/dist/report.js +31 -0
  32. package/dist/report.js.map +1 -0
  33. package/dist/runner/assertions.d.ts +11 -0
  34. package/dist/runner/assertions.d.ts.map +1 -0
  35. package/dist/runner/assertions.js +253 -0
  36. package/dist/runner/assertions.js.map +1 -0
  37. package/dist/runner/driver.d.ts +58 -0
  38. package/dist/runner/driver.d.ts.map +1 -0
  39. package/dist/runner/driver.js +2 -0
  40. package/dist/runner/driver.js.map +1 -0
  41. package/dist/runner/run.d.ts +17 -0
  42. package/dist/runner/run.d.ts.map +1 -0
  43. package/dist/runner/run.js +390 -0
  44. package/dist/runner/run.js.map +1 -0
  45. package/dist/schema.d.ts +168 -0
  46. package/dist/schema.d.ts.map +1 -0
  47. package/dist/schema.js +121 -0
  48. package/dist/schema.js.map +1 -0
  49. package/package.json +53 -3
  50. package/verification.json +165 -0
@@ -0,0 +1,567 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "CT-VERIFY-001",
5
+ "title": "A valid verification token activates the account without creating a session",
6
+ "category": "email-verification",
7
+ "level": "core",
8
+ "requirements": ["AUTHN-VERIFY-007", "AUTHN-VERIFY-004", "SEC-TOKEN-002", "SEC-AUDIT-001"],
9
+ "given": [],
10
+ "steps": [
11
+ {
12
+ "op": "register",
13
+ "input": {
14
+ "email": "alice@example.test",
15
+ "password": "correct horse battery staple"
16
+ }
17
+ },
18
+ {
19
+ "op": "readLastEmail",
20
+ "input": {
21
+ "to": "alice@example.test"
22
+ },
23
+ "save": "mail"
24
+ },
25
+ {
26
+ "op": "inspectStorage",
27
+ "input": {
28
+ "entity": "emailVerificationToken"
29
+ },
30
+ "expect": {
31
+ "outcome": "success",
32
+ "assert": {
33
+ "noFieldContaining": ["$mail.token"],
34
+ "first.tokenHash": {
35
+ "sha256Of": "$mail.token"
36
+ }
37
+ }
38
+ }
39
+ },
40
+ {
41
+ "op": "verifyEmail",
42
+ "input": {
43
+ "token": "$mail.token"
44
+ },
45
+ "expect": {
46
+ "outcome": "success",
47
+ "sessionCreated": false
48
+ }
49
+ },
50
+ {
51
+ "op": "inspectStorage",
52
+ "input": {
53
+ "entity": "user",
54
+ "where": {
55
+ "emailNormalized": "alice@example.test"
56
+ }
57
+ },
58
+ "expect": {
59
+ "outcome": "success",
60
+ "assert": {
61
+ "first.state": "active",
62
+ "first.emailVerifiedAt": {
63
+ "notNull": true
64
+ }
65
+ }
66
+ }
67
+ },
68
+ {
69
+ "op": "inspectEvents",
70
+ "input": {
71
+ "type": "email.verified"
72
+ },
73
+ "expect": {
74
+ "outcome": "success",
75
+ "assert": {
76
+ "count": 1
77
+ }
78
+ }
79
+ },
80
+ {
81
+ "op": "login",
82
+ "input": {
83
+ "email": "alice@example.test",
84
+ "password": "correct horse battery staple"
85
+ },
86
+ "expect": {
87
+ "outcome": "success",
88
+ "sessionCreated": true
89
+ }
90
+ }
91
+ ]
92
+ },
93
+ {
94
+ "id": "CT-VERIFY-002",
95
+ "title": "Verification tokens are single-use",
96
+ "category": "email-verification",
97
+ "level": "core",
98
+ "requirements": ["AUTHN-VERIFY-006", "SEC-TOKEN-003"],
99
+ "given": [],
100
+ "steps": [
101
+ {
102
+ "op": "register",
103
+ "input": {
104
+ "email": "alice@example.test",
105
+ "password": "correct horse battery staple"
106
+ }
107
+ },
108
+ {
109
+ "op": "readLastEmail",
110
+ "input": {
111
+ "to": "alice@example.test"
112
+ },
113
+ "save": "mail"
114
+ },
115
+ {
116
+ "op": "verifyEmail",
117
+ "input": {
118
+ "token": "$mail.token"
119
+ },
120
+ "expect": {
121
+ "outcome": "success"
122
+ }
123
+ },
124
+ {
125
+ "op": "verifyEmail",
126
+ "input": {
127
+ "token": "$mail.token"
128
+ },
129
+ "expect": {
130
+ "outcome": "error",
131
+ "code": "TOKEN_INVALID"
132
+ }
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ "id": "CT-VERIFY-003",
138
+ "title": "Expired, unknown and used tokens fail with one indistinguishable error",
139
+ "category": "email-verification",
140
+ "level": "core",
141
+ "requirements": ["AUTHN-VERIFY-004", "AUTHN-VERIFY-005", "SEC-TOKEN-004"],
142
+ "given": [],
143
+ "steps": [
144
+ {
145
+ "op": "verifyEmail",
146
+ "input": {
147
+ "token": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
148
+ },
149
+ "expect": {
150
+ "outcome": "error",
151
+ "code": "TOKEN_INVALID"
152
+ },
153
+ "save": "unknown"
154
+ },
155
+ {
156
+ "op": "register",
157
+ "input": {
158
+ "email": "alice@example.test",
159
+ "password": "correct horse battery staple"
160
+ }
161
+ },
162
+ {
163
+ "op": "readLastEmail",
164
+ "input": {
165
+ "to": "alice@example.test"
166
+ },
167
+ "save": "mail"
168
+ },
169
+ {
170
+ "op": "advanceClock",
171
+ "input": {
172
+ "minutes": 1441
173
+ }
174
+ },
175
+ {
176
+ "op": "verifyEmail",
177
+ "input": {
178
+ "token": "$mail.token"
179
+ },
180
+ "expect": {
181
+ "outcome": "error",
182
+ "code": "TOKEN_INVALID",
183
+ "indistinguishableFrom": "unknown"
184
+ }
185
+ }
186
+ ]
187
+ },
188
+ {
189
+ "id": "CT-VERIFY-004",
190
+ "title": "Concurrent use of one verification token succeeds at most once",
191
+ "category": "email-verification",
192
+ "level": "core",
193
+ "requirements": ["AUTHN-VERIFY-006", "DATA-MODEL-002"],
194
+ "given": [],
195
+ "steps": [
196
+ {
197
+ "op": "register",
198
+ "input": {
199
+ "email": "alice@example.test",
200
+ "password": "correct horse battery staple"
201
+ }
202
+ },
203
+ {
204
+ "op": "readLastEmail",
205
+ "input": {
206
+ "to": "alice@example.test"
207
+ },
208
+ "save": "mail"
209
+ },
210
+ {
211
+ "op": "concurrent",
212
+ "input": {
213
+ "steps": [
214
+ {
215
+ "op": "verifyEmail",
216
+ "as": "c0",
217
+ "input": {
218
+ "token": "$mail.token"
219
+ }
220
+ },
221
+ {
222
+ "op": "verifyEmail",
223
+ "as": "c1",
224
+ "input": {
225
+ "token": "$mail.token"
226
+ }
227
+ },
228
+ {
229
+ "op": "verifyEmail",
230
+ "as": "c2",
231
+ "input": {
232
+ "token": "$mail.token"
233
+ }
234
+ },
235
+ {
236
+ "op": "verifyEmail",
237
+ "as": "c3",
238
+ "input": {
239
+ "token": "$mail.token"
240
+ }
241
+ },
242
+ {
243
+ "op": "verifyEmail",
244
+ "as": "c4",
245
+ "input": {
246
+ "token": "$mail.token"
247
+ }
248
+ }
249
+ ]
250
+ },
251
+ "expect": {
252
+ "outcome": "success",
253
+ "successCount": 1
254
+ }
255
+ }
256
+ ]
257
+ },
258
+ {
259
+ "id": "CT-VERIFY-005",
260
+ "title": "Resend is indistinguishable for pending, verified and unknown emails",
261
+ "category": "email-verification",
262
+ "level": "core",
263
+ "requirements": ["AUTHN-VERIFY-001", "SEC-ENUM-001"],
264
+ "given": [
265
+ {
266
+ "user": "pending",
267
+ "email": "pending@example.test",
268
+ "password": "correct horse battery staple",
269
+ "state": "pending"
270
+ },
271
+ {
272
+ "user": "alice",
273
+ "email": "alice@example.test",
274
+ "password": "correct horse battery staple",
275
+ "state": "active"
276
+ }
277
+ ],
278
+ "steps": [
279
+ {
280
+ "op": "requestEmailVerification",
281
+ "input": {
282
+ "email": "pending@example.test"
283
+ },
284
+ "expect": {
285
+ "outcome": "success"
286
+ },
287
+ "save": "pending"
288
+ },
289
+ {
290
+ "op": "requestEmailVerification",
291
+ "input": {
292
+ "email": "alice@example.test"
293
+ },
294
+ "expect": {
295
+ "outcome": "success",
296
+ "indistinguishableFrom": "pending"
297
+ }
298
+ },
299
+ {
300
+ "op": "requestEmailVerification",
301
+ "input": {
302
+ "email": "nobody@example.test"
303
+ },
304
+ "expect": {
305
+ "outcome": "success",
306
+ "indistinguishableFrom": "pending"
307
+ }
308
+ },
309
+ {
310
+ "op": "readLastEmail",
311
+ "input": {
312
+ "to": "pending@example.test"
313
+ },
314
+ "expect": {
315
+ "outcome": "success",
316
+ "assert": {
317
+ "kind": "verification"
318
+ }
319
+ }
320
+ },
321
+ {
322
+ "op": "readLastEmail",
323
+ "input": {
324
+ "to": "alice@example.test"
325
+ },
326
+ "expect": {
327
+ "outcome": "success",
328
+ "assert": {
329
+ "none": true
330
+ }
331
+ }
332
+ }
333
+ ]
334
+ },
335
+ {
336
+ "id": "CT-VERIFY-006",
337
+ "title": "Resend is rate limited per email, identically for unknown emails",
338
+ "category": "email-verification",
339
+ "level": "core",
340
+ "requirements": ["AUTHN-VERIFY-002", "SEC-RATE-002", "SEC-RATE-004"],
341
+ "given": [
342
+ {
343
+ "user": "pending",
344
+ "email": "pending@example.test",
345
+ "password": "correct horse battery staple",
346
+ "state": "pending"
347
+ }
348
+ ],
349
+ "steps": [
350
+ {
351
+ "op": "requestEmailVerification",
352
+ "input": {
353
+ "email": "pending@example.test"
354
+ },
355
+ "expect": {
356
+ "outcome": "success"
357
+ }
358
+ },
359
+ {
360
+ "op": "requestEmailVerification",
361
+ "input": {
362
+ "email": "pending@example.test"
363
+ },
364
+ "expect": {
365
+ "outcome": "success"
366
+ }
367
+ },
368
+ {
369
+ "op": "requestEmailVerification",
370
+ "input": {
371
+ "email": "pending@example.test"
372
+ },
373
+ "expect": {
374
+ "outcome": "success"
375
+ }
376
+ },
377
+ {
378
+ "op": "requestEmailVerification",
379
+ "input": {
380
+ "email": "pending@example.test"
381
+ },
382
+ "expect": {
383
+ "outcome": "error",
384
+ "code": "RATE_LIMITED",
385
+ "assert": {
386
+ "header.retry-after": {
387
+ "present": true
388
+ }
389
+ }
390
+ },
391
+ "save": "limited"
392
+ },
393
+ {
394
+ "op": "requestEmailVerification",
395
+ "input": {
396
+ "email": "nobody@example.test"
397
+ },
398
+ "expect": {
399
+ "outcome": "success"
400
+ }
401
+ },
402
+ {
403
+ "op": "requestEmailVerification",
404
+ "input": {
405
+ "email": "nobody@example.test"
406
+ },
407
+ "expect": {
408
+ "outcome": "success"
409
+ }
410
+ },
411
+ {
412
+ "op": "requestEmailVerification",
413
+ "input": {
414
+ "email": "nobody@example.test"
415
+ },
416
+ "expect": {
417
+ "outcome": "success"
418
+ }
419
+ },
420
+ {
421
+ "op": "requestEmailVerification",
422
+ "input": {
423
+ "email": "nobody@example.test"
424
+ },
425
+ "expect": {
426
+ "outcome": "error",
427
+ "code": "RATE_LIMITED",
428
+ "indistinguishableFrom": "limited"
429
+ }
430
+ }
431
+ ]
432
+ },
433
+ {
434
+ "id": "CT-VERIFY-007",
435
+ "title": "Email links use the configured base URL, never request headers",
436
+ "category": "email-verification",
437
+ "level": "core",
438
+ "requirements": ["AUTHN-VERIFY-009", "AUTHN-RESET-006"],
439
+ "given": [
440
+ {
441
+ "user": "alice",
442
+ "email": "alice@example.test",
443
+ "password": "correct horse battery staple",
444
+ "state": "active"
445
+ }
446
+ ],
447
+ "steps": [
448
+ {
449
+ "op": "rawRequest",
450
+ "input": {
451
+ "operation": "register",
452
+ "headers": {
453
+ "Host": "evil.test",
454
+ "X-Forwarded-Host": "evil.test"
455
+ },
456
+ "body": {
457
+ "email": "carol@example.test",
458
+ "password": "correct horse battery staple"
459
+ }
460
+ }
461
+ },
462
+ {
463
+ "op": "readLastEmail",
464
+ "input": {
465
+ "to": "carol@example.test"
466
+ },
467
+ "expect": {
468
+ "outcome": "success",
469
+ "assert": {
470
+ "linkStartsWith": "$config.appBaseUrl"
471
+ }
472
+ }
473
+ },
474
+ {
475
+ "op": "rawRequest",
476
+ "input": {
477
+ "operation": "requestPasswordReset",
478
+ "headers": {
479
+ "Host": "evil.test",
480
+ "X-Forwarded-Host": "evil.test"
481
+ },
482
+ "body": {
483
+ "email": "alice@example.test"
484
+ }
485
+ }
486
+ },
487
+ {
488
+ "op": "readLastEmail",
489
+ "input": {
490
+ "to": "alice@example.test"
491
+ },
492
+ "expect": {
493
+ "outcome": "success",
494
+ "assert": {
495
+ "kind": "passwordReset",
496
+ "linkStartsWith": "$config.appBaseUrl"
497
+ }
498
+ }
499
+ }
500
+ ]
501
+ },
502
+ {
503
+ "id": "CT-VERIFY-008",
504
+ "title": "Tokens are bound to their purpose",
505
+ "category": "email-verification",
506
+ "level": "core",
507
+ "requirements": ["SEC-TOKEN-003"],
508
+ "given": [
509
+ {
510
+ "user": "pending",
511
+ "email": "pending@example.test",
512
+ "password": "correct horse battery staple",
513
+ "state": "pending"
514
+ }
515
+ ],
516
+ "steps": [
517
+ {
518
+ "op": "requestPasswordReset",
519
+ "input": {
520
+ "email": "pending@example.test"
521
+ }
522
+ },
523
+ {
524
+ "op": "readLastEmail",
525
+ "input": {
526
+ "to": "pending@example.test"
527
+ },
528
+ "save": "reset"
529
+ },
530
+ {
531
+ "op": "verifyEmail",
532
+ "input": {
533
+ "token": "$reset.token"
534
+ },
535
+ "expect": {
536
+ "outcome": "error",
537
+ "code": "TOKEN_INVALID"
538
+ }
539
+ },
540
+ {
541
+ "op": "requestEmailVerification",
542
+ "input": {
543
+ "email": "pending@example.test"
544
+ }
545
+ },
546
+ {
547
+ "op": "readLastEmail",
548
+ "input": {
549
+ "to": "pending@example.test"
550
+ },
551
+ "save": "verify"
552
+ },
553
+ {
554
+ "op": "resetPassword",
555
+ "input": {
556
+ "token": "$verify.token",
557
+ "newPassword": "a brand new passphrase 42"
558
+ },
559
+ "expect": {
560
+ "outcome": "error",
561
+ "code": "TOKEN_INVALID"
562
+ }
563
+ }
564
+ ]
565
+ }
566
+ ]
567
+ }