@query-farm/vgi-rpc 0.6.3 → 0.7.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.
Files changed (160) hide show
  1. package/dist/access-log.d.ts +50 -0
  2. package/dist/access-log.d.ts.map +1 -0
  3. package/dist/arrow/impl-arrowjs/index.d.ts +96 -0
  4. package/dist/arrow/impl-arrowjs/index.d.ts.map +1 -0
  5. package/dist/arrow/impl-flechette/index.d.ts +102 -0
  6. package/dist/arrow/impl-flechette/index.d.ts.map +1 -0
  7. package/dist/arrow/impl-flechette/message-meta.d.ts +11 -0
  8. package/dist/arrow/impl-flechette/message-meta.d.ts.map +1 -0
  9. package/dist/arrow/index.d.ts +4 -0
  10. package/dist/arrow/index.d.ts.map +1 -0
  11. package/dist/arrow/predicates.d.ts +44 -0
  12. package/dist/arrow/predicates.d.ts.map +1 -0
  13. package/dist/arrow/types.d.ts +62 -0
  14. package/dist/arrow/types.d.ts.map +1 -0
  15. package/dist/client/capabilities.d.ts +25 -0
  16. package/dist/client/capabilities.d.ts.map +1 -0
  17. package/dist/client/connect.d.ts.map +1 -1
  18. package/dist/client/introspect.d.ts +7 -0
  19. package/dist/client/introspect.d.ts.map +1 -1
  20. package/dist/client/ipc.d.ts +8 -2
  21. package/dist/client/ipc.d.ts.map +1 -1
  22. package/dist/client/pipe.d.ts.map +1 -1
  23. package/dist/client/stream.d.ts +11 -2
  24. package/dist/client/stream.d.ts.map +1 -1
  25. package/dist/client/uploadUrl.d.ts +25 -0
  26. package/dist/client/uploadUrl.d.ts.map +1 -0
  27. package/dist/constants.d.ts +15 -1
  28. package/dist/constants.d.ts.map +1 -1
  29. package/dist/crypto.d.ts +22 -0
  30. package/dist/crypto.d.ts.map +1 -0
  31. package/dist/dispatch/describe.d.ts +10 -6
  32. package/dist/dispatch/describe.d.ts.map +1 -1
  33. package/dist/dispatch/stream.d.ts +2 -2
  34. package/dist/dispatch/stream.d.ts.map +1 -1
  35. package/dist/dispatch/unary.d.ts +2 -2
  36. package/dist/dispatch/unary.d.ts.map +1 -1
  37. package/dist/errors.d.ts +46 -0
  38. package/dist/errors.d.ts.map +1 -1
  39. package/dist/external.d.ts +25 -5
  40. package/dist/external.d.ts.map +1 -1
  41. package/dist/http/bearer.d.ts.map +1 -1
  42. package/dist/http/common.d.ts +42 -7
  43. package/dist/http/common.d.ts.map +1 -1
  44. package/dist/http/dispatch.d.ts +20 -2
  45. package/dist/http/dispatch.d.ts.map +1 -1
  46. package/dist/http/handler.d.ts.map +1 -1
  47. package/dist/http/index.d.ts +1 -0
  48. package/dist/http/index.d.ts.map +1 -1
  49. package/dist/http/mtls.d.ts +2 -1
  50. package/dist/http/mtls.d.ts.map +1 -1
  51. package/dist/http/oauth-pkce.d.ts +141 -0
  52. package/dist/http/oauth-pkce.d.ts.map +1 -0
  53. package/dist/http/pages.d.ts +3 -0
  54. package/dist/http/pages.d.ts.map +1 -1
  55. package/dist/http/sticky.d.ts +124 -0
  56. package/dist/http/sticky.d.ts.map +1 -0
  57. package/dist/http/token.d.ts +38 -12
  58. package/dist/http/token.d.ts.map +1 -1
  59. package/dist/http/types.d.ts +68 -5
  60. package/dist/http/types.d.ts.map +1 -1
  61. package/dist/index.d.ts +6 -4
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1275 -3507
  64. package/dist/index.js.map +19 -37
  65. package/dist/launcher/hash.d.ts +22 -0
  66. package/dist/launcher/hash.d.ts.map +1 -0
  67. package/dist/launcher/index.d.ts +23 -0
  68. package/dist/launcher/index.d.ts.map +1 -0
  69. package/dist/launcher/launch.d.ts +27 -0
  70. package/dist/launcher/launch.d.ts.map +1 -0
  71. package/dist/launcher/lock.d.ts +19 -0
  72. package/dist/launcher/lock.d.ts.map +1 -0
  73. package/dist/launcher/serve-unix.d.ts +54 -0
  74. package/dist/launcher/serve-unix.d.ts.map +1 -0
  75. package/dist/launcher/state.d.ts +59 -0
  76. package/dist/launcher/state.d.ts.map +1 -0
  77. package/dist/otel.d.ts.map +1 -1
  78. package/dist/protocol.d.ts +16 -2
  79. package/dist/protocol.d.ts.map +1 -1
  80. package/dist/schema.d.ts +45 -18
  81. package/dist/schema.d.ts.map +1 -1
  82. package/dist/server.d.ts +23 -2
  83. package/dist/server.d.ts.map +1 -1
  84. package/dist/types.d.ts +216 -12
  85. package/dist/types.d.ts.map +1 -1
  86. package/dist/util/gzip.d.ts +10 -0
  87. package/dist/util/gzip.d.ts.map +1 -0
  88. package/dist/util/schema.d.ts +3 -15
  89. package/dist/util/schema.d.ts.map +1 -1
  90. package/dist/util/web-crypto.d.ts +22 -0
  91. package/dist/util/web-crypto.d.ts.map +1 -0
  92. package/dist/util/zstd.d.ts +26 -3
  93. package/dist/util/zstd.d.ts.map +1 -1
  94. package/dist/wire/opaque.d.ts +11 -0
  95. package/dist/wire/opaque.d.ts.map +1 -0
  96. package/dist/wire/reader.d.ts +5 -5
  97. package/dist/wire/reader.d.ts.map +1 -1
  98. package/dist/wire/request.d.ts +11 -3
  99. package/dist/wire/request.d.ts.map +1 -1
  100. package/dist/wire/response.d.ts +6 -6
  101. package/dist/wire/response.d.ts.map +1 -1
  102. package/dist/wire/writer.d.ts +49 -39
  103. package/dist/wire/writer.d.ts.map +1 -1
  104. package/package.json +24 -10
  105. package/src/access-log.ts +195 -0
  106. package/src/arrow/impl-arrowjs/index.ts +433 -0
  107. package/src/arrow/impl-flechette/index.ts +414 -0
  108. package/src/arrow/impl-flechette/message-meta.ts +174 -0
  109. package/src/arrow/index.ts +89 -0
  110. package/src/arrow/predicates.ts +56 -0
  111. package/src/arrow/types.ts +73 -0
  112. package/src/client/capabilities.ts +84 -0
  113. package/src/client/connect.ts +103 -26
  114. package/src/client/introspect.ts +60 -38
  115. package/src/client/ipc.ts +37 -27
  116. package/src/client/pipe.ts +12 -9
  117. package/src/client/stream.ts +34 -19
  118. package/src/client/uploadUrl.ts +169 -0
  119. package/src/constants.ts +18 -1
  120. package/src/crypto.ts +95 -0
  121. package/src/dispatch/describe.ts +146 -107
  122. package/src/dispatch/stream.ts +53 -24
  123. package/src/dispatch/unary.ts +5 -4
  124. package/src/errors.ts +76 -0
  125. package/src/external.ts +43 -29
  126. package/src/http/bearer.ts +2 -5
  127. package/src/http/common.ts +90 -23
  128. package/src/http/dispatch.ts +373 -46
  129. package/src/http/handler.ts +794 -68
  130. package/src/http/index.ts +1 -0
  131. package/src/http/mtls.ts +18 -3
  132. package/src/http/oauth-pkce.ts +1035 -0
  133. package/src/http/pages.ts +30 -15
  134. package/src/http/sticky.ts +429 -0
  135. package/src/http/token.ts +165 -75
  136. package/src/http/types.ts +69 -5
  137. package/src/index.ts +40 -1
  138. package/src/launcher/hash.ts +104 -0
  139. package/src/launcher/index.ts +35 -0
  140. package/src/launcher/launch.ts +284 -0
  141. package/src/launcher/lock.ts +171 -0
  142. package/src/launcher/serve-unix.ts +385 -0
  143. package/src/launcher/state.ts +245 -0
  144. package/src/otel.ts +39 -33
  145. package/src/protocol.ts +27 -3
  146. package/src/schema.ts +107 -56
  147. package/src/server.ts +196 -20
  148. package/src/types.ts +322 -18
  149. package/src/util/gzip.ts +63 -0
  150. package/src/util/schema.ts +4 -22
  151. package/src/util/web-crypto.ts +98 -0
  152. package/src/util/zstd.ts +133 -14
  153. package/src/wire/opaque.ts +37 -0
  154. package/src/wire/reader.ts +5 -4
  155. package/src/wire/request.ts +67 -8
  156. package/src/wire/response.ts +51 -85
  157. package/src/wire/writer.ts +165 -69
  158. package/dist/util/conform.d.ts +0 -18
  159. package/dist/util/conform.d.ts.map +0 -1
  160. package/src/util/conform.ts +0 -94
