axiam-sdk 1.0.0 → 1.1.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 (42) hide show
  1. package/README.md +91 -12
  2. package/dist/browser/index.d.cts +1 -1
  3. package/dist/browser/index.d.ts +1 -1
  4. package/dist/{client-yD0eMwHQ.d.cts → client-7ZKtfXW-.d.cts} +640 -14
  5. package/dist/{client-0WJkblDE.d.ts → client-Putxo-yi.d.ts} +640 -14
  6. package/dist/{cookieJar-hWRmZkhe.d.ts → cookieJar-Cw6Zdeec.d.ts} +1 -1
  7. package/dist/{cookieJar-CTD5jOmd.d.cts → cookieJar-DkGcIr-i.d.cts} +1 -1
  8. package/dist/{errors-m0Tue_pE.d.cts → errors-CtP_lviy.d.cts} +15 -1
  9. package/dist/{errors-CmBvsxV0.d.ts → errors-VpViVRSx.d.ts} +15 -1
  10. package/dist/grpc/index.d.cts +3 -3
  11. package/dist/grpc/index.d.ts +3 -3
  12. package/dist/grpc/index.js +572 -14
  13. package/dist/grpc/index.js.map +1 -1
  14. package/dist/grpc/index.mjs +572 -14
  15. package/dist/grpc/index.mjs.map +1 -1
  16. package/dist/index.d.cts +3 -3
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +594 -15
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +592 -16
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/middleware/index.d.cts +3 -3
  23. package/dist/middleware/index.d.ts +3 -3
  24. package/dist/middleware/index.js +26 -3
  25. package/dist/middleware/index.js.map +1 -1
  26. package/dist/middleware/index.mjs +26 -3
  27. package/dist/middleware/index.mjs.map +1 -1
  28. package/dist/node/index.d.cts +3 -3
  29. package/dist/node/index.d.ts +3 -3
  30. package/dist/node/index.js +598 -17
  31. package/dist/node/index.js.map +1 -1
  32. package/dist/node/index.mjs +598 -17
  33. package/dist/node/index.mjs.map +1 -1
  34. package/dist/{oidcState-mQLVn3-A.d.cts → oidcState-Cz6erz0g.d.cts} +24 -3
  35. package/dist/{oidcState-DOSCgnMG.d.ts → oidcState-zGt6VU6v.d.ts} +24 -3
  36. package/dist/rest/index.d.cts +58 -7
  37. package/dist/rest/index.d.ts +58 -7
  38. package/dist/rest/index.js +594 -15
  39. package/dist/rest/index.js.map +1 -1
  40. package/dist/rest/index.mjs +592 -16
  41. package/dist/rest/index.mjs.map +1 -1
  42. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -765,6 +765,12 @@ var SKIP_REFRESH = [
765
765
  // regardless of what session state came before it.
766
766
  "/api/v1/auth/device",
767
767
  "/oauth2/token",
768
+ // CONTRACT.md §14.2 rule 5 (contract 1.62): a client that fails to
769
+ // authenticate at the device endpoints is `401 invalid_client`, which is not
770
+ // an expired session and which refreshing cannot fix. `/oauth2/token` (the
771
+ // poll) was already here; the authorization endpoint now authenticates the
772
+ // client too, so its 401 must not enter the §9 guard either.
773
+ "/oauth2/device_authorization",
768
774
  "/oauth2/introspect",
769
775
  "/oauth2/revoke"
770
776
  ];
@@ -826,6 +832,13 @@ function installRefreshInterceptor(axiosInstance, session) {
826
832
  }
827
833
  );
828
834
  }
