aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/transport.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
index c200674..5ead80e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
@@ -174,6 +174,18 @@ class MeshBayTransport {
throw new Error('Node requires GEK proof but no crypto available');
}
+ // Recorded the moment the challenge arrives, because everything below may
+ // need them — joining, in particular, happens before the proof and signs a
+ // transcript over both. Reading them further down, next to the proof that
+ // also uses them, meant join_request ran with neither.
+ //
+ // nonce_node ties a join to this connection, so one cannot be lifted onto
+ // another. node_pk is announced here because a first-time member has no
+ // GEK and so cannot complete the handshake that would prove it; it is
+ // unverified at this point and checked against the ack below.
+ this._nonceNode = window.MeshBayCrypto.b64decode(reply.nonce);
+ this.nodePk = reply.node_pk || null;
+
// Recover session keys from node if not available locally (P2P keypair bundle)
if (!this._sessionKeys && this._bundleKey && window.MeshBayKeys) {
const kpResp = await this._sendAndWait({
@@ -258,14 +270,7 @@ class MeshBayTransport {
_extractDtlsFingerprint(this._pc.localDescription.sdp),
_extractDtlsFingerprint(this._rawAnswerSdp),
);
- const nonceNode = C.b64decode(reply.nonce);
- // Kept for the life of the connection: a join_request is signed over it,
- // which is what stops one being lifted onto another connection.
- this._nonceNode = nonceNode;
- // Announced in the challenge because joining needs it before the ack: a
- // first-time member has no GEK, so they cannot complete the handshake that
- // would prove this key. Unverified here; checked against the ack below.
- this.nodePk = reply.node_pk || null;
+ const nonceNode = this._nonceNode; // captured when the challenge arrived
const gid = groupId || '';
const proof = await C.handshakeProof(