@casys/mcp-server 0.27.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1770
- package/README.md +10 -638
- package/esm/mod.d.ts +1 -102
- package/esm/mod.js +1 -103
- package/package.json +17 -25
- package/esm/_dnt.polyfills.d.ts +0 -12
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -15
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts +0 -33
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.js +0 -48
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts +0 -106
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.js +0 -636
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts +0 -67
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.js +0 -1393
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts +0 -44
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.js +0 -117
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.js +0 -103
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.js +0 -32
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.js +0 -96
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.js +0 -159
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.js +0 -14
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.js +0 -10
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.js +0 -22
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.js +0 -29
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.js +0 -19
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.js +0 -30
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.js +0 -10
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.js +0 -14
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.js +0 -9
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.js +0 -81
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts +0 -3
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.js +0 -20
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts +0 -32
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.js +0 -6
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts +0 -4
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.js +0 -13
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts +0 -51
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.js +0 -53
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts +0 -79
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.js +0 -91
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts +0 -100
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.js +0 -33
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts +0 -111
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.js +0 -104
- package/esm/mod.d.ts.map +0 -1
- package/esm/package.json +0 -3
- package/esm/src/auth/as-metadata-proxy.d.ts +0 -112
- package/esm/src/auth/as-metadata-proxy.d.ts.map +0 -1
- package/esm/src/auth/as-metadata-proxy.js +0 -171
- package/esm/src/auth/config.d.ts +0 -117
- package/esm/src/auth/config.d.ts.map +0 -1
- package/esm/src/auth/config.js +0 -219
- package/esm/src/auth/jwt-provider.d.ts +0 -157
- package/esm/src/auth/jwt-provider.d.ts.map +0 -1
- package/esm/src/auth/jwt-provider.js +0 -187
- package/esm/src/auth/middleware.d.ts +0 -61
- package/esm/src/auth/middleware.d.ts.map +0 -1
- package/esm/src/auth/middleware.js +0 -209
- package/esm/src/auth/mod.d.ts +0 -23
- package/esm/src/auth/mod.d.ts.map +0 -1
- package/esm/src/auth/mod.js +0 -27
- package/esm/src/auth/multi-tenant-middleware.d.ts +0 -131
- package/esm/src/auth/multi-tenant-middleware.d.ts.map +0 -1
- package/esm/src/auth/multi-tenant-middleware.js +0 -128
- package/esm/src/auth/presets.d.ts +0 -231
- package/esm/src/auth/presets.d.ts.map +0 -1
- package/esm/src/auth/presets.js +0 -223
- package/esm/src/auth/provider.d.ts +0 -47
- package/esm/src/auth/provider.d.ts.map +0 -1
- package/esm/src/auth/provider.js +0 -34
- package/esm/src/auth/scope-middleware.d.ts +0 -30
- package/esm/src/auth/scope-middleware.d.ts.map +0 -1
- package/esm/src/auth/scope-middleware.js +0 -48
- package/esm/src/auth/static-token-provider.d.ts +0 -155
- package/esm/src/auth/static-token-provider.d.ts.map +0 -1
- package/esm/src/auth/static-token-provider.js +0 -256
- package/esm/src/auth/types.d.ts +0 -151
- package/esm/src/auth/types.d.ts.map +0 -1
- package/esm/src/auth/types.js +0 -64
- package/esm/src/client-auth/callback-server.d.ts +0 -34
- package/esm/src/client-auth/callback-server.d.ts.map +0 -1
- package/esm/src/client-auth/callback-server.js +0 -141
- package/esm/src/client-auth/client-id-metadata.d.ts +0 -29
- package/esm/src/client-auth/client-id-metadata.d.ts.map +0 -1
- package/esm/src/client-auth/client-id-metadata.js +0 -149
- package/esm/src/client-auth/connect.d.ts +0 -32
- package/esm/src/client-auth/connect.d.ts.map +0 -1
- package/esm/src/client-auth/connect.js +0 -47
- package/esm/src/client-auth/mod.d.ts +0 -19
- package/esm/src/client-auth/mod.d.ts.map +0 -1
- package/esm/src/client-auth/mod.js +0 -19
- package/esm/src/client-auth/provider.d.ts +0 -78
- package/esm/src/client-auth/provider.d.ts.map +0 -1
- package/esm/src/client-auth/provider.js +0 -246
- package/esm/src/client-auth/token-store/file-store.d.ts +0 -20
- package/esm/src/client-auth/token-store/file-store.d.ts.map +0 -1
- package/esm/src/client-auth/token-store/file-store.js +0 -62
- package/esm/src/client-auth/token-store/memory-store.d.ts +0 -14
- package/esm/src/client-auth/token-store/memory-store.d.ts.map +0 -1
- package/esm/src/client-auth/token-store/memory-store.js +0 -25
- package/esm/src/client-auth/types.d.ts +0 -89
- package/esm/src/client-auth/types.d.ts.map +0 -1
- package/esm/src/client-auth/types.js +0 -10
- package/esm/src/concurrency/rate-limiter.d.ts +0 -87
- package/esm/src/concurrency/rate-limiter.d.ts.map +0 -1
- package/esm/src/concurrency/rate-limiter.js +0 -165
- package/esm/src/concurrency/request-queue.d.ts +0 -71
- package/esm/src/concurrency/request-queue.d.ts.map +0 -1
- package/esm/src/concurrency/request-queue.js +0 -128
- package/esm/src/http/body.d.ts +0 -20
- package/esm/src/http/body.d.ts.map +0 -1
- package/esm/src/http/body.js +0 -63
- package/esm/src/http/request-guards.d.ts +0 -54
- package/esm/src/http/request-guards.d.ts.map +0 -1
- package/esm/src/http/request-guards.js +0 -114
- package/esm/src/http/wire.d.ts +0 -26
- package/esm/src/http/wire.d.ts.map +0 -1
- package/esm/src/http/wire.js +0 -35
- package/esm/src/inspector/launcher.d.ts +0 -48
- package/esm/src/inspector/launcher.d.ts.map +0 -1
- package/esm/src/inspector/launcher.js +0 -100
- package/esm/src/mcp-app.d.ts +0 -728
- package/esm/src/mcp-app.d.ts.map +0 -1
- package/esm/src/mcp-app.js +0 -3530
- package/esm/src/middleware/backpressure.d.ts +0 -24
- package/esm/src/middleware/backpressure.d.ts.map +0 -1
- package/esm/src/middleware/backpressure.js +0 -31
- package/esm/src/middleware/mod.d.ts +0 -11
- package/esm/src/middleware/mod.d.ts.map +0 -1
- package/esm/src/middleware/mod.js +0 -11
- package/esm/src/middleware/rate-limit.d.ts +0 -22
- package/esm/src/middleware/rate-limit.d.ts.map +0 -1
- package/esm/src/middleware/rate-limit.js +0 -33
- package/esm/src/middleware/runner.d.ts +0 -32
- package/esm/src/middleware/runner.d.ts.map +0 -1
- package/esm/src/middleware/runner.js +0 -49
- package/esm/src/middleware/types.d.ts +0 -76
- package/esm/src/middleware/types.d.ts.map +0 -1
- package/esm/src/middleware/types.js +0 -9
- package/esm/src/middleware/validation.d.ts +0 -24
- package/esm/src/middleware/validation.d.ts.map +0 -1
- package/esm/src/middleware/validation.js +0 -30
- package/esm/src/mrtr/capability-check.d.ts +0 -75
- package/esm/src/mrtr/capability-check.d.ts.map +0 -1
- package/esm/src/mrtr/capability-check.js +0 -233
- package/esm/src/mrtr/mod.d.ts +0 -18
- package/esm/src/mrtr/mod.d.ts.map +0 -1
- package/esm/src/mrtr/mod.js +0 -12
- package/esm/src/mrtr/replay-store.d.ts +0 -50
- package/esm/src/mrtr/replay-store.d.ts.map +0 -1
- package/esm/src/mrtr/replay-store.js +0 -61
- package/esm/src/mrtr/request-state.d.ts +0 -181
- package/esm/src/mrtr/request-state.d.ts.map +0 -1
- package/esm/src/mrtr/request-state.js +0 -313
- package/esm/src/mrtr/retry-guard.d.ts +0 -61
- package/esm/src/mrtr/retry-guard.d.ts.map +0 -1
- package/esm/src/mrtr/retry-guard.js +0 -53
- package/esm/src/mrtr/types.d.ts +0 -99
- package/esm/src/mrtr/types.d.ts.map +0 -1
- package/esm/src/mrtr/types.js +0 -14
- package/esm/src/observability/metrics.d.ts +0 -104
- package/esm/src/observability/metrics.d.ts.map +0 -1
- package/esm/src/observability/metrics.js +0 -207
- package/esm/src/observability/mod.d.ts +0 -12
- package/esm/src/observability/mod.d.ts.map +0 -1
- package/esm/src/observability/mod.js +0 -11
- package/esm/src/observability/otel.d.ts +0 -73
- package/esm/src/observability/otel.d.ts.map +0 -1
- package/esm/src/observability/otel.js +0 -260
- package/esm/src/runtime/runtime.d.ts +0 -10
- package/esm/src/runtime/runtime.d.ts.map +0 -1
- package/esm/src/runtime/runtime.deno.d.ts +0 -50
- package/esm/src/runtime/runtime.deno.d.ts.map +0 -1
- package/esm/src/runtime/runtime.deno.js +0 -120
- package/esm/src/runtime/runtime.js +0 -41
- package/esm/src/runtime/runtime.node.d.ts +0 -51
- package/esm/src/runtime/runtime.node.d.ts.map +0 -1
- package/esm/src/runtime/runtime.node.js +0 -268
- package/esm/src/runtime/types.d.ts +0 -107
- package/esm/src/runtime/types.d.ts.map +0 -1
- package/esm/src/runtime/types.js +0 -12
- package/esm/src/security/channel-hmac.d.ts +0 -43
- package/esm/src/security/channel-hmac.d.ts.map +0 -1
- package/esm/src/security/channel-hmac.js +0 -135
- package/esm/src/security/csp.d.ts +0 -50
- package/esm/src/security/csp.d.ts.map +0 -1
- package/esm/src/security/csp.js +0 -63
- package/esm/src/security/message-signer.d.ts +0 -88
- package/esm/src/security/message-signer.d.ts.map +0 -1
- package/esm/src/security/message-signer.js +0 -166
- package/esm/src/subscriptions/subscription-registry.d.ts +0 -256
- package/esm/src/subscriptions/subscription-registry.d.ts.map +0 -1
- package/esm/src/subscriptions/subscription-registry.js +0 -406
- package/esm/src/tasks/mod.d.ts +0 -13
- package/esm/src/tasks/mod.d.ts.map +0 -1
- package/esm/src/tasks/mod.js +0 -11
- package/esm/src/tasks/task-store.d.ts +0 -342
- package/esm/src/tasks/task-store.d.ts.map +0 -1
- package/esm/src/tasks/task-store.js +0 -649
- package/esm/src/transport/request-headers.d.ts +0 -145
- package/esm/src/transport/request-headers.d.ts.map +0 -1
- package/esm/src/transport/request-headers.js +0 -525
- package/esm/src/types.d.ts +0 -776
- package/esm/src/types.d.ts.map +0 -1
- package/esm/src/types.js +0 -92
- package/esm/src/ui/viewer-utils.d.ts +0 -45
- package/esm/src/ui/viewer-utils.d.ts.map +0 -1
- package/esm/src/ui/viewer-utils.js +0 -97
- package/esm/src/validation/schema-validator.d.ts +0 -115
- package/esm/src/validation/schema-validator.d.ts.map +0 -1
- package/esm/src/validation/schema-validator.js +0 -249
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime adapter — Deno implementation
|
|
3
|
-
*
|
|
4
|
-
* Implements the RuntimePort contract for Deno.
|
|
5
|
-
* Selected automatically by runtime.ts (the selector) when running under Deno.
|
|
6
|
-
*
|
|
7
|
-
* @see types.ts for the port contract
|
|
8
|
-
* @module lib/server/runtime.deno
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Get an environment variable.
|
|
12
|
-
*/
|
|
13
|
-
export function env(key) {
|
|
14
|
-
return Deno.env.get(key);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Read a UTF-8 text file.
|
|
18
|
-
* Returns null if the file does not exist.
|
|
19
|
-
*/
|
|
20
|
-
export async function readTextFile(path) {
|
|
21
|
-
try {
|
|
22
|
-
return await Deno.readTextFile(path);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
if (err instanceof Deno.errors.NotFound) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Write a UTF-8 text file.
|
|
33
|
-
*/
|
|
34
|
-
export async function writeTextFile(path, content, opts) {
|
|
35
|
-
await Deno.writeTextFile(path, content, opts);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Create a directory.
|
|
39
|
-
*/
|
|
40
|
-
export async function mkdir(path, opts) {
|
|
41
|
-
await Deno.mkdir(path, opts);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Remove a file or empty directory. No-op if absent.
|
|
45
|
-
*/
|
|
46
|
-
export async function remove(path) {
|
|
47
|
-
try {
|
|
48
|
-
await Deno.remove(path);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
if (err instanceof Deno.errors.NotFound) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Read directory entry names. Returns [] if absent.
|
|
59
|
-
*/
|
|
60
|
-
export async function readDir(path) {
|
|
61
|
-
try {
|
|
62
|
-
const names = [];
|
|
63
|
-
for await (const entry of Deno.readDir(path)) {
|
|
64
|
-
names.push(entry.name);
|
|
65
|
-
}
|
|
66
|
-
return names;
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
if (err instanceof Deno.errors.NotFound) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
throw err;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Start an HTTP server with a fetch-style handler.
|
|
77
|
-
*/
|
|
78
|
-
export function serve(options, handler) {
|
|
79
|
-
let server = null;
|
|
80
|
-
try {
|
|
81
|
-
server = Deno.serve({
|
|
82
|
-
port: options.port,
|
|
83
|
-
hostname: options.hostname,
|
|
84
|
-
onListen: options.onListen,
|
|
85
|
-
}, handler);
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
const error = toError(err);
|
|
89
|
-
if (options.onError) {
|
|
90
|
-
options.onError(error);
|
|
91
|
-
return {
|
|
92
|
-
shutdown: () => Promise.resolve(),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
shutdown: () => server.shutdown(),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Unref a timer so it doesn't block process exit.
|
|
103
|
-
*/
|
|
104
|
-
export function unrefTimer(id) {
|
|
105
|
-
Deno.unrefTimer(id);
|
|
106
|
-
}
|
|
107
|
-
/** Compile-time contract check — ensures this module satisfies RuntimePort */
|
|
108
|
-
void {
|
|
109
|
-
env,
|
|
110
|
-
readTextFile,
|
|
111
|
-
writeTextFile,
|
|
112
|
-
mkdir,
|
|
113
|
-
remove,
|
|
114
|
-
readDir,
|
|
115
|
-
serve,
|
|
116
|
-
unrefTimer,
|
|
117
|
-
};
|
|
118
|
-
function toError(err) {
|
|
119
|
-
return err instanceof Error ? err : new Error(String(err));
|
|
120
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime adapter — selector
|
|
3
|
-
*
|
|
4
|
-
* Auto-detects the host runtime and forwards to the Deno or Node adapter.
|
|
5
|
-
* This is the module every consumer imports. It replaces the previous
|
|
6
|
-
* build-time file swap (runtime.ts <- runtime.node.ts), which only ever
|
|
7
|
-
* applied to mcp-server's own npm build and never to JSR consumers that
|
|
8
|
-
* bundle the Deno source for Node (e.g. @casys/mcp-erpnext via esbuild),
|
|
9
|
-
* whose bundle therefore embedded `Deno.*` calls and crashed under Node
|
|
10
|
-
* with "ReferenceError: Deno is not defined".
|
|
11
|
-
*
|
|
12
|
-
* A *dynamic* import is used on purpose so the inactive adapter is never
|
|
13
|
-
* evaluated: under Deno, runtime.node.ts — and its top-level `node:http` /
|
|
14
|
-
* `node:fs/promises` / `node:buffer` imports — never executes, which keeps
|
|
15
|
-
* capability-restricted targets like Deno Deploy (the canonical cloud
|
|
16
|
-
* target, where node:http's raw-TCP `createServer` is unsupported) safe at
|
|
17
|
-
* load time. Platforms and bundlers that statically analyze
|
|
18
|
-
* constant-specifier dynamic imports may still fetch or include the
|
|
19
|
-
* inactive module, but they never run it. Under Node, the Deno adapter is
|
|
20
|
-
* likewise never evaluated.
|
|
21
|
-
*
|
|
22
|
-
* @see types.ts for the RuntimePort contract
|
|
23
|
-
* @see runtime.deno.ts / runtime.node.ts for the implementations
|
|
24
|
-
* @module lib/server/runtime
|
|
25
|
-
*/
|
|
26
|
-
import * as dntShim from "../../_dnt.shims.js";
|
|
27
|
-
// Structural detection: a bare `globalThis.Deno = {}` shim (seen in some Node
|
|
28
|
-
// test setups and bundlers) must NOT be mistaken for a real Deno runtime, so
|
|
29
|
-
// probe a concrete field (`Deno.version.deno`) rather than mere existence.
|
|
30
|
-
const isDeno = typeof dntShim.dntGlobalThis.Deno?.version?.deno === "string";
|
|
31
|
-
const impl = isDeno
|
|
32
|
-
? await import("./runtime.deno.js")
|
|
33
|
-
: await import("./runtime.node.js");
|
|
34
|
-
export const env = impl.env;
|
|
35
|
-
export const readTextFile = impl.readTextFile;
|
|
36
|
-
export const writeTextFile = impl.writeTextFile;
|
|
37
|
-
export const mkdir = impl.mkdir;
|
|
38
|
-
export const remove = impl.remove;
|
|
39
|
-
export const readDir = impl.readDir;
|
|
40
|
-
export const serve = impl.serve;
|
|
41
|
-
export const unrefTimer = impl.unrefTimer;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime adapter — Node.js implementation
|
|
3
|
-
*
|
|
4
|
-
* Implements the RuntimePort contract for Node.js.
|
|
5
|
-
* Drop-in replacement for runtime.ts (Deno) — swapped by build script.
|
|
6
|
-
*
|
|
7
|
-
* @see runtime-types.ts for the port contract
|
|
8
|
-
* @module lib/server/runtime.node
|
|
9
|
-
*/
|
|
10
|
-
import type { FetchHandler, ServeHandle, ServeOptions } from "./types.js";
|
|
11
|
-
export type { FetchHandler, ServeHandle, ServeOptions } from "./types.js";
|
|
12
|
-
/**
|
|
13
|
-
* Get an environment variable.
|
|
14
|
-
*/
|
|
15
|
-
export declare function env(key: string): string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Read a UTF-8 text file.
|
|
18
|
-
* Returns null if the file does not exist.
|
|
19
|
-
*/
|
|
20
|
-
export declare function readTextFile(path: string): Promise<string | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Write a UTF-8 text file.
|
|
23
|
-
*/
|
|
24
|
-
export declare function writeTextFile(path: string, content: string, opts?: {
|
|
25
|
-
mode?: number;
|
|
26
|
-
}): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a directory.
|
|
29
|
-
*/
|
|
30
|
-
export declare function mkdir(path: string, opts?: {
|
|
31
|
-
recursive?: boolean;
|
|
32
|
-
mode?: number;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Remove a file or empty directory. No-op if absent.
|
|
36
|
-
*/
|
|
37
|
-
export declare function remove(path: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Read directory entry names. Returns [] if absent.
|
|
40
|
-
*/
|
|
41
|
-
export declare function readDir(path: string): Promise<string[]>;
|
|
42
|
-
/**
|
|
43
|
-
* Start an HTTP server with a fetch-style handler.
|
|
44
|
-
* Uses node:http with a Request/Response adapter (compatible with Hono).
|
|
45
|
-
*/
|
|
46
|
-
export declare function serve(options: ServeOptions, handler: FetchHandler): ServeHandle;
|
|
47
|
-
/**
|
|
48
|
-
* Unref a timer so it doesn't block process exit.
|
|
49
|
-
*/
|
|
50
|
-
export declare function unrefTimer(id: number): void;
|
|
51
|
-
//# sourceMappingURL=runtime.node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.node.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/runtime.node.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAWH,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS1E;;GAEG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnD;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWvE;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACvB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;GAEG;AACH,wBAAsB,KAAK,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASxD;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAS7D;AAED;;;GAGG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACpB,WAAW,CA0Hb;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAa3C"}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-process-global
|
|
2
|
-
/**
|
|
3
|
-
* Runtime adapter — Node.js implementation
|
|
4
|
-
*
|
|
5
|
-
* Implements the RuntimePort contract for Node.js.
|
|
6
|
-
* Drop-in replacement for runtime.ts (Deno) — swapped by build script.
|
|
7
|
-
*
|
|
8
|
-
* @see runtime-types.ts for the port contract
|
|
9
|
-
* @module lib/server/runtime.node
|
|
10
|
-
*/
|
|
11
|
-
import { Buffer } from "node:buffer";
|
|
12
|
-
import { mkdir as nodeMkdir, readdir, readFile, rm, writeFile, } from "node:fs/promises";
|
|
13
|
-
import { createServer } from "node:http";
|
|
14
|
-
class PayloadTooLargeError extends Error {
|
|
15
|
-
constructor(maxBytes) {
|
|
16
|
-
super(`Payload too large. Max ${maxBytes} bytes.`);
|
|
17
|
-
this.name = "PayloadTooLargeError";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get an environment variable.
|
|
22
|
-
*/
|
|
23
|
-
export function env(key) {
|
|
24
|
-
return process.env[key];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Read a UTF-8 text file.
|
|
28
|
-
* Returns null if the file does not exist.
|
|
29
|
-
*/
|
|
30
|
-
export async function readTextFile(path) {
|
|
31
|
-
try {
|
|
32
|
-
return await readFile(path, "utf-8");
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Write a UTF-8 text file.
|
|
43
|
-
*/
|
|
44
|
-
export async function writeTextFile(path, content, opts) {
|
|
45
|
-
await writeFile(path, content, { mode: opts?.mode });
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create a directory.
|
|
49
|
-
*/
|
|
50
|
-
export async function mkdir(path, opts) {
|
|
51
|
-
await nodeMkdir(path, { recursive: opts?.recursive, mode: opts?.mode });
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Remove a file or empty directory. No-op if absent.
|
|
55
|
-
*/
|
|
56
|
-
export async function remove(path) {
|
|
57
|
-
try {
|
|
58
|
-
await rm(path);
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
if (isNodeNotFound(err)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
throw err;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Read directory entry names. Returns [] if absent.
|
|
69
|
-
*/
|
|
70
|
-
export async function readDir(path) {
|
|
71
|
-
try {
|
|
72
|
-
return await readdir(path);
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
if (isNodeNotFound(err)) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
throw err;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Start an HTTP server with a fetch-style handler.
|
|
83
|
-
* Uses node:http with a Request/Response adapter (compatible with Hono).
|
|
84
|
-
*/
|
|
85
|
-
export function serve(options, handler) {
|
|
86
|
-
const hostname = options.hostname ?? "0.0.0.0";
|
|
87
|
-
const maxBodyBytes = options.maxBodyBytes ?? null;
|
|
88
|
-
const server = createServer(async (nodeReq, nodeRes) => {
|
|
89
|
-
try {
|
|
90
|
-
const contentLength = nodeReq.headers["content-length"];
|
|
91
|
-
if (maxBodyBytes !== null && contentLength) {
|
|
92
|
-
const length = Array.isArray(contentLength)
|
|
93
|
-
? Number(contentLength[0])
|
|
94
|
-
: Number(contentLength);
|
|
95
|
-
if (!Number.isNaN(length) && length > maxBodyBytes) {
|
|
96
|
-
nodeRes.writeHead(413);
|
|
97
|
-
nodeRes.end(`Payload too large. Max ${maxBodyBytes} bytes.`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Convert Node.js IncomingMessage → Web Request
|
|
102
|
-
// Prefer Host header (correct behind reverse proxy) over bound hostname
|
|
103
|
-
const host = nodeReq.headers.host ?? `${hostname}:${options.port}`;
|
|
104
|
-
const url = `http://${host}${nodeReq.url ?? "/"}`;
|
|
105
|
-
const headers = new Headers();
|
|
106
|
-
for (const [key, value] of Object.entries(nodeReq.headers)) {
|
|
107
|
-
if (value) {
|
|
108
|
-
if (Array.isArray(value)) {
|
|
109
|
-
for (const v of value)
|
|
110
|
-
headers.append(key, v);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
headers.set(key, value);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const body = nodeReq.method !== "GET" && nodeReq.method !== "HEAD"
|
|
118
|
-
? await collectBody(nodeReq, maxBodyBytes)
|
|
119
|
-
: undefined;
|
|
120
|
-
const request = new Request(url, {
|
|
121
|
-
method: nodeReq.method ?? "GET",
|
|
122
|
-
headers,
|
|
123
|
-
body,
|
|
124
|
-
// @ts-ignore: duplex needed for streaming requests in Node 20+
|
|
125
|
-
duplex: body ? "half" : undefined,
|
|
126
|
-
});
|
|
127
|
-
// Call the fetch handler (Hono, etc.)
|
|
128
|
-
const response = await handler(request);
|
|
129
|
-
// Convert Web Response → Node.js ServerResponse
|
|
130
|
-
// Use raw header entries to preserve duplicate Set-Cookie headers
|
|
131
|
-
const resHeaders = {};
|
|
132
|
-
response.headers.forEach((value, key) => {
|
|
133
|
-
const existing = resHeaders[key];
|
|
134
|
-
if (existing !== undefined) {
|
|
135
|
-
resHeaders[key] = Array.isArray(existing)
|
|
136
|
-
? [...existing, value]
|
|
137
|
-
: [existing, value];
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
resHeaders[key] = value;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
nodeRes.writeHead(response.status, resHeaders);
|
|
144
|
-
if (response.body) {
|
|
145
|
-
const reader = response.body.getReader();
|
|
146
|
-
while (true) {
|
|
147
|
-
const { done, value } = await reader.read();
|
|
148
|
-
if (done)
|
|
149
|
-
break;
|
|
150
|
-
nodeRes.write(value);
|
|
151
|
-
}
|
|
152
|
-
nodeRes.end();
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
nodeRes.end();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
catch (err) {
|
|
159
|
-
if (err instanceof PayloadTooLargeError) {
|
|
160
|
-
if (!nodeRes.headersSent) {
|
|
161
|
-
nodeRes.writeHead(413);
|
|
162
|
-
nodeRes.end(err.message);
|
|
163
|
-
}
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
console.error("[runtime.node] Request handler error:", err);
|
|
167
|
-
if (!nodeRes.headersSent) {
|
|
168
|
-
nodeRes.writeHead(500);
|
|
169
|
-
nodeRes.end("Internal Server Error");
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
server.on("error", (err) => {
|
|
174
|
-
if (options.onError) {
|
|
175
|
-
options.onError(err);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
throw err;
|
|
180
|
-
}, 0);
|
|
181
|
-
});
|
|
182
|
-
server.listen(options.port, hostname, () => {
|
|
183
|
-
if (options.onListen) {
|
|
184
|
-
const address = server.address();
|
|
185
|
-
const port = typeof address === "object" && address !== null
|
|
186
|
-
? address.port
|
|
187
|
-
: options.port;
|
|
188
|
-
options.onListen({ hostname, port });
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
return {
|
|
192
|
-
shutdown: () => new Promise((resolve, reject) => {
|
|
193
|
-
server.close((err) => {
|
|
194
|
-
if (err && !isNodeServerNotRunning(err)) {
|
|
195
|
-
reject(err);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
resolve();
|
|
199
|
-
});
|
|
200
|
-
}),
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Unref a timer so it doesn't block process exit.
|
|
205
|
-
*/
|
|
206
|
-
export function unrefTimer(id) {
|
|
207
|
-
// In Node.js, setTimeout returns a Timeout object (not a numeric ID).
|
|
208
|
-
// The caller passes it as `number` for Deno compat — we cast back.
|
|
209
|
-
try {
|
|
210
|
-
const timer = id;
|
|
211
|
-
if (typeof timer === "object" && timer && typeof timer.unref === "function") {
|
|
212
|
-
timer.unref();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
console.warn("[runtime.node] Failed to unref timer:", err);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/** Compile-time contract check — ensures this module satisfies RuntimePort */
|
|
220
|
-
void {
|
|
221
|
-
env,
|
|
222
|
-
readTextFile,
|
|
223
|
-
writeTextFile,
|
|
224
|
-
mkdir,
|
|
225
|
-
remove,
|
|
226
|
-
readDir,
|
|
227
|
-
serve,
|
|
228
|
-
unrefTimer,
|
|
229
|
-
};
|
|
230
|
-
// ─── Internal helpers ────────────────────────────────────
|
|
231
|
-
/** Collect request body from Node.js IncomingMessage */
|
|
232
|
-
function collectBody(req, maxBytes) {
|
|
233
|
-
return new Promise((resolve, reject) => {
|
|
234
|
-
const chunks = [];
|
|
235
|
-
let total = 0;
|
|
236
|
-
let rejected = false;
|
|
237
|
-
req.on("data", (chunk) => {
|
|
238
|
-
if (rejected)
|
|
239
|
-
return;
|
|
240
|
-
total += chunk.length;
|
|
241
|
-
if (maxBytes !== null && total > maxBytes) {
|
|
242
|
-
rejected = true;
|
|
243
|
-
req.destroy();
|
|
244
|
-
reject(new PayloadTooLargeError(maxBytes));
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
chunks.push(chunk);
|
|
248
|
-
});
|
|
249
|
-
req.on("end", () => {
|
|
250
|
-
if (!rejected) {
|
|
251
|
-
const body = Buffer.concat(chunks);
|
|
252
|
-
resolve(body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength));
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
req.on("error", (err) => {
|
|
256
|
-
if (!rejected) {
|
|
257
|
-
reject(err);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
function isNodeNotFound(err) {
|
|
263
|
-
return Boolean(err && typeof err === "object" && "code" in err && err.code === "ENOENT");
|
|
264
|
-
}
|
|
265
|
-
function isNodeServerNotRunning(err) {
|
|
266
|
-
return Boolean(err && typeof err === "object" && "code" in err &&
|
|
267
|
-
err.code === "ERR_SERVER_NOT_RUNNING");
|
|
268
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime Port — platform-agnostic contract
|
|
3
|
-
*
|
|
4
|
-
* Defines the interface that both Deno (runtime.ts) and Node.js (runtime.node.ts)
|
|
5
|
-
* must implement. This is the only file consumers need to understand the API shape.
|
|
6
|
-
*
|
|
7
|
-
* Pattern: each runtime file exports module-level functions that satisfy this port.
|
|
8
|
-
* The build script swaps runtime.ts → runtime.node.ts for Node.js distribution.
|
|
9
|
-
*
|
|
10
|
-
* @module lib/server/runtime-types
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Get an environment variable.
|
|
14
|
-
* Returns undefined if not set (never throws).
|
|
15
|
-
*/
|
|
16
|
-
export type EnvFn = (key: string) => string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Read a UTF-8 text file.
|
|
19
|
-
* Returns null if the file does not exist (no throw on ENOENT/NotFound).
|
|
20
|
-
* Throws on other errors (permission denied, etc.).
|
|
21
|
-
*/
|
|
22
|
-
export type ReadTextFileFn = (path: string) => Promise<string | null>;
|
|
23
|
-
/** Write a UTF-8 text file. */
|
|
24
|
-
export type WriteTextFileFn = (path: string, content: string, opts?: {
|
|
25
|
-
mode?: number;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
/** Create a directory. */
|
|
28
|
-
export type MkdirFn = (path: string, opts?: {
|
|
29
|
-
recursive?: boolean;
|
|
30
|
-
mode?: number;
|
|
31
|
-
}) => Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Remove a file or empty directory.
|
|
34
|
-
* Does nothing if the path does not exist.
|
|
35
|
-
*/
|
|
36
|
-
export type RemoveFn = (path: string) => Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Read directory entry names.
|
|
39
|
-
* Returns [] if the directory does not exist.
|
|
40
|
-
*/
|
|
41
|
-
export type ReadDirFn = (path: string) => Promise<string[]>;
|
|
42
|
-
/** Fetch-style request handler (Web standard) */
|
|
43
|
-
export type FetchHandler = (req: Request) => Response | Promise<Response>;
|
|
44
|
-
/** Options for starting an HTTP server */
|
|
45
|
-
export interface ServeOptions {
|
|
46
|
-
port: number;
|
|
47
|
-
hostname?: string;
|
|
48
|
-
onListen?: (info: {
|
|
49
|
-
hostname: string;
|
|
50
|
-
port: number;
|
|
51
|
-
}) => void;
|
|
52
|
-
/** Optional bind/startup error channel. */
|
|
53
|
-
onError?: (err: Error) => void;
|
|
54
|
-
/** Maximum request body size in bytes (optional, adapter-specific). */
|
|
55
|
-
maxBodyBytes?: number | null;
|
|
56
|
-
}
|
|
57
|
-
/** Handle returned by serve(), used to shut down the server */
|
|
58
|
-
export interface ServeHandle {
|
|
59
|
-
shutdown(): Promise<void>;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Start an HTTP server with a fetch-style handler.
|
|
63
|
-
*
|
|
64
|
-
* Deno: wraps Deno.serve()
|
|
65
|
-
* Node.js: wraps node:http.createServer() with Request/Response adapter
|
|
66
|
-
*/
|
|
67
|
-
export type ServeFn = (options: ServeOptions, handler: FetchHandler) => ServeHandle;
|
|
68
|
-
/**
|
|
69
|
-
* Unref a timer so it doesn't prevent process exit.
|
|
70
|
-
*
|
|
71
|
-
* Deno: Deno.unrefTimer(id)
|
|
72
|
-
* Node.js: timer.unref() on the Timeout object
|
|
73
|
-
*/
|
|
74
|
-
export type UnrefTimerFn = (id: number) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Complete runtime port contract.
|
|
77
|
-
*
|
|
78
|
-
* Both runtime.ts (Deno) and runtime.node.ts (Node.js) must export
|
|
79
|
-
* functions matching these signatures. Use `satisfies RuntimePort`
|
|
80
|
-
* at the bottom of each implementation to enforce at compile time.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* // At the bottom of runtime.ts / runtime.node.ts:
|
|
85
|
-
* export const _port = {
|
|
86
|
-
* env,
|
|
87
|
-
* readTextFile,
|
|
88
|
-
* writeTextFile,
|
|
89
|
-
* mkdir,
|
|
90
|
-
* remove,
|
|
91
|
-
* readDir,
|
|
92
|
-
* serve,
|
|
93
|
-
* unrefTimer,
|
|
94
|
-
* } satisfies RuntimePort;
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export interface RuntimePort {
|
|
98
|
-
env: EnvFn;
|
|
99
|
-
readTextFile: ReadTextFileFn;
|
|
100
|
-
writeTextFile: WriteTextFileFn;
|
|
101
|
-
mkdir: MkdirFn;
|
|
102
|
-
remove: RemoveFn;
|
|
103
|
-
readDir: ReadDirFn;
|
|
104
|
-
serve: ServeFn;
|
|
105
|
-
unrefTimer: UnrefTimerFn;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAIxD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAEtE,+BAA+B;AAC/B,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KACrB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,0BAA0B;AAC1B,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAC1C,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAI5D,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE1E,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9D,2CAA2C;IAC3C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,KAClB,WAAW,CAAC;AAIjB;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,KAAK,CAAC;IACX,YAAY,EAAE,cAAc,CAAC;IAC7B,aAAa,EAAE,eAAe,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,YAAY,CAAC;CAC1B"}
|
package/esm/src/runtime/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime Port — platform-agnostic contract
|
|
3
|
-
*
|
|
4
|
-
* Defines the interface that both Deno (runtime.ts) and Node.js (runtime.node.ts)
|
|
5
|
-
* must implement. This is the only file consumers need to understand the API shape.
|
|
6
|
-
*
|
|
7
|
-
* Pattern: each runtime file exports module-level functions that satisfy this port.
|
|
8
|
-
* The build script swaps runtime.ts → runtime.node.ts for Node.js distribution.
|
|
9
|
-
*
|
|
10
|
-
* @module lib/server/runtime-types
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HMAC Channel Authentication — Inline Script for PostMessage (MCP Apps)
|
|
3
|
-
*
|
|
4
|
-
* Generates an inline `<script>` that signs outgoing JSON-RPC messages
|
|
5
|
-
* from an iframe to its parent via PostMessage (HMAC-SHA256 + anti-replay).
|
|
6
|
-
*
|
|
7
|
-
* The HOST side is responsible for verifying incoming messages using
|
|
8
|
-
* `MessageSigner.verify()`. This script only handles the IFRAME side
|
|
9
|
-
* (signing outgoing).
|
|
10
|
-
*
|
|
11
|
-
* Part of @casys/mcp-server security module. See also:
|
|
12
|
-
* - message-signer.ts (MessageSigner class, HMAC sign/verify)
|
|
13
|
-
*
|
|
14
|
-
* @module server/security/channel-hmac
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Generate the inline `<script>` tag for iframe HMAC signing.
|
|
18
|
-
*
|
|
19
|
-
* The script:
|
|
20
|
-
* 1. Embeds the channel secret (invisible to other iframes due to cross-origin)
|
|
21
|
-
* 2. Monkey-patches `window.parent.postMessage` to sign outgoing JSON-RPC
|
|
22
|
-
*
|
|
23
|
-
* Verification of incoming messages is the HOST's responsibility
|
|
24
|
-
* (via `MessageSigner.verify()`), not the iframe's.
|
|
25
|
-
*
|
|
26
|
-
* @param secret - 64-char hex secret from MessageSigner.generateSecret()
|
|
27
|
-
* @returns HTML `<script>` string ready for injection into `<head>`
|
|
28
|
-
*/
|
|
29
|
-
export declare function generateHmacScript(secret: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Inject channel authentication script into HTML content.
|
|
32
|
-
*
|
|
33
|
-
* Inserts the HMAC signing script before `</head>` (preferred) or at the start.
|
|
34
|
-
* The injected script signs all outgoing JSON-RPC postMessages from the iframe.
|
|
35
|
-
* The HOST must verify these signatures using `MessageSigner.verify()`.
|
|
36
|
-
*
|
|
37
|
-
* @param html - HTML content to inject into
|
|
38
|
-
* @param secret - 64-char hex secret from MessageSigner.generateSecret()
|
|
39
|
-
* @returns Modified HTML with HMAC signing script injected
|
|
40
|
-
* @throws {Error} If secret is not a valid 64-char hex string
|
|
41
|
-
*/
|
|
42
|
-
export declare function injectChannelAuth(html: string, secret: string): string;
|
|
43
|
-
//# sourceMappingURL=channel-hmac.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel-hmac.d.ts","sourceRoot":"","sources":["../../../src/src/security/channel-hmac.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgFzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAYtE"}
|