@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,546 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "CT-IDENT-001",
5
+ "title": "Emails are trimmed, NFC-normalized and lower-cased for lookup",
6
+ "category": "identity",
7
+ "level": "core",
8
+ "requirements": ["IDENT-EMAIL-001"],
9
+ "given": [
10
+ {
11
+ "user": "alice",
12
+ "email": "alice@example.test",
13
+ "password": "correct horse battery staple",
14
+ "state": "active"
15
+ }
16
+ ],
17
+ "steps": [
18
+ {
19
+ "op": "login",
20
+ "input": {
21
+ "email": " ALICE@Example.Test ",
22
+ "password": "correct horse battery staple"
23
+ },
24
+ "expect": {
25
+ "outcome": "success",
26
+ "sessionCreated": true
27
+ }
28
+ },
29
+ {
30
+ "op": "register",
31
+ "note": "decomposed e + combining acute",
32
+ "input": {
33
+ "email": "José@example.test",
34
+ "password": "correct horse battery staple"
35
+ },
36
+ "expect": {
37
+ "outcome": "success"
38
+ }
39
+ },
40
+ {
41
+ "op": "inspectStorage",
42
+ "input": {
43
+ "entity": "user",
44
+ "where": {
45
+ "emailNormalized": "josé@example.test"
46
+ }
47
+ },
48
+ "expect": {
49
+ "outcome": "success",
50
+ "assert": {
51
+ "count": 1
52
+ }
53
+ }
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ "id": "CT-IDENT-002",
59
+ "title": "No provider-specific normalization: dots and +tags are distinct addresses",
60
+ "category": "identity",
61
+ "level": "core",
62
+ "requirements": ["IDENT-EMAIL-002"],
63
+ "given": [
64
+ {
65
+ "user": "alice",
66
+ "email": "alice@example.test",
67
+ "password": "correct horse battery staple",
68
+ "state": "active"
69
+ }
70
+ ],
71
+ "steps": [
72
+ {
73
+ "op": "register",
74
+ "input": {
75
+ "email": "a.lice@example.test",
76
+ "password": "correct horse battery staple"
77
+ },
78
+ "expect": {
79
+ "outcome": "success"
80
+ }
81
+ },
82
+ {
83
+ "op": "register",
84
+ "input": {
85
+ "email": "alice+tag@example.test",
86
+ "password": "correct horse battery staple"
87
+ },
88
+ "expect": {
89
+ "outcome": "success"
90
+ }
91
+ },
92
+ {
93
+ "op": "inspectStorage",
94
+ "input": {
95
+ "entity": "user"
96
+ },
97
+ "expect": {
98
+ "outcome": "success",
99
+ "assert": {
100
+ "count": 3
101
+ }
102
+ }
103
+ }
104
+ ]
105
+ },
106
+ {
107
+ "id": "CT-IDENT-003",
108
+ "title": "User identifiers are server-assigned and not sequential",
109
+ "category": "identity",
110
+ "level": "core",
111
+ "requirements": ["IDENT-ID-001", "IDENT-ID-002"],
112
+ "given": [],
113
+ "steps": [
114
+ {
115
+ "op": "register",
116
+ "input": {
117
+ "email": "u1@example.test",
118
+ "password": "correct horse battery staple"
119
+ }
120
+ },
121
+ {
122
+ "op": "register",
123
+ "input": {
124
+ "email": "u2@example.test",
125
+ "password": "correct horse battery staple"
126
+ }
127
+ },
128
+ {
129
+ "op": "inspectStorage",
130
+ "input": {
131
+ "entity": "user"
132
+ },
133
+ "expect": {
134
+ "outcome": "success",
135
+ "assert": {
136
+ "ids.opaque": true,
137
+ "ids.notSequential": true
138
+ }
139
+ }
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ "id": "CT-IDENT-004",
145
+ "title": "Only allowed state transitions succeed; deleted is terminal; changes are audited",
146
+ "category": "identity",
147
+ "level": "authorization",
148
+ "requirements": ["IDENT-STATE-002", "IDENT-STATE-005"],
149
+ "given": [
150
+ {
151
+ "user": "alice",
152
+ "email": "alice@example.test",
153
+ "password": "correct horse battery staple",
154
+ "state": "active"
155
+ },
156
+ {
157
+ "user": "admin",
158
+ "email": "admin@example.test",
159
+ "password": "correct horse battery staple",
160
+ "state": "active",
161
+ "roles": ["admin"]
162
+ }
163
+ ],
164
+ "steps": [
165
+ {
166
+ "op": "login",
167
+ "as": "admin",
168
+ "input": {
169
+ "email": "admin@example.test",
170
+ "password": "correct horse battery staple"
171
+ }
172
+ },
173
+ {
174
+ "op": "setAccountState",
175
+ "as": "admin",
176
+ "note": "active -> pending is not an allowed transition",
177
+ "input": {
178
+ "user": "$alice.id",
179
+ "state": "pending"
180
+ },
181
+ "expect": {
182
+ "outcome": "error",
183
+ "code": "CONFLICT"
184
+ }
185
+ },
186
+ {
187
+ "op": "setAccountState",
188
+ "as": "admin",
189
+ "input": {
190
+ "user": "$alice.id",
191
+ "state": "suspended"
192
+ },
193
+ "expect": {
194
+ "outcome": "success"
195
+ }
196
+ },
197
+ {
198
+ "op": "inspectEvents",
199
+ "input": {
200
+ "type": "account.state_changed"
201
+ },
202
+ "expect": {
203
+ "outcome": "success",
204
+ "assert": {
205
+ "last.metadata.from": "active",
206
+ "last.metadata.to": "suspended",
207
+ "last.actorId": "$admin.id"
208
+ }
209
+ }
210
+ },
211
+ {
212
+ "op": "setAccountState",
213
+ "as": "admin",
214
+ "input": {
215
+ "user": "$alice.id",
216
+ "state": "deleted"
217
+ },
218
+ "expect": {
219
+ "outcome": "success"
220
+ }
221
+ },
222
+ {
223
+ "op": "setAccountState",
224
+ "as": "admin",
225
+ "input": {
226
+ "user": "$alice.id",
227
+ "state": "active"
228
+ },
229
+ "expect": {
230
+ "outcome": "error",
231
+ "codeOneOf": ["CONFLICT", "NOT_FOUND"]
232
+ }
233
+ }
234
+ ]
235
+ },
236
+ {
237
+ "id": "CT-IDENT-005",
238
+ "title": "Session validation rejects users who are no longer active even if the session was not revoked",
239
+ "category": "identity",
240
+ "level": "core",
241
+ "requirements": ["IDENT-STATE-004", "AUTHN-SESS-003"],
242
+ "given": [
243
+ {
244
+ "user": "alice",
245
+ "email": "alice@example.test",
246
+ "password": "correct horse battery staple",
247
+ "state": "active"
248
+ }
249
+ ],
250
+ "steps": [
251
+ {
252
+ "op": "login",
253
+ "input": {
254
+ "email": "alice@example.test",
255
+ "password": "correct horse battery staple"
256
+ },
257
+ "expect": {
258
+ "outcome": "success",
259
+ "sessionCreated": true
260
+ }
261
+ },
262
+ {
263
+ "op": "mutateStorage",
264
+ "note": "bypasses the service layer, so sessions are not revoked",
265
+ "input": {
266
+ "entity": "user",
267
+ "where": {
268
+ "id": "$alice.id"
269
+ },
270
+ "set": {
271
+ "state": "suspended"
272
+ }
273
+ }
274
+ },
275
+ {
276
+ "op": "getCurrentUser",
277
+ "expect": {
278
+ "outcome": "error",
279
+ "code": "UNAUTHENTICATED"
280
+ }
281
+ }
282
+ ]
283
+ },
284
+ {
285
+ "id": "CT-IDENT-006",
286
+ "title": "Responses never contain password hashes or token material",
287
+ "category": "identity",
288
+ "level": "core",
289
+ "requirements": ["IDENT-PROFILE-002", "AUTHN-LOGIN-009"],
290
+ "given": [
291
+ {
292
+ "user": "alice",
293
+ "email": "alice@example.test",
294
+ "password": "correct horse battery staple",
295
+ "state": "active"
296
+ }
297
+ ],
298
+ "steps": [
299
+ {
300
+ "op": "login",
301
+ "input": {
302
+ "email": "alice@example.test",
303
+ "password": "correct horse battery staple"
304
+ },
305
+ "expect": {
306
+ "outcome": "success",
307
+ "assert": {
308
+ "bodyHasPath": ["user.id"],
309
+ "bodyExcludesKeys": [
310
+ "password",
311
+ "passwordHash",
312
+ "secretHash",
313
+ "tokenHash",
314
+ "token",
315
+ "sessionToken"
316
+ ],
317
+ "bodyExcludesCookieValue": true
318
+ }
319
+ }
320
+ },
321
+ {
322
+ "op": "getCurrentUser",
323
+ "expect": {
324
+ "outcome": "success",
325
+ "assert": {
326
+ "bodyExcludesKeys": ["password", "passwordHash", "secretHash", "tokenHash", "token"],
327
+ "bodyExcludesCookieValue": true
328
+ }
329
+ }
330
+ },
331
+ {
332
+ "op": "listSessions",
333
+ "expect": {
334
+ "outcome": "success",
335
+ "assert": {
336
+ "bodyExcludesKeys": ["token", "tokenHash"],
337
+ "bodyExcludesCookieValue": true
338
+ }
339
+ }
340
+ }
341
+ ]
342
+ },
343
+ {
344
+ "id": "CT-IDENT-007",
345
+ "title": "Credentials are stored separately as Argon2id PHC strings with minimum parameters",
346
+ "category": "identity",
347
+ "level": "core",
348
+ "requirements": [
349
+ "IDENT-PROFILE-001",
350
+ "SEC-HASH-001",
351
+ "SEC-HASH-002",
352
+ "SEC-HASH-003",
353
+ "SEC-HASH-007"
354
+ ],
355
+ "given": [],
356
+ "steps": [
357
+ {
358
+ "op": "register",
359
+ "input": {
360
+ "email": "alice@example.test",
361
+ "password": "correct horse battery staple"
362
+ }
363
+ },
364
+ {
365
+ "op": "inspectStorage",
366
+ "input": {
367
+ "entity": "user",
368
+ "where": {
369
+ "emailNormalized": "alice@example.test"
370
+ }
371
+ },
372
+ "expect": {
373
+ "outcome": "success",
374
+ "assert": {
375
+ "noFieldContaining": ["correct horse battery staple"],
376
+ "first.hasNoKeys": ["passwordHash", "secretHash"]
377
+ }
378
+ }
379
+ },
380
+ {
381
+ "op": "inspectStorage",
382
+ "input": {
383
+ "entity": "credential"
384
+ },
385
+ "expect": {
386
+ "outcome": "success",
387
+ "assert": {
388
+ "count": 1,
389
+ "first.type": "password",
390
+ "first.secretHash.phcAlgorithm": "argon2id",
391
+ "first.secretHash.argon2MinParams": [
392
+ {
393
+ "m": 19456,
394
+ "t": 2,
395
+ "p": 1
396
+ },
397
+ {
398
+ "m": 47104,
399
+ "t": 1,
400
+ "p": 1
401
+ }
402
+ ],
403
+ "first.secretHash.saltMinBytes": 16,
404
+ "noFieldContaining": ["correct horse battery staple"]
405
+ }
406
+ }
407
+ }
408
+ ]
409
+ },
410
+ {
411
+ "id": "CT-IDENT-008",
412
+ "title": "Account deletion requires the password, revokes access, deletes credentials and releases the email",
413
+ "category": "identity",
414
+ "level": "core",
415
+ "requirements": [
416
+ "IDENT-DELETE-001",
417
+ "IDENT-DELETE-002",
418
+ "IDENT-DELETE-003",
419
+ "IDENT-ID-003",
420
+ "IDENT-STATE-003"
421
+ ],
422
+ "given": [
423
+ {
424
+ "user": "alice",
425
+ "email": "alice@example.test",
426
+ "password": "correct horse battery staple",
427
+ "state": "active"
428
+ }
429
+ ],
430
+ "steps": [
431
+ {
432
+ "op": "login",
433
+ "as": "laptop",
434
+ "input": {
435
+ "email": "alice@example.test",
436
+ "password": "correct horse battery staple"
437
+ }
438
+ },
439
+ {
440
+ "op": "login",
441
+ "as": "phone",
442
+ "input": {
443
+ "email": "alice@example.test",
444
+ "password": "correct horse battery staple"
445
+ }
446
+ },
447
+ {
448
+ "op": "deleteAccount",
449
+ "as": "laptop",
450
+ "input": {
451
+ "currentPassword": "wrong password!!"
452
+ },
453
+ "expect": {
454
+ "outcome": "error",
455
+ "code": "INVALID_CREDENTIALS"
456
+ }
457
+ },
458
+ {
459
+ "op": "deleteAccount",
460
+ "as": "laptop",
461
+ "input": {
462
+ "currentPassword": "correct horse battery staple"
463
+ },
464
+ "expect": {
465
+ "outcome": "success"
466
+ }
467
+ },
468
+ {
469
+ "op": "getCurrentUser",
470
+ "as": "phone",
471
+ "expect": {
472
+ "outcome": "error",
473
+ "code": "UNAUTHENTICATED"
474
+ }
475
+ },
476
+ {
477
+ "op": "login",
478
+ "input": {
479
+ "email": "alice@example.test",
480
+ "password": "correct horse battery staple"
481
+ },
482
+ "expect": {
483
+ "outcome": "error",
484
+ "code": "INVALID_CREDENTIALS"
485
+ }
486
+ },
487
+ {
488
+ "op": "inspectStorage",
489
+ "input": {
490
+ "entity": "credential",
491
+ "where": {
492
+ "userId": "$alice.id"
493
+ }
494
+ },
495
+ "expect": {
496
+ "outcome": "success",
497
+ "assert": {
498
+ "count": 0
499
+ }
500
+ }
501
+ },
502
+ {
503
+ "op": "inspectStorage",
504
+ "input": {
505
+ "entity": "user",
506
+ "where": {
507
+ "id": "$alice.id"
508
+ }
509
+ },
510
+ "expect": {
511
+ "outcome": "success",
512
+ "assert": {
513
+ "first.state": "deleted",
514
+ "first.emailNormalized": null
515
+ }
516
+ }
517
+ },
518
+ {
519
+ "op": "register",
520
+ "input": {
521
+ "email": "alice@example.test",
522
+ "password": "correct horse battery staple"
523
+ },
524
+ "expect": {
525
+ "outcome": "success"
526
+ }
527
+ },
528
+ {
529
+ "op": "inspectStorage",
530
+ "input": {
531
+ "entity": "user",
532
+ "where": {
533
+ "emailNormalized": "alice@example.test"
534
+ }
535
+ },
536
+ "expect": {
537
+ "outcome": "success",
538
+ "assert": {
539
+ "first.idNot": "$alice.id"
540
+ }
541
+ }
542
+ }
543
+ ]
544
+ }
545
+ ]
546
+ }