835
+ function isOAuth2Endpoint(url) {
836
+ if (!url) {
837
+ return false;
838
+ }
839
+ const path = url.split(/[?#]/, 1)[0] ?? "";
840
+ return path.includes("/oauth2/");
841
+ }
829
842
  function installDeviceTokenInterceptor(axiosInstance, session) {
830
843
  axiosInstance.interceptors.request.use((config) => {
831
844
  const deviceToken = session.deviceAccessToken;
@@ -835,6 +848,9 @@ function installDeviceTokenInterceptor(axiosInstance, session) {
835
848
  const noCred = session.noCredentialsConfig();
836
849
  Object.assign(config, noCred);
837
850
  config.headers = config.headers ?? {};
851
+ if (isOAuth2Endpoint(config.url)) {
852
+ return config;
853
+ }
838
854
  config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
839
855
  config.headers["Cookie"] = "";
840
856
  return config;
@@ -1796,10 +1812,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
1796
1812
  var ConflictError = class _ConflictError extends AuthzError {
1797
1813
  /** The registry operation that conflicted. */
1798
1814
  operation;
1799
- constructor(operation, message) {
1815
+ /**
1816
+ * The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
1817
+ * or `undefined` when the body carries none (a server that predates it, or a
1818
+ * `409` of an operation that does not name one).
1819
+ *
1820
+ * The `409` of every `network` operation says which conflict it is:
1821
+ * `stale_version`, `strands_profile`, `has_children`, `site_gone`,
1822
+ * `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
1823
+ * `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
1824
+ * not know is surfaced verbatim, and a caller branches on this member —
1825
+ * never on `message`, which an SDK must not parse. It is not the `reason` of
1826
+ * an authorization decision (§3), which is a human string.
1827
+ */
1828
+ reasonCode;
1829
+ constructor(operation, message, reasonCode) {
1800
1830
  super(message);
1801
1831
  this.name = "ConflictError";
1802
1832
  this.operation = operation;
1833
+ this.reasonCode = reasonCode;
1803
1834
  Object.setPrototypeOf(this, _ConflictError.prototype);
1804
1835
  }
1805
1836
  };
@@ -2088,6 +2119,14 @@ function omitEmptyTenantScope(body) {
2088
2119
  }
2089
2120
  return body;
2090
2121
  }
2122
+ function omitNullMembers(body, members) {
2123
+ if (!body || typeof body !== "object") return body;
2124
+ const record = body;
2125
+ if (!members.some((m) => m in record && record[m] === null)) return body;
2126
+ const copy = { ...record };
2127
+ for (const m of members) if (copy[m] === null) delete copy[m];
2128
+ return copy;
2129
+ }
2091
2130
  function roleAssignmentInherits(assignment) {
2092
2131
  return assignment.inherit ?? true;
2093
2132
  }
@@ -2564,7 +2603,8 @@ function failure(report) {
2564
2603
  );
2565
2604
  if (!found) return void 0;
2566
2605
  const message = found.outcome.status === "rebind-failed" ? `${found.outcome.message}${found.outcome.restoreSucceeded ? " (previous binding restored)" : ` (restore also failed: ${found.outcome.restoreMessage ?? "unknown error"})`}` : found.outcome.message;
2567
- return { action: found.action, message };
2606
+ const reasonCode = found.outcome.status === "failed" ? found.outcome.reasonCode : void 0;
2607
+ return reasonCode === void 0 ? { action: found.action, message } : { action: found.action, message, reasonCode };
2568
2608
  }
2569
2609
  function isComplete(report) {
2570
2610
  return failure(report) === void 0;
@@ -2582,6 +2622,7 @@ function validate(manifest) {
2582
2622
  const groups = manifest.groups ?? [];
2583
2623
  const users = manifest.users ?? [];
2584
2624
  const serviceAccounts = manifest.serviceAccounts ?? [];
2625
+ const network = manifest.network;
2585
2626
  const resourceKeys = new Set(resources.map((r) => r.key));
2586
2627
  const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
2587
2628
  const permissionKeys = new Set(permissions.map((p) => p.key));
@@ -2595,6 +2636,7 @@ function validate(manifest) {
2595
2636
  duplicates("group", groups.map((g) => g.key), problems);
2596
2637
  duplicates("user", users.map((u) => u.key), problems);
2597
2638
  duplicates("service account", serviceAccounts.map((s) => s.key), problems);
2639
+ if (network !== void 0) validateNetwork(network, problems);
2598
2640
  for (const resource of resources) {
2599
2641
  if (resource.parent && !resourceKeys.has(resource.parent)) {
2600
2642
  problems.push(
@@ -2674,6 +2716,46 @@ function validate(manifest) {
2674
2716
  }
2675
2717
  }
2676
2718
  var q = (s) => JSON.stringify(s);
2719
+ function validateNetwork(network, problems) {
2720
+ if (Array.isArray(network.policy)) {
2721
+ problems.push("network declares more than one policy; the tenant has exactly one");
2722
+ }
2723
+ const segments = network.segments ?? [];
2724
+ const profiles = network.profiles ?? [];
2725
+ duplicates("network segment", segments.map((s) => s.key), problems);
2726
+ const naturalKeys = /* @__PURE__ */ new Set();
2727
+ for (const segment of segments) {
2728
+ const natural = `${segment.site}/${segment.kind}/${segment.name}`;
2729
+ if (naturalKeys.has(natural)) {
2730
+ problems.push(
2731
+ `network segment ${q(natural)} (site, kind, name) is declared more than once`
2732
+ );
2733
+ }
2734
+ naturalKeys.add(natural);
2735
+ const seenFilters = /* @__PURE__ */ new Set();
2736
+ for (const filter of segment.filterIds ?? []) {
2737
+ if (seenFilters.has(filter)) {
2738
+ problems.push(
2739
+ `network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
2740
+ );
2741
+ }
2742
+ seenFilters.add(filter);
2743
+ }
2744
+ }
2745
+ const segmentKeys = new Set(segments.map((s) => s.key));
2746
+ const profiled = /* @__PURE__ */ new Set();
2747
+ for (const profile of profiles) {
2748
+ if (!segmentKeys.has(profile.segment)) {
2749
+ problems.push(
2750
+ `network profile names segment ${q(profile.segment)}, which no network segment declares`
2751
+ );
2752
+ }
2753
+ if (profiled.has(profile.segment)) {
2754
+ problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
2755
+ }
2756
+ profiled.add(profile.segment);
2757
+ }
2758
+ }
2677
2759
  function duplicates(kind, keys, problems) {
2678
2760
  const seen = /* @__PURE__ */ new Set();
2679
2761
  for (const key of keys) {
@@ -2719,7 +2801,9 @@ var emptyResolved = () => ({
2719
2801
  roles: /* @__PURE__ */ new Map(),
2720
2802
  groups: /* @__PURE__ */ new Map(),
2721
2803
  users: /* @__PURE__ */ new Map(),
2722
- serviceAccounts: /* @__PURE__ */ new Map()
2804
+ serviceAccounts: /* @__PURE__ */ new Map(),
2805
+ segments: /* @__PURE__ */ new Map(),
2806
+ segmentVersions: /* @__PURE__ */ new Map()
2723
2807
  });
2724
2808
  var ManifestApi = class {
2725
2809
  #client;
@@ -2752,6 +2836,23 @@ var ManifestApi = class {
2752
2836
  async #read(manifest) {
2753
2837
  const c = this.#client;
2754
2838
  const start = { limit: PLAN_PAGE };
2839
+ if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
2840
+ return {
2841
+ resources: [],
2842
+ scopes: /* @__PURE__ */ new Map(),
2843
+ permissions: [],
2844
+ roles: [],
2845
+ groups: [],
2846
+ users: [],
2847
+ serviceAccounts: [],
2848
+ roleGrants: /* @__PURE__ */ new Map(),
2849
+ roleUserBindings: /* @__PURE__ */ new Map(),
2850
+ roleGroupBindings: /* @__PURE__ */ new Map(),
2851
+ roleServiceAccountBindings: /* @__PURE__ */ new Map(),
2852
+ groupMembers: /* @__PURE__ */ new Map(),
2853
+ network: await this.#readNetwork(manifest.network, start)
2854
+ };
2855
+ }
2755
2856
  const resources = await c.resources.listAll(start);
2756
2857
  const permissions = await c.permissions.listAll(start);
2757
2858
  const roles = await c.roles.listAll(start);
@@ -2807,9 +2908,29 @@ var ManifestApi = class {
2807
2908
  roleUserBindings,
2808
2909
  roleGroupBindings,
2809
2910
  roleServiceAccountBindings,
2810
- groupMembers
2911
+ groupMembers,
2912
+ network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
2811
2913
  };
2812
2914
  }
2915
+ /**
2916
+ * §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
2917
+ * list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
2918
+ * A section that states no policy does not read it; one that states no
2919
+ * profile does not list them.
2920
+ */
2921
+ async #readNetwork(spec, start) {
2922
+ const c = this.#client;
2923
+ const policy = spec.policy ? await c.network.getPolicy() : void 0;
2924
+ const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
2925
+ const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
2926
+ const profiles = /* @__PURE__ */ new Map();
2927
+ if ((spec.profiles ?? []).length) {
2928
+ for (const profile of await c.network.listProfilesAll(start)) {
2929
+ profiles.set(profile.segment_id, profile);
2930
+ }
2931
+ }
2932
+ return { policy, segments, profiles };
2933
+ }
2813
2934
  // -------------------------------------------------------------------
2814
2935
  // Plan
2815
2936
  // -------------------------------------------------------------------
@@ -3080,8 +3201,97 @@ var ManifestApi = class {
3080
3201
  push
3081
3202
  );
3082
3203
  }
3204
+ if (manifest.network && snapshot.network) {
3205
+ this.#networkSteps(manifest.network, snapshot.network, resolved, push);
3206
+ }
3083
3207
  return out;
3084
3208
  }
3209
+ /**
3210
+ * §27.6.2 — the `network` section: the policy, then the segments, then the
3211
+ * profiles, a profile after its segment (item 2). Every comparison is with
3212
+ * the value **as the read returns it** (item 3): a profile's effective
3213
+ * (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
3214
+ * Silence is not an assertion (rule 3): a member left off never drifts, and
3215
+ * the `Update` body carries the read's value for it (item 4).
3216
+ */
3217
+ #networkSteps(spec, read, resolved, push) {
3218
+ if (spec.policy) {
3219
+ const current = read.policy;
3220
+ const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
3221
+ push(
3222
+ drifted ? "update" : "no-change",
3223
+ "network-policy",
3224
+ "network.policy",
3225
+ "network policy (Session-Timeout cap)",
3226
+ drifted ? {
3227
+ kind: "update-network-policy",
3228
+ body: {
3229
+ session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
3230
+ version: current.version
3231
+ }
3232
+ } : { kind: "noop" }
3233
+ );
3234
+ }
3235
+ const segments = spec.segments ?? [];
3236
+ for (const segment of segments) {
3237
+ const found = read.segments.find(
3238
+ (r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
3239
+ );
3240
+ const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3241
+ if (!found) {
3242
+ push("create", "network-segment", segment.key, summary, {
3243
+ kind: "create-network-segment",
3244
+ key: segment.key,
3245
+ body: segmentCreateBody(segment)
3246
+ });
3247
+ continue;
3248
+ }
3249
+ resolved.segments.set(segment.key, found.id);
3250
+ resolved.segmentVersions.set(segment.key, found.version);
3251
+ const drifted = segmentDrifted(segment, found);
3252
+ push(
3253
+ drifted ? "update" : "no-change",
3254
+ "network-segment",
3255
+ segment.key,
3256
+ summary,
3257
+ drifted ? {
3258
+ kind: "update-network-segment",
3259
+ key: segment.key,
3260
+ id: found.id,
3261
+ body: segmentReplaceBody(segment, found)
3262
+ } : { kind: "noop" }
3263
+ );
3264
+ }
3265
+ const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
3266
+ for (const segment of segments) {
3267
+ const profile = bySegment.get(segment.key);
3268
+ if (!profile) continue;
3269
+ const segmentId = resolved.segments.get(segment.key);
3270
+ const found = segmentId ? read.profiles.get(segmentId) : void 0;
3271
+ const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3272
+ if (!found) {
3273
+ push("create", "network-profile", segment.key, summary, {
3274
+ kind: "create-network-profile",
3275
+ segment: segment.key,
3276
+ profile: profileCreateInput(profile)
3277
+ });
3278
+ continue;
3279
+ }
3280
+ const drifted = profileDrifted(profile, found);
3281
+ push(
3282
+ drifted ? "update" : "no-change",
3283
+ "network-profile",
3284
+ segment.key,
3285
+ summary,
3286
+ drifted ? {
3287
+ kind: "update-network-profile",
3288
+ segment: segment.key,
3289
+ version: found.version,
3290
+ profile: profileReplaceInput(profile, found)
3291
+ } : { kind: "noop" }
3292
+ );
3293
+ }
3294
+ }
3085
3295
  /**
3086
3296
  * §27.6.1 item 2 — one subject's `roles[]` against the server's existing
3087
3297
  * bindings for it. Shared by groups, users and service accounts: the
@@ -3149,9 +3359,14 @@ var ManifestApi = class {
3149
3359
  }
3150
3360
  } catch (err) {
3151
3361
  stopped = true;
3362
+ const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
3152
3363
  out.push({
3153
3364
  action,
3154
- outcome: { status: "failed", message: err instanceof Error ? err.message : String(err) }
3365
+ outcome: {
3366
+ status: "failed",
3367
+ message: err instanceof Error ? err.message : String(err),
3368
+ ...reasonCode === void 0 ? {} : { reasonCode }
3369
+ }
3155
3370
  });
3156
3371
  }
3157
3372
  }
@@ -3258,6 +3473,34 @@ var ManifestApi = class {
3258
3473
  description: step.description
3259
3474
  });
3260
3475
  return void 0;
3476
+ case "update-network-policy":
3477
+ await c.network.replacePolicy(step.body);
3478
+ return void 0;
3479
+ case "create-network-segment": {
3480
+ const created = await c.network.createSegment(step.body);
3481
+ resolved.segments.set(step.key, created.id);
3482
+ resolved.segmentVersions.set(step.key, created.version);
3483
+ return void 0;
3484
+ }
3485
+ case "update-network-segment": {
3486
+ const replaced = await c.network.replaceSegment(step.id, step.body);
3487
+ resolved.segmentVersions.set(step.key, replaced.version);
3488
+ return void 0;
3489
+ }
3490
+ case "create-network-profile":
3491
+ await c.network.createProfile({
3492
+ segment_id: lookup(resolved.segments, step.segment, "network segment"),
3493
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3494
+ profile: step.profile
3495
+ });
3496
+ return void 0;
3497
+ case "update-network-profile":
3498
+ await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
3499
+ version: step.version,
3500
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3501
+ profile: step.profile
3502
+ });
3503
+ return void 0;
3261
3504
  case "assign-role":
3262
3505
  await this.#assign(step, resolved);
3263
3506
  return void 0;
@@ -3395,6 +3638,94 @@ function lookup(map, key, kind) {
3395
3638
  }
3396
3639
  return id;
3397
3640
  }
3641
+ function hasShapeSections(manifest) {
3642
+ return [
3643
+ manifest.resources,
3644
+ manifest.permissions,
3645
+ manifest.roles,
3646
+ manifest.groups,
3647
+ manifest.users,
3648
+ manifest.serviceAccounts
3649
+ ].some((section) => (section ?? []).length > 0);
3650
+ }
3651
+ function lookupVersion(map, key) {
3652
+ const version = map.get(key);
3653
+ if (version === void 0) {
3654
+ throw new NetworkError(
3655
+ `internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
3656
+ );
3657
+ }
3658
+ return version;
3659
+ }
3660
+ function sameSet(a, b) {
3661
+ if (a.length !== b.length) return false;
3662
+ const left = new Set(a);
3663
+ return left.size === new Set(b).size && b.every((name2) => left.has(name2));
3664
+ }
3665
+ function sameOptional(stated, read) {
3666
+ return (stated ?? null) === (read ?? null);
3667
+ }
3668
+ function segmentCreateBody(spec) {
3669
+ const body = {
3670
+ kind: spec.kind,
3671
+ site_key: spec.site,
3672
+ name: spec.name,
3673
+ vlan_id: spec.vlanId
3674
+ };
3675
+ if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
3676
+ if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
3677
+ if (spec.enabled !== void 0) body.enabled = spec.enabled;
3678
+ return body;
3679
+ }
3680
+ function segmentDrifted(spec, read) {
3681
+ if (spec.vlanId !== read.vlan_id) return true;
3682
+ if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
3683
+ if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
3684
+ if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
3685
+ return false;
3686
+ }
3687
+ function segmentReplaceBody(spec, read) {
3688
+ const body = {
3689
+ version: read.version,
3690
+ vlan_id: spec.vlanId,
3691
+ filter_ids: [...spec.filterIds ?? read.filter_ids],
3692
+ enabled: spec.enabled ?? read.enabled
3693
+ };
3694
+ const rank = spec.rank === void 0 ? read.rank : spec.rank;
3695
+ if (rank !== void 0 && rank !== null) body.rank = rank;
3696
+ return body;
3697
+ }
3698
+ function profileCreateInput(spec) {
3699
+ const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
3700
+ if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
3701
+ if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
3702
+ if (spec.filterId != null) profile.filter_id = spec.filterId;
3703
+ if (spec.serviceType != null) profile.service_type = spec.serviceType;
3704
+ return profile;
3705
+ }
3706
+ function profileDrifted(spec, read) {
3707
+ if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
3708
+ if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
3709
+ if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
3710
+ if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
3711
+ if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
3712
+ return false;
3713
+ }
3714
+ function profileReplaceInput(spec, read) {
3715
+ const profile = {
3716
+ dictionary: read.dictionary,
3717
+ session_timeout_secs: spec.sessionTimeoutSecs
3718
+ };
3719
+ const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
3720
+ if (termination != null) profile.termination_action = termination;
3721
+ const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
3722
+ if (idle != null) profile.idle_timeout_secs = idle;
3723
+ const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
3724
+ if (filter != null) profile.filter_id = filter;
3725
+ const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
3726
+ if (serviceType != null) profile.service_type = serviceType;
3727
+ return profile;
3728
+ }
3398
3729
  function bindingOf(assignment) {
3399
3730
  return {
3400
3731
  resourceId: assignment.resource_id ?? void 0,
@@ -3515,7 +3846,12 @@ function mapManagementError(operation, err) {
3515
3846
  );
3516
3847
  }
3517
3848
  if (status === 409) {
3518
- return new ConflictError(operation, `${operation}: conflict${detail}`);
3849
+ const code = body?.reason_code;
3850
+ return new ConflictError(
3851
+ operation,
3852
+ `${operation}: conflict${detail}`,
3853
+ typeof code === "string" ? code : void 0
3854
+ );
3519
3855
  }
3520
3856
  if (status === 400 || status === 422) {
3521
3857
  return new ValidationError(
@@ -3525,7 +3861,7 @@ function mapManagementError(operation, err) {
3525
3861
  parseFieldErrors(body)
3526
3862
  );
3527
3863
  }
3528
- return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
3864
+ return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
3529
3865
  }
3530
3866
  function describe(body) {
3531
3867
  if (typeof body === "string" && body) return `: ${body}`;
@@ -4819,7 +5155,7 @@ var CertificatesApi = class {
4819
5155
  method: "POST",
4820
5156
  pathTemplate: "/api/v1/certificates",
4821
5157
  path: "/api/v1/certificates",
4822
- body
5158
+ body: omitNullMembers(body, ["user_id"])
4823
5159
  });
4824
5160
  return generatedCertificateFromWire(wire);
4825
5161
  }
@@ -4836,7 +5172,7 @@ var CertificatesApi = class {
4836
5172
  method: "POST",
4837
5173
  pathTemplate: "/api/v1/certificates/sign-csr",
4838
5174
  path: "/api/v1/certificates/sign-csr",
4839
- body
5175
+ body: omitNullMembers(body, ["user_id"])
4840
5176
  });
4841
5177
  return wire;
4842
5178
  }
@@ -5973,12 +6309,29 @@ function ssfStreamInputFrom(stream) {
5973
6309
  endpoint_url: stream.endpoint_url ?? null,
5974
6310
  events_allowed: [...stream.events_allowed],
5975
6311
  events_requested: [...stream.events_requested],
6312
+ expected_updated_at: stream.updated_at,
5976
6313
  receiver_client_id: stream.receiver_client_id,
5977
6314
  status: stream.status,
5978
6315
  status_reason: stream.status_reason ?? null,
5979
6316
  subject_format: stream.subject_format
5980
6317
  };
5981
6318
  }
6319
+ function ssfStreamInputWith(stream, changes2 = {}) {
6320
+ const body = ssfStreamInputFrom(stream);
6321
+ const named = Object.entries(changes2).filter(([, v]) => v !== void 0);
6322
+ const record = body;
6323
+ for (const [key, value] of named) record[key] = value;
6324
+ const names = new Set(named.map(([key]) => key));
6325
+ if (names.has("events_allowed") && !names.has("events_requested")) {
6326
+ const ceiling = new Set(body.events_allowed);
6327
+ body.events_requested = stream.events_requested.filter(
6328
+ (e) => ceiling.has(e)
6329
+ );
6330
+ }
6331
+ if (body.events_requested === null) delete body.events_requested;
6332
+ if (body.expected_updated_at === null) delete body.expected_updated_at;
6333
+ return body;
6334
+ }
5982
6335
  function scimTargetInputFrom(target) {
5983
6336
  return {
5984
6337
  auth: { ...target.auth },
@@ -6302,7 +6655,7 @@ var SsfApi = class _SsfApi {
6302
6655
  method: "POST",
6303
6656
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
6304
6657
  path: `/api/v1/tenants/${tenantId}/ssf/streams`,
6305
- body: ssfStreamInputToWire(body)
6658
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6306
6659
  });
6307
6660
  return scrubSsfStream(wire);
6308
6661
  }
@@ -6325,8 +6678,19 @@ var SsfApi = class _SsfApi {
6325
6678
  * update moves `endpoint_url` to another scheme, host or port while a header
6326
6679
  * is stored: then it must carry `authorization_header` again or
6327
6680
  * `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
6328
- * `ssfStreamInputFrom(await ssf.getStream(id))`. An update overtaken by the
6329
- * receiver's own write is `409`: read the stream again.
6681
+ * `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
6682
+ * `events_requested` and `expected_updated_at` it read and cuts
6683
+ * `events_requested` to a lowered `events_allowed` (or from the plain
6684
+ * converter `ssfStreamInputFrom`, where the cut is yours). An update
6685
+ * overtaken by the receiver's own write is `409`: read the stream again.
6686
+ * **`events_requested` has three meanings on an update** (§32.2, contract
6687
+ * 1.62): **absent resets** the stream to every event of `events_allowed` —
6688
+ * widening what the receiver narrowed; **`[]` is stored as the receiver's
6689
+ * "none"** and the stream carries nothing; **a list is stored as given** and
6690
+ * refused (`400`) if any entry is outside `events_allowed`. A raw API client
6691
+ * is bound by the same meaning: an `events_requested` left out of the `PUT`
6692
+ * resets the stream. `expected_updated_at` is the `updated_at` you read, as
6693
+ * the server's own string; an assigned `null` is "none" and is not sent.
6330
6694
  *
6331
6695
  * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6332
6696
  * members must be set, but what you do not carry over from a prior read is
@@ -6344,7 +6708,7 @@ var SsfApi = class _SsfApi {
6344
6708
  method: "PUT",
6345
6709
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
6346
6710
  path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
6347
- body: ssfStreamInputToWire(body)
6711
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6348
6712
  });
6349
6713
  return scrubSsfStream(wire);
6350
6714
  }
@@ -6412,7 +6776,7 @@ var ScimTargetsApi = class {
6412
6776
  method: "POST",
6413
6777
  pathTemplate: "/api/v1/scim-targets",
6414
6778
  path: "/api/v1/scim-targets",
6415
- body: scimTargetInputToWire(body)
6779
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6416
6780
  });
6417
6781
  return scrubScimTargetResponse(wire);
6418
6782
  }
@@ -6459,7 +6823,7 @@ var ScimTargetsApi = class {
6459
6823
  method: "PUT",
6460
6824
  pathTemplate: "/api/v1/scim-targets/{id}",
6461
6825
  path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
6462
- body: scimTargetInputToWire(body)
6826
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6463
6827
  });
6464
6828
  return scrubScimTargetResponse(wire);
6465
6829
  }
@@ -6503,6 +6867,215 @@ var ScimTargetsApi = class {
6503
6867
  }
6504
6868
  };
6505
6869
 
6870
+ // src/management/ops/network.ts
6871
+ var NetworkApi = class {
6872
+ #client;
6873
+ #scope;
6874
+ /** @internal — reached through `client.<namespace>`, never constructed directly. */
6875
+ constructor(client, scope = {}) {
6876
+ this.#client = client;
6877
+ this.#scope = scope;
6878
+ }
6879
+ /** `GET /api/v1/network/segments` */
6880
+ async listSegments(site, page = {}) {
6881
+ const wire = await sendManagement(this.#client, {
6882
+ operation: "network.list_segments",
6883
+ method: "GET",
6884
+ pathTemplate: "/api/v1/network/segments",
6885
+ path: "/api/v1/network/segments",
6886
+ query: { ...pageQuery(page), "site": site }
6887
+ });
6888
+ return wire;
6889
+ }
6890
+ /**
6891
+ * Walk `network.list_segments` to exhaustion, concatenating every page.
6892
+ *
6893
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
6894
+ * if `total` disagrees, so a misreporting server costs one wasted request
6895
+ * rather than an unbounded loop.
6896
+ */
6897
+ listSegmentsAll(site, start = {}) {
6898
+ return collectPages(start, (p) => this.listSegments(site, p));
6899
+ }
6900
+ /**
6901
+ * `POST /api/v1/network/segments`
6902
+ *
6903
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6904
+ * issued exactly once, including the ones that look idempotent.
6905
+ */
6906
+ async createSegment(body) {
6907
+ const wire = await sendManagement(this.#client, {
6908
+ operation: "network.create_segment",
6909
+ method: "POST",
6910
+ pathTemplate: "/api/v1/network/segments",
6911
+ path: "/api/v1/network/segments",
6912
+ body
6913
+ });
6914
+ return wire;
6915
+ }
6916
+ /** `GET /api/v1/network/segments/{id}` */
6917
+ async getSegment(id) {
6918
+ const wire = await sendManagement(this.#client, {
6919
+ operation: "network.get_segment",
6920
+ method: "GET",
6921
+ pathTemplate: "/api/v1/network/segments/{id}",
6922
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`
6923
+ });
6924
+ return wire;
6925
+ }
6926
+ /**
6927
+ * `PUT /api/v1/network/segments/{id}`
6928
+ *
6929
+ * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6930
+ * members must be set, but what you do not carry over from a prior read is
6931
+ * not preserved: an optional member left out is overwritten with its
6932
+ * default, not kept (except where noted above). Read first, change the field
6933
+ * you mean, send the whole thing back.
6934
+ *
6935
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6936
+ * issued exactly once, including the ones that look idempotent.
6937
+ */
6938
+ async replaceSegment(id, body) {
6939
+ const wire = await sendManagement(this.#client, {
6940
+ operation: "network.replace_segment",
6941
+ method: "PUT",
6942
+ pathTemplate: "/api/v1/network/segments/{id}",
6943
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
6944
+ body
6945
+ });
6946
+ return wire;
6947
+ }
6948
+ /**
6949
+ * `DELETE /api/v1/network/segments/{id}`
6950
+ *
6951
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6952
+ * issued exactly once, including the ones that look idempotent.
6953
+ */
6954
+ async deleteSegment(id, version) {
6955
+ await sendManagement(this.#client, {
6956
+ operation: "network.delete_segment",
6957
+ method: "DELETE",
6958
+ pathTemplate: "/api/v1/network/segments/{id}",
6959
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
6960
+ query: { "version": String(version) }
6961
+ });
6962
+ }
6963
+ /** `GET /api/v1/network/profiles` */
6964
+ async listProfiles(page = {}) {
6965
+ const wire = await sendManagement(this.#client, {
6966
+ operation: "network.list_profiles",
6967
+ method: "GET",
6968
+ pathTemplate: "/api/v1/network/profiles",
6969
+ path: "/api/v1/network/profiles",
6970
+ query: { ...pageQuery(page) }
6971
+ });
6972
+ return wire;
6973
+ }
6974
+ /**
6975
+ * Walk `network.list_profiles` to exhaustion, concatenating every page.
6976
+ *
6977
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
6978
+ * if `total` disagrees, so a misreporting server costs one wasted request
6979
+ * rather than an unbounded loop.
6980
+ */
6981
+ listProfilesAll(start = {}) {
6982
+ return collectPages(start, (p) => this.listProfiles(p));
6983
+ }
6984
+ /**
6985
+ * `POST /api/v1/network/profiles`
6986
+ *
6987
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6988
+ * issued exactly once, including the ones that look idempotent.
6989
+ */
6990
+ async createProfile(body) {
6991
+ const wire = await sendManagement(this.#client, {
6992
+ operation: "network.create_profile",
6993
+ method: "POST",
6994
+ pathTemplate: "/api/v1/network/profiles",
6995
+ path: "/api/v1/network/profiles",
6996
+ body
6997
+ });
6998
+ return wire;
6999
+ }
7000
+ /** `GET /api/v1/network/profiles/{segment_id}` */
7001
+ async getProfile(segmentId) {
7002
+ const wire = await sendManagement(this.#client, {
7003
+ operation: "network.get_profile",
7004
+ method: "GET",
7005
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7006
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
7007
+ });
7008
+ return wire;
7009
+ }
7010
+ /**
7011
+ * `PUT /api/v1/network/profiles/{segment_id}`
7012
+ *
7013
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7014
+ * body is required, and what you do not carry over from a prior read is not
7015
+ * preserved — it is overwritten. Read first, change the field you mean, send
7016
+ * the whole thing back.
7017
+ *
7018
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7019
+ * issued exactly once, including the ones that look idempotent.
7020
+ */
7021
+ async replaceProfile(segmentId, body) {
7022
+ const wire = await sendManagement(this.#client, {
7023
+ operation: "network.replace_profile",
7024
+ method: "PUT",
7025
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7026
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7027
+ body
7028
+ });
7029
+ return wire;
7030
+ }
7031
+ /**
7032
+ * `DELETE /api/v1/network/profiles/{segment_id}`
7033
+ *
7034
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7035
+ * issued exactly once, including the ones that look idempotent.
7036
+ */
7037
+ async deleteProfile(segmentId, version) {
7038
+ await sendManagement(this.#client, {
7039
+ operation: "network.delete_profile",
7040
+ method: "DELETE",
7041
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7042
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7043
+ query: { "version": String(version) }
7044
+ });
7045
+ }
7046
+ /** `GET /api/v1/network/policy` */
7047
+ async getPolicy() {
7048
+ const wire = await sendManagement(this.#client, {
7049
+ operation: "network.get_policy",
7050
+ method: "GET",
7051
+ pathTemplate: "/api/v1/network/policy",
7052
+ path: "/api/v1/network/policy"
7053
+ });
7054
+ return wire;
7055
+ }
7056
+ /**
7057
+ * `PUT /api/v1/network/policy`
7058
+ *
7059
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7060
+ * body is required, and what you do not carry over from a prior read is not
7061
+ * preserved — it is overwritten. Read first, change the field you mean, send
7062
+ * the whole thing back.
7063
+ *
7064
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7065
+ * issued exactly once, including the ones that look idempotent.
7066
+ */
7067
+ async replacePolicy(body) {
7068
+ const wire = await sendManagement(this.#client, {
7069
+ operation: "network.replace_policy",
7070
+ method: "PUT",
7071
+ pathTemplate: "/api/v1/network/policy",
7072
+ path: "/api/v1/network/policy",
7073
+ body
7074
+ });
7075
+ return wire;
7076
+ }
7077
+ };
7078
+
6506
7079
  // src/management/ops/settings.ts
6507
7080
  var SettingsApi = class _SettingsApi {
6508
7081
  #client;
@@ -7127,6 +7700,9 @@ function managementNamespaces(client) {
7127
7700
  get scimTargets() {
7128
7701
  return new ScimTargetsApi(client);
7129
7702
  },
7703
+ get network() {
7704
+ return new NetworkApi(client);
7705
+ },
7130
7706
  get settings() {
7131
7707
  return new SettingsApi(client);
7132
7708
  },
@@ -7820,6 +8396,6 @@ function name(cls) {
7820
8396
  return typeof cls === "function" && cls.name ? cls.name : String(cls);
7821
8397
  }
7822
8398
 
7823
- export { AuditApi, AuthError, AuthzError, AxiamClient, AxiamError, AxiamGrant, AxiamGroup, AxiamPermission, AxiamResource, AxiamRole, AxiamScope, AxiamServiceAccount, AxiamUser, BASE_DELAY_MS, CaCertificatesApi, CertificatesApi, ConflictError, DecisionMemo, DirectoryApi, EmailConfigApi, FederationApi, GroupsApi, KNOWN_SCIM_TARGET_AUTH_TYPES, KNOWN_SCIM_TARGET_SCOPE_TYPES, MAX_ATTEMPTS, MAX_DELAY_MS, MAX_TTL_MS, ManifestApi, NetworkError, NotFoundError, NotificationRulesApi, OAuthProtocolError, Oauth2ClientsApi, OpaqueUnavailableError, OrganizationsApi, PermissionsApi, PgpKeysApi, PlatformApi, PrivacyApi, ReactorsApi, ResourcesApi, RolesApi, SKIP_REFRESH, SamlApi, ScimTargetsApi, ScimTokensApi, ScopesApi, Sensitive, ServiceAccountsApi, SettingsApi, SharedSession, SsfApi, TelemetryDispatcher, TelemetryReporter, TenantsApi, UsersApi, ValidationError, WebauthnPolicyApi, WebhooksApi, assertKnownScimTargetAuth, assertKnownScimTargetScope, assertParseSpMetadataExactlyOne, assertValidSubjectAltName, assertValidSubjectAltNameList, backoffMs, changedCount, changes, classifyWebauthnError, clientRegistrationFromJson, collectManifest, collectPages, createFederationConfigRequestToWire, createRegistrationTokenResponseFromWire, createScimTokenResponseFromWire, createUserRequestToWire, createWebhookRequestToWire, defineManifest, delayMs, failure, generatedCaCertificateFromWire, generatedCertificateFromWire, generatedPgpKeyFromWire, hasMore, importCaCertificateRequestToWire, inheritOf, isComplete, isConverged, managementNamespaces, memoKey, normalizeSearch, oAuth2ClientCreatedResponseFromWire, omitEmptyTenantScope, opaqueAvailable, opaqueEnrollment, opaqueEnrollmentForSelf, pageQuery, parseFieldErrors, parseSpMetadataFromUrl, parseSpMetadataFromXml, resourceKeyOf, roleAssignmentInherits, roleKeyOf, rotateSecretResponseFromWire, samlServiceProviderInputFrom, scimTargetInputFrom, scimTargetInputToWire, scrubDirectoryConfig, scrubDirectoryLinkResult, scrubDirectorySyncStatus, scrubSamlIdpCredential, scrubSamlIdpCredentialPromotion, scrubSamlIdpInfo, scrubSamlServiceProvider, scrubSamlSpMetadataDraft, scrubScimReconcileAccepted, scrubScimTargetResponse, scrubSsfStream, serviceAccountCreatedResponseFromWire, setDirectoryConfigFrom, setDirectoryConfigToWire, ssfStreamInputFrom, ssfStreamInputToWire, topologicalOrder, updateDirectoryConfigToWire, updateFederationConfigRequestToWire, updateWebhookRequestToWire, validate, webauthnErrorMessage, webauthnRequestJson, withFederationConfigResponseDefaults, withRetry };
8399
+ export { AuditApi, AuthError, AuthzError, AxiamClient, AxiamError, AxiamGrant, AxiamGroup, AxiamPermission, AxiamResource, AxiamRole, AxiamScope, AxiamServiceAccount, AxiamUser, BASE_DELAY_MS, CaCertificatesApi, CertificatesApi, ConflictError, DecisionMemo, DirectoryApi, EmailConfigApi, FederationApi, GroupsApi, KNOWN_SCIM_TARGET_AUTH_TYPES, KNOWN_SCIM_TARGET_SCOPE_TYPES, MAX_ATTEMPTS, MAX_DELAY_MS, MAX_TTL_MS, ManifestApi, NetworkApi, NetworkError, NotFoundError, NotificationRulesApi, OAuthProtocolError, Oauth2ClientsApi, OpaqueUnavailableError, OrganizationsApi, PermissionsApi, PgpKeysApi, PlatformApi, PrivacyApi, ReactorsApi, ResourcesApi, RolesApi, SKIP_REFRESH, SamlApi, ScimTargetsApi, ScimTokensApi, ScopesApi, Sensitive, ServiceAccountsApi, SettingsApi, SharedSession, SsfApi, TelemetryDispatcher, TelemetryReporter, TenantsApi, UsersApi, ValidationError, WebauthnPolicyApi, WebhooksApi, assertKnownScimTargetAuth, assertKnownScimTargetScope, assertParseSpMetadataExactlyOne, assertValidSubjectAltName, assertValidSubjectAltNameList, backoffMs, changedCount, changes, classifyWebauthnError, clientRegistrationFromJson, collectManifest, collectPages, createFederationConfigRequestToWire, createRegistrationTokenResponseFromWire, createScimTokenResponseFromWire, createUserRequestToWire, createWebhookRequestToWire, defineManifest, delayMs, failure, generatedCaCertificateFromWire, generatedCertificateFromWire, generatedPgpKeyFromWire, hasMore, importCaCertificateRequestToWire, inheritOf, isComplete, isConverged, managementNamespaces, memoKey, normalizeSearch, oAuth2ClientCreatedResponseFromWire, omitEmptyTenantScope, omitNullMembers, opaqueAvailable, opaqueEnrollment, opaqueEnrollmentForSelf, pageQuery, parseFieldErrors, parseSpMetadataFromUrl, parseSpMetadataFromXml, resourceKeyOf, roleAssignmentInherits, roleKeyOf, rotateSecretResponseFromWire, samlServiceProviderInputFrom, scimTargetInputFrom, scimTargetInputToWire, scrubDirectoryConfig, scrubDirectoryLinkResult, scrubDirectorySyncStatus, scrubSamlIdpCredential, scrubSamlIdpCredentialPromotion, scrubSamlIdpInfo, scrubSamlServiceProvider, scrubSamlSpMetadataDraft, scrubScimReconcileAccepted, scrubScimTargetResponse, scrubSsfStream, serviceAccountCreatedResponseFromWire, setDirectoryConfigFrom, setDirectoryConfigToWire, ssfStreamInputFrom, ssfStreamInputToWire, ssfStreamInputWith, topologicalOrder, updateDirectoryConfigToWire, updateFederationConfigRequestToWire, updateWebhookRequestToWire, validate, webauthnErrorMessage, webauthnRequestJson, withFederationConfigResponseDefaults, withRetry };
7824
8400
  //# sourceMappingURL=index.mjs.map
7825
8401
  //# sourceMappingURL=index.mjs.map