axiam-sdk 1.1.3 → 1.2.5

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/README.md +73 -3
  2. package/dist/amqp/index.js.map +1 -1
  3. package/dist/amqp/index.mjs.map +1 -1
  4. package/dist/browser/index.d.cts +1 -1
  5. package/dist/browser/index.d.ts +1 -1
  6. package/dist/{client-BGFn1VQh.d.cts → client-Bp7riC4k.d.cts} +147 -3
  7. package/dist/{client-DrQZZ1js.d.ts → client-CaurIxje.d.ts} +147 -3
  8. package/dist/{cookieJar-BTmpjXZe.d.ts → cookieJar-DC4GLKrJ.d.ts} +2 -2
  9. package/dist/{cookieJar-BqYOnNN-.d.cts → cookieJar-oKazfbN1.d.cts} +2 -2
  10. package/dist/{errors-DZ3k8a8i.d.cts → errors-CWlh-wcm.d.cts} +7 -1
  11. package/dist/{errors-DZ3k8a8i.d.ts → errors-CWlh-wcm.d.ts} +7 -1
  12. package/dist/{errors-dlGXAsbh.d.ts → errors-DDo3oxcH.d.ts} +1 -1
  13. package/dist/{errors-RvGlTyUj.d.cts → errors-DHauOsqx.d.cts} +1 -1
  14. package/dist/grpc/index.d.cts +4 -4
  15. package/dist/grpc/index.d.ts +4 -4
  16. package/dist/grpc/index.js +26 -5
  17. package/dist/grpc/index.js.map +1 -1
  18. package/dist/grpc/index.mjs +26 -5
  19. package/dist/grpc/index.mjs.map +1 -1
  20. package/dist/index.d.cts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +26 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +26 -5
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/middleware/index.d.cts +5 -5
  27. package/dist/middleware/index.d.ts +5 -5
  28. package/dist/middleware/index.js +164 -12
  29. package/dist/middleware/index.js.map +1 -1
  30. package/dist/middleware/index.mjs +164 -12
  31. package/dist/middleware/index.mjs.map +1 -1
  32. package/dist/nestjs/index.js.map +1 -1
  33. package/dist/nestjs/index.mjs.map +1 -1
  34. package/dist/node/index.d.cts +15 -4
  35. package/dist/node/index.d.ts +15 -4
  36. package/dist/node/index.js +186 -14
  37. package/dist/node/index.js.map +1 -1
  38. package/dist/node/index.mjs +185 -15
  39. package/dist/node/index.mjs.map +1 -1
  40. package/dist/{oidcState-C3VLn3eD.d.ts → oidcState-CZhj0MBP.d.ts} +123 -5
  41. package/dist/{oidcState-BaJ-SM_R.d.cts → oidcState-EnEJmoF5.d.cts} +123 -5
  42. package/dist/rest/index.d.cts +6 -6
  43. package/dist/rest/index.d.ts +6 -6
  44. package/dist/rest/index.js +26 -5
  45. package/dist/rest/index.js.map +1 -1
  46. package/dist/rest/index.mjs +26 -5
  47. package/dist/rest/index.mjs.map +1 -1
  48. package/dist/{session-B03NsqVs.d.ts → session-Beo11VT_.d.ts} +9 -0
  49. package/dist/{session-plDr4lFu.d.cts → session-CeIUXgpE.d.cts} +9 -0
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -20,13 +20,39 @@ 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.64**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
24
- §20, §21, §22, §23, §24, §25, §26, §27 (with §27.6.2), §28, §28.12, §29, §30, §31, §32, §33 and §36,
23
+ This SDK conforms to **contract 1.66**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
24
+ §20, §21, §22, §23, §24, §25, §26, §27 (with §27.6.2), §28, §28.12, §29, §30, §31, §32, §33, §36 and §37,
25
25
  with §32.7 and §33.2 signed (including §6.1 mTLS client certificates, the
26
26
  §10.1 minimum local-verification set, the §12 OIDC/SSO relying-party helpers, and the §13
27
27
  `verifyWebhook` signature verifier). Manifest pruning: not offered in any namespace (§27.10). §12 is implemented in full at its 1.38 shape: all
