@procedures/peer 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +725 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/connection/index.d.ts +45 -0
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +148 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/discovery/index.d.ts +30 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +101 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/expose.d.ts +14 -0
- package/dist/expose.d.ts.map +1 -0
- package/dist/expose.js +16 -0
- package/dist/expose.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/input-schemas.d.ts +21 -0
- package/dist/input-schemas.d.ts.map +1 -0
- package/dist/input-schemas.js +80 -0
- package/dist/input-schemas.js.map +1 -0
- package/dist/lockfile.d.ts +48 -0
- package/dist/lockfile.d.ts.map +1 -0
- package/dist/lockfile.js +115 -0
- package/dist/lockfile.js.map +1 -0
- package/dist/manifest/index.d.ts +8 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +8 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/json.d.ts +27 -0
- package/dist/manifest/json.d.ts.map +1 -0
- package/dist/manifest/json.js +24 -0
- package/dist/manifest/json.js.map +1 -0
- package/dist/manifest/typescript.d.ts +17 -0
- package/dist/manifest/typescript.d.ts.map +1 -0
- package/dist/manifest/typescript.js +123 -0
- package/dist/manifest/typescript.js.map +1 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +42 -0
- package/dist/module.js.map +1 -0
- package/dist/output-schemas.d.ts +21 -0
- package/dist/output-schemas.d.ts.map +1 -0
- package/dist/output-schemas.js +85 -0
- package/dist/output-schemas.js.map +1 -0
- package/dist/peer/index.d.ts +47 -0
- package/dist/peer/index.d.ts.map +1 -0
- package/dist/peer/index.js +234 -0
- package/dist/peer/index.js.map +1 -0
- package/dist/peer/security.d.ts +25 -0
- package/dist/peer/security.d.ts.map +1 -0
- package/dist/peer/security.js +58 -0
- package/dist/peer/security.js.map +1 -0
- package/dist/procedures/index.d.ts +24 -0
- package/dist/procedures/index.d.ts.map +1 -0
- package/dist/procedures/index.js +15 -0
- package/dist/procedures/index.js.map +1 -0
- package/dist/procedures/manifest.generate.d.ts +11 -0
- package/dist/procedures/manifest.generate.d.ts.map +1 -0
- package/dist/procedures/manifest.generate.js +97 -0
- package/dist/procedures/manifest.generate.js.map +1 -0
- package/dist/procedures/server.call.d.ts +30 -0
- package/dist/procedures/server.call.d.ts.map +1 -0
- package/dist/procedures/server.call.js +60 -0
- package/dist/procedures/server.call.js.map +1 -0
- package/dist/procedures/server.connect.d.ts +11 -0
- package/dist/procedures/server.connect.d.ts.map +1 -0
- package/dist/procedures/server.connect.js +35 -0
- package/dist/procedures/server.connect.js.map +1 -0
- package/dist/procedures/server.connections.d.ts +22 -0
- package/dist/procedures/server.connections.d.ts.map +1 -0
- package/dist/procedures/server.connections.js +38 -0
- package/dist/procedures/server.connections.js.map +1 -0
- package/dist/procedures/server.create.d.ts +20 -0
- package/dist/procedures/server.create.d.ts.map +1 -0
- package/dist/procedures/server.create.js +64 -0
- package/dist/procedures/server.create.js.map +1 -0
- package/dist/procedures/server.disconnect.d.ts +11 -0
- package/dist/procedures/server.disconnect.d.ts.map +1 -0
- package/dist/procedures/server.disconnect.js +22 -0
- package/dist/procedures/server.disconnect.js.map +1 -0
- package/dist/procedures/server.start.d.ts +13 -0
- package/dist/procedures/server.start.d.ts.map +1 -0
- package/dist/procedures/server.start.js +179 -0
- package/dist/procedures/server.start.js.map +1 -0
- package/dist/procedures/server.status.d.ts +12 -0
- package/dist/procedures/server.status.d.ts.map +1 -0
- package/dist/procedures/server.status.js +116 -0
- package/dist/procedures/server.status.js.map +1 -0
- package/dist/procedures/server.stop.d.ts +11 -0
- package/dist/procedures/server.stop.d.ts.map +1 -0
- package/dist/procedures/server.stop.js +96 -0
- package/dist/procedures/server.stop.js.map +1 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +14 -0
- package/dist/register.js.map +1 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +14 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +192 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +87 -3
- package/src/connection/index.ts +219 -0
- package/src/discovery/index.ts +137 -0
- package/src/expose.ts +17 -0
- package/src/index.ts +69 -0
- package/src/input-schemas.ts +121 -0
- package/src/lockfile.ts +129 -0
- package/src/manifest/index.ts +8 -0
- package/src/manifest/json.ts +39 -0
- package/src/manifest/typescript.ts +148 -0
- package/src/module.ts +46 -0
- package/src/output-schemas.ts +110 -0
- package/src/peer/index.ts +325 -0
- package/src/peer/security.ts +58 -0
- package/src/procedures/index.ts +32 -0
- package/src/procedures/manifest.generate.ts +113 -0
- package/src/procedures/server.call.ts +96 -0
- package/src/procedures/server.connect.ts +45 -0
- package/src/procedures/server.connections.ts +64 -0
- package/src/procedures/server.create.ts +84 -0
- package/src/procedures/server.disconnect.ts +31 -0
- package/src/procedures/server.start.ts +209 -0
- package/src/procedures/server.status.ts +139 -0
- package/src/procedures/server.stop.ts +121 -0
- package/src/register.ts +17 -0
- package/src/schema.ts +15 -0
- package/src/types.ts +257 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request checks of a peer (deep dive TRN-1, CLI-1, CLI-2).
|
|
3
|
+
*
|
|
4
|
+
* A peer serves the whole registry, `shell.*` included. So:
|
|
5
|
+
* - a peer bound to loopback answers only requests addressed to a loopback name (a DNS
|
|
6
|
+
* rebinding attack sends another name);
|
|
7
|
+
* - a browser request is accepted only from a loopback origin or an origin in the allowlist
|
|
8
|
+
* (before, CORS was on by default with `Access-Control-Allow-Origin: *`, so any web page could
|
|
9
|
+
* call the server);
|
|
10
|
+
* - when the peer has a token, every request must carry it: `Authorization: Bearer <token>` over
|
|
11
|
+
* HTTP, `?token=<token>` for a WebSocket connection (a browser WebSocket cannot set headers).
|
|
12
|
+
*/
|
|
13
|
+
/** True for a bind address that only this computer can reach. */
|
|
14
|
+
export declare function isLoopback(host: string): boolean;
|
|
15
|
+
/** The name of a Host header without its port: "localhost:3000" gives "localhost", "[::1]:80" gives "[::1]". */
|
|
16
|
+
export declare function hostName(header: string | undefined): string;
|
|
17
|
+
/** A peer bound to loopback accepts only a loopback Host header. */
|
|
18
|
+
export declare function hostAllowed(bindHost: string, header: string | undefined): boolean;
|
|
19
|
+
/** A request without Origin (not a browser) passes; a browser origin must be loopback or in the allowlist. */
|
|
20
|
+
export declare function originAllowed(origin: string | undefined, allowlist?: readonly string[]): boolean;
|
|
21
|
+
/** True when no token is required, or when the presented token is the expected one (a constant-time comparison). */
|
|
22
|
+
export declare function tokenMatches(expected: string | undefined, presented: string | undefined | null): boolean;
|
|
23
|
+
/** The token of an `Authorization: Bearer <token>` header. */
|
|
24
|
+
export declare function bearerToken(header: string | undefined): string | undefined;
|
|
25
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/peer/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI3D;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEjF;AAED,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAQpG;AAED,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAMxG;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE1E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request checks of a peer (deep dive TRN-1, CLI-1, CLI-2).
|
|
3
|
+
*
|
|
4
|
+
* A peer serves the whole registry, `shell.*` included. So:
|
|
5
|
+
* - a peer bound to loopback answers only requests addressed to a loopback name (a DNS
|
|
6
|
+
* rebinding attack sends another name);
|
|
7
|
+
* - a browser request is accepted only from a loopback origin or an origin in the allowlist
|
|
8
|
+
* (before, CORS was on by default with `Access-Control-Allow-Origin: *`, so any web page could
|
|
9
|
+
* call the server);
|
|
10
|
+
* - when the peer has a token, every request must carry it: `Authorization: Bearer <token>` over
|
|
11
|
+
* HTTP, `?token=<token>` for a WebSocket connection (a browser WebSocket cannot set headers).
|
|
12
|
+
*/
|
|
13
|
+
import { timingSafeEqual } from "node:crypto";
|
|
14
|
+
const LOOPBACK_NAMES = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
15
|
+
/** True for a bind address that only this computer can reach. */
|
|
16
|
+
export function isLoopback(host) {
|
|
17
|
+
return LOOPBACK_NAMES.has(host);
|
|
18
|
+
}
|
|
19
|
+
/** The name of a Host header without its port: "localhost:3000" gives "localhost", "[::1]:80" gives "[::1]". */
|
|
20
|
+
export function hostName(header) {
|
|
21
|
+
if (!header)
|
|
22
|
+
return "";
|
|
23
|
+
if (header.startsWith("["))
|
|
24
|
+
return header.slice(0, header.indexOf("]") + 1).toLowerCase();
|
|
25
|
+
return (header.split(":")[0] ?? "").toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/** A peer bound to loopback accepts only a loopback Host header. */
|
|
28
|
+
export function hostAllowed(bindHost, header) {
|
|
29
|
+
return !isLoopback(bindHost) || LOOPBACK_NAMES.has(hostName(header));
|
|
30
|
+
}
|
|
31
|
+
/** A request without Origin (not a browser) passes; a browser origin must be loopback or in the allowlist. */
|
|
32
|
+
export function originAllowed(origin, allowlist = []) {
|
|
33
|
+
if (origin === undefined)
|
|
34
|
+
return true;
|
|
35
|
+
if (allowlist.includes(origin))
|
|
36
|
+
return true;
|
|
37
|
+
try {
|
|
38
|
+
return LOOPBACK_NAMES.has(new URL(origin).hostname);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** True when no token is required, or when the presented token is the expected one (a constant-time comparison). */
|
|
45
|
+
export function tokenMatches(expected, presented) {
|
|
46
|
+
if (expected === undefined)
|
|
47
|
+
return true;
|
|
48
|
+
if (!presented)
|
|
49
|
+
return false;
|
|
50
|
+
const a = Buffer.from(expected);
|
|
51
|
+
const b = Buffer.from(presented);
|
|
52
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
53
|
+
}
|
|
54
|
+
/** The token of an `Authorization: Bearer <token>` header. */
|
|
55
|
+
export function bearerToken(header) {
|
|
56
|
+
return header?.startsWith("Bearer ") ? header.slice("Bearer ".length) : undefined;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/peer/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,cA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QAA4B,EAAE,SAAoC;IAC7F,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,MAA0B;IACpD,OAAO,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Procedures
|
|
3
|
+
*
|
|
4
|
+
* All procedures exported from this module.
|
|
5
|
+
*/
|
|
6
|
+
export { serverCreateProcedure, getPeer, getActivePeerIds } from "./server.create.js";
|
|
7
|
+
export type { ServerCreateInput, ServerCreateOutput } from "./server.create.js";
|
|
8
|
+
export { serverConnectProcedure } from "./server.connect.js";
|
|
9
|
+
export type { ServerConnectInput, ServerConnectOutput } from "./server.connect.js";
|
|
10
|
+
export { serverDisconnectProcedure } from "./server.disconnect.js";
|
|
11
|
+
export type { ServerDisconnectInput, ServerDisconnectOutput } from "./server.disconnect.js";
|
|
12
|
+
export { manifestGenerateProcedure } from "./manifest.generate.js";
|
|
13
|
+
export type { ManifestGenerateInput, ManifestGenerateOutput } from "./manifest.generate.js";
|
|
14
|
+
export { serverStartProcedure } from "./server.start.js";
|
|
15
|
+
export type { ServerStartInput, ServerStartOutput } from "./server.start.js";
|
|
16
|
+
export { serverStopProcedure } from "./server.stop.js";
|
|
17
|
+
export type { ServerStopInput, ServerStopOutput } from "./server.stop.js";
|
|
18
|
+
export { serverStatusProcedure } from "./server.status.js";
|
|
19
|
+
export type { ServerStatusInput, ServerStatusOutput } from "./server.status.js";
|
|
20
|
+
export { serverCallProcedure } from "./server.call.js";
|
|
21
|
+
export type { ServerCallInput, ServerCallOutput } from "./server.call.js";
|
|
22
|
+
export { serverConnectionsProcedure } from "./server.connections.js";
|
|
23
|
+
export type { ServerConnectionsInput, ServerConnectionsOutput } from "./server.connections.js";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtF,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAE5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Procedures
|
|
3
|
+
*
|
|
4
|
+
* All procedures exported from this module.
|
|
5
|
+
*/
|
|
6
|
+
export { serverCreateProcedure, getPeer, getActivePeerIds } from "./server.create.js";
|
|
7
|
+
export { serverConnectProcedure } from "./server.connect.js";
|
|
8
|
+
export { serverDisconnectProcedure } from "./server.disconnect.js";
|
|
9
|
+
export { manifestGenerateProcedure } from "./manifest.generate.js";
|
|
10
|
+
export { serverStartProcedure } from "./server.start.js";
|
|
11
|
+
export { serverStopProcedure } from "./server.stop.js";
|
|
12
|
+
export { serverStatusProcedure } from "./server.status.js";
|
|
13
|
+
export { serverCallProcedure } from "./server.call.js";
|
|
14
|
+
export { serverConnectionsProcedure } from "./server.connections.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: manifest.generate
|
|
3
|
+
* Generates procedure manifests in various formats
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
import type { ManifestGenerateInput, ManifestGenerateOutput } from "../types.js";
|
|
7
|
+
export declare const manifestGenerateProcedure: Procedure<ManifestGenerateInput, ManifestGenerateOutput, {
|
|
8
|
+
description: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type { ManifestGenerateInput, ManifestGenerateOutput };
|
|
11
|
+
//# sourceMappingURL=manifest.generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.generate.d.ts","sourceRoot":"","sources":["../../src/procedures/manifest.generate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAsB,MAAM,oBAAoB,CAAC;AAIvG,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAiB,MAAM,aAAa,CAAC;AAShG,eAAO,MAAM,yBAAyB,EAAE,SAAS,CAC/C,qBAAqB,EACrB,sBAAsB,EACtB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CA8Ef,CAAC;AAaX,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: manifest.generate
|
|
3
|
+
* Generates procedure manifests in various formats
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure, jsonSchemaOf, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ManifestGenerateOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { manifestGenerateInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { generateTypeScript } from "../manifest/typescript.js";
|
|
10
|
+
import { generateJson } from "../manifest/json.js";
|
|
11
|
+
import { writeFile, mkdir } from "fs/promises";
|
|
12
|
+
import { join, dirname } from "path";
|
|
13
|
+
// Use pass-through schemas
|
|
14
|
+
const manifestGenerateOutputSchema = wrapSchema(ManifestGenerateOutputSchema);
|
|
15
|
+
export const manifestGenerateProcedure = createProcedure()
|
|
16
|
+
.path(["manifest", "generate"])
|
|
17
|
+
.input(manifestGenerateInputSchema)
|
|
18
|
+
.output(manifestGenerateOutputSchema)
|
|
19
|
+
.meta({ description: "Generate procedure manifests in various formats" })
|
|
20
|
+
.handler(async (input) => {
|
|
21
|
+
// Get all registered procedures
|
|
22
|
+
const allProcedures = PROCEDURE_REGISTRY.getAll();
|
|
23
|
+
// Filter by namespace if specified
|
|
24
|
+
let procedures = allProcedures;
|
|
25
|
+
if (input.namespace && input.namespace.length > 0) {
|
|
26
|
+
procedures = allProcedures.filter((proc) => {
|
|
27
|
+
// Check if procedure path starts with namespace
|
|
28
|
+
for (let i = 0; i < input.namespace.length; i++) {
|
|
29
|
+
if (proc.path[i] !== input.namespace[i]) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Convert to ProcedureInfo format
|
|
37
|
+
const procedureInfos = procedures.map((proc) => {
|
|
38
|
+
const meta = proc.metadata;
|
|
39
|
+
const info = {
|
|
40
|
+
path: proc.path,
|
|
41
|
+
};
|
|
42
|
+
if (meta?.description !== undefined) {
|
|
43
|
+
info.description = meta.description;
|
|
44
|
+
}
|
|
45
|
+
// The JSON Schemas of the input and the output, when the schemas can describe themselves
|
|
46
|
+
const inputSchema = jsonSchemaOf(proc.input, { io: "input" });
|
|
47
|
+
const outputSchema = jsonSchemaOf(proc.output, { io: "output" });
|
|
48
|
+
if (inputSchema)
|
|
49
|
+
info.inputSchema = inputSchema;
|
|
50
|
+
if (outputSchema)
|
|
51
|
+
info.outputSchema = outputSchema;
|
|
52
|
+
return info;
|
|
53
|
+
});
|
|
54
|
+
// Determine formats to generate
|
|
55
|
+
const formats = input.formats ?? ["json"];
|
|
56
|
+
const result = {};
|
|
57
|
+
const filesWritten = [];
|
|
58
|
+
// Generate JSON manifest
|
|
59
|
+
if (formats.includes("json")) {
|
|
60
|
+
const jsonManifest = generateJson(procedureInfos);
|
|
61
|
+
result.json = jsonManifest;
|
|
62
|
+
if (input.outputDir) {
|
|
63
|
+
const filePath = join(input.outputDir, "procedures.json");
|
|
64
|
+
await ensureDir(dirname(filePath));
|
|
65
|
+
await writeFile(filePath, JSON.stringify(jsonManifest, null, 2));
|
|
66
|
+
filesWritten.push(filePath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Generate TypeScript declarations
|
|
70
|
+
if (formats.includes("typescript")) {
|
|
71
|
+
const typescript = generateTypeScript(procedureInfos);
|
|
72
|
+
result.typescript = typescript;
|
|
73
|
+
if (input.outputDir) {
|
|
74
|
+
const filePath = join(input.outputDir, "procedures.d.ts");
|
|
75
|
+
await ensureDir(dirname(filePath));
|
|
76
|
+
await writeFile(filePath, typescript);
|
|
77
|
+
filesWritten.push(filePath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (filesWritten.length > 0) {
|
|
81
|
+
result.filesWritten = filesWritten;
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
})
|
|
85
|
+
.build();
|
|
86
|
+
/**
|
|
87
|
+
* Ensure directory exists
|
|
88
|
+
*/
|
|
89
|
+
async function ensureDir(dir) {
|
|
90
|
+
try {
|
|
91
|
+
await mkdir(dir, { recursive: true });
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Directory may already exist
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=manifest.generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.generate.js","sourceRoot":"","sources":["../../src/procedures/manifest.generate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAkB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC,2BAA2B;AAC3B,MAAM,4BAA4B,GAAG,UAAU,CAAyB,4BAA4B,CAAC,CAAC;AAEtG,MAAM,CAAC,MAAM,yBAAyB,GAIlC,eAAe,EAAE;KAClB,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;KAC9B,KAAK,CAAC,2BAA2B,CAAC;KAClC,MAAM,CAAC,4BAA4B,CAAC;KACpC,IAAI,CAAC,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;KACxE,OAAO,CAAC,KAAK,EAAE,KAA4B,EAAE,EAAE;IAC9C,gCAAgC;IAChC,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC;IAElD,mCAAmC;IACnC,IAAI,UAAU,GAAG,aAAa,CAAC;IAC/B,IAAI,KAAK,CAAC,SA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,YAAY,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX;;GAEG;AACH,KAAK,UAAU,SAAS,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,8BAA8B;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.call
|
|
3
|
+
* Call a procedure on a remote peer through an outbound connection
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
export interface ServerCallInput {
|
|
7
|
+
/** Connection ID (from server.connect) */
|
|
8
|
+
connectionId?: string | undefined;
|
|
9
|
+
/** Remote address (alternative to connectionId - creates one-shot connection) */
|
|
10
|
+
address?: string | undefined;
|
|
11
|
+
/** Procedure path on the remote peer - dot-separated string or array */
|
|
12
|
+
path: string | string[];
|
|
13
|
+
/** Input payload for the remote procedure */
|
|
14
|
+
input?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface ServerCallOutput {
|
|
17
|
+
/** Result from the remote procedure */
|
|
18
|
+
result: unknown;
|
|
19
|
+
/** Connection ID used */
|
|
20
|
+
connectionId: string;
|
|
21
|
+
/** Procedure path called */
|
|
22
|
+
path: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare const serverCallProcedure: Procedure<ServerCallInput, ServerCallOutput, {
|
|
25
|
+
description: string;
|
|
26
|
+
args: string[];
|
|
27
|
+
shorts: Record<string, string>;
|
|
28
|
+
output: string;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=server.call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.call.d.ts","sourceRoot":"","sources":["../../src/procedures/server.call.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAUnF,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,wEAAwE;IACxE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAQD,eAAO,MAAM,mBAAmB,EAAE,SAAS,CACzC,eAAe,EACf,gBAAgB,EAChB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmD/E,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.call
|
|
3
|
+
* Call a procedure on a remote peer through an outbound connection
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure, pathToMethod } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ServerCallOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { serverCallInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { getConnection, connect } from "../connection/index.js";
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Procedure
|
|
12
|
+
// =============================================================================
|
|
13
|
+
const serverCallOutputSchema = wrapSchema(ServerCallOutputSchema);
|
|
14
|
+
export const serverCallProcedure = createProcedure()
|
|
15
|
+
.path(["server", "call"])
|
|
16
|
+
.input(serverCallInputSchema)
|
|
17
|
+
.output(serverCallOutputSchema)
|
|
18
|
+
.meta({
|
|
19
|
+
description: "Call a procedure on a remote peer through an outbound connection",
|
|
20
|
+
args: ["path"],
|
|
21
|
+
shorts: { connectionId: "c", address: "a" },
|
|
22
|
+
output: "json",
|
|
23
|
+
})
|
|
24
|
+
.handler(async (input) => {
|
|
25
|
+
// Normalize path: accept dot-separated string or array
|
|
26
|
+
const pathArray = typeof input.path === "string"
|
|
27
|
+
? input.path.split(".")
|
|
28
|
+
: input.path;
|
|
29
|
+
// Resolve connection: by ID, or create one-shot from address
|
|
30
|
+
let connectionId;
|
|
31
|
+
let client;
|
|
32
|
+
if (input.connectionId) {
|
|
33
|
+
const connection = getConnection(input.connectionId);
|
|
34
|
+
if (!connection) {
|
|
35
|
+
throw new Error(`Connection not found: ${input.connectionId}. Use 'server connect' first, or pass --address.`);
|
|
36
|
+
}
|
|
37
|
+
connectionId = connection.id;
|
|
38
|
+
client = connection.client;
|
|
39
|
+
}
|
|
40
|
+
else if (input.address) {
|
|
41
|
+
// Create a connection on-the-fly
|
|
42
|
+
const connection = await connect({ address: input.address });
|
|
43
|
+
connectionId = connection.id;
|
|
44
|
+
client = connection.client;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Error("Either connectionId or address is required");
|
|
48
|
+
}
|
|
49
|
+
// Convert procedure path to Method format for client.call: the core mapping of every host
|
|
50
|
+
// (deep dive architecture review 3.3)
|
|
51
|
+
const method = pathToMethod(pathArray);
|
|
52
|
+
const result = await client.call(method, input.input ?? {});
|
|
53
|
+
return {
|
|
54
|
+
result,
|
|
55
|
+
connectionId,
|
|
56
|
+
path: pathArray,
|
|
57
|
+
};
|
|
58
|
+
})
|
|
59
|
+
.build();
|
|
60
|
+
//# sourceMappingURL=server.call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.call.js","sourceRoot":"","sources":["../../src/procedures/server.call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;YAChB,MAAM,IAAI,KAAK,CACb,yBAAyB,KAAK,CAAC,YAAY,kDAAkD,CAC9F,CAAC;QACJ,CAAC;QACD,YAAY,GAAG,UAAU,CAAC,EAAE,CAAC;QAC7B,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,iCAAiC;QACjC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,YAAY,GAAG,UAAU,CAAC,EAAE,CAAC;QAC7B,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,0FAA0F;IAC1F,sCAAsC;IACtC,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAE5D,OAAO;QACL,MAAM;QACN,YAAY;QACZ,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.connect
|
|
3
|
+
* Connects to a remote peer for bidirectional RPC
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
import type { ServerConnectInput, ServerConnectOutput } from "../types.js";
|
|
7
|
+
export declare const serverConnectProcedure: Procedure<ServerConnectInput, ServerConnectOutput, {
|
|
8
|
+
description: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type { ServerConnectInput, ServerConnectOutput };
|
|
11
|
+
//# sourceMappingURL=server.connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.connect.d.ts","sourceRoot":"","sources":["../../src/procedures/server.connect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAM3E,eAAO,MAAM,sBAAsB,EAAE,SAAS,CAC5C,kBAAkB,EAClB,mBAAmB,EACnB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAwBf,CAAC;AAEX,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.connect
|
|
3
|
+
* Connects to a remote peer for bidirectional RPC
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ServerConnectOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { serverConnectInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { connect } from "../connection/index.js";
|
|
10
|
+
// Use pass-through schemas
|
|
11
|
+
const serverConnectOutputSchema = wrapSchema(ServerConnectOutputSchema);
|
|
12
|
+
export const serverConnectProcedure = createProcedure()
|
|
13
|
+
.path(["server", "connect"])
|
|
14
|
+
.input(serverConnectInputSchema)
|
|
15
|
+
.output(serverConnectOutputSchema)
|
|
16
|
+
.meta({ description: "Connect to a remote peer for bidirectional RPC", args: ["address"] })
|
|
17
|
+
.handler(async (input) => {
|
|
18
|
+
const connectOptions = {
|
|
19
|
+
address: input.address,
|
|
20
|
+
};
|
|
21
|
+
if (input.transport !== undefined) {
|
|
22
|
+
connectOptions.transport = input.transport;
|
|
23
|
+
}
|
|
24
|
+
if (input.timeout !== undefined) {
|
|
25
|
+
connectOptions.timeout = input.timeout;
|
|
26
|
+
}
|
|
27
|
+
const connection = await connect(connectOptions);
|
|
28
|
+
return {
|
|
29
|
+
connectionId: connection.id,
|
|
30
|
+
remotePeerId: connection.remote.remotePeerId,
|
|
31
|
+
remoteProcedures: connection.remote.remoteProcedures,
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
.build();
|
|
35
|
+
//# sourceMappingURL=server.connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.connect.js","sourceRoot":"","sources":["../../src/procedures/server.connect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,2BAA2B;AAC3B,MAAM,yBAAyB,GAAG,UAAU,CAAsB,yBAAyB,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,sBAAsB,GAI/B,eAAe,EAAE;KAClB,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;KAC3B,KAAK,CAAC,wBAAwB,CAAC;KAC/B,MAAM,CAAC,yBAAyB,CAAC;KACjC,IAAI,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;KAC1F,OAAO,CAAC,KAAK,EAAE,KAAyB,EAAE,EAAE;IAC3C,MAAM,cAAc,GAAkC;QACpD,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;IACF,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAClC,cAAc,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAC7C,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IACzC,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAEjD,OAAO;QACL,YAAY,EAAE,UAAU,CAAC,EAAE;QAC3B,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY;QAC5C,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB;KACrD,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.connections
|
|
3
|
+
* List all outbound connections to remote peers
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
export interface ServerConnectionsInput {
|
|
7
|
+
}
|
|
8
|
+
export interface ServerConnectionsOutput {
|
|
9
|
+
connections: Array<{
|
|
10
|
+
connectionId: string;
|
|
11
|
+
remotePeerId: string;
|
|
12
|
+
transport: string;
|
|
13
|
+
state: string;
|
|
14
|
+
remoteProcedureCount: number;
|
|
15
|
+
connectedAt?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export declare const serverConnectionsProcedure: Procedure<ServerConnectionsInput, ServerConnectionsOutput, {
|
|
19
|
+
description: string;
|
|
20
|
+
output: string;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=server.connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.connections.d.ts","sourceRoot":"","sources":["../../src/procedures/server.connections.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAUrE,MAAM,WAAW,sBAAsB;CAEtC;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,KAAK,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,oBAAoB,EAAE,MAAM,CAAC;QAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC,CAAC,CAAC;CACJ;AAQD,eAAO,MAAM,0BAA0B,EAAE,SAAS,CAChD,sBAAsB,EACtB,uBAAuB,EACvB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAwB/B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.connections
|
|
3
|
+
* List all outbound connections to remote peers
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ServerConnectionsOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { serverConnectionsInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { getConnectionIds, getConnection } from "../connection/index.js";
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Procedure
|
|
12
|
+
// =============================================================================
|
|
13
|
+
const serverConnectionsOutputSchema = wrapSchema(ServerConnectionsOutputSchema);
|
|
14
|
+
export const serverConnectionsProcedure = createProcedure()
|
|
15
|
+
.path(["server", "connections"])
|
|
16
|
+
.input(serverConnectionsInputSchema)
|
|
17
|
+
.output(serverConnectionsOutputSchema)
|
|
18
|
+
.meta({
|
|
19
|
+
description: "List outbound connections to remote peers",
|
|
20
|
+
output: "json",
|
|
21
|
+
})
|
|
22
|
+
.handler(async () => {
|
|
23
|
+
const ids = getConnectionIds();
|
|
24
|
+
const connections = ids.map((id) => {
|
|
25
|
+
const conn = getConnection(id);
|
|
26
|
+
return {
|
|
27
|
+
connectionId: conn.id,
|
|
28
|
+
remotePeerId: conn.remote.remotePeerId,
|
|
29
|
+
transport: conn.remote.transport,
|
|
30
|
+
state: conn.remote.state,
|
|
31
|
+
remoteProcedureCount: conn.remote.remoteProcedures.length,
|
|
32
|
+
connectedAt: conn.remote.connectedAt?.toISOString(),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return { connections };
|
|
36
|
+
})
|
|
37
|
+
.build();
|
|
38
|
+
//# sourceMappingURL=server.connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.connections.js","sourceRoot":"","sources":["../../src/procedures/server.connections.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAqBzE,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,6BAA6B,GAAG,UAAU,CAA0B,6BAA6B,CAAC,CAAC;AAEzG,MAAM,CAAC,MAAM,0BAA0B,GAInC,eAAe,EAAE;KAClB,IAAI,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;KAC/B,KAAK,CAAC,4BAA4B,CAAC;KACnC,MAAM,CAAC,6BAA6B,CAAC;KACrC,IAAI,CAAC;IACJ,WAAW,EAAE,2CAA2C;IACxD,MAAM,EAAE,MAAM;CACf,CAAC;KACD,OAAO,CAAC,KAAK,IAAsC,EAAE;IACpD,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,CAAE,CAAC;QAChC,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,EAAE;YACrB,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACtC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM;YACzD,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE;SACpD,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.create
|
|
3
|
+
* Creates a transport-agnostic peer that exposes procedures
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
import type { ServerCreateInput, ServerCreateOutput } from "../types.js";
|
|
7
|
+
import { type Peer } from "../peer/index.js";
|
|
8
|
+
export declare const serverCreateProcedure: Procedure<ServerCreateInput, ServerCreateOutput, {
|
|
9
|
+
description: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Get an active peer by ID
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPeer(serverId: string): Peer | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get all active peer IDs
|
|
17
|
+
*/
|
|
18
|
+
export declare function getActivePeerIds(): string[];
|
|
19
|
+
export type { ServerCreateInput, ServerCreateOutput };
|
|
20
|
+
//# sourceMappingURL=server.create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.create.d.ts","sourceRoot":"","sources":["../../src/procedures/server.create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,SAAS,EAAsB,MAAM,oBAAoB,CAAC;AAIzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AASzD,eAAO,MAAM,qBAAqB,EAAE,SAAS,CAC3C,iBAAiB,EACjB,kBAAkB,EAClB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CA6Cf,CAAC;AAEX;;GAEG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAE1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.create
|
|
3
|
+
* Creates a transport-agnostic peer that exposes procedures
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ServerCreateOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { serverCreateInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { createPeer } from "../peer/index.js";
|
|
10
|
+
import { exposeRule } from "../expose.js";
|
|
11
|
+
// Use pass-through schemas for simplicity (validation happens at Zod level if needed)
|
|
12
|
+
const serverCreateOutputSchema = wrapSchema(ServerCreateOutputSchema);
|
|
13
|
+
// Active peers (module-level state for now, could be in context)
|
|
14
|
+
const activePeers = new Map();
|
|
15
|
+
export const serverCreateProcedure = createProcedure()
|
|
16
|
+
.path(["server", "create"])
|
|
17
|
+
.input(serverCreateInputSchema)
|
|
18
|
+
.output(serverCreateOutputSchema)
|
|
19
|
+
.meta({ description: "Create a transport-agnostic peer that exposes procedures" })
|
|
20
|
+
.handler(async (input) => {
|
|
21
|
+
// Generate unique server ID
|
|
22
|
+
const serverId = `peer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
23
|
+
// Default transports if not specified
|
|
24
|
+
// A server-wide token goes to each transport that has none of its own
|
|
25
|
+
const transports = (input.transports ?? [{ type: "http", port: 3000 }]).map((transport) => transport.type === "local" || input.token === undefined || transport.token !== undefined
|
|
26
|
+
? transport
|
|
27
|
+
: { ...transport, token: input.token });
|
|
28
|
+
const autoRegister = input.autoRegister ?? true;
|
|
29
|
+
// Create peer with configured transports
|
|
30
|
+
const peer = await createPeer({
|
|
31
|
+
id: serverId,
|
|
32
|
+
transports,
|
|
33
|
+
autoRegister,
|
|
34
|
+
registry: PROCEDURE_REGISTRY,
|
|
35
|
+
...(input.expose ? { expose: exposeRule(input.expose) } : {}),
|
|
36
|
+
});
|
|
37
|
+
// Start the peer
|
|
38
|
+
await peer.start();
|
|
39
|
+
// Store for later reference
|
|
40
|
+
activePeers.set(serverId, peer);
|
|
41
|
+
// Get procedure count
|
|
42
|
+
const procedureCount = input.autoRegister
|
|
43
|
+
? PROCEDURE_REGISTRY.getAll().filter((p) => p.handler).length
|
|
44
|
+
: 0;
|
|
45
|
+
return {
|
|
46
|
+
serverId,
|
|
47
|
+
endpoints: peer.getEndpoints(),
|
|
48
|
+
procedureCount,
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
.build();
|
|
52
|
+
/**
|
|
53
|
+
* Get an active peer by ID
|
|
54
|
+
*/
|
|
55
|
+
export function getPeer(serverId) {
|
|
56
|
+
return activePeers.get(serverId);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get all active peer IDs
|
|
60
|
+
*/
|
|
61
|
+
export function getActivePeerIds() {
|
|
62
|
+
return Array.from(activePeers.keys());
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=server.create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.create.js","sourceRoot":"","sources":["../../src/procedures/server.create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAkB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MA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CAAC,YAAY,IAAI,IAAI,CAAC;IAEhD,yCAAyC;IACzC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC;QAC5B,EAAE,EAAE,QAAQ;QACZ,UAAU;QACV,YAAY;QACZ,QAAQ,EAAE,kBAAkB;QAC5B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC,CAAC;IAEH,iBAAiB;IACjB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAEnB,4BAA4B;IAC5B,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEhC,sBAAsB;IACtB,MAAM,cAAc,GAAG,KAAK,CAAC,YAAY;QACvC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;QAC7D,CAAC,CAAC,CAAC,CAAC;IAEN,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;QAC9B,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.disconnect
|
|
3
|
+
* Disconnects from a remote peer
|
|
4
|
+
*/
|
|
5
|
+
import { type Procedure } from "@procedures/client";
|
|
6
|
+
import type { ServerDisconnectInput, ServerDisconnectOutput } from "../types.js";
|
|
7
|
+
export declare const serverDisconnectProcedure: Procedure<ServerDisconnectInput, ServerDisconnectOutput, {
|
|
8
|
+
description: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type { ServerDisconnectInput, ServerDisconnectOutput };
|
|
11
|
+
//# sourceMappingURL=server.disconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.disconnect.d.ts","sourceRoot":"","sources":["../../src/procedures/server.disconnect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAMjF,eAAO,MAAM,yBAAyB,EAAE,SAAS,CAC/C,qBAAqB,EACrB,sBAAsB,EACtB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAUf,CAAC;AAEX,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure: server.disconnect
|
|
3
|
+
* Disconnects from a remote peer
|
|
4
|
+
*/
|
|
5
|
+
import { createProcedure } from "@procedures/client";
|
|
6
|
+
import { wrapSchema } from "../schema.js";
|
|
7
|
+
import { ServerDisconnectOutputSchema } from "../output-schemas.js";
|
|
8
|
+
import { serverDisconnectInputSchema } from "../input-schemas.js";
|
|
9
|
+
import { disconnect } from "../connection/index.js";
|
|
10
|
+
// Use pass-through schemas
|
|
11
|
+
const serverDisconnectOutputSchema = wrapSchema(ServerDisconnectOutputSchema);
|
|
12
|
+
export const serverDisconnectProcedure = createProcedure()
|
|
13
|
+
.path(["server", "disconnect"])
|
|
14
|
+
.input(serverDisconnectInputSchema)
|
|
15
|
+
.output(serverDisconnectOutputSchema)
|
|
16
|
+
.meta({ description: "Disconnect from a remote peer", args: ["connectionId"] })
|
|
17
|
+
.handler(async (input) => {
|
|
18
|
+
const success = await disconnect(input.connectionId);
|
|
19
|
+
return { success };
|
|
20
|
+
})
|
|
21
|
+
.build();
|
|
22
|
+
//# sourceMappingURL=server.disconnect.js.map
|