@cyaxis/ulvia 1.0.0 → 1.0.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/dist/index.js +362 -126
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25240,32 +25240,48 @@ var init_assetFiles = () => {};
|
|
|
25240
25240
|
// packages/features/cms-repository/src/repository/filesystem/core/immutableJsonCache.ts
|
|
25241
25241
|
class ImmutableJsonCache {
|
|
25242
25242
|
maximumEntries;
|
|
25243
|
+
maximumBytes;
|
|
25243
25244
|
entries = new Map;
|
|
25244
|
-
|
|
25245
|
+
bytes = 0;
|
|
25246
|
+
constructor(maximumEntries = 256, maximumBytes = 64 * 1024 * 1024) {
|
|
25245
25247
|
this.maximumEntries = maximumEntries;
|
|
25248
|
+
this.maximumBytes = maximumBytes;
|
|
25246
25249
|
}
|
|
25247
25250
|
get(key, canonicalJson) {
|
|
25251
|
+
return this.project(key, canonicalJson, (value) => value);
|
|
25252
|
+
}
|
|
25253
|
+
project(key, canonicalJson, project) {
|
|
25248
25254
|
const entry = this.entries.get(key);
|
|
25249
25255
|
if (!entry || entry.canonicalJson !== canonicalJson) {
|
|
25250
|
-
this.
|
|
25256
|
+
this.delete(key);
|
|
25251
25257
|
return null;
|
|
25252
25258
|
}
|
|
25253
25259
|
this.entries.delete(key);
|
|
25254
25260
|
this.entries.set(key, entry);
|
|
25255
|
-
return structuredClone(entry.value);
|
|
25261
|
+
return structuredClone(project(entry.value));
|
|
25256
25262
|
}
|
|
25257
25263
|
set(key, canonicalJson, value) {
|
|
25258
|
-
this.
|
|
25259
|
-
|
|
25260
|
-
|
|
25261
|
-
|
|
25264
|
+
this.delete(key);
|
|
25265
|
+
const bytes = canonicalJson.length * 2 + JSON.stringify(value).length * 2;
|
|
25266
|
+
if (bytes <= this.maximumBytes) {
|
|
25267
|
+
const frozen = structuredClone(value);
|
|
25268
|
+
deepFreeze(frozen);
|
|
25269
|
+
this.entries.set(key, { canonicalJson, value: frozen, bytes });
|
|
25270
|
+
this.bytes += bytes;
|
|
25271
|
+
while (this.entries.size > this.maximumEntries || this.bytes > this.maximumBytes) {
|
|
25272
|
+
this.delete(this.entries.keys().next().value);
|
|
25273
|
+
}
|
|
25262
25274
|
}
|
|
25263
25275
|
return structuredClone(value);
|
|
25264
25276
|
}
|
|
25265
25277
|
delete(key) {
|
|
25278
|
+
this.bytes -= this.entries.get(key)?.bytes ?? 0;
|
|
25266
25279
|
this.entries.delete(key);
|
|
25267
25280
|
}
|
|
25268
25281
|
}
|
|
25282
|
+
var init_immutableJsonCache = __esm(() => {
|
|
25283
|
+
init_protocol();
|
|
25284
|
+
});
|
|
25269
25285
|
|
|
25270
25286
|
// packages/features/cms-repository/src/repository/filesystem/artifacts/collections.ts
|
|
25271
25287
|
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
@@ -25359,21 +25375,11 @@ class LocalCollectionRepository {
|
|
|
25359
25375
|
return verifyStoredCollectionArtifact(metadata.release, assets, metadata.digest);
|
|
25360
25376
|
}
|
|
25361
25377
|
async getMetadata(publisherId, collectionId, version) {
|
|
25362
|
-
|
|
25363
|
-
|
|
25364
|
-
}
|
|
25365
|
-
const path = this.releasePath(publisherId, collectionId, version);
|
|
25366
|
-
const bytes = await readFile5(path).catch((error) => {
|
|
25367
|
-
if (error.code === "ENOENT") {
|
|
25368
|
-
this.metadataCache.delete(path);
|
|
25369
|
-
return null;
|
|
25370
|
-
}
|
|
25371
|
-
throw error;
|
|
25372
|
-
});
|
|
25373
|
-
if (!bytes) {
|
|
25378
|
+
const document2 = await this.readDocument(publisherId, collectionId, version);
|
|
25379
|
+
if (!document2) {
|
|
25374
25380
|
return null;
|
|
25375
25381
|
}
|
|
25376
|
-
const canonicalJson =
|
|
25382
|
+
const { path, bytes, canonicalJson } = document2;
|
|
25377
25383
|
const cached = this.metadataCache.get(path, canonicalJson);
|
|
25378
25384
|
if (cached) {
|
|
25379
25385
|
return cached;
|
|
@@ -25386,12 +25392,27 @@ class LocalCollectionRepository {
|
|
|
25386
25392
|
return this.metadataCache.set(path, canonicalJson, artifact);
|
|
25387
25393
|
}
|
|
25388
25394
|
async getAsset(publisherId, collectionId, version, assetId, metadataOnly = false) {
|
|
25389
|
-
const
|
|
25390
|
-
|
|
25391
|
-
if (!metadata || !definition) {
|
|
25395
|
+
const document2 = await this.readDocument(publisherId, collectionId, version);
|
|
25396
|
+
if (!document2) {
|
|
25392
25397
|
return null;
|
|
25393
25398
|
}
|
|
25394
|
-
const
|
|
25399
|
+
const project = (metadata) => ({
|
|
25400
|
+
definition: metadata.release.assets.find((asset) => asset.id === assetId),
|
|
25401
|
+
digest: metadata.digest
|
|
25402
|
+
});
|
|
25403
|
+
let selected = this.metadataCache.project(document2.path, document2.canonicalJson, project);
|
|
25404
|
+
if (!selected) {
|
|
25405
|
+
const metadata = await this.getMetadata(publisherId, collectionId, version);
|
|
25406
|
+
if (!metadata) {
|
|
25407
|
+
return null;
|
|
25408
|
+
}
|
|
25409
|
+
selected = project(metadata);
|
|
25410
|
+
}
|
|
25411
|
+
const definition = selected.definition;
|
|
25412
|
+
if (!definition) {
|
|
25413
|
+
return null;
|
|
25414
|
+
}
|
|
25415
|
+
const bytes = Bun.file(join5(this.root, "assets", "collections", selected.digest.slice("sha256:".length), assetFileName(assetId)));
|
|
25395
25416
|
if (metadataOnly) {
|
|
25396
25417
|
return await bytes.exists() && bytes.size === definition.byteLength ? { definition, bytes } : null;
|
|
25397
25418
|
}
|
|
@@ -25405,6 +25426,20 @@ class LocalCollectionRepository {
|
|
|
25405
25426
|
async prune() {
|
|
25406
25427
|
await pruneRepository(this.root);
|
|
25407
25428
|
}
|
|
25429
|
+
async readDocument(publisherId, collectionId, version) {
|
|
25430
|
+
if (!isRepositoryIdentifier(publisherId) || !isCollectionNamespace(collectionId) || !VERSION2.test(version)) {
|
|
25431
|
+
return null;
|
|
25432
|
+
}
|
|
25433
|
+
const path = this.releasePath(publisherId, collectionId, version);
|
|
25434
|
+
const bytes = await readFile5(path).catch((error) => {
|
|
25435
|
+
if (error.code === "ENOENT") {
|
|
25436
|
+
this.metadataCache.delete(path);
|
|
25437
|
+
return null;
|
|
25438
|
+
}
|
|
25439
|
+
throw error;
|
|
25440
|
+
});
|
|
25441
|
+
return bytes ? { path, bytes, canonicalJson: new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes) } : null;
|
|
25442
|
+
}
|
|
25408
25443
|
releasePath(publisherId, collectionId, version) {
|
|
25409
25444
|
return join5(this.root, "releases", publisherId, collectionId, `${version}.json`);
|
|
25410
25445
|
}
|
|
@@ -25435,6 +25470,7 @@ var init_collections2 = __esm(() => {
|
|
|
25435
25470
|
init_immutableFiles();
|
|
25436
25471
|
init_recovery();
|
|
25437
25472
|
init_assetFiles();
|
|
25473
|
+
init_immutableJsonCache();
|
|
25438
25474
|
VERSION2 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
25439
25475
|
});
|
|
25440
25476
|
|
|
@@ -25737,7 +25773,6 @@ var init_planPublications = __esm(() => {
|
|
|
25737
25773
|
var init_publishContractSet = __esm(() => {
|
|
25738
25774
|
init_planPublications();
|
|
25739
25775
|
});
|
|
25740
|
-
|
|
25741
25776
|
// packages/features/cms-repository/src/exports/contracts/catalogue.ts
|
|
25742
25777
|
var init_catalogue2 = __esm(() => {
|
|
25743
25778
|
init_InMemoryReleaseCatalogue();
|
|
@@ -28312,11 +28347,15 @@ var init_publishedPage = () => {};
|
|
|
28312
28347
|
|
|
28313
28348
|
// packages/features/cms-content/src/pages/core/routing/values.ts
|
|
28314
28349
|
var init_values4 = () => {};
|
|
28350
|
+
// packages/features/cms-content/src/application/core/pageRenderInputs.ts
|
|
28351
|
+
var init_pageRenderInputs = () => {};
|
|
28352
|
+
|
|
28315
28353
|
// packages/features/cms-content/src/application/core/createContentReader.ts
|
|
28316
28354
|
var init_createContentReader = __esm(() => {
|
|
28317
28355
|
init_resolvePublishedRoute();
|
|
28318
28356
|
init_publishedPage();
|
|
28319
28357
|
init_values4();
|
|
28358
|
+
init_pageRenderInputs();
|
|
28320
28359
|
});
|
|
28321
28360
|
// packages/features/cms-content/src/blocs/core/markup/bindingRoot.ts
|
|
28322
28361
|
function wrapBindingCore(content) {
|
|
@@ -28797,7 +28836,6 @@ var init_links = __esm(() => {
|
|
|
28797
28836
|
init_errors7();
|
|
28798
28837
|
init_esm7();
|
|
28799
28838
|
});
|
|
28800
|
-
|
|
28801
28839
|
// packages/features/cms-content/src/blocs/core/catalogue/siteBlocGroups.ts
|
|
28802
28840
|
var init_siteBlocGroups = __esm(() => {
|
|
28803
28841
|
init_errors5();
|
|
@@ -30318,8 +30356,8 @@ function localEdgeEnvironment(_instance, config, connection, services, image, pr
|
|
|
30318
30356
|
}
|
|
30319
30357
|
|
|
30320
30358
|
// packages/runtimes/ulvia-cli/src/runtime/stack/version.ts
|
|
30321
|
-
var injectedCliVersion = "1.0.
|
|
30322
|
-
var injectedStackVersion = "1.0.
|
|
30359
|
+
var injectedCliVersion = "1.0.1";
|
|
30360
|
+
var injectedStackVersion = "1.0.4";
|
|
30323
30361
|
var CLI_VERSION = injectedCliVersion ?? "development";
|
|
30324
30362
|
var DEFAULT_STACK_VERSION = injectedStackVersion ?? "unbundled";
|
|
30325
30363
|
function defaultStackVersion() {
|
|
@@ -31040,6 +31078,190 @@ function toRecord(entry) {
|
|
|
31040
31078
|
};
|
|
31041
31079
|
}
|
|
31042
31080
|
|
|
31081
|
+
// packages/features/cms-repository/src/providers/installations/core/errors.ts
|
|
31082
|
+
class ProviderInstallationValidationError extends TypeError {
|
|
31083
|
+
code;
|
|
31084
|
+
path;
|
|
31085
|
+
constructor(code, message, path = "$") {
|
|
31086
|
+
super(`${path}: ${message}`);
|
|
31087
|
+
this.name = "ProviderInstallationValidationError";
|
|
31088
|
+
this.code = code;
|
|
31089
|
+
this.path = path;
|
|
31090
|
+
}
|
|
31091
|
+
}
|
|
31092
|
+
// packages/features/cms-repository/src/providers/installations/core/limits.ts
|
|
31093
|
+
var DEFAULT_PROVIDER_INSTALLATION_LIMITS = Object.freeze({
|
|
31094
|
+
maxDocumentBytes: 512 * 1024,
|
|
31095
|
+
maxJsonDepth: 48,
|
|
31096
|
+
maxImplementations: 128
|
|
31097
|
+
});
|
|
31098
|
+
// packages/features/cms-repository/src/providers/installations/core/protocol.ts
|
|
31099
|
+
init_protocol();
|
|
31100
|
+
var PROVIDER_CONNECTION_PROTOCOL = deepFreeze({
|
|
31101
|
+
protocol: "ulvia-provider/v1",
|
|
31102
|
+
authentication: "bearer",
|
|
31103
|
+
report: { method: "GET", path: "/ulvia/report" },
|
|
31104
|
+
registration: { method: "PUT", path: "/ulvia/connections/{installationId}" },
|
|
31105
|
+
disconnect: { method: "DELETE", path: "/ulvia/connections/{installationId}" }
|
|
31106
|
+
});
|
|
31107
|
+
function assertProviderConnectionToken(token) {
|
|
31108
|
+
if (typeof token !== "string" || !/^[\x21-\x7e]{24,512}$/u.test(token)) {
|
|
31109
|
+
throw new TypeError("Invalid provider token");
|
|
31110
|
+
}
|
|
31111
|
+
}
|
|
31112
|
+
// packages/features/cms-repository/src/providers/installations/core/parsing/parseProviderConnectionTarget.ts
|
|
31113
|
+
init_values3();
|
|
31114
|
+
|
|
31115
|
+
// packages/features/cms-repository/src/providers/installations/core/parsing/documents.ts
|
|
31116
|
+
init_contracts();
|
|
31117
|
+
init_protocol();
|
|
31118
|
+
init_errors6();
|
|
31119
|
+
init_values3();
|
|
31120
|
+
function parseInstallationDocument(value, limits, parseRecord) {
|
|
31121
|
+
validateLimits(limits);
|
|
31122
|
+
try {
|
|
31123
|
+
if (canonicalIJsonBytes(value, limits.maxJsonDepth).byteLength > limits.maxDocumentBytes) {
|
|
31124
|
+
throw new ProviderInstallationValidationError("body_limit_exceeded", "document exceeds byte limit");
|
|
31125
|
+
}
|
|
31126
|
+
return deepFreeze(parseRecord(expectRecord2(structuredClone(value), "$")));
|
|
31127
|
+
} catch (error) {
|
|
31128
|
+
return translateError(error);
|
|
31129
|
+
}
|
|
31130
|
+
}
|
|
31131
|
+
function parseInstallationJson(input, limits, parseValue) {
|
|
31132
|
+
validateLimits(limits);
|
|
31133
|
+
try {
|
|
31134
|
+
return parseValue(parseStrictJson(input, limits.maxDocumentBytes, limits.maxJsonDepth));
|
|
31135
|
+
} catch (error) {
|
|
31136
|
+
return translateError(error);
|
|
31137
|
+
}
|
|
31138
|
+
}
|
|
31139
|
+
function validateLimits(limits) {
|
|
31140
|
+
for (const value of [limits.maxDocumentBytes, limits.maxJsonDepth, limits.maxImplementations]) {
|
|
31141
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
31142
|
+
throw new TypeError("Provider installation limits must be positive safe integers");
|
|
31143
|
+
}
|
|
31144
|
+
}
|
|
31145
|
+
}
|
|
31146
|
+
function translateError(error) {
|
|
31147
|
+
if (!(error instanceof ReleaseValidationError) && !(error instanceof ProviderManifestValidationError)) {
|
|
31148
|
+
throw error;
|
|
31149
|
+
}
|
|
31150
|
+
const codes = new Set([
|
|
31151
|
+
"body_limit_exceeded",
|
|
31152
|
+
"duplicate_json_property",
|
|
31153
|
+
"invalid_json",
|
|
31154
|
+
"invalid_utf8",
|
|
31155
|
+
"json_depth_limit_exceeded"
|
|
31156
|
+
]);
|
|
31157
|
+
const code = codes.has(error.code) ? error.code : "invalid_installation";
|
|
31158
|
+
const prefix = `${error.path}: `;
|
|
31159
|
+
const message = error.message.startsWith(prefix) ? error.message.slice(prefix.length) : error.message;
|
|
31160
|
+
throw new ProviderInstallationValidationError(code, message, error.path);
|
|
31161
|
+
}
|
|
31162
|
+
|
|
31163
|
+
// packages/features/cms-repository/src/providers/installations/core/parsing/fields.ts
|
|
31164
|
+
init_contracts();
|
|
31165
|
+
init_errors6();
|
|
31166
|
+
init_values3();
|
|
31167
|
+
init_parseEndpoint();
|
|
31168
|
+
function parseOpaqueId(value, path) {
|
|
31169
|
+
const id = expectString2(value, path, 128);
|
|
31170
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(id)) {
|
|
31171
|
+
throw new ProviderInstallationValidationError("invalid_installation", "must be an opaque identifier", path);
|
|
31172
|
+
}
|
|
31173
|
+
return id;
|
|
31174
|
+
}
|
|
31175
|
+
function parseDigest(value, path) {
|
|
31176
|
+
const digest = expectString2(value, path, 71);
|
|
31177
|
+
if (!isReleaseDigest(digest)) {
|
|
31178
|
+
throw new ProviderInstallationValidationError("invalid_installation", "must be a SHA-256 digest", path);
|
|
31179
|
+
}
|
|
31180
|
+
return digest;
|
|
31181
|
+
}
|
|
31182
|
+
// packages/features/cms-repository/src/providers/installations/core/parsing/parseProviderInstallation.ts
|
|
31183
|
+
init_identifiers2();
|
|
31184
|
+
init_versionRange2();
|
|
31185
|
+
init_values3();
|
|
31186
|
+
// packages/features/cms-repository/src/providers/installations/core/parsing/parseGatewayRegistration.ts
|
|
31187
|
+
init_values3();
|
|
31188
|
+
init_identifiers2();
|
|
31189
|
+
// packages/features/cms-repository/src/providers/installations/core/reports/parseProviderRuntimeReport.ts
|
|
31190
|
+
init_identifiers2();
|
|
31191
|
+
init_values3();
|
|
31192
|
+
init_versionRange2();
|
|
31193
|
+
function parseProviderRuntimeReport(value, limits = DEFAULT_PROVIDER_INSTALLATION_LIMITS) {
|
|
31194
|
+
return parseInstallationDocument(value, limits, (record) => {
|
|
31195
|
+
rejectUnknownKeys2(record, ["protocol", "providerId", "instanceId", "account", "buildVersion", "manifest", "implementations"], "$");
|
|
31196
|
+
if (record.protocol !== "ulvia-provider/v1") {
|
|
31197
|
+
throw new ProviderInstallationValidationError("invalid_installation", "must be ulvia-provider/v1", "$.protocol");
|
|
31198
|
+
}
|
|
31199
|
+
const account = expectRecord2(record.account, "$.account");
|
|
31200
|
+
rejectUnknownKeys2(account, ["id", "label"], "$.account");
|
|
31201
|
+
const manifest = expectRecord2(record.manifest, "$.manifest");
|
|
31202
|
+
rejectUnknownKeys2(manifest, ["version", "digest"], "$.manifest");
|
|
31203
|
+
const implementations = expectArray2(record.implementations, "$.implementations", limits.maxImplementations).map((implementation, index) => parseImplementation2(implementation, `$.implementations[${index}]`));
|
|
31204
|
+
unique2(implementations.map((entry) => `${entry.contractId}\x00${entry.version}`), "$.implementations");
|
|
31205
|
+
return {
|
|
31206
|
+
protocol: "ulvia-provider/v1",
|
|
31207
|
+
providerId: parseIdentifier2(record.providerId, "$.providerId", 96),
|
|
31208
|
+
instanceId: parseOpaqueId(record.instanceId, "$.instanceId"),
|
|
31209
|
+
account: {
|
|
31210
|
+
id: parseOpaqueId(account.id, "$.account.id"),
|
|
31211
|
+
label: expectString2(account.label, "$.account.label", 128)
|
|
31212
|
+
},
|
|
31213
|
+
buildVersion: parseSemVer2(record.buildVersion, "$.buildVersion"),
|
|
31214
|
+
manifest: {
|
|
31215
|
+
version: parseSemVer2(manifest.version, "$.manifest.version"),
|
|
31216
|
+
digest: parseDigest(manifest.digest, "$.manifest.digest")
|
|
31217
|
+
},
|
|
31218
|
+
implementations: implementations.sort((left, right) => compareOrdinal(left.contractId, right.contractId) || compareOrdinal(left.version, right.version))
|
|
31219
|
+
};
|
|
31220
|
+
});
|
|
31221
|
+
}
|
|
31222
|
+
function parseProviderRuntimeReportJson(input, limits = DEFAULT_PROVIDER_INSTALLATION_LIMITS) {
|
|
31223
|
+
return parseInstallationJson(input, limits, (value) => parseProviderRuntimeReport(value, limits));
|
|
31224
|
+
}
|
|
31225
|
+
function parseImplementation2(value, path) {
|
|
31226
|
+
const record = expectRecord2(value, path);
|
|
31227
|
+
rejectUnknownKeys2(record, ["contractId", "version", "digest", "status"], path);
|
|
31228
|
+
const status = record.status;
|
|
31229
|
+
if (status !== "ready" && status !== "setup-required" && status !== "unavailable") {
|
|
31230
|
+
throw new ProviderInstallationValidationError("invalid_installation", "must be ready, setup-required, or unavailable", `${path}.status`);
|
|
31231
|
+
}
|
|
31232
|
+
return {
|
|
31233
|
+
contractId: parseIdentifier2(record.contractId, `${path}.contractId`, 96),
|
|
31234
|
+
version: parseSemVer2(record.version, `${path}.version`),
|
|
31235
|
+
digest: parseDigest(record.digest, `${path}.digest`),
|
|
31236
|
+
status
|
|
31237
|
+
};
|
|
31238
|
+
}
|
|
31239
|
+
// packages/features/cms-repository/src/providers/installations/core/reports/validateProviderRuntimeReport.ts
|
|
31240
|
+
init_versionRange2();
|
|
31241
|
+
// packages/features/cms-repository/src/providers/installations/core/validateProviderInstallation.ts
|
|
31242
|
+
init_schema();
|
|
31243
|
+
// packages/features/cms-repository/src/providers/installations/core/lifecycle/ProviderInstallationLifecycle.ts
|
|
31244
|
+
init_protocol();
|
|
31245
|
+
init_values3();
|
|
31246
|
+
|
|
31247
|
+
// packages/features/cms-repository/src/providers/installations/core/lifecycle/candidates.ts
|
|
31248
|
+
init_protocol();
|
|
31249
|
+
init_values3();
|
|
31250
|
+
|
|
31251
|
+
// packages/features/cms-repository/src/providers/installations/core/lifecycle/preparations.ts
|
|
31252
|
+
init_verifyProviderManifestAdmission();
|
|
31253
|
+
init_limits3();
|
|
31254
|
+
init_values3();
|
|
31255
|
+
|
|
31256
|
+
// packages/features/cms-repository/src/providers/installations/core/lifecycle/state.ts
|
|
31257
|
+
init_identifiers2();
|
|
31258
|
+
// packages/features/cms-repository/src/providers/installations/default-implementation/memory/InMemoryProviderInstallationStore.ts
|
|
31259
|
+
init_protocol();
|
|
31260
|
+
|
|
31261
|
+
// packages/features/cms-repository/src/providers/installations/core/selectionRevision.ts
|
|
31262
|
+
init_protocol();
|
|
31263
|
+
// packages/features/cms-repository/src/providers/installations/core/lifecycle/readiness.ts
|
|
31264
|
+
init_protocol();
|
|
31043
31265
|
// packages/features/cms-repository/src/exports/contracts/bindings.ts
|
|
31044
31266
|
init_compileContractBindings();
|
|
31045
31267
|
init_compile();
|
|
@@ -31675,6 +31897,7 @@ class HttpGatewayTransport {
|
|
|
31675
31897
|
const firstByteTimeout = setTimeout(() => abort.abort(new DOMException("Provider first byte timed out", "TimeoutError")), this.#timeoutMs);
|
|
31676
31898
|
const exchange = {
|
|
31677
31899
|
...prepared,
|
|
31900
|
+
...request.authorityReads ? { authorityReads: request.authorityReads } : {},
|
|
31678
31901
|
requestId: request.requestId,
|
|
31679
31902
|
installationId: request.installationId,
|
|
31680
31903
|
providerTokenRef: request.providerTokenRef,
|
|
@@ -31939,78 +32162,6 @@ import { isIP as isIP2 } from "net";
|
|
|
31939
32162
|
init_compatibility();
|
|
31940
32163
|
init_protocol();
|
|
31941
32164
|
import { createHash as createHash9, createHmac, timingSafeEqual } from "crypto";
|
|
31942
|
-
// packages/features/cms-repository/src/providers/installations/core/limits.ts
|
|
31943
|
-
var DEFAULT_PROVIDER_INSTALLATION_LIMITS = Object.freeze({
|
|
31944
|
-
maxDocumentBytes: 512 * 1024,
|
|
31945
|
-
maxJsonDepth: 48,
|
|
31946
|
-
maxImplementations: 128
|
|
31947
|
-
});
|
|
31948
|
-
// packages/features/cms-repository/src/providers/installations/core/protocol.ts
|
|
31949
|
-
init_protocol();
|
|
31950
|
-
var PROVIDER_CONNECTION_PROTOCOL = deepFreeze({
|
|
31951
|
-
protocol: "ulvia-provider/v1",
|
|
31952
|
-
authentication: "bearer",
|
|
31953
|
-
report: { method: "GET", path: "/ulvia/report" },
|
|
31954
|
-
registration: { method: "PUT", path: "/ulvia/connections/{installationId}" },
|
|
31955
|
-
disconnect: { method: "DELETE", path: "/ulvia/connections/{installationId}" }
|
|
31956
|
-
});
|
|
31957
|
-
function assertProviderConnectionToken(token) {
|
|
31958
|
-
if (typeof token !== "string" || !/^[\x21-\x7e]{24,512}$/u.test(token)) {
|
|
31959
|
-
throw new TypeError("Invalid provider token");
|
|
31960
|
-
}
|
|
31961
|
-
}
|
|
31962
|
-
// packages/features/cms-repository/src/providers/installations/core/parsing/parseProviderConnectionTarget.ts
|
|
31963
|
-
init_values3();
|
|
31964
|
-
|
|
31965
|
-
// packages/features/cms-repository/src/providers/installations/core/parsing/documents.ts
|
|
31966
|
-
init_contracts();
|
|
31967
|
-
init_protocol();
|
|
31968
|
-
init_errors6();
|
|
31969
|
-
init_values3();
|
|
31970
|
-
|
|
31971
|
-
// packages/features/cms-repository/src/providers/installations/core/parsing/fields.ts
|
|
31972
|
-
init_contracts();
|
|
31973
|
-
init_errors6();
|
|
31974
|
-
init_values3();
|
|
31975
|
-
init_parseEndpoint();
|
|
31976
|
-
// packages/features/cms-repository/src/providers/installations/core/parsing/parseProviderInstallation.ts
|
|
31977
|
-
init_identifiers2();
|
|
31978
|
-
init_versionRange2();
|
|
31979
|
-
init_values3();
|
|
31980
|
-
// packages/features/cms-repository/src/providers/installations/core/parsing/parseGatewayRegistration.ts
|
|
31981
|
-
init_values3();
|
|
31982
|
-
init_identifiers2();
|
|
31983
|
-
// packages/features/cms-repository/src/providers/installations/core/reports/parseProviderRuntimeReport.ts
|
|
31984
|
-
init_identifiers2();
|
|
31985
|
-
init_values3();
|
|
31986
|
-
init_versionRange2();
|
|
31987
|
-
// packages/features/cms-repository/src/providers/installations/core/reports/validateProviderRuntimeReport.ts
|
|
31988
|
-
init_versionRange2();
|
|
31989
|
-
// packages/features/cms-repository/src/providers/installations/core/validateProviderInstallation.ts
|
|
31990
|
-
init_schema();
|
|
31991
|
-
// packages/features/cms-repository/src/providers/installations/core/lifecycle/ProviderInstallationLifecycle.ts
|
|
31992
|
-
init_protocol();
|
|
31993
|
-
init_values3();
|
|
31994
|
-
|
|
31995
|
-
// packages/features/cms-repository/src/providers/installations/core/lifecycle/candidates.ts
|
|
31996
|
-
init_protocol();
|
|
31997
|
-
init_values3();
|
|
31998
|
-
|
|
31999
|
-
// packages/features/cms-repository/src/providers/installations/core/lifecycle/preparations.ts
|
|
32000
|
-
init_verifyProviderManifestAdmission();
|
|
32001
|
-
init_limits3();
|
|
32002
|
-
init_values3();
|
|
32003
|
-
|
|
32004
|
-
// packages/features/cms-repository/src/providers/installations/core/lifecycle/state.ts
|
|
32005
|
-
init_identifiers2();
|
|
32006
|
-
// packages/features/cms-repository/src/providers/installations/default-implementation/memory/InMemoryProviderInstallationStore.ts
|
|
32007
|
-
init_protocol();
|
|
32008
|
-
|
|
32009
|
-
// packages/features/cms-repository/src/providers/installations/core/selectionRevision.ts
|
|
32010
|
-
init_protocol();
|
|
32011
|
-
// packages/features/cms-repository/src/providers/installations/core/lifecycle/readiness.ts
|
|
32012
|
-
init_protocol();
|
|
32013
|
-
// packages/features/cms-gateway/src/protocol/ProviderInvocationToken.ts
|
|
32014
32165
|
var TOKEN_VERSION = 1;
|
|
32015
32166
|
var MAX_TTL_SECONDS = 30;
|
|
32016
32167
|
var IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
@@ -32134,6 +32285,57 @@ function isPublicAddress(candidate) {
|
|
|
32134
32285
|
return true;
|
|
32135
32286
|
}
|
|
32136
32287
|
|
|
32288
|
+
// packages/features/cms-gateway/src/invocation/node-http/pinnedAgents.ts
|
|
32289
|
+
import { Agent as HttpAgent } from "http";
|
|
32290
|
+
import { Agent as HttpsAgent } from "https";
|
|
32291
|
+
var options = { keepAlive: true, maxSockets: 16, maxTotalSockets: 64, maxFreeSockets: 4 };
|
|
32292
|
+
function authority(request) {
|
|
32293
|
+
const headers = request.headers;
|
|
32294
|
+
const host = headers && !Array.isArray(headers) && "host" in headers ? headers.host : undefined;
|
|
32295
|
+
if (typeof host !== "string" || !host) {
|
|
32296
|
+
throw new TypeError("Pinned connection requires an explicit Host authority");
|
|
32297
|
+
}
|
|
32298
|
+
return host;
|
|
32299
|
+
}
|
|
32300
|
+
|
|
32301
|
+
class PinnedHttpAgent extends HttpAgent {
|
|
32302
|
+
keepSocketAlive(socket) {
|
|
32303
|
+
const keep = super.keepSocketAlive(socket);
|
|
32304
|
+
if (keep === false) {
|
|
32305
|
+
return false;
|
|
32306
|
+
}
|
|
32307
|
+
socket.setTimeout(1e4);
|
|
32308
|
+
return true;
|
|
32309
|
+
}
|
|
32310
|
+
reuseSocket(socket, request) {
|
|
32311
|
+
socket.setTimeout(0);
|
|
32312
|
+
super.reuseSocket(socket, request);
|
|
32313
|
+
}
|
|
32314
|
+
getName(request) {
|
|
32315
|
+
return `${super.getName(request)}\x00${authority(request)}`;
|
|
32316
|
+
}
|
|
32317
|
+
}
|
|
32318
|
+
|
|
32319
|
+
class PinnedHttpsAgent extends HttpsAgent {
|
|
32320
|
+
keepSocketAlive(socket) {
|
|
32321
|
+
const keep = super.keepSocketAlive(socket);
|
|
32322
|
+
if (keep === false) {
|
|
32323
|
+
return false;
|
|
32324
|
+
}
|
|
32325
|
+
socket.setTimeout(1e4);
|
|
32326
|
+
return true;
|
|
32327
|
+
}
|
|
32328
|
+
reuseSocket(socket, request) {
|
|
32329
|
+
socket.setTimeout(0);
|
|
32330
|
+
super.reuseSocket(socket, request);
|
|
32331
|
+
}
|
|
32332
|
+
getName(request) {
|
|
32333
|
+
return `${super.getName(request)}\x00${authority(request)}`;
|
|
32334
|
+
}
|
|
32335
|
+
}
|
|
32336
|
+
var pinnedHttpAgent = new PinnedHttpAgent(options);
|
|
32337
|
+
var pinnedHttpsAgent = new PinnedHttpsAgent(options);
|
|
32338
|
+
|
|
32137
32339
|
// packages/features/cms-gateway/src/invocation/node-http/nodeHttpRequest.ts
|
|
32138
32340
|
import { request as httpRequest } from "http";
|
|
32139
32341
|
import { request as httpsRequest } from "https";
|
|
@@ -32149,7 +32351,7 @@ async function sendPinnedHttpRequest(value) {
|
|
|
32149
32351
|
method: value.method,
|
|
32150
32352
|
headers: { ...value.headers, host: value.url.host },
|
|
32151
32353
|
signal: value.signal,
|
|
32152
|
-
agent:
|
|
32354
|
+
agent: secure ? pinnedHttpsAgent : pinnedHttpAgent,
|
|
32153
32355
|
...secure ? { servername: value.url.hostname.replace(/^\[|\]$/g, "") } : {}
|
|
32154
32356
|
};
|
|
32155
32357
|
const request = (secure ? httpsRequest : httpRequest)(options, (incoming) => {
|
|
@@ -32385,6 +32587,7 @@ class OperatorObservabilityClient {
|
|
|
32385
32587
|
endpoint;
|
|
32386
32588
|
token;
|
|
32387
32589
|
instanceId;
|
|
32590
|
+
#contractVersion;
|
|
32388
32591
|
constructor(endpoint, token, instanceId) {
|
|
32389
32592
|
this.endpoint = endpoint;
|
|
32390
32593
|
this.token = token;
|
|
@@ -32459,7 +32662,7 @@ class OperatorObservabilityClient {
|
|
|
32459
32662
|
"content-type": "application/json",
|
|
32460
32663
|
"x-ulvia-request-id": crypto.randomUUID(),
|
|
32461
32664
|
"x-ulvia-contract-id": "ulvia.cms.installations",
|
|
32462
|
-
"x-ulvia-contract-version":
|
|
32665
|
+
"x-ulvia-contract-version": await this.contractVersion(),
|
|
32463
32666
|
"x-ulvia-capability-id": capabilityId
|
|
32464
32667
|
},
|
|
32465
32668
|
body: JSON.stringify(input),
|
|
@@ -32470,34 +32673,67 @@ class OperatorObservabilityClient {
|
|
|
32470
32673
|
await response.body?.cancel();
|
|
32471
32674
|
throw new Error(`Local Provider rejected the operator request (${response.status})`);
|
|
32472
32675
|
}
|
|
32473
|
-
|
|
32474
|
-
|
|
32475
|
-
|
|
32676
|
+
return readResponse(response);
|
|
32677
|
+
}
|
|
32678
|
+
contractVersion() {
|
|
32679
|
+
if (this.#contractVersion) {
|
|
32680
|
+
return this.#contractVersion;
|
|
32476
32681
|
}
|
|
32477
|
-
|
|
32478
|
-
|
|
32479
|
-
|
|
32480
|
-
|
|
32481
|
-
|
|
32482
|
-
|
|
32483
|
-
|
|
32484
|
-
|
|
32485
|
-
|
|
32486
|
-
bytes += part.value.byteLength;
|
|
32487
|
-
if (bytes > 2 * 1024 * 1024) {
|
|
32488
|
-
await reader.cancel();
|
|
32489
|
-
throw new Error("Local Provider response exceeds its limit");
|
|
32490
|
-
}
|
|
32491
|
-
source += decoder.decode(part.value, { stream: true });
|
|
32682
|
+
const load = async () => {
|
|
32683
|
+
const response = await fetch(new URL("/ulvia/report", this.endpoint), {
|
|
32684
|
+
headers: { authorization: `Bearer ${this.token}` },
|
|
32685
|
+
redirect: "manual",
|
|
32686
|
+
signal: AbortSignal.timeout(5000)
|
|
32687
|
+
});
|
|
32688
|
+
if (!response.ok) {
|
|
32689
|
+
await response.body?.cancel();
|
|
32690
|
+
throw new Error("Local Provider report is unavailable");
|
|
32492
32691
|
}
|
|
32493
|
-
const
|
|
32494
|
-
|
|
32495
|
-
|
|
32692
|
+
const report = parseProviderRuntimeReportJson(JSON.stringify(await readResponse(response)));
|
|
32693
|
+
const control = report.implementations.find((item) => item.contractId === "ulvia.cms.installations" && item.status === "ready");
|
|
32694
|
+
if (report.instanceId !== this.instanceId || !control || !["1.0.0", "1.1.0"].includes(control.version)) {
|
|
32695
|
+
throw new Error("Local Provider control contract does not match the instance");
|
|
32496
32696
|
}
|
|
32497
|
-
return
|
|
32498
|
-
}
|
|
32499
|
-
|
|
32697
|
+
return control.version;
|
|
32698
|
+
};
|
|
32699
|
+
const pending = load();
|
|
32700
|
+
this.#contractVersion = pending;
|
|
32701
|
+
pending.catch(() => {
|
|
32702
|
+
if (this.#contractVersion === pending) {
|
|
32703
|
+
this.#contractVersion = undefined;
|
|
32704
|
+
}
|
|
32705
|
+
});
|
|
32706
|
+
return pending;
|
|
32707
|
+
}
|
|
32708
|
+
}
|
|
32709
|
+
async function readResponse(response) {
|
|
32710
|
+
const reader = response.body?.getReader();
|
|
32711
|
+
if (!reader) {
|
|
32712
|
+
throw new Error("Local Provider returned an empty response");
|
|
32713
|
+
}
|
|
32714
|
+
let source = "";
|
|
32715
|
+
const decoder = new TextDecoder;
|
|
32716
|
+
try {
|
|
32717
|
+
let bytes = 0;
|
|
32718
|
+
for (;; ) {
|
|
32719
|
+
const part = await reader.read();
|
|
32720
|
+
if (part.done) {
|
|
32721
|
+
break;
|
|
32722
|
+
}
|
|
32723
|
+
bytes += part.value.byteLength;
|
|
32724
|
+
if (bytes > 2 * 1024 * 1024) {
|
|
32725
|
+
await reader.cancel();
|
|
32726
|
+
throw new Error("Local Provider response exceeds its limit");
|
|
32727
|
+
}
|
|
32728
|
+
source += decoder.decode(part.value, { stream: true });
|
|
32729
|
+
}
|
|
32730
|
+
const value = JSON.parse(source + decoder.decode());
|
|
32731
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
32732
|
+
throw new Error("Invalid local Provider response");
|
|
32500
32733
|
}
|
|
32734
|
+
return value;
|
|
32735
|
+
} finally {
|
|
32736
|
+
reader.releaseLock();
|
|
32501
32737
|
}
|
|
32502
32738
|
}
|
|
32503
32739
|
|