@volter/world-core 3.0.38 → 3.0.40
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/app-route.cjs +26 -25
- package/app-route.d.cts +1 -0
- package/dist/app-route.cjs +26 -25
- package/dist/app-route.d.cts +1 -0
- package/dist/generated/pack-facts.json +409 -352
- package/dist/inject.cjs +474 -95
- package/dist/network-policy.cjs +110 -13
- package/dist/network-policy.d.cts +8 -3
- package/dist/src/actions.js +2 -1
- package/dist/src/anthropic-wire.d.ts +2 -0
- package/dist/src/anthropic-wire.js +5 -0
- package/dist/src/attestation.d.ts +6 -0
- package/dist/src/attestation.js +27 -0
- package/dist/src/bytes.d.ts +3 -0
- package/dist/src/bytes.js +17 -0
- package/dist/src/changeset.js +2 -1
- package/dist/src/clickhouse/sql.js +73 -14
- package/dist/src/derived-core.d.ts +210 -32
- package/dist/src/derived-core.js +510 -244
- package/dist/src/derived-real.d.ts +1 -1
- package/dist/src/derived-real.js +704 -93
- package/dist/src/derived.d.ts +18 -2
- package/dist/src/derived.js +21 -2
- package/dist/src/events.d.ts +28 -45
- package/dist/src/events.js +40 -58
- package/dist/src/exact-json.d.ts +10 -0
- package/dist/src/exact-json.js +98 -0
- package/dist/src/executor.d.ts +17 -0
- package/dist/src/executor.js +91 -30
- package/dist/src/file-response.js +1 -1
- package/dist/src/form.d.ts +8 -0
- package/dist/src/form.js +76 -0
- package/dist/src/git/format.d.ts +16 -0
- package/dist/src/git/format.js +110 -0
- package/dist/src/git/index.d.ts +1 -0
- package/dist/src/git/index.js +1 -0
- package/dist/src/git/lfs.d.ts +1 -1
- package/dist/src/git/lfs.js +4 -3
- package/dist/src/graphql-wire.d.ts +6 -0
- package/dist/src/graphql-wire.js +6 -3
- package/dist/src/grpc-wire.js +2 -1
- package/dist/src/head.d.ts +1 -0
- package/dist/src/head.js +15 -4
- package/dist/src/held-reads.d.ts +6 -0
- package/dist/src/held-reads.js +60 -0
- package/dist/src/history.js +5 -4
- package/dist/src/host-port.d.ts +5 -0
- package/dist/src/host-port.js +14 -0
- package/dist/src/index.d.ts +11 -3
- package/dist/src/index.js +9 -4
- package/dist/src/log.js +12 -7
- package/dist/src/machines.d.ts +81 -5
- package/dist/src/machines.js +125 -9
- package/dist/src/managed-database.d.ts +15 -11
- package/dist/src/managed-database.js +38 -37
- package/dist/src/multipart.d.ts +21 -3
- package/dist/src/multipart.js +112 -38
- package/dist/src/observe.d.ts +3 -0
- package/dist/src/observe.js +6 -2
- package/dist/src/openai-wire.d.ts +16 -0
- package/dist/src/openai-wire.js +43 -12
- package/dist/src/pack-fetch.d.ts +4 -6
- package/dist/src/pack-fetch.js +189 -57
- package/dist/src/packRegistry.d.ts +7 -1
- package/dist/src/packRegistry.js +20 -3
- package/dist/src/private-transport.d.ts +1 -0
- package/dist/src/private-transport.js +11 -0
- package/dist/src/protobuf.js +10 -4
- package/dist/src/rateBudget.d.ts +8 -1
- package/dist/src/rateBudget.js +1 -0
- package/dist/src/redis/engine.d.ts +14 -5
- package/dist/src/redis/engine.js +271 -72
- package/dist/src/redis/frames.d.ts +17 -0
- package/dist/src/redis/frames.js +123 -0
- package/dist/src/redis/index.d.ts +6 -0
- package/dist/src/redis/index.js +6 -0
- package/dist/src/redis/json.d.ts +2 -0
- package/dist/src/redis/json.js +14 -0
- package/dist/src/redis/lua-libs.d.ts +4 -0
- package/dist/src/redis/lua-libs.js +173 -0
- package/dist/src/redis/lua.d.ts +1 -0
- package/dist/src/redis/lua.js +36 -0
- package/dist/src/redis/member-storage.d.ts +5 -0
- package/dist/src/redis/member-storage.js +75 -0
- package/dist/src/redis/resp2.d.ts +4 -0
- package/dist/src/redis/resp2.js +29 -0
- package/dist/src/redis/stream.d.ts +14 -0
- package/dist/src/redis/stream.js +335 -0
- package/dist/src/remote-execute.d.ts +2 -2
- package/dist/src/request-body.d.ts +11 -0
- package/dist/src/request-body.js +11 -0
- package/dist/src/runtime.d.ts +6 -5
- package/dist/src/runtime.js +5 -5
- package/dist/src/s3/wire.d.ts +4 -4
- package/dist/src/s3/wire.js +5 -3
- package/dist/src/scenario.d.ts +22 -0
- package/dist/src/scenario.js +35 -31
- package/dist/src/serve-http.d.ts +2 -1
- package/dist/src/serve-http.js +10 -1
- package/dist/src/serve.js +7 -4
- package/dist/src/signing.d.ts +23 -5
- package/dist/src/signing.js +74 -11
- package/dist/src/sigv4.d.ts +3 -1
- package/dist/src/sigv4.js +4 -2
- package/dist/src/smtp.js +2 -1
- package/dist/src/sockets.js +8 -3
- package/dist/src/state-system.d.ts +3 -0
- package/dist/src/storage.js +5 -2
- package/dist/src/twin-fetch.d.ts +3 -1
- package/dist/src/twin-fetch.js +3 -2
- package/dist/src/vendor-call.d.ts +10 -3
- package/dist/src/vendor-call.js +58 -14
- package/dist/test-fixtures/attestation.SOURCE.md +1 -0
- package/dist/test-fixtures/attestation.json +50 -0
- package/generated/pack-facts.json +409 -352
- package/inject.cjs +474 -95
- package/network-policy.cjs +110 -13
- package/network-policy.d.cts +8 -3
- package/package.json +11 -4
- package/src/actions.ts +2 -1
- package/src/anthropic-wire.ts +6 -0
- package/src/attestation.ts +23 -0
- package/src/bytes.ts +21 -0
- package/src/changeset.ts +2 -1
- package/src/clickhouse/sql.ts +50 -16
- package/src/derived-core.ts +573 -249
- package/src/derived-real.ts +552 -42
- package/src/derived.ts +23 -4
- package/src/events.ts +54 -85
- package/src/exact-json.ts +71 -0
- package/src/executor.ts +86 -27
- package/src/file-response.ts +1 -1
- package/src/form.ts +66 -0
- package/src/git/format.ts +89 -0
- package/src/git/index.ts +1 -0
- package/src/git/lfs.ts +5 -4
- package/src/graphql-wire.ts +8 -3
- package/src/grpc-wire.ts +2 -1
- package/src/head.ts +15 -5
- package/src/held-reads.ts +54 -0
- package/src/history.ts +5 -4
- package/src/host-port.ts +9 -0
- package/src/index.ts +10 -4
- package/src/log.ts +11 -7
- package/src/machines.ts +135 -13
- package/src/managed-database.ts +48 -40
- package/src/multipart.ts +110 -35
- package/src/observe.ts +6 -3
- package/src/openai-wire.ts +45 -14
- package/src/pack-fetch.ts +173 -50
- package/src/packRegistry.ts +27 -4
- package/src/private-transport.ts +8 -0
- package/src/protobuf.ts +8 -4
- package/src/rateBudget.ts +6 -1
- package/src/redis/engine.ts +168 -63
- package/src/redis/frames.ts +53 -0
- package/src/redis/index.ts +6 -0
- package/src/redis/json.ts +13 -0
- package/src/redis/lua-libs.ts +62 -0
- package/src/redis/lua.ts +20 -0
- package/src/redis/member-storage.ts +58 -0
- package/src/redis/resp2.ts +25 -0
- package/src/redis/stream.ts +102 -0
- package/src/remote-execute.ts +2 -2
- package/src/request-body.ts +12 -0
- package/src/runtime.ts +6 -5
- package/src/s3/wire.ts +8 -5
- package/src/scenario.ts +34 -13
- package/src/serve-http.ts +11 -2
- package/src/serve.ts +4 -3
- package/src/signing.ts +71 -17
- package/src/sigv4.ts +5 -3
- package/src/smtp.ts +3 -2
- package/src/sockets.ts +8 -3
- package/src/state-system.ts +3 -0
- package/src/storage.ts +5 -2
- package/src/twin-fetch.ts +4 -3
- package/src/vendor-call.ts +59 -12
- package/test-fixtures/attestation.json +50 -0
package/app-route.cjs
CHANGED
|
@@ -222,37 +222,39 @@ async function appFetch(value, init = {}) {
|
|
|
222
222
|
if (refusal !== null) throw new TypeError(refusal);
|
|
223
223
|
return fetch(value, init);
|
|
224
224
|
}
|
|
225
|
-
const mode = init.redirect || 'follow';
|
|
226
|
-
const signal = init.signal || undefined;
|
|
227
|
-
let at = new URL(String(value));
|
|
228
|
-
let method = String(init.method || 'GET').toUpperCase();
|
|
229
225
|
const headers = {};
|
|
230
226
|
new Headers(init.headers || {}).forEach((v, k) => { headers[k] = v; });
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
const body = requestBody(init.body, headers);
|
|
228
|
+
return followRedirects(value, { ...init, headers, body }, async (at, request) => {
|
|
229
|
+
const method = request.method, signal = request.signal;
|
|
230
|
+
const headers = Object.fromEntries(new Headers(request.headers));
|
|
233
231
|
const route = appDestination(at);
|
|
234
|
-
let res;
|
|
235
232
|
if (route) {
|
|
236
|
-
// the application's own origin is where the request goes: an application recorded outside the World (an app-url
|
|
237
|
-
// naming a deployment elsewhere) meets the World's egress rule as any other destination does
|
|
238
233
|
const originRefusal = require('./network-policy.cjs').worldEgressRefusal(route.origin);
|
|
239
234
|
if (originRefusal !== null) throw new TypeError(originRefusal);
|
|
240
|
-
|
|
241
|
-
// application never holds a delivery, or the API request awaiting it, for good; a caller's signal may end it sooner
|
|
242
|
-
const answer = await deliverToApp(route, at, { method, headers, body, signal, timeoutMs: 300_000 });
|
|
235
|
+
const answer = await deliverToApp(route, at, { method, headers, body: request.body, signal, timeoutMs: 300_000 });
|
|
243
236
|
const nullBody = NULL_BODY.includes(answer.status) || method === 'HEAD';
|
|
244
|
-
// a status fetch resolves with but Response refuses to construct (outside 200-599) is carried as fetch carries it
|
|
245
237
|
const inRange = answer.status >= 200 && answer.status <= 599;
|
|
246
|
-
res = new Response(nullBody ? null : answer.body, { status: inRange ? answer.status : 200, headers: answer.headers });
|
|
238
|
+
const res = new Response(nullBody ? null : answer.body, { status: inRange ? answer.status : 200, headers: answer.headers });
|
|
247
239
|
if (!inRange) Object.defineProperties(res, { status: { value: answer.status }, ok: { value: false } });
|
|
248
240
|
Object.defineProperty(res, 'url', { value: at.toString() });
|
|
249
|
-
|
|
250
|
-
const refusal = require('./network-policy.cjs').worldEgressRefusal(at);
|
|
251
|
-
if (refusal !== null) throw new TypeError(refusal);
|
|
252
|
-
// off the application, the World's own headers never go with the request
|
|
253
|
-
for (const k of Object.keys(headers)) if (['x-twins-key', 'x-volter-twin-original-host'].includes(k.toLowerCase())) delete headers[k];
|
|
254
|
-
res = await fetch(at, { method, headers, ...(body != null && method !== 'GET' && method !== 'HEAD' ? { body } : {}), redirect: 'manual', signal });
|
|
241
|
+
return res;
|
|
255
242
|
}
|
|
243
|
+
const refusal = require('./network-policy.cjs').worldEgressRefusal(at);
|
|
244
|
+
if (refusal !== null) throw new TypeError(refusal);
|
|
245
|
+
for (const k of Object.keys(headers)) if (['x-twins-key', 'x-volter-twin-original-host'].includes(k.toLowerCase())) { delete headers[k]; request.headers.delete(k); }
|
|
246
|
+
return fetch(at, { ...request, headers, body: method === 'GET' || method === 'HEAD' ? undefined : request.body });
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Shared Fetch redirect semantics. send routes/refuses each hop; no destination is fetched here. */
|
|
251
|
+
async function followRedirects(value, init, send, extraDropped = []) {
|
|
252
|
+
const mode = init.redirect || 'follow';
|
|
253
|
+
let at = new URL(String(value));
|
|
254
|
+
let method = String(init.method || 'GET').toUpperCase(), body = init.body;
|
|
255
|
+
const headers = new Headers(init.headers);
|
|
256
|
+
for (let hops = 0; ; hops++) {
|
|
257
|
+
const res = await send(at, { ...init, method, headers, body, redirect: 'manual' });
|
|
256
258
|
if (hops > 0) Object.defineProperty(res, 'redirected', { value: true });
|
|
257
259
|
const location = res.headers.get('location');
|
|
258
260
|
if (!REDIRECTS.includes(res.status) || location === null || mode === 'manual') return res;
|
|
@@ -262,13 +264,12 @@ async function appFetch(value, init = {}) {
|
|
|
262
264
|
const next = new URL(location, at);
|
|
263
265
|
if (next.protocol !== 'http:' && next.protocol !== 'https:') throw new TypeError(`redirect to ${next.protocol} is not followed`);
|
|
264
266
|
if ((res.status === 303 && method !== 'GET' && method !== 'HEAD') || ((res.status === 301 || res.status === 302) && method === 'POST')) {
|
|
265
|
-
method = 'GET';
|
|
266
|
-
|
|
267
|
-
for (const k of Object.keys(headers)) if (/^content-/i.test(k)) delete headers[k];
|
|
267
|
+
method = 'GET'; body = undefined;
|
|
268
|
+
for (const k of [...headers.keys()]) if (/^content-/i.test(k)) headers.delete(k);
|
|
268
269
|
}
|
|
269
|
-
if (next.origin !== at.origin) for (const k of
|
|
270
|
+
if (next.origin !== at.origin) for (const k of [...headers.keys()]) if ([...CROSS_ORIGIN_DROPPED, ...extraDropped].includes(k.toLowerCase())) headers.delete(k);
|
|
270
271
|
at = next;
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
|
|
274
|
-
module.exports = { appRouteFor, appHostMatch, appForwardHeaders, appDestination, appRequestOptions, deliverToApp, appFetch, sessionCa };
|
|
275
|
+
module.exports = { appRouteFor, appHostMatch, appForwardHeaders, appDestination, appRequestOptions, deliverToApp, appFetch, followRedirects, sessionCa };
|
package/app-route.d.cts
CHANGED
|
@@ -6,3 +6,4 @@ export function appForwardHeaders(url: URL): Record<string, string>;
|
|
|
6
6
|
export function appDestination(value: string | URL, env?: Readonly<Record<string, string | undefined>>): AppRoute | null;
|
|
7
7
|
export function deliverToApp(route: AppRoute, value: string | URL, init?: { method?: string; headers?: Record<string, string>; body?: string | Uint8Array | null; /** Infinity: no deadline of its own */ timeoutMs?: number; signal?: AbortSignal }): Promise<AppAnswer>;
|
|
8
8
|
export function appFetch(value: string | URL, init?: RequestInit): Promise<Response>;
|
|
9
|
+
export function followRedirects(value: string | URL, init: RequestInit, send: (url: URL, init: RequestInit) => Promise<Response>, extraDropped?: string[]): Promise<Response>;
|
package/dist/app-route.cjs
CHANGED
|
@@ -222,37 +222,39 @@ async function appFetch(value, init = {}) {
|
|
|
222
222
|
if (refusal !== null) throw new TypeError(refusal);
|
|
223
223
|
return fetch(value, init);
|
|
224
224
|
}
|
|
225
|
-
const mode = init.redirect || 'follow';
|
|
226
|
-
const signal = init.signal || undefined;
|
|
227
|
-
let at = new URL(String(value));
|
|
228
|
-
let method = String(init.method || 'GET').toUpperCase();
|
|
229
225
|
const headers = {};
|
|
230
226
|
new Headers(init.headers || {}).forEach((v, k) => { headers[k] = v; });
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
const body = requestBody(init.body, headers);
|
|
228
|
+
return followRedirects(value, { ...init, headers, body }, async (at, request) => {
|
|
229
|
+
const method = request.method, signal = request.signal;
|
|
230
|
+
const headers = Object.fromEntries(new Headers(request.headers));
|
|
233
231
|
const route = appDestination(at);
|
|
234
|
-
let res;
|
|
235
232
|
if (route) {
|
|
236
|
-
// the application's own origin is where the request goes: an application recorded outside the World (an app-url
|
|
237
|
-
// naming a deployment elsewhere) meets the World's egress rule as any other destination does
|
|
238
233
|
const originRefusal = require('./network-policy.cjs').worldEgressRefusal(route.origin);
|
|
239
234
|
if (originRefusal !== null) throw new TypeError(originRefusal);
|
|
240
|
-
|
|
241
|
-
// application never holds a delivery, or the API request awaiting it, for good; a caller's signal may end it sooner
|
|
242
|
-
const answer = await deliverToApp(route, at, { method, headers, body, signal, timeoutMs: 300_000 });
|
|
235
|
+
const answer = await deliverToApp(route, at, { method, headers, body: request.body, signal, timeoutMs: 300_000 });
|
|
243
236
|
const nullBody = NULL_BODY.includes(answer.status) || method === 'HEAD';
|
|
244
|
-
// a status fetch resolves with but Response refuses to construct (outside 200-599) is carried as fetch carries it
|
|
245
237
|
const inRange = answer.status >= 200 && answer.status <= 599;
|
|
246
|
-
res = new Response(nullBody ? null : answer.body, { status: inRange ? answer.status : 200, headers: answer.headers });
|
|
238
|
+
const res = new Response(nullBody ? null : answer.body, { status: inRange ? answer.status : 200, headers: answer.headers });
|
|
247
239
|
if (!inRange) Object.defineProperties(res, { status: { value: answer.status }, ok: { value: false } });
|
|
248
240
|
Object.defineProperty(res, 'url', { value: at.toString() });
|
|
249
|
-
|
|
250
|
-
const refusal = require('./network-policy.cjs').worldEgressRefusal(at);
|
|
251
|
-
if (refusal !== null) throw new TypeError(refusal);
|
|
252
|
-
// off the application, the World's own headers never go with the request
|
|
253
|
-
for (const k of Object.keys(headers)) if (['x-twins-key', 'x-volter-twin-original-host'].includes(k.toLowerCase())) delete headers[k];
|
|
254
|
-
res = await fetch(at, { method, headers, ...(body != null && method !== 'GET' && method !== 'HEAD' ? { body } : {}), redirect: 'manual', signal });
|
|
241
|
+
return res;
|
|
255
242
|
}
|
|
243
|
+
const refusal = require('./network-policy.cjs').worldEgressRefusal(at);
|
|
244
|
+
if (refusal !== null) throw new TypeError(refusal);
|
|
245
|
+
for (const k of Object.keys(headers)) if (['x-twins-key', 'x-volter-twin-original-host'].includes(k.toLowerCase())) { delete headers[k]; request.headers.delete(k); }
|
|
246
|
+
return fetch(at, { ...request, headers, body: method === 'GET' || method === 'HEAD' ? undefined : request.body });
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Shared Fetch redirect semantics. send routes/refuses each hop; no destination is fetched here. */
|
|
251
|
+
async function followRedirects(value, init, send, extraDropped = []) {
|
|
252
|
+
const mode = init.redirect || 'follow';
|
|
253
|
+
let at = new URL(String(value));
|
|
254
|
+
let method = String(init.method || 'GET').toUpperCase(), body = init.body;
|
|
255
|
+
const headers = new Headers(init.headers);
|
|
256
|
+
for (let hops = 0; ; hops++) {
|
|
257
|
+
const res = await send(at, { ...init, method, headers, body, redirect: 'manual' });
|
|
256
258
|
if (hops > 0) Object.defineProperty(res, 'redirected', { value: true });
|
|
257
259
|
const location = res.headers.get('location');
|
|
258
260
|
if (!REDIRECTS.includes(res.status) || location === null || mode === 'manual') return res;
|
|
@@ -262,13 +264,12 @@ async function appFetch(value, init = {}) {
|
|
|
262
264
|
const next = new URL(location, at);
|
|
263
265
|
if (next.protocol !== 'http:' && next.protocol !== 'https:') throw new TypeError(`redirect to ${next.protocol} is not followed`);
|
|
264
266
|
if ((res.status === 303 && method !== 'GET' && method !== 'HEAD') || ((res.status === 301 || res.status === 302) && method === 'POST')) {
|
|
265
|
-
method = 'GET';
|
|
266
|
-
|
|
267
|
-
for (const k of Object.keys(headers)) if (/^content-/i.test(k)) delete headers[k];
|
|
267
|
+
method = 'GET'; body = undefined;
|
|
268
|
+
for (const k of [...headers.keys()]) if (/^content-/i.test(k)) headers.delete(k);
|
|
268
269
|
}
|
|
269
|
-
if (next.origin !== at.origin) for (const k of
|
|
270
|
+
if (next.origin !== at.origin) for (const k of [...headers.keys()]) if ([...CROSS_ORIGIN_DROPPED, ...extraDropped].includes(k.toLowerCase())) headers.delete(k);
|
|
270
271
|
at = next;
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
|
|
274
|
-
module.exports = { appRouteFor, appHostMatch, appForwardHeaders, appDestination, appRequestOptions, deliverToApp, appFetch, sessionCa };
|
|
275
|
+
module.exports = { appRouteFor, appHostMatch, appForwardHeaders, appDestination, appRequestOptions, deliverToApp, appFetch, followRedirects, sessionCa };
|
package/dist/app-route.d.cts
CHANGED
|
@@ -6,3 +6,4 @@ export function appForwardHeaders(url: URL): Record<string, string>;
|
|
|
6
6
|
export function appDestination(value: string | URL, env?: Readonly<Record<string, string | undefined>>): AppRoute | null;
|
|
7
7
|
export function deliverToApp(route: AppRoute, value: string | URL, init?: { method?: string; headers?: Record<string, string>; body?: string | Uint8Array | null; /** Infinity: no deadline of its own */ timeoutMs?: number; signal?: AbortSignal }): Promise<AppAnswer>;
|
|
8
8
|
export function appFetch(value: string | URL, init?: RequestInit): Promise<Response>;
|
|
9
|
+
export function followRedirects(value: string | URL, init: RequestInit, send: (url: URL, init: RequestInit) => Promise<Response>, extraDropped?: string[]): Promise<Response>;
|