axiam-sdk 1.1.1 → 1.1.2

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 (42) hide show
  1. package/README.md +20 -4
  2. package/dist/browser/index.d.cts +1 -1
  3. package/dist/browser/index.d.ts +1 -1
  4. package/dist/{client-D34sXV8p.d.cts → client-BGFn1VQh.d.cts} +7 -1
  5. package/dist/{client-BMNQi36J.d.ts → client-DrQZZ1js.d.ts} +7 -1
  6. package/dist/{cookieJar-DcrMe93Q.d.ts → cookieJar-BTmpjXZe.d.ts} +8 -2
  7. package/dist/{cookieJar-C_xPuniu.d.cts → cookieJar-BqYOnNN-.d.cts} +8 -2
  8. package/dist/grpc/index.d.cts +4 -4
  9. package/dist/grpc/index.d.ts +4 -4
  10. package/dist/grpc/index.js +32 -2
  11. package/dist/grpc/index.js.map +1 -1
  12. package/dist/grpc/index.mjs +32 -2
  13. package/dist/grpc/index.mjs.map +1 -1
  14. package/dist/index.d.cts +2 -2
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +24 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +24 -2
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/middleware/index.d.cts +3 -3
  21. package/dist/middleware/index.d.ts +3 -3
  22. package/dist/middleware/index.js +149 -22
  23. package/dist/middleware/index.js.map +1 -1
  24. package/dist/middleware/index.mjs +149 -22
  25. package/dist/middleware/index.mjs.map +1 -1
  26. package/dist/node/index.d.cts +3 -3
  27. package/dist/node/index.d.ts +3 -3
  28. package/dist/node/index.js +178 -23
  29. package/dist/node/index.js.map +1 -1
  30. package/dist/node/index.mjs +178 -23
  31. package/dist/node/index.mjs.map +1 -1
  32. package/dist/{oidcState-BFIHt7_Y.d.cts → oidcState-BaJ-SM_R.d.cts} +37 -6
  33. package/dist/{oidcState-qoy2vsYG.d.ts → oidcState-C3VLn3eD.d.ts} +37 -6
  34. package/dist/rest/index.d.cts +3 -3
  35. package/dist/rest/index.d.ts +3 -3
  36. package/dist/rest/index.js +24 -2
  37. package/dist/rest/index.js.map +1 -1
  38. package/dist/rest/index.mjs +24 -2
  39. package/dist/rest/index.mjs.map +1 -1
  40. package/dist/{session-BbPFTpMZ.d.ts → session-B03NsqVs.d.ts} +16 -0
  41. package/dist/{session-C9WlP6DV.d.cts → session-plDr4lFu.d.cts} +16 -0
  42. package/package.json +1 -1
