axiam-sdk 1.3.0 → 1.4.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/README.md +130 -14
  2. package/dist/amqp/index.d.cts +384 -17
  3. package/dist/amqp/index.d.ts +384 -17
  4. package/dist/amqp/index.js +639 -66
  5. package/dist/amqp/index.js.map +1 -1
  6. package/dist/amqp/index.mjs +631 -67
  7. package/dist/amqp/index.mjs.map +1 -1
  8. package/dist/{authzCore-D-hquWSI.d.ts → authzCore-Ced9zDIV.d.ts} +49 -12
  9. package/dist/{authzCore-CqXzLNmT.d.cts → authzCore-Des2NcKA.d.cts} +49 -12
  10. package/dist/browser/index.d.cts +1 -1
  11. package/dist/browser/index.d.ts +1 -1
  12. package/dist/{client-CaurIxje.d.ts → client-C1kRISf8.d.ts} +15 -1
  13. package/dist/{client-Bp7riC4k.d.cts → client-Dpd864N9.d.cts} +15 -1
  14. package/dist/{cookieJar-oKazfbN1.d.cts → cookieJar-CeH2FZIT.d.cts} +3 -3
  15. package/dist/{cookieJar-DC4GLKrJ.d.ts → cookieJar-DPx9Qtcf.d.ts} +3 -3
  16. package/dist/grpc/index.d.cts +5 -5
  17. package/dist/grpc/index.d.ts +5 -5
  18. package/dist/grpc/index.js +249 -18
  19. package/dist/grpc/index.js.map +1 -1
  20. package/dist/grpc/index.mjs +249 -18
  21. package/dist/grpc/index.mjs.map +1 -1
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +29 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +29 -3
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/{jwks-CTVpOWzI.d.cts → jwks-CQtWokVd.d.cts} +62 -7
  29. package/dist/{jwks-CTVpOWzI.d.ts → jwks-CQtWokVd.d.ts} +62 -7
  30. package/dist/middleware/index.d.cts +220 -43
  31. package/dist/middleware/index.d.ts +220 -43
  32. package/dist/middleware/index.js +587 -149
  33. package/dist/middleware/index.js.map +1 -1
  34. package/dist/middleware/index.mjs +579 -150
  35. package/dist/middleware/index.mjs.map +1 -1
  36. package/dist/nestjs/index.d.cts +18 -4
  37. package/dist/nestjs/index.d.ts +18 -4
  38. package/dist/nestjs/index.js +20 -1
  39. package/dist/nestjs/index.js.map +1 -1
  40. package/dist/nestjs/index.mjs +19 -2
  41. package/dist/nestjs/index.mjs.map +1 -1
  42. package/dist/node/index.d.cts +5 -5
  43. package/dist/node/index.d.ts +5 -5
  44. package/dist/node/index.js +351 -66
  45. package/dist/node/index.js.map +1 -1
  46. package/dist/node/index.mjs +348 -67
  47. package/dist/node/index.mjs.map +1 -1
  48. package/dist/{oidcState-CZhj0MBP.d.ts → oidcState-CzpXPAHF.d.ts} +54 -14
  49. package/dist/{oidcState-EnEJmoF5.d.cts → oidcState-XOYEMQP6.d.cts} +54 -14
  50. package/dist/rest/index.d.cts +3 -3
  51. package/dist/rest/index.d.ts +3 -3
  52. package/dist/rest/index.js +29 -3
  53. package/dist/rest/index.js.map +1 -1
  54. package/dist/rest/index.mjs +29 -3
  55. package/dist/rest/index.mjs.map +1 -1
  56. package/dist/{session-CeIUXgpE.d.cts → session-DoQzoChX.d.cts} +1 -1
  57. package/dist/{session-Beo11VT_.d.ts → session-Z-6IyaSU.d.ts} +1 -1
  58. package/package.json +10 -10
