@johnhenry/browsermesh-core 0.2.0 → 0.2.2
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/package.json +8 -2
- package/src/handshake.mjs +22 -2
- package/src/peer-tools.mjs +12 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/browsermesh-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Identity, crypto, peer management, and trust primitives for BrowserMesh",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -20,7 +20,13 @@
|
|
|
20
20
|
"directory": "packages/browsermesh-core"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@johnhenry/browsermesh-primitives": ">=0.0.1 <1.0.0"
|
|
23
|
+
"@johnhenry/browsermesh-primitives": ">=0.0.1 <1.0.0",
|
|
24
|
+
"@johnhenry/browsermesh-apps": ">=0.4.0 <1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"@johnhenry/browsermesh-apps": {
|
|
28
|
+
"optional": true
|
|
29
|
+
}
|
|
24
30
|
},
|
|
25
31
|
"scripts": {
|
|
26
32
|
"test": "node --import ./test/_setup-globals.mjs --test test/*.test.mjs"
|
package/src/handshake.mjs
CHANGED
|
@@ -316,9 +316,19 @@ export class SignalingClient {
|
|
|
316
316
|
if (!this.#ws) {
|
|
317
317
|
throw new Error('SignalingClient not connected')
|
|
318
318
|
}
|
|
319
|
+
// The real deployed signaling server (browsermesh-servers/signaling)
|
|
320
|
+
// forwards offer/answer/ice-candidate/signal messages by their
|
|
321
|
+
// "target" field, not "to" -- confirmed directly against that
|
|
322
|
+
// server's own source (`const {target, ...payload} = msg`). A `to`
|
|
323
|
+
// field is simply ignored server-side, so every forwarded message
|
|
324
|
+
// was rejected with "forwarded messages require a target field"
|
|
325
|
+
// before this fix. `from` is sent for backward-compatible local
|
|
326
|
+
// debugging/logging only -- the server doesn't read or forward it
|
|
327
|
+
// as-is; see #fire()'s own comment for why the receiving side no
|
|
328
|
+
// longer trusts it.
|
|
319
329
|
const msg = JSON.stringify({
|
|
320
330
|
from: this.#localPodId,
|
|
321
|
-
|
|
331
|
+
target: remotePodId,
|
|
322
332
|
type,
|
|
323
333
|
...payload,
|
|
324
334
|
})
|
|
@@ -372,8 +382,18 @@ export class SignalingClient {
|
|
|
372
382
|
#fire(event, data) {
|
|
373
383
|
const set = this.#listeners.get(event)
|
|
374
384
|
if (!set) return
|
|
385
|
+
// The real signaling server stamps forwarded peer-to-peer messages
|
|
386
|
+
// with its own "source" field, based on which authenticated
|
|
387
|
+
// WebSocket connection the message actually arrived on -- that's
|
|
388
|
+
// the trustworthy value. `from` is whatever the ORIGINAL sender
|
|
389
|
+
// self-declared in their own outgoing payload and the server never
|
|
390
|
+
// validates it before forwarding, so preferring it here would mean
|
|
391
|
+
// trusting an arbitrary, spoofable claim over the server's own
|
|
392
|
+
// attribution. Falls back to `from` only for non-forwarded,
|
|
393
|
+
// direct server messages (e.g. `registered`) that have no `source`.
|
|
394
|
+
const fromPodId = data.source ?? data.from
|
|
375
395
|
for (const cb of set) {
|
|
376
|
-
try { cb(data,
|
|
396
|
+
try { cb(data, fromPodId) } catch (e) { silentCatch('clawser-mesh-handshake', 'swallow-listener-errors', e) }
|
|
377
397
|
}
|
|
378
398
|
}
|
|
379
399
|
}
|
package/src/peer-tools.mjs
CHANGED
|
@@ -209,13 +209,18 @@ export class MeshSchedulerSubmitTool extends BrowserTool {
|
|
|
209
209
|
if (!sched) return { success: false, output: '', error: 'Mesh scheduler not initialized.' }
|
|
210
210
|
try {
|
|
211
211
|
// ScheduledTask lives in the sibling browsermesh-apps package, which
|
|
212
|
-
// itself depends on browsermesh-core (peerDependency)
|
|
213
|
-
// depend back on apps without a cycle
|
|
214
|
-
//
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
//
|
|
218
|
-
|
|
212
|
+
// itself depends on browsermesh-core (peerDependency) -- core can't
|
|
213
|
+
// depend back on apps without a build-time cycle. Reached via a
|
|
214
|
+
// lazy import of the real package NAME (not a monorepo-relative
|
|
215
|
+
// path, which only ever resolved inside this workspace and broke
|
|
216
|
+
// for every standalone consumer via esm.sh) -- matches this
|
|
217
|
+
// family's established pattern for an optional cross-package reach
|
|
218
|
+
// (see @johnhenry/andbox's lazy import in browsermesh-apps'
|
|
219
|
+
// serverless-executor-andbox.mjs). Declared as an optional peer
|
|
220
|
+
// dependency below; contained by the surrounding try/catch so a
|
|
221
|
+
// consumer without apps installed still fails this one tool
|
|
222
|
+
// gracefully instead of crashing the module.
|
|
223
|
+
const { ScheduledTask } = await import('@johnhenry/browsermesh-apps')
|
|
219
224
|
const task = new ScheduledTask({
|
|
220
225
|
id: crypto.randomUUID(),
|
|
221
226
|
type,
|