@void/platform 1.10.0 → 1.12.0
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 +44 -38
- 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/meta/_journal.json +7 -0
- package/dist/runtime/emailGateway/index.js +5 -5
- package/dist/runtime/manifest.json +23 -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 +24 -7
package/dist/ai-logging.d.mts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Gateway logging policy shared by the platform API, proxy and installer.
|
|
3
|
-
*
|
|
4
|
-
* The API saves a project override (and plan defaults) in Postgres and publishes the
|
|
5
|
-
* effective mode to ROUTING KV under `aiLoggingKey(projectId)`. The proxy reads only
|
|
6
|
-
* that key. A missing key means `inherit`: the gateway's own `collect_logs` setting.
|
|
7
|
-
*/
|
|
8
1
|
/** Every mode an operator can choose. `inherit` clears an override. */
|
|
9
2
|
export declare const AI_LOGGING_MODES: readonly ["inherit", "off", "metadata", "full"];
|
|
10
3
|
export type AiLoggingMode = (typeof AI_LOGGING_MODES)[number];
|
|
@@ -29,11 +22,12 @@ export declare function aiLoggingKey(projectId: string): string;
|
|
|
29
22
|
* returns `undefined` so callers fail closed instead of logging more than intended.
|
|
30
23
|
*/
|
|
31
24
|
export declare function parsePublishedAiLogging(value: string | null): AiLoggingMode | undefined;
|
|
32
|
-
|
|
33
|
-
export declare function resolveAiLogging(projectMode: AiLoggingMode | null | undefined, planMode: AiLoggingMode | null | undefined): Readonly<{
|
|
25
|
+
type EffectiveAiLogging = Readonly<{
|
|
34
26
|
mode: AiLoggingMode;
|
|
35
27
|
source: AiLoggingSource;
|
|
36
28
|
}>;
|
|
29
|
+
/** Effective mode: the project override, else the plan default, else inherit. */
|
|
30
|
+
export declare function resolveAiLogging(projectMode: AiLoggingMode | null | undefined, planMode: AiLoggingMode | null | undefined): EffectiveAiLogging;
|
|
37
31
|
/** Compares two effective modes (not saved project fields) to order a publish. */
|
|
38
32
|
export declare function publishOrder(previousEffective: AiLoggingMode, nextEffective: AiLoggingMode): AiLoggingPublishOrder;
|
|
39
33
|
/**
|
|
@@ -54,14 +48,15 @@ export declare const AI_LOGGING_CACHE_TTL_SECONDS = 30;
|
|
|
54
48
|
export declare function aiLoggingClearedKey(projectId: string): string;
|
|
55
49
|
/** KV expiry of the cleared marker, in seconds (KV's minimum is 60). */
|
|
56
50
|
export declare const AI_LOGGING_CLEARED_TTL_SECONDS: number;
|
|
57
|
-
|
|
58
|
-
export declare function aiLoggingClearedMarker(at: number): Readonly<{
|
|
51
|
+
type AiLoggingClearedMarker = Readonly<{
|
|
59
52
|
value: string;
|
|
60
53
|
metadata: Readonly<{
|
|
61
54
|
at: number;
|
|
62
55
|
}>;
|
|
63
56
|
expirationTtl: number;
|
|
64
57
|
}>;
|
|
58
|
+
/** The KV value and options of a cleared marker written at `at` (ms). */
|
|
59
|
+
export declare function aiLoggingClearedMarker(at: number): AiLoggingClearedMarker;
|
|
65
60
|
/** Reads a cleared marker's time; anything missing or malformed is `null`. */
|
|
66
61
|
export declare function parseAiLoggingClearedAt(metadata: unknown): number | null;
|
|
67
62
|
/** ROUTING KV metadata written with every published key. `at` is the publish time in ms. */
|
|
@@ -130,4 +125,5 @@ export declare function planPublishPending(publish: PlanAiLoggingPublish | null,
|
|
|
130
125
|
* Reads a plan's `aiLogging` field from a plan change. `undefined` keeps the current
|
|
131
126
|
* value and `inherit` clears it.
|
|
132
127
|
*/
|
|
133
|
-
export declare function parsePlanAiLoggingInput(value: unknown): AiLoggingMode | undefined;
|
|
128
|
+
export declare function parsePlanAiLoggingInput(value: unknown): AiLoggingMode | undefined;
|
|
129
|
+
export {};
|
package/dist/ai-logging.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as isRecord, s as record } from "./validate-CTKcW3Vp.mjs";
|
|
1
2
|
// src/ai-logging.ts
|
|
2
3
|
/**
|
|
3
4
|
* AI Gateway logging policy shared by the platform API, proxy and installer.
|
|
@@ -96,13 +97,13 @@ function aiLoggingClearedMarker(at) {
|
|
|
96
97
|
}
|
|
97
98
|
/** Reads a cleared marker's time; anything missing or malformed is `null`. */
|
|
98
99
|
function parseAiLoggingClearedAt(metadata) {
|
|
99
|
-
if (
|
|
100
|
+
if (!isRecord(metadata)) return null;
|
|
100
101
|
const { at } = metadata;
|
|
101
102
|
return typeof at === "number" && Number.isSafeInteger(at) ? at : null;
|
|
102
103
|
}
|
|
103
104
|
/** Reads the metadata of a published key; anything malformed is `null` (treated as drift). */
|
|
104
105
|
function parseAiLoggingKeyMetadata(value) {
|
|
105
|
-
if (
|
|
106
|
+
if (!isRecord(value)) return null;
|
|
106
107
|
const { mode, at } = value;
|
|
107
108
|
if (!isPublishedAiLoggingMode(mode) || typeof at !== "number" || !Number.isSafeInteger(at)) return null;
|
|
108
109
|
return {
|
|
@@ -117,14 +118,10 @@ const PLAN_AI_LOGGING_SETTING = "plans:ai-logging";
|
|
|
117
118
|
* has written KV but not committed yet. Cleanup leaves keys this young alone.
|
|
118
119
|
*/
|
|
119
120
|
const AI_LOGGING_ORPHAN_GRACE_MS = 6e5;
|
|
120
|
-
function settingsRecord(value, name) {
|
|
121
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${name} must be an object.`);
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
121
|
function parsePlanAiLoggingPublish(value) {
|
|
125
122
|
if (value === null || value === void 0) return null;
|
|
126
|
-
const { revision, planIds, includeUnknown, cursor, complete, error } =
|
|
127
|
-
if (!Number.isSafeInteger(revision) || !Array.isArray(planIds) || !planIds.every((id) => typeof id === "string") || typeof includeUnknown !== "boolean" || cursor !== null && typeof cursor !== "string" || typeof complete !== "boolean" || error !== void 0 && typeof error !== "string") throw new Error("Invalid AI logging publish progress.");
|
|
123
|
+
const { revision, planIds, includeUnknown, cursor, complete, error } = record(value, "AI logging publish");
|
|
124
|
+
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || !Array.isArray(planIds) || !planIds.every((id) => typeof id === "string") || typeof includeUnknown !== "boolean" || cursor !== null && typeof cursor !== "string" || typeof complete !== "boolean" || error !== void 0 && typeof error !== "string") throw new Error("Invalid AI logging publish progress.");
|
|
128
125
|
return {
|
|
129
126
|
revision,
|
|
130
127
|
planIds,
|
|
@@ -145,8 +142,8 @@ function parsePlanAiLoggingSettings(value) {
|
|
|
145
142
|
modes: {},
|
|
146
143
|
publish: null
|
|
147
144
|
};
|
|
148
|
-
const input =
|
|
149
|
-
const saved =
|
|
145
|
+
const input = record(value, "Plan AI logging settings");
|
|
146
|
+
const saved = record(input.modes ?? {}, "Plan AI logging modes");
|
|
150
147
|
const modes = {};
|
|
151
148
|
for (const [planId, mode] of Object.entries(saved)) {
|
|
152
149
|
if (!isAiLoggingMode(mode)) throw new Error(`Invalid AI logging mode for plan ${planId}.`);
|
package/dist/browser-page.mjs
CHANGED
|
@@ -62,13 +62,13 @@ html[data-theme="dark"] { color-scheme: dark; }
|
|
|
62
62
|
@media (max-width: 500px) { .void-auth-page h1 { font-size: 24px; } }
|
|
63
63
|
`;
|
|
64
64
|
function escapeBrowserHtml(value) {
|
|
65
|
-
return value.
|
|
65
|
+
return value.replaceAll(/[&<>"']/g, (character) => ({
|
|
66
66
|
"&": "&",
|
|
67
67
|
"<": "<",
|
|
68
68
|
">": ">",
|
|
69
69
|
"\"": """,
|
|
70
70
|
"'": "'"
|
|
71
|
-
})[character]);
|
|
71
|
+
})[character] ?? character);
|
|
72
72
|
}
|
|
73
73
|
function browserPageIdentity(identity) {
|
|
74
74
|
return "<dl class=\"void-auth-identity\">" + [
|
package/dist/email-protocol.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as isRecord } from "./validate-CTKcW3Vp.mjs";
|
|
1
2
|
// src/email-protocol.ts
|
|
2
3
|
/** Worker-safe wire contract shared by the platform gateway and tenant entry. */
|
|
3
4
|
const EMAIL_PROTOCOL_VERSION = 1;
|
|
@@ -11,6 +12,9 @@ const EMAIL_MAX_INBOUND_HEADERS = 1024;
|
|
|
11
12
|
const EMAIL_MAX_INBOUND_HEADER_BYTES = 131072;
|
|
12
13
|
const encoder = new TextEncoder();
|
|
13
14
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
15
|
+
function hasStringHeaderValues(headers) {
|
|
16
|
+
return Object.values(headers).every((header) => typeof header === "string");
|
|
17
|
+
}
|
|
14
18
|
function assertFlatJson(bytes, maxDepth, maxFields) {
|
|
15
19
|
let depth = 0;
|
|
16
20
|
let fields = 0;
|
|
@@ -74,11 +78,10 @@ async function readEmailEnvelope(stream, deadlineMs = 15e3) {
|
|
|
74
78
|
if (metadataLength > 131072 || total < 4 + metadataLength) throw new Error("invalid email envelope");
|
|
75
79
|
const metadataBytes = bytes.subarray(4, 4 + metadataLength);
|
|
76
80
|
assertFlatJson(metadataBytes, 2, 1032);
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
const value = metadata;
|
|
81
|
+
const value = JSON.parse(decoder.decode(metadataBytes));
|
|
82
|
+
if (!isRecord(value)) throw new Error("invalid email envelope");
|
|
80
83
|
const raw = bytes.subarray(4 + metadataLength, total);
|
|
81
|
-
if (raw.byteLength > 10485760 || typeof value.from !== "string" || value.from.length > 320 || typeof value.to !== "string" || value.to.length > 320 || typeof value.rawSize !== "number" || value.rawSize !== raw.byteLength || !
|
|
84
|
+
if (raw.byteLength > 10485760 || typeof value.from !== "string" || value.from.length > 320 || typeof value.to !== "string" || value.to.length > 320 || typeof value.rawSize !== "number" || value.rawSize !== raw.byteLength || !isRecord(value.headers) || Object.keys(value.headers).length > 1024 || !hasStringHeaderValues(value.headers) || value.viaDomain !== void 0 && (typeof value.viaDomain !== "string" || value.viaDomain.length > 253)) throw new Error("invalid email envelope");
|
|
82
85
|
return {
|
|
83
86
|
from: value.from,
|
|
84
87
|
to: value.to,
|
|
@@ -119,15 +122,15 @@ async function verifyEmailReceipt(token, signingSecret, expected, now = Date.now
|
|
|
119
122
|
const signature = unbase64url(parts[1]);
|
|
120
123
|
if (payload.byteLength > 768 || signature.byteLength !== 32) return null;
|
|
121
124
|
if (!await crypto.subtle.verify("HMAC", await receiptKey(signingSecret, "verify"), Uint8Array.from(signature), Uint8Array.from(payload))) return null;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const value = claims;
|
|
125
|
-
if (value.version !== 1 || typeof value.receiptId !== "string" || !/^[a-f0-9-]{16,64}$/.test(value.receiptId) || value.projectId !== expected.projectId || value.deploymentId !== expected.deploymentId || value.recipient !== expected.recipient || typeof value.expiresAt !== "number" || !Number.isSafeInteger(value.expiresAt) || value.expiresAt < now || value.expiresAt > now + 6e4) return null;
|
|
126
|
-
return value;
|
|
125
|
+
const value = JSON.parse(decoder.decode(payload));
|
|
126
|
+
return matchesReceiptClaims(value, expected, now) ? value : null;
|
|
127
127
|
} catch {
|
|
128
128
|
return null;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
function matchesReceiptClaims(value, expected, now) {
|
|
132
|
+
return isRecord(value) && value.version === 1 && typeof value.receiptId === "string" && /^[a-f0-9-]{16,64}$/.test(value.receiptId) && value.projectId === expected.projectId && value.deploymentId === expected.deploymentId && value.recipient === expected.recipient && typeof value.expiresAt === "number" && Number.isSafeInteger(value.expiresAt) && !(value.expiresAt < now || value.expiresAt > now + 6e4);
|
|
133
|
+
}
|
|
131
134
|
function frame(kind, payload) {
|
|
132
135
|
const bytes = new Uint8Array(5 + payload.byteLength);
|
|
133
136
|
new DataView(bytes.buffer).setUint32(0, payload.byteLength);
|
|
@@ -212,9 +215,8 @@ async function readEmailActions(stream, deadlineMs = 15e3) {
|
|
|
212
215
|
if (kind !== 1 || length > 8192 || actions.length >= 100) throw new Error("invalid email action frame");
|
|
213
216
|
const metadataBytes = await exact(length);
|
|
214
217
|
assertFlatJson(metadataBytes, 2, 40);
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
const action = value;
|
|
218
|
+
const action = JSON.parse(decoder.decode(metadataBytes));
|
|
219
|
+
if (!isRecord(action)) throw new Error("invalid email action");
|
|
218
220
|
if (action.type === "reply") {
|
|
219
221
|
if (typeof action.from !== "string" || typeof action.to !== "string" || Object.keys(action).length !== 3) throw new Error("invalid email reply");
|
|
220
222
|
const rawHead = await exact(5);
|
|
@@ -227,9 +229,9 @@ async function readEmailActions(stream, deadlineMs = 15e3) {
|
|
|
227
229
|
raw: await exact(rawLength)
|
|
228
230
|
});
|
|
229
231
|
} else if (action.type === "forward") {
|
|
230
|
-
if (typeof action.to !== "string" || Object.keys(action).length > 3 || action.headers !== void 0 && (typeof action.headers !== "object" || action.headers === null || Array.isArray(action.headers))) throw new Error("invalid email forward");
|
|
231
232
|
const headers = action.headers;
|
|
232
|
-
if (
|
|
233
|
+
if (typeof action.to !== "string" || Object.keys(action).length > 3 || headers !== void 0 && !isRecord(headers)) throw new Error("invalid email forward");
|
|
234
|
+
if (headers && (Object.keys(headers).length > 32 || !hasStringHeaderValues(headers))) throw new Error("invalid email headers");
|
|
233
235
|
actions.push({
|
|
234
236
|
type: "forward",
|
|
235
237
|
to: action.to,
|
package/dist/index.d.mts
CHANGED
|
@@ -26,7 +26,7 @@ type PlatformAppAccessSetup = Readonly<{
|
|
|
26
26
|
identityProviderIds: ReadonlyArray<string>;
|
|
27
27
|
policyIds: ReadonlyArray<string>;
|
|
28
28
|
}>;
|
|
29
|
-
export declare function parsePlatformAppAccessSetup(
|
|
29
|
+
export declare function parsePlatformAppAccessSetup(input: unknown): PlatformAppAccessSetup;
|
|
30
30
|
/** Owner recovery capabilities authorize a provider test, never a platform session. */
|
|
31
31
|
type PlatformAuthenticationRecovery = Readonly<{
|
|
32
32
|
installationId: string;
|
|
@@ -192,6 +192,11 @@ type PlatformCapabilities = Readonly<{
|
|
|
192
192
|
googleOAuth: boolean;
|
|
193
193
|
managedBuilds: boolean;
|
|
194
194
|
sandbox: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* The installation may run security audits. Optional in stored documents:
|
|
197
|
+
* missing means `false`. `true` requires deployment schema version 7.
|
|
198
|
+
*/
|
|
199
|
+
securityAudits: boolean;
|
|
195
200
|
}>;
|
|
196
201
|
type PlatformControlPlane = Readonly<{
|
|
197
202
|
apiHostname: string | null;
|
|
@@ -248,7 +253,11 @@ type PlatformDeploymentManifest = Readonly<{
|
|
|
248
253
|
runtimeLogs?: PlatformRuntimeLogs;
|
|
249
254
|
/** Requires schema version 6 so older CLIs cannot silently drop this setting. */
|
|
250
255
|
storageLocationHint?: R2LocationHint;
|
|
251
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Version 7 means `capabilities.securityAudits` is on, so an older CLI refuses
|
|
258
|
+
* the manifest instead of dropping the capability.
|
|
259
|
+
*/
|
|
260
|
+
schemaVersion: typeof PLATFORM_DEPLOYMENT_SCHEMA_VERSION | 2 | 3 | 4 | 5 | 6 | 7;
|
|
252
261
|
}>;
|
|
253
262
|
type PlatformDeploymentManifestInput = Readonly<{
|
|
254
263
|
appAccess?: PlatformAppAccess;
|
|
@@ -278,6 +287,17 @@ type PlatformApplicationRoute = Readonly<{
|
|
|
278
287
|
pattern: string;
|
|
279
288
|
zoneName: string;
|
|
280
289
|
}>;
|
|
290
|
+
/**
|
|
291
|
+
* Reads one capability from an untrusted record. An optional capability that
|
|
292
|
+
* older documents omit reads as `false`; anything else is returned unchanged
|
|
293
|
+
* for the caller to validate.
|
|
294
|
+
*/
|
|
295
|
+
export declare function readPlatformCapability(record: Readonly<Record<string, unknown>>, name: string): unknown;
|
|
296
|
+
/**
|
|
297
|
+
* `PLATFORM_CAPABILITIES` for the platform Workers. An optional capability that
|
|
298
|
+
* is off is left out, so an installation without it gets the same value as before.
|
|
299
|
+
*/
|
|
300
|
+
export declare function serializePlatformCapabilities(capabilities: PlatformCapabilities): string;
|
|
281
301
|
export declare function normalizeInstallationSlug(value: string): string;
|
|
282
302
|
export declare function normalizeApplicationDomain(value: string): string;
|
|
283
303
|
export declare function normalizePlatformDashboardUrl(value: string): string;
|
|
@@ -382,7 +402,7 @@ type PlatformResourceOwnershipMarker = Readonly<{
|
|
|
382
402
|
resourceName: string;
|
|
383
403
|
schemaVersion: typeof PLATFORM_RESOURCE_OWNERSHIP_SCHEMA_VERSION;
|
|
384
404
|
}>;
|
|
385
|
-
|
|
405
|
+
type ResourceOwnershipMarkerInput = {
|
|
386
406
|
accountId: string;
|
|
387
407
|
installationId: string;
|
|
388
408
|
ownershipNonce: string;
|
|
@@ -390,7 +410,8 @@ export declare function createPlatformResourceOwnershipMarker(input: {
|
|
|
390
410
|
resourceKey: string;
|
|
391
411
|
resourceKind: InstallationResourceKind;
|
|
392
412
|
resourceName: string;
|
|
393
|
-
}
|
|
413
|
+
};
|
|
414
|
+
export declare function createPlatformResourceOwnershipMarker(input: ResourceOwnershipMarkerInput): PlatformResourceOwnershipMarker;
|
|
394
415
|
export declare function parsePlatformResourceOwnershipMarker(value: unknown): PlatformResourceOwnershipMarker;
|
|
395
416
|
export declare function createPlatformInstallationManifest(input: {
|
|
396
417
|
account: {
|
|
@@ -473,6 +494,11 @@ export declare function createPlatformWorkerConfigs(input: {
|
|
|
473
494
|
proxyUrl: string;
|
|
474
495
|
emailGatewayUrl: string;
|
|
475
496
|
resources: PlatformProvisionedResourceIds;
|
|
497
|
+
/**
|
|
498
|
+
* The runtime exports `SecurityScanScheduler` (runtime manifest `securityAudits: 1`).
|
|
499
|
+
* The class and its migration then ship whatever the capability says.
|
|
500
|
+
*/
|
|
501
|
+
securityScanScheduler?: boolean;
|
|
476
502
|
runtimeEntrypoints: Readonly<Record<"api" | "dispatch" | "proxy" | "tail" | "emailGateway", string>>;
|
|
477
503
|
runtimeApiAssetsDirectory?: string;
|
|
478
504
|
trafficState?: "enabled" | "sandbox-drain" | "staging";
|