@aopslabs/aops-server 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +6 -5
  2. package/THIRD_PARTY_NOTICES +1112 -90
  3. package/THIRD_PARTY_NOTICES.inventory.json +228 -17
  4. package/build/client/_app/immutable/chunks/{BlANKL2r.js → Bjgoxj0p.js} +1 -1
  5. package/build/client/_app/immutable/entry/{app.a0iGCm6X.js → app.BYB9Sok4.js} +2 -2
  6. package/build/client/_app/immutable/entry/start.B9dFbET3.js +1 -0
  7. package/build/client/_app/immutable/nodes/{1.BtbjYUHR.js → 1.CVn3O1wW.js} +1 -1
  8. package/build/client/_app/version.json +1 -1
  9. package/build/handler.js +3 -3
  10. package/build/index.js +3 -3
  11. package/build/server/chunks/{1-UJuUicIe.js → 1-dRRhKt5b.js} +2 -2
  12. package/build/server/chunks/{_server.ts-BkxSxdd0.js → _server.ts-B-i329o7.js} +29 -68
  13. package/build/server/chunks/{_server.ts-Ua5Ieisy.js → _server.ts-BKHrYeaH.js} +13 -10
  14. package/build/server/chunks/{_server.ts-BX4X0tW0.js → _server.ts-BQ60-REv.js} +1 -1
  15. package/build/server/chunks/{_server.ts-DQzYSH_C.js → _server.ts-BZ4AVjKT.js} +12 -9
  16. package/build/server/chunks/{_server.ts-B9gjXi95.js → _server.ts-BpeZOHh9.js} +1 -1
  17. package/build/server/chunks/{_server.ts-CjzSQgpk.js → _server.ts-Bvm76oFb.js} +11 -8
  18. package/build/server/chunks/{_server.ts-DaIr3NkR.js → _server.ts-BzCsmQvL.js} +1 -1
  19. package/build/server/chunks/{_server.ts-Bz-Erv-1.js → _server.ts-CLPseTqB.js} +1 -1
  20. package/build/server/chunks/{_server.ts-XmKDT59M.js → _server.ts-CUfJtkgM.js} +13 -10
  21. package/build/server/chunks/{_server.ts-AwMeEYiZ.js → _server.ts-Cc0Bnt1g.js} +1 -1
  22. package/build/server/chunks/{_server.ts-u2UWBqNN.js → _server.ts-CsKHhoNV.js} +1 -1
  23. package/build/server/chunks/{_server.ts-N61POKjl.js → _server.ts-D9nuwLDu.js} +12 -9
  24. package/build/server/chunks/{_server.ts-DsTeOL2P.js → _server.ts-DL4m3Nag.js} +1 -1
  25. package/build/server/chunks/{_server.ts-DQWRrk5C.js → _server.ts-DUxJA8_s.js} +1 -1
  26. package/build/server/chunks/{_server.ts-CRKd0KAC.js → _server.ts-Df-V1NXF.js} +13 -10
  27. package/build/server/chunks/{_server.ts-6bdzoHJH.js → _server.ts-Dm0Cz5fI.js} +17 -6
  28. package/build/server/chunks/{_server.ts-o9pJceJP.js → _server.ts-Dpu5VI6c.js} +1 -1
  29. package/build/server/chunks/{_server.ts-De9ZrSV0.js → _server.ts-DxGF-jS0.js} +12 -9
  30. package/build/server/chunks/{agent-gateway-runtime-C7Kvvy0H.js → agent-gateway-runtime-DV-xLmJx.js} +39 -4
  31. package/build/server/chunks/commercial-admission-loader-ZGZHRPLe.js +480 -0
  32. package/build/server/chunks/{discovery-BvDEgiqC.js → discovery-DL0RzVks.js} +2 -2
  33. package/build/server/chunks/{error.svelte-B9R6O_Hn.js → error.svelte-c1sBbVzV.js} +1 -1
  34. package/build/server/chunks/{handler-DurXhqww.js → handler-MPrrqrDK.js} +262 -2
  35. package/build/server/chunks/{hooks.server-DYGrWbgh.js → hooks.server-Dpmff0ik.js} +1 -1
  36. package/build/server/chunks/{index.js-BQnOaW3H.js → index.js-CkBvZHgI.js} +1414 -2293
  37. package/build/server/chunks/{manifest.js-CCJDdahY.js → manifest.js-CVFLTOOv.js} +20 -20
  38. package/build/server/chunks/{registry-DO8ob5o1.js → registry-DIreA2IZ.js} +132 -268
  39. package/cockpit/.vite/manifest.json +122 -122
  40. package/cockpit/community.module-inventory.json +30 -30
  41. package/host.config.json +140 -0
  42. package/npm-shrinkwrap.json +6640 -0
  43. package/package.json +10 -4
  44. package/runtime/commercial-integrity-worker.mjs +8 -1
  45. package/runtime-closure.package.json +26 -6
  46. package/build/client/_app/immutable/entry/start.Df7u6fQ1.js +0 -1
  47. package/build/server/chunks/admission-snapshot-C2wGfTWE.js +0 -1034
  48. package/build/server/chunks/canonical-text-order-DbXJJnFD.js +0 -5
  49. package/build/server/chunks/commercial-admission-loader-V_vXHdVa.js +0 -2077