package/README.md CHANGED
@@ -20,13 +20,38 @@ Official TypeScript/JavaScript client SDK for [AXIAM](https://github.com/ilpanic
20
20
 
21
21
  ## Contract conformance
22
22
 
23
- This SDK conforms to **contract 1.66**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
23
+ The vendored `CONTRACT.md` is **contract 1.69**. This SDK conforms to **contract 1.66** as listed
24
+ here, **plus the contract 1.68 obligations of §34.12 (a)–(g)** and **the contract 1.69 obligations
25
+ of §34.13 (a)–(c)**: `verifyLogoutToken` selects the key by `kid` and refuses a kid-less token as
26
+ `unknown_kid` (a), the AMQP authz requester has no unsigned-response opt-out and requires a 1.68
27
+ server (b), and every requester discard logs the fixed event (c). The tables under "Contract
28
+ 1.68" below say what each §34.12 obligation does here. Of contract 1.67 (§34.11) it implements the
29
+ additive `AuditLogEntry.organization_id` ((c)) and, through 1.68's §10.1 rules 10–12, the verifier
30
+ half of (e); the documentation and test updates §34.11 (a)–(d) ask for are **not** done in this
31
+ release, so it does not claim 1.67 in full. Contract 1.66: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
24
32
  §20, §21, §22, §23, §24, §25, §26, §27 (with §27.6.2), §28, §28.12, §29, §30, §31, §32, §33, §36 and §37,
25
33
  with §32.7 and §33.2 signed (including §6.1 mTLS client certificates, the
26
34
  §10.1 minimum local-verification set, the §12 OIDC/SSO relying-party helpers, and the §13
27
35
  `verifyWebhook` signature verifier). Manifest pruning: not offered in any namespace (§27.10). §12 is implemented in full at its 1.38 shape: all
28
36
  **thirteen** operations, including the four public "Sign in with X" entry points.
29
37
 
38
+ ### Contract 1.68 — security audit 2026-11-14, Wave 2 (§34.12) — release 1.4.0
39
+
40
+ Release 1.4.0 is a **minor** release with three **behaviour changes for integrators** — the login
41
+ glue binding (C7), the `returnTo` rule (C6) and `requireRole` reading only the `roles` claim (N15).
42
+ Read the migration notes in the [CHANGELOG](./CHANGELOG.md#140---unreleased) before upgrading.
43
+
44
+ | Clause | What this SDK does |
45
+ |---|---|
46
+ | (a) login glue binds the callback to the browser (C7, §12.8 rules 1, 2, 4) | `oidcLoginHandlers` (Express) and `oidcLoginPlugin` (Fastify) set `__Host-axiam_oidc_bind` at login (`axiam_oidc_bind` without `Secure` only for a plain-HTTP loopback `redirectUri`), store its SHA-256 as `OidcStateEntry.bindingDigest`, and at the callback consume the state **first**, then compare in constant time; a missing or different cookie is the uniform `401` with no code exchange and no `onSuccess`. Every callback response clears the cookie, including the error response the framework sends when the state store or `onSuccess` throws (the error itself still reaches the application's error handler). `onSuccess` receives the framework request as a third argument. The framework-neutral `completeOidcLogin` takes the presented cookie in a new `context` argument and refuses every callback without one. Design: [`docs/login-glue-binding.md`](./docs/login-glue-binding.md). |
47
+ | (b) `returnTo` (C6, §12.8 rules 3, 4) | Followed only as a same-origin relative path (`isSafeReturnTo`), checked when stored and again before the redirect; otherwise dropped. `allowReturnTo` widens it. |
48
+ | (c) unknown-`kid` re-fetch window (§12.4 rule 2) | One 60 s window for every refresh, implemented by the verifier's own key-set cache (contract 1.69: TTL at most 300 s, bounded stale-if-error, see `test/node/jwksStaleIfError.test.ts`). The rule's conformance test is carried (`test/node/jwksRefetchWindow.test.ts`) against the §10 verifier: with a warm cache, 50 tokens with 50 different unknown `kid`s in one window cost at most one JWKS fetch and are all rejected; with the mocked clock past the window and a rotated set, the new `kid` is accepted after one fetch. The §10 verifier is bound to the JWKS URI and reads no discovery document. |
49
+ | (d) access-token kind (N14, §10.1 rules 10–12) | `verifyAccessToken` and `authenticateRequest` refuse a header `typ` other than `at+jwt` (case-insensitive, `application/` allowed), a `purpose` claim, and a header with no `kid` (no single-key fallback). A token from a server before 1.67 (`typ: JWT`) is refused. |
50
+ | (e) roles (N15, §11.2 rule 11) | `AxiamIdentity.roles` is the token's `roles` claim only (`undefined` when absent, `[]` kept distinct); the new `AxiamIdentity.scopes` carries `scope`. `requireRole`/`requireRoleHook`/`@RequireRole` fail closed without a `roles` claim; `requireScope`/`requireScopeHook`/`@RequireScope` are added. **Request the `roles` scope** (and register it on the client) for `requireRole` to admit anyone. |
51
+ | (f) signed `AuthzResponse` (N2, §8) | New `AuthzRequester` (`createAuthzRequester(channel, …)` / `connectAuthzRequester(amqpsUrl, …)`): publishes a signed `AuthzRequest` with fresh random `correlation_id` and `nonce` to `axiam.authz.request` on the default exchange, `reply_to` a private exclusive auto-delete broker-named queue (an empty or `axiam.`-prefixed name is refused), and resolves `check()` only with an answer `AuthzResponseVerifier` verifies over its received bytes (tenant subkey, own `tenant_id`, the request's `correlation_id` and `nonce`). Forged or mismatched answers are nacked without requeue and the check keeps waiting, until its timeout. An unsigned answer is discarded (`unsigned`) and the check keeps waiting; there is no option to accept one (contract 1.69, #881). Every discard logs one warning with `timestamp`, `exchange`, `routingKey`, the requester's own `tenantId` and a `reason` (`malformed`, `unsigned`, `signature`, `tenant`, `unknown_request`), never a signature or a nonce (contract 1.69, #883). `connectAuthzRequester` handles its own connection's and channel's `'error'` (logged, never an uncaught exception) and `'close'` (the requester closes, releasing every waiter at once); with `createAuthzRequester` the caller owns both. The four contract vectors and the request vector are tests. |
52
+ | (g) §3a for every cookie-accepting guard | No change: `axiamMiddleware` and `axiamPlugin` already apply it, and every §11 helper reads their identity. |
53
+ | (h), (i) | Informative; no SDK change. |
54
+
30
55
  ### Contract 1.66 — sign-in hardening (§34.10)
31
56
 
32
57
  Contract 1.66 adds no operation and changes no API here. A federated sign-in is bound to the client
@@ -216,7 +241,9 @@ rule on every inbound token: EdDSA `alg` pinned before the JWKS is consulted, a
216
241
  `exp` (`jose` only checks `exp` *if present*, so `requiredClaims: ['exp']` is passed
217
242
  explicitly), `nbf` honoured when present, `tenant_id` asserted against the session's
218
243
  configured tenant, `iss`/`aud` checked when configured, all under a named 60-second
219
- `CLOCK_SKEW_LEEWAY_SEC` — **and, since contract 1.51, rule 9**: a token carrying `cnf` is
244
+ `CLOCK_SKEW_LEEWAY_SEC`, **since contract 1.68 rules 10–12** (a header `typ` other than `at+jwt`,
245
+ a `purpose` claim, or a header with no `kid` is refused, so AXIAM's MFA-challenge and WebAuthn
246
+ state tokens never pass as access tokens) — **and, since contract 1.51, rule 9**: a token carrying `cnf` is
220
247
  refused unless transport evidence backs it. `axiamMiddleware`/`axiamPlugin` derive that
221
248
  evidence automatically from the request's own raw socket (the peer certificate the TLS
222
249
  layer verified for *this* connection, when Node itself terminates TLS) via the new
@@ -320,9 +347,9 @@ never contains `@grpc/grpc-js` or `amqplib`):
320
347
  | `axiam-sdk` / `axiam-sdk/rest` | Browser + Node, REST-only | `AxiamClient`: `login`/`verifyMfa`/`refresh`/`logout`, `can`/`batchCheck` over the FND-04 REST authz endpoint |
321
348
  | `axiam-sdk/browser` | Browser only | The WebAuthn **platform ceremony** — `webauthnRegister`/`webauthnSetupRegister`/`webauthnLogin`/`webauthnDiscoverableLogin` over `navigator.credentials` (CONTRACT.md §24.6b). The relying-party operations themselves are on `AxiamClient` in `/rest` and work in Node too. |
322
349
  | `axiam-sdk/grpc` | Node only | Everything in `/rest` plus `AuthzGrpcClient.checkAccess`/`batchCheck` and `UserInfoGrpcClient.getUserInfo` over gRPC, the Node persona (`createNodeSession`), and the local-JWKS verifier |
323
- | `axiam-sdk/amqp` | Node only | `consume()` — HMAC-verified AMQP audit/authz event consumer (CONTRACT.md §8) |
350
+ | `axiam-sdk/amqp` | Node only | `consume()` — HMAC-verified AMQP audit/authz event consumer, and `AuthzRequester` / `AuthzResponseVerifier` for authorization over AMQP with the signed `AuthzResponse` (CONTRACT.md §8) |
324
351
  | `axiam-sdk/node` | Node only | The Node persona (`createNodeSession`/`createNodeClient`, cookie jar + local-JWKS verifier) plus the **OIDC/SSO relying-party helpers** — `OidcClient`, `MemoryOidcStateStore`, PKCE primitives (CONTRACT.md §12) |
325
- | `axiam-sdk/middleware` | Node only | `axiamMiddleware` (Express) / `axiamPlugin` (Fastify) — shared local-JWKS verify core (CONTRACT.md §10) — plus `requireAuth`/`requireAccess`/`requireRole` declarative route guards (CONTRACT.md §11) and the `oidcLoginHandlers`/`oidcLoginPlugin` "Login with AXIAM" routes (CONTRACT.md §12) |
352
+ | `axiam-sdk/middleware` | Node only | `axiamMiddleware` (Express) / `axiamPlugin` (Fastify) — shared local-JWKS verify core (CONTRACT.md §10) — plus `requireAuth`/`requireAccess`/`requireRole`/`requireScope` declarative route guards (CONTRACT.md §11) and the `oidcLoginHandlers`/`oidcLoginPlugin` "Login with AXIAM" routes (CONTRACT.md §12) |
326
353
  | `axiam-sdk/nestjs` | Node only, optional | `@RequireAccess`/`@RequireAuth`/`@RequireRole` metadata decorators + `AxiamGuard` (CONTRACT.md §11, Tier 2) |
327
354
 
328
355
  **Browser code should only ever import from `axiam-sdk` or `axiam-sdk/rest`.** Importing
@@ -660,14 +687,73 @@ await consume(
660
687
  // Only a verified event ever reaches this closure — HMAC-SHA256
661
688
  // signature checked and stripped by the SDK before your handler runs
662
689
  // (CONTRACT.md §8). Verification failures are nacked-without-requeue.
690
+ // Verified over the received bytes: the body must start with `{`, end in
691
+ // the `hmac_signature` member and have exactly the configured type's
692
+ // members in order (§8 step 2; a byte-order mark is refused, never
693
+ // stripped). An unsigned message is always refused; there is no lenient mode.
663
694
  console.log('verified audit event:', event);
664
695
  },
665
- // Optional. The PEM bundle for a privately issued broker certificate — the
666
- // common in-cluster case (§8b rule 2), and the only TLS knob this SDK has.
667
- { tls: { caCert: readFileSync('/etc/axiam/broker-ca.pem', 'utf8') } },
696
+ {
697
+ tenantId, // this consumer's OWN tenant: named in every discard event
698
+ eventType: 'AuditEventMessage', // the ONE type consumed; any other layout is `malformed`
699
+ // Optional. The PEM bundle for a privately issued broker certificate — the
700
+ // common in-cluster case (§8b rule 2), and the only TLS knob this SDK has.
701
+ tls: { caCert: readFileSync('/etc/axiam/broker-ca.pem', 'utf8') },
702
+ },
668
703
  );
704
+ // Every discard (nack without requeue) logs ONE warning event with exactly `timestamp`, `exchange`,
705
+ // `routingKey`, `tenantId` and `reason` (`malformed` | `unsigned` | `signature` | `key_version` |
706
+ // `stale` | `replay`) — never a signature, a nonce, a key or the body. To consume both event types,
707
+ // run two consumers, each typed.
669
708
  ```
670
709
 
710
+ #### Authorization over AMQP — `AuthzRequester` (contract 1.68, §8)
711
+
712
+ The server signs every `AuthzResponse` with the requester's tenant subkey and binds it to the
713
+ request (`tenant_id`, `nonce`, `correlation_id`). `AuthzRequester` publishes the request and
714
+ accepts only that signed answer:
715
+
716
+ ```typescript
717
+ import { connectAuthzRequester, Sensitive } from 'axiam-sdk/amqp';
718
+
719
+ const authz = await connectAuthzRequester('amqps://broker.example.com:5671', {
720
+ tenantId, // your OWN tenant (UUID)
721
+ subkey: new Sensitive(tenantSubkey), // the tenant's HKDF-derived AMQP subkey, key_version 2
722
+ timeoutMs: 5_000, // default 10 s
723
+ });
724
+ const decision = await authz.check({ subjectId, action: 'documents:read', resourceId });
725
+ if (decision.allowed) { /* … */ }
726
+ await authz.close();
727
+ ```
728
+
729
+ Each request goes to `axiam.authz.request` with a fresh random `correlation_id` and `nonce`, and
730
+ `reply_to` names a private queue (exclusive, auto-delete, broker-named `amq.gen-…`) only this
731
+ requester consumes — the signature proves only "a holder of the tenant subkey", which every producer
732
+ of the tenant is, so the private queue is what keeps another same-tenant service from reading or
733
+ answering in your place (§8 trust boundary). An answer that does not verify, names another tenant,
734
+ or matches no outstanding request is nacked without requeue and the check keeps waiting; with no
735
+ verified answer it rejects with `NetworkError` at the timeout. A deny is a decision
736
+ (`allowed: false`, `reasonCode`), not an error. `createAuthzRequester(channel, options)` takes an
737
+ existing amqplib channel instead.
738
+
739
+ The AMQP authorization requester requires an AXIAM server of 1.68 or later (contract 1.68). Such a
740
+ server signs every authorization response with the tenant's AMQP subkey and answers on the
741
+ requester's private `reply_to` queue. A server older than 1.68 ignores `reply_to` and answers,
742
+ unsigned, only on the shared `axiam.authz.response` queue, which this requester never reads:
743
+ against it every check times out. There is no option to accept unsigned responses (CONTRACT 1.69
744
+ §8): no AXIAM server sends one to a reply queue, so an unsigned response can only have been
745
+ published by someone else, and it is discarded and logged. During a rolling upgrade from a pre-1.68
746
+ server, use REST or gRPC authorization until every replica runs 1.68 or later.
747
+
748
+ Every discarded answer logs one warning on `axiam_sdk.security` carrying `timestamp`, `exchange`
749
+ (`""` for the default exchange), `routingKey` (the requester's reply queue), `tenantId` (the
750
+ requester's own tenant, never the one the answer claims) and `reason`; the event never carries a
751
+ signature value, a `nonce` or any member read from the discarded body.
752
+
753
+ `AuthzResponseVerifier` is the verification step on its own, for an application that publishes its
754
+ requests itself. A broker confirm of the publish still says nothing about AXIAM having decided
755
+ (§8, minimal profile).
756
+
671
757
  #### Transport security (§8b)
672
758
 
673
759
  `consume()` and `reactorServe()` both require `amqps://` and enforce it before
@@ -922,6 +1008,7 @@ import {
922
1008
  fromParam,
923
1009
  requireAccess,
924
1010
  requireRole,
1011
+ requireScope,
925
1012
  type AuthzVerifiableSession,
926
1013
  } from 'axiam-sdk/middleware';
927
1014
 
@@ -941,9 +1028,24 @@ app.get('/documents/:id', requireAccess(authzSession, 'read', fromParam('id')),
941
1028
  });
942
1029
 
943
1030
  // Local-only (no server round-trip) role check — NOT a substitute for requireAccess.
1031
+ // Reads ONLY the token's `roles` claim (contract 1.68): request the `roles` scope.
944
1032
  app.get('/admin', requireRole(session, 'admin'), (_req, res) => res.json({ ok: true }));
1033
+
1034
+ // OAuth2 scope check — what the client was granted, not what the user holds.
1035
+ app.get('/reports', requireScope(session, 'reports:read'), (_req, res) => res.json({ ok: true }));
945
1036
  ```
946
1037
 
1038
+ **`requireRole` needs the `roles` scope (contract 1.68, §11.2 rule 11).** It reads the verified
1039
+ token's `roles` claim and nothing else, and a token without one is refused `403`. The server
1040
+ emits `roles` — the subject's global role names in the tenant, direct or through groups — only
1041
+ when the client requested **and is registered for** the `roles` scope, so add `roles` to the
1042
+ `scope` you pass to `oidcBegin`/`oidcPar`/the device and CIBA flows and to the client's
1043
+ registered scopes. Until then every `requireRole` route answers `403`. The claim is a snapshot
1044
+ taken when the token was minted (stale for at most one access-token lifetime); `requireAccess`
1045
+ evaluates live. Before 1.4.0 `requireRole` matched OAuth2 **scopes** (N15) — a route that relied
1046
+ on that should use `requireScope`. The same holds for `requireRoleHook`/`@RequireRole`, and
1047
+ `requireScopeHook`/`@RequireScope` are the Fastify and NestJS scope helpers.
1048
+
947
1049
  The Fastify equivalents are `requireAuthHook`/`requireAccessHook`/`requireRoleHook`, each
948
1050
  returning a plain `preHandler` function:
949
1051
 
@@ -1188,7 +1290,8 @@ console.log(tokens.idClaims?.sub); // validated ID-token subject
1188
1290
 
1189
1291
  `MemoryOidcStateStore` is an optional, opt-in reference store for that bookkeeping (10-minute
1190
1292
  TTL, single-use `consume(state)` — mirroring the server's own `federation_login_state`
1191
- semantics). It is single-process; use a shared store (Redis, a database) behind a load
1293
+ semantics — and, since 1.4.0, at most `OIDC_STATE_MAX_ENTRIES` (10 000) entries, the oldest
1294
+ evicted first; the second constructor argument lowers it). It is single-process; use a shared store (Redis, a database) behind a load
1192
1295
  balancer by implementing `OidcStateStore` yourself. The core operations never require one.
1193
1296
 
1194
1297
  ### Framework glue
@@ -1202,8 +1305,8 @@ const { login, callback } = oidcLoginHandlers({
1202
1305
  redirectUri: 'https://app.example.com/auth/callback',
1203
1306
  scope: 'openid profile email',
1204
1307
  // Establishing YOUR app session is your decision — the SDK validates the login
1205
- // and hands you the token set.
1206
- onSuccess: (tokens) => establishMySession(String(tokens.idClaims?.sub)),
1308
+ // and hands you the token set, the consumed entry and the request.
1309
+ onSuccess: (tokens, _entry, req) => establishMySession(req, String(tokens.idClaims?.sub)),
1207
1310
  });
1208
1311
 
1209
1312
  app.get('/auth/login', login); // 302 -> AXIAM /oauth2/authorize
@@ -1216,10 +1319,21 @@ core, so they cannot drift. Failure mapping is identical: `400` malformed callba
1216
1319
  authentication failure (unknown/expired/replayed state, IdP error, ID-token failure, OAuth2
1217
1320
  protocol error), `503` when AXIAM is unreachable — never a silent success.
1218
1321
 
1219
- The login handler reads an optional `?returnTo=` and stores it with the login state.
1220
- **Validate or allowlist that value in your application** if you accept it from user input —
1221
- an unchecked redirect target is an open-redirect vector, and the SDK cannot know which
1222
- destinations your app considers safe.
1322
+ **Browser binding (contract 1.68, §12.8; C7).** The login route sets an
1323
+ `__Host-axiam_oidc_bind` cookie (`HttpOnly; Secure; SameSite=Lax; Path=/`, ten minutes) and the
1324
+ callback completes only for the browser presenting it: a callback link replayed into another
1325
+ browser — login CSRF — gets the uniform `401`, the code is never exchanged and `onSuccess` never
1326
+ runs. Serve both routes over HTTPS; for plain-HTTP development on `localhost`, `127.0.0.1` or
1327
+ `[::1]` the cookie is `axiam_oidc_bind` without `Secure`. A custom `OidcStateStore` must persist
1328
+ `bindingDigest`. Two sign-ins started at once in one browser: the later one wins. Design notes:
1329
+ [`docs/login-glue-binding.md`](./docs/login-glue-binding.md).
1330
+
1331
+ **`returnTo` (§12.8 rule 3; C6).** The login handler reads an optional `?returnTo=` and stores it
1332
+ only when it is a same-origin relative path — a single leading `/`, not `//` or `/\`, no
1333
+ backslash and no control character — and checks it again before redirecting. Anything else is
1334
+ dropped and the callback falls back to `successRedirect` or the JSON summary. To allow, say, your
1335
+ other origins, pass `allowReturnTo: (value) => myAllowlist.has(value)`; it is consulted only for
1336
+ values the default rule refuses.
1223
1337
 
1224
1338
  ### ID-token validation (always on)
1225
1339
 
@@ -2949,6 +3063,8 @@ try {
2949
3063
  explicit accessor (CONTRACT.md §7).
2950
3064
  - Strict TLS verification is always on; the only server-trust escape hatch is the
2951
3065
  constructor's `customCa` option for self-signed development environments (CONTRACT.md §6).
3066
+ The Node JWKS fetch behind `verifyAccessToken` / `verifyIdToken` honours it too, and presents
3067
+ the client identity only to the client's own origin, never to a `jwks_uri` on another host.
2952
3068
  - Optional mutual TLS (mTLS): a PEM `clientCert`/`clientKey` client identity (Node only) is
2953
3069
  presented on both REST and gRPC without ever relaxing server verification (CONTRACT.md §6.1).
2954
3070
  - AMQP messages are HMAC-SHA256 verified before your handler ever sees them; verification