28
28
  **thirteen** operations, including the four public "Sign in with X" entry points.
29
29
 
30
+ ### Contract 1.66 — sign-in hardening (§34.10)
31
+
32
+ Contract 1.66 adds no operation and changes no API here. A federated sign-in is bound to the client
33
+ that started it (§12.1 rule 12b): `ssoStart`, `ssoStartOauth2` and `samlLogin` set an
34
+ `__Host-axiam_fed_bind` cookie, and the completions refuse with `401` without it. The §4 jar carries
35
+ it, so **send the start and the completion of one sign-in through the same client instance** — a
36
+ backend that builds a fresh client per HTTP request, or completes on another replica's client, is
37
+ refused, and that `401` is terminal for the sign-in. The optional `reauthenticate` start input (rule
38
+ 12c) is not exposed.
39
+
40
+ ### Contract 1.65 — the 1.2.0 release (§34.9)
41
+
42
+ Contract 1.65 adds no management operation (202 in 29 namespaces). It adds native sign-in with a
43
+ provider ID token (§37) and the `idpHint` input of `oidcBegin` and `oidcPar` (§12.1, §26.2 rule 8).
44
+ See [Native sign-in](#native-sign-in-with-a-provider-id-token-contract-165-37) and
45
+ [Choosing the provider](#choosing-the-provider-idphint-contract-165).
46
+
47
+ | Item | What this SDK does |
48
+ |---|---|
49
+ | (a) §37 native sign-in | `OidcClient.loginWithProviderIdToken(provider, idToken, nonce, options?)` and the SHOULD helper `nativeNonce()` returning `ProviderNonce`, with all thirteen §37.9 tests. |
50
+ | (b) `idp_hint` | `idpHint` on `oidcBegin` (emitted once as `axiam_idp_hint`) and on `oidcPar` (pushed body only). |
51
+ | (h) server floor (D-N33) | Federation-config admin calls need an AXIAM server **1.2.0 or later**: `FederationConfigResponse.native_login` is required from 1.2.0, and (no runtime response validation here) a response from an older server decodes with `native_login` `undefined`. |
52
+ | (c) a replayed refresh token ends the session | No code change. `oidcRefresh` is single-flight (§9), so a burst is one wire call; `invalid_grant` is an `OAuthProtocolError`, never retried. Confirmed by a test. |
53
+ | (d), (e), (f), (g) | No code change. The SDK parses no handoff callback URL; `ssoCompleteHandoff` takes the `code` the caller already extracted. |
54
+ | (g), (i), (j) regenerated members | The §27 layer is regenerated: `default_idp`, `refresh_reuse_response` (preserved by the read-modify-write `update` forms), `native_login`. |
55
+
30
56
  ### Contract 1.64 — the 1.1.2 release (§34.8)
31
57
 
32
58
  Contract 1.64 adds no operation (202 in 29 namespaces). Every item of §34.8 that asks anything of
@@ -1015,7 +1041,7 @@ const oidc = createOidcClient(session, {
1015
1041
  | Operation | Wire call | Notes |
1016
1042
  |-----------|-----------|-------|
1017
1043
  | `oidcDiscover()` | `GET /.well-known/openid-configuration` | Cached per origin, TTL ≥ 5 min, concurrent calls share one fetch |
1018
- | `oidcBegin({ configuration, redirectUri, scope?, extraParams? })` | *none — pure local computation* | CSPRNG `state`/`nonce` (256-bit) + PKCE **S256** challenge; returns `{ url, state, nonce, codeVerifier }` |
1044
+ | `oidcBegin({ configuration, redirectUri, scope?, extraParams?, idpHint? })` | *none — pure local computation* | CSPRNG `state`/`nonce` (256-bit) + PKCE **S256** challenge; returns `{ url, state, nonce, codeVerifier }` |
1019
1045
  | `oidcExchange({ code, codeVerifier, nonce, redirectUri, tenantId?, configuration? })` | `POST /oauth2/token?tenant_id=…` | `grant_type=authorization_code`; validates the ID token in full before returning |
1020
1046
  | `oidcRefresh({ refreshToken, scope?, tenantId?, configuration? })` | `POST /oauth2/token?tenant_id=…` | `grant_type=refresh_token`, under the §9 single-flight guard. **Distinct from `AxiamClient.refresh()`**, which drives the cookie-session path |
1021
1047
  | `loginClientCredentials({ scope?, tenantId?, adoptAsCredential?, configuration? })` | `POST /oauth2/token?tenant_id=…` | Service-account M2M login; no `openid` scope, no ID token. `adoptAsCredential: true` uses the token as the session's bearer credential |
@@ -1028,6 +1054,50 @@ const oidc = createOidcClient(session, {
1028
1054
  | `ssoCompleteOauth2({ state, code })` | `POST /api/v1/auth/federation/oauth2/callback` | Step 2 of the OAuth2 variant; same `Set-Cookie` session and same post-login sync as `ssoComplete` |
1029
1055
  | `ssoCompleteHandoff({ code })` | `POST /api/v1/auth/federation/handoff` | Redeems the single-use `axiam_handoff` code the SAML and Apple flows deliver on the SPA's callback URL. Valid 60 s, redeemable **once**; a `401` is terminal and is **never retried** |
1030
1056
 
1057
+ #### Choosing the provider, `idpHint` (contract 1.65)
1058
+
1059
+ A relying party that already knows which provider its user should use can send the browser
1060
+ straight there. `idpHint` takes a provider's UUID, its `provider_slug` or a branded kind name
1061
+ (`google`, `apple`, …) and is emitted once as `axiam_idp_hint`; there is no `kc_idp_hint`.
1062
+
1063
+ ```ts
1064
+ const request = oidc.oidcBegin({ configuration, redirectUri, idpHint: 'corp-okta' });
1065
+ // under PAR the hint rides the pushed body, never the redirect:
1066
+ const pushed = await oidc.oidcPar({ request, redirectUri, configuration, idpHint: 'corp-okta' });
1067
+ ```
1068
+
1069
+ When `oidcPar` is given no `idpHint`, it pushes the hint the begin URL carries; an `idpHint` given to
1070
+ `oidcPar` wins.
1071
+
1072
+ It is validated for emptiness and 256 UTF-8 bytes only (a `ValidationError`, no URL built) and is
1073
+ never trimmed, folded or looked up; an unresolvable hint is ignored by the server.
1074
+
1075
+ #### Native sign-in with a provider ID token (contract 1.65, §37)
1076
+
1077
+ A mobile or desktop app that holds the ID token Google, Apple or Facebook's native SDK produced
1078
+ presents it to AXIAM's token endpoint (`grant_type=urn:axiam:params:oauth:grant-type:provider-id-token`).
1079
+ This is not token exchange. `nativeNonce()` is the pair the two parties need.
1080
+
1081
+ ```ts
1082
+ import { createNodeSession, createOidcClient, nativeNonce } from 'axiam-sdk/node';
1083
+
1084
+ const { raw, hashed } = nativeNonce(); // raw: Sensitive<string>, hashed: hex SHA-256
1085
+ const providerToken = await providerSdk.signIn({ nonce: hashed }); // give the provider the HASH
1086
+ const tokens = await oidc.loginWithProviderIdToken(
1087
+ 'corp-google', // the provider's UUID or provider_slug, sent verbatim (not a kind name)
1088
+ providerToken,
1089
+ raw, // the RAW nonce, sent byte for byte
1090
+ { scopes: ['openid'] }, // none are added for you: omit them and there is no ID token
1091
+ );
1092
+ ```
1093
+
1094
+ `loginWithProviderIdToken` is **never retried**: the provider's token is single-use across the
1095
+ deployment, and `invalid_grant` is the server's one generic answer to every refusal of it. Recover
1096
+ with a fresh provider token and a fresh `nativeNonce()`. An empty `provider`, `idToken` or `nonce`
1097
+ and a slug-only client are refused locally with no request. Neither the ID token nor the raw nonce
1098
+ is logged, kept or put in an error; hold the raw nonce only for the length of the attempt. The
1099
+ result is the ordinary `OidcTokenSet`, returned and not adopted as the client's credential.
1100
+
1031
1101
  #### The four public login-provider operations, and their rules
1032
1102
 
1033
1103
  **An empty provider list is a success** (§12.1 note 9). An unknown organization, a known one