@@ -9,9 +9,23 @@ export declare const SERVER_ID_KEY = "vgi_rpc.server_id";
9
9
  export declare const REQUEST_ID_KEY = "vgi_rpc.request_id";
10
10
  export declare const PROTOCOL_NAME_KEY = "vgi_rpc.protocol_name";
11
11
  export declare const DESCRIBE_VERSION_KEY = "vgi_rpc.describe_version";
12
- export declare const DESCRIBE_VERSION = "3";
12
+ export declare const PROTOCOL_HASH_KEY = "vgi_rpc.protocol_hash";
13
+ export declare const DESCRIBE_VERSION = "4";
14
+ /** Application protocol surface version. Carried on every request batch from
15
+ * a client bound to a Protocol that declares `protocolVersion`; also emitted
16
+ * in the __describe__ response metadata. Format: canonical semver
17
+ * MAJOR.MINOR.PATCH. Enforced at the dispatch boundary on the server: exact
18
+ * major+minor match required, patch ignored. Distinct from `REQUEST_VERSION`
19
+ * (wire framing). Mirrors Python's `PROTOCOL_VERSION_KEY`. */
20
+ export declare const PROTOCOL_VERSION_KEY = "vgi_rpc.protocol_version";
13
21
  export declare const DESCRIBE_METHOD_NAME = "__describe__";
14
22
  export declare const STATE_KEY = "vgi_rpc.stream_state#b64";
23
+ export declare const CANCEL_KEY = "vgi_rpc.cancel";
15
24
  export declare const LOCATION_KEY = "vgi_rpc.location";
16
25
  export declare const LOCATION_SHA256_KEY = "vgi_rpc.location.sha256";