package/README.md CHANGED
@@ -20,20 +20,36 @@ 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.63**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
23
+ This SDK conforms to **contract 1.64**: CONTRACT.md §1–§13 and §12.7, §14, §15, §17, §19,
24
24
  §20, §21, §22, §23, §24, §25, §26, §27 (with §27.6.2), §28, §28.12, §29, §30, §31, §32, §33 and §36,
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.64 — the 1.1.2 release (§34.8)
31
+
32
+ Contract 1.64 adds no operation (202 in 29 namespaces). Every item of §34.8 that asks anything of
33
+ this SDK, and what it does:
34
+
35
+ | Item | Rule | What this SDK does |
36
+ |---|---|---|
37
+ | (b) a `429 rate_limit_exceeded` on a poll is waited out | §14.2 rule 9, §14.6 | `devicePoll` raises any `429` as an `OAuthProtocolError` with `error == "rate_limit_exceeded"` (the status decides, not the body: a bodiless `429`, or one saying `slow_down`, included; never `slow_down`). `deviceLogin` treats it as non-terminal: it waits `Retry-After` as a minimum (delta-seconds form), counts the wait as one interval, does **not** raise the interval (only the `400` does), and polls again. A wait that would pass the `expires_in` deadline, measured on the clock from the authorization, ends in `expired_token` and sends nothing after it. A `5xx` mid-poll is a transport failure whatever its body (`500 {"error":"server_error"}` included): retried under §16 inside the poll (three requests in all, a transport failure likewise; never a `429`), then the loop takes its next interval. A §16 retry inside the poll never passes the deadline either: a wait that would reach it (a `Retry-After` included) is not served and the typed `expired_token` is raised (the CIBA loop is bounded the same way, §34.2 P10). |
38
+ | (c) the refusal at `plan` names the member, and the value where the SDK keeps it | §27.6.2 item 4 | Already held: `plan` names the member and the value (this SDK keeps the text). |
39
+ | (a), (d)–(j) | | Informative or no SDK work. |
40
+
41
+ Follow-ups of the contract 1.63 conformance review (#148): in the browser persona an `/oauth2/*`
42
+ request uses the fetch adapter with `credentials: 'omit'`, so a same-origin `axiam_*` cookie is not
43
+ sent either (§12.1 rule 3, C163-12), and so does an RFC 7592 registration call (C164-06); the Node
44
+ persona keeps its jar-free agent pair.
45
+
30
46
  ### Contract 1.63 — the 1.1.1 release (§34.7)
31
47
 
32
48
  | Item | Rule | What this SDK does |
33
49
  |---|---|---|
34
50
  | (a) no session cookie, no CSRF header on `/oauth2/*` | §6.1 rule 11, §12.1 rule 3, §14.6 | Every `/oauth2/*` request goes through the jar-free agent pair and carries no `X-CSRF-Token`, whether or not a device credential is adopted (a path-prefix match: the federation `oauth2/start`/`callback` routes are session endpoints and are unaffected). |
35
- | (ab) an unknown open-enum value on an unstated manifest member | §27.6.2 item 4 | `plan` raises a `ValidationError` naming the member and the value, before any write; stating the member resolves it. |
36
- | (ac) `termination_action` has no "none" in a manifest | §27.6.2 item 4 | A stated `terminationAction: null` is refused at `plan` with zero wire calls. |
51
+ | C162-07 (§34.6 (ab)): an unknown open-enum value on an unstated manifest member | §27.6.2 item 4 | `plan` raises a `ValidationError` naming the member and the value, before any write; stating the member resolves it. |
52
+ | C162-08 (§34.6 (ac)): `termination_action` has no "none" in a manifest | §27.6.2 item 4 | A stated `terminationAction: null` is refused at `plan` with zero wire calls. |
37
53
  | (c) the AMQP producer's local refusal | §8 (MAY) | Not applicable: this SDK ships no helper that builds or signs an `AuditEventMessage`. |
38
54
 
39
55
  ### Contract 1.62 — the 1.1.0 release (§34.6)
@@ -224,7 +240,7 @@ See [`CONTRACT.md`](./CONTRACT.md) for the full cross-language behavioral contra
224
240
  ## Install
225
241
 
226
242
  ```bash
227
- npm install axiam-sdk@^1.1.0
243
+ npm install axiam-sdk@^1.1.2
228
244
  ```
229
245
 
230
246
  From 1.0.0 the SDK is stable and follows semantic versioning: a breaking change to its
@@ -2,7 +2,7 @@ import { AxiamClient, WebauthnWorkspace, WebauthnLoginResult, WebauthnCredential
2
2
  import { Sensitive } from '../amqp/index.cjs';
3
3
  import { LoginResult } from '../index.cjs';
4
4
  export { W as WebauthnFailure, c as classifyWebauthnError, w as webauthnErrorMessage } from '../webauthnErrors-m1LZiaRy.cjs';
5
- import '../session-C9WlP6DV.cjs';
5
+ import '../session-plDr4lFu.cjs';
6
6
  import 'axios';
7
7
  import '../telemetry-Du0-zS5f.cjs';
8
8
 
@@ -2,7 +2,7 @@ import { AxiamClient, WebauthnWorkspace, WebauthnLoginResult, WebauthnCredential
2
2
  import { Sensitive } from '../amqp/index.js';
3
3
  import { LoginResult } from '../index.js';
4
4
  export { W as WebauthnFailure, c as classifyWebauthnError, w as webauthnErrorMessage } from '../webauthnErrors-m1LZiaRy.js';
5
- import '../session-BbPFTpMZ.js';
5
+ import '../session-B03NsqVs.js';
6
6
  import 'axios';
7
7
  import '../telemetry-Du0-zS5f.js';
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { S as Sensitive } from './sensitive-BC_s7Rrd.cjs';
2
- import { S as SharedSession, A as AxiamClientOptions, D as DecisionMemo, T as TelemetryReporter } from './session-C9WlP6DV.cjs';
2
+ import { S as SharedSession, A as AxiamClientOptions, D as DecisionMemo, T as TelemetryReporter } from './session-plDr4lFu.cjs';
3
3
  import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-zXSpiQM-.cjs';
4
4
  import { a as TelemetryDispatcher } from './telemetry-Du0-zS5f.cjs';
5
5
 
@@ -29,6 +29,12 @@ interface RetryOptions {
29
29
  sleepFn?: (ms: number) => Promise<void>;
30
30
  /** Injected for tests: returns the jitter fraction in [0, 1]. */
31
31
  randomFn?: () => number;
32
+ /**
33
+ * Called with the wait before a retry is announced or served; throwing refuses the retry, so
34
+ * nothing is emitted for it and nothing more is sent. A poll inside a deadline uses it to refuse
35
+ * a wait that would reach the deadline (CONTRACT.md §14.2 rule 4, §34.2 P10).
36
+ */
37
+ admit?: (delayMs: number) => void;
32
38
  }
33
39
  /**
34
40
  * The un-jittered backoff for a 1-based attempt: `min(cap, base * 2^(n-1))`.
@@ -1,5 +1,5 @@
1
1
  import { S as Sensitive } from './sensitive-BC_s7Rrd.js';
2
- import { S as SharedSession, A as AxiamClientOptions, D as DecisionMemo, T as TelemetryReporter } from './session-BbPFTpMZ.js';
2
+ import { S as SharedSession, A as AxiamClientOptions, D as DecisionMemo, T as TelemetryReporter } from './session-B03NsqVs.js';
3
3
  import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BOX-6Srv.js';
4
4
  import { a as TelemetryDispatcher } from './telemetry-Du0-zS5f.js';
5
5
 
@@ -29,6 +29,12 @@ interface RetryOptions {
29
29
  sleepFn?: (ms: number) => Promise<void>;
30
30
  /** Injected for tests: returns the jitter fraction in [0, 1]. */
31
31
  randomFn?: () => number;
32
+ /**
33
+ * Called with the wait before a retry is announced or served; throwing refuses the retry, so
34
+ * nothing is emitted for it and nothing more is sent. A poll inside a deadline uses it to refuse
35
+ * a wait that would reach the deadline (CONTRACT.md §14.2 rule 4, §34.2 P10).
36
+ */
37
+ admit?: (delayMs: number) => void;
32
38
  }
33
39
  /**
34
40
  * The un-jittered backoff for a 1-based attempt: `min(cap, base * 2^(n-1))`.
@@ -1,7 +1,7 @@
1
1
  import { AxiosRequestConfig, AxiosInstance } from 'axios';
2
2
  import { CookieJar } from 'tough-cookie';
3
- import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-BbPFTpMZ.js';
4
- import { A as AxiamClient } from './client-BMNQi36J.js';
3
+ import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-B03NsqVs.js';
4
+ import { A as AxiamClient } from './client-DrQZZ1js.js';
5
5
  import { S as Sensitive } from './sensitive-BC_s7Rrd.js';
6
6
  import { V as Verifier } from './jwks-CTVpOWzI.js';
7
7
 
@@ -69,6 +69,12 @@ declare class NodeSession extends SharedSession {
69
69
  * fresh `https.Agent` per call would open a fresh TLS socket per call.
70
70
  */
71
71
  noCredentialsConfig(): AxiosRequestConfig;
72
+ /**
73
+ * Overrides {@link SharedSession.oauth2RequestConfig}: under Node the
74
+ * jar-free agent pair of {@link noCredentialsConfig} is what withholds the
75
+ * cookies; the browser's fetch adapter (`credentials: 'omit'`) is not used.
76
+ */
77
+ oauth2RequestConfig(): AxiosRequestConfig;
72
78
  /**
73
79
  * Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
74
80
  * session's per-instance `refreshGuard` (inherited from SharedSession) by
@@ -1,7 +1,7 @@
1
1
  import { AxiosRequestConfig, AxiosInstance } from 'axios';
2
2
  import { CookieJar } from 'tough-cookie';
3
- import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-C9WlP6DV.cjs';
4
- import { A as AxiamClient } from './client-D34sXV8p.cjs';
3
+ import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-plDr4lFu.cjs';
4
+ import { A as AxiamClient } from './client-BGFn1VQh.cjs';
5
5
  import { S as Sensitive } from './sensitive-BC_s7Rrd.cjs';
6
6
  import { V as Verifier } from './jwks-CTVpOWzI.cjs';
7
7
 
@@ -69,6 +69,12 @@ declare class NodeSession extends SharedSession {
69
69
  * fresh `https.Agent` per call would open a fresh TLS socket per call.
70
70
  */
71
71
  noCredentialsConfig(): AxiosRequestConfig;
72
+ /**
73
+ * Overrides {@link SharedSession.oauth2RequestConfig}: under Node the
74
+ * jar-free agent pair of {@link noCredentialsConfig} is what withholds the
75
+ * cookies; the browser's fetch adapter (`credentials: 'omit'`) is not used.
76
+ */
77
+ oauth2RequestConfig(): AxiosRequestConfig;
72
78
  /**
73
79
  * Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
74
80
  * session's per-instance `refreshGuard` (inherited from SharedSession) by
@@ -1,16 +1,16 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import { Interceptor } from '@grpc/grpc-js';
3
- import { N as NodeSession } from '../cookieJar-C_xPuniu.cjs';
4
- export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-C_xPuniu.cjs';
3
+ import { N as NodeSession } from '../cookieJar-BqYOnNN-.cjs';
4
+ export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-BqYOnNN-.cjs';
5
5
  import { Sensitive } from '../amqp/index.cjs';
6
6
  import { a as AccessDecision } from '../types-zXSpiQM-.cjs';
7
7
  import { CnfClaim } from '../middleware/index.cjs';
8
8
  export { A as AxiamClaims, J as JWKS_PATH, V as Verifier, c as createVerifier } from '../jwks-CTVpOWzI.cjs';
9
9
  import 'axios';
10
10
  import 'tough-cookie';
11
- import '../session-C9WlP6DV.cjs';
11
+ import '../session-plDr4lFu.cjs';
12
12
  import '../telemetry-Du0-zS5f.cjs';
13
- import '../client-D34sXV8p.cjs';
13
+ import '../client-BGFn1VQh.cjs';
14
14
 
15
15
  /**
16
16
  * Injects `authorization: Bearer <token>` (when a token is available) and
@@ -1,16 +1,16 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import { Interceptor } from '@grpc/grpc-js';
3
- import { N as NodeSession } from '../cookieJar-DcrMe93Q.js';
4
- export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-DcrMe93Q.js';
3
+ import { N as NodeSession } from '../cookieJar-BTmpjXZe.js';
4
+ export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-BTmpjXZe.js';
5
5
  import { Sensitive } from '../amqp/index.js';
6
6
  import { a as AccessDecision } from '../types-BOX-6Srv.js';
7
7
  import { CnfClaim } from '../middleware/index.js';
8
8
  export { A as AxiamClaims, J as JWKS_PATH, V as Verifier, c as createVerifier } from '../jwks-CTVpOWzI.js';
9
9
  import 'axios';
10
10
  import 'tough-cookie';
11
- import '../session-BbPFTpMZ.js';
11
+ import '../session-B03NsqVs.js';
12
12
  import '../telemetry-Du0-zS5f.js';
13
- import '../client-BMNQi36J.js';
13
+ import '../client-DrQZZ1js.js';
14
14
 
15
15
  /**
16
16
  * Injects `authorization: Bearer <token>` (when a token is available) and
@@ -1098,6 +1098,24 @@ var SharedSession = class {
1098
1098
  noCredentialsConfig() {
1099
1099
  return { withCredentials: false };
1100
1100
  }
1101
+ /**
1102
+ * Axios config for a request to an `/oauth2/*` endpoint (CONTRACT.md §12.1
1103
+ * rule 3, §14.6; C163-12): {@link noCredentialsConfig} and, in the browser
1104
+ * persona, the fetch adapter with `credentials: 'omit'`.
1105
+ *
1106
+ * `withCredentials: false` on axios's default XHR adapter is not enough: that
1107
+ * adapter sends a same-origin cookie regardless, so an app served from the
1108
+ * AXIAM origin would still present `axiam_*` on a token or device request.
1109
+ * The fetch adapter derives its `credentials` from `withCredentials: false`
1110
+ * (`'omit'`); `fetchOptions.credentials` is set as well for adapters that
1111
+ * read it.
1112
+ * `NodeSession` overrides this to {@link noCredentialsConfig}: its jar-free
1113
+ * agent pair is what keeps the cookies off there, and the fetch adapter
1114
+ * would bypass that pair.
1115
+ */
1116
+ oauth2RequestConfig() {
1117
+ return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit" } };
1118
+ }
1101
1119
  };
1102
1120
  function resolveTenantHeaderValue(options) {
1103
1121
  if (options.tenantSlug) {
@@ -1298,7 +1316,7 @@ function installDeviceTokenInterceptor(axiosInstance, session) {
1298
1316
  if (session.isForeignHost(config.url) || deviceToken === void 0 && !oauth2) {
1299
1317
  return config;
1300
1318
  }
1301
- const noCred = session.noCredentialsConfig();
1319
+ const noCred = oauth2 ? session.oauth2RequestConfig() : session.noCredentialsConfig();
1302
1320
  Object.assign(config, noCred);
1303
1321
  config.headers = config.headers ?? {};
1304
1322
  if (oauth2) {
@@ -1792,6 +1810,7 @@ async function withRetry(fn, options) {
1792
1810
  }
1793
1811
  const retryAfterMs2 = isRetryAfterCarrier(err) ? err.retryAfterMs : void 0;
1794
1812
  const delay = delayMs(attempt, retryAfterMs2, random());
1813
+ options.admit?.(delay);
1795
1814
  options.telemetry?.emit({
1796
1815
  type: "retry",
1797
1816
  operation: options.operation ?? "unknown",
@@ -2321,7 +2340,10 @@ async function bareRequest(session, operation, config) {
2321
2340
  // jar). Under the Node persona this is the jar-wrapped cookie agent, which
2322
2341
  // `noCredentialsConfig()` below replaces with a plain one.
2323
2342
  ...defaults.httpsAgent !== void 0 ? { httpsAgent: defaults.httpsAgent } : {},
2324
- ...session.noCredentialsConfig(),
2343
+ // The bare transport carries the RFC 7592 registration calls on `/oauth2/register/*`,
2344
+ // so it gets an `/oauth2/*` request's config: in the browser persona the fetch adapter
2345
+ // that omits credentials (C164-06; identical to `noCredentialsConfig()` under Node).
2346
+ ...session.oauth2RequestConfig(),
2325
2347
  withCredentials: false,
2326
2348
  maxRedirects: 0,
2327
2349
  validateStatus: () => true
@@ -8950,6 +8972,14 @@ var NodeSession = class extends SharedSession {
8950
8972
  withCredentials: false
8951
8973
  };
8952
8974
  }
8975
+ /**
8976
+ * Overrides {@link SharedSession.oauth2RequestConfig}: under Node the
8977
+ * jar-free agent pair of {@link noCredentialsConfig} is what withholds the
8978
+ * cookies; the browser's fetch adapter (`credentials: 'omit'`) is not used.
8979
+ */
8980
+ oauth2RequestConfig() {
8981
+ return this.noCredentialsConfig();
8982
+ }
8953
8983
  /**
8954
8984
  * Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
8955
8985
  * session's per-instance `refreshGuard` (inherited from SharedSession) by