axiam-sdk 1.1.0 → 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 (60) hide show
  1. package/README.md +27 -2
  2. package/dist/amqp/index.d.cts +3 -2
  3. package/dist/amqp/index.d.ts +3 -2
  4. package/dist/{authzCore-BQfX9qxN.d.cts → authzCore-CqXzLNmT.d.cts} +4 -3
  5. package/dist/{authzCore-BlSHwGnW.d.ts → authzCore-D-hquWSI.d.ts} +4 -3
  6. package/dist/browser/index.d.cts +8 -7
  7. package/dist/browser/index.d.ts +8 -7
  8. package/dist/{client-7ZKtfXW-.d.cts → client-BGFn1VQh.d.cts} +34 -24
  9. package/dist/{client-Putxo-yi.d.ts → client-DrQZZ1js.d.ts} +34 -24
  10. package/dist/{cookieJar-Cw6Zdeec.d.ts → cookieJar-BTmpjXZe.d.ts} +9 -3
  11. package/dist/{cookieJar-DkGcIr-i.d.cts → cookieJar-BqYOnNN-.d.cts} +9 -3
  12. package/dist/{errors-DMIlw2lN.d.ts → errors-DZ3k8a8i.d.cts} +2 -1
  13. package/dist/{errors-DMIlw2lN.d.cts → errors-DZ3k8a8i.d.ts} +2 -1
  14. package/dist/{errors-VpViVRSx.d.ts → errors-RvGlTyUj.d.cts} +3 -2
  15. package/dist/{errors-CtP_lviy.d.cts → errors-dlGXAsbh.d.ts} +3 -2
  16. package/dist/grpc/index.d.cts +10 -9
  17. package/dist/grpc/index.d.ts +10 -9
  18. package/dist/grpc/index.js +68 -7
  19. package/dist/grpc/index.js.map +1 -1
  20. package/dist/grpc/index.mjs +68 -7
  21. package/dist/grpc/index.mjs.map +1 -1
  22. package/dist/index.d.cts +6 -6
  23. package/dist/index.d.ts +6 -6
  24. package/dist/index.js +60 -7
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +60 -7
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/{jwks-BR55d7-Z.d.cts → jwks-CTVpOWzI.d.cts} +2 -1
  29. package/dist/{jwks-BR55d7-Z.d.ts → jwks-CTVpOWzI.d.ts} +2 -1
  30. package/dist/middleware/index.d.cts +13 -12
  31. package/dist/middleware/index.d.ts +13 -12
  32. package/dist/middleware/index.js +176 -31
  33. package/dist/middleware/index.js.map +1 -1
  34. package/dist/middleware/index.mjs +176 -31
  35. package/dist/middleware/index.mjs.map +1 -1
  36. package/dist/nestjs/index.d.cts +5 -4
  37. package/dist/nestjs/index.d.ts +5 -4
  38. package/dist/node/index.d.cts +10 -9
  39. package/dist/node/index.d.ts +10 -9
  40. package/dist/node/index.js +215 -29
  41. package/dist/node/index.js.map +1 -1
  42. package/dist/node/index.mjs +215 -29
  43. package/dist/node/index.mjs.map +1 -1
  44. package/dist/{oidcState-Cz6erz0g.d.cts → oidcState-BaJ-SM_R.d.cts} +41 -9
  45. package/dist/{oidcState-zGt6VU6v.d.ts → oidcState-C3VLn3eD.d.ts} +41 -9
  46. package/dist/rest/index.d.cts +10 -9
  47. package/dist/rest/index.d.ts +10 -9
  48. package/dist/rest/index.js +60 -7
  49. package/dist/rest/index.js.map +1 -1
  50. package/dist/rest/index.mjs +60 -7
  51. package/dist/rest/index.mjs.map +1 -1
  52. package/dist/{revocationFeed-CDoD7Twr.d.cts → revocationFeed-KQhvMMl8.d.cts} +2 -1
  53. package/dist/{revocationFeed-CDoD7Twr.d.ts → revocationFeed-KQhvMMl8.d.ts} +2 -1
  54. package/dist/{session-CeG6P9GO.d.ts → session-B03NsqVs.d.ts} +19 -2
  55. package/dist/{session-BmjEMowX.d.cts → session-plDr4lFu.d.cts} +19 -2
  56. package/dist/{telemetry--0DwnNjV.d.cts → telemetry-Du0-zS5f.d.cts} +2 -1
  57. package/dist/{telemetry--0DwnNjV.d.ts → telemetry-Du0-zS5f.d.ts} +2 -1
  58. package/dist/{webauthnErrors-fLgfOflO.d.cts → webauthnErrors-m1LZiaRy.d.cts} +2 -1
  59. package/dist/{webauthnErrors-fLgfOflO.d.ts → webauthnErrors-m1LZiaRy.d.ts} +2 -1
  60. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -669,6 +669,24 @@ var SharedSession = class {
669
669
  noCredentialsConfig() {
670
670
  return { withCredentials: false };
671
671
  }
672
+ /**
673
+ * Axios config for a request to an `/oauth2/*` endpoint (CONTRACT.md §12.1
674
+ * rule 3, §14.6; C163-12): {@link noCredentialsConfig} and, in the browser
675
+ * persona, the fetch adapter with `credentials: 'omit'`.
676
+ *
677
+ * `withCredentials: false` on axios's default XHR adapter is not enough: that
678
+ * adapter sends a same-origin cookie regardless, so an app served from the
679
+ * AXIAM origin would still present `axiam_*` on a token or device request.
680
+ * The fetch adapter derives its `credentials` from `withCredentials: false`
681
+ * (`'omit'`); `fetchOptions.credentials` is set as well for adapters that
682
+ * read it.
683
+ * `NodeSession` overrides this to {@link noCredentialsConfig}: its jar-free
684
+ * agent pair is what keeps the cookies off there, and the fetch adapter
685
+ * would bypass that pair.
686
+ */
687
+ oauth2RequestConfig() {
688
+ return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit" } };
689
+ }
672
690
  };
