axiam-sdk 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -12
- package/dist/amqp/index.d.cts +3 -2
- package/dist/amqp/index.d.ts +3 -2
- package/dist/{authzCore-BQfX9qxN.d.cts → authzCore-CqXzLNmT.d.cts} +4 -3
- package/dist/{authzCore-BlSHwGnW.d.ts → authzCore-D-hquWSI.d.ts} +4 -3
- package/dist/browser/index.d.cts +8 -7
- package/dist/browser/index.d.ts +8 -7
- package/dist/{client-0WJkblDE.d.ts → client-BMNQi36J.d.ts} +646 -16
- package/dist/{client-yD0eMwHQ.d.cts → client-D34sXV8p.d.cts} +646 -16
- package/dist/{cookieJar-CTD5jOmd.d.cts → cookieJar-C_xPuniu.d.cts} +3 -3
- package/dist/{cookieJar-hWRmZkhe.d.ts → cookieJar-DcrMe93Q.d.ts} +3 -3
- package/dist/{errors-DMIlw2lN.d.ts → errors-DZ3k8a8i.d.cts} +2 -1
- package/dist/{errors-DMIlw2lN.d.cts → errors-DZ3k8a8i.d.ts} +2 -1
- package/dist/{errors-m0Tue_pE.d.cts → errors-RvGlTyUj.d.cts} +18 -3
- package/dist/{errors-CmBvsxV0.d.ts → errors-dlGXAsbh.d.ts} +18 -3
- package/dist/grpc/index.d.cts +10 -9
- package/dist/grpc/index.d.ts +10 -9
- package/dist/grpc/index.js +604 -15
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +604 -15
- package/dist/grpc/index.mjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +626 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +624 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{jwks-BR55d7-Z.d.cts → jwks-CTVpOWzI.d.cts} +2 -1
- package/dist/{jwks-BR55d7-Z.d.ts → jwks-CTVpOWzI.d.ts} +2 -1
- package/dist/middleware/index.d.cts +13 -12
- package/dist/middleware/index.d.ts +13 -12
- package/dist/middleware/index.js +53 -12
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +53 -12
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/nestjs/index.d.cts +5 -4
- package/dist/nestjs/index.d.ts +5 -4
- package/dist/node/index.d.cts +10 -9
- package/dist/node/index.d.ts +10 -9
- package/dist/node/index.js +631 -19
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +631 -19
- package/dist/node/index.mjs.map +1 -1
- package/dist/{oidcState-mQLVn3-A.d.cts → oidcState-BFIHt7_Y.d.cts} +29 -7
- package/dist/{oidcState-DOSCgnMG.d.ts → oidcState-qoy2vsYG.d.ts} +29 -7
- package/dist/rest/index.d.cts +64 -12
- package/dist/rest/index.d.ts +64 -12
- package/dist/rest/index.js +626 -16
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +624 -17
- package/dist/rest/index.mjs.map +1 -1
- package/dist/{revocationFeed-CDoD7Twr.d.cts → revocationFeed-KQhvMMl8.d.cts} +2 -1
- package/dist/{revocationFeed-CDoD7Twr.d.ts → revocationFeed-KQhvMMl8.d.ts} +2 -1
- package/dist/{session-CeG6P9GO.d.ts → session-BbPFTpMZ.d.ts} +3 -2
- package/dist/{session-BmjEMowX.d.cts → session-C9WlP6DV.d.cts} +3 -2
- package/dist/{telemetry--0DwnNjV.d.cts → telemetry-Du0-zS5f.d.cts} +2 -1
- package/dist/{telemetry--0DwnNjV.d.ts → telemetry-Du0-zS5f.d.ts} +2 -1
- package/dist/{webauthnErrors-fLgfOflO.d.cts → webauthnErrors-m1LZiaRy.d.cts} +2 -1
- package/dist/{webauthnErrors-fLgfOflO.d.ts → webauthnErrors-m1LZiaRy.d.ts} +2 -1
- package/package.json +2 -2
package/dist/node/index.js
CHANGED
|
@@ -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
|
];
|
|
@@ -796,6 +802,9 @@ function installCsrfInterceptor(axiosInstance, session) {
|
|
|
796
802
|
if (session.isForeignHost(config.url)) {
|
|
797
803
|
return config;
|
|
798
804
|
}
|
|
805
|
+
if (isOAuth2Endpoint(config.url, session.baseUrl)) {
|
|
806
|
+
return config;
|
|
807
|
+
}
|
|
799
808
|
const method = (config.method ?? "get").toLowerCase();
|
|
800
809
|
const cookieString = typeof document !== "undefined" ? document.cookie : "";
|
|
801
810
|
const csrfToken = typeof document !== "undefined" ? csrfHeaderForMethod(method, cookieString) : csrfHeaderForMethod(method, session.csrfToken ? `axiam_csrf=${session.csrfToken}` : "");
|
|
@@ -849,15 +858,35 @@ function installRefreshInterceptor(axiosInstance, session) {
|
|
|
849
858
|
}
|
|
850
859
|
);
|
|
851
860
|
}
|
|
861
|
+
function isOAuth2Endpoint(url, baseUrl) {
|
|
862
|
+
if (!url) {
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
try {
|
|
866
|
+
const base = new URL(baseUrl);
|
|
867
|
+
let path = new URL(url, base).pathname;
|
|
868
|
+
const prefix = base.pathname.replace(/\/+$/, "");
|
|
869
|
+
if (prefix !== "" && path.startsWith(`${prefix}/`)) {
|
|
870
|
+
path = path.slice(prefix.length);
|
|
871
|
+
}
|
|
872
|
+
return path.startsWith("/oauth2/");
|
|
873
|
+
} catch {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
852
877
|
function installDeviceTokenInterceptor(axiosInstance, session) {
|
|
853
878
|
axiosInstance.interceptors.request.use((config) => {
|
|
854
879
|
const deviceToken = session.deviceAccessToken;
|
|
855
|
-
|
|
880
|
+
const oauth2 = isOAuth2Endpoint(config.url, session.baseUrl);
|
|
881
|
+
if (session.isForeignHost(config.url) || deviceToken === void 0 && !oauth2) {
|
|
856
882
|
return config;
|
|
857
883
|
}
|
|
858
884
|
const noCred = session.noCredentialsConfig();
|
|
859
885
|
Object.assign(config, noCred);
|
|
860
886
|
config.headers = config.headers ?? {};
|
|
887
|
+
if (oauth2) {
|
|
888
|
+
return config;
|
|
889
|
+
}
|
|
861
890
|
config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
|
|
862
891
|
config.headers["Cookie"] = "";
|
|
863
892
|
return config;
|
|
@@ -1816,10 +1845,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
|
|
|
1816
1845
|
var ConflictError = class _ConflictError extends AuthzError {
|
|
1817
1846
|
/** The registry operation that conflicted. */
|
|
1818
1847
|
operation;
|
|
1819
|
-
|
|
1848
|
+
/**
|
|
1849
|
+
* The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
|
|
1850
|
+
* or `undefined` when the body carries none (a server that predates it, or a
|
|
1851
|
+
* `409` of an operation that does not name one).
|
|
1852
|
+
*
|
|
1853
|
+
* The `409` of every `network` operation says which conflict it is:
|
|
1854
|
+
* `stale_version`, `strands_profile`, `has_children`, `site_gone`,
|
|
1855
|
+
* `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
|
|
1856
|
+
* `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
|
|
1857
|
+
* not know is surfaced verbatim, and a caller branches on this member —
|
|
1858
|
+
* never on `message`, which an SDK must not parse. It is not the `reason` of
|
|
1859
|
+
* an authorization decision (§3), which is a human string.
|
|
1860
|
+
*/
|
|
1861
|
+
reasonCode;
|
|
1862
|
+
constructor(operation, message, reasonCode) {
|
|
1820
1863
|
super(message);
|
|
1821
1864
|
this.name = "ConflictError";
|
|
1822
1865
|
this.operation = operation;
|
|
1866
|
+
this.reasonCode = reasonCode;
|
|
1823
1867
|
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
1824
1868
|
}
|
|
1825
1869
|
};
|
|
@@ -2108,6 +2152,14 @@ function omitEmptyTenantScope(body) {
|
|
|
2108
2152
|
}
|
|
2109
2153
|
return body;
|
|
2110
2154
|
}
|
|
2155
|
+
function omitNullMembers(body, members) {
|
|
2156
|
+
if (!body || typeof body !== "object") return body;
|
|
2157
|
+
const record = body;
|
|
2158
|
+
if (!members.some((m) => m in record && record[m] === null)) return body;
|
|
2159
|
+
const copy = { ...record };
|
|
2160
|
+
for (const m of members) if (copy[m] === null) delete copy[m];
|
|
2161
|
+
return copy;
|
|
2162
|
+
}
|
|
2111
2163
|
function roleAssignmentInherits(assignment) {
|
|
2112
2164
|
return assignment.inherit ?? true;
|
|
2113
2165
|
}
|
|
@@ -2580,6 +2632,7 @@ function validate(manifest) {
|
|
|
2580
2632
|
const groups = manifest.groups ?? [];
|
|
2581
2633
|
const users = manifest.users ?? [];
|
|
2582
2634
|
const serviceAccounts = manifest.serviceAccounts ?? [];
|
|
2635
|
+
const network = manifest.network;
|
|
2583
2636
|
const resourceKeys = new Set(resources.map((r) => r.key));
|
|
2584
2637
|
const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
|
|
2585
2638
|
const permissionKeys = new Set(permissions.map((p) => p.key));
|
|
@@ -2593,6 +2646,7 @@ function validate(manifest) {
|
|
|
2593
2646
|
duplicates("group", groups.map((g) => g.key), problems);
|
|
2594
2647
|
duplicates("user", users.map((u) => u.key), problems);
|
|
2595
2648
|
duplicates("service account", serviceAccounts.map((s) => s.key), problems);
|
|
2649
|
+
if (network !== void 0) validateNetwork(network, problems);
|
|
2596
2650
|
for (const resource of resources) {
|
|
2597
2651
|
if (resource.parent && !resourceKeys.has(resource.parent)) {
|
|
2598
2652
|
problems.push(
|
|
@@ -2672,6 +2726,51 @@ function validate(manifest) {
|
|
|
2672
2726
|
}
|
|
2673
2727
|
}
|
|
2674
2728
|
var q = (s) => JSON.stringify(s);
|
|
2729
|
+
function validateNetwork(network, problems) {
|
|
2730
|
+
if (Array.isArray(network.policy)) {
|
|
2731
|
+
problems.push("network declares more than one policy; the tenant has exactly one");
|
|
2732
|
+
}
|
|
2733
|
+
const segments = network.segments ?? [];
|
|
2734
|
+
const profiles = network.profiles ?? [];
|
|
2735
|
+
duplicates("network segment", segments.map((s) => s.key), problems);
|
|
2736
|
+
const naturalKeys = /* @__PURE__ */ new Set();
|
|
2737
|
+
for (const segment of segments) {
|
|
2738
|
+
const natural = `${segment.site}/${segment.kind}/${segment.name}`;
|
|
2739
|
+
if (naturalKeys.has(natural)) {
|
|
2740
|
+
problems.push(
|
|
2741
|
+
`network segment ${q(natural)} (site, kind, name) is declared more than once`
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2744
|
+
naturalKeys.add(natural);
|
|
2745
|
+
const seenFilters = /* @__PURE__ */ new Set();
|
|
2746
|
+
for (const filter of segment.filterIds ?? []) {
|
|
2747
|
+
if (seenFilters.has(filter)) {
|
|
2748
|
+
problems.push(
|
|
2749
|
+
`network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
seenFilters.add(filter);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
const segmentKeys = new Set(segments.map((s) => s.key));
|
|
2756
|
+
const profiled = /* @__PURE__ */ new Set();
|
|
2757
|
+
for (const profile of profiles) {
|
|
2758
|
+
if (!segmentKeys.has(profile.segment)) {
|
|
2759
|
+
problems.push(
|
|
2760
|
+
`network profile names segment ${q(profile.segment)}, which no network segment declares`
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
if (profiled.has(profile.segment)) {
|
|
2764
|
+
problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
|
|
2765
|
+
}
|
|
2766
|
+
profiled.add(profile.segment);
|
|
2767
|
+
if (profile.terminationAction === null) {
|
|
2768
|
+
problems.push(
|
|
2769
|
+
`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)`
|
|
2770
|
+
);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2675
2774
|
function duplicates(kind, keys, problems) {
|
|
2676
2775
|
const seen = /* @__PURE__ */ new Set();
|
|
2677
2776
|
for (const key of keys) {
|
|
@@ -2717,7 +2816,9 @@ var emptyResolved = () => ({
|
|
|
2717
2816
|
roles: /* @__PURE__ */ new Map(),
|
|
2718
2817
|
groups: /* @__PURE__ */ new Map(),
|
|
2719
2818
|
users: /* @__PURE__ */ new Map(),
|
|
2720
|
-
serviceAccounts: /* @__PURE__ */ new Map()
|
|
2819
|
+
serviceAccounts: /* @__PURE__ */ new Map(),
|
|
2820
|
+
segments: /* @__PURE__ */ new Map(),
|
|
2821
|
+
segmentVersions: /* @__PURE__ */ new Map()
|
|
2721
2822
|
});
|
|
2722
2823
|
var ManifestApi = class {
|
|
2723
2824
|
#client;
|
|
@@ -2750,6 +2851,23 @@ var ManifestApi = class {
|
|
|
2750
2851
|
async #read(manifest) {
|
|
2751
2852
|
const c = this.#client;
|
|
2752
2853
|
const start = { limit: PLAN_PAGE };
|
|
2854
|
+
if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
|
|
2855
|
+
return {
|
|
2856
|
+
resources: [],
|
|
2857
|
+
scopes: /* @__PURE__ */ new Map(),
|
|
2858
|
+
permissions: [],
|
|
2859
|
+
roles: [],
|
|
2860
|
+
groups: [],
|
|
2861
|
+
users: [],
|
|
2862
|
+
serviceAccounts: [],
|
|
2863
|
+
roleGrants: /* @__PURE__ */ new Map(),
|
|
2864
|
+
roleUserBindings: /* @__PURE__ */ new Map(),
|
|
2865
|
+
roleGroupBindings: /* @__PURE__ */ new Map(),
|
|
2866
|
+
roleServiceAccountBindings: /* @__PURE__ */ new Map(),
|
|
2867
|
+
groupMembers: /* @__PURE__ */ new Map(),
|
|
2868
|
+
network: await this.#readNetwork(manifest.network, start)
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2753
2871
|
const resources = await c.resources.listAll(start);
|
|
2754
2872
|
const permissions = await c.permissions.listAll(start);
|
|
2755
2873
|
const roles = await c.roles.listAll(start);
|
|
@@ -2805,9 +2923,29 @@ var ManifestApi = class {
|
|
|
2805
2923
|
roleUserBindings,
|
|
2806
2924
|
roleGroupBindings,
|
|
2807
2925
|
roleServiceAccountBindings,
|
|
2808
|
-
groupMembers
|
|
2926
|
+
groupMembers,
|
|
2927
|
+
network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
|
|
2809
2928
|
};
|
|
2810
2929
|
}
|
|
2930
|
+
/**
|
|
2931
|
+
* §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
|
|
2932
|
+
* list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
|
|
2933
|
+
* A section that states no policy does not read it; one that states no
|
|
2934
|
+
* profile does not list them.
|
|
2935
|
+
*/
|
|
2936
|
+
async #readNetwork(spec, start) {
|
|
2937
|
+
const c = this.#client;
|
|
2938
|
+
const policy = spec.policy ? await c.network.getPolicy() : void 0;
|
|
2939
|
+
const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
|
|
2940
|
+
const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
|
|
2941
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
2942
|
+
if ((spec.profiles ?? []).length) {
|
|
2943
|
+
for (const profile of await c.network.listProfilesAll(start)) {
|
|
2944
|
+
profiles.set(profile.segment_id, profile);
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
return { policy, segments, profiles };
|
|
2948
|
+
}
|
|
2811
2949
|
// -------------------------------------------------------------------
|
|
2812
2950
|
// Plan
|
|
2813
2951
|
// -------------------------------------------------------------------
|
|
@@ -3078,8 +3216,97 @@ var ManifestApi = class {
|
|
|
3078
3216
|
push
|
|
3079
3217
|
);
|
|
3080
3218
|
}
|
|
3219
|
+
if (manifest.network && snapshot.network) {
|
|
3220
|
+
this.#networkSteps(manifest.network, snapshot.network, resolved, push);
|
|
3221
|
+
}
|
|
3081
3222
|
return out;
|
|
3082
3223
|
}
|
|
3224
|
+
/**
|
|
3225
|
+
* §27.6.2 — the `network` section: the policy, then the segments, then the
|
|
3226
|
+
* profiles, a profile after its segment (item 2). Every comparison is with
|
|
3227
|
+
* the value **as the read returns it** (item 3): a profile's effective
|
|
3228
|
+
* (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
|
|
3229
|
+
* Silence is not an assertion (rule 3): a member left off never drifts, and
|
|
3230
|
+
* the `Update` body carries the read's value for it (item 4).
|
|
3231
|
+
*/
|
|
3232
|
+
#networkSteps(spec, read, resolved, push) {
|
|
3233
|
+
if (spec.policy) {
|
|
3234
|
+
const current = read.policy;
|
|
3235
|
+
const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
|
|
3236
|
+
push(
|
|
3237
|
+
drifted ? "update" : "no-change",
|
|
3238
|
+
"network-policy",
|
|
3239
|
+
"network.policy",
|
|
3240
|
+
"network policy (Session-Timeout cap)",
|
|
3241
|
+
drifted ? {
|
|
3242
|
+
kind: "update-network-policy",
|
|
3243
|
+
body: {
|
|
3244
|
+
session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
|
|
3245
|
+
version: current.version
|
|
3246
|
+
}
|
|
3247
|
+
} : { kind: "noop" }
|
|
3248
|
+
);
|
|
3249
|
+
}
|
|
3250
|
+
const segments = spec.segments ?? [];
|
|
3251
|
+
for (const segment of segments) {
|
|
3252
|
+
const found = read.segments.find(
|
|
3253
|
+
(r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
|
|
3254
|
+
);
|
|
3255
|
+
const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
|
|
3256
|
+
if (!found) {
|
|
3257
|
+
push("create", "network-segment", segment.key, summary, {
|
|
3258
|
+
kind: "create-network-segment",
|
|
3259
|
+
key: segment.key,
|
|
3260
|
+
body: segmentCreateBody(segment)
|
|
3261
|
+
});
|
|
3262
|
+
continue;
|
|
3263
|
+
}
|
|
3264
|
+
resolved.segments.set(segment.key, found.id);
|
|
3265
|
+
resolved.segmentVersions.set(segment.key, found.version);
|
|
3266
|
+
const drifted = segmentDrifted(segment, found);
|
|
3267
|
+
push(
|
|
3268
|
+
drifted ? "update" : "no-change",
|
|
3269
|
+
"network-segment",
|
|
3270
|
+
segment.key,
|
|
3271
|
+
summary,
|
|
3272
|
+
drifted ? {
|
|
3273
|
+
kind: "update-network-segment",
|
|
3274
|
+
key: segment.key,
|
|
3275
|
+
id: found.id,
|
|
3276
|
+
body: segmentReplaceBody(segment, found)
|
|
3277
|
+
} : { kind: "noop" }
|
|
3278
|
+
);
|
|
3279
|
+
}
|
|
3280
|
+
const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
|
|
3281
|
+
for (const segment of segments) {
|
|
3282
|
+
const profile = bySegment.get(segment.key);
|
|
3283
|
+
if (!profile) continue;
|
|
3284
|
+
const segmentId = resolved.segments.get(segment.key);
|
|
3285
|
+
const found = segmentId ? read.profiles.get(segmentId) : void 0;
|
|
3286
|
+
const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
|
|
3287
|
+
if (!found) {
|
|
3288
|
+
push("create", "network-profile", segment.key, summary, {
|
|
3289
|
+
kind: "create-network-profile",
|
|
3290
|
+
segment: segment.key,
|
|
3291
|
+
profile: profileCreateInput(profile)
|
|
3292
|
+
});
|
|
3293
|
+
continue;
|
|
3294
|
+
}
|
|
3295
|
+
const drifted = profileDrifted(profile, found);
|
|
3296
|
+
push(
|
|
3297
|
+
drifted ? "update" : "no-change",
|
|
3298
|
+
"network-profile",
|
|
3299
|
+
segment.key,
|
|
3300
|
+
summary,
|
|
3301
|
+
drifted ? {
|
|
3302
|
+
kind: "update-network-profile",
|
|
3303
|
+
segment: segment.key,
|
|
3304
|
+
version: found.version,
|
|
3305
|
+
profile: profileReplaceInput(profile, found)
|
|
3306
|
+
} : { kind: "noop" }
|
|
3307
|
+
);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3083
3310
|
/**
|
|
3084
3311
|
* §27.6.1 item 2 — one subject's `roles[]` against the server's existing
|
|
3085
3312
|
* bindings for it. Shared by groups, users and service accounts: the
|
|
@@ -3147,9 +3374,14 @@ var ManifestApi = class {
|
|
|
3147
3374
|
}
|
|
3148
3375
|
} catch (err) {
|
|
3149
3376
|
stopped = true;
|
|
3377
|
+
const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
|
|
3150
3378
|
out.push({
|
|
3151
3379
|
action,
|
|
3152
|
-
outcome: {
|
|
3380
|
+
outcome: {
|
|
3381
|
+
status: "failed",
|
|
3382
|
+
message: err instanceof Error ? err.message : String(err),
|
|
3383
|
+
...reasonCode === void 0 ? {} : { reasonCode }
|
|
3384
|
+
}
|
|
3153
3385
|
});
|
|
3154
3386
|
}
|
|
3155
3387
|
}
|
|
@@ -3256,6 +3488,34 @@ var ManifestApi = class {
|
|
|
3256
3488
|
description: step.description
|
|
3257
3489
|
});
|
|
3258
3490
|
return void 0;
|
|
3491
|
+
case "update-network-policy":
|
|
3492
|
+
await c.network.replacePolicy(step.body);
|
|
3493
|
+
return void 0;
|
|
3494
|
+
case "create-network-segment": {
|
|
3495
|
+
const created = await c.network.createSegment(step.body);
|
|
3496
|
+
resolved.segments.set(step.key, created.id);
|
|
3497
|
+
resolved.segmentVersions.set(step.key, created.version);
|
|
3498
|
+
return void 0;
|
|
3499
|
+
}
|
|
3500
|
+
case "update-network-segment": {
|
|
3501
|
+
const replaced = await c.network.replaceSegment(step.id, step.body);
|
|
3502
|
+
resolved.segmentVersions.set(step.key, replaced.version);
|
|
3503
|
+
return void 0;
|
|
3504
|
+
}
|
|
3505
|
+
case "create-network-profile":
|
|
3506
|
+
await c.network.createProfile({
|
|
3507
|
+
segment_id: lookup(resolved.segments, step.segment, "network segment"),
|
|
3508
|
+
segment_version: lookupVersion(resolved.segmentVersions, step.segment),
|
|
3509
|
+
profile: step.profile
|
|
3510
|
+
});
|
|
3511
|
+
return void 0;
|
|
3512
|
+
case "update-network-profile":
|
|
3513
|
+
await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
|
|
3514
|
+
version: step.version,
|
|
3515
|
+
segment_version: lookupVersion(resolved.segmentVersions, step.segment),
|
|
3516
|
+
profile: step.profile
|
|
3517
|
+
});
|
|
3518
|
+
return void 0;
|
|
3259
3519
|
case "assign-role":
|
|
3260
3520
|
await this.#assign(step, resolved);
|
|
3261
3521
|
return void 0;
|
|
@@ -3393,6 +3653,107 @@ function lookup(map, key, kind) {
|
|
|
3393
3653
|
}
|
|
3394
3654
|
return id;
|
|
3395
3655
|
}
|
|
3656
|
+
function hasShapeSections(manifest) {
|
|
3657
|
+
return [
|
|
3658
|
+
manifest.resources,
|
|
3659
|
+
manifest.permissions,
|
|
3660
|
+
manifest.roles,
|
|
3661
|
+
manifest.groups,
|
|
3662
|
+
manifest.users,
|
|
3663
|
+
manifest.serviceAccounts
|
|
3664
|
+
].some((section) => (section ?? []).length > 0);
|
|
3665
|
+
}
|
|
3666
|
+
function lookupVersion(map, key) {
|
|
3667
|
+
const version = map.get(key);
|
|
3668
|
+
if (version === void 0) {
|
|
3669
|
+
throw new NetworkError(
|
|
3670
|
+
`internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
|
|
3671
|
+
);
|
|
3672
|
+
}
|
|
3673
|
+
return version;
|
|
3674
|
+
}
|
|
3675
|
+
function sameSet(a, b) {
|
|
3676
|
+
if (a.length !== b.length) return false;
|
|
3677
|
+
const left = new Set(a);
|
|
3678
|
+
return left.size === new Set(b).size && b.every((name) => left.has(name));
|
|
3679
|
+
}
|
|
3680
|
+
function sameOptional(stated, read) {
|
|
3681
|
+
return (stated ?? null) === (read ?? null);
|
|
3682
|
+
}
|
|
3683
|
+
function segmentCreateBody(spec) {
|
|
3684
|
+
const body = {
|
|
3685
|
+
kind: spec.kind,
|
|
3686
|
+
site_key: spec.site,
|
|
3687
|
+
name: spec.name,
|
|
3688
|
+
vlan_id: spec.vlanId
|
|
3689
|
+
};
|
|
3690
|
+
if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
|
|
3691
|
+
if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
|
|
3692
|
+
if (spec.enabled !== void 0) body.enabled = spec.enabled;
|
|
3693
|
+
return body;
|
|
3694
|
+
}
|
|
3695
|
+
function segmentDrifted(spec, read) {
|
|
3696
|
+
if (spec.vlanId !== read.vlan_id) return true;
|
|
3697
|
+
if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
|
|
3698
|
+
if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
|
|
3699
|
+
if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
|
|
3700
|
+
return false;
|
|
3701
|
+
}
|
|
3702
|
+
function segmentReplaceBody(spec, read) {
|
|
3703
|
+
const body = {
|
|
3704
|
+
version: read.version,
|
|
3705
|
+
vlan_id: spec.vlanId,
|
|
3706
|
+
filter_ids: [...spec.filterIds ?? read.filter_ids],
|
|
3707
|
+
enabled: spec.enabled ?? read.enabled
|
|
3708
|
+
};
|
|
3709
|
+
const rank = spec.rank === void 0 ? read.rank : spec.rank;
|
|
3710
|
+
if (rank !== void 0 && rank !== null) body.rank = rank;
|
|
3711
|
+
return body;
|
|
3712
|
+
}
|
|
3713
|
+
function profileCreateInput(spec) {
|
|
3714
|
+
const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
|
|
3715
|
+
if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
|
|
3716
|
+
if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
|
|
3717
|
+
if (spec.filterId != null) profile.filter_id = spec.filterId;
|
|
3718
|
+
if (spec.serviceType != null) profile.service_type = spec.serviceType;
|
|
3719
|
+
return profile;
|
|
3720
|
+
}
|
|
3721
|
+
function profileDrifted(spec, read) {
|
|
3722
|
+
if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
|
|
3723
|
+
if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
|
|
3724
|
+
if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
|
|
3725
|
+
if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
|
|
3726
|
+
if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
|
|
3727
|
+
return false;
|
|
3728
|
+
}
|
|
3729
|
+
var KNOWN_TERMINATION_ACTIONS = ["default", "radius_request"];
|
|
3730
|
+
var KNOWN_SERVICE_TYPES = ["framed_user"];
|
|
3731
|
+
function refuseUnknownCarried(member, stated, read, known) {
|
|
3732
|
+
if (stated !== void 0 || read == null || known.includes(read)) return;
|
|
3733
|
+
throw new ValidationError(
|
|
3734
|
+
"manifest.plan",
|
|
3735
|
+
400,
|
|
3736
|
+
`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)`,
|
|
3737
|
+
[{ field: member, message: `unknown value ${JSON.stringify(read)} on an unstated member` }]
|
|
3738
|
+
);
|
|
3739
|
+
}
|
|
3740
|
+
function profileReplaceInput(spec, read) {
|
|
3741
|
+
const profile = {
|
|
3742
|
+
dictionary: read.dictionary,
|
|
3743
|
+
session_timeout_secs: spec.sessionTimeoutSecs
|
|
3744
|
+
};
|
|
3745
|
+
refuseUnknownCarried("termination_action", spec.terminationAction, read.termination_action, KNOWN_TERMINATION_ACTIONS);
|
|
3746
|
+
refuseUnknownCarried("service_type", spec.serviceType, read.service_type, KNOWN_SERVICE_TYPES);
|
|
3747
|
+
const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
|
|
3748
|
+
if (termination != null) profile.termination_action = termination;
|
|
3749
|
+
const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
|
|
3750
|
+
if (idle != null) profile.idle_timeout_secs = idle;
|
|
3751
|
+
const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
|
|
3752
|
+
if (filter != null) profile.filter_id = filter;
|
|
3753
|
+
const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
|
|
3754
|
+
if (serviceType != null) profile.service_type = serviceType;
|
|
3755
|
+
return profile;
|
|
3756
|
+
}
|
|
3396
3757
|
function bindingOf(assignment) {
|
|
3397
3758
|
return {
|
|
3398
3759
|
resourceId: assignment.resource_id ?? void 0,
|
|
@@ -3510,7 +3871,12 @@ function mapManagementError(operation, err) {
|
|
|
3510
3871
|
);
|
|
3511
3872
|
}
|
|
3512
3873
|
if (status === 409) {
|
|
3513
|
-
|
|
3874
|
+
const code = body?.reason_code;
|
|
3875
|
+
return new ConflictError(
|
|
3876
|
+
operation,
|
|
3877
|
+
`${operation}: conflict${detail}`,
|
|
3878
|
+
typeof code === "string" ? code : void 0
|
|
3879
|
+
);
|
|
3514
3880
|
}
|
|
3515
3881
|
if (status === 400 || status === 422) {
|
|
3516
3882
|
return new ValidationError(
|
|
@@ -3520,7 +3886,7 @@ function mapManagementError(operation, err) {
|
|
|
3520
3886
|
parseFieldErrors(body)
|
|
3521
3887
|
);
|
|
3522
3888
|
}
|
|
3523
|
-
return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
|
|
3889
|
+
return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
|
|
3524
3890
|
}
|
|
3525
3891
|
function describe(body) {
|
|
3526
3892
|
if (typeof body === "string" && body) return `: ${body}`;
|
|
@@ -4814,7 +5180,7 @@ var CertificatesApi = class {
|
|
|
4814
5180
|
method: "POST",
|
|
4815
5181
|
pathTemplate: "/api/v1/certificates",
|
|
4816
5182
|
path: "/api/v1/certificates",
|
|
4817
|
-
body
|
|
5183
|
+
body: omitNullMembers(body, ["user_id"])
|
|
4818
5184
|
});
|
|
4819
5185
|
return generatedCertificateFromWire(wire);
|
|
4820
5186
|
}
|
|
@@ -4831,7 +5197,7 @@ var CertificatesApi = class {
|
|
|
4831
5197
|
method: "POST",
|
|
4832
5198
|
pathTemplate: "/api/v1/certificates/sign-csr",
|
|
4833
5199
|
path: "/api/v1/certificates/sign-csr",
|
|
4834
|
-
body
|
|
5200
|
+
body: omitNullMembers(body, ["user_id"])
|
|
4835
5201
|
});
|
|
4836
5202
|
return wire;
|
|
4837
5203
|
}
|
|
@@ -6225,7 +6591,7 @@ var SsfApi = class _SsfApi {
|
|
|
6225
6591
|
method: "POST",
|
|
6226
6592
|
pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
|
|
6227
6593
|
path: `/api/v1/tenants/${tenantId}/ssf/streams`,
|
|
6228
|
-
body: ssfStreamInputToWire(body)
|
|
6594
|
+
body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
|
|
6229
6595
|
});
|
|
6230
6596
|
return scrubSsfStream(wire);
|
|
6231
6597
|
}
|
|
@@ -6248,8 +6614,19 @@ var SsfApi = class _SsfApi {
|
|
|
6248
6614
|
* update moves `endpoint_url` to another scheme, host or port while a header
|
|
6249
6615
|
* is stored: then it must carry `authorization_header` again or
|
|
6250
6616
|
* `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
|
|
6251
|
-
* `
|
|
6252
|
-
*
|
|
6617
|
+
* `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
|
|
6618
|
+
* `events_requested` and `expected_updated_at` it read and cuts
|
|
6619
|
+
* `events_requested` to a lowered `events_allowed` (or from the plain
|
|
6620
|
+
* converter `ssfStreamInputFrom`, where the cut is yours). An update
|
|
6621
|
+
* overtaken by the receiver's own write is `409`: read the stream again.
|
|
6622
|
+
* **`events_requested` has three meanings on an update** (§32.2, contract
|
|
6623
|
+
* 1.62): **absent resets** the stream to every event of `events_allowed` —
|
|
6624
|
+
* widening what the receiver narrowed; **`[]` is stored as the receiver's
|
|
6625
|
+
* "none"** and the stream carries nothing; **a list is stored as given** and
|
|
6626
|
+
* refused (`400`) if any entry is outside `events_allowed`. A raw API client
|
|
6627
|
+
* is bound by the same meaning: an `events_requested` left out of the `PUT`
|
|
6628
|
+
* resets the stream. `expected_updated_at` is the `updated_at` you read, as
|
|
6629
|
+
* the server's own string; an assigned `null` is "none" and is not sent.
|
|
6253
6630
|
*
|
|
6254
6631
|
* **This is a replacement, not a patch** (§27.4 rule 5). Only the required
|
|
6255
6632
|
* members must be set, but what you do not carry over from a prior read is
|
|
@@ -6267,7 +6644,7 @@ var SsfApi = class _SsfApi {
|
|
|
6267
6644
|
method: "PUT",
|
|
6268
6645
|
pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
|
|
6269
6646
|
path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
|
|
6270
|
-
body: ssfStreamInputToWire(body)
|
|
6647
|
+
body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
|
|
6271
6648
|
});
|
|
6272
6649
|
return scrubSsfStream(wire);
|
|
6273
6650
|
}
|
|
@@ -6335,7 +6712,7 @@ var ScimTargetsApi = class {
|
|
|
6335
6712
|
method: "POST",
|
|
6336
6713
|
pathTemplate: "/api/v1/scim-targets",
|
|
6337
6714
|
path: "/api/v1/scim-targets",
|
|
6338
|
-
body: scimTargetInputToWire(body)
|
|
6715
|
+
body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
|
|
6339
6716
|
});
|
|
6340
6717
|
return scrubScimTargetResponse(wire);
|
|
6341
6718
|
}
|
|
@@ -6382,7 +6759,7 @@ var ScimTargetsApi = class {
|
|
|
6382
6759
|
method: "PUT",
|
|
6383
6760
|
pathTemplate: "/api/v1/scim-targets/{id}",
|
|
6384
6761
|
path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
|
|
6385
|
-
body: scimTargetInputToWire(body)
|
|
6762
|
+
body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
|
|
6386
6763
|
});
|
|
6387
6764
|
return scrubScimTargetResponse(wire);
|
|
6388
6765
|
}
|
|
@@ -6426,6 +6803,215 @@ var ScimTargetsApi = class {
|
|
|
6426
6803
|
}
|
|
6427
6804
|
};
|
|
6428
6805
|
|
|
6806
|
+
// src/management/ops/network.ts
|
|
6807
|
+
var NetworkApi = class {
|
|
6808
|
+
#client;
|
|
6809
|
+
#scope;
|
|
6810
|
+
/** @internal — reached through `client.<namespace>`, never constructed directly. */
|
|
6811
|
+
constructor(client, scope = {}) {
|
|
6812
|
+
this.#client = client;
|
|
6813
|
+
this.#scope = scope;
|
|
6814
|
+
}
|
|
6815
|
+
/** `GET /api/v1/network/segments` */
|
|
6816
|
+
async listSegments(site, page = {}) {
|
|
6817
|
+
const wire = await sendManagement(this.#client, {
|
|
6818
|
+
operation: "network.list_segments",
|
|
6819
|
+
method: "GET",
|
|
6820
|
+
pathTemplate: "/api/v1/network/segments",
|
|
6821
|
+
path: "/api/v1/network/segments",
|
|
6822
|
+
query: { ...pageQuery(page), "site": site }
|
|
6823
|
+
});
|
|
6824
|
+
return wire;
|
|
6825
|
+
}
|
|
6826
|
+
/**
|
|
6827
|
+
* Walk `network.list_segments` to exhaustion, concatenating every page.
|
|
6828
|
+
*
|
|
6829
|
+
* The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
|
|
6830
|
+
* if `total` disagrees, so a misreporting server costs one wasted request
|
|
6831
|
+
* rather than an unbounded loop.
|
|
6832
|
+
*/
|
|
6833
|
+
listSegmentsAll(site, start = {}) {
|
|
6834
|
+
return collectPages(start, (p) => this.listSegments(site, p));
|
|
6835
|
+
}
|
|
6836
|
+
/**
|
|
6837
|
+
* `POST /api/v1/network/segments`
|
|
6838
|
+
*
|
|
6839
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6840
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6841
|
+
*/
|
|
6842
|
+
async createSegment(body) {
|
|
6843
|
+
const wire = await sendManagement(this.#client, {
|
|
6844
|
+
operation: "network.create_segment",
|
|
6845
|
+
method: "POST",
|
|
6846
|
+
pathTemplate: "/api/v1/network/segments",
|
|
6847
|
+
path: "/api/v1/network/segments",
|
|
6848
|
+
body
|
|
6849
|
+
});
|
|
6850
|
+
return wire;
|
|
6851
|
+
}
|
|
6852
|
+
/** `GET /api/v1/network/segments/{id}` */
|
|
6853
|
+
async getSegment(id) {
|
|
6854
|
+
const wire = await sendManagement(this.#client, {
|
|
6855
|
+
operation: "network.get_segment",
|
|
6856
|
+
method: "GET",
|
|
6857
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6858
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`
|
|
6859
|
+
});
|
|
6860
|
+
return wire;
|
|
6861
|
+
}
|
|
6862
|
+
/**
|
|
6863
|
+
* `PUT /api/v1/network/segments/{id}`
|
|
6864
|
+
*
|
|
6865
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Only the required
|
|
6866
|
+
* members must be set, but what you do not carry over from a prior read is
|
|
6867
|
+
* not preserved: an optional member left out is overwritten with its
|
|
6868
|
+
* default, not kept (except where noted above). Read first, change the field
|
|
6869
|
+
* you mean, send the whole thing back.
|
|
6870
|
+
*
|
|
6871
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6872
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6873
|
+
*/
|
|
6874
|
+
async replaceSegment(id, body) {
|
|
6875
|
+
const wire = await sendManagement(this.#client, {
|
|
6876
|
+
operation: "network.replace_segment",
|
|
6877
|
+
method: "PUT",
|
|
6878
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6879
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
|
|
6880
|
+
body
|
|
6881
|
+
});
|
|
6882
|
+
return wire;
|
|
6883
|
+
}
|
|
6884
|
+
/**
|
|
6885
|
+
* `DELETE /api/v1/network/segments/{id}`
|
|
6886
|
+
*
|
|
6887
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6888
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6889
|
+
*/
|
|
6890
|
+
async deleteSegment(id, version) {
|
|
6891
|
+
await sendManagement(this.#client, {
|
|
6892
|
+
operation: "network.delete_segment",
|
|
6893
|
+
method: "DELETE",
|
|
6894
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6895
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
|
|
6896
|
+
query: { "version": String(version) }
|
|
6897
|
+
});
|
|
6898
|
+
}
|
|
6899
|
+
/** `GET /api/v1/network/profiles` */
|
|
6900
|
+
async listProfiles(page = {}) {
|
|
6901
|
+
const wire = await sendManagement(this.#client, {
|
|
6902
|
+
operation: "network.list_profiles",
|
|
6903
|
+
method: "GET",
|
|
6904
|
+
pathTemplate: "/api/v1/network/profiles",
|
|
6905
|
+
path: "/api/v1/network/profiles",
|
|
6906
|
+
query: { ...pageQuery(page) }
|
|
6907
|
+
});
|
|
6908
|
+
return wire;
|
|
6909
|
+
}
|
|
6910
|
+
/**
|
|
6911
|
+
* Walk `network.list_profiles` to exhaustion, concatenating every page.
|
|
6912
|
+
*
|
|
6913
|
+
* The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
|
|
6914
|
+
* if `total` disagrees, so a misreporting server costs one wasted request
|
|
6915
|
+
* rather than an unbounded loop.
|
|
6916
|
+
*/
|
|
6917
|
+
listProfilesAll(start = {}) {
|
|
6918
|
+
return collectPages(start, (p) => this.listProfiles(p));
|
|
6919
|
+
}
|
|
6920
|
+
/**
|
|
6921
|
+
* `POST /api/v1/network/profiles`
|
|
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 createProfile(body) {
|
|
6927
|
+
const wire = await sendManagement(this.#client, {
|
|
6928
|
+
operation: "network.create_profile",
|
|
6929
|
+
method: "POST",
|
|
6930
|
+
pathTemplate: "/api/v1/network/profiles",
|
|
6931
|
+
path: "/api/v1/network/profiles",
|
|
6932
|
+
body
|
|
6933
|
+
});
|
|
6934
|
+
return wire;
|
|
6935
|
+
}
|
|
6936
|
+
/** `GET /api/v1/network/profiles/{segment_id}` */
|
|
6937
|
+
async getProfile(segmentId) {
|
|
6938
|
+
const wire = await sendManagement(this.#client, {
|
|
6939
|
+
operation: "network.get_profile",
|
|
6940
|
+
method: "GET",
|
|
6941
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6942
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
|
|
6943
|
+
});
|
|
6944
|
+
return wire;
|
|
6945
|
+
}
|
|
6946
|
+
/**
|
|
6947
|
+
* `PUT /api/v1/network/profiles/{segment_id}`
|
|
6948
|
+
*
|
|
6949
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
|
|
6950
|
+
* body is required, and what you do not carry over from a prior read is not
|
|
6951
|
+
* preserved — it is overwritten. Read first, change the field you mean, send
|
|
6952
|
+
* the whole thing back.
|
|
6953
|
+
*
|
|
6954
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6955
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6956
|
+
*/
|
|
6957
|
+
async replaceProfile(segmentId, body) {
|
|
6958
|
+
const wire = await sendManagement(this.#client, {
|
|
6959
|
+
operation: "network.replace_profile",
|
|
6960
|
+
method: "PUT",
|
|
6961
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6962
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
|
|
6963
|
+
body
|
|
6964
|
+
});
|
|
6965
|
+
return wire;
|
|
6966
|
+
}
|
|
6967
|
+
/**
|
|
6968
|
+
* `DELETE /api/v1/network/profiles/{segment_id}`
|
|
6969
|
+
*
|
|
6970
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6971
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6972
|
+
*/
|
|
6973
|
+
async deleteProfile(segmentId, version) {
|
|
6974
|
+
await sendManagement(this.#client, {
|
|
6975
|
+
operation: "network.delete_profile",
|
|
6976
|
+
method: "DELETE",
|
|
6977
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6978
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
|
|
6979
|
+
query: { "version": String(version) }
|
|
6980
|
+
});
|
|
6981
|
+
}
|
|
6982
|
+
/** `GET /api/v1/network/policy` */
|
|
6983
|
+
async getPolicy() {
|
|
6984
|
+
const wire = await sendManagement(this.#client, {
|
|
6985
|
+
operation: "network.get_policy",
|
|
6986
|
+
method: "GET",
|
|
6987
|
+
pathTemplate: "/api/v1/network/policy",
|
|
6988
|
+
path: "/api/v1/network/policy"
|
|
6989
|
+
});
|
|
6990
|
+
return wire;
|
|
6991
|
+
}
|
|
6992
|
+
/**
|
|
6993
|
+
* `PUT /api/v1/network/policy`
|
|
6994
|
+
*
|
|
6995
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
|
|
6996
|
+
* body is required, and what you do not carry over from a prior read is not
|
|
6997
|
+
* preserved — it is overwritten. Read first, change the field you mean, send
|
|
6998
|
+
* the whole thing back.
|
|
6999
|
+
*
|
|
7000
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
7001
|
+
* issued exactly once, including the ones that look idempotent.
|
|
7002
|
+
*/
|
|
7003
|
+
async replacePolicy(body) {
|
|
7004
|
+
const wire = await sendManagement(this.#client, {
|
|
7005
|
+
operation: "network.replace_policy",
|
|
7006
|
+
method: "PUT",
|
|
7007
|
+
pathTemplate: "/api/v1/network/policy",
|
|
7008
|
+
path: "/api/v1/network/policy",
|
|
7009
|
+
body
|
|
7010
|
+
});
|
|
7011
|
+
return wire;
|
|
7012
|
+
}
|
|
7013
|
+
};
|
|
7014
|
+
|
|
6429
7015
|
// src/management/ops/settings.ts
|
|
6430
7016
|
var SettingsApi = class _SettingsApi {
|
|
6431
7017
|
#client;
|
|
@@ -7050,6 +7636,9 @@ function managementNamespaces(client) {
|
|
|
7050
7636
|
get scimTargets() {
|
|
7051
7637
|
return new ScimTargetsApi(client);
|
|
7052
7638
|
},
|
|
7639
|
+
get network() {
|
|
7640
|
+
return new NetworkApi(client);
|
|
7641
|
+
},
|
|
7053
7642
|
get settings() {
|
|
7054
7643
|
return new SettingsApi(client);
|
|
7055
7644
|
},
|
|
@@ -9175,9 +9764,21 @@ var OidcClient = class {
|
|
|
9175
9764
|
* and obtain the code pair.
|
|
9176
9765
|
*
|
|
9177
9766
|
* @remarks
|
|
9178
|
-
* **
|
|
9179
|
-
*
|
|
9180
|
-
*
|
|
9767
|
+
* **The client authenticates as it does at every other token request
|
|
9768
|
+
* (contract 1.62, §14.1 rule 2).** A client built with a `clientSecret` sends
|
|
9769
|
+
* it as `client_secret` in the **form body** — never as `Authorization:
|
|
9770
|
+
* Basic`, whatever the client is registered for (§12.1 rule 3 stands for
|
|
9771
|
+
* this route, and the maintainer's 2026-10-16 "same rules" reading fixes the
|
|
9772
|
+
* form body) — and a client with a §6.1 client certificate presents it on the
|
|
9773
|
+
* connection, through the `mtls_endpoint_aliases` entry when discovery
|
|
9774
|
+
* publishes one (§21.3). **A public client sends no credential at all** and
|
|
9775
|
+
* is never refused client-side, so a device that cannot hold a secret still
|
|
9776
|
+
* works. The SDK sends a credential only when its caller configured one: it
|
|
9777
|
+
* never borrows one from another configuration. `private_key_jwt` client
|
|
9778
|
+
* authentication is not implemented by this SDK.
|
|
9779
|
+
*
|
|
9780
|
+
* A `401` with `{"error":"invalid_client"}` is an {@link OAuthProtocolError}
|
|
9781
|
+
* (§14.2 rule 5), is made once, and does not enter the §9 refresh guard.
|
|
9181
9782
|
*/
|
|
9182
9783
|
async deviceAuthorize(params = {}) {
|
|
9183
9784
|
const configuration = params.configuration ?? await this.oidcDiscover();
|
|
@@ -9189,6 +9790,7 @@ var OidcClient = class {
|
|
|
9189
9790
|
}
|
|
9190
9791
|
const form = new URLSearchParams();
|
|
9191
9792
|
form.set("client_id", this.#options.clientId);
|
|
9793
|
+
this.#appendClientSecret(form);
|
|
9192
9794
|
if (params.scope !== void 0) {
|
|
9193
9795
|
form.set("scope", Array.isArray(params.scope) ? params.scope.join(" ") : params.scope);
|
|
9194
9796
|
}
|
|
@@ -9299,6 +9901,15 @@ var OidcClient = class {
|
|
|
9299
9901
|
* {@link OAuthProtocolError} — `authorization_pending` and `slow_down`
|
|
9300
9902
|
* included — so a hand-rolled loop sees exactly what {@link deviceLogin}
|
|
9301
9903
|
* sees. Most callers want {@link deviceLogin}.
|
|
9904
|
+
*
|
|
9905
|
+
* Client authentication is the one {@link deviceAuthorize} describes
|
|
9906
|
+
* (contract 1.62, §14.1 rule 2): a configured `clientSecret` is sent as
|
|
9907
|
+
* `client_secret` in the form body, never as `Authorization: Basic`; a public
|
|
9908
|
+
* client sends none; `client_id` is sent on **every** poll (§14.1 rule 3). A
|
|
9909
|
+
* `401 invalid_client` surfaces as {@link OAuthProtocolError}, is not retried
|
|
9910
|
+
* and does not enter the §9 refresh guard (§14.2 rule 5). This SDK ships no
|
|
9911
|
+
* DPoP proof generator, so it cannot drive a client registered for DPoP; it
|
|
9912
|
+
* surfaces that client's refusal as the same `invalid_client`.
|
|
9302
9913
|
*/
|
|
9303
9914
|
async devicePoll(params) {
|
|
9304
9915
|
const configuration = params.configuration ?? await this.oidcDiscover();
|
|
@@ -9306,6 +9917,7 @@ var OidcClient = class {
|
|
|
9306
9917
|
form.set("grant_type", DEVICE_CODE_GRANT_TYPE);
|
|
9307
9918
|
form.set("device_code", exposeSecret(params.deviceCode));
|
|
9308
9919
|
form.set("client_id", this.#options.clientId);
|
|
9920
|
+
this.#appendClientSecret(form);
|
|
9309
9921
|
const wire = await this.#postToken(configuration, form, params.tenantId);
|
|
9310
9922
|
return this.#toTokenSet(wire, configuration, void 0);
|
|
9311
9923
|
}
|
|
@@ -10224,7 +10836,7 @@ var OidcClient = class {
|
|
|
10224
10836
|
this.#session.axios.interceptors.request.use((config) => {
|
|
10225
10837
|
const adopted = this.#adoptedCredential;
|
|
10226
10838
|
const url = config.url ?? "";
|
|
10227
|
-
if (!adopted || this.#session.isForeignHost(url) || url.
|
|
10839
|
+
if (!adopted || this.#session.isForeignHost(url) || isOAuth2Endpoint(url, this.#session.baseUrl)) {
|
|
10228
10840
|
return config;
|
|
10229
10841
|
}
|
|
10230
10842
|
config.headers = config.headers ?? {};
|