@selfauth/conformance 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) 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/compliance.d.ts +118 -0
  18. package/dist/compliance.d.ts.map +1 -0
  19. package/dist/compliance.js +201 -0
  20. package/dist/compliance.js.map +1 -0
  21. package/dist/coverage.d.ts +26 -0
  22. package/dist/coverage.d.ts.map +1 -0
  23. package/dist/coverage.js +105 -0
  24. package/dist/coverage.js.map +1 -0
  25. package/dist/index.d.ts +9 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +9 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/load.d.ts +12 -0
  30. package/dist/load.d.ts.map +1 -0
  31. package/dist/load.js +26 -0
  32. package/dist/load.js.map +1 -0
  33. package/dist/render.d.ts +19 -0
  34. package/dist/render.d.ts.map +1 -0
  35. package/dist/render.js +20 -0
  36. package/dist/render.js.map +1 -0
  37. package/dist/report.d.ts +3 -0
  38. package/dist/report.d.ts.map +1 -0
  39. package/dist/report.js +31 -0
  40. package/dist/report.js.map +1 -0
  41. package/dist/runner/assertions.d.ts +11 -0
  42. package/dist/runner/assertions.d.ts.map +1 -0
  43. package/dist/runner/assertions.js +253 -0
  44. package/dist/runner/assertions.js.map +1 -0
  45. package/dist/runner/driver.d.ts +58 -0
  46. package/dist/runner/driver.d.ts.map +1 -0
  47. package/dist/runner/driver.js +2 -0
  48. package/dist/runner/driver.js.map +1 -0
  49. package/dist/runner/run.d.ts +17 -0
  50. package/dist/runner/run.d.ts.map +1 -0
  51. package/dist/runner/run.js +390 -0
  52. package/dist/runner/run.js.map +1 -0
  53. package/dist/schema.d.ts +168 -0
  54. package/dist/schema.d.ts.map +1 -0
  55. package/dist/schema.js +121 -0
  56. package/dist/schema.js.map +1 -0
  57. package/package.json +53 -3
  58. package/verification.json +165 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The SelfAuth Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,17 @@
