@void/platform 1.11.0 → 1.12.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/ai-logging.d.mts +8 -12
- package/dist/ai-logging.mjs +7 -10
- package/dist/browser-page.mjs +2 -2
- package/dist/email-protocol.mjs +16 -14
- package/dist/index.d.mts +30 -4
- package/dist/index.mjs +120 -69
- package/dist/installer.d.mts +2 -0
- package/dist/installer.mjs +13 -13
- package/dist/plans.mjs +22 -10
- package/dist/runtime/api/assets/admin/client.js +51 -45
- package/dist/runtime/api/assets/admin/style.css +1 -1
- package/dist/runtime/api/index.js +3748 -329
- package/dist/runtime/dispatch/index.js +8 -8
- package/dist/runtime/drizzle/0065_security_audits.sql +313 -0
- package/dist/runtime/drizzle/compatibility.json +28 -0
- package/dist/runtime/drizzle/meta/_journal.json +7 -0
- package/dist/runtime/emailGateway/index.js +5 -5
- package/dist/runtime/manifest.json +51 -16
- package/dist/runtime/proxy/index.js +5 -5
- package/dist/security-local-check.d.mts +28 -0
- package/dist/security-local-check.mjs +140 -0
- package/dist/security-lockfile.d.mts +34 -0
- package/dist/security-lockfile.mjs +181 -0
- package/dist/security-models.d.mts +88 -0
- package/dist/security-models.mjs +186 -0
- package/dist/security-policy.d.mts +245 -0
- package/dist/security-policy.mjs +491 -0
- package/package.json +23 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isSourceRevision, c as requiredString, i as isSandboxDrainProtocol, n as isPrintableText, o as isUsageProtocolVersion, s as record, t as assertRecord } from "./validate-CTKcW3Vp.mjs";
|
|
1
|
+
import { a as isSourceRevision, c as requiredString, i as isSandboxDrainProtocol, n as isPrintableText, o as isUsageProtocolVersion, r as isRecord, s as record, t as assertRecord } from "./validate-CTKcW3Vp.mjs";
|
|
2
2
|
import { BUILD_INSTANCE_FREE, BUILD_INSTANCE_LARGE, PLAN_EDITABLE_LIMIT_KEYS, PLAN_LIMITS, createDefaultPlanCatalog, parseBuildInstanceType, parsePlanLimitsPatch, parsePlanName, parsePlatformPlanCatalog, parsePlatformPlanId, validatePlanLimits } from "./plans.mjs";
|
|
3
3
|
import { isR2LocationHint } from "@void/deploy-core";
|
|
4
4
|
// src/access-policy.ts
|
|
@@ -57,13 +57,12 @@ function isPlatformAccessIdentityRule(rule, companyLoginMethod) {
|
|
|
57
57
|
const PLATFORM_APP_ACCESS_SETUP_PROOF_PREFIX = "void-platform-app-access-v1";
|
|
58
58
|
/** Uninstall handoff that turns off installer-managed project Zero Trust before any user exists. */
|
|
59
59
|
const PLATFORM_APP_ACCESS_TURN_OFF_PROOF_PREFIX = "void-platform-app-access-turn-off-v1";
|
|
60
|
-
function parsePlatformAppAccessSetup(
|
|
61
|
-
if (!
|
|
62
|
-
|
|
63
|
-
if (input.version !== 1 || !["public", "protected"].includes(String(input.mode)) || typeof input.managed !== "boolean" || typeof input.accountId !== "string" || !input.accountId) throw new Error("Invalid app access setup.");
|
|
60
|
+
function parsePlatformAppAccessSetup(input) {
|
|
61
|
+
if (!isRecord(input)) throw new Error("Invalid app access setup.");
|
|
62
|
+
if (input.version !== 1 || input.mode !== "public" && input.mode !== "protected" || typeof input.managed !== "boolean" || typeof input.accountId !== "string" || !input.accountId) throw new Error("Invalid app access setup.");
|
|
64
63
|
const ids = (name) => {
|
|
65
64
|
const entries = input[name];
|
|
66
|
-
if (!Array.isArray(entries) || entries.length > 16 || entries.
|
|
65
|
+
if (!Array.isArray(entries) || entries.length > 16 || !entries.every((id) => typeof id === "string" && !!id.trim() && id.length <= 128) || new Set(entries).size !== entries.length) throw new Error(`Invalid app access ${name}.`);
|
|
67
66
|
return [...entries];
|
|
68
67
|
};
|
|
69
68
|
const identityProviderIds = ids("identityProviderIds");
|
|
@@ -76,7 +75,7 @@ function parsePlatformAppAccessSetup(value) {
|
|
|
76
75
|
accountId: input.accountId,
|
|
77
76
|
mode: input.mode,
|
|
78
77
|
managed: input.managed,
|
|
79
|
-
...input.
|
|
78
|
+
...typeof input.apiToken === "string" ? { apiToken: input.apiToken } : {},
|
|
80
79
|
identityProviderIds,
|
|
81
80
|
policyIds
|
|
82
81
|
};
|
|
@@ -102,6 +101,9 @@ const PLATFORM_LOGIN_KINDS = [
|
|
|
102
101
|
"oidc",
|
|
103
102
|
"cloudflare-access"
|
|
104
103
|
];
|
|
104
|
+
function isPlatformLoginKind(value) {
|
|
105
|
+
return PLATFORM_LOGIN_KINDS.some((kind) => kind === value);
|
|
106
|
+
}
|
|
105
107
|
/** Operator-side coverage verification, bound to one administrator and settings revision. */
|
|
106
108
|
function platformProtectionProofMessage(input) {
|
|
107
109
|
return `void-platform-protection-v1\n${JSON.stringify({
|
|
@@ -153,10 +155,11 @@ function parsePlatformAuthenticationSetup(value) {
|
|
|
153
155
|
if (!Array.isArray(input.connections) || input.connections.length === 0 || input.connections.length > 32) throw new Error("Authentication setup requires between 1 and 32 connections.");
|
|
154
156
|
const connections = input.connections.map((value) => {
|
|
155
157
|
const entry = record(value, "Login connection");
|
|
156
|
-
|
|
158
|
+
const { clientSecret } = entry;
|
|
159
|
+
assertPrintableText(clientSecret, "Client secret", 8192);
|
|
157
160
|
return {
|
|
158
161
|
configuration: parsePlatformLoginConfiguration(entry.configuration),
|
|
159
|
-
clientSecret
|
|
162
|
+
clientSecret
|
|
160
163
|
};
|
|
161
164
|
});
|
|
162
165
|
if (new Set(connections.map((entry) => entry.configuration.id)).size !== connections.length) throw new Error("Authentication setup connection IDs must be unique.");
|
|
@@ -179,8 +182,11 @@ function parsePlatformAuthenticationSetup(value) {
|
|
|
179
182
|
const DEFAULT_PLATFORM_SESSION_SECONDS = 2592e3;
|
|
180
183
|
const GOOGLE_OIDC_ISSUER = "https://accounts.google.com";
|
|
181
184
|
const PLATFORM_AUTH_SETUP_PROOF_PREFIX = "void.platform.auth.setup.v1";
|
|
182
|
-
function
|
|
185
|
+
function assertPrintableText(value, name, maximum) {
|
|
183
186
|
if (!isPrintableText(value, maximum)) throw new Error(`${name} must be a nonempty string of at most ${maximum} characters.`);
|
|
187
|
+
}
|
|
188
|
+
function string(value, name, maximum = 512) {
|
|
189
|
+
assertPrintableText(value, name, maximum);
|
|
184
190
|
return value.trim();
|
|
185
191
|
}
|
|
186
192
|
function strings(value, name, maximum = 100) {
|
|
@@ -208,8 +214,8 @@ function parsePlatformIdentityUrl(value, name, originOnly = false) {
|
|
|
208
214
|
function parsePlatformLoginDescriptor(value) {
|
|
209
215
|
const entry = record(value, "Login connection");
|
|
210
216
|
const id = parsePlatformLoginId(entry.id);
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
const { kind } = entry;
|
|
218
|
+
if (!isPlatformLoginKind(kind)) throw new Error("Login kind must be github, google, oidc, or cloudflare-access.");
|
|
213
219
|
if ((id === "github" || id === "google") && id !== kind) throw new Error(`Connection ID ${id} is reserved for ${id} login.`);
|
|
214
220
|
if ((kind === "github" || kind === "google") && id !== kind) throw new Error(`${kind} uses the fixed connection ID ${kind}.`);
|
|
215
221
|
return {
|
|
@@ -296,6 +302,9 @@ function validatePlatformAdmissionPolicy(policy, enabledConnections, protection)
|
|
|
296
302
|
}
|
|
297
303
|
// src/manifest.ts
|
|
298
304
|
const PLATFORM_DEPLOYMENT_SCHEMA_VERSION = 1;
|
|
305
|
+
function isPlatformAppAccess(value) {
|
|
306
|
+
return value === "public" || value === "platform" || value === "custom";
|
|
307
|
+
}
|
|
299
308
|
const CORE_CAPABILITIES = {
|
|
300
309
|
ai: true,
|
|
301
310
|
customDomains: false,
|
|
@@ -304,8 +313,27 @@ const CORE_CAPABILITIES = {
|
|
|
304
313
|
githubOAuth: true,
|
|
305
314
|
googleOAuth: false,
|
|
306
315
|
managedBuilds: false,
|
|
307
|
-
sandbox: false
|
|
316
|
+
sandbox: false,
|
|
317
|
+
securityAudits: false
|
|
308
318
|
};
|
|
319
|
+
/** Capabilities that older documents may omit; a missing value means `false`. */
|
|
320
|
+
const OPTIONAL_CAPABILITIES = /* @__PURE__ */ new Set(["securityAudits"]);
|
|
321
|
+
/**
|
|
322
|
+
* Reads one capability from an untrusted record. An optional capability that
|
|
323
|
+
* older documents omit reads as `false`; anything else is returned unchanged
|
|
324
|
+
* for the caller to validate.
|
|
325
|
+
*/
|
|
326
|
+
function readPlatformCapability(record, name) {
|
|
327
|
+
const value = record[name];
|
|
328
|
+
return value === void 0 && OPTIONAL_CAPABILITIES.has(name) ? false : value;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* `PLATFORM_CAPABILITIES` for the platform Workers. An optional capability that
|
|
332
|
+
* is off is left out, so an installation without it gets the same value as before.
|
|
333
|
+
*/
|
|
334
|
+
function serializePlatformCapabilities(capabilities) {
|
|
335
|
+
return JSON.stringify(Object.fromEntries(Object.entries(capabilities).filter(([key, value]) => value || !OPTIONAL_CAPABILITIES.has(key))));
|
|
336
|
+
}
|
|
309
337
|
const CONTROL_PLANE_DEFAULTS = {
|
|
310
338
|
apiHostname: null,
|
|
311
339
|
dashboardHostname: null,
|
|
@@ -390,6 +418,28 @@ function createApplicationRoutes(application) {
|
|
|
390
418
|
}
|
|
391
419
|
return routes;
|
|
392
420
|
}
|
|
421
|
+
/** Validate application fields read independently from a persisted deployment manifest. */
|
|
422
|
+
function readPlatformApplicationInput(value, label = "application") {
|
|
423
|
+
assertRecord(value, label);
|
|
424
|
+
const { baseDomain, dedicatedZone, zoneName, workersDev, zoneId } = value;
|
|
425
|
+
if (dedicatedZone !== void 0 && dedicatedZone !== null && typeof dedicatedZone !== "boolean") throw new Error(`${label}.dedicatedZone must be a boolean.`);
|
|
426
|
+
let identity;
|
|
427
|
+
if (workersDev) {
|
|
428
|
+
assertRecord(workersDev, `${label}.workersDev`);
|
|
429
|
+
identity = {
|
|
430
|
+
...workersDev,
|
|
431
|
+
subdomain: requiredString(workersDev.subdomain, "workersDev.subdomain"),
|
|
432
|
+
installationId: requiredString(workersDev.installationId, "workersDev.installationId")
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
baseDomain: requiredString(baseDomain, `${label}.baseDomain`),
|
|
437
|
+
dedicatedZone: dedicatedZone ?? void 0,
|
|
438
|
+
zoneName: identity && zoneName === "" ? "" : requiredString(zoneName, `${label}.zoneName`),
|
|
439
|
+
...identity ? { workersDev: identity } : {},
|
|
440
|
+
...zoneId ? { zoneId: requiredString(zoneId, `${label}.zoneId`) } : {}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
393
443
|
function createPlatformDeploymentManifest(input) {
|
|
394
444
|
if (input.emailSharedZoneId === void 0 !== (input.emailSenderDomain === void 0)) throw new Error("Shared email configuration requires both emailSenderDomain and emailSharedZoneId.");
|
|
395
445
|
const installationSlug = normalizeInstallationSlug(input.installationSlug);
|
|
@@ -397,7 +447,7 @@ function createPlatformDeploymentManifest(input) {
|
|
|
397
447
|
const workersDev = input.application.workersDev;
|
|
398
448
|
if (workersDev && (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(workersDev.subdomain) || !/^[a-z0-9][a-z0-9-]{0,80}$/.test(workersDev.installationId))) throw new Error("Invalid workers.dev installation identity.");
|
|
399
449
|
const zoneName = workersDev && input.application.zoneName === "" ? "" : normalizeApplicationDomain(input.application.zoneName);
|
|
400
|
-
if (!zoneName && baseDomain !== `${workersDev.subdomain}.workers.dev`) throw new Error("workers.dev application domain must match its account subdomain.");
|
|
450
|
+
if (!zoneName && (!workersDev || baseDomain !== `${workersDev.subdomain}.workers.dev`)) throw new Error("workers.dev application domain must match its account subdomain.");
|
|
401
451
|
const resources = {
|
|
402
452
|
...createPlatformResourceNames(installationSlug),
|
|
403
453
|
...input.resources
|
|
@@ -407,11 +457,7 @@ function createPlatformDeploymentManifest(input) {
|
|
|
407
457
|
...input.capabilities
|
|
408
458
|
};
|
|
409
459
|
if (capabilities.managedBuilds && !capabilities.githubActions) throw new Error("Managed builds require the GitHub Actions capability.");
|
|
410
|
-
if (input.appAccess !== void 0 && !
|
|
411
|
-
"public",
|
|
412
|
-
"platform",
|
|
413
|
-
"custom"
|
|
414
|
-
].includes(input.appAccess)) throw new Error("appAccess must be public, platform, or custom.");
|
|
460
|
+
if (input.appAccess !== void 0 && !isPlatformAppAccess(input.appAccess)) throw new Error("appAccess must be public, platform, or custom.");
|
|
415
461
|
if (input.runtimeLogs !== void 0 && input.runtimeLogs !== "minimal") throw new Error("runtimeLogs must be minimal when set.");
|
|
416
462
|
if (input.storageLocationHint !== void 0 && !isR2LocationHint(input.storageLocationHint)) throw new Error("Invalid storageLocationHint.");
|
|
417
463
|
const providers = input.authentication?.providers ?? ["github"];
|
|
@@ -451,7 +497,7 @@ function createPlatformDeploymentManifest(input) {
|
|
|
451
497
|
resources,
|
|
452
498
|
...input.runtimeLogs ? { runtimeLogs: input.runtimeLogs } : {},
|
|
453
499
|
...input.storageLocationHint ? { storageLocationHint: input.storageLocationHint } : {},
|
|
454
|
-
schemaVersion: input.storageLocationHint ? 6 : input.runtimeLogs ? 5 : input.appAccess !== void 0 ? 4 : configurable ? 3 : workersDev ? 2 : 1
|
|
500
|
+
schemaVersion: capabilities.securityAudits ? 7 : input.storageLocationHint ? 6 : input.runtimeLogs ? 5 : input.appAccess !== void 0 ? 4 : configurable ? 3 : workersDev ? 2 : 1
|
|
455
501
|
};
|
|
456
502
|
createApplicationRoutes(manifest.application);
|
|
457
503
|
for (const [key, value] of Object.entries(manifest.controlPlane)) {
|
|
@@ -467,7 +513,7 @@ function createPlatformDeploymentManifest(input) {
|
|
|
467
513
|
}
|
|
468
514
|
function parsePlatformDeploymentManifest(value) {
|
|
469
515
|
assertRecord(value, "Platform deployment manifest");
|
|
470
|
-
if (value.schemaVersion !== 1 && value.schemaVersion !== 2 && value.schemaVersion !== 3 && value.schemaVersion !== 4 && value.schemaVersion !== 5 && value.schemaVersion !== 6) throw new Error(`Unsupported platform deployment schema version: ${String(value.schemaVersion)}.`);
|
|
516
|
+
if (value.schemaVersion !== 1 && value.schemaVersion !== 2 && value.schemaVersion !== 3 && value.schemaVersion !== 4 && value.schemaVersion !== 5 && value.schemaVersion !== 6 && value.schemaVersion !== 7) throw new Error(`Unsupported platform deployment schema version: ${String(value.schemaVersion)}.`);
|
|
471
517
|
const application = value.application;
|
|
472
518
|
const authentication = value.authentication;
|
|
473
519
|
const rawCapabilities = value.capabilities;
|
|
@@ -486,37 +532,30 @@ function parsePlatformDeploymentManifest(value) {
|
|
|
486
532
|
assertRecord(controlPlane, "controlPlane");
|
|
487
533
|
assertRecord(authentication, "authentication");
|
|
488
534
|
assertRecord(rawResources, "resources");
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
for (const key of capabilityKeys) {
|
|
492
|
-
const entry = rawCapabilities[key];
|
|
535
|
+
const capabilities = Object.fromEntries(Object.keys(CORE_CAPABILITIES).map((key) => {
|
|
536
|
+
const entry = readPlatformCapability(rawCapabilities, key);
|
|
493
537
|
if (typeof entry !== "boolean") throw new Error(`capabilities.${key} must be a boolean.`);
|
|
494
|
-
|
|
495
|
-
}
|
|
538
|
+
return [key, entry];
|
|
539
|
+
}));
|
|
540
|
+
if (capabilities.securityAudits && Number(value.schemaVersion) < 7) throw new Error("Security audits require deployment schema version 7.");
|
|
541
|
+
if (value.schemaVersion === 7 && !capabilities.securityAudits) throw new Error("Deployment schema version 7 requires capabilities.securityAudits.");
|
|
496
542
|
const providers = authentication.providers;
|
|
497
|
-
if (!Array.isArray(providers) || providers.
|
|
543
|
+
if (!Array.isArray(providers) || !providers.every((provider) => isPlatformLoginKind(provider) && (Number(value.schemaVersion) >= 3 || provider === "github" || provider === "google"))) throw new Error("authentication.providers must contain only github or google.");
|
|
498
544
|
if (value.schemaVersion === 3 && authentication.configurable !== true || Number(value.schemaVersion) < 3 && (authentication.configurable !== void 0 || authentication.accessProtection !== void 0) || authentication.accessProtection !== void 0 && authentication.accessProtection !== true) throw new Error("Configurable authentication requires deployment schema version 3.");
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
"platform",
|
|
502
|
-
"custom"
|
|
503
|
-
].includes(String(value.appAccess)) : Number(value.schemaVersion) >= 5 ? value.appAccess !== void 0 && ![
|
|
504
|
-
"public",
|
|
505
|
-
"platform",
|
|
506
|
-
"custom"
|
|
507
|
-
].includes(String(value.appAccess)) : value.appAccess !== void 0) throw new Error("Guided app access requires deployment schema version 4 and a valid appAccess choice.");
|
|
545
|
+
const appAccess = isPlatformAppAccess(value.appAccess) ? value.appAccess : void 0;
|
|
546
|
+
if (value.schemaVersion === 4 ? appAccess === void 0 : Number(value.schemaVersion) >= 5 ? value.appAccess !== void 0 && appAccess === void 0 : value.appAccess !== void 0) throw new Error("Guided app access requires deployment schema version 4 and a valid appAccess choice.");
|
|
508
547
|
if (authentication.configurable !== void 0 && authentication.configurable !== true) throw new Error("Invalid configurable authentication flag.");
|
|
509
|
-
if (value.schemaVersion === 5 ? value.runtimeLogs !== "minimal" : value.schemaVersion
|
|
510
|
-
|
|
548
|
+
if (value.schemaVersion === 5 ? value.runtimeLogs !== "minimal" : Number(value.schemaVersion) >= 6 ? value.runtimeLogs !== void 0 && value.runtimeLogs !== "minimal" : value.runtimeLogs !== void 0) throw new Error("Minimal runtime logs require deployment schema version 5.");
|
|
549
|
+
const storageLocationHint = isR2LocationHint(value.storageLocationHint) ? value.storageLocationHint : void 0;
|
|
550
|
+
if (value.schemaVersion === 6 ? storageLocationHint === void 0 : value.schemaVersion === 7 ? value.storageLocationHint !== void 0 && storageLocationHint === void 0 : value.storageLocationHint !== void 0) throw new Error("storageLocationHint requires deployment schema version 6 and a valid R2 location hint.");
|
|
511
551
|
const resourceDefaults = createPlatformResourceNames(requiredString(value.installationSlug, "installationSlug"));
|
|
512
|
-
const resources = {};
|
|
513
|
-
for (const key of Object.keys(resourceDefaults)) resources[key] = requiredString(rawResources[key] ?? (key === "emailGatewayWorker" || key === "deploymentQueue" ? resourceDefaults[key] : void 0), `resources.${key}`);
|
|
552
|
+
const resources = Object.fromEntries(Object.keys(resourceDefaults).map((key) => [key, requiredString(rawResources[key] ?? (key === "emailGatewayWorker" || key === "deploymentQueue" ? resourceDefaults[key] : void 0), `resources.${key}`)]));
|
|
514
553
|
const readHostname = (key) => {
|
|
515
554
|
const hostname = controlPlane[key];
|
|
516
555
|
return hostname === null ? null : requiredString(hostname, `controlPlane.${key}`);
|
|
517
556
|
};
|
|
518
557
|
return createPlatformDeploymentManifest({
|
|
519
|
-
...
|
|
558
|
+
...appAccess === void 0 ? {} : { appAccess },
|
|
520
559
|
application: {
|
|
521
560
|
baseDomain: requiredString(application.baseDomain, "application.baseDomain"),
|
|
522
561
|
dedicatedZone: application.dedicatedZone === true,
|
|
@@ -542,7 +581,7 @@ function parsePlatformDeploymentManifest(value) {
|
|
|
542
581
|
installationSlug: requiredString(value.installationSlug, "installationSlug"),
|
|
543
582
|
resources,
|
|
544
583
|
...value.runtimeLogs === "minimal" ? { runtimeLogs: "minimal" } : {},
|
|
545
|
-
...
|
|
584
|
+
...storageLocationHint === void 0 ? {} : { storageLocationHint }
|
|
546
585
|
});
|
|
547
586
|
}
|
|
548
587
|
// src/installation.ts
|
|
@@ -679,6 +718,9 @@ function assertTimestamp(value, label) {
|
|
|
679
718
|
return value;
|
|
680
719
|
}
|
|
681
720
|
function createPlatformResourceOwnershipMarker(input) {
|
|
721
|
+
return validateResourceOwnershipMarker(input);
|
|
722
|
+
}
|
|
723
|
+
function validateResourceOwnershipMarker(input) {
|
|
682
724
|
if (!isResourceKind(input.resourceKind)) throw new Error("Invalid ownership marker resource kind.");
|
|
683
725
|
return {
|
|
684
726
|
accountId: requiredString(input.accountId, "ownership accountId"),
|
|
@@ -694,7 +736,7 @@ function createPlatformResourceOwnershipMarker(input) {
|
|
|
694
736
|
function parsePlatformResourceOwnershipMarker(value) {
|
|
695
737
|
assertRecord(value, "Platform resource ownership marker");
|
|
696
738
|
if (value.schemaVersion !== 1) throw new Error(`Unsupported platform resource ownership schema version: ${String(value.schemaVersion)}.`);
|
|
697
|
-
return
|
|
739
|
+
return validateResourceOwnershipMarker(value);
|
|
698
740
|
}
|
|
699
741
|
function createPlatformInstallationManifest(input) {
|
|
700
742
|
const createdAt = assertTimestamp(input.createdAt, "createdAt");
|
|
@@ -823,10 +865,9 @@ function parsePlatformInstallationManifest(value) {
|
|
|
823
865
|
const runtime = parsePlatformRuntimeProvenance(value.runtime);
|
|
824
866
|
let pendingDomain;
|
|
825
867
|
if (value.pendingDomain !== void 0) {
|
|
826
|
-
assertRecord(value.pendingDomain, "pendingDomain");
|
|
827
868
|
pendingDomain = createPlatformDeploymentManifest({
|
|
828
869
|
...manifest.deployment,
|
|
829
|
-
application: value.pendingDomain
|
|
870
|
+
application: readPlatformApplicationInput(value.pendingDomain, "pendingDomain")
|
|
830
871
|
}).application;
|
|
831
872
|
if (!manifest.deployment.application.workersDev || !pendingDomain.zoneName || JSON.stringify(pendingDomain.workersDev) !== JSON.stringify(manifest.deployment.application.workersDev)) throw new Error("Pending domain must retain the installation workers.dev identity.");
|
|
832
873
|
}
|
|
@@ -941,7 +982,7 @@ function parsePlatformApplication(value) {
|
|
|
941
982
|
return createPlatformDeploymentManifest({
|
|
942
983
|
installationSlug: "runtime",
|
|
943
984
|
displayName: "Runtime",
|
|
944
|
-
application: value
|
|
985
|
+
application: readPlatformApplicationInput(value)
|
|
945
986
|
}).application;
|
|
946
987
|
}
|
|
947
988
|
function platformWorkersDevAliasKey(hostname) {
|
|
@@ -1057,24 +1098,24 @@ function parsePlatformDiscoveryDocument(value) {
|
|
|
1057
1098
|
if (document.schemaVersion === 1 && document.applicationRouting !== void 0) throw new Error("Application routing requires discovery schema version 2.");
|
|
1058
1099
|
if (document.schemaVersion === 2 && document.applicationRouting === void 0) throw new Error("Discovery schema version 2 requires application routing.");
|
|
1059
1100
|
assertRecord(capabilities, "capabilities");
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
"customDomains",
|
|
1063
|
-
"email",
|
|
1064
|
-
"githubActions",
|
|
1065
|
-
"githubOAuth",
|
|
1066
|
-
"googleOAuth",
|
|
1067
|
-
"managedBuilds",
|
|
1068
|
-
"sandbox"
|
|
1069
|
-
];
|
|
1070
|
-
const parsedCapabilities = {};
|
|
1071
|
-
for (const name of capabilityNames) {
|
|
1072
|
-
const enabled = capabilities[name];
|
|
1101
|
+
const readCapability = (name) => {
|
|
1102
|
+
const enabled = readPlatformCapability(capabilities, name);
|
|
1073
1103
|
if (typeof enabled !== "boolean") throw new Error(`capabilities.${name} must be a boolean.`);
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1104
|
+
return enabled;
|
|
1105
|
+
};
|
|
1106
|
+
const parsedCapabilities = {
|
|
1107
|
+
ai: readCapability("ai"),
|
|
1108
|
+
customDomains: readCapability("customDomains"),
|
|
1109
|
+
email: readCapability("email"),
|
|
1110
|
+
githubActions: readCapability("githubActions"),
|
|
1111
|
+
githubOAuth: readCapability("githubOAuth"),
|
|
1112
|
+
googleOAuth: readCapability("googleOAuth"),
|
|
1113
|
+
managedBuilds: readCapability("managedBuilds"),
|
|
1114
|
+
sandbox: readCapability("sandbox"),
|
|
1115
|
+
securityAudits: readCapability("securityAudits")
|
|
1116
|
+
};
|
|
1076
1117
|
const providers = document.authenticationProviders;
|
|
1077
|
-
if (!Array.isArray(providers) || providers.
|
|
1118
|
+
if (!Array.isArray(providers) || !providers.every((provider) => typeof provider === "string" && (document.schemaVersion === 3 || provider === "github" || provider === "google"))) throw new Error("authenticationProviders must contain only github or google.");
|
|
1078
1119
|
if (document.schemaVersion !== 3 && document.authentication !== void 0) throw new Error("Configurable authentication requires discovery schema version 3.");
|
|
1079
1120
|
const authentication = document.schemaVersion === 3 ? parseAuthentication(document.authentication) : void 0;
|
|
1080
1121
|
if (authentication) providers.forEach(parsePlatformLoginId);
|
|
@@ -1139,6 +1180,7 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1139
1180
|
resourceKind: "worker",
|
|
1140
1181
|
resourceName
|
|
1141
1182
|
})) });
|
|
1183
|
+
const capabilitiesVar = serializePlatformCapabilities(deployment.capabilities);
|
|
1142
1184
|
const runtimeLogs = deployment.runtimeLogs ? { PLATFORM_RUNTIME_LOGS: deployment.runtimeLogs } : {};
|
|
1143
1185
|
const common = {
|
|
1144
1186
|
account_id: accountId,
|
|
@@ -1198,6 +1240,7 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1198
1240
|
}],
|
|
1199
1241
|
kv_namespaces: kv,
|
|
1200
1242
|
...deployment.capabilities.email ? { send_email: [{ name: "EMAIL" }] } : {},
|
|
1243
|
+
...deployment.capabilities.securityAudits ? { ai: { binding: "AI" } } : {},
|
|
1201
1244
|
r2_buckets: r2,
|
|
1202
1245
|
dispatch_namespaces: dispatchNamespace,
|
|
1203
1246
|
durable_objects: { bindings: [
|
|
@@ -1216,7 +1259,11 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1216
1259
|
{
|
|
1217
1260
|
name: "SANDBOX_CONCURRENCY_COUNTER",
|
|
1218
1261
|
class_name: "SandboxConcurrencyCounter"
|
|
1219
|
-
}
|
|
1262
|
+
},
|
|
1263
|
+
...input.securityScanScheduler ? [{
|
|
1264
|
+
name: "SECURITY_SCAN_SCHEDULER",
|
|
1265
|
+
class_name: "SecurityScanScheduler"
|
|
1266
|
+
}] : []
|
|
1220
1267
|
] },
|
|
1221
1268
|
migrations: [
|
|
1222
1269
|
{
|
|
@@ -1234,7 +1281,11 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1234
1281
|
{
|
|
1235
1282
|
tag: "v4",
|
|
1236
1283
|
new_sqlite_classes: ["SandboxConcurrencyCounter"]
|
|
1237
|
-
}
|
|
1284
|
+
},
|
|
1285
|
+
...input.securityScanScheduler ? [{
|
|
1286
|
+
tag: "security-audits-v1",
|
|
1287
|
+
new_sqlite_classes: ["SecurityScanScheduler"]
|
|
1288
|
+
}] : []
|
|
1238
1289
|
],
|
|
1239
1290
|
queues: {
|
|
1240
1291
|
producers: [
|
|
@@ -1282,7 +1333,7 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1282
1333
|
DISPATCH_NAMESPACE: names.dispatchNamespace,
|
|
1283
1334
|
DISPATCH_WORKER_NAME: names.dispatchWorker,
|
|
1284
1335
|
LOGS_DATASET: names.logsDataset,
|
|
1285
|
-
PLATFORM_CAPABILITIES:
|
|
1336
|
+
PLATFORM_CAPABILITIES: capabilitiesVar,
|
|
1286
1337
|
...input.authenticationDatabaseUncached ? { PLATFORM_AUTH_DATABASE_UNCACHED: "true" } : {},
|
|
1287
1338
|
PLATFORM_DISPLAY_NAME: deployment.displayName,
|
|
1288
1339
|
PLATFORM_ENV: "production",
|
|
@@ -1331,7 +1382,7 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1331
1382
|
...deployment.capabilities.email ? { send_email: [{ name: "SEND_EMAIL" }] } : {},
|
|
1332
1383
|
vars: {
|
|
1333
1384
|
AI_GATEWAY_ID: names.aiGateway,
|
|
1334
|
-
PLATFORM_CAPABILITIES:
|
|
1385
|
+
PLATFORM_CAPABILITIES: capabilitiesVar,
|
|
1335
1386
|
PLATFORM_HEALTH_PROBE_TOKEN: healthProbeToken,
|
|
1336
1387
|
PLATFORM_INSTALLATION_ID: installationId,
|
|
1337
1388
|
PLATFORM_TRAFFIC_STATE: trafficState,
|
|
@@ -1364,7 +1415,7 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1364
1415
|
dispatch_namespaces: dispatchNamespace,
|
|
1365
1416
|
...deployment.capabilities.email ? { send_email: [{ name: "SEND_EMAIL" }] } : {},
|
|
1366
1417
|
vars: {
|
|
1367
|
-
PLATFORM_CAPABILITIES:
|
|
1418
|
+
PLATFORM_CAPABILITIES: capabilitiesVar,
|
|
1368
1419
|
PLATFORM_INSTALLATION_ID: installationId,
|
|
1369
1420
|
PLATFORM_VERSION: platformVersion,
|
|
1370
1421
|
PLATFORM_TRAFFIC_STATE: trafficState,
|
|
@@ -1430,4 +1481,4 @@ function createPlatformWorkerConfigs(input) {
|
|
|
1430
1481
|
}
|
|
1431
1482
|
};
|
|
1432
1483
|
}
|
|
1433
|
-
export { BUILD_INSTANCE_FREE, BUILD_INSTANCE_LARGE, DEFAULT_PLATFORM_SESSION_SECONDS, GOOGLE_OIDC_ISSUER, PLAN_EDITABLE_LIMIT_KEYS, PLAN_LIMITS, PLATFORM_APPLICATION_KEY, PLATFORM_APP_ACCESS_SETUP_PROOF_PREFIX, PLATFORM_APP_ACCESS_TURN_OFF_PROOF_PREFIX, PLATFORM_AUTH_SETUP_PROOF_PREFIX, PLATFORM_DEPLOYMENT_SCHEMA_VERSION, PLATFORM_DISABLED_KEY, PLATFORM_DISABLED_VALUE, PLATFORM_DISCOVERY_SCHEMA_VERSION, PLATFORM_HEALTH_HOSTNAME_LABEL, PLATFORM_INSTALLATION_SCHEMA_VERSION, PLATFORM_LOGIN_KINDS, PLATFORM_PROJECT_INGRESS_SOURCE, PLATFORM_R2_OWNERSHIP_MARKER_KEY, PLATFORM_REMOTE_INSTALLATION_MANIFEST_KEY, PLATFORM_RESOURCE_OWNERSHIP_SCHEMA_VERSION, PLATFORM_SANDBOX_DRAIN_KEY, PLATFORM_USAGE_PROTOCOL_VERSION, createApplicationRoutes, createDefaultPlanCatalog, createPlatformDeploymentManifest, createPlatformDiscoveryDocument, createPlatformInstallationManifest, createPlatformResourceNames, createPlatformResourceOwnershipMarker, createPlatformWorkerConfigs, isPlatformAccessCompanyIdentityProvider, isPlatformAccessEmailDomain, isPlatformAccessIdentityRule, isPlatformSignupAllowed, normalizeApplicationDomain, normalizeInstallationSlug, normalizePlatformDashboardUrl, parseBuildInstanceType, parsePlanLimitsPatch, parsePlanName, parsePlatformAccessProtection, parsePlatformAdmissionPolicy, parsePlatformAppAccessSetup, parsePlatformAuthenticationSetup, parsePlatformDeploymentManifest, parsePlatformDiscoveryDocument, parsePlatformIdentityUrl, parsePlatformInstallationManifest, parsePlatformLifecycleOperation, parsePlatformLoginConfiguration, parsePlatformLoginDescriptor, parsePlatformLoginId, parsePlatformPlanCatalog, parsePlatformPlanId, parsePlatformResourceOwnershipMarker, parsePlatformSignupAllowlistEntry, platformAuthenticationRecoveryMessage, platformDashboardUrl, platformHealthHostname, platformProjectHostname, platformProjectHostnames, platformProjectIngressName, platformProjectIngressPrefix, platformProjectWorkersDevHostname, platformProtectionProofMessage, platformWorkersDevAliasKey, readPlatformApplication, recordInstallationResource, recordInstallationStep, resolvePlatformApplicationEnvironment, setInstallationDesiredState, setInstallationEndpoints, transitionInstallation, validatePlanLimits, validatePlatformAdmissionPolicy };
|
|
1484
|
+
export { BUILD_INSTANCE_FREE, BUILD_INSTANCE_LARGE, DEFAULT_PLATFORM_SESSION_SECONDS, GOOGLE_OIDC_ISSUER, PLAN_EDITABLE_LIMIT_KEYS, PLAN_LIMITS, PLATFORM_APPLICATION_KEY, PLATFORM_APP_ACCESS_SETUP_PROOF_PREFIX, PLATFORM_APP_ACCESS_TURN_OFF_PROOF_PREFIX, PLATFORM_AUTH_SETUP_PROOF_PREFIX, PLATFORM_DEPLOYMENT_SCHEMA_VERSION, PLATFORM_DISABLED_KEY, PLATFORM_DISABLED_VALUE, PLATFORM_DISCOVERY_SCHEMA_VERSION, PLATFORM_HEALTH_HOSTNAME_LABEL, PLATFORM_INSTALLATION_SCHEMA_VERSION, PLATFORM_LOGIN_KINDS, PLATFORM_PROJECT_INGRESS_SOURCE, PLATFORM_R2_OWNERSHIP_MARKER_KEY, PLATFORM_REMOTE_INSTALLATION_MANIFEST_KEY, PLATFORM_RESOURCE_OWNERSHIP_SCHEMA_VERSION, PLATFORM_SANDBOX_DRAIN_KEY, PLATFORM_USAGE_PROTOCOL_VERSION, createApplicationRoutes, createDefaultPlanCatalog, createPlatformDeploymentManifest, createPlatformDiscoveryDocument, createPlatformInstallationManifest, createPlatformResourceNames, createPlatformResourceOwnershipMarker, createPlatformWorkerConfigs, isPlatformAccessCompanyIdentityProvider, isPlatformAccessEmailDomain, isPlatformAccessIdentityRule, isPlatformSignupAllowed, normalizeApplicationDomain, normalizeInstallationSlug, normalizePlatformDashboardUrl, parseBuildInstanceType, parsePlanLimitsPatch, parsePlanName, parsePlatformAccessProtection, parsePlatformAdmissionPolicy, parsePlatformAppAccessSetup, parsePlatformAuthenticationSetup, parsePlatformDeploymentManifest, parsePlatformDiscoveryDocument, parsePlatformIdentityUrl, parsePlatformInstallationManifest, parsePlatformLifecycleOperation, parsePlatformLoginConfiguration, parsePlatformLoginDescriptor, parsePlatformLoginId, parsePlatformPlanCatalog, parsePlatformPlanId, parsePlatformResourceOwnershipMarker, parsePlatformSignupAllowlistEntry, platformAuthenticationRecoveryMessage, platformDashboardUrl, platformHealthHostname, platformProjectHostname, platformProjectHostnames, platformProjectIngressName, platformProjectIngressPrefix, platformProjectWorkersDevHostname, platformProtectionProofMessage, platformWorkersDevAliasKey, readPlatformApplication, readPlatformCapability, recordInstallationResource, recordInstallationStep, resolvePlatformApplicationEnvironment, serializePlatformCapabilities, setInstallationDesiredState, setInstallationEndpoints, transitionInstallation, validatePlanLimits, validatePlatformAdmissionPolicy };
|
package/dist/installer.d.mts
CHANGED
|
@@ -29,6 +29,8 @@ export type PlatformRuntimeManifest = Readonly<{
|
|
|
29
29
|
/** The runtime honours `runtimeLogs: minimal` (PLATFORM_RUNTIME_LOGS). */
|
|
30
30
|
runtimeLogs?: 1;
|
|
31
31
|
storageLocationHint?: 1;
|
|
32
|
+
/** The runtime ships the `SecurityScanScheduler` class and reads `capabilities.securityAudits`. */
|
|
33
|
+
securityAudits?: 1;
|
|
32
34
|
/** Durable deployment Queue payload and PostgreSQL operation journal contract. */
|
|
33
35
|
deploymentExecution?: 1;
|
|
34
36
|
authenticationProtocolVersion?: 1;
|
package/dist/installer.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { a as isSourceRevision, i as isSandboxDrainProtocol, o as isUsageProtocolVersion, r as isRecord } from "./validate-CTKcW3Vp.mjs";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { readFileSync, realpathSync, statSync } from "node:fs";
|
|
4
|
-
import {
|
|
5
|
-
import { dirname, isAbsolute, join, resolve } from "pathslash";
|
|
4
|
+
import { isAbsolute, join, resolve } from "pathslash";
|
|
6
5
|
// src/installer.ts
|
|
7
6
|
const PLATFORM_ADMIN_ASSETS_DIRECTORY = "api/assets";
|
|
8
7
|
const PLATFORM_ADMIN_CLIENT_ASSET_PATH = `${PLATFORM_ADMIN_ASSETS_DIRECTORY}/admin/client.js`;
|
|
@@ -27,20 +26,20 @@ function parsePlatformRuntimeManifest(value) {
|
|
|
27
26
|
if (root.appAccessSetup !== void 0 && root.appAccessSetup !== 1) throw new Error("Unsupported app access setup protocol.");
|
|
28
27
|
if (root.storageLocationHint !== void 0 && root.storageLocationHint !== 1) throw new Error("Unsupported storage location hint protocol.");
|
|
29
28
|
if (root.runtimeLogs !== void 0 && root.runtimeLogs !== 1) throw new Error("Unsupported runtime logs protocol.");
|
|
29
|
+
if (root.securityAudits !== void 0 && root.securityAudits !== 1) throw new Error("Unsupported security audits protocol.");
|
|
30
30
|
if (root.deploymentExecution !== void 0 && root.deploymentExecution !== 1) throw new Error("Unsupported deployment execution protocol.");
|
|
31
31
|
if (root.authenticationProtocolVersion !== void 0 && root.authenticationProtocolVersion !== 1) throw new Error("Unsupported authentication protocol version.");
|
|
32
32
|
if (root.emailProtocolVersion !== void 0 && root.emailProtocolVersion !== 1) throw new Error("Unsupported email protocol version.");
|
|
33
33
|
const artifactsValue = record(root.artifacts, "runtime manifest artifacts");
|
|
34
34
|
if (root.emailProtocolVersion === 1 && artifactsValue.emailGateway === void 0) throw new Error("Email protocol version 1 requires an emailGateway runtime artifact.");
|
|
35
35
|
if (artifactsValue.emailGateway !== void 0 && root.emailProtocolVersion !== 1) throw new Error("An emailGateway runtime artifact requires email protocol version 1.");
|
|
36
|
-
const
|
|
37
|
-
"api",
|
|
38
|
-
"dispatch",
|
|
39
|
-
"proxy",
|
|
40
|
-
"tail",
|
|
41
|
-
...artifactsValue.emailGateway === void 0 ?
|
|
42
|
-
|
|
43
|
-
const artifacts = Object.fromEntries(artifactNames.map((name) => [name, parseArtifact(artifactsValue[name], name)]));
|
|
36
|
+
const artifacts = {
|
|
37
|
+
api: parseArtifact(artifactsValue.api, "api"),
|
|
38
|
+
dispatch: parseArtifact(artifactsValue.dispatch, "dispatch"),
|
|
39
|
+
proxy: parseArtifact(artifactsValue.proxy, "proxy"),
|
|
40
|
+
tail: parseArtifact(artifactsValue.tail, "tail"),
|
|
41
|
+
...artifactsValue.emailGateway === void 0 ? {} : { emailGateway: parseArtifact(artifactsValue.emailGateway, "emailGateway") }
|
|
42
|
+
};
|
|
44
43
|
let assets;
|
|
45
44
|
if (root.assets !== void 0) {
|
|
46
45
|
const assetsValue = record(root.assets, "runtime manifest assets");
|
|
@@ -89,6 +88,7 @@ function parsePlatformRuntimeManifest(value) {
|
|
|
89
88
|
...root.appAccessSetup === 1 ? { appAccessSetup: 1 } : {},
|
|
90
89
|
...root.storageLocationHint === 1 ? { storageLocationHint: 1 } : {},
|
|
91
90
|
...root.runtimeLogs === 1 ? { runtimeLogs: 1 } : {},
|
|
91
|
+
...root.securityAudits === 1 ? { securityAudits: 1 } : {},
|
|
92
92
|
...root.deploymentExecution === 1 ? { deploymentExecution: 1 } : {},
|
|
93
93
|
...assets ? { assets } : {},
|
|
94
94
|
...root.authenticationProtocolVersion === 1 ? { authenticationProtocolVersion: 1 } : {},
|
|
@@ -122,7 +122,7 @@ function usageProtocolVersion(value) {
|
|
|
122
122
|
return value;
|
|
123
123
|
}
|
|
124
124
|
function getPlatformRuntimeDirectory() {
|
|
125
|
-
return join(
|
|
125
|
+
return join(import.meta.dirname, "runtime");
|
|
126
126
|
}
|
|
127
127
|
function readPlatformRuntimeManifest(runtimeDirectory = getPlatformRuntimeDirectory()) {
|
|
128
128
|
return readRuntimeManifestFile(join(runtimeDirectory, "manifest.json")).manifest;
|
|
@@ -135,7 +135,7 @@ function resolvePlatformRuntime(customRuntimeDirectory, baseDirectory = process.
|
|
|
135
135
|
directory = realpathSync(requestedDirectory);
|
|
136
136
|
if (!statSync(directory).isDirectory()) throw new Error("not a directory");
|
|
137
137
|
} catch (error) {
|
|
138
|
-
throw new Error(`Void Platform runtime directory is unavailable at ${requestedDirectory}: ${error instanceof Error ? error.message : String(error)}
|
|
138
|
+
throw new Error(`Void Platform runtime directory is unavailable at ${requestedDirectory}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
139
139
|
}
|
|
140
140
|
const { contents, manifest } = readRuntimeManifestFile(join(directory, "manifest.json"));
|
|
141
141
|
return {
|
|
@@ -153,7 +153,7 @@ function readRuntimeManifestFile(path) {
|
|
|
153
153
|
manifest: parsePlatformRuntimeManifest(JSON.parse(contents.toString("utf8")))
|
|
154
154
|
};
|
|
155
155
|
} catch (error) {
|
|
156
|
-
throw new Error(`Void Platform deployment artifacts are missing or invalid at ${path}: ${error instanceof Error ? error.message : String(error)}
|
|
156
|
+
throw new Error(`Void Platform deployment artifacts are missing or invalid at ${path}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
function parseArtifact(value, name) {
|
package/dist/plans.mjs
CHANGED
|
@@ -127,16 +127,28 @@ function parsePlanLimitsPatch(value) {
|
|
|
127
127
|
const input = record(value, "Plan limits");
|
|
128
128
|
for (const [key, limit] of Object.entries(input)) {
|
|
129
129
|
if (!PLAN_EDITABLE_LIMIT_KEYS.includes(key)) throw new Error("Unknown or unenforced plan limit: " + key + ".");
|
|
130
|
-
if (!Number.isSafeInteger(limit) || limit < 0) throw new Error(key + " must be a nonnegative safe integer; 0 means unlimited.");
|
|
130
|
+
if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 0) throw new Error(key + " must be a nonnegative safe integer; 0 means unlimited.");
|
|
131
131
|
}
|
|
132
132
|
if (typeof input.buildTimeoutMinutes === "number" && input.buildTimeoutMinutes > 60) throw new Error("buildTimeoutMinutes must be between 0 and 60; builds have a 60-minute platform maximum.");
|
|
133
133
|
return input;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
for (const [key, limit] of Object.entries(limits)) if (!Number.isSafeInteger(limit) || limit < 0) throw new Error(key + " must be a nonnegative safe integer.");
|
|
135
|
+
function validatePlanLimitValues(limits) {
|
|
136
|
+
for (const [key, limit] of Object.entries(limits)) if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 0) throw new Error(key + " must be a nonnegative safe integer.");
|
|
137
|
+
}
|
|
138
|
+
function validatePlanLimitBounds(limits) {
|
|
137
139
|
if (limits.buildTimeoutMinutes > 60) throw new Error("buildTimeoutMinutes must be between 0 and 60; builds have a 60-minute platform maximum.");
|
|
138
140
|
if (limits.maxCpuMsPerRequest !== 0 && (limits.cpuMsPerRequest === 0 || limits.cpuMsPerRequest > limits.maxCpuMsPerRequest)) throw new Error("cpuMsPerRequest must not exceed maxCpuMsPerRequest; an unlimited default requires an unlimited ceiling.");
|
|
139
141
|
}
|
|
142
|
+
function validatePlanLimits(limits) {
|
|
143
|
+
validatePlanLimitValues(limits);
|
|
144
|
+
validatePlanLimitBounds(limits);
|
|
145
|
+
}
|
|
146
|
+
function assertCompletePlanLimits(limits) {
|
|
147
|
+
const required = Object.keys(PLAN_LIMITS.free);
|
|
148
|
+
const supplied = Object.keys(limits);
|
|
149
|
+
if (supplied.length !== required.length || required.some((key) => !supplied.includes(key))) throw new Error("Plan limits must contain all supported fields.");
|
|
150
|
+
validatePlanLimitValues(limits);
|
|
151
|
+
}
|
|
140
152
|
function parseBuildInstanceType(value) {
|
|
141
153
|
if (value !== "standard-3" && value !== "standard-4") throw new Error("buildInstanceType must be standard-3 or standard-4.");
|
|
142
154
|
return value;
|
|
@@ -144,7 +156,8 @@ function parseBuildInstanceType(value) {
|
|
|
144
156
|
/** Strict saved-state validation: invalid configuration must not silently lift quotas. */
|
|
145
157
|
function parsePlatformPlanCatalog(value) {
|
|
146
158
|
const input = record(value, "Plan catalog");
|
|
147
|
-
|
|
159
|
+
const revision = input.revision;
|
|
160
|
+
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < 0) throw new Error("Invalid plan catalog revision.");
|
|
148
161
|
if (!Array.isArray(input.plans) || input.plans.length === 0 || input.plans.length > 100) throw new Error("A plan catalog must contain between 1 and 100 plans.");
|
|
149
162
|
const ids = /* @__PURE__ */ new Set();
|
|
150
163
|
const plans = input.plans.map((value) => {
|
|
@@ -155,9 +168,8 @@ function parsePlatformPlanCatalog(value) {
|
|
|
155
168
|
if (typeof plan.archived !== "boolean") throw new Error("archived must be a boolean.");
|
|
156
169
|
if (typeof plan.allowShortSlugs !== "boolean") throw new Error("allowShortSlugs must be a boolean.");
|
|
157
170
|
const limits = record(plan.limits, "Plan limits");
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
validatePlanLimits(limits);
|
|
171
|
+
assertCompletePlanLimits(limits);
|
|
172
|
+
validatePlanLimitBounds(limits);
|
|
161
173
|
return {
|
|
162
174
|
id,
|
|
163
175
|
name: parsePlanName(plan.name),
|
|
@@ -172,7 +184,7 @@ function parsePlatformPlanCatalog(value) {
|
|
|
172
184
|
let reconciliation = null;
|
|
173
185
|
if (input.reconciliation !== null) {
|
|
174
186
|
const operation = record(input.reconciliation, "Plan reconciliation");
|
|
175
|
-
if (operation.revision !==
|
|
187
|
+
if (operation.revision !== revision || typeof operation.complete !== "boolean" || !(operation.cursor === null || typeof operation.cursor === "string") || !Array.isArray(operation.planIds) || operation.planIds.length > 100) throw new Error("Invalid plan reconciliation state.");
|
|
176
188
|
const planIds = operation.planIds.map(parsePlatformPlanId);
|
|
177
189
|
if (planIds.some((id) => !ids.has(id))) throw new Error("A reconciliation plan is missing.");
|
|
178
190
|
let error;
|
|
@@ -185,7 +197,7 @@ function parsePlatformPlanCatalog(value) {
|
|
|
185
197
|
};
|
|
186
198
|
}
|
|
187
199
|
reconciliation = {
|
|
188
|
-
revision
|
|
200
|
+
revision,
|
|
189
201
|
complete: operation.complete,
|
|
190
202
|
cursor: operation.cursor,
|
|
191
203
|
planIds,
|
|
@@ -193,7 +205,7 @@ function parsePlatformPlanCatalog(value) {
|
|
|
193
205
|
};
|
|
194
206
|
}
|
|
195
207
|
return {
|
|
196
|
-
revision
|
|
208
|
+
revision,
|
|
197
209
|
defaultPlanId,
|
|
198
210
|
plans,
|
|
199
211
|
reconciliation
|