@twinsearth/w2m-dsh-plugin 0.16.0 → 0.17.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 +45 -0
- package/package.json +5 -4
- package/src/agent/crypto.mjs +72 -2
- package/src/plugin/tools.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,51 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.17.0] — 2026-10-15
|
|
8
|
+
|
|
9
|
+
**BLAKE2s-256 is not the cause of `P2P_PUNCH_FAILED`, and a failure that names nothing costs a probe per guess.**
|
|
10
|
+
|
|
11
|
+
### The hypothesis, and its refutation
|
|
12
|
+
|
|
13
|
+
`P2P_PUNCH_FAILED: Digest method not supported` has been reproduced twice in production and never under
|
|
14
|
+
instrumentation. The obvious candidate was `createHash('blake2s256')` in `handshakeHash` — an algorithm that
|
|
15
|
+
some Node builds lack, whose absence produces exactly that string.
|
|
16
|
+
|
|
17
|
+
**Measured, and refuted:** both MacMini and this Windows host compute a 32-byte BLAKE2s-256 digest, on the
|
|
18
|
+
same run that reported the failure. `blake2s256` is available on both. **So the algorithm is not the cause**,
|
|
19
|
+
and the real cause remains **UNVERIFIED**.
|
|
20
|
+
|
|
21
|
+
### What changed anyway, because the failure's *shape* is the real defect
|
|
22
|
+
|
|
23
|
+
OpenSSL's message names **no algorithm, no caller and no host**. Establishing that BLAKE2s was innocent
|
|
24
|
+
therefore required probing each machine by hand, over a channel that carries one exit code — a round trip per
|
|
25
|
+
hypothesis. `handshakeHash` now:
|
|
26
|
+
|
|
27
|
+
* catches the unavailable case and throws `CRYPTO_BLAKE2S256_UNAVAILABLE` naming the algorithm, the runtime,
|
|
28
|
+
and the fact that **it is a wire-protocol primitive which cannot be replaced with SHA-256** without breaking
|
|
29
|
+
interoperability with every peer — so nobody "fixes" it by substituting an algorithm and silently splits the
|
|
30
|
+
fleet;
|
|
31
|
+
* refuses a digest that is not 32 bytes (`CRYPTO_BLAKE2S256_WRONG_LENGTH`), because a truncated digest throws
|
|
32
|
+
nowhere and would surface as an authentication failure far from its cause;
|
|
33
|
+
* exposes `blake2s256Support()` so a machine can answer the question about itself in one dispatch.
|
|
34
|
+
|
|
35
|
+
The wrapper is transparent on the happy path, and a test asserts it byte-for-byte against a direct
|
|
36
|
+
`createHash` call — if it changed the bytes, every peer would compute a different handshake.
|
|
37
|
+
|
|
38
|
+
### A defect in the fix itself, found before shipping
|
|
39
|
+
|
|
40
|
+
The first version called `getHashes()` without importing it, so `typeof getHashes === 'function'` was silently
|
|
41
|
+
`false` and the `advertised` flag would have been wrong forever. Caught by inspecting the import block rather
|
|
42
|
+
than by a test, which is the honest description of how it was caught.
|
|
43
|
+
|
|
44
|
+
### The 0 % direct share stands
|
|
45
|
+
|
|
46
|
+
Last round measured **12 of 12 tasks carried by the relay**, at RTT 354 ms (macmini) and 336 ms (ToFuture)
|
|
47
|
+
where jp-shared answers in 20 ms. This release does not improve that number; it makes the next attempt at
|
|
48
|
+
diagnosing it cheaper.
|
|
49
|
+
|
|
50
|
+
**10 new tests, 0 failures.**
|
|
51
|
+
|
|
7
52
|
## [0.16.0] — 2026-10-15
|
|
8
53
|
|
|
9
54
|
**A non-zero exit code is not a fleet failure, and this session conflated them repeatedly.**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twinsearth/w2m-dsh-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "DSH: Windows2MacOS — drive the same project on online Windows and macOS machines from one DeepSeek account, across networks and regions. P2P hole punching is the default path (relay + shared server as rendezvous, ledger and fallback), with a bundled STUN responder, Tailscale/public-VPS/tunnel shapes, Rabbit relay + per-machine Localside + eight DSH tools (replicate / split), nine aggregate verdicts and signed requests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -113,13 +113,13 @@
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
"scripts": {
|
|
116
|
-
"test": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/agent.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/layer-model.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-crypto.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/chatops-fleet-join.test.mjs",
|
|
116
|
+
"test": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/agent.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/crypto-blake2s.test.mjs test/layer-model.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-crypto.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/chatops-fleet-join.test.mjs",
|
|
117
117
|
"test:e2e": "node --test --test-force-exit test/e2e.test.mjs test/crossnetwork.test.mjs test/signing-e2e.test.mjs test/outbound-only.test.mjs test/recovery.test.mjs test/pipeline-e2e.test.mjs test/p2p-agent.test.mjs",
|
|
118
118
|
"test:relay": "node --test --test-force-exit test/relay.test.mjs",
|
|
119
119
|
"test:agent": "node --test --test-force-exit test/agent.test.mjs test/memory.test.mjs",
|
|
120
120
|
"test:tools": "node --test --test-force-exit test/tools.test.mjs",
|
|
121
121
|
"test:crossnetwork": "node --test --test-force-exit test/crossnetwork.test.mjs",
|
|
122
|
-
"test:all": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/agent.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/layer-model.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/e2e.test.mjs test/crossnetwork.test.mjs test/signing-e2e.test.mjs test/outbound-only.test.mjs test/recovery.test.mjs test/pipeline-e2e.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-agent.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/p2p-crypto.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/chatops-fleet-join.test.mjs",
|
|
122
|
+
"test:all": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/agent.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/crypto-blake2s.test.mjs test/layer-model.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/e2e.test.mjs test/crossnetwork.test.mjs test/signing-e2e.test.mjs test/outbound-only.test.mjs test/recovery.test.mjs test/pipeline-e2e.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-agent.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/p2p-crypto.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/chatops-fleet-join.test.mjs",
|
|
123
123
|
"pack": "node scripts/pack.mjs",
|
|
124
124
|
"verify:join": "node scripts/verify-join.mjs",
|
|
125
125
|
"lint": "eslint .",
|
|
@@ -142,7 +142,8 @@
|
|
|
142
142
|
"layer-check": "node scripts/layer-check.mjs",
|
|
143
143
|
"test:test-report": "node --test --test-force-exit test/test-report.test.mjs",
|
|
144
144
|
"test:fleet-scale": "node --test --test-force-exit test/fleet-scale.test.mjs",
|
|
145
|
-
"test:fleet-state": "node --test --test-force-exit test/fleet-state.test.mjs"
|
|
145
|
+
"test:fleet-state": "node --test --test-force-exit test/fleet-state.test.mjs",
|
|
146
|
+
"test:crypto-blake2s": "node --test --test-force-exit test/crypto-blake2s.test.mjs"
|
|
146
147
|
},
|
|
147
148
|
"keywords": [
|
|
148
149
|
"dsh-bundle",
|
package/src/agent/crypto.mjs
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
createPublicKey,
|
|
49
49
|
diffieHellman,
|
|
50
50
|
generateKeyPairSync,
|
|
51
|
+
getHashes,
|
|
51
52
|
hkdfSync,
|
|
52
53
|
randomBytes,
|
|
53
54
|
timingSafeEqual,
|
|
@@ -703,16 +704,85 @@ export function derive(ikm, label, length = KEY_BYTES) {
|
|
|
703
704
|
return Buffer.from(hkdfSync('sha256', ikm, Buffer.alloc(0), Buffer.from(label, 'utf8'), length));
|
|
704
705
|
}
|
|
705
706
|
|
|
707
|
+
/**
|
|
708
|
+
* How BLAKE2s-256 is reached on this runtime, discovered once and remembered.
|
|
709
|
+
*
|
|
710
|
+
* ## Why a probe exists for a call that simply works
|
|
711
|
+
*
|
|
712
|
+
* `P2P_PUNCH_FAILED: Digest method not supported` was reproduced twice in production and, measured directly,
|
|
713
|
+
* **neither MacMini nor this Windows host lacks `blake2s256`** — so the algorithm is *not* the cause. What
|
|
714
|
+
* made that take so long to establish is the shape of the failure: OpenSSL's message names no algorithm, no
|
|
715
|
+
* caller and no host, so the only way to rule a candidate out was to probe each machine by hand.
|
|
716
|
+
*
|
|
717
|
+
* This wrapper does not change behaviour. It changes what a failure *says*: the algorithm that was requested,
|
|
718
|
+
* whether the runtime advertises it, and the fact that it cannot be substituted. That is the difference
|
|
719
|
+
* between a message a reader can act on and one that costs a round trip per hypothesis.
|
|
720
|
+
*/
|
|
721
|
+
let blake2sSupport = null;
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Whether this runtime can compute BLAKE2s-256, and how it was reached.
|
|
725
|
+
*
|
|
726
|
+
* @returns {{ok: boolean, advertised: boolean, detail: string}}
|
|
727
|
+
*/
|
|
728
|
+
export function blake2s256Support() {
|
|
729
|
+
if (blake2sSupport !== null) return blake2sSupport;
|
|
730
|
+
let advertised = false;
|
|
731
|
+
try {
|
|
732
|
+
advertised = typeof getHashes === 'function' && getHashes().includes('blake2s256');
|
|
733
|
+
} catch {
|
|
734
|
+
advertised = false;
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
const probe = createHash('blake2s256');
|
|
738
|
+
probe.update('');
|
|
739
|
+
const bytes = probe.digest().length;
|
|
740
|
+
blake2sSupport = {
|
|
741
|
+
ok: bytes === 32,
|
|
742
|
+
advertised,
|
|
743
|
+
detail: bytes === 32
|
|
744
|
+
? `BLAKE2s-256 available (${advertised ? 'advertised by getHashes' : 'works though not advertised'})`
|
|
745
|
+
: `BLAKE2s-256 produced ${bytes} bytes rather than 32`,
|
|
746
|
+
};
|
|
747
|
+
} catch (e) {
|
|
748
|
+
blake2sSupport = {
|
|
749
|
+
ok: false,
|
|
750
|
+
advertised,
|
|
751
|
+
detail: `BLAKE2s-256 unavailable on this runtime: ${e?.message ?? String(e)}. It is a WIRE PROTOCOL primitive -- the handshake hash, the prologue hash and the session binding -- so it cannot be replaced with SHA-256 without breaking interoperability with every peer. This machine cannot take part in a handshake until the runtime supports it.`,
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
return blake2sSupport;
|
|
755
|
+
}
|
|
756
|
+
|
|
706
757
|
/**
|
|
707
758
|
* BLAKE2s-256, §3's handshake hash.
|
|
708
759
|
*
|
|
760
|
+
* Throws a message naming the algorithm and the consequence when the runtime cannot provide it, instead of
|
|
761
|
+
* letting OpenSSL's `Digest method not supported` escape — which names neither, and which is why a real
|
|
762
|
+
* production failure took several rounds to attribute.
|
|
763
|
+
*
|
|
709
764
|
* @param {...(Buffer|string)} parts
|
|
710
765
|
* @returns {Buffer} 32 bytes.
|
|
711
766
|
*/
|
|
712
767
|
export function handshakeHash(...parts) {
|
|
713
|
-
|
|
768
|
+
let hash;
|
|
769
|
+
try {
|
|
770
|
+
hash = createHash('blake2s256');
|
|
771
|
+
} catch (e) {
|
|
772
|
+
const support = blake2s256Support();
|
|
773
|
+
const error = new Error(`handshakeHash requires BLAKE2s-256: ${support.detail}`);
|
|
774
|
+
error.code = 'CRYPTO_BLAKE2S256_UNAVAILABLE';
|
|
775
|
+
error.cause = e;
|
|
776
|
+
throw error;
|
|
777
|
+
}
|
|
714
778
|
for (const part of parts) hash.update(part);
|
|
715
|
-
|
|
779
|
+
const out = hash.digest();
|
|
780
|
+
if (out.length !== 32) {
|
|
781
|
+
const error = new Error(`handshakeHash expected a 32-byte digest and produced ${out.length}; peers would compute a different handshake hash`);
|
|
782
|
+
error.code = 'CRYPTO_BLAKE2S256_WRONG_LENGTH';
|
|
783
|
+
throw error;
|
|
784
|
+
}
|
|
785
|
+
return out;
|
|
716
786
|
}
|
|
717
787
|
|
|
718
788
|
/**
|
package/src/plugin/tools.mjs
CHANGED
|
@@ -185,7 +185,7 @@ const MAX_STAGES = 16;
|
|
|
185
185
|
* `package.json` during `scripts/pack.mjs` rather than hand-maintained, and `W2M_PLUGIN_VERSION`
|
|
186
186
|
* overrides it at runtime for tests and packagers.
|
|
187
187
|
*/
|
|
188
|
-
const PLUGIN_VERSION = '0.
|
|
188
|
+
const PLUGIN_VERSION = '0.17.0';
|
|
189
189
|
|
|
190
190
|
/** How long any single HTTP call may take before it is aborted, in milliseconds. */
|
|
191
191
|
const DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
|