wire-mesh-core 3.9.0 → 3.10.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/dist/adapters/byte-stream-connection.d.cts +2 -2
- package/dist/adapters/byte-stream-connection.d.mts +2 -2
- package/dist/adapters/frame-codec.d.cts +1 -1
- package/dist/adapters/frame-codec.d.mts +1 -1
- package/dist/adapters/node-identity.d.cts +2 -2
- package/dist/adapters/node-identity.d.mts +2 -2
- package/dist/adapters/tcp-transport.d.cts +1 -1
- package/dist/adapters/tcp-transport.d.mts +1 -1
- package/dist/adapters/threshold-identity.d.cts +2 -2
- package/dist/adapters/threshold-identity.d.mts +2 -2
- package/dist/adapters/threshold-wasm.d.cts +1 -1
- package/dist/adapters/threshold-wasm.d.mts +1 -1
- package/dist/adapters/tls-transport.d.cts +1 -1
- package/dist/adapters/tls-transport.d.mts +1 -1
- package/dist/domain/advert-extension-policy.d.cts +1 -1
- package/dist/domain/advert-extension-policy.d.mts +1 -1
- package/dist/domain/bulk.d.cts +2 -2
- package/dist/domain/bulk.d.mts +2 -2
- package/dist/domain/capability-grant.d.cts +2 -2
- package/dist/domain/capability-grant.d.mts +2 -2
- package/dist/domain/capability-request.d.cts +3 -3
- package/dist/domain/capability-request.d.mts +3 -3
- package/dist/domain/coordinator-election.d.cts +1 -1
- package/dist/domain/coordinator-election.d.mts +1 -1
- package/dist/domain/data-sync.d.cts +2 -2
- package/dist/domain/data-sync.d.mts +2 -2
- package/dist/domain/device-id.d.cts +1 -1
- package/dist/domain/device-id.d.mts +1 -1
- package/dist/domain/direct-manage-request.d.cts +2 -2
- package/dist/domain/direct-manage-request.d.mts +2 -2
- package/dist/domain/gossip-expansion.d.cts +1 -1
- package/dist/domain/gossip-expansion.d.mts +1 -1
- package/dist/domain/grant-candidates.d.cts +1 -1
- package/dist/domain/grant-candidates.d.mts +1 -1
- package/dist/domain/handshake.d.cts +1 -1
- package/dist/domain/handshake.d.mts +1 -1
- package/dist/domain/hub-mailbox.d.cts +1 -1
- package/dist/domain/hub-mailbox.d.mts +1 -1
- package/dist/domain/mesh-session.d.cts +3 -3
- package/dist/domain/mesh-session.d.mts +3 -3
- package/dist/domain/notice-board.d.cts +2 -2
- package/dist/domain/notice-board.d.mts +2 -2
- package/dist/domain/path-trace.d.cts +1 -1
- package/dist/domain/path-trace.d.mts +1 -1
- package/dist/domain/peer-advert.d.cts +2 -2
- package/dist/domain/peer-advert.d.mts +2 -2
- package/dist/domain/relay-advert.d.cts +1 -1
- package/dist/domain/relay-advert.d.mts +1 -1
- package/dist/domain/relay-hub.cjs +72 -15
- package/dist/domain/relay-hub.d.cts +6 -2
- package/dist/domain/relay-hub.d.mts +6 -2
- package/dist/domain/relay-hub.mjs +72 -15
- package/dist/domain/relay-use-gate.d.cts +2 -2
- package/dist/domain/relay-use-gate.d.mts +2 -2
- package/dist/domain/revocation-view.d.cts +1 -1
- package/dist/domain/revocation-view.d.mts +1 -1
- package/dist/domain/room-rekey.d.cts +2 -2
- package/dist/domain/room-rekey.d.mts +2 -2
- package/dist/domain/room-token-verification.d.cts +1 -1
- package/dist/domain/room-token-verification.d.mts +1 -1
- package/dist/domain/room.d.cts +3 -3
- package/dist/domain/room.d.mts +3 -3
- package/dist/domain/shard-manifest.d.cts +1 -1
- package/dist/domain/shard-manifest.d.mts +1 -1
- package/dist/domain/token-predicates.d.cts +1 -1
- package/dist/domain/token-predicates.d.mts +1 -1
- package/dist/domain/token-scope.d.cts +1 -1
- package/dist/domain/token-scope.d.mts +1 -1
- package/dist/domain/tokens.d.cts +3 -3
- package/dist/domain/tokens.d.mts +3 -3
- package/dist/domain/topology-snapshot.d.cts +1 -1
- package/dist/domain/topology-snapshot.d.mts +1 -1
- package/dist/domain/topology.d.cts +1 -1
- package/dist/domain/topology.d.mts +1 -1
- package/dist/domain/webrtc-signaling.d.cts +1 -1
- package/dist/domain/webrtc-signaling.d.mts +1 -1
- package/dist/generated/protocol.cjs +4 -2
- package/dist/generated/protocol.d.cts +1 -1
- package/dist/generated/protocol.d.mts +1 -1
- package/dist/generated/protocol.mjs +4 -2
- package/dist/{identity-DJbr96J3.d.cts → identity-B6nhlSOT.d.cts} +1 -1
- package/dist/{identity-ViYdZrIU.d.mts → identity-EV-HHv_D.d.mts} +1 -1
- package/dist/ports/identity.d.cts +1 -1
- package/dist/ports/identity.d.mts +1 -1
- package/dist/ports/transport.d.cts +1 -1
- package/dist/ports/transport.d.mts +1 -1
- package/dist/{protocol-BgR1e_NI.d.cts → protocol-DzmpxxUr.d.cts} +6 -0
- package/dist/{protocol-BgR1e_NI.d.mts → protocol-DzmpxxUr.d.mts} +6 -0
- package/dist/{room-token-verification-BpQ6yJtj.d.cts → room-token-verification-Dh7SGJfK.d.cts} +1 -1
- package/dist/{room-token-verification-CTQSihUO.d.mts → room-token-verification-Hb1LkpFh.d.mts} +1 -1
- package/dist/{token-predicates-C-aIe1DT.d.cts → token-predicates-D4NNPLnp.d.cts} +1 -1
- package/dist/{token-predicates-DqvyS7Y8.d.mts → token-predicates-DqpG8VZZ.d.mts} +1 -1
- package/dist/{transport-DP3hdehk.d.cts → transport-bD3p_TO_.d.mts} +1 -1
- package/dist/{transport-Dv_LTCsF.d.mts → transport-gDbSHO-r.d.cts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Frame } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { N as Frame } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as Connection } from "../transport-gDbSHO-r.cjs";
|
|
3
3
|
//#region src/adapters/byte-stream-connection.d.ts
|
|
4
4
|
/** The largest frame body a peer may announce in a length prefix, matching the 100 MiB the `ws` package applies to one message on the same hub, so a WebSocket peer and a byte-stream peer are bounded alike. Without a bound a peer-controlled 4 GiB prefix makes the reader buffer until memory runs out. */
|
|
5
5
|
export declare const MAX_FRAME_BYTES: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Frame } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { N as Frame } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as Connection } from "../transport-bD3p_TO_.mjs";
|
|
3
3
|
//#region src/adapters/byte-stream-connection.d.ts
|
|
4
4
|
/** The largest frame body a peer may announce in a length prefix, matching the 100 MiB the `ws` package applies to one message on the same hub, so a WebSocket peer and a byte-stream peer are bounded alike. Without a bound a peer-controlled 4 GiB prefix makes the reader buffer until memory runs out. */
|
|
5
5
|
export declare const MAX_FRAME_BYTES: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/adapters/frame-codec.d.ts
|
|
3
3
|
export declare function messageFromFrame(frame: Frame): Uint8Array<ArrayBuffer>;
|
|
4
4
|
/** Wraps frame as a relay-data-frame's own opaque payload, stamping to-device when the caller knows which established pairing to address it to (wire-mesh#30) -- the outbound counterpart to tryDecodeFrame's own doc comment below, which describes the inbound side of the same relay-data envelope. Omitting toDevice leaves the frame unaddressed, which the receiving hub then routes via its own most-recently-established-pairing fallback. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, N as Frame, ht as RelayDataFrame } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/adapters/frame-codec.d.ts
|
|
3
3
|
export declare function messageFromFrame(frame: Frame): Uint8Array<ArrayBuffer>;
|
|
4
4
|
/** Wraps frame as a relay-data-frame's own opaque payload, stamping to-device when the caller knows which established pairing to address it to (wire-mesh#30) -- the outbound counterpart to tryDecodeFrame's own doc comment below, which describes the inbound side of the same relay-data envelope. Omitting toDevice leaves the frame unaddressed, which the receiving hub then routes via its own most-recently-established-pairing fallback. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
3
3
|
import { webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/adapters/node-identity.d.ts
|
|
5
5
|
export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
3
3
|
import { webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/adapters/node-identity.d.ts
|
|
5
5
|
export declare function deriveDeviceId(publicKey: Uint8Array): Promise<DeviceId>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Transport } from "../transport-
|
|
1
|
+
import { r as Transport } from "../transport-gDbSHO-r.cjs";
|
|
2
2
|
//#region src/adapters/tcp-transport.d.ts
|
|
3
3
|
/** A Node net.Socket-based Transport: length-prefixed, CBOR-encoded frames over plain TCP -- matching Cascade's own transport shape, since interop with Cascade nodes is wire-mesh's stated goal. Framing (not TLS) is this adapter's own concern; a TLS-terminated variant is a separate adapter behind the same Transport contract. */
|
|
4
4
|
export declare function createTcpTransport(): Transport;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Transport } from "../transport-
|
|
1
|
+
import { r as Transport } from "../transport-bD3p_TO_.mjs";
|
|
2
2
|
//#region src/adapters/tcp-transport.d.ts
|
|
3
3
|
/** A Node net.Socket-based Transport: length-prefixed, CBOR-encoded frames over plain TCP -- matching Cascade's own transport shape, since interop with Cascade nodes is wire-mesh's stated goal. Framing (not TLS) is this adapter's own concern; a TLS-terminated variant is a separate adapter behind the same Transport contract. */
|
|
4
4
|
export declare function createTcpTransport(): Transport;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
3
3
|
import { DeviceKeyed } from "./threshold-wasm.cjs";
|
|
4
4
|
import { ThresholdSubject } from "../domain/threshold-subject.cjs";
|
|
5
5
|
//#region src/adapters/threshold-identity.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
3
3
|
import { DeviceKeyed } from "./threshold-wasm.mjs";
|
|
4
4
|
import { ThresholdSubject } from "../domain/threshold-subject.mjs";
|
|
5
5
|
//#region src/adapters/threshold-identity.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/adapters/threshold-wasm.d.ts
|
|
3
3
|
/** One `(deviceId, bytes)` pair -- the wasm boundary's own encoding of a map keyed by participant, since wasm-bindgen has no built-in `Map<Uint8Array, Uint8Array>` marshalling. */
|
|
4
4
|
export interface DeviceKeyed<T extends Uint8Array = Uint8Array<ArrayBuffer>> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/adapters/threshold-wasm.d.ts
|
|
3
3
|
/** One `(deviceId, bytes)` pair -- the wasm boundary's own encoding of a map keyed by participant, since wasm-bindgen has no built-in `Map<Uint8Array, Uint8Array>` marshalling. */
|
|
4
4
|
export interface DeviceKeyed<T extends Uint8Array = Uint8Array<ArrayBuffer>> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/domain/advert-extension-policy.d.ts
|
|
3
3
|
/** Whether one extension entry's value is one the hub will carry. Must be strict: a value with a field the validator did not expect is refused, since the point is that nothing unexpected is published. */
|
|
4
4
|
export type ExtensionValidator = (value: unknown) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/domain/advert-extension-policy.d.ts
|
|
3
3
|
/** Whether one extension entry's value is one the hub will carry. Must be strict: a value with a field the validator did not expect is refused, since the point is that nothing unexpected is published. */
|
|
4
4
|
export type ExtensionValidator = (value: unknown) => boolean;
|
package/dist/domain/bulk.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as Connection } from "../transport-gDbSHO-r.cjs";
|
|
3
3
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.cjs";
|
|
5
5
|
//#region src/domain/bulk.d.ts
|
package/dist/domain/bulk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, N as Frame, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as Connection } from "../transport-bD3p_TO_.mjs";
|
|
3
3
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.mjs";
|
|
5
5
|
//#region src/domain/bulk.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
4
4
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.cjs";
|
|
5
5
|
import { RevocationCheck } from "./tokens.cjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
4
4
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.mjs";
|
|
5
5
|
import { RevocationCheck } from "./tokens.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.cjs";
|
|
5
|
-
import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-
|
|
5
|
+
import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-D4NNPLnp.cjs";
|
|
6
6
|
import { RevocationCheck } from "./tokens.cjs";
|
|
7
7
|
//#region src/domain/capability-request.d.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken, u as CapabilityGrantOk } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
3
3
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
4
4
|
import { IncomingManageRequest, MeshSession } from "./mesh-session.mjs";
|
|
5
|
-
import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-
|
|
5
|
+
import { m as TokenDelegateHandler, r as ConditionsContext } from "../token-predicates-DqpG8VZZ.mjs";
|
|
6
6
|
import { RevocationCheck } from "./tokens.mjs";
|
|
7
7
|
//#region src/domain/capability-request.d.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/domain/coordinator-election.d.ts
|
|
3
3
|
/** The claim this side currently accepts: one coordinator, at the term that put it there. */
|
|
4
4
|
export interface CoordinatorClaim {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, g as CoordinatorFrame } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/domain/coordinator-election.d.ts
|
|
3
3
|
/** The claim this side currently accepts: one coordinator, at the term that put it there. */
|
|
4
4
|
export interface CoordinatorClaim {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
4
4
|
//#region src/domain/data-sync.d.ts
|
|
5
5
|
export interface DataSyncOptions {
|
|
6
6
|
identity: IdentityPort;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
4
4
|
//#region src/domain/data-sync.d.ts
|
|
5
5
|
export interface DataSyncOptions {
|
|
6
6
|
identity: IdentityPort;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/domain/device-id.d.ts
|
|
3
3
|
/** Lowercase, byte-exact hex for an arbitrary-length byte string -- the same encoding convention deviceIdToHex uses for the fixed-length device-id case, extracted so any other byte string needing a stable, displayable, map-keyable text form (e.g. a token-id, which tokens.cddl defines as an arbitrary-length bstr rather than a 32-byte device-id) can use the identical convention without going through a device-id-shaped function. */
|
|
4
4
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId } from "../protocol-
|
|
1
|
+
import { D as DeviceId } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/domain/device-id.d.ts
|
|
3
3
|
/** Lowercase, byte-exact hex for an arbitrary-length byte string -- the same encoding convention deviceIdToHex uses for the fixed-length device-id case, extracted so any other byte string needing a stable, displayable, map-keyable text form (e.g. a token-id, which tokens.cddl defines as an arbitrary-length bstr rather than a 32-byte device-id) can use the identical convention without going through a device-id-shaped function. */
|
|
4
4
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-gDbSHO-r.cjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome } from "./mesh-session.cjs";
|
|
4
4
|
//#region src/domain/direct-manage-request.d.ts
|
|
5
5
|
/** Reads exactly one frame off a freshly-accepted, bare connection and, if it's a manage-request, returns an IncomingManageRequest ready to hand to the same application-level dispatch logic session.incomingManageRequests already feeds elsewhere -- no handshake or gossip is ever read or sent on this connection (wire-mesh#38: the manage-request/manage-response exchange has no dependency on handshake state at the dispatch layer, confirmed against mesh-session.ts's own applyManageRequest/applyFrame). respond() sends the manage-response directly and closes the connection, since a one-off request/response is this connection's entire purpose -- unlike a real MeshSession, there is nothing further to do with it afterwards. Resolves null, without closing the connection (that's the caller's call), for any other first frame or if the connection ends before one arrives: interpreting either case is a Transport.listen() caller's own business, e.g. peeking the first frame to route between this path and acceptMeshSession's own handshake path. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
1
|
+
import { D as DeviceId, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-bD3p_TO_.mjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome } from "./mesh-session.mjs";
|
|
4
4
|
//#region src/domain/direct-manage-request.d.ts
|
|
5
5
|
/** Reads exactly one frame off a freshly-accepted, bare connection and, if it's a manage-request, returns an IncomingManageRequest ready to hand to the same application-level dispatch logic session.incomingManageRequests already feeds elsewhere -- no handshake or gossip is ever read or sent on this connection (wire-mesh#38: the manage-request/manage-response exchange has no dependency on handshake state at the dispatch layer, confirmed against mesh-session.ts's own applyManageRequest/applyFrame). respond() sends the manage-response directly and closes the connection, since a one-off request/response is this connection's entire purpose -- unlike a real MeshSession, there is nothing further to do with it afterwards. Resolves null, without closing the connection (that's the caller's call), for any other first frame or if the connection ends before one arrives: interpreting either case is a Transport.listen() caller's own business, e.g. peeking the first frame to route between this path and acceptMeshSession's own handshake path. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { D as DeviceId, et as PeerAdvert } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { MeshSession } from "./mesh-session.cjs";
|
|
3
3
|
//#region src/domain/gossip-expansion.d.ts
|
|
4
4
|
/** One not-yet-considered device this session's gossip directory has surfaced, carrying only what a dial/trust decision needs: the device-id to decide identity, and the "host:port" addresses its own peer-advert claims are directly reachable at, in the order it advertised them. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { D as DeviceId, et as PeerAdvert } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { MeshSession } from "./mesh-session.mjs";
|
|
3
3
|
//#region src/domain/gossip-expansion.d.ts
|
|
4
4
|
/** One not-yet-considered device this session's gossip directory has surfaced, carrying only what a dial/trust decision needs: the device-id to decide identity, and the "host:port" addresses its own peer-advert claims are directly reachable at, in the order it advertised them. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, f as CapabilityScope } from "../protocol-
|
|
1
|
+
import { D as DeviceId, f as CapabilityScope } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { DirectoryEntry, MeshSession } from "./mesh-session.cjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/domain/grant-candidates.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, f as CapabilityScope } from "../protocol-
|
|
1
|
+
import { D as DeviceId, f as CapabilityScope } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { DirectoryEntry, MeshSession } from "./mesh-session.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/domain/grant-candidates.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-
|
|
1
|
+
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/domain/handshake.d.ts
|
|
3
3
|
/** The highest protocol version this build of core understands. */
|
|
4
4
|
export declare const SUPPORTED_PROTOCOL_VERSION: ProtocolVersion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-
|
|
1
|
+
import { A as DomainId, R as HandshakeFrame, lt as ProtocolVersion } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/domain/handshake.d.ts
|
|
3
3
|
/** The highest protocol version this build of core understands. */
|
|
4
4
|
export declare const SUPPORTED_PROTOCOL_VERSION: ProtocolVersion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
3
3
|
//#region src/domain/hub-mailbox.d.ts
|
|
4
4
|
export interface MailboxLimits {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, w as DataEntriesFrame } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
3
3
|
//#region src/domain/hub-mailbox.d.ts
|
|
4
4
|
export interface MailboxLimits {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, U as ManageError, V as ManageCommand, W as ManageOk, bt as RevocationEntry, et as PeerAdvert, f as CapabilityScope, g as CoordinatorFrame, lt as ProtocolVersion, nn as TopologyPeers, p as CapabilityToken, w as DataEntriesFrame } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, U as ManageError, V as ManageCommand, W as ManageOk, bt as RevocationEntry, et as PeerAdvert, f as CapabilityScope, g as CoordinatorFrame, lt as ProtocolVersion, nn as TopologyPeers, p as CapabilityToken, w as DataEntriesFrame } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-gDbSHO-r.cjs";
|
|
3
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
4
4
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
5
5
|
//#region src/domain/mesh-session.d.ts
|
|
6
6
|
/** How long to wait for the node's handshake before calling it unanswered. A relay-only node never sends one; that is a state to display, not an error. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, U as ManageError, V as ManageCommand, W as ManageOk, bt as RevocationEntry, et as PeerAdvert, f as CapabilityScope, g as CoordinatorFrame, lt as ProtocolVersion, nn as TopologyPeers, p as CapabilityToken, w as DataEntriesFrame } from "../protocol-
|
|
2
|
-
import { r as Transport, t as Connection } from "../transport-
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { D as DeviceId, E as DataRequestFrame, N as Frame, T as DataHaveFrame, U as ManageError, V as ManageCommand, W as ManageOk, bt as RevocationEntry, et as PeerAdvert, f as CapabilityScope, g as CoordinatorFrame, lt as ProtocolVersion, nn as TopologyPeers, p as CapabilityToken, w as DataEntriesFrame } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { r as Transport, t as Connection } from "../transport-bD3p_TO_.mjs";
|
|
3
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
4
4
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
5
5
|
//#region src/domain/mesh-session.d.ts
|
|
6
6
|
/** How long to wait for the node's handshake before calling it unanswered. A relay-only node never sends one; that is a state to display, not an error. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeClaims, p as CapabilityToken } from "../protocol-
|
|
1
|
+
import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeClaims, p as CapabilityToken } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.cjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
4
4
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
5
5
|
import { RevocationCheck } from "./tokens.cjs";
|
|
6
6
|
import { RoomNoticeVerdictReason } from "./room.cjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeClaims, p as CapabilityToken } from "../protocol-
|
|
1
|
+
import { D as DeviceId, Ot as RoomNotice, T as DataHaveFrame, kt as RoomNoticeClaims, p as CapabilityToken } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { t as KeyValueStorage } from "../storage-B403CRyu.mjs";
|
|
3
|
-
import { t as IdentityPort } from "../identity-
|
|
3
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
4
4
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
5
5
|
import { RevocationCheck } from "./tokens.mjs";
|
|
6
6
|
import { RoomNoticeVerdictReason } from "./room.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, H as ManageCommandParams, Q as PathTrace, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
1
|
+
import { D as DeviceId, H as ManageCommandParams, Q as PathTrace, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
import { t as Clock } from "../clock-DiSx-WKM.cjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.cjs";
|
|
4
4
|
//#region src/domain/path-trace.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DeviceId, H as ManageCommandParams, Q as PathTrace, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-
|
|
1
|
+
import { D as DeviceId, H as ManageCommandParams, Q as PathTrace, V as ManageCommand, f as CapabilityScope, p as CapabilityToken } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
import { t as Clock } from "../clock-DiSx-WKM.mjs";
|
|
3
3
|
import { IncomingManageRequest, ManageOutcome, MeshSession } from "./mesh-session.mjs";
|
|
4
4
|
//#region src/domain/path-trace.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId, et as PeerAdvert } from "../protocol-DzmpxxUr.cjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-B6nhlSOT.cjs";
|
|
3
3
|
//#region src/domain/peer-advert.d.ts
|
|
4
4
|
/** peer-advert's own signature field, the one entry the signature does not cover, named once here so the signing input and the reserved-extension-key guard cannot drift apart. */
|
|
5
5
|
export declare const PEER_ADVERT_SIGNATURE_KEY = "signature";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as IdentityKey, D as DeviceId, et as PeerAdvert } from "../protocol-
|
|
2
|
-
import { t as IdentityPort } from "../identity-
|
|
1
|
+
import { B as IdentityKey, D as DeviceId, et as PeerAdvert } from "../protocol-DzmpxxUr.mjs";
|
|
2
|
+
import { t as IdentityPort } from "../identity-EV-HHv_D.mjs";
|
|
3
3
|
//#region src/domain/peer-advert.d.ts
|
|
4
4
|
/** peer-advert's own signature field, the one entry the signature does not cover, named once here so the signing input and the reserved-extension-key guard cannot drift apart. */
|
|
5
5
|
export declare const PEER_ADVERT_SIGNATURE_KEY = "signature";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-DzmpxxUr.cjs";
|
|
2
2
|
//#region src/domain/relay-advert.d.ts
|
|
3
3
|
/** The domain-qualified gossip extension key a node's relay offer rides under, the same `wire-mesh` domain the core's own gossiped version fact occupies. */
|
|
4
4
|
export declare const RELAY_OFFER_GOSSIP_KEY = "wire-mesh/relay-offer";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as PeerAdvert } from "../protocol-
|
|
1
|
+
import { et as PeerAdvert } from "../protocol-DzmpxxUr.mjs";
|
|
2
2
|
//#region src/domain/relay-advert.d.ts
|
|
3
3
|
/** The domain-qualified gossip extension key a node's relay offer rides under, the same `wire-mesh` domain the core's own gossiped version fact occupies. */
|
|
4
4
|
export declare const RELAY_OFFER_GOSSIP_KEY = "wire-mesh/relay-offer";
|
|
@@ -28,6 +28,7 @@ function supersedes(registered, advert, connection) {
|
|
|
28
28
|
}
|
|
29
29
|
function createRelayHub(options) {
|
|
30
30
|
const connections = /* @__PURE__ */ new Set();
|
|
31
|
+
let uplink;
|
|
31
32
|
const devices = /* @__PURE__ */ new Map();
|
|
32
33
|
const connectionDevice = /* @__PURE__ */ new Map();
|
|
33
34
|
const pairings = /* @__PURE__ */ new Map();
|
|
@@ -51,14 +52,16 @@ function createRelayHub(options) {
|
|
|
51
52
|
function forgetConnection(connection) {
|
|
52
53
|
connections.delete(connection);
|
|
53
54
|
for (const [key, registration] of devices) if (registration.connection === connection) devices.delete(key);
|
|
54
|
-
const ownDevice = connectionDevice.get(connection);
|
|
55
55
|
connectionDevice.delete(connection);
|
|
56
56
|
mostRecentPairing.delete(connection);
|
|
57
|
+
if (connection === uplink) uplink = void 0;
|
|
57
58
|
const own = pairings.get(connection);
|
|
58
59
|
if (own) {
|
|
59
60
|
for (const peer of own.values()) {
|
|
60
61
|
const peerOwn = pairings.get(peer);
|
|
61
|
-
if (peerOwn
|
|
62
|
+
if (peerOwn) {
|
|
63
|
+
for (const [key, paired] of peerOwn) if (paired === connection) peerOwn.delete(key);
|
|
64
|
+
}
|
|
62
65
|
if (mostRecentPairing.get(peer) === connection) mostRecentPairing.delete(peer);
|
|
63
66
|
stateChanged(peer);
|
|
64
67
|
}
|
|
@@ -98,11 +101,14 @@ function createRelayHub(options) {
|
|
|
98
101
|
advert
|
|
99
102
|
});
|
|
100
103
|
}
|
|
104
|
+
for (const { connection, state } of entries) for (const advert of state.adverts) {
|
|
105
|
+
const key = deviceKey(advert.device);
|
|
106
|
+
if (!byDevice.has(key)) byDevice.set(key, connection);
|
|
107
|
+
}
|
|
101
108
|
for (const { connection, state } of entries) for (const paired of state.pairedDevices) {
|
|
102
109
|
const peer = byDevice.get(deviceKey(paired));
|
|
103
110
|
if (peer === void 0) continue;
|
|
104
111
|
pairingsOf(connection).set(deviceKey(paired), peer);
|
|
105
|
-
pairingsOf(peer).set(deviceKey(state.device), connection);
|
|
106
112
|
}
|
|
107
113
|
for (const { connection, state } of entries) {
|
|
108
114
|
const recent = state.mostRecentDevice;
|
|
@@ -111,6 +117,27 @@ function createRelayHub(options) {
|
|
|
111
117
|
if (peer !== void 0) mostRecentPairing.set(connection, peer);
|
|
112
118
|
}
|
|
113
119
|
}
|
|
120
|
+
/** The device a frame from `connection` acts for: the one it names when it fronts that device, otherwise the device the hub attributes to the connection when none is named. Undefined when the connection has no device yet or names one it does not front. */
|
|
121
|
+
function initiatorOf(connection, claimed) {
|
|
122
|
+
if (claimed === void 0) return connectionDevice.get(connection);
|
|
123
|
+
return devices.get(deviceKey(claimed))?.connection === connection ? claimed : void 0;
|
|
124
|
+
}
|
|
125
|
+
/** A relay-inbound is only meaningful from the upstream hub, which sends one to say a device it holds was paired with a device fronted through this hub. Both devices must be known here (the upstream one registered to the uplink, the addressed one to a local client) so the pairing can be recorded and the client told. */
|
|
126
|
+
async function handleUplinkInbound(connection, frame) {
|
|
127
|
+
const target = frame["target-device"];
|
|
128
|
+
if (connection !== uplink || target === void 0) return;
|
|
129
|
+
const local = devices.get(deviceKey(target));
|
|
130
|
+
const source = devices.get(deviceKey(frame["source-device"]));
|
|
131
|
+
if (local === void 0 || local.connection === connection || source?.connection !== connection) return;
|
|
132
|
+
addPairing(local.connection, target, connection, frame["source-device"]);
|
|
133
|
+
stateChanged(local.connection);
|
|
134
|
+
stateChanged(connection);
|
|
135
|
+
await local.connection.send({
|
|
136
|
+
type: "relay-inbound",
|
|
137
|
+
"source-device": frame["source-device"],
|
|
138
|
+
"target-device": target
|
|
139
|
+
});
|
|
140
|
+
}
|
|
114
141
|
async function handleFrame(connection, frame) {
|
|
115
142
|
if (frame.type === "gossip") {
|
|
116
143
|
const supplanted = /* @__PURE__ */ new Set();
|
|
@@ -156,7 +183,7 @@ function createRelayHub(options) {
|
|
|
156
183
|
}
|
|
157
184
|
const catchUp = [];
|
|
158
185
|
for (const registration of devices.values()) if (registration.connection !== connection) catchUp.push(registration.advert);
|
|
159
|
-
if (catchUp.length > 0) try {
|
|
186
|
+
if (catchUp.length > 0 && connection !== uplink) try {
|
|
160
187
|
await connection.send({
|
|
161
188
|
type: "gossip",
|
|
162
189
|
peers: catchUp
|
|
@@ -167,24 +194,39 @@ function createRelayHub(options) {
|
|
|
167
194
|
if (frame.type === "relay-connect") {
|
|
168
195
|
const registration = devices.get(deviceKey(frame["target-device"]));
|
|
169
196
|
if (!registration || registration.connection === connection) return;
|
|
170
|
-
const initiatorDevice =
|
|
171
|
-
if (initiatorDevice === void 0) return;
|
|
197
|
+
const initiatorDevice = initiatorOf(connection, frame["source-device"]);
|
|
198
|
+
if (initiatorDevice === void 0 || connection === uplink) return;
|
|
172
199
|
addPairing(connection, initiatorDevice, registration.connection, registration.advert.device);
|
|
173
200
|
stateChanged(connection);
|
|
174
201
|
stateChanged(registration.connection);
|
|
202
|
+
if (registration.connection === uplink) {
|
|
203
|
+
await registration.connection.send({
|
|
204
|
+
type: "relay-connect",
|
|
205
|
+
"target-device": registration.advert.device,
|
|
206
|
+
"source-device": initiatorDevice
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
175
210
|
await registration.connection.send({
|
|
176
211
|
type: "relay-inbound",
|
|
177
|
-
"source-device": initiatorDevice
|
|
212
|
+
"source-device": initiatorDevice,
|
|
213
|
+
"target-device": registration.advert.device
|
|
178
214
|
});
|
|
179
215
|
return;
|
|
180
216
|
}
|
|
217
|
+
if (frame.type === "relay-inbound") {
|
|
218
|
+
await handleUplinkInbound(connection, frame);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
181
221
|
if (frame.type === "relay-data") {
|
|
182
222
|
const own = pairings.get(connection);
|
|
183
223
|
const toDevice = frame["to-device"];
|
|
184
224
|
const peer = toDevice !== void 0 ? own?.get(deviceKey(toDevice)) : mostRecentPairing.get(connection);
|
|
185
225
|
if (!peer) return;
|
|
186
|
-
const
|
|
226
|
+
const claimedFrom = frame["from-device"];
|
|
227
|
+
const senderDevice = initiatorOf(connection, claimedFrom);
|
|
187
228
|
if (senderDevice === void 0) return;
|
|
229
|
+
if (claimedFrom !== void 0 && pairings.get(peer)?.get(deviceKey(claimedFrom)) !== connection) return;
|
|
188
230
|
await peer.send({
|
|
189
231
|
type: "relay-data",
|
|
190
232
|
payload: frame.payload,
|
|
@@ -213,14 +255,28 @@ function createRelayHub(options) {
|
|
|
213
255
|
return;
|
|
214
256
|
}
|
|
215
257
|
}
|
|
258
|
+
async function serve(connection) {
|
|
259
|
+
connections.add(connection);
|
|
260
|
+
try {
|
|
261
|
+
for await (const frame of connection.receive()) await handleFrame(connection, frame);
|
|
262
|
+
} catch {} finally {
|
|
263
|
+
forgetConnection(connection);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
216
266
|
return {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
267
|
+
handleConnection: serve,
|
|
268
|
+
async handleUplink(connection) {
|
|
269
|
+
if (uplink !== void 0) throw new Error("this relay hub already has an uplink");
|
|
270
|
+
uplink = connection;
|
|
271
|
+
const local = [];
|
|
272
|
+
for (const registration of devices.values()) local.push(registration.advert);
|
|
273
|
+
if (local.length > 0) try {
|
|
274
|
+
await connection.send({
|
|
275
|
+
type: "gossip",
|
|
276
|
+
peers: local
|
|
277
|
+
});
|
|
278
|
+
} catch {}
|
|
279
|
+
await serve(connection);
|
|
224
280
|
},
|
|
225
281
|
registerConnection(connection) {
|
|
226
282
|
connections.add(connection);
|
|
@@ -235,6 +291,7 @@ function createRelayHub(options) {
|
|
|
235
291
|
connectionDevice.clear();
|
|
236
292
|
pairings.clear();
|
|
237
293
|
mostRecentPairing.clear();
|
|
294
|
+
uplink = void 0;
|
|
238
295
|
}
|
|
239
296
|
};
|
|
240
297
|
}
|