1
- # Temporary Holding Version
1
+ # @selfauth/conformance
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Language-neutral conformance cases for SelfAuth adapters, the runner that
4
+ executes them, and requirement-coverage tooling.
5
+
6
+ - `cases/*.json`: one case per behaviour, each tied to the requirement IDs it
7
+ proves, for example "login is rate limited per account" or "a session can't
8
+ be fixed by the client".
9
+ - `loadCases()`, `runCase(driver, case)` and the `Driver` interface: an
10
+ adapter implements `Driver`, which is HTTP requests plus test-only views of
11
+ time, mail, storage and logs. It then runs every case. The Express
12
+ reference implementation passes all 87.
13
+ - `selfauth-coverage` (bin) reports every MUST requirement as covered by a
14
+ case, covered by `verification.json`, or uncovered.
15
+
16
+ See `CONFORMANCE.md` in [`@selfauth/spec`](https://www.npmjs.com/package/@selfauth/spec)
17
+ and the [repository](https://github.com/thetejasmagade/selfauth).
@@ -0,0 +1,326 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "CT-ADMIN-001",
5
+ "title": "Administrative operations require their system permission and are audited",
6
+ "category": "admin",
7
+ "level": "authorization",
8
+ "requirements": ["AUTHZ-ADMIN-001", "IDENT-STATE-005"],
9
+ "given": [
10
+ {
11
+ "user": "alice",
12
+ "email": "alice@example.test",
13
+ "password": "correct horse battery staple",
14
+ "state": "active"
15
+ },
16
+ {
17
+ "user": "bob",
18
+ "email": "bob@example.test",
19
+ "password": "correct horse battery staple",
20
+ "state": "active",
21
+ "roles": ["user"]
22
+ },
23
+ {
24
+ "user": "admin",
25
+ "email": "admin@example.test",
26
+ "password": "correct horse battery staple",
27
+ "state": "active",
28
+ "roles": ["admin"]
29
+ }
30
+ ],
31
+ "steps": [
32
+ {
33
+ "op": "login",
34
+ "as": "bob",
35
+ "input": {
36
+ "email": "bob@example.test",
37
+ "password": "correct horse battery staple"
38
+ }
39
+ },
40
+ {
41
+ "op": "setAccountState",
42
+ "as": "bob",
43
+ "input": {
44
+ "user": "$alice.id",
45
+ "state": "suspended"
46
+ },
47
+ "expect": {
48
+ "outcome": "error",
49
+ "code": "FORBIDDEN"
50
+ }
51
+ },
52
+ {
53
+ "op": "assignRole",
54
+ "as": "bob",
55
+ "input": {
56
+ "user": "$bob.id",
57
+ "role": "admin"
58
+ },
59
+ "expect": {
60
+ "outcome": "error",
61
+ "code": "FORBIDDEN"
62
+ }
63
+ },
64
+ {
65
+ "op": "login",
66
+ "as": "admin",
67
+ "input": {
68
+ "email": "admin@example.test",
69
+ "password": "correct horse battery staple"
70
+ }
71
+ },
72
+ {
73
+ "op": "setAccountState",
74
+ "as": "admin",
75
+ "input": {
76
+ "user": "$alice.id",
77
+ "state": "suspended"
78
+ },
79
+ "expect": {
80
+ "outcome": "success"
81
+ }
82
+ },
83
+ {
84
+ "op": "inspectEvents",
85
+ "input": {
86
+ "type": "account.state_changed"
87
+ },
88
+ "expect": {
89
+ "outcome": "success",
90
+ "assert": {
91
+ "count": 1,
92
+ "last.actorId": "$admin.id",
93
+ "last.userId": "$alice.id"
94
+ }
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "id": "CT-ADMIN-002",
101
+ "title": "Role assignment cannot escalate beyond the actor's own permissions",
102
+ "category": "admin",
103
+ "level": "authorization",
104
+ "requirements": ["AUTHZ-ADMIN-002"],
105
+ "config": {
106
+ "authorization": {
107
+ "permissions": [],
108
+ "roles": {
109
+ "user": [],
110
+ "moderator": ["auth.roles.assign"],
111
+ "admin": []
112
+ }
113
+ }
114
+ },
115
+ "given": [
116
+ {
117
+ "user": "bob",
118
+ "email": "bob@example.test",
119
+ "password": "correct horse battery staple",
120
+ "state": "active",
121
+ "roles": []
122
+ },
123
+ {
124
+ "user": "mod",
125
+ "email": "mod@example.test",
126
+ "password": "correct horse battery staple",
127
+ "state": "active",
128
+ "roles": ["moderator"]
129
+ }
130
+ ],
131
+ "steps": [
132
+ {
133
+ "op": "login",
134
+ "as": "mod",
135
+ "input": {
136
+ "email": "mod@example.test",
137
+ "password": "correct horse battery staple"
138
+ }
139
+ },
140
+ {
141
+ "op": "assignRole",
142
+ "as": "mod",
143
+ "input": {
144
+ "user": "$bob.id",
145
+ "role": "user"
146
+ },
147
+ "expect": {
148
+ "outcome": "success"
149
+ }
150
+ },
151
+ {
152
+ "op": "assignRole",
153
+ "as": "mod",
154
+ "input": {
155
+ "user": "$bob.id",
156
+ "role": "admin"
157
+ },
158
+ "expect": {
159
+ "outcome": "error",
160
+ "code": "FORBIDDEN"
161
+ }
162
+ },
163
+ {
164
+ "op": "assignRole",
165
+ "as": "mod",
166
+ "input": {
167
+ "user": "$mod.id",
168
+ "role": "admin"
169
+ },
170
+ "expect": {
171
+ "outcome": "error",
172
+ "code": "FORBIDDEN"
173
+ }
174
+ }
175
+ ]
176
+ },
177
+ {
178
+ "id": "CT-ADMIN-003",
179
+ "title": "The last active administrator cannot be removed or blocked",
180
+ "category": "admin",
181
+ "level": "authorization",
182
+ "requirements": ["AUTHZ-ADMIN-003"],
183
+ "given": [
184
+ {
185
+ "user": "admin",
186
+ "email": "admin@example.test",
187
+ "password": "correct horse battery staple",
188
+ "state": "active",
189
+ "roles": ["admin"]
190
+ }
191
+ ],
192
+ "steps": [
193
+ {
194
+ "op": "login",
195
+ "as": "admin",
196
+ "input": {
197
+ "email": "admin@example.test",
198
+ "password": "correct horse battery staple"
199
+ }
200
+ },
201
+ {
202
+ "op": "removeRole",
203
+ "as": "admin",
204
+ "input": {
205
+ "user": "$admin.id",
206
+ "role": "admin"
207
+ },
208
+ "expect": {
209
+ "outcome": "error",
210
+ "code": "CONFLICT"
211
+ }
212
+ },
213
+ {
214
+ "op": "setAccountState",
215
+ "as": "admin",
216
+ "input": {
217
+ "user": "$admin.id",
218
+ "state": "suspended"
219
+ },
220
+ "expect": {
221
+ "outcome": "error",
222
+ "code": "CONFLICT"
223
+ }
224
+ },
225
+ {
226
+ "op": "setAccountState",
227
+ "as": "admin",
228
+ "input": {
229
+ "user": "$admin.id",
230
+ "state": "deleted"
231
+ },
232
+ "expect": {
233
+ "outcome": "error",
234
+ "code": "CONFLICT"
235
+ }
236
+ },
237
+ {
238
+ "op": "deleteAccount",
239
+ "as": "admin",
240
+ "input": {
241
+ "currentPassword": "correct horse battery staple"
242
+ },
243
+ "expect": {
244
+ "outcome": "error",
245
+ "code": "CONFLICT"
246
+ }
247
+ }
248
+ ]
249
+ },
250
+ {
251
+ "id": "CT-ADMIN-004",
252
+ "title": "Suspending a user revokes their sessions immediately",
253
+ "category": "admin",
254
+ "level": "authorization",
255
+ "requirements": ["AUTHZ-ADMIN-006", "IDENT-STATE-003", "AUTHN-SESS-006"],
256
+ "given": [
257
+ {
258
+ "user": "alice",
259
+ "email": "alice@example.test",
260
+ "password": "correct horse battery staple",
261
+ "state": "active"
262
+ },
263
+ {
264
+ "user": "admin",
265
+ "email": "admin@example.test",
266
+ "password": "correct horse battery staple",
267
+ "state": "active",
268
+ "roles": ["admin"]
269
+ }
270
+ ],
271
+ "steps": [
272
+ {
273
+ "op": "login",
274
+ "as": "alice",
275
+ "input": {
276
+ "email": "alice@example.test",
277
+ "password": "correct horse battery staple"
278
+ }
279
+ },
280
+ {
281
+ "op": "login",
282
+ "as": "admin",
283
+ "input": {
284
+ "email": "admin@example.test",
285
+ "password": "correct horse battery staple"
286
+ }
287
+ },
288
+ {
289
+ "op": "setAccountState",
290
+ "as": "admin",
291
+ "input": {
292
+ "user": "$alice.id",
293
+ "state": "suspended"
294
+ },
295
+ "expect": {
296
+ "outcome": "success"
297
+ }
298
+ },
299
+ {
300
+ "op": "getCurrentUser",
301
+ "as": "alice",
302
+ "expect": {
303
+ "outcome": "error",
304
+ "code": "UNAUTHENTICATED"
305
+ }
306
+ },
307
+ {
308
+ "op": "inspectStorage",
309
+ "input": {
310
+ "entity": "session",
311
+ "where": {
312
+ "userId": "$alice.id",
313
+ "revokedAt": null
314
+ }
315
+ },
316
+ "expect": {
317
+ "outcome": "success",
318
+ "assert": {
319
+ "count": 0
320
+ }
321
+ }
322
+ }
323
+ ]
324
+ }
325
+ ]
326
+ }
@@ -0,0 +1,233 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "CT-AUDIT-001",
5
+ "title": "Security events carry the required fields",
6
+ "category": "audit-and-errors",
7
+ "level": "core",
8
+ "requirements": ["SEC-AUDIT-001", "SEC-AUDIT-002"],
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": "rawRequest",
20
+ "input": {
21
+ "operation": "login",
22
+ "headers": {
23
+ "User-Agent": "conformance-agent/1.0"
24
+ },
25
+ "body": {
26
+ "email": "alice@example.test",
27
+ "password": "correct horse battery staple"
28
+ }
29
+ }
30
+ },
31
+ {
32
+ "op": "inspectEvents",
33
+ "input": {
34
+ "type": "auth.login.succeeded"
35
+ },
36
+ "expect": {
37
+ "outcome": "success",
38
+ "assert": {
39
+ "last.hasFields": [
40
+ "type",
41
+ "occurredAt",
42
+ "outcome",
43
+ "userId",
44
+ "ipAddress",
45
+ "userAgent"
46
+ ],
47
+ "last.userAgent": "conformance-agent/1.0",
48
+ "last.outcome": "success"
49
+ }
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "id": "CT-LOG-001",
56
+ "title": "Logs and events never contain passwords, tokens or cookies",
57
+ "category": "audit-and-errors",
58
+ "level": "core",
59
+ "requirements": ["SEC-LOG-001", "SEC-HASH-007", "SEC-AUDIT-003"],
60
+ "given": [
61
+ {
62
+ "user": "alice",
63
+ "email": "alice@example.test",
64
+ "password": "correct horse battery staple",
65
+ "state": "active"
66
+ }
67
+ ],
68
+ "steps": [
69
+ {
70
+ "op": "login",
71
+ "input": {
72
+ "email": "alice@example.test",
73
+ "password": "correct horse battery staple"
74
+ },
75
+ "save": "sess"
76
+ },
77
+ {
78
+ "op": "login",
79
+ "input": {
80
+ "email": "alice@example.test",
81
+ "password": "wrong password!!"
82
+ }
83
+ },
84
+ {
85
+ "op": "requestPasswordReset",
86
+ "input": {
87
+ "email": "alice@example.test"
88
+ }
89
+ },
90
+ {
91
+ "op": "readLastEmail",
92
+ "input": {
93
+ "to": "alice@example.test"
94
+ },
95
+ "save": "mail"
96
+ },
97
+ {
98
+ "op": "resetPassword",
99
+ "input": {
100
+ "token": "$mail.token",
101
+ "newPassword": "a brand new passphrase 42"
102
+ }
103
+ },
104
+ {
105
+ "op": "inspectLogs",
106
+ "expect": {
107
+ "outcome": "success",
108
+ "assert": {
109
+ "noOccurrenceOf": [
110
+ "correct horse battery staple",
111
+ "a brand new passphrase 42",
112
+ "wrong password!!",
113
+ "$sess.cookieValue",
114
+ "$mail.token"
115
+ ]
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "op": "inspectEvents",
121
+ "input": {
122
+ "type": "*"
123
+ },
124
+ "expect": {
125
+ "outcome": "success",
126
+ "assert": {
127
+ "noFieldContaining": [
128
+ "correct horse battery staple",
129
+ "a brand new passphrase 42",
130
+ "$sess.cookieValue",
131
+ "$mail.token"
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ ]
137
+ },
138
+ {
139
+ "id": "CT-ERR-001",
140
+ "title": "Errors use the standard envelope; details describe only the caller's input",
141
+ "category": "audit-and-errors",
142
+ "level": "core",
143
+ "requirements": ["ERR-FORMAT-001", "ERR-FORMAT-002"],
144
+ "given": [
145
+ {
146
+ "user": "alice",
147
+ "email": "alice@example.test",
148
+ "password": "correct horse battery staple",
149
+ "state": "active"
150
+ }
151
+ ],
152
+ "steps": [
153
+ {
154
+ "op": "register",
155
+ "input": {
156
+ "email": "not-an-email",
157
+ "password": "correct horse battery staple"
158
+ },
159
+ "expect": {
160
+ "outcome": "error",
161
+ "code": "VALIDATION_FAILED",
162
+ "assert": {
163
+ "bodyHasPath": ["error.code", "error.message"],
164
+ "body.error.details[].field": {
165
+ "oneOf": ["email", "password"]
166
+ }
167
+ }
168
+ }
169
+ },
170
+ {
171
+ "op": "login",
172
+ "input": {
173
+ "email": "alice@example.test",
174
+ "password": "wrong password!!"
175
+ },
176
+ "expect": {
177
+ "outcome": "error",
178
+ "code": "INVALID_CREDENTIALS",
179
+ "assert": {
180
+ "bodyHasPath": ["error.code", "error.message"],
181
+ "bodyLacksPath": ["error.details"]
182
+ }
183
+ }
184
+ }
185
+ ]
186
+ },
187
+ {
188
+ "id": "CT-ERR-002",
189
+ "title": "Unexpected failures in production expose no internals",
190
+ "category": "audit-and-errors",
191
+ "level": "production",
192
+ "requirements": ["SEC-LOG-002", "ERR-FORMAT-001"],
193
+ "environment": "production",
194
+ "given": [],
195
+ "steps": [
196
+ {
197
+ "op": "rawRequest",
198
+ "input": {
199
+ "operation": "driverFaultRoute"
200
+ },
201
+ "expect": {
202
+ "outcome": "error",
203
+ "code": "INTERNAL_ERROR",
204
+ "assert": {
205
+ "bodyExcludesPatterns": ["at .*\\(.*:\\d+:\\d+\\)", "SELECT ", "Error: "]
206
+ }
207
+ }
208
+ }
209
+ ]
210
+ },
211
+ {
212
+ "id": "CT-HTTP-001",
213
+ "title": "Oversized request bodies are rejected",
214
+ "category": "audit-and-errors",
215
+ "level": "core",
216
+ "requirements": ["SEC-HTTP-003"],
217
+ "given": [],
218
+ "steps": [
219
+ {
220
+ "op": "rawRequest",
221
+ "input": {
222
+ "operation": "login",
223
+ "bodySizeBytes": 17408
224
+ },
225
+ "expect": {
226
+ "outcome": "error",
227
+ "code": "PAYLOAD_TOO_LARGE"
228
+ }
229
+ }
230
+ ]
231
+ }
232
+ ]
233
+ }