26
+ export declare const RPC_ERROR_HEADER = "X-VGI-RPC-Error";
27
+ /** Top-level metadata key on an EXCEPTION batch identifying the error category.
28
+ * Hoisted by `buildErrorBatch` when the thrown error has a static or instance
29
+ * `errorKind` property. Mirrors Python's `vgi_rpc.metadata.ERROR_KIND_KEY`. */
30
+ export declare const ERROR_KIND_KEY = "vgi_rpc.error_kind";
17
31
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,6DAA6D;AAE7D,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAC7D,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO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@link openBytes} for any envelope it cannot open — malformed,
2
+ * tampered, wrong key, wrong AAD, wrong version, truncated, all surface the
3
+ * same way so callers cannot distinguish failure modes via error content. */
4
+ export declare class SealError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /** Normalise a key to 32 bytes by SHA-256 hashing when it isn't already 32B.
8
+ * Mirrors Python's `normalize_key` so any callers can pass operator-provided
9
+ * keys of arbitrary length without a separate stretching step. */
10
+ export declare function normalizeKey(key: Uint8Array): Promise<Uint8Array>;
11
+ export interface SealOptions {
12
+ /** Associated data bound at the crypto layer — typically a principal or
13
+ * request-scoped identifier. Must match between seal and open. */
14
+ aad: Uint8Array;
15
+ /** Envelope version byte. Defaults to 1; carry through to {@link openBytes}. */
16
+ version?: number;
17
+ }
18
+ /** Seal `plaintext` under `key` with AEAD, returning the wire envelope. */
19
+ export declare function sealBytes(plaintext: Uint8Array, key: Uint8Array, opts: SealOptions): Uint8Array;
20
+ /** Open and verify an envelope produced by {@link sealBytes}. */
21
+ export declare function openBytes(envelope: Uint8Array, key: Uint8Array, opts: SealOptions): Uint8Array;
22
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AA8BA;;8EAE8E;AAC9E,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED;;mEAEmE;AACnE,wBAAsB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAIvE;AAED,MAAM,WAAW,WAAW;IAC1B;uEACmE;IACnE,GAAG,EAAE,UAAU,CAAC;IAChB,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAe/F;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAkB9F"}
@@ -1,14 +1,18 @@
1
- import { RecordBatch, Schema } from "@query-farm/apache-arrow";
1
+ import { type VgiBatch } from "../arrow/index.js";
2
2
  import type { MethodDefinition } from "../types.js";
3
3
  /**
4
- * The schema for the __describe__ response, matching Python's _DESCRIBE_SCHEMA.
4
+ * Slim DESCRIBE_VERSION 4 schema. Python-flavoured fields (doc,
5
+ * param_types_json, param_defaults_json, param_docs_json) are not on the
6
+ * wire — Arrow IPC schema bytes are the authoritative type information;
7
+ * everything else is source-level metadata that callers should consult the
8
+ * Protocol class for.
5
9
  */
6
- export declare const DESCRIBE_SCHEMA: Schema<any>;
10
+ export declare const DESCRIBE_SCHEMA: import("../arrow/types.js").VgiSchema;
7
11
  /**
8
12
  * Build the __describe__ response batch and metadata.
9
13
  */
10
- export declare function buildDescribeBatch(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string): {
11
- batch: RecordBatch;
14
+ export declare function buildDescribeBatch(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string, protocolVersion?: string): Promise<{
15
+ batch: VgiBatch;
12
16
  metadata: Map<string, string>;
13
- };
17
+ }>;
14
18
  //# sourceMappingURL=describe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/dispatch/describe.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,WAAW,EACX,MAAM,EAIP,MAAM,0BAA0B,CAAC;AASlC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,eAAe,aAa1B,CAAC;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAgHvD"}
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/dispatch/describe.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAW3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,uCAS1B,CAAC;AAkEH;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAoF7D"}
@@ -1,5 +1,5 @@
1
1
  import { type ExternalLocationConfig } from "../external.js";
2
- import type { MethodDefinition } from "../types.js";
2
+ import type { MethodDefinition, TransportKind } from "../types.js";
3
3
  import type { IpcStreamReader } from "../wire/reader.js";
4
4
  import type { IpcStreamWriter } from "../wire/writer.js";
5
5
  /**
@@ -17,5 +17,5 @@ import type { IpcStreamWriter } from "../wire/writer.js";
17
17
  * - Server writes output batch(es) for each input
18
18
  * - Stream ends when client closes input (EOS)
19
19
  */
20
- export declare function dispatchStream(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, reader: IpcStreamReader, serverId: string, requestId: string | null, externalConfig?: ExternalLocationConfig): Promise<void>;
20
+ export declare function dispatchStream(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, reader: IpcStreamReader, serverId: string, requestId: string | null, externalConfig?: ExternalLocationConfig, kind?: TransportKind): Promise<void>;
21
21
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/dispatch/stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,sBAAsB,GACtC,OAAO,CAAC,IAAI,CAAC,CA8Hf"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/dispatch/stream.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,sBAAsB,EACvC,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,IAAI,CAAC,CA0Jf"}
@@ -1,10 +1,10 @@
1
1
  import { type ExternalLocationConfig } from "../external.js";
2
- import type { MethodDefinition } from "../types.js";
2
+ import type { MethodDefinition, TransportKind } from "../types.js";
3
3
  import type { IpcStreamWriter } from "../wire/writer.js";
4
4
  /**
5
5
  * Dispatch a unary RPC call.
6
6
  * Calls the handler with parsed params, writes result or error batch.
7
7
  * Supports client-directed logging via ctx.clientLog().
8
8
  */
