@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,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Declaration Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates .d.ts files from procedure definitions
|
|
5
|
+
* for static type checking on clients.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate TypeScript declaration file content
|
|
9
|
+
*/
|
|
10
|
+
export function generateTypeScript(procedures) {
|
|
11
|
+
const lines = [
|
|
12
|
+
"/**",
|
|
13
|
+
" * Auto-generated procedure type declarations",
|
|
14
|
+
` * Generated at: ${new Date().toISOString()}`,
|
|
15
|
+
" */",
|
|
16
|
+
"",
|
|
17
|
+
];
|
|
18
|
+
// Group procedures by namespace (first path segment)
|
|
19
|
+
const namespaces = new Map();
|
|
20
|
+
for (const proc of procedures) {
|
|
21
|
+
const namespace = proc.path[0] ?? "root";
|
|
22
|
+
const existing = namespaces.get(namespace) ?? [];
|
|
23
|
+
existing.push(proc);
|
|
24
|
+
namespaces.set(namespace, existing);
|
|
25
|
+
}
|
|
26
|
+
// Generate interface for each namespace
|
|
27
|
+
for (const [namespace, procs] of namespaces) {
|
|
28
|
+
lines.push(`export interface ${pascalCase(namespace)}Procedures {`);
|
|
29
|
+
for (const proc of procs) {
|
|
30
|
+
const path = proc.path.slice(1);
|
|
31
|
+
const methodName = path.join("_") || namespace;
|
|
32
|
+
if (proc.description) {
|
|
33
|
+
lines.push(` /** ${proc.description} */`);
|
|
34
|
+
}
|
|
35
|
+
// The types come from the JSON Schemas; a procedure without one has `unknown`
|
|
36
|
+
lines.push(` ${camelCase(methodName)}: {`);
|
|
37
|
+
lines.push(` path: ${JSON.stringify(proc.path)};`);
|
|
38
|
+
lines.push(` input: ${jsonSchemaToTs(proc.inputSchema, " ")};`);
|
|
39
|
+
lines.push(` output: ${jsonSchemaToTs(proc.outputSchema, " ")};`);
|
|
40
|
+
lines.push(` };`);
|
|
41
|
+
}
|
|
42
|
+
lines.push(`}`);
|
|
43
|
+
lines.push("");
|
|
44
|
+
}
|
|
45
|
+
// Generate combined type
|
|
46
|
+
lines.push("export interface RemoteProcedures {");
|
|
47
|
+
for (const namespace of namespaces.keys()) {
|
|
48
|
+
lines.push(` ${camelCase(namespace)}: ${pascalCase(namespace)}Procedures;`);
|
|
49
|
+
}
|
|
50
|
+
lines.push("}");
|
|
51
|
+
lines.push("");
|
|
52
|
+
return lines.join("\n");
|
|
53
|
+
}
|
|
54
|
+
/** A property name as TypeScript writes it: quoted when it is not an identifier. */
|
|
55
|
+
function propertyName(name) {
|
|
56
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The TypeScript type of a JSON Schema: objects, arrays, records, enums, constants and unions.
|
|
60
|
+
* A schema that it cannot read is `unknown`.
|
|
61
|
+
*/
|
|
62
|
+
export function jsonSchemaToTs(schema, indent = "") {
|
|
63
|
+
if (!schema || typeof schema !== "object")
|
|
64
|
+
return "unknown";
|
|
65
|
+
const node = schema;
|
|
66
|
+
const union = node.anyOf ?? node.oneOf;
|
|
67
|
+
if (union?.length)
|
|
68
|
+
return union.map((member) => jsonSchemaToTs(member, indent)).join(" | ");
|
|
69
|
+
if (node.allOf?.length)
|
|
70
|
+
return node.allOf.map((member) => jsonSchemaToTs(member, indent)).join(" & ");
|
|
71
|
+
if (Array.isArray(node.enum))
|
|
72
|
+
return node.enum.map((value) => JSON.stringify(value)).join(" | ") || "never";
|
|
73
|
+
if (node.const !== undefined)
|
|
74
|
+
return JSON.stringify(node.const);
|
|
75
|
+
const types = Array.isArray(node.type) ? node.type : node.type ? [node.type] : [];
|
|
76
|
+
if (types.length > 1)
|
|
77
|
+
return types.map((type) => jsonSchemaToTs({ ...node, type }, indent)).join(" | ");
|
|
78
|
+
switch (types[0]) {
|
|
79
|
+
case "string":
|
|
80
|
+
return "string";
|
|
81
|
+
case "number":
|
|
82
|
+
case "integer":
|
|
83
|
+
return "number";
|
|
84
|
+
case "boolean":
|
|
85
|
+
return "boolean";
|
|
86
|
+
case "null":
|
|
87
|
+
return "null";
|
|
88
|
+
case "array":
|
|
89
|
+
return Array.isArray(node.items)
|
|
90
|
+
? `[${node.items.map((part) => jsonSchemaToTs(part, indent)).join(", ")}]`
|
|
91
|
+
: `Array<${jsonSchemaToTs(node.items, indent)}>`;
|
|
92
|
+
case "object": {
|
|
93
|
+
const properties = Object.entries(node.properties ?? {});
|
|
94
|
+
const extra = node.additionalProperties;
|
|
95
|
+
if (properties.length === 0) {
|
|
96
|
+
return extra && typeof extra === "object" ? `Record<string, ${jsonSchemaToTs(extra, indent)}>` : "Record<string, unknown>";
|
|
97
|
+
}
|
|
98
|
+
const required = new Set(node.required ?? []);
|
|
99
|
+
const inner = `${indent} `;
|
|
100
|
+
const members = properties.map(([name, value]) => `${inner}${propertyName(name)}${required.has(name) ? "" : "?"}: ${jsonSchemaToTs(value, inner)};`);
|
|
101
|
+
return `{\n${members.join("\n")}\n${indent}}`;
|
|
102
|
+
}
|
|
103
|
+
default:
|
|
104
|
+
return "unknown";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Convert string to PascalCase
|
|
109
|
+
*/
|
|
110
|
+
function pascalCase(str) {
|
|
111
|
+
return str
|
|
112
|
+
.split(/[-_\s]+/)
|
|
113
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
114
|
+
.join("");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Convert string to camelCase
|
|
118
|
+
*/
|
|
119
|
+
function camelCase(str) {
|
|
120
|
+
const pascal = pascalCase(str);
|
|
121
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/manifest/typescript.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAA2B;IAC5D,MAAM,KAAK,GAAa;QACtB,KAAK;QACL,+CAA+C;QAC/C,oBAAoB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;QAC9C,KAAK;QACL,EAAE;KACH,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I,CAAC,IAAI,CAAC,KAAK,MAAM,GAAG,CAAC;QAChD,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,KAAK,CAAC,SAAS,CAAC;SAChB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACzE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module (no side effects): the procedures of this package as data, for `createRegistry()`.
|
|
3
|
+
*
|
|
4
|
+
* Procedure Registration
|
|
5
|
+
*
|
|
6
|
+
* Registers server procedures with the client system.
|
|
7
|
+
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*/
|
|
9
|
+
import { type AnyProcedure, type ProcedureModule } from "@procedures/client";
|
|
10
|
+
/**
|
|
11
|
+
* All server procedures
|
|
12
|
+
*/
|
|
13
|
+
export declare const procedures: readonly AnyProcedure[];
|
|
14
|
+
/**
|
|
15
|
+
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
16
|
+
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
17
|
+
*/
|
|
18
|
+
export declare const serverModule: ProcedureModule;
|
|
19
|
+
export default serverModule;
|
|
20
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAgB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAc3F;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,YAAY,EAW7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,eAAmE,CAAC;eAEhF,YAAY"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module (no side effects): the procedures of this package as data, for `createRegistry()`.
|
|
3
|
+
*
|
|
4
|
+
* Procedure Registration
|
|
5
|
+
*
|
|
6
|
+
* Registers server procedures with the client system.
|
|
7
|
+
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*/
|
|
9
|
+
import { defineModule } from "@procedures/client";
|
|
10
|
+
// Import all procedures
|
|
11
|
+
import { serverCreateProcedure } from "./procedures/server.create.js";
|
|
12
|
+
import { serverConnectProcedure } from "./procedures/server.connect.js";
|
|
13
|
+
import { serverDisconnectProcedure } from "./procedures/server.disconnect.js";
|
|
14
|
+
import { manifestGenerateProcedure } from "./procedures/manifest.generate.js";
|
|
15
|
+
import { discoveryAnnounceProcedure } from "./discovery/index.js";
|
|
16
|
+
import { serverStartProcedure } from "./procedures/server.start.js";
|
|
17
|
+
import { serverStopProcedure } from "./procedures/server.stop.js";
|
|
18
|
+
import { serverStatusProcedure } from "./procedures/server.status.js";
|
|
19
|
+
import { serverCallProcedure } from "./procedures/server.call.js";
|
|
20
|
+
import { serverConnectionsProcedure } from "./procedures/server.connections.js";
|
|
21
|
+
/**
|
|
22
|
+
* All server procedures
|
|
23
|
+
*/
|
|
24
|
+
export const procedures = [
|
|
25
|
+
serverCreateProcedure,
|
|
26
|
+
serverConnectProcedure,
|
|
27
|
+
serverDisconnectProcedure,
|
|
28
|
+
manifestGenerateProcedure,
|
|
29
|
+
discoveryAnnounceProcedure,
|
|
30
|
+
serverStartProcedure,
|
|
31
|
+
serverStopProcedure,
|
|
32
|
+
serverStatusProcedure,
|
|
33
|
+
serverCallProcedure,
|
|
34
|
+
serverConnectionsProcedure,
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
38
|
+
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
39
|
+
*/
|
|
40
|
+
export const serverModule = defineModule("@procedures/peer", [...procedures]);
|
|
41
|
+
export default serverModule;
|
|
42
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAqB,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAE3F,wBAAwB;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,qBAAqB;IACrB,sBAAsB;IACtB,yBAAyB;IACzB,yBAAyB;IACzB,0BAA0B;IAC1B,oBAAoB;IACpB,mBAAmB;IACnB,qBAAqB;IACrB,mBAAmB;IACnB,0BAA0B;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAoB,YAAY,CAAC,kBAAkB,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;AAE/F,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The output schemas of the server.* and manifest.* procedures (roadmap 2.1).
|
|
3
|
+
*
|
|
4
|
+
* Loose objects: a field that a schema does not name stays in the result (a strict schema would
|
|
5
|
+
* remove it when the output is validated). Each schema is a `z.ZodType` of its output type, so
|
|
6
|
+
* the compiler checks it against the type.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import type { ManifestGenerateOutput, ServerConnectOutput, ServerCreateOutput, ServerDisconnectOutput, ServerStartOutput, ServerStatusOutput, ServerStopOutput } from "./types.js";
|
|
10
|
+
import type { ServerCallOutput } from "./procedures/server.call.js";
|
|
11
|
+
import type { ServerConnectionsOutput } from "./procedures/server.connections.js";
|
|
12
|
+
export declare const ServerCreateOutputSchema: z.ZodType<ServerCreateOutput>;
|
|
13
|
+
export declare const ServerConnectOutputSchema: z.ZodType<ServerConnectOutput>;
|
|
14
|
+
export declare const ServerDisconnectOutputSchema: z.ZodType<ServerDisconnectOutput>;
|
|
15
|
+
export declare const ManifestGenerateOutputSchema: z.ZodType<ManifestGenerateOutput>;
|
|
16
|
+
export declare const ServerStartOutputSchema: z.ZodType<ServerStartOutput>;
|
|
17
|
+
export declare const ServerStopOutputSchema: z.ZodType<ServerStopOutput>;
|
|
18
|
+
export declare const ServerStatusOutputSchema: z.ZodType<ServerStatusOutput>;
|
|
19
|
+
export declare const ServerCallOutputSchema: z.ZodType<ServerCallOutput>;
|
|
20
|
+
export declare const ServerConnectionsOutputSchema: z.ZodType<ServerConnectionsOutput>;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
* The output schemas of the server.* and manifest.* procedures (roadmap 2.1).
|
|
3
|
+
*
|
|
4
|
+
* Loose objects: a field that a schema does not name stays in the result (a strict schema would
|
|
5
|
+
* remove it when the output is validated). Each schema is a `z.ZodType` of its output type, so
|
|
6
|
+
* the compiler checks it against the type.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
const procedureInfo = z.looseObject({
|
|
10
|
+
path: z.array(z.string()).describe("The procedure path"),
|
|
11
|
+
description: z.string().optional().describe("The description of the procedure"),
|
|
12
|
+
inputSchema: z.record(z.string(), z.unknown()).optional().describe("The JSON Schema of the input"),
|
|
13
|
+
outputSchema: z.record(z.string(), z.unknown()).optional().describe("The JSON Schema of the output"),
|
|
14
|
+
});
|
|
15
|
+
export const ServerCreateOutputSchema = z.looseObject({
|
|
16
|
+
serverId: z.string().describe("The id of the server: server.stop takes it"),
|
|
17
|
+
endpoints: z
|
|
18
|
+
.array(z.looseObject({
|
|
19
|
+
type: z.enum(["http", "websocket", "local"]).describe("The transport"),
|
|
20
|
+
address: z.string().describe("The address of the endpoint"),
|
|
21
|
+
}))
|
|
22
|
+
.describe("The endpoints of the server"),
|
|
23
|
+
procedureCount: z.number().describe("The number of procedures that the server serves"),
|
|
24
|
+
});
|
|
25
|
+
export const ServerConnectOutputSchema = z.looseObject({
|
|
26
|
+
connectionId: z.string().describe("The id of the connection: server.call and server.disconnect take it"),
|
|
27
|
+
remotePeerId: z.string().describe("The id of the remote peer"),
|
|
28
|
+
remoteProcedures: z.array(procedureInfo).describe("The procedures of the remote peer"),
|
|
29
|
+
});
|
|
30
|
+
export const ServerDisconnectOutputSchema = z.looseObject({
|
|
31
|
+
success: z.boolean().describe("True when the connection closed"),
|
|
32
|
+
});
|
|
33
|
+
export const ManifestGenerateOutputSchema = z.looseObject({
|
|
34
|
+
json: z
|
|
35
|
+
.looseObject({
|
|
36
|
+
procedures: z.array(procedureInfo).describe("The procedures with their JSON Schemas"),
|
|
37
|
+
generatedAt: z.string().describe("The time of the manifest (ISO 8601)"),
|
|
38
|
+
version: z.string().describe("The version of the manifest format"),
|
|
39
|
+
})
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("The JSON manifest, for the json format"),
|
|
42
|
+
typescript: z.string().optional().describe("The TypeScript declarations, for the typescript format"),
|
|
43
|
+
filesWritten: z.array(z.string()).optional().describe("The files that the call wrote, with outputDir"),
|
|
44
|
+
});
|
|
45
|
+
export const ServerStartOutputSchema = z.looseObject({
|
|
46
|
+
success: z.boolean().describe("True when the server started"),
|
|
47
|
+
pid: z.number().optional().describe("The process id of the server"),
|
|
48
|
+
port: z.number().optional().describe("The port of the server"),
|
|
49
|
+
endpoint: z.string().optional().describe("The URL of the server"),
|
|
50
|
+
logFile: z.string().optional().describe("The log file of the server"),
|
|
51
|
+
message: z.string().describe("A message about the result"),
|
|
52
|
+
});
|
|
53
|
+
export const ServerStopOutputSchema = z.looseObject({
|
|
54
|
+
success: z.boolean().describe("True when the server stopped"),
|
|
55
|
+
message: z.string().describe("A message about the result"),
|
|
56
|
+
});
|
|
57
|
+
export const ServerStatusOutputSchema = z.looseObject({
|
|
58
|
+
running: z.boolean().describe("True when a server runs"),
|
|
59
|
+
pid: z.number().optional().describe("The process id of the server"),
|
|
60
|
+
port: z.number().optional().describe("The port of the server"),
|
|
61
|
+
endpoint: z.string().optional().describe("The URL of the server"),
|
|
62
|
+
transport: z.string().optional().describe("The transport of the server"),
|
|
63
|
+
startedAt: z.string().optional().describe("The start time (ISO 8601)"),
|
|
64
|
+
uptime: z.string().optional().describe("The time since the start, as text"),
|
|
65
|
+
logFile: z.string().optional().describe("The log file of the server"),
|
|
66
|
+
message: z.string().describe("A message about the result"),
|
|
67
|
+
});
|
|
68
|
+
export const ServerCallOutputSchema = z.looseObject({
|
|
69
|
+
result: z.unknown().describe("The result of the remote procedure"),
|
|
70
|
+
connectionId: z.string().describe("The connection that the call used"),
|
|
71
|
+
path: z.array(z.string()).describe("The path of the remote procedure"),
|
|
72
|
+
});
|
|
73
|
+
export const ServerConnectionsOutputSchema = z.looseObject({
|
|
74
|
+
connections: z
|
|
75
|
+
.array(z.looseObject({
|
|
76
|
+
connectionId: z.string().describe("The id of the connection"),
|
|
77
|
+
remotePeerId: z.string().describe("The id of the remote peer"),
|
|
78
|
+
transport: z.string().describe("The transport of the connection"),
|
|
79
|
+
state: z.string().describe("The state: connecting, connected, disconnected or error"),
|
|
80
|
+
remoteProcedureCount: z.number().describe("The number of procedures of the remote peer"),
|
|
81
|
+
connectedAt: z.string().optional().describe("The time of the connection (ISO 8601)"),
|
|
82
|
+
}))
|
|
83
|
+
.describe("The open connections"),
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=output-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-schemas.js","sourceRoot":"","sources":["../src/output-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACxD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC/E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAClG,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CACrG,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAkC,C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Q,CAAC,kCAAkC,CAAC;CACvE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAuC,CAAC,CAAC,WAAW,CAAC;IAC7F,WAAW,EAAE,CAAC;SACX,KAAK,CACJ,CAAC,CAAC,WAAW,CAAC;QACZ,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QAC7D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC9D,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QACjE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yDAAyD,CAAC;QACrF,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;QACxF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;KACrF,CAAC,CACH;SACA,QAAQ,CAAC,sBAAsB,CAAC;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer Module
|
|
3
|
+
*
|
|
4
|
+
* Transport-agnostic peer implementation for bidirectional RPC.
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureServer, type ProcedureRegistry, type HostPolicy } from "@procedures/client";
|
|
7
|
+
import type { ProcedurePath } from "@procedures/client";
|
|
8
|
+
import type { TransportConfig, TransportType } from "../types.js";
|
|
9
|
+
export interface PeerOptions {
|
|
10
|
+
/** Unique peer ID */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Transports to enable */
|
|
13
|
+
transports: TransportConfig[];
|
|
14
|
+
/** Auto-register procedures from registry */
|
|
15
|
+
autoRegister?: boolean;
|
|
16
|
+
/** Procedure registry to use */
|
|
17
|
+
registry?: ProcedureRegistry;
|
|
18
|
+
/** The procedures that the peer serves (see `exposeRule`). Without it, the peer serves every procedure. */
|
|
19
|
+
expose?: ((path: ProcedurePath) => boolean) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The policy of the host (`hostPolicy()` of the core, roadmap 2.3): the expose rule, the call
|
|
22
|
+
* rule, the interceptors (a time limit), the token of each network transport that has none of
|
|
23
|
+
* its own, and the browser checks. `expose` above, when given, wins over the policy's.
|
|
24
|
+
*/
|
|
25
|
+
policy?: HostPolicy | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface PeerEndpoint {
|
|
28
|
+
type: TransportType;
|
|
29
|
+
address: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Peer {
|
|
32
|
+
/** Peer ID */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Start all transports */
|
|
35
|
+
start(): Promise<void>;
|
|
36
|
+
/** Stop all transports */
|
|
37
|
+
stop(): Promise<void>;
|
|
38
|
+
/** Get active endpoints */
|
|
39
|
+
getEndpoints(): PeerEndpoint[];
|
|
40
|
+
/** Get underlying server */
|
|
41
|
+
getServer(): ProcedureServer;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a new peer instance
|
|
45
|
+
*/
|
|
46
|
+
export declare function createPeer(options: PeerOptions): Promise<Peer>;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/peer/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EAGf,KAAK,iBAAiB,EAOtB,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAuB,eAAe,EAAE,aAAa,EAA4B,MAAM,aAAa,CAAC;AA0BjH,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,2GAA2G;IAC3G,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;IACxD;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,IAAI;IACnB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,0BAA0B;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,2BAA2B;IAC3B,YAAY,IAAI,YAAY,EAAE,CAAC;IAC/B,4BAA4B;IAC5B,SAAS,IAAI,eAAe,CAAC;CAC9B;AA4OD;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer Module
|
|
3
|
+
*
|
|
4
|
+
* Transport-agnostic peer implementation for bidirectional RPC.
|
|
5
|
+
*/
|
|
6
|
+
import { ProcedureServer, HttpServerTransport, WebSocketServerTransport, PROCEDURE_REGISTRY, rpcServerUrlStrategy, defaultServerUrlStrategy, defaultUrlPattern, procedureServerOptions, } from "@procedures/client";
|
|
7
|
+
import { bearerToken, hostAllowed, originAllowed, tokenMatches } from "./security.js";
|
|
8
|
+
/**
|
|
9
|
+
* URL strategy that matches the client's defaultUrlPattern
|
|
10
|
+
* Maps: POST /api/server/status → { service: "server", operation: "status" }
|
|
11
|
+
*/
|
|
12
|
+
function patternUrlStrategy(req) {
|
|
13
|
+
const basePath = "/api";
|
|
14
|
+
let path = req.path;
|
|
15
|
+
// Remove base path prefix if present
|
|
16
|
+
if (path.startsWith(basePath)) {
|
|
17
|
+
path = path.slice(basePath.length);
|
|
18
|
+
}
|
|
19
|
+
// Use the client's defaultUrlPattern parser
|
|
20
|
+
// Cast method to expected type (parser doesn't actually use it for this pattern)
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
return defaultUrlPattern.parse(path, req.method.toUpperCase());
|
|
23
|
+
}
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// Implementation
|
|
26
|
+
// =============================================================================
|
|
27
|
+
class PeerImpl {
|
|
28
|
+
id;
|
|
29
|
+
server;
|
|
30
|
+
transports;
|
|
31
|
+
endpoints = [];
|
|
32
|
+
started = false;
|
|
33
|
+
registry;
|
|
34
|
+
startTime = Date.now();
|
|
35
|
+
/** The browser checks of the policy (an origin rule here replaces the peer's own rule). */
|
|
36
|
+
browser;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
this.id = options.id;
|
|
39
|
+
const policy = options.policy;
|
|
40
|
+
// The policy's token goes to each network transport that has none of its own
|
|
41
|
+
this.transports = options.transports.map((transport) => transport.type === "local" || policy?.token === undefined || transport.token !== undefined
|
|
42
|
+
? transport
|
|
43
|
+
: { ...transport, token: policy.token });
|
|
44
|
+
this.registry = options.registry ?? PROCEDURE_REGISTRY;
|
|
45
|
+
this.browser = policy?.browser ?? {};
|
|
46
|
+
// Create procedure server
|
|
47
|
+
this.server = new ProcedureServer({
|
|
48
|
+
...(policy ? procedureServerOptions(policy, this.registry) : {}),
|
|
49
|
+
autoRegister: options.autoRegister ?? true,
|
|
50
|
+
registry: this.registry,
|
|
51
|
+
...(options.expose ? { expose: options.expose } : {}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async start() {
|
|
55
|
+
if (this.started)
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
for (const transport of this.transports) {
|
|
59
|
+
await this.startTransport(transport);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// Stop the transports that started, so a failed start leaves no port open
|
|
64
|
+
await this.server.stop().catch(() => { });
|
|
65
|
+
this.endpoints = [];
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
this.started = true;
|
|
69
|
+
}
|
|
70
|
+
async startTransport(config) {
|
|
71
|
+
switch (config.type) {
|
|
72
|
+
case "http":
|
|
73
|
+
await this.startHttpTransport(config);
|
|
74
|
+
break;
|
|
75
|
+
case "websocket":
|
|
76
|
+
await this.startWebSocketTransport(config);
|
|
77
|
+
break;
|
|
78
|
+
case "local":
|
|
79
|
+
// Local transport doesn't need network setup
|
|
80
|
+
this.endpoints.push({
|
|
81
|
+
type: "local",
|
|
82
|
+
address: "local://in-process",
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async startHttpTransport(config) {
|
|
88
|
+
// Dynamic import to avoid bundling express if not used
|
|
89
|
+
const express = (await import("express")).default;
|
|
90
|
+
const app = express();
|
|
91
|
+
app.use(express.json());
|
|
92
|
+
const port = config.port ?? 3000;
|
|
93
|
+
// Loopback by default so the full procedure registry (incl. shell.run / fs.write) is not
|
|
94
|
+
// served unauthenticated on all interfaces. Pass host: "0.0.0.0" to expose on the LAN
|
|
95
|
+
// deliberately. See documentation/BUGS-2026-07.md (H19).
|
|
96
|
+
const host = config.host ?? "127.0.0.1";
|
|
97
|
+
const basePath = config.basePath ?? "/api";
|
|
98
|
+
// Host, origin and token checks (deep dive TRN-1, CLI-1, CLI-2). The health endpoints need no
|
|
99
|
+
// token: a client uses them to check that a lockfile's server is alive.
|
|
100
|
+
app.use((req, res, next) => {
|
|
101
|
+
if (!hostAllowed(host, req.headers.host) || !originAllowed(req.headers.origin, config.corsOrigins)) {
|
|
102
|
+
res.status(403).json({ error: "Forbidden: the host or the origin is not allowed", code: "FORBIDDEN" });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const isHealth = req.path === "/health" || req.path === `${basePath}/health`;
|
|
106
|
+
if (!isHealth && req.method !== "OPTIONS" && !tokenMatches(config.token, bearerToken(req.headers.authorization))) {
|
|
107
|
+
res.status(401).json({ error: "Unauthorized: this server requires its token", code: "UNAUTHORIZED" });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
next();
|
|
111
|
+
});
|
|
112
|
+
// Health endpoint for container orchestration
|
|
113
|
+
app.get(`${basePath}/health`, (_req, res) => {
|
|
114
|
+
const procedureCount = this.registry.getAll().filter((p) => p.handler).length;
|
|
115
|
+
res.json({
|
|
116
|
+
status: "ok",
|
|
117
|
+
uptime: Date.now() - this.startTime,
|
|
118
|
+
procedures: procedureCount,
|
|
119
|
+
peerId: this.id,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
// Also add at root /health for convenience
|
|
123
|
+
app.get("/health", (_req, res) => {
|
|
124
|
+
const procedureCount = this.registry.getAll().filter((p) => p.handler).length;
|
|
125
|
+
res.json({
|
|
126
|
+
status: "ok",
|
|
127
|
+
uptime: Date.now() - this.startTime,
|
|
128
|
+
procedures: procedureCount,
|
|
129
|
+
peerId: this.id,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
// Select URL strategy based on config
|
|
133
|
+
// Default to patternUrlStrategy which matches the client's defaultUrlPattern
|
|
134
|
+
const urlStrategy = config.urlStrategy === "rpc"
|
|
135
|
+
? rpcServerUrlStrategy
|
|
136
|
+
: config.urlStrategy === "rest"
|
|
137
|
+
? defaultServerUrlStrategy
|
|
138
|
+
: patternUrlStrategy;
|
|
139
|
+
const httpTransport = new HttpServerTransport(this.server, {
|
|
140
|
+
app,
|
|
141
|
+
port,
|
|
142
|
+
host,
|
|
143
|
+
basePath,
|
|
144
|
+
// Off by default: before, every peer sent Access-Control-Allow-Origin: * (deep dive CLI-2)
|
|
145
|
+
cors: config.cors ?? false,
|
|
146
|
+
urlStrategy,
|
|
147
|
+
// The transport's browser checks follow the peer's rule: loopback origins and the listed
|
|
148
|
+
// ones (the token is required in any case). The RESTful strategy calls by GET.
|
|
149
|
+
allowedOrigins: this.browser.allowedOrigins ?? ((origin) => originAllowed(origin, config.corsOrigins)),
|
|
150
|
+
...(this.browser.allowedHosts ? { allowedHosts: this.browser.allowedHosts } : {}),
|
|
151
|
+
allowGet: this.browser.allowGet ?? config.urlStrategy === "rest",
|
|
152
|
+
});
|
|
153
|
+
this.server.addTransport(httpTransport);
|
|
154
|
+
await httpTransport.start();
|
|
155
|
+
this.endpoints.push({
|
|
156
|
+
type: "http",
|
|
157
|
+
address: `http://${host === "0.0.0.0" ? "localhost" : host}:${port}${basePath}`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async startWebSocketTransport(config) {
|
|
161
|
+
// WebSocket transport requires an HTTP server to attach to
|
|
162
|
+
// For standalone WebSocket, we create an HTTP server first
|
|
163
|
+
const { createServer } = await import("http");
|
|
164
|
+
const port = config.port ?? 3001;
|
|
165
|
+
// Loopback by default so the full procedure registry (incl. shell.run / fs.write) is not
|
|
166
|
+
// served unauthenticated on all interfaces. Pass host: "0.0.0.0" to expose on the LAN
|
|
167
|
+
// deliberately. See documentation/BUGS-2026-07.md (H19).
|
|
168
|
+
const host = config.host ?? "127.0.0.1";
|
|
169
|
+
const path = config.path ?? "/ws";
|
|
170
|
+
const httpServer = createServer();
|
|
171
|
+
// Listen first, then attach the WebSocket server. A listen error (EADDRINUSE, EACCES) rejects:
|
|
172
|
+
// before, the error had no listener, so the process ended with an unhandled 'error' event
|
|
173
|
+
// (deep dive CLI-16).
|
|
174
|
+
await new Promise((resolve, reject) => {
|
|
175
|
+
const onError = (error) => {
|
|
176
|
+
reject(new Error(`The WebSocket server cannot listen on ${host}:${port}: ${error.message}`));
|
|
177
|
+
};
|
|
178
|
+
httpServer.once("error", onError);
|
|
179
|
+
httpServer.listen(port, host, () => {
|
|
180
|
+
httpServer.off("error", onError);
|
|
181
|
+
resolve();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
const wsTransport = new WebSocketServerTransport(this.server, {
|
|
185
|
+
server: httpServer,
|
|
186
|
+
path,
|
|
187
|
+
allowedOrigins: this.browser.allowedOrigins ?? ((origin) => originAllowed(origin, config.origins)),
|
|
188
|
+
...(this.browser.allowedHosts ? { allowedHosts: this.browser.allowedHosts } : {}),
|
|
189
|
+
// Host, origin and token checks: before, any web page could open a connection and call
|
|
190
|
+
// procedures (cross-site WebSocket hijacking, deep dive TRN-1)
|
|
191
|
+
authenticate: (req) => {
|
|
192
|
+
const token = new URL(req.url ?? "/", "http://localhost").searchParams.get("token") ?? bearerToken(req.headers.authorization);
|
|
193
|
+
return (hostAllowed(host, req.headers.host) &&
|
|
194
|
+
originAllowed(req.headers.origin, config.origins) &&
|
|
195
|
+
tokenMatches(config.token, token));
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
this.server.addTransport(wsTransport);
|
|
199
|
+
try {
|
|
200
|
+
await wsTransport.start();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
httpServer.close();
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
this.endpoints.push({
|
|
207
|
+
type: "websocket",
|
|
208
|
+
address: `ws://${host === "0.0.0.0" ? "localhost" : host}:${port}${path}`,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async stop() {
|
|
212
|
+
if (!this.started)
|
|
213
|
+
return;
|
|
214
|
+
await this.server.stop();
|
|
215
|
+
this.started = false;
|
|
216
|
+
this.endpoints = [];
|
|
217
|
+
}
|
|
218
|
+
getEndpoints() {
|
|
219
|
+
return [...this.endpoints];
|
|
220
|
+
}
|
|
221
|
+
getServer() {
|
|
222
|
+
return this.server;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// =============================================================================
|
|
226
|
+
// Factory
|
|
227
|
+
// =============================================================================
|
|
228
|
+
/**
|
|
229
|
+
* Create a new peer instance
|
|
230
|
+
*/
|
|
231
|
+
export async function createPeer(options) {
|
|
232
|
+
return new PeerImpl(options);
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/peer/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EAExB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtF;;;GAGG;AACH,SAAS,kBAAkB,CAAC,GAAY;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC;IACxB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpB,qCAAqC;IACrC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,4CAA4C;IAC5C,iFAAiF;IACjF,8DAA8D;IAC9D,OAAO,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,EAAS,CAAC,CAAC;AACxE,CAAC;AA2CD,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF,MAAM,QAAQ;IACH,EAAE,CAAS;IACZ,MAAM,CAAkB;IACxB,UAAU,CAAoB;IAC9B,SAAS,GAAmB,EAAE,CAAC;IAC/B,OAAO,GAAG,KAAK,CAAC;IAChB,QAAQ,CAAoB;IAC5B,SAAS,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvC,2F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