axiam-sdk 1.0.0-beta17 → 1.0.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 (66) hide show
  1. package/README.md +320 -24
  2. package/dist/amqp/index.d.cts +1 -1
  3. package/dist/amqp/index.d.ts +1 -1
  4. package/dist/amqp/index.js +6 -1
  5. package/dist/amqp/index.js.map +1 -1
  6. package/dist/amqp/index.mjs +6 -1
  7. package/dist/amqp/index.mjs.map +1 -1
  8. package/dist/{authzCore-BpXRhTLF.d.cts → authzCore-BQfX9qxN.d.cts} +1 -1
  9. package/dist/{authzCore-BxCr9i1y.d.ts → authzCore-BlSHwGnW.d.ts} +1 -1
  10. package/dist/browser/index.d.cts +3 -3
  11. package/dist/browser/index.d.ts +3 -3
  12. package/dist/{client-CX7MwFct.d.ts → client-0WJkblDE.d.ts} +2156 -95
  13. package/dist/{client-D3BOv0PD.d.cts → client-yD0eMwHQ.d.cts} +2156 -95
  14. package/dist/{cookieJar-Uh-6shG1.d.cts → cookieJar-CTD5jOmd.d.cts} +3 -3
  15. package/dist/{cookieJar-B4bMYc7_.d.ts → cookieJar-hWRmZkhe.d.ts} +3 -3
  16. package/dist/errors-CmBvsxV0.d.ts +79 -0
  17. package/dist/errors-DMIlw2lN.d.cts +101 -0
  18. package/dist/errors-DMIlw2lN.d.ts +101 -0
  19. package/dist/errors-m0Tue_pE.d.cts +79 -0
  20. package/dist/grpc/index.d.cts +7 -7
  21. package/dist/grpc/index.d.ts +7 -7
  22. package/dist/grpc/index.js +1456 -92
  23. package/dist/grpc/index.js.map +1 -1
  24. package/dist/grpc/index.mjs +1456 -92
  25. package/dist/grpc/index.mjs.map +1 -1
  26. package/dist/index.d.cts +6 -5
  27. package/dist/index.d.ts +6 -5
  28. package/dist/index.js +1560 -92
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +1529 -93
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/{jwks-DmERws3k.d.cts → jwks-BR55d7-Z.d.cts} +1 -1
  33. package/dist/{jwks-DmERws3k.d.ts → jwks-BR55d7-Z.d.ts} +1 -1
  34. package/dist/middleware/index.d.cts +11 -9
  35. package/dist/middleware/index.d.ts +11 -9
  36. package/dist/middleware/index.js +565 -21
  37. package/dist/middleware/index.js.map +1 -1
  38. package/dist/middleware/index.mjs +564 -23
  39. package/dist/middleware/index.mjs.map +1 -1
  40. package/dist/nestjs/index.d.cts +2 -2
  41. package/dist/nestjs/index.d.ts +2 -2
  42. package/dist/nestjs/index.js +6 -1
  43. package/dist/nestjs/index.js.map +1 -1
  44. package/dist/nestjs/index.mjs +6 -1
  45. package/dist/nestjs/index.mjs.map +1 -1
  46. package/dist/node/index.d.cts +307 -7
  47. package/dist/node/index.d.ts +307 -7
  48. package/dist/node/index.js +2447 -101
  49. package/dist/node/index.js.map +1 -1
  50. package/dist/node/index.mjs +2434 -103
  51. package/dist/node/index.mjs.map +1 -1
  52. package/dist/{oidcState-D9o_JxmM.d.ts → oidcState-DOSCgnMG.d.ts} +382 -9
  53. package/dist/{oidcState-E8Z5dXgQ.d.cts → oidcState-mQLVn3-A.d.cts} +382 -9
  54. package/dist/rest/index.d.cts +78 -11
  55. package/dist/rest/index.d.ts +78 -11
  56. package/dist/rest/index.js +1560 -92
  57. package/dist/rest/index.js.map +1 -1
  58. package/dist/rest/index.mjs +1529 -93
  59. package/dist/rest/index.mjs.map +1 -1
  60. package/dist/{session-Bsn9t50R.d.cts → session-BmjEMowX.d.cts} +1 -1
  61. package/dist/{session-BuqKS5nx.d.ts → session-CeG6P9GO.d.ts} +1 -1
  62. package/dist/{telemetry-DrGqL4kb.d.cts → telemetry--0DwnNjV.d.cts} +24 -2
  63. package/dist/{telemetry-DrGqL4kb.d.ts → telemetry--0DwnNjV.d.ts} +24 -2
  64. package/package.json +6 -3
  65. package/dist/errors-CxqAZsex.d.cts +0 -168
  66. package/dist/errors-CxqAZsex.d.ts +0 -168
package/README.md CHANGED
@@ -1,13 +1,8 @@
1
1
  # axiam-sdk (TypeScript/JavaScript)
2
2
 
