@query-farm/vgi-rpc 0.4.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/client/connect.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/oauth.d.ts +36 -0
- package/dist/client/oauth.d.ts.map +1 -1
- package/dist/client/pipe.d.ts +3 -0
- package/dist/client/pipe.d.ts.map +1 -1
- package/dist/client/stream.d.ts +3 -0
- package/dist/client/stream.d.ts.map +1 -1
- package/dist/client/types.d.ts +4 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/dispatch/describe.d.ts.map +1 -1
- package/dist/dispatch/stream.d.ts +2 -1
- package/dist/dispatch/stream.d.ts.map +1 -1
- package/dist/dispatch/unary.d.ts +2 -1
- package/dist/dispatch/unary.d.ts.map +1 -1
- package/dist/external.d.ts +45 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/gcs.d.ts +38 -0
- package/dist/gcs.d.ts.map +1 -0
- package/dist/http/auth.d.ts +13 -2
- package/dist/http/auth.d.ts.map +1 -1
- package/dist/http/bearer.d.ts +34 -0
- package/dist/http/bearer.d.ts.map +1 -0
- package/dist/http/dispatch.d.ts +2 -0
- package/dist/http/dispatch.d.ts.map +1 -1
- package/dist/http/handler.d.ts.map +1 -1
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/jwt.d.ts +2 -2
- package/dist/http/jwt.d.ts.map +1 -1
- package/dist/http/mtls.d.ts +78 -0
- package/dist/http/mtls.d.ts.map +1 -0
- package/dist/http/pages.d.ts +9 -0
- package/dist/http/pages.d.ts.map +1 -0
- package/dist/http/types.d.ts +17 -1
- package/dist/http/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1119 -230
- package/dist/index.js.map +24 -20
- package/dist/otel.d.ts +47 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/s3.d.ts +43 -0
- package/dist/s3.d.ts.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +44 -1
- package/src/client/connect.ts +13 -5
- package/src/client/index.ts +10 -1
- package/src/client/introspect.ts +1 -1
- package/src/client/oauth.ts +94 -1
- package/src/client/pipe.ts +19 -4
- package/src/client/stream.ts +20 -7
- package/src/client/types.ts +4 -0
- package/src/constants.ts +4 -1
- package/src/dispatch/describe.ts +20 -0
- package/src/dispatch/stream.ts +7 -1
- package/src/dispatch/unary.ts +6 -1
- package/src/external.ts +209 -0
- package/src/gcs.ts +86 -0
- package/src/http/auth.ts +67 -4
- package/src/http/bearer.ts +107 -0
- package/src/http/dispatch.ts +26 -6
- package/src/http/handler.ts +81 -4
- package/src/http/index.ts +10 -0
- package/src/http/jwt.ts +17 -3
- package/src/http/mtls.ts +298 -0
- package/src/http/pages.ts +298 -0
- package/src/http/types.ts +17 -1
- package/src/index.ts +25 -0
- package/src/otel.ts +161 -0
- package/src/s3.ts +94 -0
- package/src/server.ts +42 -8
- package/src/types.ts +34 -0
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Define RPC methods with Arrow-typed schemas, serve them over stdin/stdout, and i
|
|
|
15
15
|
- **Type-safe streaming state** — generic `<S>` parameter threads state types through init and produce/exchange functions
|
|
16
16
|
- **Runtime introspection** — opt-in `__describe__` method for dynamic service discovery via the CLI
|
|
17
17
|
- **Result validation** — missing required fields in handler results throw descriptive errors at emit time
|
|
18
|
+
- **Authentication** — bearer tokens, JWT, mTLS (PEM-in-header and XFCC), with chainable authenticators
|
|
18
19
|
- **Three client transports** — HTTP, subprocess, and raw pipe, all sharing a unified `RpcClient` interface
|
|
19
20
|
|
|
20
21
|
## Installation
|
|
@@ -297,6 +298,52 @@ handler: async ({ a, b }) => {
|
|
|
297
298
|
|
|
298
299
|
Errors are transmitted as zero-row Arrow batches with `EXCEPTION`-level metadata. The transport remains clean for subsequent requests.
|
|
299
300
|
|
|
301
|
+
## Authentication
|
|
302
|
+
|
|
303
|
+
The HTTP handler supports pluggable authentication. Built-in factories cover common strategies:
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
import {
|
|
307
|
+
createHttpHandler,
|
|
308
|
+
chainAuthenticate,
|
|
309
|
+
mtlsAuthenticateSubject,
|
|
310
|
+
bearerAuthenticateStatic,
|
|
311
|
+
jwtAuthenticate,
|
|
312
|
+
AuthContext,
|
|
313
|
+
} from "@query-farm/vgi-rpc";
|
|
314
|
+
|
|
315
|
+
// mTLS via proxy-forwarded client certificate
|
|
316
|
+
const mtlsAuth = mtlsAuthenticateSubject({
|
|
317
|
+
allowedSubjects: new Set(["my-service"]),
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Static API key map
|
|
321
|
+
const apiKeyAuth = bearerAuthenticateStatic({
|
|
322
|
+
tokens: { "sk-abc123": new AuthContext("apikey", true, "ci-bot") },
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// Chain: try mTLS first, fall back to API key
|
|
326
|
+
const auth = chainAuthenticate(mtlsAuth, apiKeyAuth);
|
|
327
|
+
|
|
328
|
+
const handler = createHttpHandler(protocol, {
|
|
329
|
+
signingKey: myKey,
|
|
330
|
+
authenticate: auth,
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Available factories:
|
|
335
|
+
|
|
336
|
+
| Factory | Description |
|
|
337
|
+
|---------|-------------|
|
|
338
|
+
| `bearerAuthenticate` | Custom bearer token validation |
|
|
339
|
+
| `bearerAuthenticateStatic` | Static token map with constant-time comparison |
|
|
340
|
+
| `jwtAuthenticate` | JWT validation via OIDC discovery |
|
|
341
|
+
| `mtlsAuthenticate` | Custom X.509 certificate validation |
|
|
342
|
+
| `mtlsAuthenticateFingerprint` | Certificate fingerprint lookup |
|
|
343
|
+
| `mtlsAuthenticateSubject` | Subject CN extraction with optional allowlist |
|
|
344
|
+
| `mtlsAuthenticateXfcc` | Envoy `x-forwarded-client-cert` header |
|
|
345
|
+
| `chainAuthenticate` | Try multiple strategies in order |
|
|
346
|
+
|
|
300
347
|
## Testing with the Python CLI
|
|
301
348
|
|
|
302
349
|
The [vgi-rpc CLI](https://github.com/Query-farm/vgi-rpc-python) can introspect and call methods on any TypeScript server:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/client/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/client/connect.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAS3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKpE,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACxF,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7E,QAAQ,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAsSpF"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { httpConnect, type RpcClient } from "./connect.js";
|
|
2
2
|
export { httpIntrospect, type MethodInfo, parseDescribeResponse, type ServiceDescription } from "./introspect.js";
|
|
3
3
|
export type { OAuthResourceMetadataResponse } from "./oauth.js";
|
|
4
|
-
export { fetchOAuthMetadata, httpOAuthMetadata, parseResourceMetadataUrl } from "./oauth.js";
|
|
4
|
+
export { fetchOAuthMetadata, httpOAuthMetadata, parseClientId, parseClientSecret, parseDeviceCodeClientId, parseDeviceCodeClientSecret, parseResourceMetadataUrl, parseUseIdTokenAsBearer, } from "./oauth.js";
|
|
5
5
|
export { PipeStreamSession, pipeConnect, subprocessConnect } from "./pipe.js";
|
|
6
6
|
export { HttpStreamSession } from "./stream.js";
|
|
7
7
|
export type { HttpConnectOptions, LogMessage, PipeConnectOptions, StreamSession, SubprocessConnectOptions, } from "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClH,YAAY,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClH,YAAY,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/client/oauth.d.ts
CHANGED
|
@@ -4,10 +4,21 @@ export interface OAuthResourceMetadataResponse {
|
|
|
4
4
|
authorizationServers: string[];
|
|
5
5
|
scopesSupported?: string[];
|
|
6
6
|
bearerMethodsSupported?: string[];
|
|
7
|
+
resourceSigningAlgValuesSupported?: string[];
|
|
7
8
|
resourceName?: string;
|
|
8
9
|
resourceDocumentation?: string;
|
|
9
10
|
resourcePolicyUri?: string;
|
|
10
11
|
resourceTosUri?: string;
|
|
12
|
+
/** OAuth client_id advertised by the server. */
|
|
13
|
+
clientId?: string;
|
|
14
|
+
/** OAuth client_secret advertised by the server. */
|
|
15
|
+
clientSecret?: string;
|
|
16
|
+
/** When true, use the OIDC id_token as the Bearer token instead of access_token. */
|
|
17
|
+
useIdTokenAsBearer?: boolean;
|
|
18
|
+
/** OAuth client_id for device code flow. */
|
|
19
|
+
deviceCodeClientId?: string;
|
|
20
|
+
/** OAuth client_secret for device code flow. */
|
|
21
|
+
deviceCodeClientSecret?: string;
|
|
11
22
|
}
|
|
12
23
|
/**
|
|
13
24
|
* Discover OAuth Protected Resource Metadata (RFC 9728) from a vgi-rpc server.
|
|
@@ -23,4 +34,29 @@ export declare function fetchOAuthMetadata(metadataUrl: string): Promise<OAuthRe
|
|
|
23
34
|
* Returns `null` if no resource_metadata parameter is found.
|
|
24
35
|
*/
|
|
25
36
|
export declare function parseResourceMetadataUrl(wwwAuthenticate: string): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the `client_id` from a WWW-Authenticate Bearer challenge.
|
|
39
|
+
* Returns `null` if no client_id parameter is found.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseClientId(wwwAuthenticate: string): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the `client_secret` from a WWW-Authenticate Bearer challenge.
|
|
44
|
+
* Returns `null` if no client_secret parameter is found.
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseClientSecret(wwwAuthenticate: string): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Extract the `use_id_token_as_bearer` flag from a WWW-Authenticate Bearer challenge.
|
|
49
|
+
* Returns `true` if the parameter is present and set to "true", `false` otherwise.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseUseIdTokenAsBearer(wwwAuthenticate: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Extract the `device_code_client_id` from a WWW-Authenticate Bearer challenge.
|
|
54
|
+
* Returns `null` if no device_code_client_id parameter is found.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseDeviceCodeClientId(wwwAuthenticate: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Extract the `device_code_client_secret` from a WWW-Authenticate Bearer challenge.
|
|
59
|
+
* Returns `null` if no device_code_client_secret parameter is found.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseDeviceCodeClientSecret(wwwAuthenticate: string): string | null;
|
|
26
62
|
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/client/oauth.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EA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AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASxE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CASxE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS9E;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASlF"}
|
package/dist/client/pipe.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "@query-farm/apache-arrow";
|
|
2
|
+
import { type ExternalLocationConfig } from "../external.js";
|
|
2
3
|
import { IpcStreamReader } from "../wire/reader.js";
|
|
3
4
|
import type { RpcClient } from "./connect.js";
|
|
4
5
|
import type { LogMessage, PipeConnectOptions, StreamSession, SubprocessConnectOptions } from "./types.js";
|
|
@@ -20,6 +21,7 @@ export declare class PipeStreamSession implements StreamSession {
|
|
|
20
21
|
private _outputSchema;
|
|
21
22
|
private _releaseBusy;
|
|
22
23
|
private _setDrainPromise;
|
|
24
|
+
private _externalConfig?;
|
|
23
25
|
constructor(opts: {
|
|
24
26
|
reader: IpcStreamReader;
|
|
25
27
|
writeFn: WriteFn;
|
|
@@ -28,6 +30,7 @@ export declare class PipeStreamSession implements StreamSession {
|
|
|
28
30
|
outputSchema: Schema;
|
|
29
31
|
releaseBusy: () => void;
|
|
30
32
|
setDrainPromise: (p: Promise<void>) => void;
|
|
33
|
+
externalConfig?: ExternalLocationConfig;
|
|
31
34
|
});
|
|
32
35
|
get header(): Record<string, any> | null;
|
|
33
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/client/pipe.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,MAAM,EAGP,MAAM,0BAA0B,CAAC;
|
|
1
|
+
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I,CAAC;QACnC,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,IAAI,CAAC;QACxB,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;QAC5C,cAAc,CAAC,EAAE,sBAAsB,CAAC;KACzC;IAWD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAEvC;IAED;;;;OAIG;YACW,gBAAgB;IAqB9B;;;;;OAKG;YACW,mBAAmB;IASjC;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAsG5E;;OAEG;YACW,QAAQ;IAiBtB;;OAEG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAqD7E,KAAK,IAAI,IAAI;CAoCd;AAMD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,EACpC,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,SAAS,CAkOX;AAMD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAwC9F"}
|
package/dist/client/stream.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RecordBatch, Schema } from "@query-farm/apache-arrow";
|
|
2
|
+
import { type ExternalLocationConfig } from "../external.js";
|
|
2
3
|
import type { LogMessage, StreamSession } from "./types.js";
|
|
3
4
|
type CompressFn = (data: Uint8Array, level: number) => Uint8Array;
|
|
4
5
|
type DecompressFn = (data: Uint8Array) => Uint8Array;
|
|
@@ -17,6 +18,7 @@ export declare class HttpStreamSession implements StreamSession {
|
|
|
17
18
|
private _compressFn?;
|
|
18
19
|
private _decompressFn?;
|
|
19
20
|
private _authorization?;
|
|
21
|
+
private _externalConfig?;
|
|
20
22
|
constructor(opts: {
|
|
21
23
|
baseUrl: string;
|
|
22
24
|
prefix: string;
|
|
@@ -32,6 +34,7 @@ export declare class HttpStreamSession implements StreamSession {
|
|
|
32
34
|
compressFn?: CompressFn;
|
|
33
35
|
decompressFn?: DecompressFn;
|
|
34
36
|
authorization?: string;
|
|
37
|
+
externalConfig?: ExternalLocationConfig;
|
|
35
38
|
});
|
|
36
39
|
get header(): Record<string, any> | null;
|
|
37
40
|
private _buildHeaders;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/client/stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,WAAW,EAAE,MAAM,EAA2B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/client/stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,WAAW,EAAE,MAAM,EAA2B,MAAM,0BAA0B,CAAC;AAGzG,OAAO,EAAE,KAAK,sBAAsB,EAAoD,MAAM,gBAAgB,CAAC;AAG/G,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;AAClE,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;AAErD,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OA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W;IAuCzB,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YAkD/D,iBAAiB;IA2B/B,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface HttpConnectOptions {
|
|
|
4
4
|
compressionLevel?: number;
|
|
5
5
|
/** Authorization header value (e.g. "Bearer <token>"). Sent with every request. */
|
|
6
6
|
authorization?: string;
|
|
7
|
+
/** External storage config for resolving externalized batches. */
|
|
8
|
+
externalLocation?: import("../external.js").ExternalLocationConfig;
|
|
7
9
|
}
|
|
8
10
|
export interface LogMessage {
|
|
9
11
|
level: string;
|
|
@@ -18,6 +20,8 @@ export interface StreamSession {
|
|
|
18
20
|
}
|
|
19
21
|
export interface PipeConnectOptions {
|
|
20
22
|
onLog?: (msg: LogMessage) => void;
|
|
23
|
+
/** External storage config for resolving externalized batches. */
|
|
24
|
+
externalLocation?: import("../external.js").ExternalLocationConfig;
|
|
21
25
|
}
|
|
22
26
|
export interface SubprocessConnectOptions extends PipeConnectOptions {
|
|
23
27
|
cwd?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IA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ERVER_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 = "
|
|
12
|
+
export declare const DESCRIBE_VERSION = "3";
|
|
13
13
|
export declare const DESCRIBE_METHOD_NAME = "__describe__";
|
|
14
14
|
export declare const STATE_KEY = "vgi_rpc.stream_state#b64";
|
|
15
|
+
export declare const LOCATION_KEY = "vgi_rpc.location";
|
|
16
|
+
export declare const LOCATION_SHA256_KEY = "vgi_rpc.location.sha256";
|
|
15
17
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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,MAAM,iBAAiB,0BAA0B,CAAC;AACzD,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAC/D,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAEnD,eAAO,MAAM,SAAS,6BAA6B,CAAC"}
|
|
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,MAAM,iBAAiB,0BAA0B,CAAC;AACzD,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAC/D,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAEnD,eAAO,MAAM,SAAS,6BAA6B,CAAC;AAEpD,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAC/C,eAAO,MAAM,mBAAmB,4BAA4B,CAAC"}
|
|
@@ -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,
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { type ExternalLocationConfig } from "../external.js";
|
|
1
2
|
import type { MethodDefinition } from "../types.js";
|
|
2
3
|
import type { IpcStreamReader } from "../wire/reader.js";
|
|
3
4
|
import type { IpcStreamWriter } from "../wire/writer.js";
|
|
@@ -16,5 +17,5 @@ import type { IpcStreamWriter } from "../wire/writer.js";
|
|
|
16
17
|
* - Server writes output batch(es) for each input
|
|
17
18
|
* - Stream ends when client closes input (EOS)
|
|
18
19
|
*/
|
|
19
|
-
export declare function dispatchStream(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, reader: IpcStreamReader, serverId: string, requestId: string | null): Promise<void>;
|
|
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
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,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,
|
|
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"}
|
package/dist/dispatch/unary.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ExternalLocationConfig } from "../external.js";
|
|
1
2
|
import type { MethodDefinition } from "../types.js";
|
|
2
3
|
import type { IpcStreamWriter } from "../wire/writer.js";
|
|
3
4
|
/**
|
|
@@ -5,5 +6,5 @@ import type { IpcStreamWriter } from "../wire/writer.js";
|
|
|
5
6
|
* Calls the handler with parsed params, writes result or error batch.
|
|
6
7
|
* Supports client-directed logging via ctx.clientLog().
|
|
7
8
|
*/
|
|
8
|
-
export declare function dispatchUnary(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, serverId: string, requestId: string | null): Promise<void>;
|
|
9
|
+
export declare function dispatchUnary(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, serverId: string, requestId: string | null, externalConfig?: ExternalLocationConfig): Promise<void>;
|
|
9
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,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,
|
|
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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External storage support for large Arrow IPC batches.
|
|
3
|
+
*
|
|
4
|
+
* When a batch exceeds a configurable threshold, it is serialized to IPC,
|
|
5
|
+
* optionally compressed with zstd, and uploaded to pluggable storage.
|
|
6
|
+
* The batch is replaced with a zero-row "pointer batch" containing the
|
|
7
|
+
* download URL and SHA-256 checksum in metadata.
|
|
8
|
+
*/
|
|
9
|
+
import { type RecordBatch, type Schema } from "@query-farm/apache-arrow";
|
|
10
|
+
/** Pluggable storage backend for uploading large batches. */
|
|
11
|
+
export interface ExternalStorage {
|
|
12
|
+
/** Upload IPC data and return a URL for retrieval. */
|
|
13
|
+
upload(data: Uint8Array, contentEncoding: string): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
/** Configuration for external storage of large batches. */
|
|
16
|
+
export interface ExternalLocationConfig {
|
|
17
|
+
/** Storage backend for uploading. */
|
|
18
|
+
storage: ExternalStorage;
|
|
19
|
+
/** Minimum batch byte size to trigger externalization. Default: 1MB. */
|
|
20
|
+
externalizeThresholdBytes?: number;
|
|
21
|
+
/** Optional zstd compression for uploaded data. */
|
|
22
|
+
compression?: {
|
|
23
|
+
algorithm: "zstd";
|
|
24
|
+
level?: number;
|
|
25
|
+
};
|
|
26
|
+
/** URL validator called before fetching. Throw to reject. Default: HTTPS-only. */
|
|
27
|
+
urlValidator?: ((url: string) => void) | null;
|
|
28
|
+
}
|
|
29
|
+
/** Default validator that rejects non-HTTPS URLs. */
|
|
30
|
+
export declare function httpsOnlyValidator(url: string): void;
|
|
31
|
+
/** Returns true if the batch is a zero-row pointer to external data. */
|
|
32
|
+
export declare function isExternalLocationBatch(batch: RecordBatch): boolean;
|
|
33
|
+
/** 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;
|
|
35
|
+
/**
|
|
36
|
+
* Maybe externalize a batch if it exceeds the threshold.
|
|
37
|
+
* Returns the original batch unchanged if below threshold or no config.
|
|
38
|
+
*/
|
|
39
|
+
export declare function maybeExternalizeBatch(batch: RecordBatch, config?: ExternalLocationConfig | null): Promise<RecordBatch>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve an external pointer batch by fetching the data from the URL.
|
|
42
|
+
* Returns the original batch unchanged if not a pointer or no config.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveExternalLocation(batch: RecordBatch, config?: ExternalLocationConfig | null): Promise<RecordBatch>;
|
|
45
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +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,EAAE,WAAW,GAAG,OAAO,CAKnE;AAMD,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAOnG;AA4BD;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,sBAAsB,GAAG,IAAI,GACrC,OAAO,CAAC,WAAW,CAAC,CAyBtB;AAMD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,sBAAsB,GAAG,IAAI,GACrC,OAAO,CAAC,WAAW,CAAC,CA4CtB"}
|
package/dist/gcs.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Cloud Storage backend for external storage of large Arrow IPC batches.
|
|
3
|
+
*
|
|
4
|
+
* Requires `@google-cloud/storage` as a peer dependency.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createGCSStorage } from "@query-farm/vgi-rpc/gcs";
|
|
9
|
+
*
|
|
10
|
+
* const storage = createGCSStorage({
|
|
11
|
+
* bucket: "my-bucket",
|
|
12
|
+
* prefix: "vgi-rpc/",
|
|
13
|
+
* });
|
|
14
|
+
* const handler = createHttpHandler(protocol, {
|
|
15
|
+
* externalLocation: { storage, externalizeThresholdBytes: 1_048_576 },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import type { ExternalStorage } from "./external.js";
|
|
20
|
+
/** Configuration for the GCS storage backend. */
|
|
21
|
+
export interface GCSStorageConfig {
|
|
22
|
+
/** GCS bucket name. */
|
|
23
|
+
bucket: string;
|
|
24
|
+
/** Key prefix for uploaded objects. Default: "vgi-rpc/". */
|
|
25
|
+
prefix?: string;
|
|
26
|
+
/** Lifetime of signed GET URLs in seconds. Default: 3600 (1 hour). */
|
|
27
|
+
presignExpirySeconds?: number;
|
|
28
|
+
/** GCS project ID. If omitted, uses Application Default Credentials. */
|
|
29
|
+
projectId?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a GCS-backed ExternalStorage.
|
|
33
|
+
*
|
|
34
|
+
* Lazily imports `@google-cloud/storage` on first upload to avoid
|
|
35
|
+
* loading the SDK unless needed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createGCSStorage(config: GCSStorageConfig): ExternalStorage;
|
|
38
|
+
//# sourceMappingURL=gcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcs.d.ts","sourceRoot":"","sources":["../src/gcs.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,eAAe,CA2C1E"}
|
package/dist/http/auth.d.ts
CHANGED
|
@@ -7,15 +7,26 @@ export interface OAuthResourceMetadata {
|
|
|
7
7
|
authorizationServers: string[];
|
|
8
8
|
scopesSupported?: string[];
|
|
9
9
|
bearerMethodsSupported?: string[];
|
|
10
|
+
resourceSigningAlgValuesSupported?: string[];
|
|
10
11
|
resourceName?: string;
|
|
11
12
|
resourceDocumentation?: string;
|
|
12
13
|
resourcePolicyUri?: string;
|
|
13
14
|
resourceTosUri?: string;
|
|
15
|
+
/** OAuth client_id that clients should use with the authorization server. */
|
|
16
|
+
clientId?: string;
|
|
17
|
+
/** OAuth client_secret that clients should use with the authorization server. */
|
|
18
|
+
clientSecret?: string;
|
|
19
|
+
/** OAuth client_id for device code flow. */
|
|
20
|
+
deviceCodeClientId?: string;
|
|
21
|
+
/** OAuth client_secret for device code flow. */
|
|
22
|
+
deviceCodeClientSecret?: string;
|
|
23
|
+
/** When true, clients should use the OIDC id_token as the Bearer token instead of access_token. */
|
|
24
|
+
useIdTokenAsBearer?: boolean;
|
|
14
25
|
}
|
|
15
26
|
/** Convert OAuthResourceMetadata to RFC 9728 snake_case JSON object. */
|
|
16
27
|
export declare function oauthResourceMetadataToJson(metadata: OAuthResourceMetadata): Record<string, any>;
|
|
17
28
|
/** Compute the well-known path for OAuth Protected Resource Metadata. */
|
|
18
29
|
export declare function wellKnownPath(prefix: string): string;
|
|
19
|
-
/** Build a WWW-Authenticate header value with optional resource_metadata URL. */
|
|
20
|
-
export declare function buildWwwAuthenticateHeader(metadataUrl?: string): string;
|
|
30
|
+
/** Build a WWW-Authenticate header value with optional resource_metadata URL, client_id, client_secret, device_code_client_id, device_code_client_secret, and use_id_token_as_bearer. */
|
|
31
|
+
export declare function buildWwwAuthenticateHeader(metadataUrl?: string, clientId?: string, clientSecret?: string, useIdTokenAsBearer?: boolean, deviceCodeClientId?: string, deviceCodeClientSecret?: string): string;
|
|
21
32
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/http/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/http/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEtF,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sour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O,EAC5B,kBAAkB,CAAC,EAAE,MAAM,EAC3B,sBAAsB,CAAC,EAAE,MAAM,GAC9B,MAAM,CAqBR"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AuthContext } from "../auth.js";
|
|
2
|
+
import type { AuthenticateFn } from "./auth.js";
|
|
3
|
+
/** Receives the raw bearer token string, returns an AuthContext on success. Must throw on failure. */
|
|
4
|
+
export type BearerValidateFn = (token: string) => AuthContext | Promise<AuthContext>;
|
|
5
|
+
/**
|
|
6
|
+
* Create a bearer-token authenticate callback.
|
|
7
|
+
*
|
|
8
|
+
* Extracts the `Authorization: Bearer <token>` header and delegates
|
|
9
|
+
* validation to the user-supplied `validate` callback.
|
|
10
|
+
*/
|
|
11
|
+
export declare function bearerAuthenticate(options: {
|
|
12
|
+
validate: BearerValidateFn;
|
|
13
|
+
}): AuthenticateFn;
|
|
14
|
+
/**
|
|
15
|
+
* Create a bearer-token authenticate callback from a static token map.
|
|
16
|
+
*
|
|
17
|
+
* Convenience wrapper around `bearerAuthenticate` that looks up the
|
|
18
|
+
* token in a pre-built mapping using constant-time comparison.
|
|
19
|
+
*/
|
|
20
|
+
export declare function bearerAuthenticateStatic(options: {
|
|
21
|
+
tokens: ReadonlyMap<string, AuthContext> | Record<string, AuthContext>;
|
|
22
|
+
}): AuthenticateFn;
|
|
23
|
+
/**
|
|
24
|
+
* Chain multiple authenticate callbacks, trying each in order.
|
|
25
|
+
*
|
|
26
|
+
* Each authenticator is called in sequence. Plain `Error` (credential
|
|
27
|
+
* rejection) causes the next authenticator to be tried. Error subclasses
|
|
28
|
+
* (`TypeError`, `RangeError`, etc.), `PermissionError`-named errors, and
|
|
29
|
+
* non-Error throws propagate immediately.
|
|
30
|
+
*
|
|
31
|
+
* @throws Error if no authenticators are provided.
|
|
32
|
+
*/
|
|
33
|
+
export declare function chainAuthenticate(...authenticators: AuthenticateFn[]): AuthenticateFn;
|
|
34
|
+
//# sourceMappingURL=bearer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer.d.ts","sourceRoot":"","sources":["../../src/http/bearer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,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;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"}
|
package/dist/http/dispatch.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AuthContext } from "../auth.js";
|
|
2
|
+
import { type ExternalLocationConfig } from "../external.js";
|
|
2
3
|
import type { MethodDefinition } from "../types.js";
|
|
3
4
|
import type { StateSerializer } from "./types.js";
|
|
4
5
|
export interface DispatchContext {
|
|
@@ -8,6 +9,7 @@ export interface DispatchContext {
|
|
|
8
9
|
maxStreamResponseBytes?: number;
|
|
9
10
|
stateSerializer: StateSerializer;
|
|
10
11
|
authContext?: AuthContext;
|
|
12
|
+
externalLocation?: ExternalLocationConfig;
|
|
11
13
|
}
|
|
12
14
|
/** Dispatch a __describe__ request. */
|
|
13
15
|
export declare function httpDispatchDescribe(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string): Response;
|
|
@@ -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,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;
|
|
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,QAAQ,CAAC,CAqHnB"}
|
|
@@ -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;
|
|
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,CAiSpD"}
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export type { AuthenticateFn, OAuthResourceMetadata } from "./auth.js";
|
|
2
2
|
export { oauthResourceMetadataToJson } from "./auth.js";
|
|
3
|
+
export type { BearerValidateFn } from "./bearer.js";
|
|
4
|
+
export { bearerAuthenticate, bearerAuthenticateStatic, chainAuthenticate } from "./bearer.js";
|
|
3
5
|
export { ARROW_CONTENT_TYPE } from "./common.js";
|
|
4
6
|
export { createHttpHandler } from "./handler.js";
|
|
5
7
|
export type { JwtAuthenticateOptions } from "./jwt.js";
|
|
6
8
|
export { jwtAuthenticate } from "./jwt.js";
|
|
9
|
+
export type { CertValidateFn, XfccElement, XfccValidateFn } from "./mtls.js";
|
|
10
|
+
export { mtlsAuthenticate, mtlsAuthenticateFingerprint, mtlsAuthenticateSubject, mtlsAuthenticateXfcc, parseXfcc, } from "./mtls.js";
|
|
7
11
|
export { type UnpackedToken, unpackStateToken } from "./token.js";
|
|
8
12
|
export type { HttpHandlerOptions, StateSerializer } from "./types.js";
|
|
9
13
|
export { jsonStateSerializer } from "./types.js";
|
package/dist/http/index.d.ts.map
CHANGED
|
@@ -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,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,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,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"}
|
package/dist/http/jwt.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { AuthenticateFn } from "./auth.js";
|
|
|
2
2
|
export interface JwtAuthenticateOptions {
|
|
3
3
|
/** The expected `iss` claim (also used to discover AS metadata). */
|
|
4
4
|
issuer: string;
|
|
5
|
-
/** The expected `aud` claim. */
|
|
6
|
-
audience: string;
|
|
5
|
+
/** The expected `aud` claim. If an array, tries each audience in order. */
|
|
6
|
+
audience: string | string[];
|
|
7
7
|
/** Explicit JWKS URI. If omitted, discovered from issuer metadata. */
|
|
8
8
|
jwksUri?: string;
|
|
9
9
|
/** JWT claim to use as the principal. Default: "sub". */
|
package/dist/http/jwt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/http/jwt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/http/jwt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,cAAc,CAqD/E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { X509Certificate } from "node:crypto";
|
|
2
|
+
import { AuthContext } from "../auth.js";
|
|
3
|
+
import type { AuthenticateFn } from "./auth.js";
|
|
4
|
+
/** A single element from an `x-forwarded-client-cert` header. */
|
|
5
|
+
export interface XfccElement {
|
|
6
|
+
hash: string | null;
|
|
7
|
+
cert: string | null;
|
|
8
|
+
subject: string | null;
|
|
9
|
+
uri: string | null;
|
|
10
|
+
dns: readonly string[];
|
|
11
|
+
by: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** Receives a parsed XFCC element, returns an AuthContext on success. Must throw on failure. */
|
|
14
|
+
export type XfccValidateFn = (element: XfccElement) => AuthContext | Promise<AuthContext>;
|
|
15
|
+
/** Receives a parsed X509Certificate, returns an AuthContext on success. Must throw on failure. */
|
|
16
|
+
export type CertValidateFn = (cert: X509Certificate) => AuthContext | Promise<AuthContext>;
|
|
17
|
+
/**
|
|
18
|
+
* Parse an `x-forwarded-client-cert` header value.
|
|
19
|
+
*
|
|
20
|
+
* Handles comma-separated elements (respecting quoted values),
|
|
21
|
+
* semicolon-separated key=value pairs within each element, and
|
|
22
|
+
* URL-encoded Cert/URI/By fields.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseXfcc(headerValue: string): XfccElement[];
|
|
25
|
+
/**
|
|
26
|
+
* Create an authenticate callback from Envoy `x-forwarded-client-cert`.
|
|
27
|
+
*
|
|
28
|
+
* Parses the `x-forwarded-client-cert` header and extracts client identity.
|
|
29
|
+
* Does not require any crypto dependencies.
|
|
30
|
+
*
|
|
31
|
+
* **Warning:** The reverse proxy MUST strip client-supplied
|
|
32
|
+
* `x-forwarded-client-cert` headers before forwarding.
|
|
33
|
+
*/
|
|
34
|
+
export declare function mtlsAuthenticateXfcc(options?: {
|
|
35
|
+
validate?: XfccValidateFn;
|
|
36
|
+
domain?: string;
|
|
37
|
+
selectElement?: "first" | "last";
|
|
38
|
+
}): AuthenticateFn;
|
|
39
|
+
/**
|
|
40
|
+
* Create an mTLS authenticate callback with custom certificate validation.
|
|
41
|
+
*
|
|
42
|
+
* Generic factory that parses the client certificate from a proxy header
|
|
43
|
+
* and delegates identity extraction to a user-supplied `validate` callback.
|
|
44
|
+
*
|
|
45
|
+
* **Warning:** The reverse proxy MUST strip client-supplied certificate
|
|
46
|
+
* headers before forwarding.
|
|
47
|
+
*/
|
|
48
|
+
export declare function mtlsAuthenticate(options: {
|
|
49
|
+
validate: CertValidateFn;
|
|
50
|
+
header?: string;
|
|
51
|
+
checkExpiry?: boolean;
|
|
52
|
+
}): AuthenticateFn;
|
|
53
|
+
/**
|
|
54
|
+
* Create an mTLS authenticate callback using certificate fingerprint lookup.
|
|
55
|
+
*
|
|
56
|
+
* Computes the certificate fingerprint and looks it up in the provided
|
|
57
|
+
* mapping. Fingerprints must be lowercase hex without colons.
|
|
58
|
+
*/
|
|
59
|
+
export declare function mtlsAuthenticateFingerprint(options: {
|
|
60
|
+
fingerprints: ReadonlyMap<string, AuthContext> | Record<string, AuthContext>;
|
|
61
|
+
header?: string;
|
|
62
|
+
algorithm?: string;
|
|
63
|
+
domain?: string;
|
|
64
|
+
checkExpiry?: boolean;
|
|
65
|
+
}): AuthenticateFn;
|
|
66
|
+
/**
|
|
67
|
+
* Create an mTLS authenticate callback using certificate subject CN.
|
|
68
|
+
*
|
|
69
|
+
* Extracts the Subject Common Name as `principal` and populates
|
|
70
|
+
* `claims` with the full DN, serial number (hex), and `not_valid_after`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mtlsAuthenticateSubject(options?: {
|
|
73
|
+
header?: string;
|
|
74
|
+
domain?: string;
|
|
75
|
+
allowedSubjects?: ReadonlySet<string> | null;
|
|
76
|
+
checkExpiry?: boolean;
|
|
77
|
+
}): AuthenticateFn;
|
|
78
|
+
//# sourceMappingURL=mtls.d.ts.map
|