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.mjs
CHANGED
|
@@ -782,6 +782,12 @@ var SKIP_REFRESH = [
|
|
|
782
782
|
// regardless of what session state came before it.
|
|
783
783
|
"/api/v1/auth/device",
|
|
784
784
|
"/oauth2/token",
|
|
785
|
+
// CONTRACT.md §14.2 rule 5 (contract 1.62): a client that fails to
|
|
786
|
+
// authenticate at the device endpoints is `401 invalid_client`, which is not
|
|
787
|
+
// an expired session and which refreshing cannot fix. `/oauth2/token` (the
|
|
788
|
+
// poll) was already here; the authorization endpoint now authenticates the
|
|
789
|
+
// client too, so its 401 must not enter the §9 guard either.
|
|
790
|
+
"/oauth2/device_authorization",
|
|
785
791
|
"/oauth2/introspect",
|
|
786
792
|
"/oauth2/revoke"
|
|
787
793
|
];
|
|
@@ -790,6 +796,9 @@ function installCsrfInterceptor(axiosInstance, session) {
|
|
|
790
796
|
if (session.isForeignHost(config.url)) {
|
|
791
797
|
return config;
|
|
792
798
|
}
|
|
799
|
+
if (isOAuth2Endpoint(config.url, session.baseUrl)) {
|
|
800
|
+
return config;
|
|
801
|
+
}
|
|
793
802
|
const method = (config.method ?? "get").toLowerCase();
|
|
794
803
|
const cookieString = typeof document !== "undefined" ? document.cookie : "";
|
|
795
804
|
const csrfToken = typeof document !== "undefined" ? csrfHeaderForMethod(method, cookieString) : csrfHeaderForMethod(method, session.csrfToken ? `axiam_csrf=${session.csrfToken}` : "");
|
|
@@ -843,15 +852,35 @@ function installRefreshInterceptor(axiosInstance, session) {
|
|
|
843
852
|
}
|
|
844
853
|
);
|
|
845
854
|
}
|
|
855
|
+
function isOAuth2Endpoint(url, baseUrl) {
|
|
856
|
+
if (!url) {
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
try {
|
|
860
|
+
const base = new URL(baseUrl);
|
|
861
|
+
let path = new URL(url, base).pathname;
|
|
862
|
+
const prefix = base.pathname.replace(/\/+$/, "");
|
|
863
|
+
if (prefix !== "" && path.startsWith(`${prefix}/`)) {
|
|
864
|
+
path = path.slice(prefix.length);
|
|
865
|
+
}
|
|
866
|
+
return path.startsWith("/oauth2/");
|
|
867
|
+
} catch {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
846
871
|
function installDeviceTokenInterceptor(axiosInstance, session) {
|
|
847
872
|
axiosInstance.interceptors.request.use((config) => {
|
|
848
873
|
const deviceToken = session.deviceAccessToken;
|
|
849
|
-
|
|
874
|
+
const oauth2 = isOAuth2Endpoint(config.url, session.baseUrl);
|
|
875
|
+
if (session.isForeignHost(config.url) || deviceToken === void 0 && !oauth2) {
|
|
850
876
|
return config;
|
|
851
877
|
}
|
|
852
878
|
const noCred = session.noCredentialsConfig();
|
|
853
879
|
Object.assign(config, noCred);
|
|
854
880
|
config.headers = config.headers ?? {};
|
|
881
|
+
if (oauth2) {
|
|
882
|
+
return config;
|
|
883
|
+
}
|
|
855
884
|
config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
|
|
856
885
|
config.headers["Cookie"] = "";
|
|
857
886
|
return config;
|
|
@@ -1810,10 +1839,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
|
|
|
1810
1839
|
var ConflictError = class _ConflictError extends AuthzError {
|
|
1811
1840
|
/** The registry operation that conflicted. */
|
|
1812
1841
|
operation;
|
|
1813
|
-
|
|
1842
|
+
/**
|
|
1843
|
+
* The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
|
|
1844
|
+
* or `undefined` when the body carries none (a server that predates it, or a
|
|
1845
|
+
* `409` of an operation that does not name one).
|
|
1846
|
+
*
|
|
1847
|
+
* The `409` of every `network` operation says which conflict it is:
|
|
1848
|
+
* `stale_version`, `strands_profile`, `has_children`, `site_gone`,
|
|
1849
|
+
* `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
|
|
1850
|
+
* `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
|
|
1851
|
+
* not know is surfaced verbatim, and a caller branches on this member —
|
|
1852
|
+
* never on `message`, which an SDK must not parse. It is not the `reason` of
|
|
1853
|
+
* an authorization decision (§3), which is a human string.
|
|
1854
|
+
*/
|
|
1855
|
+
reasonCode;
|
|
1856
|
+
constructor(operation, message, reasonCode) {
|
|
1814
1857
|
super(message);
|
|
1815
1858
|
this.name = "ConflictError";
|
|
1816
1859
|
this.operation = operation;
|
|
1860
|
+
this.reasonCode = reasonCode;
|
|
1817
1861
|
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
1818
1862
|
}
|
|
1819
1863
|
};
|
|
@@ -2102,6 +2146,14 @@ function omitEmptyTenantScope(body) {
|
|
|
2102
2146
|
}
|
|
2103
2147
|
return body;
|
|
2104
2148
|
}
|
|
2149
|
+
function omitNullMembers(body, members) {
|
|
2150
|
+
if (!body || typeof body !== "object") return body;
|
|
2151
|
+
const record = body;
|
|
2152
|
+
if (!members.some((m) => m in record && record[m] === null)) return body;
|
|
2153
|
+
const copy = { ...record };
|
|
2154
|
+
for (const m of members) if (copy[m] === null) delete copy[m];
|
|
2155
|
+
return copy;
|
|
2156
|
+
}
|
|
2105
2157
|
function roleAssignmentInherits(assignment) {
|
|
2106
2158
|
return assignment.inherit ?? true;
|
|
2107
2159
|
}
|
|
@@ -2574,6 +2626,7 @@ function validate(manifest) {
|
|
|
2574
2626
|
const groups = manifest.groups ?? [];
|
|
2575
2627
|
const users = manifest.users ?? [];
|
|
2576
2628
|
const serviceAccounts = manifest.serviceAccounts ?? [];
|
|
2629
|
+
const network = manifest.network;
|
|
2577
2630
|
const resourceKeys = new Set(resources.map((r) => r.key));
|
|
2578
2631
|
const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
|
|
2579
2632
|
const permissionKeys = new Set(permissions.map((p) => p.key));
|
|
@@ -2587,6 +2640,7 @@ function validate(manifest) {
|
|
|
2587
2640
|
duplicates("group", groups.map((g) => g.key), problems);
|
|
2588
2641
|
duplicates("user", users.map((u) => u.key), problems);
|
|
2589
2642
|
duplicates("service account", serviceAccounts.map((s) => s.key), problems);
|
|
2643
|
+
if (network !== void 0) validateNetwork(network, problems);
|
|
2590
2644
|
for (const resource of resources) {
|
|
2591
2645
|
if (resource.parent && !resourceKeys.has(resource.parent)) {
|
|
2592
2646
|
problems.push(
|
|
@@ -2666,6 +2720,51 @@ function validate(manifest) {
|
|
|
2666
2720
|
}
|
|
2667
2721
|
}
|
|
2668
2722
|
var q = (s) => JSON.stringify(s);
|
|
2723
|
+
function validateNetwork(network, problems) {
|
|
2724
|
+
if (Array.isArray(network.policy)) {
|
|
2725
|
+
problems.push("network declares more than one policy; the tenant has exactly one");
|
|
2726
|
+
}
|
|
2727
|
+
const segments = network.segments ?? [];
|
|
2728
|
+
const profiles = network.profiles ?? [];
|
|
2729
|
+
duplicates("network segment", segments.map((s) => s.key), problems);
|
|
2730
|
+
const naturalKeys = /* @__PURE__ */ new Set();
|
|
2731
|
+
for (const segment of segments) {
|
|
2732
|
+
const natural = `${segment.site}/${segment.kind}/${segment.name}`;
|
|
2733
|
+
if (naturalKeys.has(natural)) {
|
|
2734
|
+
problems.push(
|
|
2735
|
+
`network segment ${q(natural)} (site, kind, name) is declared more than once`
|
|
2736
|
+
);
|
|
2737
|
+
}
|
|
2738
|
+
naturalKeys.add(natural);
|
|
2739
|
+
const seenFilters = /* @__PURE__ */ new Set();
|
|
2740
|
+
for (const filter of segment.filterIds ?? []) {
|
|
2741
|
+
if (seenFilters.has(filter)) {
|
|
2742
|
+
problems.push(
|
|
2743
|
+
`network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
|
|
2744
|
+
);
|
|
2745
|
+
}
|
|
2746
|
+
seenFilters.add(filter);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
const segmentKeys = new Set(segments.map((s) => s.key));
|
|
2750
|
+
const profiled = /* @__PURE__ */ new Set();
|
|
2751
|
+
for (const profile of profiles) {
|
|
2752
|
+
if (!segmentKeys.has(profile.segment)) {
|
|
2753
|
+
problems.push(
|
|
2754
|
+
`network profile names segment ${q(profile.segment)}, which no network segment declares`
|
|
2755
|
+
);
|
|
2756
|
+
}
|
|
2757
|
+
if (profiled.has(profile.segment)) {
|
|
2758
|
+
problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
|
|
2759
|
+
}
|
|
2760
|
+
profiled.add(profile.segment);
|
|
2761
|
+
if (profile.terminationAction === null) {
|
|
2762
|
+
problems.push(
|
|
2763
|
+
`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)`
|
|
2764
|
+
);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2669
2768
|
function duplicates(kind, keys, problems) {
|
|
2670
2769
|
const seen = /* @__PURE__ */ new Set();
|
|
2671
2770
|
for (const key of keys) {
|
|
@@ -2711,7 +2810,9 @@ var emptyResolved = () => ({
|
|
|
2711
2810
|
roles: /* @__PURE__ */ new Map(),
|
|
2712
2811
|
groups: /* @__PURE__ */ new Map(),
|
|
2713
2812
|
users: /* @__PURE__ */ new Map(),
|
|
2714
|
-
serviceAccounts: /* @__PURE__ */ new Map()
|
|
2813
|
+
serviceAccounts: /* @__PURE__ */ new Map(),
|
|
2814
|
+
segments: /* @__PURE__ */ new Map(),
|
|
2815
|
+
segmentVersions: /* @__PURE__ */ new Map()
|
|
2715
2816
|
});
|
|
2716
2817
|
var ManifestApi = class {
|
|
2717
2818
|
#client;
|
|
@@ -2744,6 +2845,23 @@ var ManifestApi = class {
|
|
|
2744
2845
|
async #read(manifest) {
|
|
2745
2846
|
const c = this.#client;
|
|
2746
2847
|
const start = { limit: PLAN_PAGE };
|
|
2848
|
+
if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
|
|
2849
|
+
return {
|
|
2850
|
+
resources: [],
|
|
2851
|
+
scopes: /* @__PURE__ */ new Map(),
|
|
2852
|
+
permissions: [],
|
|
2853
|
+
roles: [],
|
|
2854
|
+
groups: [],
|
|
2855
|
+
users: [],
|
|
2856
|
+
serviceAccounts: [],
|
|
2857
|
+
roleGrants: /* @__PURE__ */ new Map(),
|
|
2858
|
+
roleUserBindings: /* @__PURE__ */ new Map(),
|
|
2859
|
+
roleGroupBindings: /* @__PURE__ */ new Map(),
|
|
2860
|
+
roleServiceAccountBindings: /* @__PURE__ */ new Map(),
|
|
2861
|
+
groupMembers: /* @__PURE__ */ new Map(),
|
|
2862
|
+
network: await this.#readNetwork(manifest.network, start)
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2747
2865
|
const resources = await c.resources.listAll(start);
|
|
2748
2866
|
const permissions = await c.permissions.listAll(start);
|
|
2749
2867
|
const roles = await c.roles.listAll(start);
|
|
@@ -2799,9 +2917,29 @@ var ManifestApi = class {
|
|
|
2799
2917
|
roleUserBindings,
|
|
2800
2918
|
roleGroupBindings,
|
|
2801
2919
|
roleServiceAccountBindings,
|
|
2802
|
-
groupMembers
|
|
2920
|
+
groupMembers,
|
|
2921
|
+
network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
|
|
2803
2922
|
};
|
|
2804
2923
|
}
|
|
2924
|
+
/**
|
|
2925
|
+
* §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
|
|
2926
|
+
* list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
|
|
2927
|
+
* A section that states no policy does not read it; one that states no
|
|
2928
|
+
* profile does not list them.
|
|
2929
|
+
*/
|
|
2930
|
+
async #readNetwork(spec, start) {
|
|
2931
|
+
const c = this.#client;
|
|
2932
|
+
const policy = spec.policy ? await c.network.getPolicy() : void 0;
|
|
2933
|
+
const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
|
|
2934
|
+
const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
|
|
2935
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
2936
|
+
if ((spec.profiles ?? []).length) {
|
|
2937
|
+
for (const profile of await c.network.listProfilesAll(start)) {
|
|
2938
|
+
profiles.set(profile.segment_id, profile);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
return { policy, segments, profiles };
|
|
2942
|
+
}
|
|
2805
2943
|
// -------------------------------------------------------------------
|
|
2806
2944
|
// Plan
|
|
2807
2945
|
// -------------------------------------------------------------------
|
|
@@ -3072,8 +3210,97 @@ var ManifestApi = class {
|
|
|
3072
3210
|
push
|
|
3073
3211
|
);
|
|
3074
3212
|
}
|
|
3213
|
+
if (manifest.network && snapshot.network) {
|
|
3214
|
+
this.#networkSteps(manifest.network, snapshot.network, resolved, push);
|
|
3215
|
+
}
|
|
3075
3216
|
return out;
|
|
3076
3217
|
}
|
|
3218
|
+
/**
|
|
3219
|
+
* §27.6.2 — the `network` section: the policy, then the segments, then the
|
|
3220
|
+
* profiles, a profile after its segment (item 2). Every comparison is with
|
|
3221
|
+
* the value **as the read returns it** (item 3): a profile's effective
|
|
3222
|
+
* (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
|
|
3223
|
+
* Silence is not an assertion (rule 3): a member left off never drifts, and
|
|
3224
|
+
* the `Update` body carries the read's value for it (item 4).
|
|
3225
|
+
*/
|
|
3226
|
+
#networkSteps(spec, read, resolved, push) {
|
|
3227
|
+
if (spec.policy) {
|
|
3228
|
+
const current = read.policy;
|
|
3229
|
+
const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
|
|
3230
|
+
push(
|
|
3231
|
+
drifted ? "update" : "no-change",
|
|
3232
|
+
"network-policy",
|
|
3233
|
+
"network.policy",
|
|
3234
|
+
"network policy (Session-Timeout cap)",
|
|
3235
|
+
drifted ? {
|
|
3236
|
+
kind: "update-network-policy",
|
|
3237
|
+
body: {
|
|
3238
|
+
session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
|
|
3239
|
+
version: current.version
|
|
3240
|
+
}
|
|
3241
|
+
} : { kind: "noop" }
|
|
3242
|
+
);
|
|
3243
|
+
}
|
|
3244
|
+
const segments = spec.segments ?? [];
|
|
3245
|
+
for (const segment of segments) {
|
|
3246
|
+
const found = read.segments.find(
|
|
3247
|
+
(r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
|
|
3248
|
+
);
|
|
3249
|
+
const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
|
|
3250
|
+
if (!found) {
|
|
3251
|
+
push("create", "network-segment", segment.key, summary, {
|
|
3252
|
+
kind: "create-network-segment",
|
|
3253
|
+
key: segment.key,
|
|
3254
|
+
body: segmentCreateBody(segment)
|
|
3255
|
+
});
|
|
3256
|
+
continue;
|
|
3257
|
+
}
|
|
3258
|
+
resolved.segments.set(segment.key, found.id);
|
|
3259
|
+
resolved.segmentVersions.set(segment.key, found.version);
|
|
3260
|
+
const drifted = segmentDrifted(segment, found);
|
|
3261
|
+
push(
|
|
3262
|
+
drifted ? "update" : "no-change",
|
|
3263
|
+
"network-segment",
|
|
3264
|
+
segment.key,
|
|
3265
|
+
summary,
|
|
3266
|
+
drifted ? {
|
|
3267
|
+
kind: "update-network-segment",
|
|
3268
|
+
key: segment.key,
|
|
3269
|
+
id: found.id,
|
|
3270
|
+
body: segmentReplaceBody(segment, found)
|
|
3271
|
+
} : { kind: "noop" }
|
|
3272
|
+
);
|
|
3273
|
+
}
|
|
3274
|
+
const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
|
|
3275
|
+
for (const segment of segments) {
|
|
3276
|
+
const profile = bySegment.get(segment.key);
|
|
3277
|
+
if (!profile) continue;
|
|
3278
|
+
const segmentId = resolved.segments.get(segment.key);
|
|
3279
|
+
const found = segmentId ? read.profiles.get(segmentId) : void 0;
|
|
3280
|
+
const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
|
|
3281
|
+
if (!found) {
|
|
3282
|
+
push("create", "network-profile", segment.key, summary, {
|
|
3283
|
+
kind: "create-network-profile",
|
|
3284
|
+
segment: segment.key,
|
|
3285
|
+
profile: profileCreateInput(profile)
|
|
3286
|
+
});
|
|
3287
|
+
continue;
|
|
3288
|
+
}
|
|
3289
|
+
const drifted = profileDrifted(profile, found);
|
|
3290
|
+
push(
|
|
3291
|
+
drifted ? "update" : "no-change",
|
|
3292
|
+
"network-profile",
|
|
3293
|
+
segment.key,
|
|
3294
|
+
summary,
|
|
3295
|
+
drifted ? {
|
|
3296
|
+
kind: "update-network-profile",
|
|
3297
|
+
segment: segment.key,
|
|
3298
|
+
version: found.version,
|
|
3299
|
+
profile: profileReplaceInput(profile, found)
|
|
3300
|
+
} : { kind: "noop" }
|
|
3301
|
+
);
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3077
3304
|
/**
|
|
3078
3305
|
* §27.6.1 item 2 — one subject's `roles[]` against the server's existing
|
|
3079
3306
|
* bindings for it. Shared by groups, users and service accounts: the
|
|
@@ -3141,9 +3368,14 @@ var ManifestApi = class {
|
|
|
3141
3368
|
}
|
|
3142
3369
|
} catch (err) {
|
|
3143
3370
|
stopped = true;
|
|
3371
|
+
const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
|
|
3144
3372
|
out.push({
|
|
3145
3373
|
action,
|
|
3146
|
-
outcome: {
|
|
3374
|
+
outcome: {
|
|
3375
|
+
status: "failed",
|
|
3376
|
+
message: err instanceof Error ? err.message : String(err),
|
|
3377
|
+
...reasonCode === void 0 ? {} : { reasonCode }
|
|
3378
|
+
}
|
|
3147
3379
|
});
|
|
3148
3380
|
}
|
|
3149
3381
|
}
|
|
@@ -3250,6 +3482,34 @@ var ManifestApi = class {
|
|
|
3250
3482
|
description: step.description
|
|
3251
3483
|
});
|
|
3252
3484
|
return void 0;
|
|
3485
|
+
case "update-network-policy":
|
|
3486
|
+
await c.network.replacePolicy(step.body);
|
|
3487
|
+
return void 0;
|
|
3488
|
+
case "create-network-segment": {
|
|
3489
|
+
const created = await c.network.createSegment(step.body);
|
|
3490
|
+
resolved.segments.set(step.key, created.id);
|
|
3491
|
+
resolved.segmentVersions.set(step.key, created.version);
|
|
3492
|
+
return void 0;
|
|
3493
|
+
}
|
|
3494
|
+
case "update-network-segment": {
|
|
3495
|
+
const replaced = await c.network.replaceSegment(step.id, step.body);
|
|
3496
|
+
resolved.segmentVersions.set(step.key, replaced.version);
|
|
3497
|
+
return void 0;
|
|
3498
|
+
}
|
|
3499
|
+
case "create-network-profile":
|
|
3500
|
+
await c.network.createProfile({
|
|
3501
|
+
segment_id: lookup(resolved.segments, step.segment, "network segment"),
|
|
3502
|
+
segment_version: lookupVersion(resolved.segmentVersions, step.segment),
|
|
3503
|
+
profile: step.profile
|
|
3504
|
+
});
|
|
3505
|
+
return void 0;
|
|
3506
|
+
case "update-network-profile":
|
|
3507
|
+
await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
|
|
3508
|
+
version: step.version,
|
|
3509
|
+
segment_version: lookupVersion(resolved.segmentVersions, step.segment),
|
|
3510
|
+
profile: step.profile
|
|
3511
|
+
});
|
|
3512
|
+
return void 0;
|
|
3253
3513
|
case "assign-role":
|
|
3254
3514
|
await this.#assign(step, resolved);
|
|
3255
3515
|
return void 0;
|
|
@@ -3387,6 +3647,107 @@ function lookup(map, key, kind) {
|
|
|
3387
3647
|
}
|
|
3388
3648
|
return id;
|
|
3389
3649
|
}
|
|
3650
|
+
function hasShapeSections(manifest) {
|
|
3651
|
+
return [
|
|
3652
|
+
manifest.resources,
|
|
3653
|
+
manifest.permissions,
|
|
3654
|
+
manifest.roles,
|
|
3655
|
+
manifest.groups,
|
|
3656
|
+
manifest.users,
|
|
3657
|
+
manifest.serviceAccounts
|
|
3658
|
+
].some((section) => (section ?? []).length > 0);
|
|
3659
|
+
}
|
|
3660
|
+
function lookupVersion(map, key) {
|
|
3661
|
+
const version = map.get(key);
|
|
3662
|
+
if (version === void 0) {
|
|
3663
|
+
throw new NetworkError(
|
|
3664
|
+
`internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
|
|
3665
|
+
);
|
|
3666
|
+
}
|
|
3667
|
+
return version;
|
|
3668
|
+
}
|
|
3669
|
+
function sameSet(a, b) {
|
|
3670
|
+
if (a.length !== b.length) return false;
|
|
3671
|
+
const left = new Set(a);
|
|
3672
|
+
return left.size === new Set(b).size && b.every((name) => left.has(name));
|
|
3673
|
+
}
|
|
3674
|
+
function sameOptional(stated, read) {
|
|
3675
|
+
return (stated ?? null) === (read ?? null);
|
|
3676
|
+
}
|
|
3677
|
+
function segmentCreateBody(spec) {
|
|
3678
|
+
const body = {
|
|
3679
|
+
kind: spec.kind,
|
|
3680
|
+
site_key: spec.site,
|
|
3681
|
+
name: spec.name,
|
|
3682
|
+
vlan_id: spec.vlanId
|
|
3683
|
+
};
|
|
3684
|
+
if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
|
|
3685
|
+
if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
|
|
3686
|
+
if (spec.enabled !== void 0) body.enabled = spec.enabled;
|
|
3687
|
+
return body;
|
|
3688
|
+
}
|
|
3689
|
+
function segmentDrifted(spec, read) {
|
|
3690
|
+
if (spec.vlanId !== read.vlan_id) return true;
|
|
3691
|
+
if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
|
|
3692
|
+
if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
|
|
3693
|
+
if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
|
|
3694
|
+
return false;
|
|
3695
|
+
}
|
|
3696
|
+
function segmentReplaceBody(spec, read) {
|
|
3697
|
+
const body = {
|
|
3698
|
+
version: read.version,
|
|
3699
|
+
vlan_id: spec.vlanId,
|
|
3700
|
+
filter_ids: [...spec.filterIds ?? read.filter_ids],
|
|
3701
|
+
enabled: spec.enabled ?? read.enabled
|
|
3702
|
+
};
|
|
3703
|
+
const rank = spec.rank === void 0 ? read.rank : spec.rank;
|
|
3704
|
+
if (rank !== void 0 && rank !== null) body.rank = rank;
|
|
3705
|
+
return body;
|
|
3706
|
+
}
|
|
3707
|
+
function profileCreateInput(spec) {
|
|
3708
|
+
const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
|
|
3709
|
+
if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
|
|
3710
|
+
if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
|
|
3711
|
+
if (spec.filterId != null) profile.filter_id = spec.filterId;
|
|
3712
|
+
if (spec.serviceType != null) profile.service_type = spec.serviceType;
|
|
3713
|
+
return profile;
|
|
3714
|
+
}
|
|
3715
|
+
function profileDrifted(spec, read) {
|
|
3716
|
+
if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
|
|
3717
|
+
if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
|
|
3718
|
+
if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
|
|
3719
|
+
if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
|
|
3720
|
+
if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
|
|
3721
|
+
return false;
|
|
3722
|
+
}
|
|
3723
|
+
var KNOWN_TERMINATION_ACTIONS = ["default", "radius_request"];
|
|
3724
|
+
var KNOWN_SERVICE_TYPES = ["framed_user"];
|
|
3725
|
+
function refuseUnknownCarried(member, stated, read, known) {
|
|
3726
|
+
if (stated !== void 0 || read == null || known.includes(read)) return;
|
|
3727
|
+
throw new ValidationError(
|
|
3728
|
+
"manifest.plan",
|
|
3729
|
+
400,
|
|
3730
|
+
`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)`,
|
|
3731
|
+
[{ field: member, message: `unknown value ${JSON.stringify(read)} on an unstated member` }]
|
|
3732
|
+
);
|
|
3733
|
+
}
|
|
3734
|
+
function profileReplaceInput(spec, read) {
|
|
3735
|
+
const profile = {
|
|
3736
|
+
dictionary: read.dictionary,
|
|
3737
|
+
session_timeout_secs: spec.sessionTimeoutSecs
|
|
3738
|
+
};
|
|
3739
|
+
refuseUnknownCarried("termination_action", spec.terminationAction, read.termination_action, KNOWN_TERMINATION_ACTIONS);
|
|
3740
|
+
refuseUnknownCarried("service_type", spec.serviceType, read.service_type, KNOWN_SERVICE_TYPES);
|
|
3741
|
+
const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
|
|
3742
|
+
if (termination != null) profile.termination_action = termination;
|
|
3743
|
+
const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
|
|
3744
|
+
if (idle != null) profile.idle_timeout_secs = idle;
|
|
3745
|
+
const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
|
|
3746
|
+
if (filter != null) profile.filter_id = filter;
|
|
3747
|
+
const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
|
|
3748
|
+
if (serviceType != null) profile.service_type = serviceType;
|
|
3749
|
+
return profile;
|
|
3750
|
+
}
|
|
3390
3751
|
function bindingOf(assignment) {
|
|
3391
3752
|
return {
|
|
3392
3753
|
resourceId: assignment.resource_id ?? void 0,
|
|
@@ -3504,7 +3865,12 @@ function mapManagementError(operation, err) {
|
|
|
3504
3865
|
);
|
|
3505
3866
|
}
|
|
3506
3867
|
if (status === 409) {
|
|
3507
|
-
|
|
3868
|
+
const code = body?.reason_code;
|
|
3869
|
+
return new ConflictError(
|
|
3870
|
+
operation,
|
|
3871
|
+
`${operation}: conflict${detail}`,
|
|
3872
|
+
typeof code === "string" ? code : void 0
|
|
3873
|
+
);
|
|
3508
3874
|
}
|
|
3509
3875
|
if (status === 400 || status === 422) {
|
|
3510
3876
|
return new ValidationError(
|
|
@@ -3514,7 +3880,7 @@ function mapManagementError(operation, err) {
|
|
|
3514
3880
|
parseFieldErrors(body)
|
|
3515
3881
|
);
|
|
3516
3882
|
}
|
|
3517
|
-
return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
|
|
3883
|
+
return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
|
|
3518
3884
|
}
|
|
3519
3885
|
function describe(body) {
|
|
3520
3886
|
if (typeof body === "string" && body) return `: ${body}`;
|
|
@@ -4808,7 +5174,7 @@ var CertificatesApi = class {
|
|
|
4808
5174
|
method: "POST",
|
|
4809
5175
|
pathTemplate: "/api/v1/certificates",
|
|
4810
5176
|
path: "/api/v1/certificates",
|
|
4811
|
-
body
|
|
5177
|
+
body: omitNullMembers(body, ["user_id"])
|
|
4812
5178
|
});
|
|
4813
5179
|
return generatedCertificateFromWire(wire);
|
|
4814
5180
|
}
|
|
@@ -4825,7 +5191,7 @@ var CertificatesApi = class {
|
|
|
4825
5191
|
method: "POST",
|
|
4826
5192
|
pathTemplate: "/api/v1/certificates/sign-csr",
|
|
4827
5193
|
path: "/api/v1/certificates/sign-csr",
|
|
4828
|
-
body
|
|
5194
|
+
body: omitNullMembers(body, ["user_id"])
|
|
4829
5195
|
});
|
|
4830
5196
|
return wire;
|
|
4831
5197
|
}
|
|
@@ -6219,7 +6585,7 @@ var SsfApi = class _SsfApi {
|
|
|
6219
6585
|
method: "POST",
|
|
6220
6586
|
pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
|
|
6221
6587
|
path: `/api/v1/tenants/${tenantId}/ssf/streams`,
|
|
6222
|
-
body: ssfStreamInputToWire(body)
|
|
6588
|
+
body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
|
|
6223
6589
|
});
|
|
6224
6590
|
return scrubSsfStream(wire);
|
|
6225
6591
|
}
|
|
@@ -6242,8 +6608,19 @@ var SsfApi = class _SsfApi {
|
|
|
6242
6608
|
* update moves `endpoint_url` to another scheme, host or port while a header
|
|
6243
6609
|
* is stored: then it must carry `authorization_header` again or
|
|
6244
6610
|
* `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
|
|
6245
|
-
* `
|
|
6246
|
-
*
|
|
6611
|
+
* `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
|
|
6612
|
+
* `events_requested` and `expected_updated_at` it read and cuts
|
|
6613
|
+
* `events_requested` to a lowered `events_allowed` (or from the plain
|
|
6614
|
+
* converter `ssfStreamInputFrom`, where the cut is yours). An update
|
|
6615
|
+
* overtaken by the receiver's own write is `409`: read the stream again.
|
|
6616
|
+
* **`events_requested` has three meanings on an update** (§32.2, contract
|
|
6617
|
+
* 1.62): **absent resets** the stream to every event of `events_allowed` —
|
|
6618
|
+
* widening what the receiver narrowed; **`[]` is stored as the receiver's
|
|
6619
|
+
* "none"** and the stream carries nothing; **a list is stored as given** and
|
|
6620
|
+
* refused (`400`) if any entry is outside `events_allowed`. A raw API client
|
|
6621
|
+
* is bound by the same meaning: an `events_requested` left out of the `PUT`
|
|
6622
|
+
* resets the stream. `expected_updated_at` is the `updated_at` you read, as
|
|
6623
|
+
* the server's own string; an assigned `null` is "none" and is not sent.
|
|
6247
6624
|
*
|
|
6248
6625
|
* **This is a replacement, not a patch** (§27.4 rule 5). Only the required
|
|
6249
6626
|
* members must be set, but what you do not carry over from a prior read is
|
|
@@ -6261,7 +6638,7 @@ var SsfApi = class _SsfApi {
|
|
|
6261
6638
|
method: "PUT",
|
|
6262
6639
|
pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
|
|
6263
6640
|
path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
|
|
6264
|
-
body: ssfStreamInputToWire(body)
|
|
6641
|
+
body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
|
|
6265
6642
|
});
|
|
6266
6643
|
return scrubSsfStream(wire);
|
|
6267
6644
|
}
|
|
@@ -6329,7 +6706,7 @@ var ScimTargetsApi = class {
|
|
|
6329
6706
|
method: "POST",
|
|
6330
6707
|
pathTemplate: "/api/v1/scim-targets",
|
|
6331
6708
|
path: "/api/v1/scim-targets",
|
|
6332
|
-
body: scimTargetInputToWire(body)
|
|
6709
|
+
body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
|
|
6333
6710
|
});
|
|
6334
6711
|
return scrubScimTargetResponse(wire);
|
|
6335
6712
|
}
|
|
@@ -6376,7 +6753,7 @@ var ScimTargetsApi = class {
|
|
|
6376
6753
|
method: "PUT",
|
|
6377
6754
|
pathTemplate: "/api/v1/scim-targets/{id}",
|
|
6378
6755
|
path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
|
|
6379
|
-
body: scimTargetInputToWire(body)
|
|
6756
|
+
body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
|
|
6380
6757
|
});
|
|
6381
6758
|
return scrubScimTargetResponse(wire);
|
|
6382
6759
|
}
|
|
@@ -6420,6 +6797,215 @@ var ScimTargetsApi = class {
|
|
|
6420
6797
|
}
|
|
6421
6798
|
};
|
|
6422
6799
|
|
|
6800
|
+
// src/management/ops/network.ts
|
|
6801
|
+
var NetworkApi = class {
|
|
6802
|
+
#client;
|
|
6803
|
+
#scope;
|
|
6804
|
+
/** @internal — reached through `client.<namespace>`, never constructed directly. */
|
|
6805
|
+
constructor(client, scope = {}) {
|
|
6806
|
+
this.#client = client;
|
|
6807
|
+
this.#scope = scope;
|
|
6808
|
+
}
|
|
6809
|
+
/** `GET /api/v1/network/segments` */
|
|
6810
|
+
async listSegments(site, page = {}) {
|
|
6811
|
+
const wire = await sendManagement(this.#client, {
|
|
6812
|
+
operation: "network.list_segments",
|
|
6813
|
+
method: "GET",
|
|
6814
|
+
pathTemplate: "/api/v1/network/segments",
|
|
6815
|
+
path: "/api/v1/network/segments",
|
|
6816
|
+
query: { ...pageQuery(page), "site": site }
|
|
6817
|
+
});
|
|
6818
|
+
return wire;
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Walk `network.list_segments` to exhaustion, concatenating every page.
|
|
6822
|
+
*
|
|
6823
|
+
* The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
|
|
6824
|
+
* if `total` disagrees, so a misreporting server costs one wasted request
|
|
6825
|
+
* rather than an unbounded loop.
|
|
6826
|
+
*/
|
|
6827
|
+
listSegmentsAll(site, start = {}) {
|
|
6828
|
+
return collectPages(start, (p) => this.listSegments(site, p));
|
|
6829
|
+
}
|
|
6830
|
+
/**
|
|
6831
|
+
* `POST /api/v1/network/segments`
|
|
6832
|
+
*
|
|
6833
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6834
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6835
|
+
*/
|
|
6836
|
+
async createSegment(body) {
|
|
6837
|
+
const wire = await sendManagement(this.#client, {
|
|
6838
|
+
operation: "network.create_segment",
|
|
6839
|
+
method: "POST",
|
|
6840
|
+
pathTemplate: "/api/v1/network/segments",
|
|
6841
|
+
path: "/api/v1/network/segments",
|
|
6842
|
+
body
|
|
6843
|
+
});
|
|
6844
|
+
return wire;
|
|
6845
|
+
}
|
|
6846
|
+
/** `GET /api/v1/network/segments/{id}` */
|
|
6847
|
+
async getSegment(id) {
|
|
6848
|
+
const wire = await sendManagement(this.#client, {
|
|
6849
|
+
operation: "network.get_segment",
|
|
6850
|
+
method: "GET",
|
|
6851
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6852
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`
|
|
6853
|
+
});
|
|
6854
|
+
return wire;
|
|
6855
|
+
}
|
|
6856
|
+
/**
|
|
6857
|
+
* `PUT /api/v1/network/segments/{id}`
|
|
6858
|
+
*
|
|
6859
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Only the required
|
|
6860
|
+
* members must be set, but what you do not carry over from a prior read is
|
|
6861
|
+
* not preserved: an optional member left out is overwritten with its
|
|
6862
|
+
* default, not kept (except where noted above). Read first, change the field
|
|
6863
|
+
* you mean, send the whole thing back.
|
|
6864
|
+
*
|
|
6865
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6866
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6867
|
+
*/
|
|
6868
|
+
async replaceSegment(id, body) {
|
|
6869
|
+
const wire = await sendManagement(this.#client, {
|
|
6870
|
+
operation: "network.replace_segment",
|
|
6871
|
+
method: "PUT",
|
|
6872
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6873
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
|
|
6874
|
+
body
|
|
6875
|
+
});
|
|
6876
|
+
return wire;
|
|
6877
|
+
}
|
|
6878
|
+
/**
|
|
6879
|
+
* `DELETE /api/v1/network/segments/{id}`
|
|
6880
|
+
*
|
|
6881
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6882
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6883
|
+
*/
|
|
6884
|
+
async deleteSegment(id, version) {
|
|
6885
|
+
await sendManagement(this.#client, {
|
|
6886
|
+
operation: "network.delete_segment",
|
|
6887
|
+
method: "DELETE",
|
|
6888
|
+
pathTemplate: "/api/v1/network/segments/{id}",
|
|
6889
|
+
path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
|
|
6890
|
+
query: { "version": String(version) }
|
|
6891
|
+
});
|
|
6892
|
+
}
|
|
6893
|
+
/** `GET /api/v1/network/profiles` */
|
|
6894
|
+
async listProfiles(page = {}) {
|
|
6895
|
+
const wire = await sendManagement(this.#client, {
|
|
6896
|
+
operation: "network.list_profiles",
|
|
6897
|
+
method: "GET",
|
|
6898
|
+
pathTemplate: "/api/v1/network/profiles",
|
|
6899
|
+
path: "/api/v1/network/profiles",
|
|
6900
|
+
query: { ...pageQuery(page) }
|
|
6901
|
+
});
|
|
6902
|
+
return wire;
|
|
6903
|
+
}
|
|
6904
|
+
/**
|
|
6905
|
+
* Walk `network.list_profiles` to exhaustion, concatenating every page.
|
|
6906
|
+
*
|
|
6907
|
+
* The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
|
|
6908
|
+
* if `total` disagrees, so a misreporting server costs one wasted request
|
|
6909
|
+
* rather than an unbounded loop.
|
|
6910
|
+
*/
|
|
6911
|
+
listProfilesAll(start = {}) {
|
|
6912
|
+
return collectPages(start, (p) => this.listProfiles(p));
|
|
6913
|
+
}
|
|
6914
|
+
/**
|
|
6915
|
+
* `POST /api/v1/network/profiles`
|
|
6916
|
+
*
|
|
6917
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6918
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6919
|
+
*/
|
|
6920
|
+
async createProfile(body) {
|
|
6921
|
+
const wire = await sendManagement(this.#client, {
|
|
6922
|
+
operation: "network.create_profile",
|
|
6923
|
+
method: "POST",
|
|
6924
|
+
pathTemplate: "/api/v1/network/profiles",
|
|
6925
|
+
path: "/api/v1/network/profiles",
|
|
6926
|
+
body
|
|
6927
|
+
});
|
|
6928
|
+
return wire;
|
|
6929
|
+
}
|
|
6930
|
+
/** `GET /api/v1/network/profiles/{segment_id}` */
|
|
6931
|
+
async getProfile(segmentId) {
|
|
6932
|
+
const wire = await sendManagement(this.#client, {
|
|
6933
|
+
operation: "network.get_profile",
|
|
6934
|
+
method: "GET",
|
|
6935
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6936
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
|
|
6937
|
+
});
|
|
6938
|
+
return wire;
|
|
6939
|
+
}
|
|
6940
|
+
/**
|
|
6941
|
+
* `PUT /api/v1/network/profiles/{segment_id}`
|
|
6942
|
+
*
|
|
6943
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
|
|
6944
|
+
* body is required, and what you do not carry over from a prior read is not
|
|
6945
|
+
* preserved — it is overwritten. Read first, change the field you mean, send
|
|
6946
|
+
* the whole thing back.
|
|
6947
|
+
*
|
|
6948
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6949
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6950
|
+
*/
|
|
6951
|
+
async replaceProfile(segmentId, body) {
|
|
6952
|
+
const wire = await sendManagement(this.#client, {
|
|
6953
|
+
operation: "network.replace_profile",
|
|
6954
|
+
method: "PUT",
|
|
6955
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6956
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
|
|
6957
|
+
body
|
|
6958
|
+
});
|
|
6959
|
+
return wire;
|
|
6960
|
+
}
|
|
6961
|
+
/**
|
|
6962
|
+
* `DELETE /api/v1/network/profiles/{segment_id}`
|
|
6963
|
+
*
|
|
6964
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6965
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6966
|
+
*/
|
|
6967
|
+
async deleteProfile(segmentId, version) {
|
|
6968
|
+
await sendManagement(this.#client, {
|
|
6969
|
+
operation: "network.delete_profile",
|
|
6970
|
+
method: "DELETE",
|
|
6971
|
+
pathTemplate: "/api/v1/network/profiles/{segment_id}",
|
|
6972
|
+
path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
|
|
6973
|
+
query: { "version": String(version) }
|
|
6974
|
+
});
|
|
6975
|
+
}
|
|
6976
|
+
/** `GET /api/v1/network/policy` */
|
|
6977
|
+
async getPolicy() {
|
|
6978
|
+
const wire = await sendManagement(this.#client, {
|
|
6979
|
+
operation: "network.get_policy",
|
|
6980
|
+
method: "GET",
|
|
6981
|
+
pathTemplate: "/api/v1/network/policy",
|
|
6982
|
+
path: "/api/v1/network/policy"
|
|
6983
|
+
});
|
|
6984
|
+
return wire;
|
|
6985
|
+
}
|
|
6986
|
+
/**
|
|
6987
|
+
* `PUT /api/v1/network/policy`
|
|
6988
|
+
*
|
|
6989
|
+
* **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
|
|
6990
|
+
* body is required, and what you do not carry over from a prior read is not
|
|
6991
|
+
* preserved — it is overwritten. Read first, change the field you mean, send
|
|
6992
|
+
* the whole thing back.
|
|
6993
|
+
*
|
|
6994
|
+
* Not retried on failure (§27.4 rule 8): every write on this surface is
|
|
6995
|
+
* issued exactly once, including the ones that look idempotent.
|
|
6996
|
+
*/
|
|
6997
|
+
async replacePolicy(body) {
|
|
6998
|
+
const wire = await sendManagement(this.#client, {
|
|
6999
|
+
operation: "network.replace_policy",
|
|
7000
|
+
method: "PUT",
|
|
7001
|
+
pathTemplate: "/api/v1/network/policy",
|
|
7002
|
+
path: "/api/v1/network/policy",
|
|
7003
|
+
body
|
|
7004
|
+
});
|
|
7005
|
+
return wire;
|
|
7006
|
+
}
|
|
7007
|
+
};
|
|
7008
|
+
|
|
6423
7009
|
// src/management/ops/settings.ts
|
|
6424
7010
|
var SettingsApi = class _SettingsApi {
|
|
6425
7011
|
#client;
|
|
@@ -7044,6 +7630,9 @@ function managementNamespaces(client) {
|
|
|
7044
7630
|
get scimTargets() {
|
|
7045
7631
|
return new ScimTargetsApi(client);
|
|
7046
7632
|
},
|
|
7633
|
+
get network() {
|
|
7634
|
+
return new NetworkApi(client);
|
|
7635
|
+
},
|
|
7047
7636
|
get settings() {
|
|
7048
7637
|
return new SettingsApi(client);
|
|
7049
7638
|
},
|
|
@@ -9169,9 +9758,21 @@ var OidcClient = class {
|
|
|
9169
9758
|
* and obtain the code pair.
|
|
9170
9759
|
*
|
|
9171
9760
|
* @remarks
|
|
9172
|
-
* **
|
|
9173
|
-
*
|
|
9174
|
-
*
|
|
9761
|
+
* **The client authenticates as it does at every other token request
|
|
9762
|
+
* (contract 1.62, §14.1 rule 2).** A client built with a `clientSecret` sends
|
|
9763
|
+
* it as `client_secret` in the **form body** — never as `Authorization:
|
|
9764
|
+
* Basic`, whatever the client is registered for (§12.1 rule 3 stands for
|
|
9765
|
+
* this route, and the maintainer's 2026-10-16 "same rules" reading fixes the
|
|
9766
|
+
* form body) — and a client with a §6.1 client certificate presents it on the
|
|
9767
|
+
* connection, through the `mtls_endpoint_aliases` entry when discovery
|
|
9768
|
+
* publishes one (§21.3). **A public client sends no credential at all** and
|
|
9769
|
+
* is never refused client-side, so a device that cannot hold a secret still
|
|
9770
|
+
* works. The SDK sends a credential only when its caller configured one: it
|
|
9771
|
+
* never borrows one from another configuration. `private_key_jwt` client
|
|
9772
|
+
* authentication is not implemented by this SDK.
|
|
9773
|
+
*
|
|
9774
|
+
* A `401` with `{"error":"invalid_client"}` is an {@link OAuthProtocolError}
|
|
9775
|
+
* (§14.2 rule 5), is made once, and does not enter the §9 refresh guard.
|
|
9175
9776
|
*/
|
|
9176
9777
|
async deviceAuthorize(params = {}) {
|
|
9177
9778
|
const configuration = params.configuration ?? await this.oidcDiscover();
|
|
@@ -9183,6 +9784,7 @@ var OidcClient = class {
|
|
|
9183
9784
|
}
|
|
9184
9785
|
const form = new URLSearchParams();
|
|
9185
9786
|
form.set("client_id", this.#options.clientId);
|
|
9787
|
+
this.#appendClientSecret(form);
|
|
9186
9788
|
if (params.scope !== void 0) {
|
|
9187
9789
|
form.set("scope", Array.isArray(params.scope) ? params.scope.join(" ") : params.scope);
|
|
9188
9790
|
}
|
|
@@ -9293,6 +9895,15 @@ var OidcClient = class {
|
|
|
9293
9895
|
* {@link OAuthProtocolError} — `authorization_pending` and `slow_down`
|
|
9294
9896
|
* included — so a hand-rolled loop sees exactly what {@link deviceLogin}
|
|
9295
9897
|
* sees. Most callers want {@link deviceLogin}.
|
|
9898
|
+
*
|
|
9899
|
+
* Client authentication is the one {@link deviceAuthorize} describes
|
|
9900
|
+
* (contract 1.62, §14.1 rule 2): a configured `clientSecret` is sent as
|
|
9901
|
+
* `client_secret` in the form body, never as `Authorization: Basic`; a public
|
|
9902
|
+
* client sends none; `client_id` is sent on **every** poll (§14.1 rule 3). A
|
|
9903
|
+
* `401 invalid_client` surfaces as {@link OAuthProtocolError}, is not retried
|
|
9904
|
+
* and does not enter the §9 refresh guard (§14.2 rule 5). This SDK ships no
|
|
9905
|
+
* DPoP proof generator, so it cannot drive a client registered for DPoP; it
|
|
9906
|
+
* surfaces that client's refusal as the same `invalid_client`.
|
|
9296
9907
|
*/
|
|
9297
9908
|
async devicePoll(params) {
|
|
9298
9909
|
const configuration = params.configuration ?? await this.oidcDiscover();
|
|
@@ -9300,6 +9911,7 @@ var OidcClient = class {
|
|
|
9300
9911
|
form.set("grant_type", DEVICE_CODE_GRANT_TYPE);
|
|
9301
9912
|
form.set("device_code", exposeSecret(params.deviceCode));
|
|
9302
9913
|
form.set("client_id", this.#options.clientId);
|
|
9914
|
+
this.#appendClientSecret(form);
|
|
9303
9915
|
const wire = await this.#postToken(configuration, form, params.tenantId);
|
|
9304
9916
|
return this.#toTokenSet(wire, configuration, void 0);
|
|
9305
9917
|
}
|
|
@@ -10218,7 +10830,7 @@ var OidcClient = class {
|
|
|
10218
10830
|
this.#session.axios.interceptors.request.use((config) => {
|
|
10219
10831
|
const adopted = this.#adoptedCredential;
|
|
10220
10832
|
const url = config.url ?? "";
|
|
10221
|
-
if (!adopted || this.#session.isForeignHost(url) || url.
|
|
10833
|
+
if (!adopted || this.#session.isForeignHost(url) || isOAuth2Endpoint(url, this.#session.baseUrl)) {
|
|
10222
10834
|
return config;
|
|
10223
10835
|
}
|
|
10224
10836
|
config.headers = config.headers ?? {};
|