@sentropic/h2a-cli 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/remote/client.d.ts +27 -0
- package/dist/runtime/remote/client.d.ts.map +1 -0
- package/dist/runtime/remote/client.js +34 -0
- package/dist/runtime/remote/client.js.map +1 -0
- package/dist/runtime/remote/index.d.ts +2 -0
- package/dist/runtime/remote/index.d.ts.map +1 -1
- package/dist/runtime/remote/index.js +2 -0
- package/dist/runtime/remote/index.js.map +1 -1
- package/dist/runtime/remote/server.d.ts +36 -0
- package/dist/runtime/remote/server.d.ts.map +1 -0
- package/dist/runtime/remote/server.js +100 -0
- package/dist/runtime/remote/server.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { H2A_STORE_SCHEMA_FILE, H2A_STORE_SCHEMA_VERSION, LockTimeoutError, Stor
|
|
|
10
10
|
export { H2A_CLI_MCP_TOOL_DESCRIPTORS, NotificationDispatcher, SessionRegistry, createMcpServer, runMcpStdio, type CreateMcpServerOptions, type McpErrorResult, type McpPushNotification, type McpServer, type McpToolDescriptor, type McpToolName, type McpToolResult, type NotificationSink, type OpenSessionRequest, type RunMcpStdioOptions, type SessionRegistryOptions } from "./runtime/mcp/index.js";
|
|
11
11
|
export { renderK8sSidecar, type K8sSidecarFragment, type K8sSidecarOptions } from "./runtime/deploy/k8s-sidecar.js";
|
|
12
12
|
export { renderK8sTenant, type K8sTenantManifest, type K8sTenantOptions } from "./runtime/deploy/k8s-tenant.js";
|
|
13
|
-
export { acceptRemoteEnvelope, type AcceptRemoteOptions, type H2AAcceptRejection, type H2AAcceptResult } from "./runtime/remote/index.js";
|
|
13
|
+
export { acceptRemoteEnvelope, createRemoteServer, rejectionStatus, sendRemoteEnvelope, type AcceptRemoteOptions, type H2AAcceptRejection, type H2AAcceptResult, type RemoteServerOptions, type SendRemoteOptions, type SendRemoteResult } from "./runtime/remote/index.js";
|
|
14
14
|
export declare const H2A_CLI_HOSTS: readonly [import("./hosts/codex.js").H2AConfigurableHostDescriptor, import("./hosts/codex.js").H2AConfigurableHostDescriptor, import("./hosts/codex.js").H2AConfigurableHostDescriptor];
|
|
15
15
|
export declare const H2A_CLI_ADAPTER: {
|
|
16
16
|
readonly packageName: "@sentropic/h2a-cli";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,YAAY,EACV,6BAA6B,EAC7B,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,WAAW,EACZ,CAAC;AAEF,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,YA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tB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,aAAa,yLAIhB,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { H2A_STORE_SCHEMA_FILE, H2A_STORE_SCHEMA_VERSION, LockTimeoutError, Stor
|
|
|
9
9
|
export { H2A_CLI_MCP_TOOL_DESCRIPTORS, NotificationDispatcher, SessionRegistry, createMcpServer, runMcpStdio } from "./runtime/mcp/index.js";
|
|
10
10
|
export { renderK8sSidecar } from "./runtime/deploy/k8s-sidecar.js";
|
|
11
11
|
export { renderK8sTenant } from "./runtime/deploy/k8s-tenant.js";
|
|
12
|
-
export { acceptRemoteEnvelope } from "./runtime/remote/index.js";
|
|
12
|
+
export { acceptRemoteEnvelope, createRemoteServer, rejectionStatus, sendRemoteEnvelope } from "./runtime/remote/index.js";
|
|
13
13
|
export const H2A_CLI_HOSTS = [
|
|
14
14
|
H2A_CODEX_HOST,
|
|
15
15
|
H2A_CLAUDE_HOST,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAUlD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,WAAW,EACZ,CAAC;AAEF,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAI9B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,aAAa,EAgBd,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,WAAW,EAYZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,gBAAgB,EAGjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,eAAe,EAGhB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC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|
1
|
+
/**
|
|
2
|
+
* HTTP client for signed envelopes (DEC-076), the send side of slice 3b.
|
|
3
|
+
*
|
|
4
|
+
* Signs an envelope (DEC-073) and POSTs it to a remote h2a endpoint. The
|
|
5
|
+
* transport only moves bytes — provenance and freshness are carried in the
|
|
6
|
+
* envelope itself and verified by the receiver (DEC-075).
|
|
7
|
+
*/
|
|
8
|
+
import { type H2AEnvelope } from "@sentropic/h2a";
|
|
9
|
+
export interface SendRemoteOptions {
|
|
10
|
+
/** Signer instance id recorded in the signature's `by`. */
|
|
11
|
+
by: string;
|
|
12
|
+
/** Signer's ed25519 private-key PEM. */
|
|
13
|
+
privateKeyPem: string;
|
|
14
|
+
/** Optional fetch override (tests / custom agents). Defaults to global fetch. */
|
|
15
|
+
fetchImpl?: typeof fetch;
|
|
16
|
+
}
|
|
17
|
+
export interface SendRemoteResult {
|
|
18
|
+
status: number;
|
|
19
|
+
body: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sign `envelope` and POST it as JSON to `url`. Returns the HTTP status and the
|
|
23
|
+
* parsed JSON body (or undefined if the response was not JSON). Network errors
|
|
24
|
+
* propagate to the caller.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sendRemoteEnvelope(url: string, envelope: H2AEnvelope, options: SendRemoteOptions): Promise<SendRemoteResult>;
|
|
27
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/runtime/remote/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAkB3B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for signed envelopes (DEC-076), the send side of slice 3b.
|
|
3
|
+
*
|
|
4
|
+
* Signs an envelope (DEC-073) and POSTs it to a remote h2a endpoint. The
|
|
5
|
+
* transport only moves bytes — provenance and freshness are carried in the
|
|
6
|
+
* envelope itself and verified by the receiver (DEC-075).
|
|
7
|
+
*/
|
|
8
|
+
import { signEnvelope } from "@sentropic/h2a";
|
|
9
|
+
/**
|
|
10
|
+
* Sign `envelope` and POST it as JSON to `url`. Returns the HTTP status and the
|
|
11
|
+
* parsed JSON body (or undefined if the response was not JSON). Network errors
|
|
12
|
+
* propagate to the caller.
|
|
13
|
+
*/
|
|
14
|
+
export async function sendRemoteEnvelope(url, envelope, options) {
|
|
15
|
+
const signed = signEnvelope(envelope, {
|
|
16
|
+
by: options.by,
|
|
17
|
+
privateKeyPem: options.privateKeyPem
|
|
18
|
+
});
|
|
19
|
+
const doFetch = options.fetchImpl ?? fetch;
|
|
20
|
+
const res = await doFetch(url, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: { "content-type": "application/json" },
|
|
23
|
+
body: JSON.stringify(signed)
|
|
24
|
+
});
|
|
25
|
+
let body;
|
|
26
|
+
try {
|
|
27
|
+
body = await res.json();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
body = undefined;
|
|
31
|
+
}
|
|
32
|
+
return { status: res.status, body };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/runtime/remote/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAgBhE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAW,EACX,QAAqB,EACrB,OAA0B;IAE1B,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE;QACpC,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,aAAa,EAAE,OAAO,CAAC,aAAa;KACrC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC3C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE;QAC7B,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAC;IACH,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { acceptRemoteEnvelope, type AcceptRemoteOptions, type H2AAcceptRejection, type H2AAcceptResult } from "./accept.js";
|
|
2
|
+
export { createRemoteServer, rejectionStatus, type RemoteServerOptions } from "./server.js";
|
|
3
|
+
export { sendRemoteEnvelope, type SendRemoteOptions, type SendRemoteResult } from "./client.js";
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/remote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/remote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/remote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAIrB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/remote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAIrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAGnB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for signed envelopes (DEC-076), slice 3b of the signed-bearer
|
|
3
|
+
* transport-auth workstream (DEC-073/074/075).
|
|
4
|
+
*
|
|
5
|
+
* The server is a thin, channel-untrusting front-end over the DEC-075
|
|
6
|
+
* `acceptRemoteEnvelope` pipeline: it reads a POSTed JSON envelope and hands it
|
|
7
|
+
* to the pipeline, which does all verification. The HTTP layer adds only
|
|
8
|
+
* framing (a single POST endpoint, a body-size cap) and a result→status map.
|
|
9
|
+
*/
|
|
10
|
+
import { type Server } from "node:http";
|
|
11
|
+
import { type H2AEnvelope, type H2AReplayGuard } from "@sentropic/h2a";
|
|
12
|
+
import { type H2AAcceptRejection } from "./accept.js";
|
|
13
|
+
export interface RemoteServerOptions {
|
|
14
|
+
/** Resolve a signer instance to its ed25519 public-key PEM (e.g. from the registry). */
|
|
15
|
+
resolvePublicKey: (signerInstance: string) => string | undefined;
|
|
16
|
+
/** Deliver an accepted envelope to a local recipient's inbox. */
|
|
17
|
+
deliver: (recipient: string, envelope: H2AEnvelope) => void;
|
|
18
|
+
/** Shared replay guard. Defaults to a fresh in-memory guard (DEC-074). */
|
|
19
|
+
guard?: H2AReplayGuard;
|
|
20
|
+
/** POST endpoint path. Default `/h2a/envelopes`. */
|
|
21
|
+
path?: string;
|
|
22
|
+
/** Reject bodies larger than this many bytes. Default 256 KiB. */
|
|
23
|
+
maxBodyBytes?: number;
|
|
24
|
+
/** Clock source handed to the replay guard. Defaults to `Date.now`. */
|
|
25
|
+
now?: () => number;
|
|
26
|
+
}
|
|
27
|
+
/** Map an accept-pipeline rejection to an HTTP status code. */
|
|
28
|
+
export declare function rejectionStatus(reason: H2AAcceptRejection): number;
|
|
29
|
+
/**
|
|
30
|
+
* Build (but do not start) an HTTP server that feeds POSTed envelopes to the
|
|
31
|
+
* DEC-075 trust boundary. Accepted → 202; rejected → see {@link rejectionStatus};
|
|
32
|
+
* wrong method/path → 404/405. The caller starts it with `.listen(port, host)`
|
|
33
|
+
* and is responsible for closing it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createRemoteServer(options: RemoteServerOptions): Server;
|
|
36
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/runtime/remote/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE1F,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE5E,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,gBAAgB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACjE,iEAAiE;IACjE,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5D,0EAA0E;IAC1E,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAkBlE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA2DvE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for signed envelopes (DEC-076), slice 3b of the signed-bearer
|
|
3
|
+
* transport-auth workstream (DEC-073/074/075).
|
|
4
|
+
*
|
|
5
|
+
* The server is a thin, channel-untrusting front-end over the DEC-075
|
|
6
|
+
* `acceptRemoteEnvelope` pipeline: it reads a POSTed JSON envelope and hands it
|
|
7
|
+
* to the pipeline, which does all verification. The HTTP layer adds only
|
|
8
|
+
* framing (a single POST endpoint, a body-size cap) and a result→status map.
|
|
9
|
+
*/
|
|
10
|
+
import { createServer } from "node:http";
|
|
11
|
+
import { createReplayGuard } from "@sentropic/h2a";
|
|
12
|
+
import { acceptRemoteEnvelope } from "./accept.js";
|
|
13
|
+
/** Map an accept-pipeline rejection to an HTTP status code. */
|
|
14
|
+
export function rejectionStatus(reason) {
|
|
15
|
+
switch (reason) {
|
|
16
|
+
case "malformed":
|
|
17
|
+
case "no-target":
|
|
18
|
+
case "no-signature":
|
|
19
|
+
case "invalid-timestamp":
|
|
20
|
+
return 400; // bad request (structural / unparseable)
|
|
21
|
+
case "no-public-key":
|
|
22
|
+
case "bad-signature":
|
|
23
|
+
return 401; // unauthorized (cannot authenticate the emitter)
|
|
24
|
+
case "replayed":
|
|
25
|
+
return 409; // conflict (already seen)
|
|
26
|
+
case "expired":
|
|
27
|
+
case "future":
|
|
28
|
+
return 422; // unprocessable (outside the freshness window)
|
|
29
|
+
default:
|
|
30
|
+
return 400;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build (but do not start) an HTTP server that feeds POSTed envelopes to the
|
|
35
|
+
* DEC-075 trust boundary. Accepted → 202; rejected → see {@link rejectionStatus};
|
|
36
|
+
* wrong method/path → 404/405. The caller starts it with `.listen(port, host)`
|
|
37
|
+
* and is responsible for closing it.
|
|
38
|
+
*/
|
|
39
|
+
export function createRemoteServer(options) {
|
|
40
|
+
const guard = options.guard ?? createReplayGuard();
|
|
41
|
+
const path = options.path ?? "/h2a/envelopes";
|
|
42
|
+
const maxBodyBytes = options.maxBodyBytes ?? 256 * 1024;
|
|
43
|
+
return createServer((req, res) => {
|
|
44
|
+
const respond = (status, body) => {
|
|
45
|
+
const payload = JSON.stringify(body);
|
|
46
|
+
res.writeHead(status, { "content-type": "application/json" });
|
|
47
|
+
res.end(payload);
|
|
48
|
+
};
|
|
49
|
+
const url = req.url ?? "";
|
|
50
|
+
if (url.split("?")[0] !== path) {
|
|
51
|
+
respond(404, { ok: false, error: "not-found" });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (req.method !== "POST") {
|
|
55
|
+
res.setHeader("allow", "POST");
|
|
56
|
+
respond(405, { ok: false, error: "method-not-allowed" });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const chunks = [];
|
|
60
|
+
let total = 0;
|
|
61
|
+
let aborted = false;
|
|
62
|
+
req.on("data", (chunk) => {
|
|
63
|
+
if (aborted)
|
|
64
|
+
return;
|
|
65
|
+
total += chunk.length;
|
|
66
|
+
if (total > maxBodyBytes) {
|
|
67
|
+
aborted = true;
|
|
68
|
+
respond(413, { ok: false, error: "payload-too-large" });
|
|
69
|
+
req.destroy();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
chunks.push(chunk);
|
|
73
|
+
});
|
|
74
|
+
req.on("end", () => {
|
|
75
|
+
if (aborted)
|
|
76
|
+
return;
|
|
77
|
+
let payload;
|
|
78
|
+
try {
|
|
79
|
+
payload = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
respond(400, { ok: false, reason: "malformed" });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const result = acceptRemoteEnvelope(payload, {
|
|
86
|
+
resolvePublicKey: options.resolvePublicKey,
|
|
87
|
+
guard,
|
|
88
|
+
deliver: options.deliver,
|
|
89
|
+
now: options.now?.()
|
|
90
|
+
});
|
|
91
|
+
if (result.ok) {
|
|
92
|
+
respond(202, result);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
respond(rejectionStatus(result.reason), result);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/runtime/remote/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAyC,MAAM,gBAAgB,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAA2B,MAAM,aAAa,CAAC;AAiB5E,+DAA+D;AAC/D,MAAM,UAAU,eAAe,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EAAE,CAAC,CAAC;gBACjD,OAAO;YACT,CAAC;YACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,EAAE;gBAC3C,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;gBAC1C,KAAK;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE;aACrB,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/h2a-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Unified CLI surface for h2a hosts and MCP-oriented coordination flows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"skills"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@sentropic/h2a": "^0.2.
|
|
43
|
+
"@sentropic/h2a": "^0.2.8"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|