@query-farm/vgi 0.48.4 → 0.49.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/README.md +52 -1
- package/dist/attach-secret-keyfile.d.ts +11 -0
- package/dist/attach-secret-options.d.ts +96 -0
- package/dist/catalog/attach-option.d.ts +6 -0
- package/dist/catalog/composite.d.ts +2 -0
- package/dist/catalog/descriptors.d.ts +11 -0
- package/dist/catalog/interface.d.ts +54 -2
- package/dist/catalog/scan-planning.d.ts +76 -0
- package/dist/client-entry.js +32 -4
- package/dist/client-entry.js.map +9 -8
- package/dist/generated/vgi-client.d.ts +1 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +1 -1
- package/dist/generated/vgi-service.d.ts +5 -1
- package/dist/index.core.d.ts +3 -0
- package/dist/index.js +3245 -2538
- package/dist/index.js.map +32 -29
- package/dist/protocol/dispatch.d.ts +13 -2
- package/dist/protocol/handlers/catalog/admin.d.ts +1 -1
- package/dist/protocol/handlers/catalog/index.d.ts +1 -1
- package/dist/protocol/handlers/catalog/index_methods.d.ts +1 -1
- package/dist/protocol/handlers/catalog/macro.d.ts +1 -1
- package/dist/protocol/handlers/catalog/shared.d.ts +28 -3
- package/dist/protocol/handlers/catalog/table.d.ts +1 -1
- package/dist/protocol/handlers/catalog/view.d.ts +1 -1
- package/dist/protocol/handlers/function.d.ts +2 -0
- package/dist/protocol/handlers/table-buffering.d.ts +1 -1
- package/dist/serve-entry.d.ts +5 -0
- package/dist/serve-entry.js +2026 -101
- package/dist/serve-entry.js.map +27 -20
- package/dist/worker-cf-entry.d.ts +2 -2
- package/dist/worker-cf-entry.js +823 -103
- package/dist/worker-cf-entry.js.map +27 -24
- package/dist/worker.d.ts +10 -0
- package/package.json +1 -1
- package/src/attach-secret-keyfile.ts +185 -0
- package/src/attach-secret-options.ts +418 -0
- package/src/catalog/attach-option.ts +6 -0
- package/src/catalog/column-metadata.ts +7 -0
- package/src/catalog/composite.ts +5 -0
- package/src/catalog/descriptors.ts +11 -0
- package/src/catalog/interface.ts +97 -2
- package/src/catalog/read-only.ts +14 -1
- package/src/catalog/scan-planning.ts +314 -0
- package/src/generated/vgi-client.ts +2 -1
- package/src/generated/vgi-protocol-schemas.ts +6 -2
- package/src/generated/vgi-service.ts +7 -2
- package/src/index.core.ts +21 -0
- package/src/protocol/dispatch.ts +16 -4
- package/src/protocol/handlers/catalog/admin.ts +33 -18
- package/src/protocol/handlers/catalog/index.ts +6 -5
- package/src/protocol/handlers/catalog/index_methods.ts +5 -3
- package/src/protocol/handlers/catalog/macro.ts +7 -5
- package/src/protocol/handlers/catalog/shared.ts +52 -6
- package/src/protocol/handlers/catalog/table.ts +43 -30
- package/src/protocol/handlers/catalog/view.ts +9 -7
- package/src/protocol/handlers/function.ts +11 -5
- package/src/protocol/handlers/table-buffering.ts +2 -1
- package/src/serve-entry.ts +6 -1
- package/src/worker-cf-entry.ts +9 -0
- package/src/worker.ts +12 -0
|
@@ -13,6 +13,17 @@ export interface ProtocolConfig {
|
|
|
13
13
|
* unsealed — OS process ownership already enforces identity there.
|
|
14
14
|
*/
|
|
15
15
|
signingKey?: Uint8Array | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Optional root key for secret ATTACH options (`AttachOptionSpec.secret`),
|
|
18
|
+
* which the framework encrypts inside `attach_opaque_data` so functions and
|
|
19
|
+
* transaction hooks can read them with `attachOptions()`. Defaults to the
|
|
20
|
+
* signing key when there is one (HTTP), else the host-local key file
|
|
21
|
+
* (`$VGI_ATTACH_SECRET_KEY_FILE`, or `vgi/attach-secret-options.key` under
|
|
22
|
+
* `$XDG_RUNTIME_DIR` / the per-user temp dir). Any length; the AEAD key is
|
|
23
|
+
* always derived from it with HKDF-SHA256. Every worker process that may
|
|
24
|
+
* receive a given attach must use the same key.
|
|
25
|
+
*/
|
|
26
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
16
27
|
}
|
|
17
28
|
/**
|
|
18
29
|
* Wire name of the VGI protocol: the `vgi_rpc.protocol` routing key and the
|
|
@@ -50,11 +61,11 @@ export { VGI_PROTOCOL_NAME };
|
|
|
50
61
|
* hash covers method names, types and the params/result/header schemas only
|
|
51
62
|
* (WIRE_PROTOCOL.md §14).
|
|
52
63
|
*
|
|
53
|
-
* It changes only with vgi.v3's protocol version (currently 3.
|
|
64
|
+
* It changes only with vgi.v3's protocol version (currently 3.2.0). Asserted
|
|
54
65
|
* by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
|
|
55
66
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
56
67
|
*/
|
|
57
|
-
export declare const VGI_V3_PROTOCOL_HASH = "
|
|
68
|
+
export declare const VGI_V3_PROTOCOL_HASH = "171ac8263bf22ffdd5dd4ac2c3d3c4e1dc186a7ceba45d386f324af8c9c6fced";
|
|
58
69
|
/**
|
|
59
70
|
* This worker's `vgi.v3` implementation: the generated UNIMPLEMENTED default
|
|
60
71
|
* for every method, overridden by the handler groups for what this SDK serves.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function catalogAdminHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
3
|
+
export declare function catalogAdminHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
2
2
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
3
3
|
/** The catalog_* `vgi.v3` handlers, over *catalog* (or `NoCatalogError` without one). */
|
|
4
|
-
export declare function catalogHandlers(catalog: CatalogInterface | undefined, signingKey?: Uint8Array): Partial<VgiService>;
|
|
4
|
+
export declare function catalogHandlers(catalog: CatalogInterface | undefined, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function catalogIndexHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
3
|
+
export declare function catalogIndexHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function catalogMacroHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
3
|
+
export declare function catalogMacroHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import type { AuthContext, CallContext } from "@query-farm/vgi-rpc";
|
|
2
2
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* The keys a catalog handler group opens opaque values with: the HTTP signing
|
|
5
|
+
* key (absent on stdio / unix) and the optional explicit root key for secret
|
|
6
|
+
* ATTACH options (`attachSecretKey`; see ../../../attach-secret-options.ts).
|
|
7
|
+
*/
|
|
8
|
+
export interface OpaqueKeys {
|
|
9
|
+
signingKey?: Uint8Array | undefined;
|
|
10
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The options a catalog_attach packs into the attach value after the catalog's
|
|
14
|
+
* own bytes (secret ones encrypted). See ../../../attach-secret-options.ts.
|
|
15
|
+
*/
|
|
16
|
+
export interface AttachOptionsToPack {
|
|
17
|
+
/** The request's `options` IPC batch (null / empty: no options, no trailer). */
|
|
18
|
+
optionsIpc: Uint8Array | null | undefined;
|
|
19
|
+
/** Lower-cased names of the options declared `secret: true`. */
|
|
20
|
+
secretNames: ReadonlySet<string>;
|
|
21
|
+
/** Explicit root key for the secret options, if configured. */
|
|
22
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
23
|
+
}
|
|
3
24
|
export type GetCatalog = () => CatalogInterface;
|
|
4
25
|
/**
|
|
5
26
|
* Mint and seal a catalog_attach value: prepend a fresh framework UUID
|
|
@@ -7,8 +28,12 @@ export type GetCatalog = () => CatalogInterface;
|
|
|
7
28
|
* across re-seals and globally unique, unlike the random-nonce ciphertext or
|
|
8
29
|
* the (possibly non-unique) catalog bytes. openAttach strips the UUID back off
|
|
9
30
|
* so the catalog only ever sees its own bytes. Mirrors vgi-python/-go.
|
|
31
|
+
*
|
|
32
|
+
* With `options`, the attach's ATTACH options are packed after the catalog's
|
|
33
|
+
* bytes (secret ones encrypted, never plaintext) so `attachOptions()` can hand
|
|
34
|
+
* them to every function call and transaction hook of this attach.
|
|
10
35
|
*/
|
|
11
|
-
export declare function sealAttach(plaintext: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined): Promise<Uint8Array>;
|
|
36
|
+
export declare function sealAttach(plaintext: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined, options?: AttachOptionsToPack): Promise<Uint8Array>;
|
|
12
37
|
/**
|
|
13
38
|
* Open an attach envelope returning the FULL framework plaintext
|
|
14
39
|
* uuid(16) || catalog_bytes (not stripped). Storage shards on the leading UUID.
|
|
@@ -19,7 +44,7 @@ export declare function openAttachFull(envelope: Uint8Array, auth: AuthContext |
|
|
|
19
44
|
* framework UUID prefix is stripped. This is what catalog/function bodies see;
|
|
20
45
|
* storage routing uses openAttachFull / deriveShardKey to reach the UUID.
|
|
21
46
|
*/
|
|
22
|
-
export declare function openAttach(envelope: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined): Promise<Uint8Array>;
|
|
47
|
+
export declare function openAttach(envelope: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined, attachSecretKey?: Uint8Array): Promise<Uint8Array>;
|
|
23
48
|
/**
|
|
24
49
|
* deriveShardKey returns the Cloudflare-DO routing key for an attach:
|
|
25
50
|
* "att-" + hex(the 16-byte framework UUID at the head of the unwrapped attach).
|
|
@@ -52,7 +77,7 @@ export declare function openTransaction(envelope: Uint8Array, attachEnvelope: Ui
|
|
|
52
77
|
* / catalog_transaction_begin, which seal their outputs and are written
|
|
53
78
|
* bespoke. The body sees the flattened params as a plain record.
|
|
54
79
|
*/
|
|
55
|
-
export declare function catalogHandler<R>(
|
|
80
|
+
export declare function catalogHandler<R>(keysOrSigningKey: OpaqueKeys | Uint8Array | undefined, handler: (params: Record<string, any>, ctx: CallContext) => R | Promise<R>): (params: object, ctx: CallContext) => Promise<R>;
|
|
56
81
|
export declare function makeGetCatalog(catalog: CatalogInterface | undefined): GetCatalog;
|
|
57
82
|
/**
|
|
58
83
|
* Decode the `options` field of a catalog_attach request into a plain
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
3
|
+
export declare function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
3
|
+
export declare function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -3,6 +3,8 @@ import type { FunctionRegistry } from "../../functions/registry.js";
|
|
|
3
3
|
export interface FunctionHandlerConfig {
|
|
4
4
|
registry: FunctionRegistry;
|
|
5
5
|
signingKey?: Uint8Array | undefined;
|
|
6
|
+
/** Explicit root key for secret ATTACH options (see attach-secret-options.ts). */
|
|
7
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
6
8
|
/**
|
|
7
9
|
* Used to map a bind's `attach_opaque_data` to its catalog, so resolution can
|
|
8
10
|
* be scoped when two catalogs declare the same schema and function name.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { VgiService } from "../../generated/vgi-service.js";
|
|
2
2
|
import type { FunctionRegistry } from "../../functions/registry.js";
|
|
3
3
|
/** The table_buffering lifecycle's `vgi.v3` handlers. */
|
|
4
|
-
export declare function tableBufferingHandlers(registry: FunctionRegistry, signingKey?: Uint8Array): Partial<VgiService>;
|
|
4
|
+
export declare function tableBufferingHandlers(registry: FunctionRegistry, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService>;
|
package/dist/serve-entry.d.ts
CHANGED
|
@@ -54,6 +54,11 @@ export interface ServeVgiWorkerOptions extends HostingOptions {
|
|
|
54
54
|
hostname?: string | undefined;
|
|
55
55
|
/** Overrides `$VGI_SIGNING_KEY`. 32 bytes. */
|
|
56
56
|
signingKey?: Uint8Array | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Optional root key for secret ATTACH options (encrypted inside
|
|
59
|
+
* `attach_opaque_data` for `attachOptions()`). Defaults to the signing key.
|
|
60
|
+
*/
|
|
61
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
57
62
|
/** Overrides `$VGI_TOKEN_TTL` (default 3600 seconds). */
|
|
58
63
|
tokenTtl?: number | undefined;
|
|
59
64
|
/** Overrides `$CORS_ORIGINS` (default "*"). Pass `null` to disable CORS. */
|