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
@@ -788,6 +788,12 @@ var SKIP_REFRESH = [
788
788
  // regardless of what session state came before it.
789
789
  "/api/v1/auth/device",
790
790
  "/oauth2/token",
791
+ // CONTRACT.md §14.2 rule 5 (contract 1.62): a client that fails to
792
+ // authenticate at the device endpoints is `401 invalid_client`, which is not
793
+ // an expired session and which refreshing cannot fix. `/oauth2/token` (the
794
+ // poll) was already here; the authorization endpoint now authenticates the
795
+ // client too, so its 401 must not enter the §9 guard either.
796
+ "/oauth2/device_authorization",
791
797
  "/oauth2/introspect",
792
798
  "/oauth2/revoke"
793
799
  ];
@@ -849,6 +855,13 @@ function installRefreshInterceptor(axiosInstance, session) {
849
855
  }
850
856
  );
851
857
  }
858
+ function isOAuth2Endpoint(url) {
859
+ if (!url) {
860
+ return false;
861
+ }
862
+ const path = url.split(/[?#]/, 1)[0] ?? "";
863
+ return path.includes("/oauth2/");
864
+ }
852
865
  function installDeviceTokenInterceptor(axiosInstance, session) {
853
866
  axiosInstance.interceptors.request.use((config) => {
854
867
  const deviceToken = session.deviceAccessToken;
@@ -858,6 +871,9 @@ function installDeviceTokenInterceptor(axiosInstance, session) {
858
871
  const noCred = session.noCredentialsConfig();
859
872
  Object.assign(config, noCred);
860
873
  config.headers = config.headers ?? {};
874
+ if (isOAuth2Endpoint(config.url)) {
875
+ return config;
876
+ }
861
877
  config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
862
878
  config.headers["Cookie"] = "";
863
879
  return config;
@@ -1816,10 +1832,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
1816
1832
  var ConflictError = class _ConflictError extends AuthzError {
1817
1833
  /** The registry operation that conflicted. */
1818
1834
  operation;
1819
- constructor(operation, message) {
1835
+ /**
1836
+ * The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
1837
+ * or `undefined` when the body carries none (a server that predates it, or a
1838
+ * `409` of an operation that does not name one).
1839
+ *
1840
+ * The `409` of every `network` operation says which conflict it is:
1841
+ * `stale_version`, `strands_profile`, `has_children`, `site_gone`,
1842
+ * `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
1843
+ * `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
1844
+ * not know is surfaced verbatim, and a caller branches on this member —
1845
+ * never on `message`, which an SDK must not parse. It is not the `reason` of
1846
+ * an authorization decision (§3), which is a human string.
1847
+ */
1848
+ reasonCode;
1849
+ constructor(operation, message, reasonCode) {
1820
1850
  super(message);
1821
1851
  this.name = "ConflictError";
1822
1852
  this.operation = operation;
1853
+ this.reasonCode = reasonCode;
1823
1854
  Object.setPrototypeOf(this, _ConflictError.prototype);
1824
1855
  }
1825
1856
  };
@@ -2108,6 +2139,14 @@ function omitEmptyTenantScope(body) {
2108
2139
  }
2109
2140
  return body;
2110
2141
  }
2142
+ function omitNullMembers(body, members) {
2143
+ if (!body || typeof body !== "object") return body;
2144
+ const record = body;
2145
+ if (!members.some((m) => m in record && record[m] === null)) return body;
2146
+ const copy = { ...record };
2147
+ for (const m of members) if (copy[m] === null) delete copy[m];
2148
+ return copy;
2149
+ }
2111
2150
  function roleAssignmentInherits(assignment) {
2112
2151
  return assignment.inherit ?? true;
2113
2152
  }
@@ -2580,6 +2619,7 @@ function validate(manifest) {
2580
2619
  const groups = manifest.groups ?? [];
2581
2620
  const users = manifest.users ?? [];
2582
2621
  const serviceAccounts = manifest.serviceAccounts ?? [];
2622
+ const network = manifest.network;
2583
2623
  const resourceKeys = new Set(resources.map((r) => r.key));
2584
2624
  const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
2585
2625
  const permissionKeys = new Set(permissions.map((p) => p.key));
@@ -2593,6 +2633,7 @@ function validate(manifest) {
2593
2633
  duplicates("group", groups.map((g) => g.key), problems);
2594
2634
  duplicates("user", users.map((u) => u.key), problems);
2595
2635
  duplicates("service account", serviceAccounts.map((s) => s.key), problems);
2636
+ if (network !== void 0) validateNetwork(network, problems);
2596
2637
  for (const resource of resources) {
2597
2638
  if (resource.parent && !resourceKeys.has(resource.parent)) {
2598
2639
  problems.push(
@@ -2672,6 +2713,46 @@ function validate(manifest) {
2672
2713
  }
2673
2714
  }
2674
2715
  var q = (s) => JSON.stringify(s);
2716
+ function validateNetwork(network, problems) {
2717
+ if (Array.isArray(network.policy)) {
2718
+ problems.push("network declares more than one policy; the tenant has exactly one");
2719
+ }
2720
+ const segments = network.segments ?? [];
2721
+ const profiles = network.profiles ?? [];
2722
+ duplicates("network segment", segments.map((s) => s.key), problems);
2723
+ const naturalKeys = /* @__PURE__ */ new Set();
2724
+ for (const segment of segments) {
2725
+ const natural = `${segment.site}/${segment.kind}/${segment.name}`;
2726
+ if (naturalKeys.has(natural)) {
2727
+ problems.push(
2728
+ `network segment ${q(natural)} (site, kind, name) is declared more than once`
2729
+ );
2730
+ }
2731
+ naturalKeys.add(natural);
2732
+ const seenFilters = /* @__PURE__ */ new Set();
2733
+ for (const filter of segment.filterIds ?? []) {
2734
+ if (seenFilters.has(filter)) {
2735
+ problems.push(
2736
+ `network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
2737
+ );
2738
+ }
2739
+ seenFilters.add(filter);
2740
+ }
2741
+ }
2742
+ const segmentKeys = new Set(segments.map((s) => s.key));
2743
+ const profiled = /* @__PURE__ */ new Set();
2744
+ for (const profile of profiles) {
2745
+ if (!segmentKeys.has(profile.segment)) {
2746
+ problems.push(
2747
+ `network profile names segment ${q(profile.segment)}, which no network segment declares`
2748
+ );
2749
+ }
2750
+ if (profiled.has(profile.segment)) {
2751
+ problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
2752
+ }
2753
+ profiled.add(profile.segment);
2754
+ }
2755
+ }
2675
2756
  function duplicates(kind, keys, problems) {
2676
2757
  const seen = /* @__PURE__ */ new Set();
2677
2758
  for (const key of keys) {
@@ -2717,7 +2798,9 @@ var emptyResolved = () => ({
2717
2798
  roles: /* @__PURE__ */ new Map(),
2718
2799
  groups: /* @__PURE__ */ new Map(),
2719
2800
  users: /* @__PURE__ */ new Map(),
2720
- serviceAccounts: /* @__PURE__ */ new Map()
2801
+ serviceAccounts: /* @__PURE__ */ new Map(),
2802
+ segments: /* @__PURE__ */ new Map(),
2803
+ segmentVersions: /* @__PURE__ */ new Map()
2721
2804
  });
2722
2805
  var ManifestApi = class {
2723
2806
  #client;
@@ -2750,6 +2833,23 @@ var ManifestApi = class {
2750
2833
  async #read(manifest) {
2751
2834
  const c = this.#client;
2752
2835
  const start = { limit: PLAN_PAGE };
2836
+ if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
2837
+ return {
2838
+ resources: [],
2839
+ scopes: /* @__PURE__ */ new Map(),
2840
+ permissions: [],
2841
+ roles: [],
2842
+ groups: [],
2843
+ users: [],
2844
+ serviceAccounts: [],
2845
+ roleGrants: /* @__PURE__ */ new Map(),
2846
+ roleUserBindings: /* @__PURE__ */ new Map(),
2847
+ roleGroupBindings: /* @__PURE__ */ new Map(),
2848
+ roleServiceAccountBindings: /* @__PURE__ */ new Map(),
2849
+ groupMembers: /* @__PURE__ */ new Map(),
2850
+ network: await this.#readNetwork(manifest.network, start)
2851
+ };
2852
+ }
2753
2853
  const resources = await c.resources.listAll(start);
2754
2854
  const permissions = await c.permissions.listAll(start);
2755
2855
  const roles = await c.roles.listAll(start);
@@ -2805,9 +2905,29 @@ var ManifestApi = class {
2805
2905
  roleUserBindings,
2806
2906
  roleGroupBindings,
2807
2907
  roleServiceAccountBindings,
2808
- groupMembers
2908
+ groupMembers,
2909
+ network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
2809
2910
  };
2810
2911
  }
2912
+ /**
2913
+ * §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
2914
+ * list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
2915
+ * A section that states no policy does not read it; one that states no
2916
+ * profile does not list them.
2917
+ */
2918
+ async #readNetwork(spec, start) {
2919
+ const c = this.#client;
2920
+ const policy = spec.policy ? await c.network.getPolicy() : void 0;
2921
+ const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
2922
+ const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
2923
+ const profiles = /* @__PURE__ */ new Map();
2924
+ if ((spec.profiles ?? []).length) {
2925
+ for (const profile of await c.network.listProfilesAll(start)) {
2926
+ profiles.set(profile.segment_id, profile);
2927
+ }
2928
+ }
2929
+ return { policy, segments, profiles };
2930
+ }
2811
2931
  // -------------------------------------------------------------------
2812
2932
  // Plan
2813
2933
  // -------------------------------------------------------------------
@@ -3078,8 +3198,97 @@ var ManifestApi = class {
3078
3198
  push
3079
3199
  );
3080
3200
  }
3201
+ if (manifest.network && snapshot.network) {
3202
+ this.#networkSteps(manifest.network, snapshot.network, resolved, push);
3203
+ }
3081
3204
  return out;
3082
3205
  }
3206
+ /**
3207
+ * §27.6.2 — the `network` section: the policy, then the segments, then the
3208
+ * profiles, a profile after its segment (item 2). Every comparison is with
3209
+ * the value **as the read returns it** (item 3): a profile's effective
3210
+ * (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
3211
+ * Silence is not an assertion (rule 3): a member left off never drifts, and
3212
+ * the `Update` body carries the read's value for it (item 4).
3213
+ */
3214
+ #networkSteps(spec, read, resolved, push) {
3215
+ if (spec.policy) {
3216
+ const current = read.policy;
3217
+ const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
3218
+ push(
3219
+ drifted ? "update" : "no-change",
3220
+ "network-policy",
3221
+ "network.policy",
3222
+ "network policy (Session-Timeout cap)",
3223
+ drifted ? {
3224
+ kind: "update-network-policy",
3225
+ body: {
3226
+ session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
3227
+ version: current.version
3228
+ }
3229
+ } : { kind: "noop" }
3230
+ );
3231
+ }
3232
+ const segments = spec.segments ?? [];
3233
+ for (const segment of segments) {
3234
+ const found = read.segments.find(
3235
+ (r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
3236
+ );
3237
+ const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3238
+ if (!found) {
3239
+ push("create", "network-segment", segment.key, summary, {
3240
+ kind: "create-network-segment",
3241
+ key: segment.key,
3242
+ body: segmentCreateBody(segment)
3243
+ });
3244
+ continue;
3245
+ }
3246
+ resolved.segments.set(segment.key, found.id);
3247
+ resolved.segmentVersions.set(segment.key, found.version);
3248
+ const drifted = segmentDrifted(segment, found);
3249
+ push(
3250
+ drifted ? "update" : "no-change",
3251
+ "network-segment",
3252
+ segment.key,
3253
+ summary,
3254
+ drifted ? {
3255
+ kind: "update-network-segment",
3256
+ key: segment.key,
3257
+ id: found.id,
3258
+ body: segmentReplaceBody(segment, found)
3259
+ } : { kind: "noop" }
3260
+ );
3261
+ }
3262
+ const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
3263
+ for (const segment of segments) {
3264
+ const profile = bySegment.get(segment.key);
3265
+ if (!profile) continue;
3266
+ const segmentId = resolved.segments.get(segment.key);
3267
+ const found = segmentId ? read.profiles.get(segmentId) : void 0;
3268
+ const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3269
+ if (!found) {
3270
+ push("create", "network-profile", segment.key, summary, {
3271
+ kind: "create-network-profile",
3272
+ segment: segment.key,
3273
+ profile: profileCreateInput(profile)
3274
+ });
3275
+ continue;
3276
+ }
3277
+ const drifted = profileDrifted(profile, found);
3278
+ push(
3279
+ drifted ? "update" : "no-change",
3280
+ "network-profile",
3281
+ segment.key,
3282
+ summary,
3283
+ drifted ? {
3284
+ kind: "update-network-profile",
3285
+ segment: segment.key,
3286
+ version: found.version,
3287
+ profile: profileReplaceInput(profile, found)
3288
+ } : { kind: "noop" }
3289
+ );
3290
+ }
3291
+ }
3083
3292
  /**
3084
3293
  * §27.6.1 item 2 — one subject's `roles[]` against the server's existing
3085
3294
  * bindings for it. Shared by groups, users and service accounts: the
@@ -3147,9 +3356,14 @@ var ManifestApi = class {
3147
3356
  }
3148
3357
  } catch (err) {
3149
3358
  stopped = true;
3359
+ const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
3150
3360
  out.push({
3151
3361
  action,
3152
- outcome: { status: "failed", message: err instanceof Error ? err.message : String(err) }
3362
+ outcome: {
3363
+ status: "failed",
3364
+ message: err instanceof Error ? err.message : String(err),
3365
+ ...reasonCode === void 0 ? {} : { reasonCode }
3366
+ }
3153
3367
  });
3154
3368
  }
3155
3369
  }
@@ -3256,6 +3470,34 @@ var ManifestApi = class {
3256
3470
  description: step.description
3257
3471
  });
3258
3472
  return void 0;
3473
+ case "update-network-policy":
3474
+ await c.network.replacePolicy(step.body);
3475
+ return void 0;
3476
+ case "create-network-segment": {
3477
+ const created = await c.network.createSegment(step.body);
3478
+ resolved.segments.set(step.key, created.id);
3479
+ resolved.segmentVersions.set(step.key, created.version);
3480
+ return void 0;
3481
+ }
3482
+ case "update-network-segment": {
3483
+ const replaced = await c.network.replaceSegment(step.id, step.body);
3484
+ resolved.segmentVersions.set(step.key, replaced.version);
3485
+ return void 0;
3486
+ }
3487
+ case "create-network-profile":
3488
+ await c.network.createProfile({
3489
+ segment_id: lookup(resolved.segments, step.segment, "network segment"),
3490
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3491
+ profile: step.profile
3492
+ });
3493
+ return void 0;
3494
+ case "update-network-profile":
3495
+ await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
3496
+ version: step.version,
3497
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3498
+ profile: step.profile
3499
+ });
3500
+ return void 0;
3259
3501
  case "assign-role":
3260
3502
  await this.#assign(step, resolved);
3261
3503
  return void 0;
@@ -3393,6 +3635,94 @@ function lookup(map, key, kind) {
3393
3635
  }
3394
3636
  return id;
3395
3637
  }
3638
+ function hasShapeSections(manifest) {
3639
+ return [
3640
+ manifest.resources,
3641
+ manifest.permissions,
3642
+ manifest.roles,
3643
+ manifest.groups,
3644
+ manifest.users,
3645
+ manifest.serviceAccounts
3646
+ ].some((section) => (section ?? []).length > 0);
3647
+ }
3648
+ function lookupVersion(map, key) {
3649
+ const version = map.get(key);
3650
+ if (version === void 0) {
3651
+ throw new NetworkError(
3652
+ `internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
3653
+ );
3654
+ }
3655
+ return version;
3656
+ }
3657
+ function sameSet(a, b) {
3658
+ if (a.length !== b.length) return false;
3659
+ const left = new Set(a);
3660
+ return left.size === new Set(b).size && b.every((name) => left.has(name));
3661
+ }
3662
+ function sameOptional(stated, read) {
3663
+ return (stated ?? null) === (read ?? null);
3664
+ }
3665
+ function segmentCreateBody(spec) {
3666
+ const body = {
3667
+ kind: spec.kind,
3668
+ site_key: spec.site,
3669
+ name: spec.name,
3670
+ vlan_id: spec.vlanId
3671
+ };
3672
+ if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
3673
+ if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
3674
+ if (spec.enabled !== void 0) body.enabled = spec.enabled;
3675
+ return body;
3676
+ }
3677
+ function segmentDrifted(spec, read) {
3678
+ if (spec.vlanId !== read.vlan_id) return true;
3679
+ if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
3680
+ if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
3681
+ if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
3682
+ return false;
3683
+ }
3684
+ function segmentReplaceBody(spec, read) {
3685
+ const body = {
3686
+ version: read.version,
3687
+ vlan_id: spec.vlanId,
3688
+ filter_ids: [...spec.filterIds ?? read.filter_ids],
3689
+ enabled: spec.enabled ?? read.enabled
3690
+ };
3691
+ const rank = spec.rank === void 0 ? read.rank : spec.rank;
3692
+ if (rank !== void 0 && rank !== null) body.rank = rank;
3693
+ return body;
3694
+ }
3695
+ function profileCreateInput(spec) {
3696
+ const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
3697
+ if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
3698
+ if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
3699
+ if (spec.filterId != null) profile.filter_id = spec.filterId;
3700
+ if (spec.serviceType != null) profile.service_type = spec.serviceType;
3701
+ return profile;
3702
+ }
3703
+ function profileDrifted(spec, read) {
3704
+ if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
3705
+ if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
3706
+ if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
3707
+ if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
3708
+ if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
3709
+ return false;
3710
+ }
3711
+ function profileReplaceInput(spec, read) {
3712
+ const profile = {
3713
+ dictionary: read.dictionary,
3714
+ session_timeout_secs: spec.sessionTimeoutSecs
3715
+ };
3716
+ const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
3717
+ if (termination != null) profile.termination_action = termination;
3718
+ const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
3719
+ if (idle != null) profile.idle_timeout_secs = idle;
3720
+ const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
3721
+ if (filter != null) profile.filter_id = filter;
3722
+ const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
3723
+ if (serviceType != null) profile.service_type = serviceType;
3724
+ return profile;
3725
+ }
3396
3726
  function bindingOf(assignment) {
3397
3727
  return {
3398
3728
  resourceId: assignment.resource_id ?? void 0,
@@ -3510,7 +3840,12 @@ function mapManagementError(operation, err) {
3510
3840
  );
3511
3841
  }
3512
3842
  if (status === 409) {
3513
- return new ConflictError(operation, `${operation}: conflict${detail}`);
3843
+ const code = body?.reason_code;
3844
+ return new ConflictError(
3845
+ operation,
3846
+ `${operation}: conflict${detail}`,
3847
+ typeof code === "string" ? code : void 0
3848
+ );
3514
3849
  }
3515
3850
  if (status === 400 || status === 422) {
3516
3851
  return new ValidationError(
@@ -3520,7 +3855,7 @@ function mapManagementError(operation, err) {
3520
3855
  parseFieldErrors(body)
3521
3856
  );
3522
3857
  }
3523
- return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
3858
+ return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
3524
3859
  }
3525
3860
  function describe(body) {
3526
3861
  if (typeof body === "string" && body) return `: ${body}`;
@@ -4814,7 +5149,7 @@ var CertificatesApi = class {
4814
5149
  method: "POST",
4815
5150
  pathTemplate: "/api/v1/certificates",
4816
5151
  path: "/api/v1/certificates",
4817
- body
5152
+ body: omitNullMembers(body, ["user_id"])
4818
5153
  });
4819
5154
  return generatedCertificateFromWire(wire);
4820
5155
  }
@@ -4831,7 +5166,7 @@ var CertificatesApi = class {
4831
5166
  method: "POST",
4832
5167
  pathTemplate: "/api/v1/certificates/sign-csr",
4833
5168
  path: "/api/v1/certificates/sign-csr",
4834
- body
5169
+ body: omitNullMembers(body, ["user_id"])
4835
5170
  });
4836
5171
  return wire;
4837
5172
  }
@@ -6225,7 +6560,7 @@ var SsfApi = class _SsfApi {
6225
6560
  method: "POST",
6226
6561
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
6227
6562
  path: `/api/v1/tenants/${tenantId}/ssf/streams`,
6228
- body: ssfStreamInputToWire(body)
6563
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6229
6564
  });
6230
6565
  return scrubSsfStream(wire);
6231
6566
  }
@@ -6248,8 +6583,19 @@ var SsfApi = class _SsfApi {
6248
6583
  * update moves `endpoint_url` to another scheme, host or port while a header
6249
6584
  * is stored: then it must carry `authorization_header` again or
6250
6585
  * `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
6251
- * `ssfStreamInputFrom(await ssf.getStream(id))`. An update overtaken by the
6252
- * receiver's own write is `409`: read the stream again.
6586
+ * `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
6587
+ * `events_requested` and `expected_updated_at` it read and cuts
6588
+ * `events_requested` to a lowered `events_allowed` (or from the plain
6589
+ * converter `ssfStreamInputFrom`, where the cut is yours). An update
6590
+ * overtaken by the receiver's own write is `409`: read the stream again.
6591
+ * **`events_requested` has three meanings on an update** (§32.2, contract
6592
+ * 1.62): **absent resets** the stream to every event of `events_allowed` —
6593
+ * widening what the receiver narrowed; **`[]` is stored as the receiver's
6594
+ * "none"** and the stream carries nothing; **a list is stored as given** and
6595
+ * refused (`400`) if any entry is outside `events_allowed`. A raw API client
6596
+ * is bound by the same meaning: an `events_requested` left out of the `PUT`
6597
+ * resets the stream. `expected_updated_at` is the `updated_at` you read, as
6598
+ * the server's own string; an assigned `null` is "none" and is not sent.
6253
6599
  *
6254
6600
  * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6255
6601
  * members must be set, but what you do not carry over from a prior read is
@@ -6267,7 +6613,7 @@ var SsfApi = class _SsfApi {
6267
6613
  method: "PUT",
6268
6614
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
6269
6615
  path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
6270
- body: ssfStreamInputToWire(body)
6616
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6271
6617
  });
6272
6618
  return scrubSsfStream(wire);
6273
6619
  }
@@ -6335,7 +6681,7 @@ var ScimTargetsApi = class {
6335
6681
  method: "POST",
6336
6682
  pathTemplate: "/api/v1/scim-targets",
6337
6683
  path: "/api/v1/scim-targets",
6338
- body: scimTargetInputToWire(body)
6684
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6339
6685
  });
6340
6686
  return scrubScimTargetResponse(wire);
6341
6687
  }
@@ -6382,7 +6728,7 @@ var ScimTargetsApi = class {
6382
6728
  method: "PUT",
6383
6729
  pathTemplate: "/api/v1/scim-targets/{id}",
6384
6730
  path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
6385
- body: scimTargetInputToWire(body)
6731
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6386
6732
  });
6387
6733
  return scrubScimTargetResponse(wire);
6388
6734
  }
@@ -6426,6 +6772,215 @@ var ScimTargetsApi = class {
6426
6772
  }
6427
6773
  };
6428
6774
 
6775
+ // src/management/ops/network.ts
6776
+ var NetworkApi = class {
6777
+ #client;
6778
+ #scope;
6779
+ /** @internal — reached through `client.<namespace>`, never constructed directly. */
6780
+ constructor(client, scope = {}) {
6781
+ this.#client = client;
6782
+ this.#scope = scope;
6783
+ }
6784
+ /** `GET /api/v1/network/segments` */
6785
+ async listSegments(site, page = {}) {
6786
+ const wire = await sendManagement(this.#client, {
6787
+ operation: "network.list_segments",
6788
+ method: "GET",
6789
+ pathTemplate: "/api/v1/network/segments",
6790
+ path: "/api/v1/network/segments",
6791
+ query: { ...pageQuery(page), "site": site }
6792
+ });
6793
+ return wire;
6794
+ }
6795
+ /**
6796
+ * Walk `network.list_segments` to exhaustion, concatenating every page.
6797
+ *
6798
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
6799
+ * if `total` disagrees, so a misreporting server costs one wasted request
6800
+ * rather than an unbounded loop.
6801
+ */
6802
+ listSegmentsAll(site, start = {}) {
6803
+ return collectPages(start, (p) => this.listSegments(site, p));
6804
+ }
6805
+ /**
6806
+ * `POST /api/v1/network/segments`
6807
+ *
6808
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6809
+ * issued exactly once, including the ones that look idempotent.
6810
+ */
6811
+ async createSegment(body) {
6812
+ const wire = await sendManagement(this.#client, {
6813
+ operation: "network.create_segment",
6814
+ method: "POST",
6815
+ pathTemplate: "/api/v1/network/segments",
6816
+ path: "/api/v1/network/segments",
6817
+ body
6818
+ });
6819
+ return wire;
6820
+ }
6821
+ /** `GET /api/v1/network/segments/{id}` */
6822
+ async getSegment(id) {
6823
+ const wire = await sendManagement(this.#client, {
6824
+ operation: "network.get_segment",
6825
+ method: "GET",
6826
+ pathTemplate: "/api/v1/network/segments/{id}",
6827
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`
6828
+ });
6829
+ return wire;
6830
+ }
6831
+ /**
6832
+ * `PUT /api/v1/network/segments/{id}`
6833
+ *
6834
+ * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6835
+ * members must be set, but what you do not carry over from a prior read is
6836
+ * not preserved: an optional member left out is overwritten with its
6837
+ * default, not kept (except where noted above). Read first, change the field
6838
+ * you mean, send the whole thing back.
6839
+ *
6840
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6841
+ * issued exactly once, including the ones that look idempotent.
6842
+ */
6843
+ async replaceSegment(id, body) {
6844
+ const wire = await sendManagement(this.#client, {
6845
+ operation: "network.replace_segment",
6846
+ method: "PUT",
6847
+ pathTemplate: "/api/v1/network/segments/{id}",
6848
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
6849
+ body
6850
+ });
6851
+ return wire;
6852
+ }
6853
+ /**
6854
+ * `DELETE /api/v1/network/segments/{id}`
6855
+ *
6856
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6857
+ * issued exactly once, including the ones that look idempotent.
6858
+ */
6859
+ async deleteSegment(id, version) {
6860
+ await sendManagement(this.#client, {
6861
+ operation: "network.delete_segment",
6862
+ method: "DELETE",
6863
+ pathTemplate: "/api/v1/network/segments/{id}",
6864
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
6865
+ query: { "version": String(version) }
6866
+ });
6867
+ }
6868
+ /** `GET /api/v1/network/profiles` */
6869
+ async listProfiles(page = {}) {
6870
+ const wire = await sendManagement(this.#client, {
6871
+ operation: "network.list_profiles",
6872
+ method: "GET",
6873
+ pathTemplate: "/api/v1/network/profiles",
6874
+ path: "/api/v1/network/profiles",
6875
+ query: { ...pageQuery(page) }
6876
+ });
6877
+ return wire;
6878
+ }
6879
+ /**
6880
+ * Walk `network.list_profiles` to exhaustion, concatenating every page.
6881
+ *
6882
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
6883
+ * if `total` disagrees, so a misreporting server costs one wasted request
6884
+ * rather than an unbounded loop.
6885
+ */
6886
+ listProfilesAll(start = {}) {
6887
+ return collectPages(start, (p) => this.listProfiles(p));
6888
+ }
6889
+ /**
6890
+ * `POST /api/v1/network/profiles`
6891
+ *
6892
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6893
+ * issued exactly once, including the ones that look idempotent.
6894
+ */
6895
+ async createProfile(body) {
6896
+ const wire = await sendManagement(this.#client, {
6897
+ operation: "network.create_profile",
6898
+ method: "POST",
6899
+ pathTemplate: "/api/v1/network/profiles",
6900
+ path: "/api/v1/network/profiles",
6901
+ body
6902
+ });
6903
+ return wire;
6904
+ }
6905
+ /** `GET /api/v1/network/profiles/{segment_id}` */
6906
+ async getProfile(segmentId) {
6907
+ const wire = await sendManagement(this.#client, {
6908
+ operation: "network.get_profile",
6909
+ method: "GET",
6910
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
6911
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
6912
+ });
6913
+ return wire;
6914
+ }
6915
+ /**
6916
+ * `PUT /api/v1/network/profiles/{segment_id}`
6917
+ *
6918
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
6919
+ * body is required, and what you do not carry over from a prior read is not
6920
+ * preserved — it is overwritten. Read first, change the field you mean, send
6921
+ * the whole thing back.
6922
+ *
6923
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6924
+ * issued exactly once, including the ones that look idempotent.
6925
+ */
6926
+ async replaceProfile(segmentId, body) {
6927
+ const wire = await sendManagement(this.#client, {
6928
+ operation: "network.replace_profile",
6929
+ method: "PUT",
6930
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
6931
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
6932
+ body
6933
+ });
6934
+ return wire;
6935
+ }
6936
+ /**
6937
+ * `DELETE /api/v1/network/profiles/{segment_id}`
6938
+ *
6939
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6940
+ * issued exactly once, including the ones that look idempotent.
6941
+ */
6942
+ async deleteProfile(segmentId, version) {
6943
+ await sendManagement(this.#client, {
6944
+ operation: "network.delete_profile",
6945
+ method: "DELETE",
6946
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
6947
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
6948
+ query: { "version": String(version) }
6949
+ });
6950
+ }
6951
+ /** `GET /api/v1/network/policy` */
6952
+ async getPolicy() {
6953
+ const wire = await sendManagement(this.#client, {
6954
+ operation: "network.get_policy",
6955
+ method: "GET",
6956
+ pathTemplate: "/api/v1/network/policy",
6957
+ path: "/api/v1/network/policy"
6958
+ });
6959
+ return wire;
6960
+ }
6961
+ /**
6962
+ * `PUT /api/v1/network/policy`
6963
+ *
6964
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
6965
+ * body is required, and what you do not carry over from a prior read is not
6966
+ * preserved — it is overwritten. Read first, change the field you mean, send
6967
+ * the whole thing back.
6968
+ *
6969
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
6970
+ * issued exactly once, including the ones that look idempotent.
6971
+ */
6972
+ async replacePolicy(body) {
6973
+ const wire = await sendManagement(this.#client, {
6974
+ operation: "network.replace_policy",
6975
+ method: "PUT",
6976
+ pathTemplate: "/api/v1/network/policy",
6977
+ path: "/api/v1/network/policy",
6978
+ body
6979
+ });
6980
+ return wire;
6981
+ }
6982
+ };
6983
+
6429
6984
  // src/management/ops/settings.ts
6430
6985
  var SettingsApi = class _SettingsApi {
6431
6986
  #client;
@@ -7050,6 +7605,9 @@ function managementNamespaces(client) {
7050
7605
  get scimTargets() {
7051
7606
  return new ScimTargetsApi(client);
7052
7607
  },
7608
+ get network() {
7609
+ return new NetworkApi(client);
7610
+ },
7053
7611
  get settings() {
7054
7612
  return new SettingsApi(client);
7055
7613
  },
@@ -9175,9 +9733,21 @@ var OidcClient = class {
9175
9733
  * and obtain the code pair.
9176
9734
  *
9177
9735
  * @remarks
9178
- * **Unauthenticated by design.** A device that cannot show a browser also
9179
- * cannot hold a client secret, so this never sends `client_secret` and never
9180
- * refuses a client built without one (§14.1).
9736
+ * **The client authenticates as it does at every other token request
9737
+ * (contract 1.62, §14.1 rule 2).** A client built with a `clientSecret` sends
9738
+ * it as `client_secret` in the **form body** — never as `Authorization:
9739
+ * Basic`, whatever the client is registered for (§12.1 rule 3 stands for
9740
+ * this route, and the maintainer's 2026-10-16 "same rules" reading fixes the
9741
+ * form body) — and a client with a §6.1 client certificate presents it on the
9742
+ * connection, through the `mtls_endpoint_aliases` entry when discovery
9743
+ * publishes one (§21.3). **A public client sends no credential at all** and
9744
+ * is never refused client-side, so a device that cannot hold a secret still
9745
+ * works. The SDK sends a credential only when its caller configured one: it
9746
+ * never borrows one from another configuration. `private_key_jwt` client
9747
+ * authentication is not implemented by this SDK.
9748
+ *
9749
+ * A `401` with `{"error":"invalid_client"}` is an {@link OAuthProtocolError}
9750
+ * (§14.2 rule 5), is made once, and does not enter the §9 refresh guard.
9181
9751
  */
9182
9752
  async deviceAuthorize(params = {}) {
9183
9753
  const configuration = params.configuration ?? await this.oidcDiscover();
@@ -9189,6 +9759,7 @@ var OidcClient = class {
9189
9759
  }
9190
9760
  const form = new URLSearchParams();
9191
9761
  form.set("client_id", this.#options.clientId);
9762
+ this.#appendClientSecret(form);
9192
9763
  if (params.scope !== void 0) {
9193
9764
  form.set("scope", Array.isArray(params.scope) ? params.scope.join(" ") : params.scope);
9194
9765
  }
@@ -9299,6 +9870,15 @@ var OidcClient = class {
9299
9870
  * {@link OAuthProtocolError} — `authorization_pending` and `slow_down`
9300
9871
  * included — so a hand-rolled loop sees exactly what {@link deviceLogin}
9301
9872
  * sees. Most callers want {@link deviceLogin}.
9873
+ *
9874
+ * Client authentication is the one {@link deviceAuthorize} describes
9875
+ * (contract 1.62, §14.1 rule 2): a configured `clientSecret` is sent as
9876
+ * `client_secret` in the form body, never as `Authorization: Basic`; a public
9877
+ * client sends none; `client_id` is sent on **every** poll (§14.1 rule 3). A
9878
+ * `401 invalid_client` surfaces as {@link OAuthProtocolError}, is not retried
9879
+ * and does not enter the §9 refresh guard (§14.2 rule 5). This SDK ships no
9880
+ * DPoP proof generator, so it cannot drive a client registered for DPoP; it
9881
+ * surfaces that client's refusal as the same `invalid_client`.
9302
9882
  */
9303
9883
  async devicePoll(params) {
9304
9884
  const configuration = params.configuration ?? await this.oidcDiscover();
@@ -9306,6 +9886,7 @@ var OidcClient = class {
9306
9886
  form.set("grant_type", DEVICE_CODE_GRANT_TYPE);
9307
9887
  form.set("device_code", exposeSecret(params.deviceCode));
9308
9888
  form.set("client_id", this.#options.clientId);
9889
+ this.#appendClientSecret(form);
9309
9890
  const wire = await this.#postToken(configuration, form, params.tenantId);
9310
9891
  return this.#toTokenSet(wire, configuration, void 0);
9311
9892
  }