axiam-sdk 1.0.0-alpha40 → 1.0.0-alpha43

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.
package/README.md CHANGED
@@ -16,6 +16,7 @@ Official TypeScript/JavaScript client SDK for [AXIAM](https://github.com/ilpanic
16
16
  - **Registry:** [npmjs.com/package/axiam-sdk](https://www.npmjs.com/package/axiam-sdk) _(reserved, not yet published)_
17
17
  - **Source:** [github.com/ilpanich/axiam-typescript-sdk](https://github.com/ilpanich/axiam-typescript-sdk)
18
18
  - **License:** Apache-2.0
19
+ - **Node:** `>=22` — see [Supported Node versions](#supported-node-versions)
19
20
 
20
21
  ## Contract conformance
21
22
 
@@ -64,6 +65,39 @@ See [`CONTRACT.md`](./CONTRACT.md) for the full cross-language behavioral contra
64
65
  npm install axiam-sdk
65
66
  ```
66
67
 
68
+ ## Supported Node versions
69
+
70
+ | | Version | Why this one |
71
+ |---|---|---|
72
+ | **Floor** | 22 | The oldest release line still receiving security fixes. Node 18 went EOL 2025-04-30 and Node 20 on 2026-04-30. `engines.node` is `>=22`. |
73
+ | **Newest** | 26 | The current release line (out 2026-05, promoted to LTS 2026-10), and the line `@types/node` is pinned to. |
74
+
75
+ Node 24 (Active LTS) sits between the two and is supported.
76
+
77
+ **The SDK is built against the floor, and runs on everything up to the newest.**
78
+ Those are two different claims, and CI proves each separately: the gating
79
+ matrix in `sdk-ci-typescript.yml` runs `build`, `typecheck`, the full test
80
+ suite and the CommonJS-require smoke tests on **22 and on 26**. The floor leg
81
+ is what stops a Node 24-only built-in from slipping in; the newest leg is what
82
+ catches a removal, and is the runtime `tsc` is typechecking against. A line
83
+ between two green legs is interpolation, which is why the matrix is two legs
84
+ rather than four — the runtime-independent gates (bundle-grep, the token-leak
85
+ and TLS-lint greps, `npm audit`, the docs gate and the publish dry-run) run
86
+ once, on the floor.
87
+
88
+ If you are on a newer runtime than the floor you need do nothing: the
89
+ published bundle targets ES2022 and is forward-compatible, and the newest leg
90
+ is the evidence.
91
+
92
+ The browser persona (`axiam-sdk/browser`) has no Node floor at all — it needs
93
+ a runtime with `fetch`, `crypto.subtle` and `TextEncoder`, which every
94
+ currently supported browser has.
95
+
96
+ `test/core/versionPolicy.test.ts` fails the build if `engines.node`, the
97
+ `@types/node` pin and the CI matrix ever stop agreeing. They are three
98
+ independent declarations of the same fact and nothing else compares them —
99
+ before that test existed, all three disagreed at once.
100
+
67
101
  ## Two personas, tree-shaken subpath entries
68
102
 
69
103
  `axiam-sdk` ships as **one package with two personas**, each reachable through its own
@@ -742,8 +776,19 @@ try {
742
776
  ```
743
777
 
744
778
  The `if` is the important line. **Any other error is a failed login**, and
745
- retrying it over `login()` would hand the plaintext to a server that just
746
- failed to prove it holds the record.
779
+ retrying it over `login()` yourself would hand the plaintext to a server that
780
+ just failed to prove it holds the record.
781
+
782
+ One case is handled for you. `login/start` returns the tenant's `mode`, and when
783
+ it is `"optional"` — the mid-migration state, where accounts acquire a
784
+ registration record only as their passwords are next set — a failed exchange is
785
+ not yet a verdict on the credentials, so `loginOpaque` retries over
786
+ `POST /api/v1/auth/login` itself and returns that call's outcome (CONTRACT.md
787
+ §23.4 rule 7). Under `"required"`, and against a server too old to send `mode`
788
+ at all, it fails closed exactly as before. `mode` is **not** downgrade
789
+ protection: a hostile server that wanted the plaintext could answer `404` and
790
+ get the fallback above regardless. `required` is what closes that, server-side,
791
+ by refusing `/auth/login` for every principal in the tenant.
747
792
 
748
793
  ### What this buys, and what it does not
749
794
 
@@ -1016,6 +1016,7 @@ async function login(client, email, password) {
1016
1016
  } catch (err) {
1017
1017
  const setup = mfaSetupRequired(err);
1018
1018
  if (setup) return setup;
1019
+ if (err instanceof AxiamError) throw err;
1019
1020
  const status = extractAxiosStatus(err);
1020
1021
  if (status !== void 0) {
1021
1022
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "login failed", {
@@ -1035,6 +1036,7 @@ async function verifyMfa(client, mfaToken, code) {
1035
1036
  await client.session.onAuthenticated?.();
1036
1037
  return loginSuccessToResult(response.data);
1037
1038
  } catch (err) {
1039
+ if (err instanceof AxiamError) throw err;
1038
1040
  const status = extractAxiosStatus(err);
1039
1041
  if (status !== void 0) {
1040
1042
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "verifyMfa failed", {
@@ -1051,6 +1053,7 @@ async function refresh(client) {
1051
1053
  await client.session.axios.post(REFRESH_PATH, client.session.buildRefreshBody());
1052
1054
  await client.session.onAuthenticated?.();
1053
1055
  } catch (err) {
1056
+ if (err instanceof AxiamError) throw err;
1054
1057
  const status = extractAxiosStatus(err);
1055
1058
  if (status !== void 0) {
1056
1059
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "refresh failed", {
@@ -1066,6 +1069,7 @@ async function logout(client) {
1066
1069
  try {
1067
1070
  await client.session.axios.post(LOGOUT_PATH, {});
1068
1071
  } catch (err) {
1072
+ if (err instanceof AxiamError) throw err;
1069
1073
  const status = extractAxiosStatus(err);
1070
1074
  if (status !== void 0) {
1071
1075
  throw mapHttpStatusToError(status, extractErrorMessage(extractAxiosData(err)) ?? "logout failed", {
@@ -1231,6 +1235,9 @@ async function loginOpaque(client, usernameOrEmail, password) {
1231
1235
  ke3 = exchange.finish(started.ke2, started);
1232
1236
  } catch (err) {
1233
1237
  if (err instanceof NetworkError) throw err;
1238
+ if (started.mode === "optional") {
1239
+ return await login(client, usernameOrEmail, password);
1240
+ }
1234
1241
  throw mapHttpStatusToError(401, "invalid credentials", { cause: err });
1235
1242
  }
1236
1243
  let response;