3
- <!-- Track the CURRENT channel's dist-tag, not `latest`: releases are prereleases and
4
- the publish job keeps those off `latest` (see "Release / versioning"), so a plain
5
- `npm/v/axiam-sdk` badge reports whatever was last published to `latest` — today
6
- 1.0.0-alpha28, dozens of releases stale. Move `beta` below to `rc`, then drop it
7
- entirely, as the channel advances. -->
8
3
  [![CI](https://github.com/ilpanich/axiam-typescript-sdk/actions/workflows/sdk-ci-typescript.yml/badge.svg?branch=main)](https://github.com/ilpanich/axiam-typescript-sdk/actions/workflows/sdk-ci-typescript.yml)
9
4
  [![Coverage Status](https://coveralls.io/repos/github/ilpanich/axiam-typescript-sdk/badge.svg?branch=main)](https://coveralls.io/github/ilpanich/axiam-typescript-sdk?branch=main)
10
- [![npm](https://img.shields.io/npm/v/axiam-sdk/beta?label=npm%20beta)](https://www.npmjs.com/package/axiam-sdk)
5
+ [![npm](https://img.shields.io/npm/v/axiam-sdk)](https://www.npmjs.com/package/axiam-sdk)
11
6
  [![Docs](https://img.shields.io/badge/docs-TypeDoc-blue.svg)](https://ilpanich.github.io/axiam-typescript-sdk/)
12
7
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
13
8
 
@@ -18,19 +13,80 @@ Official TypeScript/JavaScript client SDK for [AXIAM](https://github.com/ilpanic
18
13
  ## Package identity
19
14
 
20
15
  - **npm package:** `axiam-sdk`
21
- - **Registry:** [npmjs.com/package/axiam-sdk](https://www.npmjs.com/package/axiam-sdk) — published as prereleases, under the `alpha`/`beta` dist-tags
16
+ - **Registry:** [npmjs.com/package/axiam-sdk](https://www.npmjs.com/package/axiam-sdk) — stable releases on the `latest` dist-tag, following [semantic versioning](https://semver.org/)
22
17
  - **Source:** [github.com/ilpanich/axiam-typescript-sdk](https://github.com/ilpanich/axiam-typescript-sdk)
23
18
  - **License:** Apache-2.0
24
19
  - **Node:** `>=22` — see [Supported Node versions](#supported-node-versions)
25
20
 
26
21
  ## Contract conformance
27
22
 
28
- This SDK conforms to **contract 1.52**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
29
- §20, §21, §22, §23, §24, §25, §26, §27, §28 (including §6.1 mTLS client certificates, the
23
+ This SDK conforms to **contract 1.60**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
24
+ §20, §21, §22, §23, §24, §25, §26, §27, §28, §28.12, §29, §30, §31, §32 and §33, with §32.7 and
25
+ §33.2 signed (including §6.1 mTLS client certificates, the
30
26
  §10.1 minimum local-verification set, the §12 OIDC/SSO relying-party helpers, and the §13
31
27
  `verifyWebhook` signature verifier). §12 is implemented in full at its 1.38 shape: all
32
28
  **thirteen** operations, including the four public "Sign in with X" entry points.
33
29
 
30
+ ### Contract 1.60 — the answers to #588 and the release wave (§34.4)
31
+
32
+ Contract 1.60 changes no route; it answers the questions the 1.59 ports raised (§34.4
33
+ A1 – B9, C-1 – C-16) and adds the 1.0.0 release wave's members. Every §34.4 row assigned to
34
+ TypeScript:
35
+
36
+ | Row | Rule | What this SDK does |
37
+ |---|---|---|
38
+ | A3 | §32.7 step 4, P6 | A failed cold-cache fill and a failed expiry refresh of the SSF key cache count toward the once-a-minute limit; the cache expires after ten minutes (`JWKS_CACHE_MAX_AGE_MS`). |
39
+ | B1, C-1 | §32.7 step 9, P3, P4 | A replay store that cannot answer (a throw, a rejection, any answer but `true`/`false`) gives no verdict: `verifySet` raises `NetworkError`, the store's failure on `cause`, and `poll` leaves the SET unjudged. A `SetRefusedError` thrown from inside a store is wrapped too, so no store failure carries a reason code. |
40
+ | C-3, C-4 | P1, §19.1 | After the replay store fails in a `poll` batch it is not asked again: every later SET that verifies is unjudged, one that fails verification is still refused. A `poll` that returns with SETs unjudged emits the §19 `ssfUnjudged` event (count and category, `key_fetch` or `replay_store`; no `jti`). |
41
+ | §15.2 rule 9 | §15 | The `actor_token` is the same client's `client_credentials` token. |
42
+ | §8 minimal profile | §8 | A broker confirm is not evidence that AXIAM saw a message. |
43
+ | §31 `expected_updated_at` | §31.3 rule 4 | On `ScimTargetInput`, sent exactly as given and only when set; `scimTargetInputFrom` carries the read's `updated_at`, so a read-modify-write of a target written since is `409`. |
44
+ | §27.15 `window_minutes` | §27.15 note 1 | On the `notificationRules` models, sent as given (never clamped) and only when set. |
45
+ | §27.15 `allow_sha1_signatures`, `idp_metadata_signing_cert_pem` | notes 6, 7 | On the three federation configuration models, sent only when set; a response without `allow_sha1_signatures` (a server before 1.0.0) reads `false`. |
46
+ | §27.15 note 8 | §27.4 rule 5 | `federation.updateConfig`: each of the ten nullable members of `UpdateFederationConfigRequest` is cleared by `null` and left unchanged when `undefined`, and the body carries exactly the members you set. |
47
+ | §12.1 refresh `scope` | §12.1 | An `oidcRefresh` result's `scope` is the refresh response's, which may be narrower than the grant's. |
48
+ | §21.5 discovery | §21.5, §12.1 | `OidcConfiguration` carries the four revocation and introspection auth members, all optional; a document without them decodes. |
49
+
50
+ ### Contract 1.59 — the Phase 23 ports review (§34)
51
+
52
+ Contract 1.59 changes no wire shape; it clarifies §28.12 and §29 – §33 (§34.2 P1 – P12) and
53
+ lists what the review of this SDK found (follow-up F-59-02). What changed here:
54
+
55
+ | Row | Rule | What changed |
56
+ |---|---|---|
57
+ | R-18 | §30.5, §31.5, §32.5, §7 rule 1 | A management write that fails with a `5xx` or a transport error no longer carries its request — and so its `bind_secret`, `credential`, `authorization_header`, or §27.5 secret — in `NetworkError.cause`: the cause is rebuilt from an allow-list of diagnostics. |
58
+ | R-1 | §32.7, P1 | `SsfReceiver.poll` returns the SETs it judged and leaves one it could not judge unrecorded, listed in `unjudged`; it never keeps a `jti` it does not return. |
59
+ | R-7 | §32.7, P7 | The SSF section says `poll` is retried on `408` and `429`, as it always was. |
60
+ | R-20 | §29.5, §31.2, P12.1 | Every `directory`, `saml`, `scimTargets` and `ssf` response keeps only the members its type declares, at every depth; an unknown union arm keeps only its `type`. |
61
+ | R-23 | §28.12.2 rule 4, P12.4 | `updateClientRegistration` sends no list the read lacked, and a list of an unexpected shape as read; `redirect_uris`, `grant_types` and `response_types` are optional on `ClientRegistration`. |
62
+ | R-28 | §27.4 rule 5, §29.2, §21.3.1 | Generated docs no longer call every replacement body all-required or every all-optional type sparse; seven mTLS aliases, not six. |
63
+ | §33.8 t8 | §33.7 rule 5, P8 | `cibaPoll` retries a `5xx` whatever its body, `500 {"error":"server_error"}` included. |
64
+
65
+ The choice P1 leaves open: `poll` takes the second form — return what was judged, leave the
66
+ unjudged unrecorded and list their `jti`s — and, when it accepted nothing, records nothing and
67
+ throws the failure (the first form's outcome).
68
+
69
+ ### Contracts 1.53 – 1.58
70
+
71
+ | Section | What ships | Where |
72
+ |---|---|---|
73
+ | §28.12 RFC 7592 client configuration (1.53) | `readClientRegistration`, `updateClientRegistration`, `deleteClientRegistration`, `ClientRegistration` | `AxiamClient` (see [below](#rfc-7592-client-configuration-contract-153-2812)) |
74
+ | §30 directory configuration (1.54) | the `directory` namespace, explicit-`null` sparse update, `setDirectoryConfigFrom` | `client.directory` |
75
+ | §29 SAML service-provider registration (1.55) | the `saml` namespace, `parseSpMetadataFromUrl` / `FromXml`, `samlServiceProviderInputFrom` | `client.saml` |
76
+ | §32 SSF stream registration (1.56) | the `ssf` namespace, `ssfStreamInputFrom` | `client.ssf` |
77
+ | §32.7 SSF receiver helper (1.56) | `SsfReceiver.verifySet` / `.poll` | `axiam-sdk/node` |
78
+ | §31 outbound SCIM targets (1.57) | the `scim_targets` namespace, `scimTargetInputFrom` | `client.scimTargets` |
79
+ | §33 CIBA, and §33.2's signed form (1.58) | `cibaInitiate`, `cibaPoll`, `cibaAwait`, `cibaHandlePing`, `CibaRequestSigner` (PS256, ES256, EdDSA) | `OidcClient` (`axiam-sdk/node`) |
80
+ | §21.3.1 vector A amended (1.58) | `mtls_endpoint_aliases.backchannel_authentication_endpoint`, the seventh alias | `OidcConfiguration` |
81
+
82
+ **Not shipped, and why:** nothing in these sections is declined. Two placement notes:
83
+ `SsfReceiver` is Node-only (it verifies Ed25519 signatures with `node:crypto`), and the CIBA
84
+ helpers live on the Node-only `OidcClient` with the rest of §12, as §33.6 asks ("the handle
85
+ that already carries `oidc_exchange` and `device_authorize`"). A CIBA client authenticates
86
+ by `clientSecret` (`client_secret_post`) or by the session's §6.1 client certificate
87
+ (`tls_client_auth`); this SDK has no `private_key_jwt` client authentication (§21.8 is
88
+ informative), so a CIBA client registered for `private_key_jwt` cannot use these helpers.
89
+
34
90
  ### Contract 1.51 — the dogfooding remediation
35
91
 
36
92
  | Item | Status |
@@ -53,7 +109,7 @@ browser bundle pulls in no Node-only code. §12.2 forbids splitting them across
53
109
  the four operations contract 1.38 adds are on `OidcClient` too, with the nine that preceded
54
110
  them, even though three of them need no Node-only code at all.
55
111
 
56
- §27 is implemented **in full**, both halves: the 162-operation imperative surface *and*
112
+ §27 is implemented **in full**, both halves: the 190-operation imperative surface *and*
57
113
  the §27.6 declarative manifest with its §27.7 `defineManifest` and decorator forms. The
58
114
  contract asks an SDK that ships only one half to say which; this one ships both.
59
115
 
@@ -62,8 +118,8 @@ Express middleware and the Fastify plugin — with all three operations, the
62
118
  `resourceMetadataUrl` guard option and §28.9's five required tests. This SDK is §28.10's
63
119
  reference implementation: it lands first and the ten ports are read against it.
64
120
 
65
- §12.7, §14, §15, §17, §19, §20, §21, §22, §23, §24, §25, §26, §27 and §28 are named rather
66
- than folded into the range because they landed after this SDK already claimed §1–§13:
121
+ §12.7, §14, §15, §17, §19, §20, §21, §22, §23, §24, §25, §26, §27, §28, §28.12, §29, §30,
122
+ §31, §32, §32.7, §33 and §33.2 signed are named rather than folded into the range because they landed after this SDK already claimed §1–§13:
67
123
  widening the range silently would turn a statement that was true when written into a
68
124
  different claim without anyone editing it.
69
125
 
@@ -125,13 +181,12 @@ See [`CONTRACT.md`](./CONTRACT.md) for the full cross-language behavioral contra
125
181
  ## Install
126
182
 
127
183
  ```bash
128
- npm install axiam-sdk@beta
184
+ npm install axiam-sdk@^1.0.0
129
185
  ```
130
186
 
131
- Every release so far is a prerelease, and the publish job files each one under its
132
- channel's dist-tag (`beta` today) rather than `latest` — so name the channel, or pin an
133
- exact version. A bare `npm install axiam-sdk` resolves `latest`, which no prerelease
134
- moves.
187
+ From 1.0.0 the SDK is stable and follows semantic versioning: a breaking change to its
188
+ public API waits for the next major version. Releases are published on npm's `latest`
189
+ dist-tag, so a bare `npm install axiam-sdk` resolves the newest one.
135
190
 
136
191
  ## Supported Node versions
137
192
 
@@ -303,6 +358,7 @@ name wherever the document publishes one:
303
358
  | `revoke` | `revocation_endpoint` |
304
359
  | `deviceAuthorize` | `device_authorization_endpoint` |
305
360
  | `oidcPar` | `pushed_authorization_request_endpoint` |
361
+ | `cibaInitiate` | `backchannel_authentication_endpoint` |
306
362
 
307
363
  Three things this deliberately does **not** do:
308
364
 
@@ -310,8 +366,11 @@ Three things this deliberately does **not** do:
310
366
  terminates mutual TLS on the issuer's own host", so the conventional endpoints keep
311
367
  being used. A deployment running `client_auth = optional` on one listener serves both
312
368
  populations there and correctly publishes nothing.
313
- - **No alias is ever synthesised.** Only the six endpoints RFC 8705 §5 lists can be
314
- aliased — never `authorization_endpoint`, `end_session_endpoint` or `jwks_uri`. The
369
+ - **No alias is ever synthesised.** Only the seven endpoints CONTRACT.md §21.3.1's vector
370
+ aliases can be — `token_endpoint`, `introspection_endpoint`, `revocation_endpoint`,
371
+ `device_authorization_endpoint`, `pushed_authorization_request_endpoint`,
372
+ `userinfo_endpoint` and CIBA's `backchannel_authentication_endpoint` — never
373
+ `authorization_endpoint`, `end_session_endpoint` or `jwks_uri`. The
315
374
  first two are front-channel and the third is public key material; sending a browser to
316
375
  an mTLS host raises a native certificate-chooser dialog most users cannot answer.
317
376
  - **`issuer` does not move.** It is an identifier, not an endpoint. §12.4 rule 3 still
@@ -541,6 +600,16 @@ into production, where it turns TLS into an expensive no-op against precisely
541
600
  the attacker TLS exists to stop. `caCert` covers the legitimate reason people
542
601
  reach for one.
543
602
 
603
+ #### Minimal profile (contract 1.60, §8)
604
+
605
+ A server running in the **minimal profile** (`AXIAM__AMQP__ENABLED=false`) reads no AMQP
606
+ queue: it does not consume `axiam.authz.request` or `axiam.audit.events`, whatever a broker
607
+ holds. **A broker confirm is not evidence that AXIAM saw a message** — a publisher confirm, or
608
+ the broker's `basic.ack` of a publish, means only that the broker accepted it, never that
609
+ AXIAM decided the request or recorded the event. This SDK does not treat one as such. Against
610
+ a minimal-profile server use REST or gRPC; `GET /health` reports `profile: minimal` and lists
611
+ `amqp_authz` and `amqp_audit_ingestion` under `unavailable`.
612
+
544
613
  ### Node — reactors, AMQP extension actors (`axiam-sdk/amqp`, CONTRACT.md §22)
545
614
 
546
615
  A **reactor** is an external process that subscribes to named hook events on the AMQP bus and
@@ -1605,9 +1674,13 @@ RFC 8693 — a service holding a user's token exchanging it for a *narrower* one
1605
1674
  calling the next service.
1606
1675
 
1607
1676
  ```ts
1677
+ // Delegation: the actor token is THIS client's own client_credentials token (§15.2 rule 9).
1678
+ const actor = await oidc.loginClientCredentials();
1679
+
1608
1680
  const exchanged = await oidc.tokenExchange({
1609
1681
  subjectToken: new Sensitive(userToken),
1610
1682
  subjectTokenType: ACCESS_TOKEN_TYPE, // required (§15.1), no default
1683
+ actorToken: actor.accessToken, // omit it and you ask for impersonation instead
1611
1684
  scopes: ['orders:read'],
1612
1685
  audience: 'orders-service',
1613
1686
  });
@@ -1617,6 +1690,14 @@ Most of what this method does is refuse to be helpful, and each refusal is delib
1617
1690
 
1618
1691
  - **No default `actorToken`.** Omitting it asks for *impersonation*; the SDK will not
1619
1692
  quietly substitute the client's own session token and turn that into a delegation.
1693
+ - **The actor token must have been issued to the exchanging client** (contract 1.60,
1694
+ §15.2 rule 9). The usual actor is the exchanging client's own `client_credentials` token
1695
+ (`loginClientCredentials()` above): its `sub` — and so the issued token's `act.sub` — is
1696
+ the client's `client_id`. One issued to another client, a console sign-in or a service
1697
+ account is answered `400 invalid_request` (`actor_token was not issued to the exchanging
1698
+ client`), which the SDK surfaces unchanged: no retry, no dropping the actor token to
1699
+ impersonate instead, no substituting a token of its own. You obtain and pass the actor
1700
+ token; the SDK supplies none.
1620
1701
  - **No auto-narrowing after `invalid_scope`.** The server refuses rather than silently
1621
1702
  narrowing precisely so the caller finds out here.
1622
1703
  - **No refresh token, ever** — `ExchangedToken` has no such field, so there is nothing to
@@ -2099,6 +2180,219 @@ just failed to authenticate, so both must stay readable. The corollary is the on
2099
2180
  matters — **no part of the presented credential reaches either of them**, in any parameter,
2100
2181
  any header, any body or any log line the guard writes on the 401 path.
2101
2182
 
2183
+ ## RFC 7592 client configuration (contract 1.53, §28.12)
2184
+
2185
+ A client that registered itself through `POST /oauth2/register` (RFC 7591) received, once,
2186
+ a `registration_client_uri` and a `registration_access_token`. With them it reads, replaces
2187
+ and deletes **its own** registration:
2188
+
2189
+ ```ts
2190
+ const token = new Sensitive(storedRegistrationToken);
2191
+ const current = await client.readClientRegistration(registrationClientUri, token);
2192
+
2193
+ // An update is a FULL replacement: start from the read, change what you mean.
2194
+ current.client_name = 'Agent v2';
2195
+ const updated = await client.updateClientRegistration(registrationClientUri, token, current);
2196
+ await persist(updated.registration_access_token!); // the ONLY valid token from now on
2197
+
2198
+ await client.deleteClientRegistration(registrationClientUri, updated.registration_access_token!);
2199
+ ```
2200
+
2201
+ - The URI is used **verbatim** (its `tenant_id` query included), and only at this client's
2202
+ configured origin: another scheme, host or port — or `http` unless `baseUrl` is `http` on a
2203
+ loopback host — is refused locally with a `ValidationError` before any request.
2204
+ - The token travels in `Authorization: Bearer` only, on a session-free transport: no SDK
2205
+ cookie, access token or CSRF header rides along, redirects are not followed, and a `401`
2206
+ never refreshes the SDK's session. (A browser follows redirects itself; use these
2207
+ server-side.)
2208
+ - `ClientRegistration` keeps every member it does not model in `extra`, so a read passed to
2209
+ an update round-trips them; the SDK drops `registration_access_token`,
2210
+ `registration_client_uri`, `client_secret_expires_at`, `client_id_issued_at` and
2211
+ `client_secret` from the body and sets `client_id`. Both secrets are `Sensitive`.
2212
+ - **Update and delete are never retried**; persist the rotated token before anything else.
2213
+ The read follows §16, but never retries a `4xx` other than `408`/`429`.
2214
+ - A body with `error` is an `OAuthProtocolError` at any status (`invalid_token`,
2215
+ `invalid_client_metadata`, …); a `204` on delete resolves.
2216
+
2217
+ ## Directory, SAML, SSF and SCIM targets (§29 – §32)
2218
+
2219
+ Four management namespaces, generated like every other (§27), with the call-site rules the
2220
+ contract makes an SDK repeat in their TSDoc. Every write is issued once; reads retry.
2221
+
2222
+ ```ts
2223
+ import { Sensitive, setDirectoryConfigFrom, parseSpMetadataFromUrl,
2224
+ samlServiceProviderInputFrom, ssfStreamInputFrom, scimTargetInputFrom } from 'axiam-sdk';
2225
+
2226
+ // §30 directory — a sparse update: undefined keeps, null CLEARS.
2227
+ await client.directory.update({ group_filter: null }); // sends {"group_filter":null}
2228
+ await client.directory.update({ enabled: false }); // sends {"enabled":false}
2229
+ // Moving the connection (url, start_tls, bind_dn, trust_anchors_pem) requires the secret
2230
+ // again — the SDK holds no copy (§30.3 rule 2).
2231
+ await client.directory.update({ url: 'ldaps://dc2.corp.example', bind_secret: new Sensitive(secret) });
2232
+ // set() is a replacement: start from a read (bind_secret absent keeps the stored one).
2233
+ const config = setDirectoryConfigFrom(await client.directory.get());
2234
+ await client.directory.set({ ...config, sync_interval_secs: 900 });
2235
+
2236
+ // §29 SAML — parse a draft (stores nothing), review it, create from it.
2237
+ const draft = await client.saml.parseSpMetadata(parseSpMetadataFromUrl('https://sp.example/metadata'));
2238
+ const sp = await client.saml.createServiceProvider(draft.service_provider);
2239
+ const body = samlServiceProviderInputFrom(await client.saml.getServiceProvider(sp.id));
2240
+ await client.saml.updateServiceProvider(sp.id, { ...body, display_name: 'Payroll (EU)' });
2241
+
2242
+ // §32 SSF and §31 SCIM targets — read-modify-write; the secret is left absent (kept).
2243
+ const stream = ssfStreamInputFrom(await client.ssf.getStream(streamId));
2244
+ await client.ssf.updateStream(streamId, { ...stream, description: 'rotated' });
2245
+ const target = scimTargetInputFrom(await client.scimTargets.get(targetId));
2246
+ await client.scimTargets.update(targetId, { ...target, push_groups: true });
2247
+ ```
2248
+
2249
+ - `bind_secret`, `authorization_header` and `credential` are `Sensitive` and write-only. A
2250
+ response that (wrongly) carries one of them — or `private_key_pem` on a SAML credential —
2251
+ has it dropped before it reaches you, so it surfaces in no rendering.
2252
+ - `parseSpMetadata` needs **exactly one** of `metadata_url` / `metadata_xml`: both or
2253
+ neither is a local `ValidationError`.
2254
+ - Enums and the `ScimTargetAuth` / `ScimTargetScope` unions are open: an unknown value
2255
+ decodes. An unknown `auth.type` / `scope.type` is refused before it is sent back.
2256
+ - `getIdp` is never cached: readiness changes with every credential write.
2257
+
2258
+ ## SSF receiver (`axiam-sdk/node`, contract 1.56, §32.7)
2259
+
2260
+ For a relying party that **receives** AXIAM's Security Event Tokens. Node-only.
2261
+
2262
+ ```ts
2263
+ import { SsfReceiver, SetRefusedError, setErrFromReason, createOidcClient } from 'axiam-sdk/node';
2264
+
2265
+ const receiver = new SsfReceiver(client, {
2266
+ issuer: 'https://iam.example.com/t/<tenant-uuid>',
2267
+ audience: 'https://rp.example.com',
2268
+ jwksUri: 'https://iam.example.com/oauth2/jwks', // or discoveryUrl
2269
+ accessTokenProvider: async () =>
2270
+ (await oidc.loginClientCredentials({ scope: 'ssf.manage' })).accessToken,
2271
+ // replayWindowMs defaults to (and may not go below) seven days; replayStore is pluggable.
2272
+ });
2273
+
2274
+ // Push (RFC 8935): verify, then answer 202 — or 400 {"err": …} on a refusal.
2275
+ try {
2276
+ handle(await receiver.verifySet(rawBody));
2277
+ res.status(202).end();
2278
+ } catch (e) {
2279
+ if (e instanceof SetRefusedError) res.status(400).json(setErrFromReason(e.reason));
2280
+ else throw e; // a NetworkError: the JWKS could not be fetched — not a verdict on the SET
2281
+ }
2282
+
2283
+ // Poll (RFC 8936): acknowledge what you processed, refuse what failed, on the NEXT call.
2284
+ let ack: string[] = [];
2285
+ let setErrs = {};
2286
+ for (;;) {
2287
+ const { events, refused, moreAvailable } = await receiver.poll(streamId, { ack, setErrs });
2288
+ for (const event of events) await handle(event);
2289
+ // A `replayed` SET was accepted earlier: acknowledge it, do not report it (§34.2 P2).
2290
+ ack = [...events.map((e) => e.jti), ...refused.filter((r) => r.reason === 'replayed').map((r) => r.jti)];
2291
+ setErrs = Object.fromEntries(
2292
+ refused.filter((r) => r.reason !== 'replayed').map((r) => [r.jti, setErrFromReason(r.reason)]),
2293
+ );
2294
+ // `unjudged` SETs are neither: the transmitter offers them again.
2295
+ if (!moreAvailable) await sleep(1000);
2296
+ }
2297
+ ```
2298
+
2299
+ `verifySet` checks, in order: three base64url parts, `typ` `secevent+jwt`, `alg` `EdDSA`, the
2300
+ `kid` in the configured JWKS (one forced refetch on a miss, at most once a minute), the
2301
+ signature, `iss`, `aud`, the SET claim rules (no `exp`/`sub`; `jti`, `iat`, `sub_id`; one
2302
+ event) and replay. A refusal is a `SetRefusedError` (an `AuthError`) with a typed `reason`;
2303
+ `pushErrorCode` maps `malformed`, `invalid_type` and `replayed` to `invalid_request`, the
2304
+ others to themselves. **A SET that verifies has been recorded**: acknowledge it once
2305
+ processed, or a re-offer reads as `replayed`. **`poll` never keeps a `jti` it does not
2306
+ return** (contract 1.59, §34.2 P1): a SET it cannot judge — the JWKS or discovery fetch
2307
+ failed, or the replay store threw — is left unrecorded and listed by `jti` in `unjudged`
2308
+ (neither acknowledge nor refuse it; the transmitter offers it again), while the SETs judged
2309
+ in the same batch are returned as usual. When a poll accepts no SET at all it records
2310
+ nothing and throws that failure instead. Once the replay store fails in a batch it is not
2311
+ asked again for that batch: every later SET that verifies is unjudged as well, and `poll`
2312
+ emits the §19 `ssfUnjudged` telemetry event when it returns with any SET unjudged
2313
+ (contract 1.60). The default `MemoryReplayStore` is per process and
2314
+ **unbounded in count** — an entry leaves only when its window expires (§34.2 P4); a
2315
+ `ReplayStore` has three answers — `true` (not seen, now recorded), `false` (seen) and
2316
+ **cannot answer**, which is a throw or a rejection (contract 1.60, §34.2 P4). A store that
2317
+ cannot answer gives **no verdict**: `verifySet` raises a `NetworkError` with no reason code
2318
+ (it is never a `SetRefusedError`, and never read as `replayed`, which `poll` would have you
2319
+ acknowledge), and `poll` lists the SET in `unjudged`, records nothing for it and does not
2320
+ acknowledge it, so the transmitter offers it again. Never answer `false` for "I do not know";
2321
+ an answer that is neither `true` nor `false` is treated as cannot-answer. The key set is
2322
+ cached for ten minutes (`JWKS_CACHE_MAX_AGE_MS`; contract 1.60 requires no more than ten), so a key
2323
+ the transmitter removed stops verifying; filling an empty or expired cache is not a refetch,
2324
+ but a **failed** fetch counts toward the once-a-minute limit: after a failed fill a SET inside
2325
+ the minute makes no fetch and is left unjudged (§34.2 P6). A SET refused as `replayed` was accepted by this
2326
+ receiver on an earlier poll: acknowledge it in `ack` rather than reporting it in `setErrs`
2327
+ (§34.2 P2). `poll` never acknowledges anything itself, is not retried on a `4xx` other than
2328
+ `408` and `429` — which §16 retries, as it does a transport failure and a `5xx` — and sends
2329
+ no SDK cookie or session token.
2330
+
2331
+ ## CIBA (`axiam-sdk/node`, contract 1.58, §33)
2332
+
2333
+ Client-initiated backchannel authentication: ask AXIAM to authenticate a user **on another
2334
+ device**, then collect the tokens. On `OidcClient`; the client always authenticates, by
2335
+ `clientSecret` or a §6.1 client certificate.
2336
+
2337
+ ```ts
2338
+ import { createOidcClient, isAccessDenied, isExpiredToken, CibaRequestSigner } from 'axiam-sdk/node';
2339
+
2340
+ // Poll mode.
2341
+ const initiated = await oidc.cibaInitiate({
2342
+ scope: 'openid profile',
2343
+ loginHint: 'ada@example.com', // exactly one of loginHint / idTokenHint
2344
+ bindingMessage: 'W4SCT', // show the same code to your user
2345
+ });
2346
+ try {
2347
+ const tokens = await oidc.cibaAwait(initiated); // honours interval and slow_down; stops at expires_in
2348
+ } catch (e) {
2349
+ if (isAccessDenied(e)) { /* the user refused */ }
2350
+ else if (isExpiredToken(e)) { /* nobody answered in time */ }
2351
+ else throw e;
2352
+ }
2353
+ ```
2354
+
2355
+ **Ping mode** — AXIAM calls your notification endpoint; answer at once, then poll once:
2356
+
2357
+ ```ts
2358
+ const notificationToken = new Sensitive(randomBytes(32).toString('base64url'));
2359
+ const initiated = await oidc.cibaInitiate({
2360
+ scope: 'openid', loginHint: 'ada', delivery: { mode: 'ping', clientNotificationToken: notificationToken },
2361
+ });
2362
+
2363
+ app.post('/ciba/notify', express.raw({ type: '*/*' }), async (req, res) => {
2364
+ let authReqId;
2365
+ try {
2366
+ authReqId = oidc.cibaHandlePing(req.rawHeaders, req.body, notificationToken); // no I/O
2367
+ } catch {
2368
+ return res.status(401).end();
2369
+ }
2370
+ res.status(204).end(); // answer first: AXIAM retries a slow ping
2371
+ const tokens = await oidc.cibaPoll({ authReqId }); // the outcome: tokens, access_denied, expired_token
2372
+ });
2373
+ // No ping after expires_in / 2? Fall back to oidc.cibaAwait(initiated).
2374
+ ```
2375
+
2376
+ **Signed form** (a client registered with `backchannel_authentication_request_signing_alg`;
2377
+ required of a `fapi2` CIBA client):
2378
+
2379
+ ```ts
2380
+ const signer = await CibaRequestSigner.create('EdDSA', new Sensitive(privateKeyPkcs8Pem), 'key-1');
2381
+ await oidc.cibaInitiate({ scope: 'openid', loginHint: 'ada', bindingMessage: 'W4SCT', signer });
2382
+ // The form carries client authentication and `request` only; every member is inside the JWT.
2383
+ ```
2384
+
2385
+ - `cibaInitiate` is **never retried** — each accepted call may notify a person. A success
2386
+ proves nothing about the user: AXIAM answers an unknown, locked and real user alike.
2387
+ - `cibaPoll` surfaces every protocol answer as an `OAuthProtocolError` and retries only
2388
+ transport failures, `408`, a bodiless `429` and a `5xx` — whatever its body, so the server's
2389
+ own `500 {"error":"server_error"}` is retried and never ends `cibaAwait` (§34.2 P8). Store its tokens before anything else:
2390
+ a request is redeemed once. Neither helper adopts the tokens as the client's credential.
2391
+ - `authReqId`, `clientNotificationToken`, the signing key and the `request` JWT are
2392
+ `Sensitive` / never rendered. `CibaRequestSigner` supports PS256, ES256 and EdDSA, signs
2393
+ under exactly the algorithm given, and refuses a key that cannot (a probe signature).
2394
+ - `cibaAwait` takes an injectable `clock` (`{ now(), sleep(ms) }`) for tests.
2395
+
2102
2396
  ## Client quality-of-life (CONTRACT.md §16–§19)
2103
2397
 
2104
2398
  ### Retry policy (§16)
@@ -2161,7 +2455,9 @@ const client = new AxiamClient({
2161
2455
  - **Path templates, not URLs**, so a metric label cannot become a cardinality bomb.
2162
2456
 
2163
2457
  One `requestStart`/`requestEnd` pair is emitted **per attempt**, so you can count real wire
2164
- calls. See [`examples/telemetry-hook.ts`](examples/telemetry-hook.ts), including the
2458
+ calls. `SsfReceiver.poll` also emits `ssfUnjudged` when it returns leaving SETs unjudged
2459
+ (contract 1.60), one per failure category with a count, so an outage it cannot raise is
2460
+ still visible. See [`examples/telemetry-hook.ts`](examples/telemetry-hook.ts), including the
2165
2461
  OpenTelemetry mapping.
2166
2462
 
2167
2463
  ### Decision memo (§17) — opt-in, off by default
@@ -2196,7 +2492,7 @@ entries are keyed by subject rather than by session.
2196
2492
  Everything above assumes a populated tenant. `login` signs a user in,
2197
2493
  `checkAccess` asks about a resource, `verifyWebhook` checks a delivery signature — and
2198
2494
  none of them can create the user, declare the resource or register the webhook. The
2199
- management surface is the part that can: **160 operations across 24 namespaces**,
2495
+ management surface is the part that can: **190 operations across 28 namespaces**,
2200
2496
  generated from `management-registry.json`, which is the whole server API minus what other
2201
2497
  contract sections own and minus organization creation and deletion (§27.0 keeps those out
2202
2498
  of reach of a client library on purpose).
@@ -2209,8 +2505,8 @@ const role = await client.roles.get(roleId);
2209
2505
  await client.roles.assignToUser(roleId, { user_id: userId });
2210
2506
  ```
2211
2507
 
2212
- Operations hang off **namespace handles** rather than the client. Twenty namespaces have a
2213
- `list` and fourteen a `get`, so flattening them would need a disambiguating prefix invented
2508
+ Operations hang off **namespace handles** rather than the client. Nineteen namespaces have a
2509
+ `list` and nineteen a `get`, so flattening them would need a disambiguating prefix invented
2214
2510
  once per operation — and would bury the eight §1 methods most callers want under five times
2215
2511
  as many they do not. Acquiring a handle performs no I/O. `client.management.users` is the
2216
2512
  same handle as `client.users`, for call sites that read better with the namespace spelled
@@ -2307,7 +2603,7 @@ back.
2307
2603
 
2308
2604
  ### Declarative manifests (§27.6, §27.7)
2309
2605
 
2310
- Calling 160 operations one at a time is rarely what an application wants. What it does at
2606
+ Calling 190 operations one at a time is rarely what an application wants. What it does at
2311
2607
  start-up, in a migration, or in a test fixture is assert a shape:
2312
2608
 
2313
2609
  ```ts
@@ -1,7 +1,7 @@
1
1
  import { S as Sensitive } from '../sensitive-BC_s7Rrd.cjs';
2
2
  import { ConsumeMessage } from 'amqplib';
3
3
  import { ConnectionOptions } from 'node:tls';
4
- import { T as TelemetryHook, a as TelemetryDispatcher } from '../telemetry-DrGqL4kb.cjs';
4
+ import { T as TelemetryHook, a as TelemetryDispatcher } from '../telemetry--0DwnNjV.cjs';
5
5
 
6
6
  /**
7
7
  * Compute the hex-encoded HMAC-SHA256 of `payloadJson` using `key`.
@@ -1,7 +1,7 @@
1
1
  import { S as Sensitive } from '../sensitive-BC_s7Rrd.js';
2
2
  import { ConsumeMessage } from 'amqplib';
3
3
  import { ConnectionOptions } from 'node:tls';
4
- import { T as TelemetryHook, a as TelemetryDispatcher } from '../telemetry-DrGqL4kb.js';
4
+ import { T as TelemetryHook, a as TelemetryDispatcher } from '../telemetry--0DwnNjV.js';
5
5
 
6
6
  /**
7
7
  * Compute the hex-encoded HMAC-SHA256 of `payloadJson` using `key`.
@@ -15,7 +15,12 @@ var AxiamError = class extends Error {
15
15
  }
16
16
  };
17
17
  var NetworkError = class _NetworkError extends AxiamError {
18
- /** The underlying transport error, with every non-allowlisted response header redacted (§2, X-3). */
18
+ /**
19
+ * What is safe to keep of the underlying transport error: its name, message,
20
+ * code and status, and the response's status, body and allow-listed headers
21
+ * (§2, X-3). Never the request — its body or its headers — which may carry a
22
+ * write-only secret (contract 1.59 R-18).
23
+ */
19
24
  cause;
20
25
  constructor(message, cause) {
21
26
  super(message);