@@ -0,0 +1,480 @@
1
+ import { readVerifiedActiveCommercialArtifact, verifyEntitlementLease, buildAdmittedDomainSnapshot, RELEASE_MANIFEST_PURPOSE, readCommercialIntegrityVerificationSchedule, createInstallationPossessionProof, verifyInstallationPossessionProof, resolveManagedInstallationLayout, ENTITLEMENT_LEASE_PURPOSE, ENTITLEMENT_LEASE_ALGORITHM } from '@aopslabs/artifact-trust-contracts';
2
+ import { randomBytes, randomUUID } from 'node:crypto';
3
+ import { readFileSync, lstatSync, realpathSync } from 'node:fs';
4
+ import path from 'node:path';
5
+
6
+ function commercialIntegrityReadOptions(storeRoot, requestedMode = "routine") {
7
+ const layout = resolveManagedInstallationLayout();
8
+ if (path.resolve(storeRoot) !== path.resolve(layout.storeRoot)) {
9
+ if (requestedMode === "scheduled") {
10
+ throw new Error("commercial_integrity_scheduler_requires_managed_store");
11
+ }
12
+ return Object.freeze({ verificationMode: "full" });
13
+ }
14
+ return Object.freeze({
15
+ integrityStateRoot: layout.stateRoot,
16
+ verificationMode: requestedMode
17
+ });
18
+ }
19
+ const CONFIG_KEYS_V1 = Object.freeze([
20
+ "domain",
21
+ "entitlementEpoch",
22
+ "extensionNamespace",
23
+ "hostInstanceId",
24
+ "installationId",
25
+ "issuer",
26
+ "leaseFile",
27
+ "leaseMode",
28
+ "leaseTrustBundle",
29
+ "minimumRevocationEpoch",
30
+ "objectType",
31
+ "productId",
32
+ "releaseTrustBundle",
33
+ "schemaVersion",
34
+ "storeRoot",
35
+ "tenantId",
36
+ "target"
37
+ ]);
38
+ const CONFIG_KEYS_V2 = Object.freeze([
39
+ ...CONFIG_KEYS_V1,
40
+ "activationChallengeDigest",
41
+ "installationKeyThumbprint",
42
+ "installationPrivateKeyFile"
43
+ ]);
44
+ const SHA256_HEX = /^[a-f0-9]{64}$/;
45
+ function isRecord(value) {
46
+ return value !== null && typeof value === "object" && !Array.isArray(value);
47
+ }
48
+ function exactKeys(value, expected, reason) {
49
+ const actual = Object.keys(value).sort();
50
+ const sorted = [...expected].sort();
51
+ if (actual.length !== sorted.length || actual.some((key, index) => key !== sorted[index])) {
52
+ throw new Error(reason);
53
+ }
54
+ }
55
+ function text(value, reason) {
56
+ if (typeof value !== "string" || value !== value.trim() || value.length === 0) {
57
+ throw new Error(reason);
58
+ }
59
+ return value;
60
+ }
61
+ function nullableInteger(value, reason) {
62
+ if (value === null) return null;
63
+ if (!Number.isSafeInteger(value) || Number(value) < 0) throw new Error(reason);
64
+ return Number(value);
65
+ }
66
+ function sha256(value, reason) {
67
+ const normalized = text(value, reason);
68
+ if (!SHA256_HEX.test(normalized)) throw new Error(reason);
69
+ return normalized;
70
+ }
71
+ function digestHex(value, reason) {
72
+ const normalized = value.startsWith("sha256:") ? value.slice("sha256:".length) : value;
73
+ if (!SHA256_HEX.test(normalized)) throw new Error(reason);
74
+ return normalized;
75
+ }
76
+ function safeRegularFile(filePath, reason) {
77
+ if (!path.isAbsolute(filePath)) throw new Error(reason);
78
+ try {
79
+ const stat = lstatSync(filePath);
80
+ if (stat.isSymbolicLink() || !stat.isFile()) throw new Error(reason);
81
+ return realpathSync.native(filePath);
82
+ } catch {
83
+ throw new Error(reason);
84
+ }
85
+ }
86
+ function verifyOfflineInstallationPossessionAtLoad(input) {
87
+ const privateKeyPem = readFileSync(
88
+ safeRegularFile(
89
+ input.installationPrivateKeyFile,
90
+ "commercial_installation_private_key_invalid"
91
+ ),
92
+ "utf8"
93
+ );
94
+ const nonce = randomBytes(32).toString("base64url");
95
+ const iat = Math.floor(input.now.getTime() / 1e3);
96
+ const manifestDigest = digestHex(
97
+ input.receipt.manifestDigest,
98
+ "commercial_installation_possession_invalid"
99
+ );
100
+ const closureDigest = digestHex(
101
+ input.receipt.closureDigest,
102
+ "commercial_installation_possession_invalid"
103
+ );
104
+ try {
105
+ const proof = createInstallationPossessionProof({
106
+ privateKeyPem,
107
+ proofId: randomUUID(),
108
+ nonce,
109
+ installationId: input.installationId,
110
+ hostInstanceId: input.hostInstanceId,
111
+ leaseToken: input.leaseToken,
112
+ activationChallengeDigest: input.activationChallengeDigest,
113
+ receiptBinding: {
114
+ receiptId: input.receipt.receiptId,
115
+ releaseId: input.receipt.releaseId,
116
+ manifestDigest,
117
+ closureDigest
118
+ },
119
+ iat,
120
+ exp: iat + 2 * 60
121
+ });
122
+ verifyInstallationPossessionProof({
123
+ token: proof.token,
124
+ now: input.now,
125
+ expected: {
126
+ nonce,
127
+ installationId: input.installationId,
128
+ hostInstanceId: input.hostInstanceId,
129
+ installationKeyThumbprint: input.installationKeyThumbprint,
130
+ leaseToken: input.leaseToken,
131
+ activationChallengeDigest: input.activationChallengeDigest,
132
+ receiptId: input.receipt.receiptId,
133
+ releaseId: input.receipt.releaseId,
134
+ manifestDigest,
135
+ closureDigest
136
+ }
137
+ });
138
+ } catch {
139
+ throw new Error("commercial_installation_possession_invalid");
140
+ }
141
+ }
142
+ function safeRuntimeEntrypoint(storeRoot, relativePath) {
143
+ if (!path.isAbsolute(storeRoot) || path.isAbsolute(relativePath) || relativePath.split(/[\\/]/u).some((segment) => !segment || segment === "." || segment === "..")) throw new Error("commercial_runtime_entrypoint_invalid");
144
+ const root = realpathSync.native(storeRoot);
145
+ const candidate = path.resolve(root, relativePath);
146
+ const relative = path.relative(root, candidate);
147
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
148
+ throw new Error("commercial_runtime_entrypoint_invalid");
149
+ }
150
+ const real = safeRegularFile(candidate, "commercial_runtime_entrypoint_invalid");
151
+ const realRelative = path.relative(root, real);
152
+ if (!realRelative || realRelative.startsWith("..") || path.isAbsolute(realRelative)) {
153
+ throw new Error("commercial_runtime_entrypoint_invalid");
154
+ }
155
+ return real;
156
+ }
157
+ function parseJsonFile(filePath, reason) {
158
+ try {
159
+ return JSON.parse(readFileSync(safeRegularFile(filePath, reason), "utf8"));
160
+ } catch (error) {
161
+ if (error instanceof Error && error.message === reason) throw error;
162
+ throw new Error(reason);
163
+ }
164
+ }
165
+ function parseConfig(filePath) {
166
+ const value = parseJsonFile(filePath, "commercial_admission_config_invalid");
167
+ if (!isRecord(value)) throw new Error("commercial_admission_config_invalid");
168
+ const schemaVersion = value.schemaVersion;
169
+ if (schemaVersion !== 1 && schemaVersion !== 2 || value.objectType !== `aops-commercial-admission-config-v${schemaVersion}`) throw new Error("commercial_admission_config_invalid");
170
+ exactKeys(
171
+ value,
172
+ schemaVersion === 1 ? CONFIG_KEYS_V1 : CONFIG_KEYS_V2,
173
+ "commercial_admission_config_invalid"
174
+ );
175
+ const leaseMode = value.leaseMode;
176
+ if (leaseMode !== null && leaseMode !== "online" && leaseMode !== "offline") {
177
+ throw new Error("commercial_admission_config_invalid");
178
+ }
179
+ if (schemaVersion === 2 && leaseMode !== "offline") {
180
+ throw new Error("commercial_admission_config_invalid");
181
+ }
182
+ return Object.freeze({
183
+ schemaVersion,
184
+ target: text(value.target, "commercial_admission_config_invalid"),
185
+ storeRoot: text(value.storeRoot, "commercial_admission_config_invalid"),
186
+ releaseTrustBundle: text(value.releaseTrustBundle, "commercial_admission_config_invalid"),
187
+ leaseFile: text(value.leaseFile, "commercial_admission_config_invalid"),
188
+ leaseTrustBundle: text(value.leaseTrustBundle, "commercial_admission_config_invalid"),
189
+ issuer: text(value.issuer, "commercial_admission_config_invalid"),
190
+ tenantId: text(value.tenantId, "commercial_admission_config_invalid"),
191
+ installationId: text(value.installationId, "commercial_admission_config_invalid"),
192
+ hostInstanceId: text(value.hostInstanceId, "commercial_admission_config_invalid"),
193
+ productId: text(value.productId, "commercial_admission_config_invalid"),
194
+ domain: text(value.domain, "commercial_admission_config_invalid").toLowerCase(),
195
+ extensionNamespace: text(value.extensionNamespace, "commercial_admission_config_invalid"),
196
+ entitlementEpoch: nullableInteger(value.entitlementEpoch, "commercial_admission_config_invalid"),
197
+ minimumRevocationEpoch: nullableInteger(
198
+ value.minimumRevocationEpoch,
199
+ "commercial_admission_config_invalid"
200
+ ),
201
+ leaseMode,
202
+ activationChallengeDigest: schemaVersion === 1 ? null : sha256(value.activationChallengeDigest, "commercial_admission_config_invalid"),
203
+ installationKeyThumbprint: schemaVersion === 1 ? null : sha256(value.installationKeyThumbprint, "commercial_admission_config_invalid"),
204
+ installationPrivateKeyFile: schemaVersion === 1 ? null : text(value.installationPrivateKeyFile, "commercial_admission_config_invalid")
205
+ });
206
+ }
207
+ function parseReleaseTrustBundleFile(filePath) {
208
+ const value = parseJsonFile(filePath, "release_trust_bundle_invalid");
209
+ if (!isRecord(value)) throw new Error("release_trust_bundle_invalid");
210
+ exactKeys(
211
+ value,
212
+ ["schemaVersion", "objectType", "purpose", "keys"],
213
+ "release_trust_bundle_invalid"
214
+ );
215
+ if (value.schemaVersion !== 1 || value.objectType !== "aops-release-trust-bundle-v1" || value.purpose !== RELEASE_MANIFEST_PURPOSE || !Array.isArray(value.keys) || value.keys.length === 0) throw new Error("release_trust_bundle_invalid");
216
+ const keys = value.keys.map((candidate) => {
217
+ if (!isRecord(candidate)) throw new Error("release_trust_bundle_invalid");
218
+ const actualKeys = Object.keys(candidate).sort();
219
+ const legacyKeys = ["alg", "kid", "publicKeyPem", "purpose"];
220
+ const rotatingKeys = [
221
+ "alg",
222
+ "kid",
223
+ "notAfter",
224
+ "notBefore",
225
+ "publicKeyPem",
226
+ "purpose",
227
+ "status"
228
+ ];
229
+ const rotating = actualKeys.length === rotatingKeys.length && actualKeys.every((key, index) => key === rotatingKeys[index]);
230
+ if (!rotating && (actualKeys.length !== legacyKeys.length || actualKeys.some((key, index) => key !== legacyKeys[index]))) throw new Error("release_trust_bundle_invalid");
231
+ if (candidate.alg !== "EdDSA" || candidate.purpose !== RELEASE_MANIFEST_PURPOSE || typeof candidate.kid !== "string" || typeof candidate.publicKeyPem !== "string" || rotating && !["active", "verify-only", "retired", "revoked"].includes(
232
+ String(candidate.status)
233
+ ) || rotating && candidate.notBefore !== null && typeof candidate.notBefore !== "string" || rotating && candidate.notAfter !== null && typeof candidate.notAfter !== "string") throw new Error("release_trust_bundle_invalid");
234
+ if (candidate.kid.toLowerCase().includes("test-ephemeral")) {
235
+ throw new Error("release_trust_test_key_refused");
236
+ }
237
+ return Object.freeze({
238
+ alg: "EdDSA",
239
+ purpose: RELEASE_MANIFEST_PURPOSE,
240
+ kid: candidate.kid,
241
+ publicKeyPem: candidate.publicKeyPem,
242
+ ...rotating ? {
243
+ status: candidate.status,
244
+ ...candidate.notBefore === null ? {} : { notBefore: candidate.notBefore },
245
+ ...candidate.notAfter === null ? {} : { notAfter: candidate.notAfter }
246
+ } : {}
247
+ });
248
+ });
249
+ if (new Set(keys.map((key) => key.kid)).size !== keys.length) {
250
+ throw new Error("release_trust_bundle_invalid");
251
+ }
252
+ return Object.freeze(keys);
253
+ }
254
+ function parseLeaseTrustBundle(filePath) {
255
+ const value = parseJsonFile(filePath, "lease_trust_bundle_invalid");
256
+ if (!isRecord(value)) throw new Error("lease_trust_bundle_invalid");
257
+ exactKeys(
258
+ value,
259
+ ["schemaVersion", "objectType", "purpose", "keys"],
260
+ "lease_trust_bundle_invalid"
261
+ );
262
+ if (value.schemaVersion !== 1 || value.objectType !== "aops-entitlement-lease-trust-bundle-v1" || value.purpose !== ENTITLEMENT_LEASE_PURPOSE || !Array.isArray(value.keys) || value.keys.length === 0) throw new Error("lease_trust_bundle_invalid");
263
+ const keys = value.keys.map((candidate) => {
264
+ if (!isRecord(candidate)) throw new Error("lease_trust_bundle_invalid");
265
+ exactKeys(
266
+ candidate,
267
+ ["alg", "kid", "notAfter", "notBefore", "publicKeyPem", "purpose", "status"],
268
+ "lease_trust_bundle_invalid"
269
+ );
270
+ if (candidate.alg !== ENTITLEMENT_LEASE_ALGORITHM || candidate.purpose !== ENTITLEMENT_LEASE_PURPOSE || typeof candidate.kid !== "string" || typeof candidate.publicKeyPem !== "string" || candidate.status !== "active" && candidate.status !== "verify-only" || candidate.notBefore !== null && typeof candidate.notBefore !== "string" || candidate.notAfter !== null && typeof candidate.notAfter !== "string") throw new Error("lease_trust_bundle_invalid");
271
+ return Object.freeze({
272
+ alg: ENTITLEMENT_LEASE_ALGORITHM,
273
+ purpose: ENTITLEMENT_LEASE_PURPOSE,
274
+ kid: candidate.kid,
275
+ publicKeyPem: candidate.publicKeyPem,
276
+ status: candidate.status,
277
+ ...candidate.notBefore === null ? {} : { notBefore: candidate.notBefore },
278
+ ...candidate.notAfter === null ? {} : { notAfter: candidate.notAfter }
279
+ });
280
+ });
281
+ if (new Set(keys.map((key) => key.kid)).size !== keys.length) {
282
+ throw new Error("lease_trust_bundle_invalid");
283
+ }
284
+ return Object.freeze(keys);
285
+ }
286
+ function parseOperations(dcmBytes, operationCatalogBytes, domain, extension) {
287
+ let dcmValue;
288
+ let catalogValue;
289
+ try {
290
+ dcmValue = JSON.parse(dcmBytes.toString("utf8"));
291
+ catalogValue = JSON.parse(operationCatalogBytes.toString("utf8"));
292
+ } catch {
293
+ throw new Error("commercial_operation_contract_invalid");
294
+ }
295
+ if (!isRecord(dcmValue) || !isRecord(dcmValue.domain) || dcmValue.domain.id !== domain || !isRecord(dcmValue.capabilities) || !Array.isArray(dcmValue.capabilities.operations) || !Array.isArray(catalogValue) || !isRecord(extension)) throw new Error("commercial_operation_contract_invalid");
296
+ const featureBindings = extension.operationFeatures;
297
+ if (!Array.isArray(featureBindings)) throw new Error("commercial_operation_contract_invalid");
298
+ const features = /* @__PURE__ */ new Map();
299
+ let previousOperationId = "";
300
+ for (const binding of featureBindings) {
301
+ if (!isRecord(binding)) throw new Error("commercial_operation_contract_invalid");
302
+ exactKeys(binding, ["operationId", "requiredFeatureIds"], "commercial_operation_contract_invalid");
303
+ if (typeof binding.operationId !== "string" || !Array.isArray(binding.requiredFeatureIds)) {
304
+ throw new Error("commercial_operation_contract_invalid");
305
+ }
306
+ const required = binding.requiredFeatureIds.map((entry) => text(entry, "commercial_operation_contract_invalid"));
307
+ if (binding.operationId <= previousOperationId || required.length === 0 || new Set(required).size !== required.length || required.some((entry, index) => entry !== [...required].sort()[index])) throw new Error("commercial_operation_contract_invalid");
308
+ previousOperationId = binding.operationId;
309
+ features.set(binding.operationId, Object.freeze(required));
310
+ }
311
+ const catalog = /* @__PURE__ */ new Map();
312
+ for (const operation of catalogValue) {
313
+ if (!isRecord(operation) || typeof operation.operationId !== "string" || typeof operation.sideEffect !== "string" || catalog.has(operation.operationId)) throw new Error("commercial_operation_contract_invalid");
314
+ catalog.set(operation.operationId, operation);
315
+ }
316
+ const policies = dcmValue.capabilities.operations.map((operation) => {
317
+ if (!isRecord(operation) || typeof operation.operationId !== "string" || !["none", "db", "fs", "network", "mixed"].includes(String(operation.sideEffect)) || !features.has(operation.operationId)) throw new Error("commercial_operation_contract_invalid");
318
+ const catalogOperation = catalog.get(operation.operationId);
319
+ if (!catalogOperation || catalogOperation.sideEffect !== operation.sideEffect) {
320
+ throw new Error("commercial_operation_contract_invalid");
321
+ }
322
+ return Object.freeze({
323
+ operationId: operation.operationId,
324
+ requiredFeatureIds: features.get(operation.operationId),
325
+ sideEffect: operation.sideEffect,
326
+ ...isRecord(operation.safety) ? {
327
+ safety: Object.freeze({
328
+ destructive: operation.safety.destructive === true,
329
+ confirmationRequired: operation.safety.confirmationRequired === true,
330
+ applyRequired: operation.safety.applyRequired === true
331
+ })
332
+ } : {}
333
+ });
334
+ });
335
+ if (catalog.size !== policies.length || features.size !== policies.length) {
336
+ throw new Error("commercial_operation_contract_invalid");
337
+ }
338
+ return Object.freeze(policies);
339
+ }
340
+ function loadCommercialAdmissionSnapshot(configFile, freeDomains, now = /* @__PURE__ */ new Date(), generation) {
341
+ const config = parseConfig(configFile);
342
+ const active = readVerifiedActiveCommercialArtifact({
343
+ storeRoot: config.storeRoot,
344
+ ...commercialIntegrityReadOptions(config.storeRoot),
345
+ trustKeys: parseReleaseTrustBundleFile(config.releaseTrustBundle),
346
+ now,
347
+ expectedIdentity: {
348
+ installationId: config.installationId,
349
+ hostInstanceId: config.hostInstanceId
350
+ }
351
+ });
352
+ if (!active) throw new Error("commercial_artifact_not_active");
353
+ const extension = active.manifest.envelope.payload.extensions[config.extensionNamespace];
354
+ if (!isRecord(extension) || extension.releaseTier !== "commercial" || !Array.isArray(extension.productIds) || !extension.productIds.includes(config.productId)) throw new Error("commercial_release_extension_invalid");
355
+ const hostProjection = extension.hostProjection;
356
+ if (!isRecord(hostProjection)) throw new Error("commercial_release_extension_invalid");
357
+ exactKeys(
358
+ hostProjection,
359
+ ["manifestExport", "pluginFactory"],
360
+ "commercial_release_extension_invalid"
361
+ );
362
+ const pluginFactory = text(
363
+ hostProjection.pluginFactory,
364
+ "commercial_release_extension_invalid"
365
+ );
366
+ const manifestExport = text(
367
+ hostProjection.manifestExport,
368
+ "commercial_release_extension_invalid"
369
+ );
370
+ const operations = parseOperations(
371
+ active.dcmBytes,
372
+ active.operationCatalogBytes,
373
+ config.domain,
374
+ extension
375
+ );
376
+ const token = readFileSync(safeRegularFile(config.leaseFile, "entitlement_lease_file_invalid"), "utf8").trim();
377
+ const lease = verifyEntitlementLease({
378
+ token,
379
+ trustKeys: parseLeaseTrustBundle(config.leaseTrustBundle),
380
+ issuer: config.issuer,
381
+ now,
382
+ expected: {
383
+ tenantId: config.tenantId,
384
+ installationId: config.installationId,
385
+ productId: config.productId,
386
+ domain: config.domain,
387
+ manifestDigest: active.manifest.manifestDigest,
388
+ closureDigest: active.receipt.closureDigest,
389
+ ...config.entitlementEpoch === null ? {} : {
390
+ entitlementEpoch: config.entitlementEpoch
391
+ },
392
+ ...config.minimumRevocationEpoch === null ? {} : {
393
+ minimumRevocationEpoch: config.minimumRevocationEpoch
394
+ },
395
+ ...config.leaseMode === null ? {} : { leaseMode: config.leaseMode },
396
+ ...config.installationKeyThumbprint === null ? {} : {
397
+ installationKeyThumbprint: config.installationKeyThumbprint
398
+ },
399
+ ...config.activationChallengeDigest === null ? {} : {
400
+ activationChallengeDigest: config.activationChallengeDigest
401
+ }
402
+ }
403
+ });
404
+ if (config.schemaVersion === 2) {
405
+ if (lease.claims.schemaVersion !== 2 || config.installationPrivateKeyFile === null || config.installationKeyThumbprint === null || config.activationChallengeDigest === null) throw new Error("commercial_installation_possession_invalid");
406
+ verifyOfflineInstallationPossessionAtLoad({
407
+ installationPrivateKeyFile: config.installationPrivateKeyFile,
408
+ installationKeyThumbprint: config.installationKeyThumbprint,
409
+ activationChallengeDigest: config.activationChallengeDigest,
410
+ installationId: config.installationId,
411
+ hostInstanceId: config.hostInstanceId,
412
+ leaseToken: token,
413
+ receipt: {
414
+ receiptId: active.receipt.receiptId,
415
+ releaseId: active.receipt.releaseId,
416
+ manifestDigest: active.receipt.manifestDigest,
417
+ closureDigest: active.receipt.closureDigest
418
+ },
419
+ now
420
+ });
421
+ }
422
+ const operationIds = new Set(operations.map((operation) => operation.operationId));
423
+ if (active.manifest.envelope.payload.degradedOperationIds.some(
424
+ (operationId) => !operationIds.has(operationId)
425
+ )) throw new Error("commercial_operation_contract_invalid");
426
+ const manifestEntrypoint = active.receipt.resolvedEntrypoints.manifestProviders[0] ?? active.receipt.resolvedEntrypoints.dcmProviders[0];
427
+ if (!manifestEntrypoint) throw new Error("commercial_runtime_entrypoint_invalid");
428
+ const snapshot = buildAdmittedDomainSnapshot({
429
+ generation: generation ?? Math.max(2, active.receipt.activation.generation + 1),
430
+ freeDomains,
431
+ commercialDomains: [{
432
+ domain: config.domain,
433
+ productId: config.productId,
434
+ receipt: active.receipt,
435
+ manifest: active.manifest,
436
+ lease,
437
+ operations
438
+ }],
439
+ now
440
+ });
441
+ return Object.freeze({
442
+ snapshot,
443
+ runtime: Object.freeze({
444
+ domain: config.domain,
445
+ pluginModule: safeRuntimeEntrypoint(
446
+ config.storeRoot,
447
+ active.receipt.resolvedEntrypoints.plugin
448
+ ),
449
+ pluginFactory,
450
+ manifestModule: safeRuntimeEntrypoint(config.storeRoot, manifestEntrypoint),
451
+ manifestExport
452
+ })
453
+ });
454
+ }
455
+ function readCommercialAdmissionIntegritySchedule(configFile, now = /* @__PURE__ */ new Date()) {
456
+ const config = parseConfig(configFile);
457
+ const options = commercialIntegrityReadOptions(config.storeRoot, "scheduled");
458
+ if (!options.integrityStateRoot) {
459
+ throw new Error("commercial_integrity_scheduler_requires_managed_store");
460
+ }
461
+ return readCommercialIntegrityVerificationSchedule(options.integrityStateRoot, now);
462
+ }
463
+ function resolveCommercialIntegrityWorkerInput(configFile) {
464
+ const config = parseConfig(configFile);
465
+ const options = commercialIntegrityReadOptions(config.storeRoot, "scheduled");
466
+ if (!options.integrityStateRoot) {
467
+ throw new Error("commercial_integrity_scheduler_requires_managed_store");
468
+ }
469
+ return Object.freeze({
470
+ storeRoot: config.storeRoot,
471
+ integrityStateRoot: options.integrityStateRoot,
472
+ trustKeys: parseReleaseTrustBundleFile(config.releaseTrustBundle),
473
+ expectedIdentity: Object.freeze({
474
+ installationId: config.installationId,
475
+ hostInstanceId: config.hostInstanceId
476
+ })
477
+ });
478
+ }
479
+
480
+ export { loadCommercialAdmissionSnapshot, parseReleaseTrustBundleFile, readCommercialAdmissionIntegritySchedule, resolveCommercialIntegrityWorkerInput, verifyOfflineInstallationPossessionAtLoad };
@@ -1,5 +1,5 @@
1
- import { g as getAgentGateway, n as normalizeDomain, a as normalizeToolId, r as resolveOperationKind } from './agent-gateway-runtime-C7Kvvy0H.js';
2
- import { g as getHostConfig } from './registry-DO8ob5o1.js';
1
+ import { g as getAgentGateway, n as normalizeDomain, a as normalizeToolId, r as resolveOperationKind } from './agent-gateway-runtime-DV-xLmJx.js';
2
+ import { g as getHostConfig } from './registry-DIreA2IZ.js';
3
3
  import { g as getAuthProvider, i as isTrustedLocalAuthProvider } from './auth-provider-C07OUlnz.js';
4
4
 
5
5
  const COMMUNITY_CLIENT_COMPATIBILITY_SCHEMA_VERSION = 1;
@@ -1,4 +1,4 @@
1
- import { e as escape_html, g as getContext, n as noop, w as writable } from './index.js-BQnOaW3H.js';
1
+ import { e as escape_html, g as getContext, n as noop, w as writable } from './index.js-CkBvZHgI.js';
2
2
 
3
3
  function create_updated_store() {
4
4
  const { set, subscribe } = writable(false);