9
- export declare function dispatchUnary(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, serverId: string, requestId: string | null, externalConfig?: ExternalLocationConfig): Promise<void>;
9
+ export declare function dispatchUnary(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, serverId: string, requestId: string | null, externalConfig?: ExternalLocationConfig, kind?: TransportKind): Promise<void>;
10
10
  //# sourceMappingURL=unary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../../src/dispatch/unary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,sBAAsB,GACtC,OAAO,CAAC,IAAI,CAAC,CAiBf"}
1
+ {"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../../src/dispatch/unary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,sBAAsB,EACvC,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
package/dist/errors.d.ts CHANGED
@@ -9,4 +9,50 @@ export declare class RpcError extends Error {
9
9
  export declare class VersionError extends Error {
10
10
  constructor(message: string);
11
11
  }
12
+ /** Well-known values for the `vgi_rpc.error_kind` batch metadata key. Mirrors
13
+ * Python's `vgi_rpc.metadata.ERROR_KIND_*` constants. */
14
+ export declare const ERROR_KIND_METHOD_NOT_IMPLEMENTED = "method_not_implemented";
15
+ export declare const ERROR_KIND_SESSION_LOST = "session_lost";
16
+ export declare const ERROR_KIND_SERVER_DRAINING = "server_draining";
17
+ export declare const ERROR_KIND_PROTOCOL_VERSION_MISMATCH = "protocol_version_mismatch";
18
+ /** Raised when the client's declared `vgi_rpc.protocol_version` is
19
+ * incompatible with the server's. Subclass of `VersionError` so existing
20
+ * catch sites continue to write a typed error stream and keep serving.
21
+ * Carries a directional message that tells the reader which side to
22
+ * upgrade. Mirrors Python's `vgi_rpc.rpc.ProtocolVersionError`. */
23
+ export declare class ProtocolVersionError extends VersionError {
24
+ static readonly errorKind = "protocol_version_mismatch";
25
+ readonly errorKind = "protocol_version_mismatch";
26
+ constructor(message: string);
27
+ }
28
+ /** Parse a canonical semver string into `[major, minor, patch]`. Throws on
29
+ * any input that isn't `MAJOR.MINOR.PATCH` with non-negative integers and
30
+ * no leading zeros (except literal `0`). No prereleases, no build metadata.
31
+ * Mirrors Python's `vgi_rpc.metadata.parse_version`. */
32
+ export declare function parseProtocolVersion(value: string): [number, number, number];
33
+ /** Raised when a client invokes a method the server does not implement.
34
+ *
35
+ * Mirrors Python's `vgi_rpc.rpc.MethodNotImplementedError`. The static
36
+ * `errorKind` is hoisted onto the error batch metadata as
37
+ * `vgi_rpc.error_kind` so clients can branch on the typed marker without
38
+ * string-matching the message.
39
+ */
40
+ export declare class MethodNotImplementedError extends Error {
41
+ static readonly errorKind = "method_not_implemented";
42
+ readonly errorKind = "method_not_implemented";
43
+ constructor(message: string);
44
+ }
45
+ /** Raised when a sticky session token is malformed, expired, evicted, or
46
+ * bound to a different worker / principal. HTTP-only. */
47
+ export declare class SessionLostError extends Error {
48
+ static readonly errorKind = "session_lost";
49
+ readonly errorKind = "session_lost";
50
+ constructor(message: string);
51
+ }
52
+ /** Raised when `ctx.openSession` is called while the server is draining. */
53
+ export declare class ServerDrainingError extends Error {
54
+ static readonly errorKind = "server_draining";
55
+ readonly errorKind = "server_draining";
56
+ constructor(message: string);
57
+ }
12
58
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,qBAAa,QAAS,SAAQ,KAAK;aAEf,SAAS,EAAE,MAAM;aACjB,YAAY,EAAE,MAAM;aACpB,eAAe,EAAE,MAAM;gBAFvB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM;CAK1C;AAED,yEAAyE;AACzE,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,qBAAa,QAAS,SAAQ,KAAK;aAEf,SAAS,EA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7
  * download URL and SHA-256 checksum in metadata.
8
8
  */
9
- import { type RecordBatch, type Schema } from "@query-farm/apache-arrow";
9
+ import { type VgiBatch, type VgiSchema } from "./arrow/index.js";
10
10
  /** Pluggable storage backend for uploading large batches. */
11
11
  export interface ExternalStorage {
12
12
  /** Upload IPC data and return a URL for retrieval. */
13
13
  upload(data: Uint8Array, contentEncoding: string): Promise<string>;
14
14
  }
15
+ /** A pre-signed PUT/GET URL pair for client-side data upload. */
16
+ export interface UploadUrl {
17
+ /** Pre-signed PUT URL the client uploads to. */
18
+ uploadUrl: string;
19
+ /** Pre-signed GET URL the server fetches from. */
20
+ downloadUrl: string;
21
+ /** Expiration time (UTC) for the URL pair. */
22
+ expiresAt: Date;
23
+ }
24
+ /**
25
+ * Generates pre-signed upload URL pairs for client-vended externalization.
26
+ *
27
+ * Implementations must be safe to call from multiple concurrent requests.
28
+ * Object lifecycle is the operator's responsibility — uploaded objects are
29
+ * not automatically deleted by vgi-rpc.
30
+ */
31
+ export interface UploadUrlProvider {
32
+ /** Allocate one upload/download URL pair. */
33
+ generateUploadUrl(): Promise<UploadUrl> | UploadUrl;
34
+ }
15
35
  /** Configuration for external storage of large batches. */
16
36
  export interface ExternalLocationConfig {
17
37
  /** Storage backend for uploading. */
@@ -29,17 +49,17 @@ export interface ExternalLocationConfig {
29
49
  /** Default validator that rejects non-HTTPS URLs. */
30
50
  export declare function httpsOnlyValidator(url: string): void;
31
51
  /** Returns true if the batch is a zero-row pointer to external data. */
32
- export declare function isExternalLocationBatch(batch: RecordBatch): boolean;
52
+ export declare function isExternalLocationBatch(batch: VgiBatch): boolean;
33
53
  /** Create a zero-row pointer batch with location URL and optional SHA-256. */
34
- export declare function makeExternalLocationBatch(schema: Schema, url: string, sha256?: string): RecordBatch;
54
+ export declare function makeExternalLocationBatch(schema: VgiSchema, url: string, sha256?: string): VgiBatch;
35
55
  /**
36
56
  * Maybe externalize a batch if it exceeds the threshold.
37
57
  * Returns the original batch unchanged if below threshold or no config.
38
58
  */
39
- export declare function maybeExternalizeBatch(batch: RecordBatch, config?: ExternalLocationConfig | null): Promise<RecordBatch>;
59
+ export declare function maybeExternalizeBatch(batch: VgiBatch, config?: ExternalLocationConfig | null): Promise<VgiBatch>;
40
60
  /**
41
61
  * Resolve an external pointer batch by fetching the data from the URL.
42
62
  * Returns the original batch unchanged if not a pointer or no config.
43
63
  */
44
- export declare function resolveExternalLocation(batch: RecordBatch, config?: ExternalLocationConfig | null): Promise<RecordBatch>;
64
+ export declare function resolveExternalLocation(batch: VgiBatch, config?: ExternalLocationConfig | null): Promise<VgiBatch>;
45
65
  //# sourceMappingURL=external.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,WAAW,EAA8C,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AASrH,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE;AAED,2DAA2D;AAC3D,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,OAAO,EAAE,eAAe,CAAC;IACzB,wEAAwE;IACxE,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,mDAAmD;IACnD,WAAW,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,kFAAkF;IAClF,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/C;AAQD,qDAAqD;AACrD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKpD;AAoBD,wEAAwE;AACxE,wBAAgB,uBAAuB,CAAC,KAAK,EA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,CAW1F;AAWD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACxE,GAAG,cAAc,CAYjB;AAgBD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,cAAc,EAAE,cAAc,EAAE,GAAG,cAAc,CAsBrF"}
1
+ {"version":3,"file":"bearer.d.ts","sourceRoot":"","sources":["../../src/http/bearer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,sGAAsG;AACtG,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,gBAAgB,CAAA;CAAE,GAAG,cAAc,CAW1F;AAQD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACxE,GAAG,cAAc,CAYjB;AAgBD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,cAAc,EAAE,cAAc,EAAE,GAAG,cAAc,CAsBrF"}
@@ -1,16 +1,51 @@
1
- import { type RecordBatch, type Schema } from "@query-farm/apache-arrow";
1
+ import { type VgiBatch, type VgiSchema } from "../arrow/index.js";
2
+ import type { CookieSpec } from "../types.js";
2
3
  export declare const ARROW_CONTENT_TYPE = "application/vnd.apache.arrow.stream";
4
+ export declare const SESSION_HEADER = "VGI-Session";
5
+ export declare const SESSION_ACCEPT_HEADER = "VGI-Session-Accept";
6
+ export declare const SESSION_CLOSE_HEADER = "VGI-Session-Close";
7
+ export declare const STICKY_ENABLED_HEADER = "VGI-Sticky-Enabled";
8
+ export declare const STICKY_DEFAULT_TTL_HEADER = "VGI-Sticky-Default-TTL";
9
+ export declare const STICKY_ECHO_HEADERS_HEADER = "VGI-Sticky-Echo-Headers";
10
+ /** Prefix the server uses to tell the client "echo this header on subsequent
11
+ * requests in this session". Clients capture and replay
12
+ * `VGI-Echo-<name>: <value>` as plain `<name>: <value>` for the session
13
+ * lifetime — used for client-driven routing (e.g. `fly-force-instance-id`). */
14
+ export declare const ECHO_HEADER_PREFIX = "VGI-Echo-";
15
+ /** Framework-managed sticky session teardown endpoint path component.
16
+ * `DELETE {prefix}/__session__` idempotently closes the session referenced
17
+ * by the request's `VGI-Session` header. */
18
+ export declare const SESSION_ENDPOINT = "__session__";
19
+ /** Serialize a CookieSpec into a Set-Cookie header value. */
20
+ export declare function formatSetCookieHeader(c: CookieSpec): string;
21
+ /** Append Set-Cookie headers for each queued CookieSpec onto an existing Headers object. */
22
+ export declare function appendCookieHeaders(headers: Headers, cookies: readonly CookieSpec[]): void;
3
23
  export declare class HttpRpcError extends Error {
4
24
  readonly statusCode: number;
5
25
  constructor(message: string, statusCode: number);
6
26
  }
7
- /** Serialize a schema + batches into a complete IPC stream as Uint8Array. */
8
- export declare function serializeIpcStream(schema: Schema, batches: RecordBatch[]): Uint8Array;
9
- /** Create a Response with Arrow IPC content type. Casts Uint8Array for TS lib compat. */
27
+ /**
28
+ * Serialize a schema + batches into a complete IPC stream as Uint8Array.
29
+ *
30
+ * A single IPC stream is `[schema_msg, batch_msg, batch_msg, ..., EOS]`.
31
+ * Each backend implements `serializeBatches` to write that atomically —
32
+ * arrow-js via `RecordBatchStreamWriter`, flechette via `tablesToIPC`
33
+ * (added in our flechette fork). Naive concatenation of per-batch streams
34
+ * produces multiple EOS markers and breaks readers.
35
+ */
36
+ export declare function serializeIpcStream(schema: VgiSchema, batches: VgiBatch[]): Uint8Array;
37
+ /**
38
+ * Create a Response with Arrow IPC content type.
39
+ *
40
+ * Server errors (status 500) are translated to HTTP 200 with an
41
+ * ``X-VGI-RPC-Error: true`` header so that clients which discard
42
+ * response bodies on 5xx still receive the Arrow IPC error metadata.
43
+ * Client errors (400, 401, 404, 415) are passed through unchanged.
44
+ */
10
45
  export declare function arrowResponse(body: Uint8Array, status?: number, extraHeaders?: Headers): Response;
11
- /** Read schema + first batch from an IPC stream body. */
46
+ /** Read schema + first batch from an IPC stream body via the facade. */
12
47
  export declare function readRequestFromBody(body: Uint8Array): Promise<{
13
- schema: Schema;
14
- batch: RecordBatch;
48
+ schema: VgiSchema;
49
+ batch: VgiBatch;
15
50
  }>;
16
51
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/http/common.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAA8C,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGrH,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AAExE,qBAAa,YAAa,SAAQ,KAAK;aAGnB,UAAU,EAAE,MAAM;gBADlC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM;CAKrC;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,CAQrF;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,SAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAI9F;AAED,yDAAyD;AACzD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CAY3G"}
1
+ {"version":3,"file":"common.d.ts","sourceR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S,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC,CAU3G"}
@@ -1,18 +1,36 @@
1
1
  import type { AuthContext } from "../auth.js";
2
2
  import { type ExternalLocationConfig } from "../external.js";
3
3
  import type { MethodDefinition } from "../types.js";
4
+ import { TransportKind } from "../types.js";
4
5
  import type { StateSerializer } from "./types.js";
5
6
  export interface DispatchContext {
6
- signingKey: Uint8Array;
7
+ tokenKey: Uint8Array;
7
8
  tokenTtl: number;
8
9
  serverId: string;
10
+ /** Producer-only soft wire-cap (deprecated alias for the producer-loop
11
+ * byte budget). Unary/exchange ignore this. */
9
12
  maxStreamResponseBytes?: number;
13
+ /** Soft wire-cap for producer streams; hard wire-cap for unary/exchange.
14
+ * Externalised payloads do not count toward this. */
15
+ maxResponseBytes?: number;
16
+ /** Hard cap on bytes uploaded to external storage during one HTTP response. */
17
+ maxExternalizedResponseBytes?: number;
10
18
  stateSerializer: StateSerializer;
11
19
  authContext?: AuthContext;
12
20
  externalLocation?: ExternalLocationConfig;
21
+ /** Incoming HTTP request cookies. Empty/absent on non-HTTP paths. */
22
+ cookies?: ReadonlyMap<string, string>;
23
+ /** Transport identifier surfaced to handlers via CallContext.kind.
24
+ * Defaults to HTTP when unset (the only caller that overrides it is
25
+ * the AF_UNIX launcher path). */
26
+ kind?: TransportKind;
27
+ /** Per-request sticky-session sink. Installed by the handler when sticky
28
+ * is enabled and the dispatcher attaches it to the OutputCollector so
29
+ * `ctx.session` / `ctx.openSession` / `ctx.closeSession` work. */
30
+ stickyContext?: import("../types.js").StickyContext;
13
31
  }
14
32
  /** Dispatch a __describe__ request. */
15
- export declare function httpDispatchDescribe(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string): Response;
33
+ export declare function httpDispatchDescribe(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string, protocolVersion?: string): Promise<Response>;
16
34
  /** Dispatch a unary HTTP request. */
17
35
  export declare function httpDispatchUnary(method: MethodDefinition, body: Uint8Array, ctx: DispatchContext): Promise<Response>;
18
36
  /** Dispatch a stream init HTTP request (producer or exchange). */
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/http/dispatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUlD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAED,uCAAuC;AACvC,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,QAAQ,EAAE,MAAM,GACf,QAAQ,CAIV;AAED,qCAAqC;AACrC,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CA0BnB;AAED,kEAAkE;AAClE,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CA2EnB;AAED,yFAAyF;AACzF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC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,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CA+FnB;AAED,kEAAkE;AAClE,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CAmGnB;AAED,yFAAyF;AACzF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CAqMnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAa/C,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AAI1E;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkSpD"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoD/C,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AAwB1E;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAo7BpD"}
@@ -8,6 +8,7 @@ export type { JwtAuthenticateOptions } from "./jwt.js";
8
8
  export { jwtAuthenticate } from "./jwt.js";
9
9
  export type { CertValidateFn, XfccElement, XfccValidateFn } from "./mtls.js";
10
10
  export { mtlsAuthenticate, mtlsAuthenticateFingerprint, mtlsAuthenticateSubject, mtlsAuthenticateXfcc, parseXfcc, } from "./mtls.js";
11
+ export { cookieAuthenticate } from "./oauth-pkce.js";
11
12
  export { type UnpackedToken, unpackStateToken } from "./token.js";
12
13
  export type { HttpHandlerOptions, StateSerializer } from "./types.js";
13
14
  export { jsonStateSerializer } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
- import { X509Certificate } from "node:crypto";
2
1
  import { AuthContext } from "../auth.js";
3
2
  import type { AuthenticateFn } from "./auth.js";
3
+ type X509Certificate = any;
4
4
  /** A single element from an `x-forwarded-client-cert` header. */
5
5
  export interface XfccElement {
6
6
  hash: string | null;
@@ -75,4 +75,5 @@ export declare function mtlsAuthenticateSubject(options?: {
75
75
  allowedSubjects?: ReadonlySet<string> | null;
76
76
  checkExpiry?: boolean;
77
77
  }): AuthenticateFn;
78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AE,OAAO,CAAC;CACvB,GAAG,cAAc,CAkCjB"}
@@ -0,0 +1,141 @@
1
+ import type { AuthenticateFn } from "./auth.js";
2
+ /** Generate a 43-character URL-safe random code verifier (RFC 7636 S4.1). */
3
+ export declare function generateCodeVerifier(): string;
4
+ /** Compute S256 code challenge from a code verifier (RFC 7636 S4.2). */
5
+ export declare function generateCodeChallenge(verifier: string): string;
6
+ /** Generate a random state nonce for CSRF protection. */
7
+ export declare function generateStateNonce(): string;
8
+ /** Derive a separate HMAC key for OAuth session cookies. */
9
+ export declare function deriveSessionKey(signingKey: Uint8Array): Uint8Array;
10
+ /**
11
+ * Pack PKCE session data into a signed, base64-encoded cookie value.
12
+ *
13
+ * Wire format v4:
14
+ * [1B version=4] [8B created_at uint64 LE]
15
+ * [2B cv_len uint16 LE] [cv_len bytes code_verifier]
16
+ * [2B state_len uint16 LE] [state_len bytes state_nonce]
17
+ * [2B url_len uint16 LE] [url_len bytes original_url]
18
+ * [2B rt_len uint16 LE] [rt_len bytes return_to]
19
+ * [32B HMAC-SHA256(session_key, all above)]
20
+ */
21
+ export declare function packOAuthCookie(codeVerifier: string, stateNonce: string, originalUrl: string, sessionKey: Uint8Array, createdAt?: number, returnTo?: string): string;
22
+ export interface UnpackedOAuthCookie {
23
+ codeVerifier: string;
24
+ stateNonce: string;
25
+ originalUrl: string;
26
+ returnTo: string;
27
+ }
28
+ /**
29
+ * Unpack and verify a signed OAuth session cookie.
30
+ *
31
+ * @throws Error on tampered, expired, or malformed cookies.
32
+ */
33
+ export declare function unpackOAuthCookie(cookieValue: string, sessionKey: Uint8Array, maxAge?: number): UnpackedOAuthCookie;
34
+ export interface OidcEndpoints {
35
+ authorizationEndpoint: string;
36
+ tokenEndpoint: string;
37
+ }
38
+ /**
39
+ * Create a lazy-cached OIDC discovery function.
40
+ *
41
+ * Caches the Promise; resets on rejection so a transient failure is retried.
42
+ */
43
+ export declare function createOidcDiscovery(issuer: string): () => Promise<OidcEndpoints | null>;
44
+ export interface TokenExchangeResult {
45
+ token: string;
46
+ maxAge: number;
47
+ refreshToken: string | null;
48
+ }
49
+ /** Exchange an authorization code for a token via the token endpoint. */
50
+ export declare function exchangeCodeForToken(tokenEndpoint: string, code: string, redirectUri: string, codeVerifier: string, clientId: string, clientSecret?: string, useIdToken?: boolean): Promise<TokenExchangeResult>;
51
+ /** Validate the original URL is relative and within the expected prefix. */
52
+ export declare function validateOriginalUrl(url: string, prefix: string): string;
53
+ /** Validate an external return-to URL against an origin allowlist. */
54
+ export declare function validateReturnTo(url: string, allowedOrigins?: ReadonlySet<string>): string;
55
+ /** Parse the Cookie header from a Request into a Map. */
56
+ export declare function parseCookies(request: Request): Map<string, string>;
57
+ interface SetCookieOptions {
58
+ maxAge?: number;
59
+ path?: string;
60
+ secure?: boolean;
61
+ httpOnly?: boolean;
62
+ sameSite?: "Strict" | "Lax" | "None";
63
+ }
64
+ /** Build a Set-Cookie header string. */
65
+ export declare function buildSetCookieHeader(name: string, value: string, options: SetCookieOptions): string;
66
+ /** Render a user-friendly OAuth error page. */
67
+ export declare function buildOAuthErrorPage(message: string, detail: string | null, retryUrl: string): string;
68
+ /** Return HTML snippet (style + div + script) for user info display. */
69
+ export declare function buildUserInfoHtml(prefix: string): string;
70
+ /**
71
+ * Create an authenticate callback that reads a bearer token from a cookie.
72
+ *
73
+ * Extracts the token from the named cookie and delegates validation to the
74
+ * `innerAuth` authenticator by creating a new Request with an Authorization header.
75
+ */
76
+ export declare function cookieAuthenticate(innerAuth: AuthenticateFn, cookieName?: string): AuthenticateFn;
77
+ /** Configuration object produced by configureOAuthPkce. */
78
+ export interface OAuthPkceConfig {
79
+ sessionKey: Uint8Array;
80
+ oidcDiscovery: () => Promise<OidcEndpoints | null>;
81
+ clientId: string;
82
+ clientSecret: string | undefined;
83
+ useIdToken: boolean;
84
+ prefix: string;
85
+ secureCookie: boolean;
86
+ redirectUri: string;
87
+ scope: string;
88
+ allowedReturnOrigins: ReadonlySet<string>;
89
+ cookieAuthenticate: AuthenticateFn;
90
+ userInfoHtml: string;
91
+ }
92
+ /** Options for configureOAuthPkce. */
93
+ export interface OAuthPkceOptions {
94
+ signingKey: Uint8Array;
95
+ issuer: string;
96
+ clientId: string;
97
+ clientSecret?: string;
98
+ useIdToken?: boolean;
99
+ prefix: string;
100
+ secureCookie: boolean;
101
+ redirectUri: string;
102
+ scope?: string;
103
+ allowedReturnOrigins?: ReadonlySet<string>;
104
+ }
105
+ /**
106
+ * Resolve the OAuth PKCE `scope` string from available sources.
107
+ *
108
+ * Precedence:
109
+ * 1. `scopesSupported` from OAuth resource metadata (space-joined), when non-empty.
110
+ * 2. Explicit `optionsScope` override (e.g. `HttpHandlerOptions.oauthPkceScope`).
111
+ * 3. `undefined`, which lets `configureOAuthPkce` apply its built-in default of
112
+ * `"openid email"`.
113
+ *
114
+ * Mirrors the Python reference behavior introduced in vgi-rpc v0.6.12: authorization
115
+ * requests should use the scopes the server publishes in its protected resource
116
+ * metadata, so clients ask for exactly what the resource advertises.
117
+ */
118
+ export declare function resolvePkceScope(scopesSupported: readonly string[] | undefined, optionsScope: string | undefined): string | undefined;
119
+ /** Factory function wiring all PKCE components. */
120
+ export declare function configureOAuthPkce(opts: OAuthPkceOptions, innerAuth: AuthenticateFn): OAuthPkceConfig;
121
+ /**
122
+ * Handle POST/OPTIONS {prefix}/_oauth/token — the PKCE token-exchange proxy.
123
+ *
124
+ * SPA PKCE clients cannot safely hold a client_secret, but some IdPs
125
+ * (notably Google) reject token-endpoint requests from "Web application"
126
+ * clients without one. This handler accepts authorization_code/refresh_token
127
+ * exchanges from a browser, injects the configured server-side
128
+ * client_secret, and forwards the request to the IdP's real token_endpoint.
129
+ * The IdP response is returned verbatim (status code + body).
130
+ */
131
+ export declare function handleOAuthTokenProxy(request: Request, config: OAuthPkceConfig): Promise<Response>;
132
+ /** Handle GET {prefix}/_oauth/callback — the redirect from the authorization server. */
133
+ export declare function handleOAuthCallback(request: Request, config: OAuthPkceConfig): Promise<Response>;
134
+ /** Handle GET {prefix}/_oauth/logout — clear auth cookie and redirect. */
135
+ export declare function handleOAuthLogout(_request: Request, config: OAuthPkceConfig): Response;
136
+ /** Redirect an unauthenticated browser GET to the OAuth authorization endpoint. Returns null if unable. */
137
+ export declare function handleBrowserGetRedirect(request: Request, config: OAuthPkceConfig): Promise<Response | null>;
138
+ /** If user is already authenticated and has _vgi_return_to, redirect immediately. Returns null otherwise. */
139
+ export declare function handleEarlyReturnTo(request: Request, config: OAuthPkceConfig): Response | null;
140
+ export {};
141
+ //# sourceMappingURL=oauth-pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-pkce.d.ts","sourceRoot":"","sources":["../../src/http/oauth-pkce.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AA2ChD,6EAA6E;AAC7E,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,yDAAyD;AACzD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAMD,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAEnE;AAsBD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAsCR;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,UAAU,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E,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC9C,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAKpB;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,GAAG,eAAe,CAiBrG;AAuCD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmFxG;AAMD,wFAAwF;AACxF,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6HtG;AAMD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,QAAQ,CAetF;AAMD,2GAA2G;AAC3G,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA+DlH;AAMD,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,QAAQ,GAAG,IAAI,CAmC9F"}
@@ -3,6 +3,9 @@
3
3
  * Matches the styling of the Python and Go implementations.
4
4
  */
5
5
  import type { MethodDefinition } from "../types.js";
6
+ export declare const LOGO_URL = "https://vgi-rpc-python.query.farm/assets/logo-hero.png";
7
+ export declare const FONTS = "<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=JetBrains+Mono:wght@400;600&display=swap\" rel=\"stylesheet\">";
8
+ export declare const ERROR_PAGE_STYLE = "<style>\nbody { font-family: 'Inter', system-ui, -apple-system, sans-serif; max-width: 600px;\n margin: 0 auto; padding: 60px 20px 0; color: #2c2c1e; text-align: center;\n background: #faf8f0; }\n.logo { margin-bottom: 24px; }\n.logo img { width: 120px; height: 120px; border-radius: 50%;\n box-shadow: 0 4px 24px rgba(0,0,0,0.12); }\nh1 { color: #2d5016; margin-bottom: 8px; font-weight: 700; }\ncode { font-family: 'JetBrains Mono', monospace; background: #f0ece0;\n padding: 2px 6px; border-radius: 3px; font-size: 0.9em; color: #2c2c1e; }\na { color: #2d5016; text-decoration: none; }\na:hover { color: #4a7c23; }\np { line-height: 1.7; color: #6b6b5a; }\n.detail { margin-top: 12px; padding: 12px 16px; background: #f0ece0;\n border-radius: 6px; font-size: 0.9em; color: #6b6b5a; }\nfooter { margin-top: 48px; padding: 20px 0; border-top: 1px solid #f0ece0;\n color: #6b6b5a; font-size: 0.85em; line-height: 1.8; }\nfooter a { color: #2d5016; font-weight: 600; }\nfooter a:hover { color: #4a7c23; }\n</style>";
6
9
  export declare function buildLandingPage(protocolName: string, serverId: string, describePath: string | null, repoUrl: string | null): string;
7
10
  export declare function buildNotFoundPage(prefix: string, protocolName: string): string;
8
11
  export declare function buildDescribePage(protocolName: string, serverId: string, methods: Map<string, MethodDefinition>, repoUrl: string | null): string;
@@ -1 +1 @@
1
- {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../src/http/pages.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA8BpD,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,OAAO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