Commit 3a804e3
committed
markets/: fix cookie sessions resolving to "[object Object]"
I widened the session verifier to return claims instead of an agent id
and shipped it without updating its two callers, so every cookie session
authenticated as the string "[object Object]". Every browser user shared
one ledger row, ensureAccount minted a phantom grant against that key,
the rate limiter was keyed on a fresh object per request (so it did
nothing), and market creation from the UI 400'd because isAgentId() of
an object fails. The conservation invariant was silently false and the
journal would have replayed it that way forever.
Sixty-two green tests missed this because they asserted status codes and
never asserted WHICH agent a cookie resolved to. There are now tests for
the identity itself, for two sessions not being the same account, and
for creating a market through a cookie session.
The epoch work that widening was for is now actually wired: tokens carry
an epoch, sign-out and freeze bump it, and a replayed token after
sign-out is dead. Previously DELETE /api/session only cleared the cookie
while the self-verifying token stayed valid for its full 12 hours.
Also from the review:
- A failed journal rotation closed the fd and never reopened it, so
every later commit died with EBADF -- every trade and settlement 500ing
forever, logged as "harmless, will retry". It never retried.
- eventsFor captured the segment list at boot, so a rotation at runtime
made the operator's agent-history query blind to everything written
since startup -- the same confidently-empty answer that query exists
to prevent.
- fs.writeSync's return value was ignored: a short write truncated an
event and fsync made the truncation durable, in the one function whose
entire purpose is durability.
- An admin voiding a disputed market through /void rather than
/adjudicate forfeited the disputer's bond despite vindicating them.
- ownOrigin() can be null without baseUrl, which would have 403'd every
browser mutation with no diagnostic; it now falls back to the
request's Host.
- The header diagram still described the old dispute-grace-to-void
policy that this round deliberately reversed.
64 plugin tests.1 parent 76af048 commit 3a804e3
4 files changed
Lines changed: 135 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
153 | 167 | | |
154 | 168 | | |
155 | 169 | | |
| |||
171 | 185 | | |
172 | 186 | | |
173 | 187 | | |
174 | | - | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
224 | 238 | | |
225 | 239 | | |
226 | 240 | | |
227 | | - | |
| 241 | + | |
228 | 242 | | |
229 | 243 | | |
230 | 244 | | |
231 | 245 | | |
232 | | - | |
| 246 | + | |
233 | 247 | | |
234 | 248 | | |
235 | 249 | | |
| |||
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
244 | 268 | | |
245 | 269 | | |
246 | 270 | | |
247 | 271 | | |
248 | 272 | | |
249 | 273 | | |
250 | 274 | | |
251 | | - | |
| 275 | + | |
252 | 276 | | |
253 | 277 | | |
254 | 278 | | |
| |||
294 | 318 | | |
295 | 319 | | |
296 | 320 | | |
297 | | - | |
| 321 | + | |
298 | 322 | | |
299 | 323 | | |
300 | 324 | | |
| |||
684 | 708 | | |
685 | 709 | | |
686 | 710 | | |
687 | | - | |
688 | 711 | | |
| 712 | + | |
689 | 713 | | |
690 | 714 | | |
691 | 715 | | |
692 | 716 | | |
693 | 717 | | |
694 | 718 | | |
695 | 719 | | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
696 | 726 | | |
697 | 727 | | |
698 | 728 | | |
| |||
1043 | 1073 | | |
1044 | 1074 | | |
1045 | 1075 | | |
1046 | | - | |
1047 | | - | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
1048 | 1080 | | |
1049 | 1081 | | |
1050 | 1082 | | |
| |||
1100 | 1132 | | |
1101 | 1133 | | |
1102 | 1134 | | |
1103 | | - | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
1104 | 1139 | | |
1105 | 1140 | | |
1106 | 1141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
| |||
416 | 418 | | |
417 | 419 | | |
418 | 420 | | |
419 | | - | |
420 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
421 | 424 | | |
422 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
423 | 433 | | |
424 | | - | |
425 | 434 | | |
426 | | - | |
427 | | - | |
| 435 | + | |
428 | 436 | | |
429 | 437 | | |
430 | 438 | | |
| |||
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
447 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
448 | 464 | | |
449 | 465 | | |
450 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
352 | 404 | | |
353 | 405 | | |
354 | 406 | | |
| |||
0 commit comments