devframe 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_shared-Cm4iD0L3.d.mts → _shared-BxeuukaL.d.mts} +2 -4
- package/dist/{_shared-C61zPwIz.mjs → _shared-CtXCQFTV.mjs} +6 -9
- package/dist/adapters/build.d.mts +3 -5
- package/dist/adapters/build.mjs +7 -8
- package/dist/adapters/cac.d.mts +1 -3
- package/dist/adapters/cac.mjs +5 -7
- package/dist/adapters/dev.d.mts +6 -8
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +2 -4
- package/dist/adapters/embedded.mjs +1 -2
- package/dist/adapters/initiate.d.mts +10 -10
- package/dist/adapters/initiate.mjs +1 -2
- package/dist/adapters/mcp.d.mts +2 -2
- package/dist/adapters/mcp.mjs +1 -2
- package/dist/{agentic-C6SCkdtj.d.mts → agentic-DVgUzwhV.d.mts} +1 -3
- package/dist/{browser-agent-Pu-FLk6I.mjs → browser-agent-DmAotroz.mjs} +1 -2
- package/dist/{browser-agent-rpc-KH4HHvHf.mjs → browser-agent-rpc-CS80Sphv.mjs} +3 -5
- package/dist/cli/main.d.mts +1 -3
- package/dist/cli/main.mjs +3 -4
- package/dist/client/index.d.mts +6 -30
- package/dist/client/index.mjs +47 -72
- package/dist/{client-agent-iBkMYxqn.mjs → client-agent-qNMgDUev.mjs} +7 -12
- package/dist/constants.d.mts +1 -5
- package/dist/constants.mjs +2 -3
- package/dist/{context-BGJi0ITA.d.mts → context-B-AARy_U.d.mts} +1 -3
- package/dist/{context-D_jSSdME.mjs → context-BTxC4QrJ.mjs} +4 -5
- package/dist/{context-CAJ5V017.mjs → context-C5FcbWQi.mjs} +25 -41
- package/dist/{crypto-token-TVbGGFuj.mjs → crypto-token-CUhPE_ei.mjs} +1 -2
- package/dist/{define-BLWPsH6y.mjs → define-C8h-fyD3.mjs} +1 -2
- package/dist/{dev-BKBjIpX3.mjs → dev-Cu_iwSCy.mjs} +9 -11
- package/dist/{diagnostics-E_PvUPsA.mjs → diagnostics-DC1-WcvN.mjs} +2 -3
- package/dist/{dist-CO98PBnQ.mjs → dist-BWGpvt-z.mjs} +1 -2
- package/dist/{dist-CZXfGEkd.mjs → dist-CZ-TySHD.mjs} +3 -11
- package/dist/{events-0wDwalmL.mjs → events-qWCKwD8-.mjs} +1 -2
- package/dist/{handler-DmaAfpGq.mjs → handler-DkLlj3-B.mjs} +3 -5
- package/dist/{hash-DdPnc4k3.mjs → hash-DHqpWeMO.mjs} +4 -8
- package/dist/{host-h3-BROI6SQ4.mjs → host-h3-D1uj5EM8.mjs} +1 -2
- package/dist/{import-runtime-module-BzlEQ9PI.mjs → import-runtime-module-DsdqJ1gK.mjs} +2 -3
- package/dist/in-page-channel/index.d.mts +3 -12
- package/dist/in-page-channel/index.mjs +10 -16
- package/dist/{index-CeEtxDmK.d.mts → index-BIRF0E5l.d.mts} +0 -2
- package/dist/{index-Bia1vKjL.d.mts → index-BKu9BxcT.d.mts} +0 -2
- package/dist/{context-BNxFOPbX.d.mts → index-BhUqJUHG.d.mts} +1408 -1442
- package/dist/index.d.mts +7 -8
- package/dist/index.mjs +3 -4
- package/dist/{instance-registry-C_4PpB6N.mjs → instance-registry-DwmnWyCK.mjs} +4 -10
- package/dist/{instance-shell-m4sY2oTG.mjs → instance-shell-Coid7CP6.mjs} +38 -17
- package/dist/{instance-shell-GihbmXoF.d.mts → instance-shell-DTk514M9.d.mts} +6 -10
- package/dist/{interactive-auth-DdDxs3WF.mjs → interactive-auth-BURwIAvE.mjs} +6 -8
- package/dist/internal/index.d.mts +9 -29
- package/dist/internal/index.mjs +13 -15
- package/dist/{mcp-content-QImBQO8e.d.mts → mcp-content-0a0mpCL5.d.mts} +1 -3
- package/dist/{mcp-content-DN3O212x.mjs → mcp-content-CqU8yaF7.mjs} +1 -2
- package/dist/{mrmime-40h5OOIp.mjs → mrmime-y_XyiVcd.mjs} +1 -2
- package/dist/node/auth.d.mts +84 -3
- package/dist/node/auth.mjs +2 -2
- package/dist/node/hub-internals.d.mts +11 -2
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +4 -6
- package/dist/node/index.mjs +2 -2
- package/dist/{nostics-D0PvLZsn.mjs → nostics-InlX4tmd.mjs} +2 -4
- package/dist/{origin-DZit9g29.mjs → origin-Ck7mLbKU.mjs} +1 -2
- package/dist/recipes/interactive-auth.d.mts +3 -5
- package/dist/recipes/interactive-auth.mjs +1 -2
- package/dist/{remote-assets-eBvSKZMS.d.mts → remote-assets-5AQMHZnV.d.mts} +0 -2
- package/dist/{remote-assets-B-n83kUY.mjs → remote-assets-DhonNeo_.mjs} +5 -8
- package/dist/{revoke-CeQUo6KI.mjs → revoke-D6KA3vwr.mjs} +2 -3
- package/dist/{rolldown-runtime-B4iAMlE-.mjs → rolldown-runtime-BVN1G_yT.mjs} +6 -7
- package/dist/rpc/client.d.mts +2 -4
- package/dist/rpc/client.mjs +2 -3
- package/dist/rpc/dump.d.mts +3 -11
- package/dist/rpc/dump.mjs +1 -2
- package/dist/rpc/index.d.mts +122 -4
- package/dist/rpc/index.mjs +6 -8
- package/dist/rpc/server.d.mts +2 -4
- package/dist/rpc/server.mjs +2 -3
- package/dist/rpc/transports/sse-client.d.mts +34 -2
- package/dist/rpc/transports/sse-client.mjs +2 -3
- package/dist/rpc/transports/sse-server.d.mts +5 -7
- package/dist/rpc/transports/sse-server.mjs +4 -5
- package/dist/rpc/transports/ws-bun.d.mts +3 -5
- package/dist/rpc/transports/ws-bun.mjs +2 -3
- package/dist/rpc/transports/ws-client.d.mts +27 -2
- package/dist/rpc/transports/ws-client.mjs +2 -3
- package/dist/rpc/transports/ws-deno.d.mts +3 -5
- package/dist/rpc/transports/ws-deno.mjs +2 -3
- package/dist/rpc/transports/ws-server.d.mts +151 -4
- package/dist/rpc/transports/ws-server.mjs +5 -6
- package/dist/{rpc-core-BLc5hm9X.mjs → rpc-core-BmDHiDR6.mjs} +4 -5
- package/dist/{rpc-core-CGTCla-R.d.mts → rpc-core-CblgPYJ_.d.mts} +5 -7
- package/dist/{serialization-BhuOoL80.mjs → serialization-iiTQ7n21.mjs} +3 -5
- package/dist/{services-install-D5YUwFXW.mjs → services-install-DCuDzMJ-.mjs} +1 -2
- package/dist/{session-DPfj6zQG.mjs → session-BjvoLH3r.mjs} +1 -2
- package/dist/{session-r6PDixP6.d.mts → session-Y9R6tqg4.d.mts} +0 -2
- package/dist/{shared-state-Cc-Jrhma.mjs → shared-state-COV7NCbd.mjs} +4 -6
- package/dist/{state-W4wI6X5X.mjs → state-B_yjfeqo.mjs} +3 -5
- package/dist/{storage-CWI9PZ-5.mjs → storage-DpJ52UB_.mjs} +3 -5
- package/dist/{structured-clone-CbAV5rFI.mjs → structured-clone-B1N_XQvA.mjs} +2 -4
- package/dist/{structured-clone-CgtQ61SA.mjs → structured-clone-D1dOCZvc.mjs} +2 -4
- package/dist/{tool-input-CES3Pc4y.mjs → tool-input-CcCgJ8jq.mjs} +6 -12
- package/dist/types/index.d.mts +5 -5
- package/dist/{types-BmDbfHCx.d.mts → types-KZOyhez5.d.mts} +2 -5
- package/dist/utils/agent-tool-name.d.mts +1 -3
- package/dist/utils/agent-tool-name.mjs +1 -2
- package/dist/utils/colors.d.mts +1 -3
- package/dist/utils/colors.mjs +1 -2
- package/dist/utils/crypto-token.d.mts +1 -3
- package/dist/utils/crypto-token.mjs +1 -2
- package/dist/utils/debounce.d.mts +6 -2
- package/dist/utils/debounce.mjs +1 -2
- package/dist/utils/events.d.mts +2 -4
- package/dist/utils/events.mjs +1 -2
- package/dist/utils/get-port.d.mts +0 -2
- package/dist/utils/get-port.mjs +1 -2
- package/dist/utils/hash.d.mts +1 -3
- package/dist/utils/hash.mjs +1 -2
- package/dist/utils/launch-editor.d.mts +1 -3
- package/dist/utils/launch-editor.mjs +25 -37
- package/dist/utils/nanoid.d.mts +1 -3
- package/dist/utils/nanoid.mjs +1 -2
- package/dist/utils/nostics.d.mts +40 -2
- package/dist/utils/nostics.mjs +1 -2
- package/dist/utils/open.d.mts +1 -3
- package/dist/utils/open.mjs +1 -2
- package/dist/utils/origin.d.mts +55 -2
- package/dist/utils/origin.mjs +1 -2
- package/dist/utils/remote-assets.d.mts +2 -4
- package/dist/utils/remote-assets.mjs +1 -2
- package/dist/utils/serve-static.d.mts +3 -5
- package/dist/utils/serve-static.mjs +3 -4
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -2
- package/dist/utils/simple-schema.d.mts +1 -3
- package/dist/utils/simple-schema.mjs +1 -2
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/streaming-channel.mjs +1 -2
- package/dist/utils/structured-clone.d.mts +1 -3
- package/dist/utils/structured-clone.mjs +1 -2
- package/dist/utils/url.d.mts +1 -3
- package/dist/utils/url.mjs +1 -2
- package/dist/utils/when.d.mts +1 -3
- package/dist/utils/when.mjs +2 -4
- package/dist/{validation-CMfDAti3.mjs → validation-Cjy1P58H.mjs} +7 -13
- package/dist/{wire-codec-B1W3zH3L.mjs → wire-codec-BdngvzfH.mjs} +3 -4
- package/dist/{write-DK7rBUN3.mjs → write-3miSvPaD.mjs} +10 -16
- package/package.json +8 -8
- package/dist/index-CxJatyA1.d.mts +0 -88
- package/dist/index-DuEm0sDH.d.mts +0 -135
- package/dist/nostics-DWvukRwa.d.mts +0 -42
- package/dist/origin-CY6BBHOy.d.mts +0 -58
- package/dist/sse-client-DNdscfu_.d.mts +0 -37
- package/dist/ws-client-6Mrz6eC4.d.mts +0 -30
- package/dist/ws-server-y2R76aSW.d.mts +0 -152
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as diagnostics } from "./serialization-
|
|
1
|
+
import { r as diagnostics } from "./serialization-iiTQ7n21.mjs";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
|
|
3
|
+
// ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/_chunks/is-equal.mjs
|
|
4
4
|
function serialize(input) {
|
|
5
5
|
if (typeof input === "string") return `'${input}'`;
|
|
6
6
|
return new Serializer().serialize(input);
|
|
@@ -147,8 +147,7 @@ const Serializer = /*@__PURE__*/ (function() {
|
|
|
147
147
|
};
|
|
148
148
|
return Serializer;
|
|
149
149
|
})();
|
|
150
|
-
|
|
151
|
-
//#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/crypto/node/index.mjs
|
|
150
|
+
// ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/crypto/node/index.mjs
|
|
152
151
|
const fastHash = /*@__PURE__*/ (() => globalThis.process?.getBuiltinModule?.("crypto")?.hash)();
|
|
153
152
|
const algorithm = "sha256";
|
|
154
153
|
const encoding = "base64url";
|
|
@@ -157,21 +156,18 @@ function digest(data) {
|
|
|
157
156
|
const h = createHash(algorithm).update(data);
|
|
158
157
|
return globalThis.process?.versions?.webcontainer ? h.digest().toString(encoding) : h.digest(encoding);
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
//#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/index.mjs
|
|
159
|
+
// ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/index.mjs
|
|
162
160
|
function hash$1(input) {
|
|
163
161
|
return digest(serialize(input));
|
|
164
162
|
}
|
|
165
|
-
|
|
166
|
-
//#region src/utils/hash.ts
|
|
163
|
+
// src/utils/hash.ts
|
|
167
164
|
/**
|
|
168
165
|
* Stable, deterministic hash of any structured-cloneable value.
|
|
169
166
|
*/
|
|
170
167
|
function hash(value) {
|
|
171
168
|
return hash$1(value);
|
|
172
169
|
}
|
|
173
|
-
|
|
174
|
-
//#region src/rpc/agent-json-serialization.ts
|
|
170
|
+
// src/rpc/agent-json-serialization.ts
|
|
175
171
|
/**
|
|
176
172
|
* Prevents using a coding-agent-exposed RPC function that is explicitly
|
|
177
173
|
* marked as non-serializable, and marks these functions as serializable by
|
|
@@ -183,8 +179,7 @@ function ensureAgentJsonSerializable(fnDef) {
|
|
|
183
179
|
if (fnDef.agent && fnDef.jsonSerializable === false) throw diagnostics.DF0019({ name: fnDef.name });
|
|
184
180
|
if (fnDef.agent && !fnDef.jsonSerializable) fnDef.jsonSerializable = true;
|
|
185
181
|
}
|
|
186
|
-
|
|
187
|
-
//#region src/rpc/validation.ts
|
|
182
|
+
// src/rpc/validation.ts
|
|
188
183
|
/**
|
|
189
184
|
* Validates RPC function definitions.
|
|
190
185
|
* Action and event functions cannot have dumps (side effects should not be cached).
|
|
@@ -212,5 +207,4 @@ function validateDefinitions(definitions) {
|
|
|
212
207
|
function validateDefinition(definition) {
|
|
213
208
|
validateDefinitions([definition]);
|
|
214
209
|
}
|
|
215
|
-
//#endregion
|
|
216
210
|
export { hash as i, validateDefinitions as n, ensureAgentJsonSerializable as r, validateDefinition as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as
|
|
3
|
-
|
|
1
|
+
import { n as structuredCloneStringify, t as structuredCloneParse } from "./structured-clone-B1N_XQvA.mjs";
|
|
2
|
+
import { n as strictJsonStringify } from "./serialization-iiTQ7n21.mjs";
|
|
3
|
+
// src/rpc/wire-codec.ts
|
|
4
4
|
const EMPTY_WIRE_DEFS = /* @__PURE__ */ new Map();
|
|
5
5
|
/**
|
|
6
6
|
* Build the per-connection wire codec every live transport (WS server, WS
|
|
@@ -52,5 +52,4 @@ function peekRpcWireFrame(raw) {
|
|
|
52
52
|
return {};
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
//#endregion
|
|
56
55
|
export { peekRpcWireFrame as n, createRpcWireCodec as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as hash, n as validateDefinitions, r as ensureAgentJsonSerializable } from "./validation-
|
|
2
|
-
import { n as strictJsonStringify, r as diagnostics } from "./serialization-
|
|
3
|
-
import { t as getRpcHandler } from "./handler-
|
|
1
|
+
import { i as hash, n as validateDefinitions, r as ensureAgentJsonSerializable } from "./validation-Cjy1P58H.mjs";
|
|
2
|
+
import { n as strictJsonStringify, r as diagnostics } from "./serialization-iiTQ7n21.mjs";
|
|
3
|
+
import { t as getRpcHandler } from "./handler-DkLlj3-B.mjs";
|
|
4
4
|
import { DEVFRAME_RPC_DUMP_DIRNAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "./constants.mjs";
|
|
5
|
-
import { n as structuredCloneStringify } from "./structured-clone-
|
|
5
|
+
import { n as structuredCloneStringify } from "./structured-clone-B1N_XQvA.mjs";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import { dirname, resolve } from "pathe";
|
|
8
|
-
|
|
8
|
+
// ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
|
|
9
9
|
var Node = class {
|
|
10
10
|
value;
|
|
11
11
|
next;
|
|
@@ -62,8 +62,7 @@ var Queue = class {
|
|
|
62
62
|
while (this.#head) yield this.dequeue();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
//#region ../../node_modules/.pnpm/p-limit@7.3.3/node_modules/p-limit/index.js
|
|
65
|
+
// ../../node_modules/.pnpm/p-limit@7.3.3/node_modules/p-limit/index.js
|
|
67
66
|
function pLimit(concurrency) {
|
|
68
67
|
let rejectOnClear = false;
|
|
69
68
|
if (typeof concurrency === "object") ({concurrency, rejectOnClear = false} = concurrency);
|
|
@@ -141,8 +140,7 @@ function pLimit(concurrency) {
|
|
|
141
140
|
function validateConcurrency(concurrency) {
|
|
142
141
|
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
143
142
|
}
|
|
144
|
-
|
|
145
|
-
//#region src/rpc/dump/error.ts
|
|
143
|
+
// src/rpc/dump/error.ts
|
|
146
144
|
/**
|
|
147
145
|
* Normalize a thrown value into a plain object suitable for storage in
|
|
148
146
|
* a dump record. Preserves `message`, `name`, `cause`, and any own
|
|
@@ -192,8 +190,7 @@ function reviveDumpError(stored) {
|
|
|
192
190
|
function isPlainErrorShape(value) {
|
|
193
191
|
return typeof value === "object" && value !== null && typeof value.message === "string" && typeof value.name === "string";
|
|
194
192
|
}
|
|
195
|
-
|
|
196
|
-
//#region src/rpc/dump/collect.ts
|
|
193
|
+
// src/rpc/dump/collect.ts
|
|
197
194
|
function getDumpRecordKey(functionName, args) {
|
|
198
195
|
return `${functionName}---${hash(args)}`;
|
|
199
196
|
}
|
|
@@ -344,8 +341,7 @@ function createClientFromDump(store, options = {}) {
|
|
|
344
341
|
function getDefinitionsWithDumps(definitions) {
|
|
345
342
|
return definitions.filter((def) => def.dump !== void 0);
|
|
346
343
|
}
|
|
347
|
-
|
|
348
|
-
//#region src/rpc/dump/static.ts
|
|
344
|
+
// src/rpc/dump/static.ts
|
|
349
345
|
function makeDumpKey(name) {
|
|
350
346
|
return encodeURIComponent(name.replaceAll(":", "~"));
|
|
351
347
|
}
|
|
@@ -429,8 +425,7 @@ async function collectStaticRpcDump(definitions, context) {
|
|
|
429
425
|
files
|
|
430
426
|
};
|
|
431
427
|
}
|
|
432
|
-
|
|
433
|
-
//#region src/rpc/dump/write.ts
|
|
428
|
+
// src/rpc/dump/write.ts
|
|
434
429
|
/**
|
|
435
430
|
* Write a collected static RPC dump to disk: every sharded record file plus
|
|
436
431
|
* the `__rpc-dump/index.json` manifest, under `outDir`. Shared by the build
|
|
@@ -447,5 +442,4 @@ async function writeStaticRpcDump(dump, outDir, options = {}) {
|
|
|
447
442
|
}
|
|
448
443
|
await fs.writeFile(resolve(outDir, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME), JSON.stringify(dump.manifest, null, 2), "utf-8");
|
|
449
444
|
}
|
|
450
|
-
//#endregion
|
|
451
445
|
export { getDefinitionsWithDumps as a, dumpFunctions as i, collectStaticRpcDump as n, reviveDumpError as o, createClientFromDump as r, serializeDumpError as s, writeStaticRpcDump as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devframe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"description": "Framework for building one portable devtool integration that runs in any viewer.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"skills"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@devframes/agentic": "1.3.
|
|
80
|
+
"@devframes/agentic": "1.3.3",
|
|
81
81
|
"cac": "^7.0.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
@@ -89,18 +89,18 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"crossws": "^0.4.
|
|
93
|
-
"h3": "^2.0.
|
|
92
|
+
"crossws": "^0.4.17",
|
|
93
|
+
"h3": "^2.0.8",
|
|
94
94
|
"nostics": "^1.3.0",
|
|
95
95
|
"pathe": "^2.0.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@devframes/agentic": "1.3.
|
|
98
|
+
"@devframes/agentic": "1.3.3",
|
|
99
99
|
"@standard-schema/spec": "^1.1.0",
|
|
100
100
|
"birpc": "^4.2.0",
|
|
101
101
|
"cac": "^7.1.0",
|
|
102
102
|
"get-port-please": "^3.2.0",
|
|
103
|
-
"immer": "^11.2.
|
|
103
|
+
"immer": "^11.2.9",
|
|
104
104
|
"launch-editor": "^2.14.2",
|
|
105
105
|
"mlly": "^1.8.2",
|
|
106
106
|
"mrmime": "^2.0.1",
|
|
@@ -110,12 +110,12 @@
|
|
|
110
110
|
"perfect-debounce": "^2.1.0",
|
|
111
111
|
"structured-clone-es": "^2.0.1",
|
|
112
112
|
"tinyglobby": "^0.2.17",
|
|
113
|
-
"tsdown": "0.23.
|
|
113
|
+
"tsdown": "^0.23.7",
|
|
114
114
|
"typescript": "^6.0.3",
|
|
115
115
|
"ua-parser-modern": "^0.1.1",
|
|
116
116
|
"valibot": "^1.5.0",
|
|
117
117
|
"whenexpr": "^0.1.2",
|
|
118
|
-
"ws": "^8.22.
|
|
118
|
+
"ws": "^8.22.2"
|
|
119
119
|
},
|
|
120
120
|
"scripts": {
|
|
121
121
|
"build": "tsdown",
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-BNxFOPbX.mjs";
|
|
2
|
-
import { n as InternalAnonymousAuthStorage } from "./context-BGJi0ITA.mjs";
|
|
3
|
-
//#region src/node/auth/revoke.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Flip `isTrusted` to false on any live WS clients connected with `token`
|
|
6
|
-
* and broadcast the `auth:revoked` event so they can react.
|
|
7
|
-
*
|
|
8
|
-
* Shared between persisted-auth revocation and remote-dock token revocation.
|
|
9
|
-
*/
|
|
10
|
-
declare function revokeActiveConnectionsForToken(context: DevframeNodeContext, token: string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Revoke an auth token: remove from storage and notify all connected clients
|
|
13
|
-
* using this token that they are no longer trusted.
|
|
14
|
-
*/
|
|
15
|
-
declare function revokeAuthToken(context: DevframeNodeContext, storage: SharedState<InternalAnonymousAuthStorage>, token: string): Promise<void>;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/node/auth/state.d.ts
|
|
18
|
-
/**
|
|
19
|
-
* Format a raw `navigator.userAgent` string into the short display label
|
|
20
|
-
* shown for a trusted device (e.g. "Chrome 120 | macOS 14 desktop").
|
|
21
|
-
*
|
|
22
|
-
* The client used to parse+format this itself, but that pulled
|
|
23
|
-
* `ua-parser-modern` into the browser bundle for a label nothing else on
|
|
24
|
-
* the client needs; the client now sends the raw string and parsing
|
|
25
|
-
* happens here, at the server ingress, keeping the persisted label format
|
|
26
|
-
* identical.
|
|
27
|
-
*/
|
|
28
|
-
declare function describeUA(userAgent: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* The current one-time authentication code. Display this to the user (e.g. in
|
|
31
|
-
* the dev-server terminal) so they can type it into the browser to authenticate.
|
|
32
|
-
*/
|
|
33
|
-
declare function getTempAuthCode(): string;
|
|
34
|
-
/**
|
|
35
|
-
* The current code plus its expiry timestamp, for display (e.g. the auth
|
|
36
|
-
* banner). An already-expired code is rotated first, so the returned code is
|
|
37
|
-
* always redeemable for its remaining lifetime.
|
|
38
|
-
*/
|
|
39
|
-
declare function getTempAuthCodeInfo(): {
|
|
40
|
-
code: string;
|
|
41
|
-
expireAt: number;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Rotate the authentication code, resetting its expiry window and failed-attempt
|
|
45
|
-
* counter. Call this when a new authentication flow begins (e.g. when an
|
|
46
|
-
* untrusted client starts authenticating) so the displayed code is freshly
|
|
47
|
-
* valid for its full TTL.
|
|
48
|
-
*/
|
|
49
|
-
declare function refreshTempAuthCode(): string;
|
|
50
|
-
/**
|
|
51
|
-
* Build a "magic link" authentication URL that embeds a one-time code (OTP) in
|
|
52
|
-
* the URL **fragment**. Opening it authenticates the client without typing;
|
|
53
|
-
* print it on startup (devframe stays headless, so the host prints its own
|
|
54
|
-
* banner). Defaults to the current code; the link is subject to the same TTL.
|
|
55
|
-
*
|
|
56
|
-
* The code rides the fragment (`#devframe_otp=…`), not the query string, so it
|
|
57
|
-
* is never sent to the server, written to an access log, or leaked in a
|
|
58
|
-
* `Referer` header; the browser client reads it locally (see
|
|
59
|
-
* `consumeOtpFromUrl`). Any existing fragment parameters are preserved.
|
|
60
|
-
*/
|
|
61
|
-
declare function buildOtpAuthUrl(baseUrl: string, code?: string): string;
|
|
62
|
-
/**
|
|
63
|
-
* Re-authenticate a connection that presents a previously-issued bearer token.
|
|
64
|
-
* Returns `true` and marks the session trusted when the token is known.
|
|
65
|
-
*
|
|
66
|
-
* Used by the `anonymous:devframe:auth` handler so a client that already
|
|
67
|
-
* authenticated (token persisted in the browser) is trusted on reconnect
|
|
68
|
-
* without entering the code again.
|
|
69
|
-
*/
|
|
70
|
-
declare function verifyAuthToken(token: string, session: DevframeNodeRpcSession, storage: SharedState<InternalAnonymousAuthStorage>): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Exchange a one-time authentication code for a fresh, node-issued bearer token.
|
|
73
|
-
*
|
|
74
|
-
* On success this mints a high-entropy token, records it in the trusted store,
|
|
75
|
-
* marks the calling session trusted, rotates the code, and returns the token
|
|
76
|
-
* for the client to persist. Returns `null` on any failure.
|
|
77
|
-
*
|
|
78
|
-
* Because the code is short and human-typed, verification is hardened against
|
|
79
|
-
* brute force: it enforces a time-to-live, compares in constant time, and
|
|
80
|
-
* rotates the code after {@link TEMP_AUTH_MAX_ATTEMPTS} failed attempts so an
|
|
81
|
-
* attacker cannot keep guessing against the same code.
|
|
82
|
-
*/
|
|
83
|
-
declare function exchangeTempAuthCode(code: string, session: DevframeNodeRpcSession, info: {
|
|
84
|
-
ua: string;
|
|
85
|
-
origin: string;
|
|
86
|
-
}, storage: SharedState<InternalAnonymousAuthStorage>): string | null;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { getTempAuthCodeInfo as a, revokeActiveConnectionsForToken as c, getTempAuthCode as i, revokeAuthToken as l, describeUA as n, refreshTempAuthCode as o, exchangeTempAuthCode as r, verifyAuthToken as s, buildOtpAuthUrl as t };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { C as RpcFunctionType, S as RpcFunctionSetupResult, T as RpcReturnSchema, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, n as RpcArgsSchema, w as RpcFunctionsCollector } from "./types-BmDbfHCx.mjs";
|
|
2
|
-
//#region src/rpc/cache.d.ts
|
|
3
|
-
interface RpcCacheOptions {
|
|
4
|
-
functions: string[];
|
|
5
|
-
keySerializer?: (args: unknown[]) => string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* @experimental API is expected to change.
|
|
9
|
-
*/
|
|
10
|
-
declare class RpcCacheManager {
|
|
11
|
-
private cacheMap;
|
|
12
|
-
private options;
|
|
13
|
-
private keySerializer;
|
|
14
|
-
constructor(options: RpcCacheOptions);
|
|
15
|
-
updateOptions(options: Partial<RpcCacheOptions>): void;
|
|
16
|
-
cached<T>(m: string, a: unknown[]): T | undefined;
|
|
17
|
-
has(m: string, a: unknown[]): boolean;
|
|
18
|
-
apply(req: {
|
|
19
|
-
m: string;
|
|
20
|
-
a: unknown[];
|
|
21
|
-
}, res: unknown): void;
|
|
22
|
-
validate(m: string): boolean;
|
|
23
|
-
clear(fn?: string): void;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/rpc/collector.d.ts
|
|
27
|
-
declare class RpcFunctionsCollectorBase<LocalFunctions extends Record<string, any>, SetupContext> implements RpcFunctionsCollector<LocalFunctions, SetupContext> {
|
|
28
|
-
readonly context: SetupContext;
|
|
29
|
-
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>>;
|
|
30
|
-
readonly functions: LocalFunctions;
|
|
31
|
-
private readonly _onChanged;
|
|
32
|
-
constructor(context: SetupContext);
|
|
33
|
-
register(fnDef: RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>, force?: boolean): void;
|
|
34
|
-
update(fn: RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>, force?: boolean): void;
|
|
35
|
-
onChanged(fn: (id?: string) => void): () => void;
|
|
36
|
-
getHandler<T extends keyof LocalFunctions>(name: T): Promise<LocalFunctions[T]>;
|
|
37
|
-
getSchema<T extends keyof LocalFunctions>(name: T): {
|
|
38
|
-
args: RpcArgsSchema | undefined;
|
|
39
|
-
returns: RpcReturnSchema | undefined;
|
|
40
|
-
};
|
|
41
|
-
has(name: string): boolean;
|
|
42
|
-
get(name: string): RpcFunctionDefinition<string, any, any, any, any, any, SetupContext> | undefined;
|
|
43
|
-
list(): string[];
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/rpc/define.d.ts
|
|
47
|
-
declare function defineRpcFunction<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS>): RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS>;
|
|
48
|
-
declare function createDefineWrapperWithContext<CONTEXT>(): <NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, CONTEXT>) => RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, CONTEXT>;
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/rpc/handler.d.ts
|
|
51
|
-
declare function getRpcResolvedSetupResult<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, CONTEXT = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, any, any, CONTEXT>, context: CONTEXT): Promise<RpcFunctionSetupResult<ARGS, RETURN>>;
|
|
52
|
-
declare function getRpcHandler<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, CONTEXT = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, any, any, CONTEXT>, context: CONTEXT): Promise<(...args: ARGS) => RETURN>;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/rpc/serialization.d.ts
|
|
55
|
-
/**
|
|
56
|
-
* Wire format used by the live RPC transports (WebSocket and SSE).
|
|
57
|
-
*
|
|
58
|
-
* - **JSON (default, unprefixed):** payload is plain JSON text. Used when
|
|
59
|
-
* the dispatched method is declared `jsonSerializable: true`. Encoded
|
|
60
|
-
* via {@link strictJsonStringify} (rejects non-JSON values), decoded
|
|
61
|
-
* via `JSON.parse`.
|
|
62
|
-
* - **Structured-clone (`s:` prefix):** payload is `s:` followed by
|
|
63
|
-
* `structured-clone-es` text. Used when the method is declared
|
|
64
|
-
* `jsonSerializable: false` (or omitted, the default). Round-trips
|
|
65
|
-
* `Map`, `Set`, `Date`, `BigInt`, cycles, and class instances.
|
|
66
|
-
*
|
|
67
|
-
* birpc envelopes always start with `{`, so a leading byte that is not
|
|
68
|
-
* `s` is unambiguously JSON. Each direction independently chooses its
|
|
69
|
-
* encoding from local definitions; request and response are not
|
|
70
|
-
* coupled by a mirror rule.
|
|
71
|
-
*/
|
|
72
|
-
declare const STRUCTURED_CLONE_PREFIX = "s:";
|
|
73
|
-
/**
|
|
74
|
-
* `JSON.stringify` with a single-pass strict replacer.
|
|
75
|
-
*
|
|
76
|
-
* Throws `DF0020` synchronously when the value contains a type JSON
|
|
77
|
-
* cannot round-trip losslessly: `Map`, `Set`, `Date`, `BigInt`, class
|
|
78
|
-
* instances, or `undefined` inside an array (silently becomes `null`).
|
|
79
|
-
*
|
|
80
|
-
* Native pass-throughs (no extra work needed):
|
|
81
|
-
* - circular references: `JSON.stringify` raises `TypeError`.
|
|
82
|
-
* - `BigInt` at top level: caught here for a friendlier error path.
|
|
83
|
-
*
|
|
84
|
-
* Lenient cases (allowed without throwing):
|
|
85
|
-
* - `undefined` as an object property: legitimate optional field;
|
|
86
|
-
* JSON.stringify just omits it.
|
|
87
|
-
* - `undefined` at the root: legitimate "action returned nothing".
|
|
88
|
-
* - `Symbol` / `Function` values: semantically "drop me" in JSON.
|
|
89
|
-
*
|
|
90
|
-
* `fnName` is used only for the diagnostic message; pass the RPC
|
|
91
|
-
* function name when calling from a wire serializer / dump writer so
|
|
92
|
-
* the error points at the offending function.
|
|
93
|
-
*/
|
|
94
|
-
declare function strictJsonStringify(value: unknown, fnName?: string): string;
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/rpc/validate-io.d.ts
|
|
97
|
-
/**
|
|
98
|
-
* Validate positional arguments against their declared schemas. Only
|
|
99
|
-
* indices with a schema are checked; extra arguments pass through
|
|
100
|
-
* untouched. Throws `DF0038` on the first failing argument.
|
|
101
|
-
*
|
|
102
|
-
* Validation guards the payload without rewriting it: the original values
|
|
103
|
-
* are handed to the handler unchanged, so a schema that describes a subset
|
|
104
|
-
* of an object never silently strips the sender's extra fields (and any
|
|
105
|
-
* declared transforms stay a purely type-level concern).
|
|
106
|
-
*
|
|
107
|
-
* @internal
|
|
108
|
-
*/
|
|
109
|
-
declare function validateRpcArgs(name: string, argsSchema: RpcArgsSchema | undefined, args: readonly unknown[]): Promise<unknown[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Validate a handler's resolved return value against its declared schema.
|
|
112
|
-
* Throws `DF0039` when the value fails the schema, otherwise returns the
|
|
113
|
-
* original value unchanged (guard-only, never rewriting the payload; see
|
|
114
|
-
* {@link validateRpcArgs}). Passes through when no return schema is set.
|
|
115
|
-
*
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
declare function validateRpcReturn(name: string, returnSchema: RpcReturnSchema | undefined, value: unknown): Promise<unknown>;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/rpc/validation.d.ts
|
|
121
|
-
/**
|
|
122
|
-
* Validates RPC function definitions.
|
|
123
|
-
* Action and event functions cannot have dumps (side effects should not be cached).
|
|
124
|
-
*
|
|
125
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
126
|
-
*/
|
|
127
|
-
declare function validateDefinitions(definitions: readonly RpcFunctionDefinitionAny[]): void;
|
|
128
|
-
/**
|
|
129
|
-
* Validates a single RPC function definition.
|
|
130
|
-
*
|
|
131
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
132
|
-
*/
|
|
133
|
-
declare function validateDefinition(definition: RpcFunctionDefinitionAny): void;
|
|
134
|
-
//#endregion
|
|
135
|
-
export { STRUCTURED_CLONE_PREFIX as a, getRpcResolvedSetupResult as c, RpcFunctionsCollectorBase as d, RpcCacheManager as f, validateRpcReturn as i, createDefineWrapperWithContext as l, validateDefinitions as n, strictJsonStringify as o, RpcCacheOptions as p, validateRpcArgs as r, getRpcHandler as s, validateDefinition as t, defineRpcFunction as u };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { AnyDiagnosticReporter, AnyDiagnosticReporter as AnyDiagnosticReporter$1, ConsoleMethod, ConsoleReporterOptions, Diagnostic, Diagnostic as Diagnostic$1, DiagnosticCallParams, DiagnosticDefinition, DiagnosticDefinition as DiagnosticDefinition$1, DiagnosticHandle, DiagnosticInit, DiagnosticReporter, Diagnostics, Diagnostics as Diagnostics$1, createConsoleReporter, defineProdDiagnostics, formatDiagnostic } from "nostics";
|
|
2
|
-
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
3
|
-
//#region src/utils/nostics.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* The reporter every {@link defineDiagnostics} call below wires in ahead of
|
|
6
|
-
* any caller-supplied ones: prints the diagnostic through devframe's own
|
|
7
|
-
* ANSI colors via `console[method]` (default `'warn'`).
|
|
8
|
-
*/
|
|
9
|
-
declare function devframeReporter(d: Diagnostic, { method }?: {
|
|
10
|
-
method?: 'log' | 'warn' | 'error';
|
|
11
|
-
}): void;
|
|
12
|
-
/**
|
|
13
|
-
* Options accepted by {@link defineDiagnostics}, identical to `nostics`'s
|
|
14
|
-
* own `DefineDiagnosticsOptions`, minus the reporter devframe already
|
|
15
|
-
* prepends.
|
|
16
|
-
*/
|
|
17
|
-
type DevframeDefineDiagnosticsOptions<Codes extends Record<string, DiagnosticDefinition>, Reporters extends readonly AnyDiagnosticReporter[] = []> = Parameters<typeof defineDiagnostics<Codes, Reporters>>[0];
|
|
18
|
-
/**
|
|
19
|
-
* Drop-in replacement for `nostics`'s `defineDiagnostics()` with devframe's
|
|
20
|
-
* ANSI console reporter pre-wired ahead of any `reporters` passed in. Every
|
|
21
|
-
* `diagnostics.ts` in devframe core, `@devframes/hub`, `@devframes/json-render`,
|
|
22
|
-
* and the built-in plugins defines its codes through this instead of
|
|
23
|
-
* `nostics`'s own `defineDiagnostics`; the reporter registration lives
|
|
24
|
-
* here, once, so none of them need to build their own reporter (`colors`,
|
|
25
|
-
* `ansiFormatter`) or take a direct dependency on `nostics` themselves.
|
|
26
|
-
*/
|
|
27
|
-
declare function defineDiagnostics<const Codes extends Record<string, DiagnosticDefinition>, const Reporters extends readonly AnyDiagnosticReporter[] = []>(options: {
|
|
28
|
-
docsBase?: string | ((code: keyof Codes) => string | undefined);
|
|
29
|
-
codes: Codes;
|
|
30
|
-
reporters?: Reporters;
|
|
31
|
-
}): DevframeDiagnostics<Codes, Reporters>;
|
|
32
|
-
/**
|
|
33
|
-
* The `Diagnostics` object returned by devframe's {@link defineDiagnostics}
|
|
34
|
-
* (devframe's ANSI console reporter is always prepended). Integrations that
|
|
35
|
-
* export their own `defineDiagnostics(...)` result as public API annotate it
|
|
36
|
-
* with this type, so the reference resolves through `devframe/utils/nostics`
|
|
37
|
-
* rather than inlining `nostics`'s types or taking a direct `nostics`
|
|
38
|
-
* dependency.
|
|
39
|
-
*/
|
|
40
|
-
type DevframeDiagnostics<Codes extends Record<string, DiagnosticDefinition>, Reporters extends readonly AnyDiagnosticReporter[] = []> = Diagnostics<Codes, readonly [typeof devframeReporter, ...Reporters]>;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { formatDiagnostic as _, DevframeDiagnostics as a, DiagnosticDefinition$1 as c, DiagnosticReporter as d, Diagnostics$1 as f, defineProdDiagnostics as g, defineDiagnostics as h, DevframeDefineDiagnosticsOptions as i, DiagnosticHandle as l, createConsoleReporter as m, ConsoleMethod as n, Diagnostic$1 as o, ansiFormatter as p, ConsoleReporterOptions as r, DiagnosticCallParams as s, AnyDiagnosticReporter$1 as t, DiagnosticInit as u };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
//#region src/utils/origin.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Origin and hostname predicates shared by the RPC transports (the WS upgrade,
|
|
4
|
-
* SSE, and MCP origin gates) and the instance shell's authentication-link
|
|
5
|
-
* origin validation. Kept dependency-free and runtime-agnostic so any consumer
|
|
6
|
-
* can pull in a single check without dragging in a transport's `crossws`
|
|
7
|
-
* import.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Whether `hostname` names a loopback host: `localhost` (or any `*.localhost`
|
|
11
|
-
* subdomain), the IPv6 loopback `::1`, or an IPv4 literal inside the
|
|
12
|
-
* `127.0.0.0/8` loopback block.
|
|
13
|
-
*
|
|
14
|
-
* The IPv4 case is matched **structurally**: the whole hostname must be a
|
|
15
|
-
* canonical dotted-decimal IPv4 literal whose first octet is `127`. A bare
|
|
16
|
-
* `startsWith('127.')` prefix check would also accept an attacker-controlled
|
|
17
|
-
* DNS name that merely *begins* with `127.` (`127.attacker.example`,
|
|
18
|
-
* `127.0.0.1.attacker.example`), letting a cross-origin browser page defeat
|
|
19
|
-
* the loopback origin gate that guards the RPC/MCP surface (a DNS-rebinding /
|
|
20
|
-
* cross-site WebSocket-hijacking bypass). Requiring a real IPv4 literal keeps
|
|
21
|
-
* genuine loopback addresses (`127.0.0.1`, `127.5.5.5`) allowed while rejecting
|
|
22
|
-
* those DNS names.
|
|
23
|
-
*/
|
|
24
|
-
declare function isLoopbackHostname(hostname: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Whether `address` is a loopback peer address as reported by a socket
|
|
27
|
-
* (`net.Socket.remoteAddress`): the IPv6 loopback `::1`, an IPv4 literal in
|
|
28
|
-
* `127.0.0.0/8`, or an IPv4-mapped IPv6 form of one (`::ffff:127.0.0.1`).
|
|
29
|
-
*
|
|
30
|
-
* Unlike {@link isLoopbackHostname} this takes a raw address, not a hostname:
|
|
31
|
-
* it never accepts a `localhost`-style name (a socket peer is always a literal
|
|
32
|
-
* address) and understands the IPv4-mapped IPv6 form the OS hands back on a
|
|
33
|
-
* dual-stack listener. Used to prove a same-machine caller from the connected
|
|
34
|
-
* peer, which a client cannot forge, rather than from the `Origin` header,
|
|
35
|
-
* which it can.
|
|
36
|
-
*/
|
|
37
|
-
declare function isLoopbackAddress(address: string): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Default origin policy for a localhost dev tool: allow requests with no
|
|
40
|
-
* `Origin` header (native, non-browser clients), allow any loopback origin
|
|
41
|
-
* (so cross-port localhost dev setups keep working), and allow explicitly
|
|
42
|
-
* configured origins. Everything else, such as a real remote page in the dev's
|
|
43
|
-
* browser, is rejected.
|
|
44
|
-
*/
|
|
45
|
-
declare function isAllowedOrigin(origin: string | undefined, allowedOrigins: readonly string[]): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Decide whether a request-derived origin candidate may back a devframe's
|
|
48
|
-
* advertised public origin, the destination of the OTP magic link. Stricter
|
|
49
|
-
* than {@link isAllowedOrigin}: it rejects credentials, a path, a query, a
|
|
50
|
-
* fragment, a malformed port, and non-HTTP(S) schemes, and adopts a candidate
|
|
51
|
-
* only when its hostname is loopback or its canonical origin exactly matches
|
|
52
|
-
* an `allowedOrigins` entry (a caller with no static list passes none, so only
|
|
53
|
-
* loopback qualifies). Returns the canonical origin to adopt, or `undefined`
|
|
54
|
-
* to reject. Forwarded headers are never consulted.
|
|
55
|
-
*/
|
|
56
|
-
declare function validateOriginCandidate(candidate: string, allowedOrigins?: readonly string[]): string | undefined;
|
|
57
|
-
//#endregion
|
|
58
|
-
export { validateOriginCandidate as i, isLoopbackAddress as n, isLoopbackHostname as r, isAllowedOrigin as t };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { a as ChannelOptions } from "./index-Bia1vKjL.mjs";
|
|
2
|
-
import { g as RpcFunctionDefinitionAny } from "./types-BmDbfHCx.mjs";
|
|
3
|
-
//#region src/rpc/transports/sse-client.d.ts
|
|
4
|
-
interface SseRpcChannelOptions {
|
|
5
|
-
/** Resolved `http(s)://` URL of the SSE endpoint. */
|
|
6
|
-
url: string;
|
|
7
|
-
onConnected?: () => void;
|
|
8
|
-
onError?: (e: Error) => void;
|
|
9
|
-
onDisconnected?: () => void;
|
|
10
|
-
authToken?: string;
|
|
11
|
-
/**
|
|
12
|
-
* RPC function definitions (or just the `jsonSerializable` flag per
|
|
13
|
-
* method) used to dispatch the per-call wire serializer, the same contract
|
|
14
|
-
* as the WS channel.
|
|
15
|
-
*/
|
|
16
|
-
definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
|
|
17
|
-
/** Fetch implementation. Default: `globalThis.fetch`. */
|
|
18
|
-
fetch?: typeof globalThis.fetch;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build a birpc `ChannelOptions` object backed by an SSE stream (server →
|
|
22
|
-
* client) and HTTP `POST` (client → server): the WebSocket-free counterpart
|
|
23
|
-
* to `createWsRpcChannel`, wire-compatible with `attachSseRpcTransport`.
|
|
24
|
-
*
|
|
25
|
-
* The stream is consumed via `fetch` streaming (not `EventSource`), so it
|
|
26
|
-
* works in browsers and server runtimes alike. The server's first frame
|
|
27
|
-
* (`event: session`) carries the session id; every `POST` echoes it in the
|
|
28
|
-
* `x-birpc-session` header. A response to a client-initiated request comes
|
|
29
|
-
* back in the `POST`'s own body and is re-injected into the channel; a
|
|
30
|
-
* dropped stream terminates the channel; there is no reconnect, matching
|
|
31
|
-
* the WS channel's closed-is-done semantics.
|
|
32
|
-
*/
|
|
33
|
-
declare function createSseRpcChannel(options: SseRpcChannelOptions): ChannelOptions & {
|
|
34
|
-
close: () => void;
|
|
35
|
-
};
|
|
36
|
-
//#endregion
|
|
37
|
-
export { createSseRpcChannel as n, SseRpcChannelOptions as t };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { a as ChannelOptions } from "./index-Bia1vKjL.mjs";
|
|
2
|
-
import { g as RpcFunctionDefinitionAny } from "./types-BmDbfHCx.mjs";
|
|
3
|
-
//#region src/rpc/transports/ws-client.d.ts
|
|
4
|
-
interface WsRpcChannelOptions {
|
|
5
|
-
url: string;
|
|
6
|
-
onConnected?: (e: Event) => void;
|
|
7
|
-
onError?: (e: Error) => void;
|
|
8
|
-
onDisconnected?: (e: CloseEvent) => void;
|
|
9
|
-
authToken?: string;
|
|
10
|
-
/**
|
|
11
|
-
* RPC function definitions (or just the `jsonSerializable` flag per
|
|
12
|
-
* method) used to dispatch the per-call wire serializer. Pass an
|
|
13
|
-
* empty / partial map on clients that don't have the full registry;
|
|
14
|
-
* encoding falls back to structured-clone (the safer superset) and
|
|
15
|
-
* decoding still routes correctly via the wire prefix.
|
|
16
|
-
*/
|
|
17
|
-
definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Build a birpc `ChannelOptions` object backed by a browser `WebSocket`.
|
|
21
|
-
* Pass the result straight to `createRpcClient`'s `channel` option.
|
|
22
|
-
*
|
|
23
|
-
* Also returns `close()`, closing the underlying socket, mirroring the server transport's
|
|
24
|
-
* existing `WsRpcTransport.close()`. `birpc`'s own `ChannelOptions` has no teardown of its own.
|
|
25
|
-
*/
|
|
26
|
-
declare function createWsRpcChannel(options: WsRpcChannelOptions): ChannelOptions & {
|
|
27
|
-
close: () => void;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
export { createWsRpcChannel as n, WsRpcChannelOptions as t };
|