673
691
  function resolveTenantHeaderValue(options) {
674
692
  if (options.tenantSlug) {
@@ -779,6 +797,9 @@ function installCsrfInterceptor(axiosInstance, session) {
779
797
  if (session.isForeignHost(config.url)) {
780
798
  return config;
781
799
  }
800
+ if (isOAuth2Endpoint(config.url, session.baseUrl)) {
801
+ return config;
802
+ }
782
803
  const method = (config.method ?? "get").toLowerCase();
783
804
  const cookieString = typeof document !== "undefined" ? document.cookie : "";
784
805
  const csrfToken = typeof document !== "undefined" ? csrfHeaderForMethod(method, cookieString) : csrfHeaderForMethod(method, session.csrfToken ? `axiam_csrf=${session.csrfToken}` : "");
@@ -832,23 +853,33 @@ function installRefreshInterceptor(axiosInstance, session) {
832
853
  }
833
854
  );
834
855
  }
835
- function isOAuth2Endpoint(url) {
856
+ function isOAuth2Endpoint(url, baseUrl) {
836
857
  if (!url) {
837
858
  return false;
838
859
  }
839
- const path = url.split(/[?#]/, 1)[0] ?? "";
840
- return path.includes("/oauth2/");
860
+ try {
861
+ const base = new URL(baseUrl);
862
+ let path = new URL(url, base).pathname;
863
+ const prefix = base.pathname.replace(/\/+$/, "");
864
+ if (prefix !== "" && path.startsWith(`${prefix}/`)) {
865
+ path = path.slice(prefix.length);
866
+ }
867
+ return path.startsWith("/oauth2/");
868
+ } catch {
869
+ return false;
870
+ }
841
871
  }
842
872
  function installDeviceTokenInterceptor(axiosInstance, session) {
843
873
  axiosInstance.interceptors.request.use((config) => {
844
874
  const deviceToken = session.deviceAccessToken;
845
- if (session.isForeignHost(config.url) || deviceToken === void 0) {
875
+ const oauth2 = isOAuth2Endpoint(config.url, session.baseUrl);
876
+ if (session.isForeignHost(config.url) || deviceToken === void 0 && !oauth2) {
846
877
  return config;
847
878
  }
848
- const noCred = session.noCredentialsConfig();
879
+ const noCred = oauth2 ? session.oauth2RequestConfig() : session.noCredentialsConfig();
849
880
  Object.assign(config, noCred);
850
881
  config.headers = config.headers ?? {};
851
- if (isOAuth2Endpoint(config.url)) {
882
+ if (oauth2) {
852
883
  return config;
853
884
  }
854
885
  config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
@@ -1339,6 +1370,7 @@ async function withRetry(fn, options) {
1339
1370
  }
1340
1371
  const retryAfterMs2 = isRetryAfterCarrier(err) ? err.retryAfterMs : void 0;
1341
1372
  const delay = delayMs(attempt, retryAfterMs2, random());
1373
+ options.admit?.(delay);
1342
1374
  options.telemetry?.emit({
1343
1375
  type: "retry",
1344
1376
  operation: options.operation ?? "unknown",
@@ -1871,7 +1903,10 @@ async function bareRequest(session, operation, config) {
1871
1903
  // jar). Under the Node persona this is the jar-wrapped cookie agent, which
1872
1904
  // `noCredentialsConfig()` below replaces with a plain one.
1873
1905
  ...defaults.httpsAgent !== void 0 ? { httpsAgent: defaults.httpsAgent } : {},
1874
- ...session.noCredentialsConfig(),
1906
+ // The bare transport carries the RFC 7592 registration calls on `/oauth2/register/*`,
1907
+ // so it gets an `/oauth2/*` request's config: in the browser persona the fetch adapter
1908
+ // that omits credentials (C164-06; identical to `noCredentialsConfig()` under Node).
1909
+ ...session.oauth2RequestConfig(),
1875
1910
  withCredentials: false,
1876
1911
  maxRedirects: 0,
1877
1912
  validateStatus: () => true
@@ -2754,6 +2789,11 @@ function validateNetwork(network, problems) {
2754
2789
  problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
2755
2790
  }
2756
2791
  profiled.add(profile.segment);
2792
+ if (profile.terminationAction === null) {
2793
+ problems.push(
2794
+ `network profile of segment ${q(profile.segment)} states terminationAction as null; it has no "none" in a manifest (leave it out to keep the server default)`
2795
+ );
2796
+ }
2757
2797
  }
2758
2798
  }
2759
2799
  function duplicates(kind, keys, problems) {
@@ -3711,11 +3751,24 @@ function profileDrifted(spec, read) {
3711
3751
  if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
3712
3752
  return false;
3713
3753
  }
3754
+ var KNOWN_TERMINATION_ACTIONS = ["default", "radius_request"];
3755
+ var KNOWN_SERVICE_TYPES = ["framed_user"];
3756
+ function refuseUnknownCarried(member, stated, read, known) {
3757
+ if (stated !== void 0 || read == null || known.includes(read)) return;
3758
+ throw new ValidationError(
3759
+ "manifest.plan",
3760
+ 400,
3761
+ `network profile: ${member} was read as ${JSON.stringify(read)}, a value this SDK does not know, and the manifest does not state it; state ${member} to update this profile (CONTRACT.md \xA727.6.2 item 4)`,
3762
+ [{ field: member, message: `unknown value ${JSON.stringify(read)} on an unstated member` }]
3763
+ );
3764
+ }
3714
3765
  function profileReplaceInput(spec, read) {
3715
3766
  const profile = {
3716
3767
  dictionary: read.dictionary,
3717
3768
  session_timeout_secs: spec.sessionTimeoutSecs
3718
3769
  };
3770
+ refuseUnknownCarried("termination_action", spec.terminationAction, read.termination_action, KNOWN_TERMINATION_ACTIONS);
3771
+ refuseUnknownCarried("service_type", spec.serviceType, read.service_type, KNOWN_SERVICE_TYPES);
3719
3772
  const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
3720
3773
  if (termination != null) profile.termination_action = termination;
3721
3774
  const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;