@fairfox/polly 0.57.0 → 0.58.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.
@@ -21,14 +21,14 @@ export type { EncryptedEnvelope, SealedBytes, } from "./shared/lib/encryption";
21
21
  export { decrypt, decryptOrThrow, EncryptionError, encrypt, generateDocumentKey, KEY_BYTES as ENCRYPTION_KEY_BYTES, NONCE_BYTES as ENCRYPTION_NONCE_BYTES, TAG_BYTES as ENCRYPTION_TAG_BYTES, } from "./shared/lib/encryption";
22
22
  export type { KeyringStorage } from "./shared/lib/keyring-storage";
23
23
  export { deserialiseKeyring, memoryKeyringStorage, serialiseKeyring, } from "./shared/lib/keyring-storage";
24
- export type { CreateMeshClientOptions, MeshClient, MeshClientHandleSnapshot, MeshClientPeerStateSnapshot, } from "./shared/lib/mesh-client";
24
+ export type { CreateMeshClientOptions, MeshClient, MeshClientHandleSnapshot, MeshClientPeerStateSnapshot, MeshStateModuleDiagnostics, } from "./shared/lib/mesh-client";
25
25
  export { createMeshClient } from "./shared/lib/mesh-client";
26
26
  export type { MeshKeyring, MeshNetworkAdapterOptions, } from "./shared/lib/mesh-network-adapter";
27
27
  export { DEFAULT_MESH_KEY_ID, MeshNetworkAdapter, } from "./shared/lib/mesh-network-adapter";
28
28
  export type { MeshSignalingClientOptions, SignalingMessage as MeshSignalingMessage, } from "./shared/lib/mesh-signaling-client";
29
29
  export { MeshSignalingClient } from "./shared/lib/mesh-signaling-client";
30
30
  export type { MeshStateOptions } from "./shared/lib/mesh-state";
31
- export { $meshCounter, $meshList, $meshState, $meshText, configureMeshState, resetMeshState, } from "./shared/lib/mesh-state";
31
+ export { $meshCounter, $meshList, $meshState, $meshText, configureMeshState, getLastConfiguredRepoPeerId, getMeshStateModuleId, isMeshStateConfigured, MESH_STATE_MODULE_ID, resetMeshState, wasMeshStateResolved, } from "./shared/lib/mesh-state";
32
32
  export type { HandleSyncSnapshot, InFlightSyncSnapshot, MeshWebRTCAdapterOptions, SlotInitiationDecision, SlotInitiationRejectionReason, SweepSnapshot, SyncHandshakeAttemptSnapshot, SyncProgressEvent, TransportSnapshot, } from "./shared/lib/mesh-webrtc-adapter";
33
33
  export { DEFAULT_ICE_SERVERS, MeshWebRTCAdapter } from "./shared/lib/mesh-webrtc-adapter";
34
34
  export type { CreatePairingTokenOptions, PairingToken, } from "./shared/lib/pairing";
package/dist/src/mesh.js CHANGED
@@ -1764,16 +1764,37 @@ function fieldEquals(a, b) {
1764
1764
 
1765
1765
  // src/shared/lib/mesh-state.ts
1766
1766
  var defaultRepo;
1767
+ var MESH_STATE_MODULE_ID = `mesh-state-${typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36)}`;
1768
+ function getMeshStateModuleId() {
1769
+ return MESH_STATE_MODULE_ID;
1770
+ }
1771
+ var lastConfiguredRepoPeerId;
1772
+ function getLastConfiguredRepoPeerId() {
1773
+ return lastConfiguredRepoPeerId;
1774
+ }
1767
1775
  function configureMeshState(repo) {
1768
1776
  defaultRepo = repo;
1777
+ lastConfiguredRepoPeerId = repo.peerId;
1769
1778
  }
1770
1779
  function resetMeshState() {
1771
1780
  defaultRepo = undefined;
1781
+ lastConfiguredRepoPeerId = undefined;
1782
+ }
1783
+ function isMeshStateConfigured() {
1784
+ return defaultRepo !== undefined;
1785
+ }
1786
+ var meshStateEverResolved = false;
1787
+ function wasMeshStateResolved() {
1788
+ return meshStateEverResolved;
1772
1789
  }
1773
1790
  function resolveRepo(option) {
1791
+ meshStateEverResolved = true;
1774
1792
  const repo = option ?? defaultRepo;
1775
1793
  if (!repo) {
1776
- throw new Error("Polly $meshState: no Repo configured. Call configureMeshState(repo) at startup or pass { repo } in the primitive options.");
1794
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
1795
+ console.warn(`[polly#107 H5] $meshState resolved against unconfigured module instance ${MESH_STATE_MODULE_ID}. If createMeshClient was called elsewhere, the consumer's wrappers and the mesh client are reaching different module instances — see polly#107.`);
1796
+ }
1797
+ throw new Error(`Polly $meshState: no Repo configured (module instance ${MESH_STATE_MODULE_ID}). Call configureMeshState(repo) at startup or pass { repo } in the primitive options. If you have called configureMeshState elsewhere, the most likely cause is that the call resolved to a different module instance than this one — see polly#107.`);
1777
1798
  }
1778
1799
  return repo;
1779
1800
  }
@@ -3000,7 +3021,15 @@ async function createMeshClient(options) {
3000
3021
  runCount: 0,
3001
3022
  lastRunAt: undefined
3002
3023
  },
3003
- peers: []
3024
+ peers: [],
3025
+ meshStateModule: {
3026
+ moduleId: getMeshStateModuleId(),
3027
+ configured: isMeshStateConfigured(),
3028
+ lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),
3029
+ wasResolved: wasMeshStateResolved()
3030
+ },
3031
+ repoHandleCount: Object.keys(repo.handles).length,
3032
+ repoHandleIds: Object.keys(repo.handles)
3004
3033
  };
3005
3034
  }
3006
3035
  const base = webrtcAdapter.getPeerStateSnapshot();
@@ -3012,7 +3041,15 @@ async function createMeshClient(options) {
3012
3041
  knownPeerIds: base.knownPeerIds,
3013
3042
  presentPeerIds: base.presentPeerIds,
3014
3043
  sweep: base.sweep,
3015
- peers: enrichedPeers
3044
+ peers: enrichedPeers,
3045
+ meshStateModule: {
3046
+ moduleId: getMeshStateModuleId(),
3047
+ configured: isMeshStateConfigured(),
3048
+ lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),
3049
+ wasResolved: wasMeshStateResolved()
3050
+ },
3051
+ repoHandleCount: knownHandleIds.length,
3052
+ repoHandleIds: knownHandleIds
3016
3053
  };
3017
3054
  return out;
3018
3055
  },
@@ -3382,6 +3419,7 @@ function decodeRevocation(bytes, keyring) {
3382
3419
  return record;
3383
3420
  }
3384
3421
  export {
3422
+ wasMeshStateResolved,
3385
3423
  verify,
3386
3424
  signingKeyPairFromSecret,
3387
3425
  sign,
@@ -3392,7 +3430,10 @@ export {
3392
3430
  parsePairingToken,
3393
3431
  memoryKeyringStorage,
3394
3432
  isPairingTokenExpired,
3433
+ isMeshStateConfigured,
3395
3434
  isBlobRef,
3435
+ getMeshStateModuleId,
3436
+ getLastConfiguredRepoPeerId,
3396
3437
  generateSigningKeyPair,
3397
3438
  generateDocumentKey,
3398
3439
  encrypt,
@@ -3427,6 +3468,7 @@ export {
3427
3468
  MeshSignalingClient,
3428
3469
  MeshNetworkAdapter,
3429
3470
  MemoryBlobCache,
3471
+ MESH_STATE_MODULE_ID,
3430
3472
  IndexedDBBlobCache,
3431
3473
  EncryptionError,
3432
3474
  TAG_BYTES as ENCRYPTION_TAG_BYTES,
@@ -3441,4 +3483,4 @@ export {
3441
3483
  $meshCounter
3442
3484
  };
3443
3485
 
3444
- //# debugId=DAB92455464EE0D864756E2164756E21
3486
+ //# debugId=23078FA0DB4C154064756E2164756E21
@@ -8,13 +8,13 @@
8
8
  "/**\n * BlobRef — content-addressed reference to a binary blob.\n *\n * CRDT documents held by `$peerState` and `$meshState` primitives should not embed\n * large binary payloads directly. The Automerge history grows monotonically with every\n * op, and embedding a file means every op carries the file, memory explodes, and sync\n * bandwidth is terrible. The sound pattern is to store a reference to the blob inside\n * the document and keep the bytes in a separate, content-addressed blob store.\n *\n * This module defines the reference shape so that applications can hold `BlobRef`\n * values inside their `$peerState`/`$meshState` documents from day one. The actual\n * blob store, the upload/fetch API, and transport-specific blob sync are deliberately\n * out of scope and will land in a follow-up RFC. Provisioning the type now prevents\n * a data-model migration when that RFC ships.\n *\n * @example\n * ```ts\n * const doc = $peerState<Document>(\"doc\", { title: \"\", attachments: [] });\n *\n * const bytes = new Uint8Array(await file.arrayBuffer());\n * const ref = await createBlobRef({\n * bytes,\n * filename: file.name,\n * mimeType: file.type,\n * });\n *\n * doc.value = {\n * ...doc.value,\n * attachments: [...doc.value.attachments, ref],\n * };\n * ```\n */\n\n/**\n * Content-addressed reference to a binary blob.\n *\n * The `hash` field is a hex-encoded SHA-256 digest of the blob's bytes. Two blobs\n * with identical bytes always produce the same hash, so references can be deduplicated\n * and the blob store (when it ships) can use the hash as its primary key.\n */\nexport type BlobRef = {\n /** Hex-encoded SHA-256 digest of the blob's bytes (64 lowercase hex characters). */\n hash: string;\n /** Length of the blob in bytes. */\n size: number;\n /** Filename as supplied by the originating application. Not used for addressing. */\n filename: string;\n /** MIME type as supplied by the originating application. Not used for addressing. */\n mimeType: string;\n};\n\n/**\n * Type guard for {@link BlobRef}. Useful at CRDT document boundaries where values\n * may have been authored by older clients or by clients running different schemas.\n */\nexport function isBlobRef(value: unknown): value is BlobRef {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as unknown as Record<string, unknown>;\n return (\n typeof v[\"hash\"] === \"string\" &&\n /^[0-9a-f]{64}$/.test(v[\"hash\"]) &&\n typeof v[\"size\"] === \"number\" &&\n Number.isInteger(v[\"size\"]) &&\n v[\"size\"] >= 0 &&\n typeof v[\"filename\"] === \"string\" &&\n typeof v[\"mimeType\"] === \"string\"\n );\n}\n\n/**\n * Compute the SHA-256 hex digest of a byte sequence. Pure and deterministic.\n */\nexport async function computeBlobHash(bytes: Uint8Array): Promise<string> {\n // Copy into a fresh ArrayBuffer-backed view so the buffer type is ArrayBuffer\n // rather than the wider ArrayBufferLike, which crypto.subtle.digest's current\n // type signature rejects for SharedArrayBuffer safety.\n const buffer = new ArrayBuffer(bytes.byteLength);\n const copy = new Uint8Array(buffer);\n copy.set(bytes);\n const digest = await crypto.subtle.digest(\"SHA-256\", buffer);\n const view = new Uint8Array(digest);\n let hex = \"\";\n for (const byte of view) {\n hex += byte.toString(16).padStart(2, \"0\");\n }\n return hex;\n}\n\n/**\n * Arguments for {@link createBlobRef}.\n */\nexport type CreateBlobRefArgs = {\n bytes: Uint8Array;\n filename: string;\n mimeType: string;\n};\n\n/**\n * Build a {@link BlobRef} from raw bytes and metadata. The hash is computed from the\n * bytes; the filename and mimeType are carried from the originating application\n * verbatim and do not affect the content address.\n */\nexport async function createBlobRef({\n bytes,\n filename,\n mimeType,\n}: CreateBlobRefArgs): Promise<BlobRef> {\n const hash = await computeBlobHash(bytes);\n return {\n hash,\n size: bytes.byteLength,\n filename,\n mimeType,\n };\n}\n",
9
9
  "/**\n * blob-transfer — chunking, reassembly, and wire format for peer-to-peer\n * blob transfer over WebRTC data channels.\n *\n * Blobs are split into fixed-size chunks (64 KiB) and sent as individual\n * data channel messages. The wire format reuses the same length-prefixed\n * header + binary payload layout that MeshWebRTCAdapter uses for Automerge\n * sync messages. Blob messages are distinguished by a `type` field in the\n * JSON header that starts with \"blob-\".\n *\n * Three message types:\n * - blob-chunk: a single chunk of a blob transfer\n * - blob-request: ask a peer to send chunks for a specific hash\n * - blob-have: announce local availability of a blob\n */\n\n// Constants\n\n/** Default chunk size in bytes: 64 KiB. Stays well within WebRTC SCTP\n * message size limits (~256 KiB in most browsers). */\nexport const BLOB_CHUNK_SIZE = 65_536;\n\n/** High-water mark for RTCDataChannel.bufferedAmount. The sender pauses\n * when the buffer exceeds this threshold. */\nexport const BLOB_BUFFER_HIGH_WATER = 256 * 1024;\n\n// Message header types\n\nexport interface BlobChunkHeader {\n type: \"blob-chunk\";\n hash: string;\n index: number;\n total: number;\n}\n\nexport interface BlobRequestHeader {\n type: \"blob-request\";\n hash: string;\n /** Chunk indices needed. Omit to request all chunks. */\n missing?: number[];\n}\n\nexport interface BlobHaveHeader {\n type: \"blob-have\";\n hash: string;\n}\n\nexport type BlobMessageHeader = BlobChunkHeader | BlobRequestHeader | BlobHaveHeader;\n\n// Chunking\n\n/** Split bytes into fixed-size chunks. The last chunk may be smaller. */\nexport function chunkBlob(bytes: Uint8Array, chunkSize: number = BLOB_CHUNK_SIZE): Uint8Array[] {\n const chunks: Uint8Array[] = [];\n for (let offset = 0; offset < bytes.length; offset += chunkSize) {\n chunks.push(bytes.subarray(offset, Math.min(offset + chunkSize, bytes.length)));\n }\n // An empty blob produces one empty chunk so the protocol always sends\n // at least one blob-chunk message.\n if (chunks.length === 0) {\n chunks.push(new Uint8Array(0));\n }\n return chunks;\n}\n\n/** Reassemble chunks into a single Uint8Array. Throws if any chunk index\n * in [0, total) is missing from the map. */\nexport function reassembleChunks(chunks: Map<number, Uint8Array>, total: number): Uint8Array {\n let totalBytes = 0;\n for (let i = 0; i < total; i++) {\n const chunk = chunks.get(i);\n if (!chunk) {\n throw new Error(`reassembleChunks: missing chunk ${i} of ${total}`);\n }\n totalBytes += chunk.length;\n }\n const out = new Uint8Array(totalBytes);\n let offset = 0;\n for (let i = 0; i < total; i++) {\n const chunk = chunks.get(i) as unknown as Uint8Array;\n out.set(chunk, offset);\n offset += chunk.length;\n }\n return out;\n}\n\n/** Return the indices of chunks missing from a partial chunk map. */\nexport function missingChunkIndices(chunks: Map<number, Uint8Array>, total: number): number[] {\n const missing: number[] = [];\n for (let i = 0; i < total; i++) {\n if (!chunks.has(i)) {\n missing.push(i);\n }\n }\n return missing;\n}\n\n// Wire format\n\n/** Serialise a blob message into the shared wire format:\n * [4-byte BE header length][JSON header bytes][binary payload].\n * Returns an ArrayBuffer-backed Uint8Array usable by RTCDataChannel.send. */\nexport function serialiseBlobMessage(\n header: BlobMessageHeader,\n data: Uint8Array = new Uint8Array(0)\n): Uint8Array<ArrayBuffer> {\n const headerBytes = new TextEncoder().encode(JSON.stringify(header));\n const size = 4 + headerBytes.length + data.length;\n const buffer = new ArrayBuffer(size);\n const out = new Uint8Array(buffer);\n const view = new DataView(buffer);\n view.setUint32(0, headerBytes.length, false);\n out.set(headerBytes, 4);\n out.set(data, 4 + headerBytes.length);\n return out;\n}\n\n/** Peek at the header of a wire-format message without full\n * deserialisation. Returns the parsed header and the data slice,\n * or undefined if the bytes are too short or malformed. */\nexport function parseBlobMessage(\n bytes: Uint8Array\n): { header: BlobMessageHeader; data: Uint8Array } | undefined {\n if (bytes.length < 4) return undefined;\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const headerLen = view.getUint32(0, false);\n if (bytes.length < 4 + headerLen) return undefined;\n try {\n const header = JSON.parse(\n new TextDecoder().decode(bytes.subarray(4, 4 + headerLen))\n ) as BlobMessageHeader;\n const data = bytes.subarray(4 + headerLen);\n return { header, data };\n } catch {\n return undefined;\n }\n}\n\n/** Check whether a wire-format message header type starts with \"blob-\". */\nexport function isBlobMessageType(bytes: Uint8Array): boolean {\n if (bytes.length < 4) return false;\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const headerLen = view.getUint32(0, false);\n if (bytes.length < 4 + headerLen) return false;\n // Fast check: look for \"blob-\" in the header JSON without full parse.\n // The type field is always near the start of the JSON object.\n const headerSlice = bytes.subarray(4, 4 + headerLen);\n // Search for the byte sequence: \"type\":\"blob-\n const needle = new TextEncoder().encode('\"type\":\"blob-');\n return findSubarray(headerSlice, needle) !== -1;\n}\n\n/** Find the first occurrence of needle in haystack. Returns -1 if not found. */\nfunction findSubarray(haystack: Uint8Array, needle: Uint8Array): number {\n if (needle.length === 0) return 0;\n outer: for (let i = 0; i <= haystack.length - needle.length; i++) {\n for (let j = 0; j < needle.length; j++) {\n if (haystack[i + j] !== needle[j]) continue outer;\n }\n return i;\n }\n return -1;\n}\n",
10
10
  "/**\n * blob-store-impl — peer-to-peer blob store backed by WebRTC data channels.\n *\n * The store piggybacks on an existing MeshWebRTCAdapter. Blob messages ride\n * on the same data channel as Automerge sync traffic, distinguished by a\n * \"blob-\" prefix on the message type field.\n *\n * Lifecycle:\n * - put: hash-verify → cache plaintext locally → announce blob-have\n * - get: check cache → if miss, send blob-request(s) → receive chunks\n * → decrypt each chunk as it arrives → reassemble plaintext\n * → hash-verify → cache\n *\n * Encryption model: chunk-then-encrypt. The sender chunks the plaintext\n * into 64 KiB pieces, encrypts each chunk independently under the configured\n * key (with a fresh random nonce per chunk), and sends the sealed envelope.\n * The receiver decrypts each chunk on arrival. Peak sender memory is ~1\n * chunk of ciphertext at a time rather than the entire ciphertext blob.\n *\n * Per-op keys: callers can override the store's default encryption key per\n * put/get via BlobTransferOptions.key. This supports per-document keys\n * without requiring the store to track document ownership.\n *\n * Multi-source fetch: the get() flow requests from a single peer initially,\n * but the re-request timer rotates through peers that have announced\n * availability of the blob, so a transfer that stalls on one peer recovers\n * against another.\n */\n\nimport { MemoryBlobCache } from \"./blob-cache\";\nimport { computeBlobHash } from \"./blob-ref\";\nimport type { BlobCache, BlobProgressCallback, BlobStore, BlobStoreOptions } from \"./blob-store\";\nimport {\n type BlobChunkHeader,\n type BlobHaveHeader,\n type BlobMessageHeader,\n type BlobRequestHeader,\n chunkBlob,\n missingChunkIndices,\n reassembleChunks,\n serialiseBlobMessage,\n} from \"./blob-transfer\";\nimport type { MeshWebRTCAdapter } from \"./mesh-webrtc-adapter\";\n\nconst DEFAULT_MAX_BLOB_SIZE = 100 * 1024 * 1024; // 100 MiB\nconst DOWNLOAD_TIMEOUT_MS = 60_000;\nconst RE_REQUEST_DELAY_MS = 5_000;\n\n/** State for an in-progress blob download. */\ninterface DownloadState {\n total: number;\n /** Decrypted plaintext chunks, keyed by index. */\n chunks: Map<number, Uint8Array>;\n resolve: (bytes: Uint8Array) => void;\n reject: (error: Error) => void;\n onProgress?: BlobProgressCallback;\n timeoutId?: ReturnType<typeof setTimeout>;\n reRequestId?: ReturnType<typeof setTimeout>;\n /** Encryption key for this download, if any. */\n key?: Uint8Array;\n /** Peers we've asked, rotated on re-request for multi-source fetch. */\n peersAttempted: string[];\n /** Index into peersAttempted for the next re-request. */\n peerRotationIndex: number;\n}\n\n/** Create a blob store that transfers blobs peer-to-peer over a\n * MeshWebRTCAdapter's data channels. */\nexport function createBlobStore(adapter: MeshWebRTCAdapter, options?: BlobStoreOptions): BlobStore {\n const maxBlobSize = options?.maxBlobSize ?? DEFAULT_MAX_BLOB_SIZE;\n const defaultKey = options?.encrypt?.key;\n const cache: BlobCache = options?.cache ?? new MemoryBlobCache();\n\n // Per-hash key used at put time. Retained so that blob-request handlers\n // can encrypt chunks with the same key they were put under.\n const keysByHash = new Map<string, Uint8Array>();\n // Track which peers have which blobs (hash → set of peer IDs).\n const peerBlobs = new Map<string, Set<string>>();\n // Track in-progress downloads (hash → download state).\n const downloads = new Map<string, DownloadState>();\n // Hashes we have locally (for announcing to new peers).\n const localHashes = new Set<string>();\n // Object URL cache (hash → object URL string).\n const urlCache = new Map<string, string>();\n let disposed = false;\n\n // Wire up the adapter's blob message callback.\n adapter.onBlobMessage = (peerId, header, data) => {\n if (disposed) return;\n const type = header[\"type\"] as unknown as string;\n switch (type) {\n case \"blob-chunk\":\n void handleChunk(peerId, header as unknown as BlobChunkHeader, data);\n break;\n case \"blob-request\":\n void handleRequest(peerId, header as unknown as BlobRequestHeader);\n break;\n case \"blob-have\":\n handleHave(peerId, header as unknown as BlobHaveHeader);\n break;\n }\n };\n\n // Announce local blobs to new peers when they connect.\n const peerCandidateHandler = (event: { peerId: unknown }) => {\n if (disposed) return;\n const newPeerId = event.peerId as unknown as string;\n for (const hash of localHashes) {\n const msg = serialiseBlobMessage({ type: \"blob-have\", hash } as unknown as BlobMessageHeader);\n adapter.sendBlobMessage(newPeerId, msg);\n }\n };\n adapter.on(\"peer-candidate\", peerCandidateHandler);\n\n // Crypto helpers\n\n async function encryptChunk(plaintext: Uint8Array, key: Uint8Array): Promise<Uint8Array> {\n const { encrypt } = await import(\"./encryption\");\n return encrypt(plaintext, key);\n }\n\n async function decryptChunk(\n sealed: Uint8Array,\n key: Uint8Array\n ): Promise<Uint8Array | undefined> {\n const { decrypt } = await import(\"./encryption\");\n return decrypt(sealed, key);\n }\n\n // Incoming message handlers\n\n async function handleChunk(\n peerId: string,\n header: BlobChunkHeader,\n data: Uint8Array\n ): Promise<void> {\n const download = downloads.get(header.hash);\n if (!download) return;\n download.total = header.total;\n\n // Track this peer as a source of chunks for this blob.\n if (!download.peersAttempted.includes(peerId)) {\n download.peersAttempted.push(peerId);\n }\n\n // Decrypt if a key is configured.\n let chunkBytes: Uint8Array;\n if (download.key) {\n const plaintext = await decryptChunk(data, download.key);\n if (!plaintext) {\n // Skip this chunk — bad key or corrupted. Let re-request retry.\n return;\n }\n chunkBytes = plaintext;\n } else {\n chunkBytes = data.slice();\n }\n\n download.chunks.set(header.index, chunkBytes);\n\n reportChunkProgress(download);\n resetReRequestTimer(download);\n\n if (download.chunks.size >= header.total) {\n finishDownload(header.hash, download);\n } else {\n scheduleReRequest(header.hash, download);\n }\n }\n\n function reportChunkProgress(download: DownloadState): void {\n if (!download.onProgress || download.total <= 0) return;\n let loaded = 0;\n for (const chunk of download.chunks.values()) {\n loaded += chunk.length;\n }\n download.onProgress({ loaded, total: undefined, phase: \"downloading\" });\n }\n\n function resetReRequestTimer(download: DownloadState): void {\n if (download.reRequestId) {\n clearTimeout(download.reRequestId);\n download.reRequestId = undefined;\n }\n }\n\n function finishDownload(hash: string, download: DownloadState): void {\n clearDownloadTimers(download);\n try {\n const assembled = reassembleChunks(download.chunks, download.total);\n downloads.delete(hash);\n download.resolve(assembled);\n } catch (err) {\n downloads.delete(hash);\n download.reject(err instanceof Error ? err : new Error(String(err)));\n }\n }\n\n async function handleRequest(peerId: string, header: BlobRequestHeader): Promise<void> {\n const plaintext = await cache.get(header.hash);\n if (!plaintext) return;\n\n const plaintextChunks = chunkBlob(plaintext);\n const requested = header.missing ?? plaintextChunks.map((_, i) => i);\n const chunkKey = keysByHash.get(header.hash);\n\n for (const index of requested) {\n await sendChunkAtIndex(peerId, header.hash, plaintextChunks, index, chunkKey);\n }\n }\n\n async function sendChunkAtIndex(\n peerId: string,\n hash: string,\n plaintextChunks: Uint8Array[],\n index: number,\n chunkKey: Uint8Array | undefined\n ): Promise<void> {\n if (index < 0 || index >= plaintextChunks.length) return;\n const plainChunk = plaintextChunks[index];\n if (!plainChunk) return;\n\n const payload = chunkKey ? await encryptChunk(plainChunk, chunkKey) : plainChunk;\n const chunkHeader: BlobChunkHeader = {\n type: \"blob-chunk\",\n hash,\n index,\n total: plaintextChunks.length,\n };\n const msg = serialiseBlobMessage(chunkHeader as unknown as BlobMessageHeader, payload);\n\n if (!adapter.sendBlobMessage(peerId, msg)) {\n await waitForBufferDrain();\n adapter.sendBlobMessage(peerId, msg);\n }\n }\n\n function handleHave(peerId: string, header: BlobHaveHeader): void {\n let peers = peerBlobs.get(header.hash);\n if (!peers) {\n peers = new Set();\n peerBlobs.set(header.hash, peers);\n }\n peers.add(peerId);\n }\n\n // Helpers\n\n function announceHave(hash: string): void {\n const msg = serialiseBlobMessage({ type: \"blob-have\", hash } as unknown as BlobMessageHeader);\n for (const peerId of adapter.connectedPeerIds) {\n adapter.sendBlobMessage(peerId, msg);\n }\n }\n\n function clearDownloadTimers(download: DownloadState): void {\n if (download.timeoutId) clearTimeout(download.timeoutId);\n if (download.reRequestId) clearTimeout(download.reRequestId);\n }\n\n function scheduleReRequest(hash: string, download: DownloadState): void {\n download.reRequestId = setTimeout(() => fireReRequest(hash, download), RE_REQUEST_DELAY_MS);\n }\n\n function fireReRequest(hash: string, download: DownloadState): void {\n if (!downloads.has(hash)) return;\n const missing = missingChunkIndices(download.chunks, download.total);\n if (missing.length === 0) return;\n\n // Multi-source fetch: rotate through known peers so a stalled\n // transfer recovers against a different source.\n const peers = peerBlobs.get(hash);\n const pool = peers && peers.size > 0 ? Array.from(peers) : Array.from(adapter.connectedPeerIds);\n if (pool.length === 0) return;\n const target = pool[download.peerRotationIndex % pool.length];\n download.peerRotationIndex++;\n if (!target) return;\n\n const reqHeader: BlobRequestHeader = { type: \"blob-request\", hash, missing };\n const msg = serialiseBlobMessage(reqHeader as unknown as BlobMessageHeader);\n adapter.sendBlobMessage(target, msg);\n\n // Re-arm timer in case this peer also stalls.\n scheduleReRequest(hash, download);\n }\n\n function waitForBufferDrain(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, 50));\n }\n\n // BlobStore implementation\n\n const store: BlobStore = {\n async put(ref, bytes, options?): Promise<void> {\n if (disposed) throw new Error(\"BlobStore is disposed\");\n options?.signal?.throwIfAborted();\n\n if (bytes.length > maxBlobSize) {\n throw new Error(`Blob exceeds maximum size (${bytes.length} > ${maxBlobSize})`);\n }\n\n // Verify hash.\n const hash = await computeBlobHash(bytes);\n if (hash !== ref.hash) {\n throw new Error(`Hash mismatch: expected ${ref.hash}, got ${hash}`);\n }\n\n options?.signal?.throwIfAborted();\n\n // Resolve the encryption key: per-op override > store default > no\n // encryption. Record the key so incoming blob-requests encrypt with\n // the same one.\n const key = options?.key ?? defaultKey;\n if (key) {\n keysByHash.set(ref.hash, key);\n }\n\n options?.onProgress?.({ loaded: bytes.length, total: bytes.length, phase: \"uploading\" });\n\n // Store plaintext in cache. Chunking + encryption is deferred to\n // handleRequest for streaming behavior.\n await cache.put(ref.hash, bytes);\n localHashes.add(ref.hash);\n\n announceHave(ref.hash);\n },\n\n async get(hash, options?): Promise<Uint8Array | undefined> {\n if (disposed) throw new Error(\"BlobStore is disposed\");\n options?.signal?.throwIfAborted();\n\n // Check local cache first.\n const cached = await cache.get(hash);\n if (cached) return cached;\n\n // Resolve the decryption key: per-op override > store default > no\n // decryption (plaintext chunks).\n const key = options?.key ?? defaultKey;\n\n // Find peers that have this blob.\n const peers = peerBlobs.get(hash);\n const candidates =\n peers && peers.size > 0 ? Array.from(peers) : Array.from(adapter.connectedPeerIds);\n const targetPeer = candidates[0];\n if (!targetPeer) return undefined;\n\n const requestHeader: BlobRequestHeader = { type: \"blob-request\", hash };\n const msg = serialiseBlobMessage(requestHeader as unknown as BlobMessageHeader);\n adapter.sendBlobMessage(targetPeer, msg);\n\n // Wait for chunks to arrive.\n const plaintext = await new Promise<Uint8Array>((resolve, reject) => {\n const download: DownloadState = {\n total: 0,\n chunks: new Map(),\n resolve,\n reject,\n onProgress: options?.onProgress,\n key,\n peersAttempted: [targetPeer],\n peerRotationIndex: 1,\n };\n downloads.set(hash, download);\n\n options?.signal?.addEventListener(\n \"abort\",\n () => {\n if (downloads.has(hash)) {\n clearDownloadTimers(download);\n downloads.delete(hash);\n reject(new Error(\"Blob download aborted\"));\n }\n },\n { once: true }\n );\n\n download.timeoutId = setTimeout(() => {\n if (downloads.has(hash)) {\n clearDownloadTimers(download);\n downloads.delete(hash);\n reject(new Error(\"Blob download timed out\"));\n }\n }, DOWNLOAD_TIMEOUT_MS);\n });\n\n // Verify hash against the plaintext.\n const actualHash = await computeBlobHash(plaintext);\n if (actualHash !== hash) {\n throw new Error(`Blob hash mismatch after download: expected ${hash}, got ${actualHash}`);\n }\n\n // Cache locally. Record the key so future blob-requests from peers\n // use the same one.\n await cache.put(hash, plaintext);\n if (key) keysByHash.set(hash, key);\n localHashes.add(hash);\n\n return plaintext;\n },\n\n async url(hash): Promise<string | undefined> {\n if (disposed) return undefined;\n const cached = urlCache.get(hash);\n if (cached) return cached;\n const bytes = await cache.get(hash);\n if (!bytes) return undefined;\n const buffer = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(buffer).set(bytes);\n const objectUrl = URL.createObjectURL(new Blob([buffer]));\n urlCache.set(hash, objectUrl);\n return objectUrl;\n },\n\n async pin(hash): Promise<void> {\n await cache.pin(hash);\n },\n\n async unpin(hash): Promise<void> {\n await cache.unpin(hash);\n },\n\n async size(): Promise<number> {\n return cache.size();\n },\n\n async evict(maxBytes): Promise<number> {\n return cache.evict(maxBytes);\n },\n\n dispose(): void {\n disposed = true;\n adapter.onBlobMessage = undefined;\n adapter.off(\"peer-candidate\", peerCandidateHandler);\n for (const [hash, download] of downloads) {\n clearDownloadTimers(download);\n download.reject(new Error(\"BlobStore disposed\"));\n downloads.delete(hash);\n }\n for (const objectUrl of urlCache.values()) {\n URL.revokeObjectURL(objectUrl);\n }\n urlCache.clear();\n keysByHash.clear();\n cache.dispose();\n },\n };\n\n return store;\n}\n",
11
- "/**\n * @fairfox/polly/mesh — mesh-networked CRDT state with end-to-end encryption.\n *\n * Wraps the peer-first primitives with WebRTC mesh transport and\n * sign-then-encrypt envelopes. This subpath export isolates the\n * @automerge/* and tweetnacl dependency trees so consumers who only\n * use $sharedState / $syncedState / $resource never pull them in.\n *\n * @example\n * ```typescript\n * import { $meshState, configureMeshState } from \"@fairfox/polly/mesh\";\n * ```\n */\n\n// Eagerly initialise Automerge's WASM runtime. Must come before anything\n// that touches @automerge/automerge-repo/slim.\nimport \"./shared/lib/wasm-init\";\n\nexport { IndexedDBBlobCache, MemoryBlobCache } from \"./shared/lib/blob-cache\";\nexport type { BlobRef, CreateBlobRefArgs } from \"./shared/lib/blob-ref\";\nexport { computeBlobHash, createBlobRef, isBlobRef } from \"./shared/lib/blob-ref\";\n// Blob store\nexport type {\n BlobCache,\n BlobProgressCallback,\n BlobProgressEvent,\n BlobStore,\n BlobStoreOptions,\n BlobTransferOptions,\n} from \"./shared/lib/blob-store\";\nexport { createBlobStore } from \"./shared/lib/blob-store-impl\";\nexport type {\n EncryptedEnvelope,\n SealedBytes,\n} from \"./shared/lib/encryption\";\nexport {\n decrypt,\n decryptOrThrow,\n EncryptionError,\n encrypt,\n generateDocumentKey,\n KEY_BYTES as ENCRYPTION_KEY_BYTES,\n NONCE_BYTES as ENCRYPTION_NONCE_BYTES,\n TAG_BYTES as ENCRYPTION_TAG_BYTES,\n} from \"./shared/lib/encryption\";\n// Keyring storage (runtime-agnostic)\nexport type { KeyringStorage } from \"./shared/lib/keyring-storage\";\nexport {\n deserialiseKeyring,\n memoryKeyringStorage,\n serialiseKeyring,\n} from \"./shared/lib/keyring-storage\";\n// Mesh client factory\nexport type {\n CreateMeshClientOptions,\n MeshClient,\n MeshClientHandleSnapshot,\n MeshClientPeerStateSnapshot,\n} from \"./shared/lib/mesh-client\";\nexport { createMeshClient } from \"./shared/lib/mesh-client\";\n// Mesh network adapter (sign-then-encrypt envelopes over any base adapter)\nexport type {\n MeshKeyring,\n MeshNetworkAdapterOptions,\n} from \"./shared/lib/mesh-network-adapter\";\nexport {\n DEFAULT_MESH_KEY_ID,\n MeshNetworkAdapter,\n} from \"./shared/lib/mesh-network-adapter\";\n// Mesh signaling client\nexport type {\n MeshSignalingClientOptions,\n SignalingMessage as MeshSignalingMessage,\n} from \"./shared/lib/mesh-signaling-client\";\nexport { MeshSignalingClient } from \"./shared/lib/mesh-signaling-client\";\n// Mesh state wrappers\nexport type { MeshStateOptions } from \"./shared/lib/mesh-state\";\nexport {\n $meshCounter,\n $meshList,\n $meshState,\n $meshText,\n configureMeshState,\n resetMeshState,\n} from \"./shared/lib/mesh-state\";\n// Mesh WebRTC adapter\nexport type {\n HandleSyncSnapshot,\n InFlightSyncSnapshot,\n MeshWebRTCAdapterOptions,\n SlotInitiationDecision,\n SlotInitiationRejectionReason,\n SweepSnapshot,\n SyncHandshakeAttemptSnapshot,\n SyncProgressEvent,\n TransportSnapshot,\n} from \"./shared/lib/mesh-webrtc-adapter\";\nexport { DEFAULT_ICE_SERVERS, MeshWebRTCAdapter } from \"./shared/lib/mesh-webrtc-adapter\";\n// Pairing and revocation (depend on signing/encryption)\nexport type {\n CreatePairingTokenOptions,\n PairingToken,\n} from \"./shared/lib/pairing\";\nexport {\n applyPairingToken,\n createPairingToken,\n createPairingTokenWithFreshIdentity,\n DEFAULT_PAIRING_TTL_MS,\n decodePairingToken,\n encodePairingToken,\n isPairingTokenExpired,\n PAIRING_NONCE_BYTES,\n PAIRING_TOKEN_VERSION,\n PairingError,\n parsePairingToken,\n serialisePairingToken,\n} from \"./shared/lib/pairing\";\nexport type {\n CreateRevocationOptions,\n RevocationRecord,\n} from \"./shared/lib/revocation\";\nexport {\n applyRevocation,\n createRevocation,\n decodeRevocation,\n encodeRevocation,\n REVOCATION_MAGIC,\n REVOCATION_RECORD_VERSION,\n RevocationError,\n revokePeerLocally,\n} from \"./shared/lib/revocation\";\n// Cryptographic primitives (signing + encryption)\nexport type { SignedEnvelope, SigningKeyPair } from \"./shared/lib/signing\";\nexport {\n generateSigningKeyPair,\n PUBLIC_KEY_BYTES as SIGNING_PUBLIC_KEY_BYTES,\n SECRET_KEY_BYTES as SIGNING_SECRET_KEY_BYTES,\n SIGNATURE_BYTES as SIGNING_SIGNATURE_BYTES,\n SigningError,\n sign,\n signingKeyPairFromSecret,\n verify,\n} from \"./shared/lib/signing\";\n",
11
+ "/**\n * @fairfox/polly/mesh — mesh-networked CRDT state with end-to-end encryption.\n *\n * Wraps the peer-first primitives with WebRTC mesh transport and\n * sign-then-encrypt envelopes. This subpath export isolates the\n * @automerge/* and tweetnacl dependency trees so consumers who only\n * use $sharedState / $syncedState / $resource never pull them in.\n *\n * @example\n * ```typescript\n * import { $meshState, configureMeshState } from \"@fairfox/polly/mesh\";\n * ```\n */\n\n// Eagerly initialise Automerge's WASM runtime. Must come before anything\n// that touches @automerge/automerge-repo/slim.\nimport \"./shared/lib/wasm-init\";\n\nexport { IndexedDBBlobCache, MemoryBlobCache } from \"./shared/lib/blob-cache\";\nexport type { BlobRef, CreateBlobRefArgs } from \"./shared/lib/blob-ref\";\nexport { computeBlobHash, createBlobRef, isBlobRef } from \"./shared/lib/blob-ref\";\n// Blob store\nexport type {\n BlobCache,\n BlobProgressCallback,\n BlobProgressEvent,\n BlobStore,\n BlobStoreOptions,\n BlobTransferOptions,\n} from \"./shared/lib/blob-store\";\nexport { createBlobStore } from \"./shared/lib/blob-store-impl\";\nexport type {\n EncryptedEnvelope,\n SealedBytes,\n} from \"./shared/lib/encryption\";\nexport {\n decrypt,\n decryptOrThrow,\n EncryptionError,\n encrypt,\n generateDocumentKey,\n KEY_BYTES as ENCRYPTION_KEY_BYTES,\n NONCE_BYTES as ENCRYPTION_NONCE_BYTES,\n TAG_BYTES as ENCRYPTION_TAG_BYTES,\n} from \"./shared/lib/encryption\";\n// Keyring storage (runtime-agnostic)\nexport type { KeyringStorage } from \"./shared/lib/keyring-storage\";\nexport {\n deserialiseKeyring,\n memoryKeyringStorage,\n serialiseKeyring,\n} from \"./shared/lib/keyring-storage\";\n// Mesh client factory\nexport type {\n CreateMeshClientOptions,\n MeshClient,\n MeshClientHandleSnapshot,\n MeshClientPeerStateSnapshot,\n MeshStateModuleDiagnostics,\n} from \"./shared/lib/mesh-client\";\nexport { createMeshClient } from \"./shared/lib/mesh-client\";\n// Mesh network adapter (sign-then-encrypt envelopes over any base adapter)\nexport type {\n MeshKeyring,\n MeshNetworkAdapterOptions,\n} from \"./shared/lib/mesh-network-adapter\";\nexport {\n DEFAULT_MESH_KEY_ID,\n MeshNetworkAdapter,\n} from \"./shared/lib/mesh-network-adapter\";\n// Mesh signaling client\nexport type {\n MeshSignalingClientOptions,\n SignalingMessage as MeshSignalingMessage,\n} from \"./shared/lib/mesh-signaling-client\";\nexport { MeshSignalingClient } from \"./shared/lib/mesh-signaling-client\";\n// Mesh state wrappers\nexport type { MeshStateOptions } from \"./shared/lib/mesh-state\";\nexport {\n $meshCounter,\n $meshList,\n $meshState,\n $meshText,\n configureMeshState,\n getLastConfiguredRepoPeerId,\n getMeshStateModuleId,\n isMeshStateConfigured,\n MESH_STATE_MODULE_ID,\n resetMeshState,\n wasMeshStateResolved,\n} from \"./shared/lib/mesh-state\";\n// Mesh WebRTC adapter\nexport type {\n HandleSyncSnapshot,\n InFlightSyncSnapshot,\n MeshWebRTCAdapterOptions,\n SlotInitiationDecision,\n SlotInitiationRejectionReason,\n SweepSnapshot,\n SyncHandshakeAttemptSnapshot,\n SyncProgressEvent,\n TransportSnapshot,\n} from \"./shared/lib/mesh-webrtc-adapter\";\nexport { DEFAULT_ICE_SERVERS, MeshWebRTCAdapter } from \"./shared/lib/mesh-webrtc-adapter\";\n// Pairing and revocation (depend on signing/encryption)\nexport type {\n CreatePairingTokenOptions,\n PairingToken,\n} from \"./shared/lib/pairing\";\nexport {\n applyPairingToken,\n createPairingToken,\n createPairingTokenWithFreshIdentity,\n DEFAULT_PAIRING_TTL_MS,\n decodePairingToken,\n encodePairingToken,\n isPairingTokenExpired,\n PAIRING_NONCE_BYTES,\n PAIRING_TOKEN_VERSION,\n PairingError,\n parsePairingToken,\n serialisePairingToken,\n} from \"./shared/lib/pairing\";\nexport type {\n CreateRevocationOptions,\n RevocationRecord,\n} from \"./shared/lib/revocation\";\nexport {\n applyRevocation,\n createRevocation,\n decodeRevocation,\n encodeRevocation,\n REVOCATION_MAGIC,\n REVOCATION_RECORD_VERSION,\n RevocationError,\n revokePeerLocally,\n} from \"./shared/lib/revocation\";\n// Cryptographic primitives (signing + encryption)\nexport type { SignedEnvelope, SigningKeyPair } from \"./shared/lib/signing\";\nexport {\n generateSigningKeyPair,\n PUBLIC_KEY_BYTES as SIGNING_PUBLIC_KEY_BYTES,\n SECRET_KEY_BYTES as SIGNING_SECRET_KEY_BYTES,\n SIGNATURE_BYTES as SIGNING_SIGNATURE_BYTES,\n SigningError,\n sign,\n signingKeyPairFromSecret,\n verify,\n} from \"./shared/lib/signing\";\n",
12
12
  "/**\n * keyring-storage — persistence abstraction for {@link MeshKeyring}.\n *\n * The keyring itself is a plain structural object of `Map`s, `Set`s, and a\n * signing keypair; it is deliberately not coupled to any persistence layer.\n * This module defines a storage interface that applications implement once\n * for their runtime (IndexedDB, the filesystem, a keychain, a secret\n * manager, whatever) and wire into {@link createMeshClient} via its\n * `keyring.storage` option.\n *\n * A canonical JSON-with-base64 serialisation is provided by\n * {@link serialiseKeyring} and {@link deserialiseKeyring}. It is inspectable\n * by humans, survives manual edits, and round-trips every field of the\n * keyring. Storage implementations that write plain strings (files,\n * localStorage, `kv` stores) can lean on these helpers; storage\n * implementations that persist structured data (IndexedDB, a keychain API)\n * can serialise differently if they prefer.\n */\n\nimport type { MeshKeyring } from \"./mesh-network-adapter\";\nimport type { SigningKeyPair } from \"./signing\";\n\n/**\n * A load/save pair for a single {@link MeshKeyring}. Implementations are\n * free to choose where and how the keyring is stored; the factory only\n * cares that `load()` returns the previously-saved keyring or `null`, and\n * that `save(keyring)` durably persists it.\n */\nexport interface KeyringStorage {\n /** Load the previously-saved keyring, or return `null` if none exists.\n * Implementations may throw for truly exceptional conditions (disk\n * errors, permission failures); a missing keyring is not exceptional. */\n load(): Promise<MeshKeyring | null>;\n /** Durably persist the keyring. Implementations should atomically replace\n * any existing stored value; partial writes must not leave the store in\n * an inconsistent state. */\n save(keyring: MeshKeyring): Promise<void>;\n}\n\n/**\n * In-memory storage. Useful for tests, ephemeral tools, and the first-run\n * bootstrap path where the keyring only lives for the duration of the\n * process. Calling `save` holds the keyring in a closed-over variable;\n * `load` returns it on subsequent calls within the same process.\n */\nexport function memoryKeyringStorage(): KeyringStorage {\n let stored: MeshKeyring | null = null;\n return {\n load: async () => stored,\n save: async (keyring) => {\n stored = keyring;\n },\n };\n}\n\n// Canonical JSON+base64 serialisation\n\ninterface SerialisedKeyring {\n version: 1;\n identity: { publicKey: string; secretKey: string };\n knownPeers: Record<string, string>;\n documentKeys: Record<string, string>;\n revokedPeers: string[];\n revocationAuthority?: string[];\n}\n\n/**\n * Encode a {@link MeshKeyring} to a canonical JSON string. Every\n * `Uint8Array` field (identity keys, public keys, document keys) is\n * base64-encoded; `Map`s and `Set`s become plain objects and arrays. The\n * output is pretty-printed so a human operator can eyeball or hand-edit\n * the file on disk.\n */\nexport function serialiseKeyring(keyring: MeshKeyring): string {\n const payload: SerialisedKeyring = {\n version: 1,\n identity: {\n publicKey: bytesToBase64(keyring.identity.publicKey),\n secretKey: bytesToBase64(keyring.identity.secretKey),\n },\n knownPeers: mapToBase64Record(keyring.knownPeers),\n documentKeys: mapToBase64Record(keyring.documentKeys),\n revokedPeers: [...keyring.revokedPeers],\n };\n if (keyring.revocationAuthority && keyring.revocationAuthority.size > 0) {\n payload.revocationAuthority = [...keyring.revocationAuthority];\n }\n return JSON.stringify(payload, null, 2);\n}\n\n/**\n * Decode a keyring from the format produced by {@link serialiseKeyring}.\n * Throws with a descriptive message when the input is malformed, so\n * corrupt storage surfaces as an actionable error rather than a silent\n * downgrade.\n */\nexport function deserialiseKeyring(text: string): MeshKeyring {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch (err) {\n throw new Error(`KeyringStorage: keyring payload is not valid JSON: ${(err as Error).message}`);\n }\n if (!raw || typeof raw !== \"object\") {\n throw new Error(\"KeyringStorage: keyring payload is not an object\");\n }\n const r = raw as unknown as Partial<SerialisedKeyring>;\n if (r.version !== 1) {\n throw new Error(`KeyringStorage: unsupported keyring version: ${String(r.version)}`);\n }\n if (!r.identity || typeof r.identity !== \"object\") {\n throw new Error(\"KeyringStorage: keyring payload is missing identity\");\n }\n const identity: SigningKeyPair = {\n publicKey: base64ToBytes(r.identity.publicKey),\n secretKey: base64ToBytes(r.identity.secretKey),\n };\n const keyring: MeshKeyring = {\n identity,\n knownPeers: base64RecordToMap(r.knownPeers ?? {}),\n documentKeys: base64RecordToMap(r.documentKeys ?? {}),\n revokedPeers: new Set(r.revokedPeers ?? []),\n };\n if (r.revocationAuthority && r.revocationAuthority.length > 0) {\n keyring.revocationAuthority = new Set(r.revocationAuthority);\n }\n return keyring;\n}\n\nfunction mapToBase64Record(map: Map<string, Uint8Array>): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of map) {\n out[key] = bytesToBase64(value);\n }\n return out;\n}\n\nfunction base64RecordToMap(record: Record<string, string>): Map<string, Uint8Array> {\n const out = new Map<string, Uint8Array>();\n for (const [key, value] of Object.entries(record)) {\n out.set(key, base64ToBytes(value));\n }\n return out;\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n // btoa is available in browsers, Node 16+, and Bun.\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary);\n}\n\nfunction base64ToBytes(b64: string): Uint8Array {\n const binary = atob(b64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n",
13
- "/**\n * mesh-client — first-class factory for constructing a Polly mesh client.\n *\n * The mesh transport stack has five pieces that have to be wired together:\n * a {@link MeshSignalingClient} talking to the relay server, a\n * {@link MeshWebRTCAdapter} that owns the per-peer RTCPeerConnections, a\n * {@link MeshNetworkAdapter} that signs and encrypts every message on the\n * way through, an Automerge `Repo` that drives sync, and a `MeshKeyring`\n * that holds the crypto material. Prior to this module, every consuming\n * application had to assemble the five pieces by hand — and in Node or\n * Bun had to monkey-patch `globalThis.WebSocket` / `globalThis.RTCPeerConnection`\n * because the lower-level primitives reached for those globals.\n *\n * `createMeshClient` takes options, hands back a `MeshClient`, and also\n * calls `configureMeshState(client.repo)` so `$meshState` works without\n * a second setup step. The WebSocket and RTCPeerConnection implementations\n * are injectable; defaults read from `globalThis` for browser ergonomics.\n * The companion `@fairfox/polly/mesh/node` subpath provides a CLI bootstrap\n * helper that wires werift (or `@roamhq/wrtc` if the consumer prefers) and\n * a file-backed keyring store.\n */\n\nimport { type PeerId, Repo, type StorageAdapterInterface } from \"@automerge/automerge-repo/slim\";\nimport type { KeyringStorage } from \"./keyring-storage\";\nimport { DEFAULT_MESH_KEY_ID, type MeshKeyring, MeshNetworkAdapter } from \"./mesh-network-adapter\";\nimport { MeshSignalingClient, type MeshSignalingClientOptions } from \"./mesh-signaling-client\";\nimport { configureMeshState } from \"./mesh-state\";\nimport { MeshWebRTCAdapter, type MeshWebRTCAdapterOptions } from \"./mesh-webrtc-adapter\";\n\n/** Options for {@link createMeshClient}. */\nexport interface CreateMeshClientOptions {\n /** Signalling-server configuration. `peerId` must be the same identity\n * this client's keyring was paired with on other peers. */\n signaling: {\n url: string;\n peerId: string;\n /** Optional WebSocket ctor override (e.g. `ws` on old Node). Defaults\n * to `globalThis.WebSocket`. */\n WebSocket?: MeshSignalingClientOptions[\"WebSocket\"];\n /** Forwarded error callback for diagnostic UI. */\n onError?: MeshSignalingClientOptions[\"onError\"];\n /** Forwarded hook for custom signalling frames. See\n * {@link MeshSignalingClientOptions.onCustomFrame} — consumers who\n * layer application protocols on the signalling socket receive\n * frames of unknown types here. */\n onCustomFrame?: MeshSignalingClientOptions[\"onCustomFrame\"];\n };\n /** WebRTC configuration. On browsers the defaults are fine; in Node or\n * Bun pass the `RTCPeerConnection` ctor from `werift` or `@roamhq/wrtc`. */\n rtc?: {\n RTCPeerConnection?: MeshWebRTCAdapterOptions[\"RTCPeerConnection\"];\n iceServers?: RTCIceServer[];\n /**\n * Async resolver for ICE servers, called once at connect time. Wins\n * over `iceServers` if both are set. The realistic pattern is a\n * consumer fetching short-lived TURN credentials from its own\n * backend before each session — for production WebRTC apps that\n * care about coverage, TURN is the only way two peers behind\n * symmetric NATs (cellular CGNAT, some corporate firewalls) can\n * exchange bytes at all.\n *\n * Common provider shapes:\n *\n * - **Self-hosted coturn**: fetch a HMAC-derived ephemeral\n * `username` / `credential` pair from your backend and return\n * `[{ urls: \"turn:turn.example.com\", username, credential }]`.\n * - **Cloudflare Calls**: hit `/v1/turn/keys/<id>/credentials/generate`\n * from a server route and pass the returned `iceServers` array\n * straight through.\n * - **Twilio NTS**: call the network-traversal-service endpoint\n * server-side and forward `data.iceServers`.\n * - **metered.ca / Xirsys / etc.**: same pattern — credentials live\n * server-side, the resolver is the integration point.\n *\n * Resolution happens once. ICE restart with refreshed credentials\n * is a separate concern that this hook does not yet cover; if your\n * deployment needs it, tear down and rebuild the mesh client when\n * the credential window closes.\n */\n iceCredentialResolver?: () => Promise<RTCIceServer[]>;\n /** Forward of {@link MeshWebRTCAdapterOptions.iceTransportPolicy}.\n * Set to `\"relay\"` to force every candidate pair through TURN; the\n * default leaves the underlying {@link RTCPeerConnection}\n * implementation's default in place. The\n * `examples/mesh-large-initial-sync-turn` harness uses `\"relay\"` to\n * exercise the polly#105 real-transport contract. */\n iceTransportPolicy?: MeshWebRTCAdapterOptions[\"iceTransportPolicy\"];\n /** Forward of {@link MeshWebRTCAdapterOptions.iceRelayEnforcement}.\n * Defaults to `true`. Set to `false` to bypass the polly#105\n * relay-only enforcement layer; the\n * `examples/mesh-large-initial-sync-turn` falsification path\n * (`POLLY_105_DISABLE_TURN_FIX=1`) does this to reproduce the\n * pre-#105 candidate-leak shape. Production callers should leave\n * this at the default. */\n iceRelayEnforcement?: MeshWebRTCAdapterOptions[\"iceRelayEnforcement\"];\n dataChannelLabel?: string;\n /** How often the mesh client re-evaluates whether to dial peers\n * already present in the signalling roster against the live\n * keyring. The sweep is what makes\n * `applyPairingToken(token, keyring)` calls performed *after* the\n * mesh client is up take effect on the WebRTC layer without\n * requiring the consumer to call\n * {@link MeshClient.refreshKnownPeers} by hand — see polly issue\n * #103 for the failure mode this closes. Defaults to 2000ms; set\n * to 0 to disable (the captured-set-only behaviour, kept for\n * migrations and for the pre-fix demonstration shape in\n * `examples/mesh-recovery-pair`). Forwarded straight to\n * {@link MeshWebRTCAdapterOptions.knownPeersRefreshIntervalMs}. */\n knownPeersRefreshIntervalMs?: MeshWebRTCAdapterOptions[\"knownPeersRefreshIntervalMs\"];\n /** Forward of {@link MeshWebRTCAdapterOptions.syncYieldEnabled}.\n * Defaults to `true`. The `examples/mesh-large-initial-sync`\n * example flips this to `false` when `POLLY_104_DISABLE_FIX=1` is\n * set, to demonstrate the pre-#104 tight-loop behaviour against\n * post-fix polly. Production callers should leave this at the\n * default. */\n syncYieldEnabled?: MeshWebRTCAdapterOptions[\"syncYieldEnabled\"];\n /** Forward of\n * {@link MeshWebRTCAdapterOptions.syncFragmentChunkSizeOverride}.\n * Production callers should leave this undefined. The\n * `examples/mesh-large-initial-sync` example passes 64 KiB when\n * `POLLY_104_DISABLE_FIX=1` to recreate the pre-#104\n * fragmentation bug. */\n syncFragmentChunkSizeOverride?: MeshWebRTCAdapterOptions[\"syncFragmentChunkSizeOverride\"];\n };\n /** The local peer's keyring — one of three shapes:\n *\n * - A {@link MeshKeyring} instance. The same object is used for the\n * lifetime of the mesh client; in-place mutations to its `knownPeers`\n * and `documentKeys` maps are visible to the next send and receive\n * (`MeshNetworkAdapter` re-reads the keyring on every message, so\n * `applyPairingToken` and friends take effect without a restart).\n *\n * - `{ storage }`: load the keyring once via the persistence adapter.\n * When `storage.load()` resolves to `null`, the factory throws with\n * a message pointing at the bootstrap helper in\n * `@fairfox/polly/mesh/node`; we deliberately do not generate an\n * identity silently.\n *\n * - `{ source }`: a synchronous function returning the current keyring.\n * Called by `MeshNetworkAdapter` on every send and every receive.\n * This is the shape that lets a long-lived mesh client recover from\n * keyring updates written by a *different* process — wire the\n * `source` to a cached object that a file watcher (or `readFileSync`\n * on each call) refreshes from disk, and a freshly-paired peer\n * becomes visible to the running adapter without any explicit\n * notification path. See polly issue #100. */\n keyring: MeshKeyring | { storage: KeyringStorage } | { source: () => MeshKeyring };\n /** Optional Automerge-Repo storage adapter. Applications that want\n * durable local state pass an IndexedDB adapter in browsers or a\n * filesystem adapter in Node; omitting it keeps the Repo in-memory. */\n repoStorage?: StorageAdapterInterface;\n /** When `false`, signs but does not encrypt. Defaults to `true` — the\n * full $meshState posture where the server is off the data path. */\n encryptionEnabled?: boolean;\n}\n\n/**\n * Resolve the ICE server list a mesh client will use. The resolver wins\n * over a static `iceServers` list because the realistic deployment shape\n * is a consumer fetching short-lived TURN credentials per session — the\n * resolver is the integration point and a static list alongside it would\n * silently mask a broken credential flow. Exported for unit tests; the\n * production call site is inside {@link createMeshClient}.\n */\nexport async function resolveIceServers(\n rtc: CreateMeshClientOptions[\"rtc\"]\n): Promise<RTCIceServer[] | undefined> {\n if (rtc?.iceCredentialResolver) {\n return rtc.iceCredentialResolver();\n }\n return rtc?.iceServers;\n}\n\n/** Build the per-handle entry the polly#107 snapshot enrichment emits.\n * Combines the Repo-side `state` (the canonical lifecycle) with the\n * adapter-side wire timestamps. Extracted from the snapshot mapper to\n * keep the per-peer iteration under the cognitive-complexity ceiling. */\nfunction buildHandleEntry(\n state: string,\n wire:\n | {\n lastSyncMessageOutAt: number | undefined;\n lastSyncMessageInAt: number | undefined;\n lastSyncMessageOutSize: number | undefined;\n lastSyncMessageOutType: string | undefined;\n }\n | undefined\n): MeshClientHandleSnapshot {\n return {\n state,\n announcedToPeer: wire?.lastSyncMessageOutAt !== undefined,\n lastSyncMessageOutAt: wire?.lastSyncMessageOutAt,\n lastSyncMessageInAt: wire?.lastSyncMessageInAt,\n lastSyncMessageOutSize: wire?.lastSyncMessageOutSize,\n lastSyncMessageOutType: wire?.lastSyncMessageOutType,\n };\n}\n\n/** Stringify a Repo handle's `state` value for the enriched snapshot.\n * Handles whose machine snapshot returns an object collapse to a\n * coerced string; in practice polly's $meshState always lands on a\n * leaf string. Returns `\"unknown\"` when the handle entry itself is\n * undefined. */\nfunction stringifyHandleState(handle: { state: unknown } | undefined): string {\n if (handle === undefined) return \"unknown\";\n return typeof handle.state === \"string\" ? handle.state : String(handle.state ?? \"unknown\");\n}\n\n/** Enrich one peer's slot view with the per-handle Repo×adapter merge\n * polly#107 item 7 specifies. Pulled out of the snapshot factory so the\n * outer factory stays under the cognitive-complexity ceiling and so\n * the per-iteration code is testable in isolation. */\nfunction enrichPeerSlot(\n peer: ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number],\n knownHandleIds: string[],\n repoHandles: Record<string, { state: unknown } | undefined>\n): MeshClientPeerStateSnapshot[\"peers\"][number] {\n if (!peer.slot) {\n return { ...peer, slot: undefined } as MeshClientPeerStateSnapshot[\"peers\"][number];\n }\n const enriched: Record<string, MeshClientHandleSnapshot> = {};\n for (const docId of knownHandleIds) {\n enriched[docId] = buildHandleEntry(\n stringifyHandleState(repoHandles[docId]),\n peer.slot.handles[docId]\n );\n }\n for (const docId of Object.keys(peer.slot.handles)) {\n if (enriched[docId]) continue;\n enriched[docId] = buildHandleEntry(\"unknown\", peer.slot.handles[docId]);\n }\n return { ...peer, slot: { ...peer.slot, handles: enriched } };\n}\n\n/** Lift the synchronizer's `reevaluateDocumentShare` method off a Repo\n * through a narrowed structural accessor.\n * `synchronizer.reevaluateDocumentShare` is `@hidden` on the Automerge\n * type, so we reach for it tolerantly — the worst case is the\n * polly#107 fix silently degrades to the pre-fix shape, which the\n * observability layer still surfaces clearly. */\nfunction getReevaluateDocumentShare(repo: Repo): (() => Promise<void>) | undefined {\n const sync = (\n repo as unknown as {\n synchronizer?: { reevaluateDocumentShare?: () => Promise<void> };\n }\n ).synchronizer;\n const fn = sync?.reevaluateDocumentShare;\n if (typeof fn !== \"function\" || sync === undefined) return undefined;\n return () => fn.call(sync);\n}\n\n/** Install the polly#107 peer-candidate hook on a freshly-constructed\n * mesh stack. Hides the falsification-gate branch behind a single call\n * so the outer factory's complexity score stays under the ceiling. */\nfunction installPolly107SyncReevaluation(networkAdapter: MeshNetworkAdapter, repo: Repo): void {\n const disable = typeof process !== \"undefined\" && process.env?.[\"POLLY_107_DISABLE_FIX\"] === \"1\";\n if (disable) return;\n const reevaluate = getReevaluateDocumentShare(repo);\n if (!reevaluate) return;\n networkAdapter.on(\"peer-candidate\", () => {\n void reevaluate().catch(() => {\n // Synchronizer errors are observable through\n // getPeerStateSnapshot; suppressing here keeps a single bad doc\n // from taking down the whole peer-candidate path.\n });\n });\n}\n\n/** Per-peer per-handle enrichment polly#107 adds on top of the\n * {@link MeshWebRTCAdapter} snapshot. `state` and `announcedToPeer`\n * come from the Repo side (which the adapter cannot see); the wire\n * timestamps come from the adapter's per-slot bookkeeping. */\nexport interface MeshClientHandleSnapshot {\n /** The local handle's lifecycle state — `\"ready\"`, `\"loading\"`,\n * `\"unavailable\"`, etc. — as reported by the Repo. `\"unknown\"` is\n * stamped when the wire has seen a sync message for a documentId\n * the local repo hasn't constructed a handle for yet (a remote peer\n * announcing a doc we haven't touched). */\n state: string;\n /** True iff polly's network adapter has dispatched at least one\n * outbound sync message for this document to this peer. Equivalent\n * to `lastSyncMessageOutAt !== undefined` but named for the\n * diagnostic question polly#107 asks the snapshot to answer:\n * \"has Automerge's NetworkSubsystem told this peer about this\n * handle?\". The failing-shape this ticket reports is precisely\n * the case where every entry has `state: \"ready\"` and\n * `announcedToPeer: false`. */\n announcedToPeer: boolean;\n /** `performance.now()` of the most recent outbound sync message for\n * this document to this peer. `undefined` until first send. */\n lastSyncMessageOutAt: number | undefined;\n /** `performance.now()` of the most recent inbound message dispatched\n * upward for this document from this peer. `undefined` until first\n * receive. */\n lastSyncMessageInAt: number | undefined;\n /** Byte length of the most recent outbound message. */\n lastSyncMessageOutSize: number | undefined;\n /** Type field of the most recent outbound message — typically\n * `\"sync\"` after handshake, `\"request\"` while the local side is\n * asking. */\n lastSyncMessageOutType: string | undefined;\n}\n\n/** The mesh client's enriched per-peer state snapshot. Mirrors the\n * underlying {@link MeshWebRTCAdapter.getPeerStateSnapshot} shape but\n * replaces the slot's `handles` map with the Repo-enriched view\n * polly#107 adds. */\nexport interface MeshClientPeerStateSnapshot {\n localPeerId: string;\n knownPeerIds: string[];\n presentPeerIds: string[];\n sweep: ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"sweep\"];\n peers: Array<\n Omit<ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number], \"slot\"> & {\n slot:\n | undefined\n | (Omit<\n NonNullable<\n ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number][\"slot\"]\n >,\n \"handles\"\n > & {\n handles: Record<string, MeshClientHandleSnapshot>;\n });\n }\n >;\n}\n\n/** Handle returned by {@link createMeshClient}. */\nexport interface MeshClient {\n /** The Automerge Repo. `$meshState` has already been configured against\n * this repo, so primitives just work — but the repo is exposed in case\n * the application needs it directly (server-side cron, bulk exports,\n * migration tools). */\n repo: Repo;\n /** The current keyring. Reads through the same live source the network\n * adapter uses, so the value always reflects the latest snapshot —\n * including changes introduced after construction via in-place mutation\n * or a `{ source }` callback. Applications can inspect or mutate the\n * returned object (add authorised peers, apply revocations) and the\n * next mesh message sees the change. */\n readonly keyring: MeshKeyring;\n /** The signalling client. Exposed for applications that need to hook\n * lifecycle events or send custom signalling payloads. */\n signaling: MeshSignalingClient;\n /** The WebRTC network adapter. Exposed for advanced use (blob store\n * wiring, peer-connection introspection). */\n networkAdapter: MeshNetworkAdapter;\n /** The underlying WebRTC adapter wrapped by {@link networkAdapter}. */\n webrtcAdapter: MeshWebRTCAdapter;\n /** Re-evaluate every peer currently in the signalling roster and\n * dial the ones the keyring now authorises that this client has not\n * already dialled. Equivalent to\n * {@link MeshWebRTCAdapter.refreshKnownPeers}; the periodic sweep\n * inside the WebRTC adapter calls the same code path, so consumers\n * only need this helper when they want to skip the wait between\n * sweeps after applying a pair token. Polly issue #103 — the path\n * the sweep was added to close — is the canonical use case. */\n refreshKnownPeers(): void;\n /** Snapshot of the mesh client's per-peer state — keyring\n * membership, signalling presence, per-slot SDP / ICE /\n * connectionState / data-channel state, queued-send / queued-ICE\n * depth, and per-peer per-handle sync state (state, announcedToPeer,\n * last sync message in/out). Plain data, safe to log or render.\n * Exists so a consumer harness can answer \"is the mesh layer in a\n * known good state, AND has Automerge actually announced every\n * local handle to every connected peer\" without instrumenting polly\n * internals. Polly issue #103 item 7; polly#107 item 7 added the\n * per-handle enrichment that this method overlays on top of the\n * underlying {@link MeshWebRTCAdapter} snapshot. */\n getPeerStateSnapshot(): MeshClientPeerStateSnapshot;\n /** Refresh every active peer slot's transport-level summary —\n * selected ICE candidate pair, SCTP retransmission counters, last\n * data-channel error — and populate it into the next\n * {@link getPeerStateSnapshot}. Walks {@link RTCPeerConnection.getStats}\n * once per peer, so it isn't free; consumers that want continuous\n * visibility should call this on a polling cadence the cost can\n * absorb. Polly issue #105 item 7. */\n refreshTransportStats(): Promise<void>;\n /** Force the Automerge synchronizer to re-evaluate every (handle ×\n * peer) pair and `beginSync` for any pair that should be syncing\n * but isn't. Called automatically on `peer-candidate` post-#107;\n * exposed for explicit invocation by harnesses that need to assert\n * the fix is engaged or that want a deterministic checkpoint after\n * post-construction handle additions.\n *\n * Resolves once the synchronizer's internal `Promise.allSettled`\n * over per-doc reevaluations resolves. Idempotent: if every pair is\n * already syncing this is a no-op. Polly issue #107 item 7. */\n reevaluateAllSync(): Promise<void>;\n /** Close the signalling WebSocket, tear down every RTCPeerConnection,\n * and shut the Repo cleanly. Idempotent. */\n close(): Promise<void>;\n}\n\n/**\n * Construct a fully-wired mesh client. Resolves once the signalling\n * connection is open and the Repo is ready to mutate documents; WebRTC\n * peer connections negotiate asynchronously in the background.\n */\nexport async function createMeshClient(options: CreateMeshClientOptions): Promise<MeshClient> {\n const keyringSource = await resolveKeyringSource(options.keyring);\n const keyring = keyringSource();\n const encryptionEnabled = options.encryptionEnabled ?? true;\n\n // A mesh keyring must carry the per-Repo document key used by\n // MeshNetworkAdapter's encryption layer. We fail loud rather than\n // silently disable encryption when encryptionEnabled is true.\n if (encryptionEnabled && !keyring.documentKeys.has(DEFAULT_MESH_KEY_ID)) {\n throw new Error(\n `createMeshClient: encryption is enabled but the keyring has no document key for \"${DEFAULT_MESH_KEY_ID}\". Bootstrap or apply a pairing token that carries the document key before connecting.`\n );\n }\n\n // Seed the WebRTC adapter with the keyring's current `knownPeers`\n // snapshot AND wire it to the same live keyring source the crypto\n // layer uses. The snapshot is kept for the legacy captured-set path\n // (consumers wiring MeshWebRTCAdapter directly without a source) and\n // as a \"first sweep\" hint; the live source is what closes polly\n // issue #103, where a long-lived daemon's keyring gains entries\n // through `applyPairingToken` after the adapter is already up and\n // the captured Set would otherwise never learn about them. The\n // crypto layer (MeshNetworkAdapter) reads the same source on every\n // send/receive — see mesh-network-adapter.ts for the matching\n // contract.\n const knownPeerIds = [...keyring.knownPeers.keys()].filter(\n (id) => id !== options.signaling.peerId\n );\n\n // The resolver wins when both are set. Failure here surfaces as a\n // create-time rejection rather than a silent fall-through to STUN-only,\n // which would mask broken credential plumbing until a real symmetric\n // NAT user reported \"can't connect\".\n const resolvedIceServers = await resolveIceServers(options.rtc);\n\n const webrtcAdapterOptions: MeshWebRTCAdapterOptions = {\n signaling: undefined as unknown as MeshSignalingClient, // wired after signaling construction\n peerId: options.signaling.peerId,\n knownPeerIds,\n keyringSource,\n ...(resolvedIceServers !== undefined && { iceServers: resolvedIceServers }),\n ...(options.rtc?.iceTransportPolicy !== undefined && {\n iceTransportPolicy: options.rtc.iceTransportPolicy,\n }),\n ...(options.rtc?.iceRelayEnforcement !== undefined && {\n iceRelayEnforcement: options.rtc.iceRelayEnforcement,\n }),\n ...(options.rtc?.dataChannelLabel !== undefined && {\n dataChannelLabel: options.rtc.dataChannelLabel,\n }),\n ...(options.rtc?.RTCPeerConnection !== undefined && {\n RTCPeerConnection: options.rtc.RTCPeerConnection,\n }),\n ...(options.rtc?.knownPeersRefreshIntervalMs !== undefined && {\n knownPeersRefreshIntervalMs: options.rtc.knownPeersRefreshIntervalMs,\n }),\n ...(options.rtc?.syncYieldEnabled !== undefined && {\n syncYieldEnabled: options.rtc.syncYieldEnabled,\n }),\n ...(options.rtc?.syncFragmentChunkSizeOverride !== undefined && {\n syncFragmentChunkSizeOverride: options.rtc.syncFragmentChunkSizeOverride,\n }),\n };\n\n // The signalling client needs a handleSignal callback, but that callback\n // lives on the WebRTC adapter — which itself wants a reference to the\n // signalling client for sending answers. Break the cycle by letting the\n // signalling client's callbacks reach the adapter through a closure\n // over `webrtcAdapter`, which is assigned immediately below. The same\n // closure pattern wires the peer-discovery callbacks\n // (onPeersPresent / onPeerJoined / onPeerLeft) through to the adapter's\n // dispatch methods.\n let webrtcAdapter: MeshWebRTCAdapter | undefined;\n const signaling = new MeshSignalingClient({\n url: options.signaling.url,\n peerId: options.signaling.peerId,\n ...(options.signaling.WebSocket !== undefined && { WebSocket: options.signaling.WebSocket }),\n ...(options.signaling.onError !== undefined && { onError: options.signaling.onError }),\n ...(options.signaling.onCustomFrame !== undefined && {\n onCustomFrame: options.signaling.onCustomFrame,\n }),\n onSignal: (fromPeerId, payload) => {\n webrtcAdapter?.handleSignal(fromPeerId, payload);\n },\n onPeersPresent: (peerIds) => {\n webrtcAdapter?.handlePeersPresent(peerIds);\n },\n onPeerJoined: (peerId) => {\n webrtcAdapter?.handlePeerJoined(peerId);\n },\n onPeerLeft: (peerId) => {\n webrtcAdapter?.handlePeerLeft(peerId);\n },\n });\n\n webrtcAdapterOptions.signaling = signaling;\n webrtcAdapter = new MeshWebRTCAdapter(webrtcAdapterOptions);\n\n const networkAdapter = new MeshNetworkAdapter({\n base: webrtcAdapter,\n keyringSource,\n encryptionEnabled,\n });\n\n // The Repo's peerId MUST match the mesh peer id we signed the keyring\n // against. Automerge would otherwise auto-generate a random \"peer-xxxxx\"\n // identifier, and `MeshNetworkAdapter`'s outgoing envelope would carry\n // that auto-id as its `senderId` — a value the remote keyring has never\n // seen and cannot look up in `knownPeers`. Every message would then fail\n // signature verification silently, and no `$meshState` sync would ever\n // apply.\n const repo = new Repo({\n network: [networkAdapter],\n peerId: options.signaling.peerId as unknown as PeerId,\n ...(options.repoStorage !== undefined && { storage: options.repoStorage }),\n });\n\n configureMeshState(repo);\n\n // polly#107 — on peer-candidate, force the synchronizer to\n // re-evaluate every (handle × peer) pair so any handle whose\n // `addDocument`/`addPeer` ordering race left it un-synced for this\n // peer gets `beginSync` invoked synchronously after the peer is\n // registered. The default Automerge flow IS supposed to handle this\n // through the `addPeer`-iterates-docSynchronizers and\n // `addDocument`-iterates-#peers cross-paths, but the polly#107\n // failing-shape evidence (fourteen pre-warmed handles, peer-candidate\n // fires, firstOutboundSendAt stays `(none)`) shows that path leaves\n // a gap in the realistic case. `reevaluateDocumentShare` walks every\n // docSynchronizer and starts a `beginSync` for every peer that\n // should be syncing but isn't — idempotent for handles that already\n // started, load-bearing for handles that didn't.\n //\n // Falsification gate (POLLY_107_DISABLE_FIX=1): skip the\n // re-evaluation so the pre-fix shape is preserved. The polly#107\n // example asserts that pre-fix-emulated runs produce the named\n // failure \"Automerge never invoked NetworkAdapter.send despite N\n // handles in repo and inbound messages received\", which is exactly\n // the production shape the ticket reports.\n installPolly107SyncReevaluation(networkAdapter, repo);\n\n await signaling.connect();\n\n return {\n repo,\n get keyring(): MeshKeyring {\n return keyringSource();\n },\n signaling,\n networkAdapter,\n webrtcAdapter,\n refreshKnownPeers: () => {\n webrtcAdapter?.refreshKnownPeers();\n },\n getPeerStateSnapshot: () => {\n // The closure-captured `webrtcAdapter` is assigned synchronously\n // before this object is returned, so the optional chain is\n // belt-and-braces against future construction reorderings.\n if (!webrtcAdapter) {\n return {\n localPeerId: options.signaling.peerId,\n knownPeerIds: [],\n presentPeerIds: [],\n sweep: {\n enabled: false,\n intervalMs: 0,\n runCount: 0,\n lastRunAt: undefined,\n },\n peers: [],\n };\n }\n const base = webrtcAdapter.getPeerStateSnapshot() as ReturnType<\n MeshWebRTCAdapter[\"getPeerStateSnapshot\"]\n >;\n // Enrich the adapter view with Repo-side handle state so the\n // polly#107 item 7 contract is observable in one place. The\n // adapter sees only the wire path; the Repo's `handles` map\n // owns the `state` (ready / loading / unavailable) and is the\n // canonical answer to \"what handles does the local replica\n // hold?\". Combining them produces \"for each handle this replica\n // holds, has Automerge announced it to this peer yet?\". The\n // failure shape polly#107 reports is precisely the case where\n // every entry in `repo.handles` is `ready` and every\n // corresponding `slot.handles[docId].lastSyncMessageOutAt` is\n // `undefined`.\n const repoHandles = repo.handles as unknown as Record<string, { state: unknown } | undefined>;\n const knownHandleIds = Object.keys(repoHandles);\n const enrichedPeers: MeshClientPeerStateSnapshot[\"peers\"] = base.peers.map((peer) =>\n enrichPeerSlot(peer, knownHandleIds, repoHandles)\n );\n const out: MeshClientPeerStateSnapshot = {\n localPeerId: base.localPeerId,\n knownPeerIds: base.knownPeerIds,\n presentPeerIds: base.presentPeerIds,\n sweep: base.sweep,\n peers: enrichedPeers,\n };\n return out;\n },\n reevaluateAllSync: async () => {\n const reevaluate = getReevaluateDocumentShare(repo);\n if (!reevaluate) return;\n await reevaluate();\n },\n refreshTransportStats: async () => {\n if (!webrtcAdapter) return;\n await webrtcAdapter.refreshAllTransportStats();\n },\n close: async () => {\n signaling.close();\n webrtcAdapter?.disconnect();\n await repo.shutdown();\n },\n };\n}\n\nasync function resolveKeyringSource(\n source: MeshKeyring | { storage: KeyringStorage } | { source: () => MeshKeyring }\n): Promise<() => MeshKeyring> {\n if (typeof source === \"object\" && source !== null && \"source\" in source) {\n return source.source;\n }\n if (\"storage\" in source) {\n const loaded = await source.storage.load();\n if (loaded === null) {\n throw new Error(\n \"createMeshClient: keyring storage returned null (no saved keyring). In a Node CLI, bootstrap with `bootstrapCliKeyring` from `@fairfox/polly/mesh/node`; in a browser, run your pairing flow first and save the keyring through the storage adapter before constructing the client.\"\n );\n }\n return () => loaded;\n }\n return () => source;\n}\n",
13
+ "/**\n * mesh-client — first-class factory for constructing a Polly mesh client.\n *\n * The mesh transport stack has five pieces that have to be wired together:\n * a {@link MeshSignalingClient} talking to the relay server, a\n * {@link MeshWebRTCAdapter} that owns the per-peer RTCPeerConnections, a\n * {@link MeshNetworkAdapter} that signs and encrypts every message on the\n * way through, an Automerge `Repo` that drives sync, and a `MeshKeyring`\n * that holds the crypto material. Prior to this module, every consuming\n * application had to assemble the five pieces by hand — and in Node or\n * Bun had to monkey-patch `globalThis.WebSocket` / `globalThis.RTCPeerConnection`\n * because the lower-level primitives reached for those globals.\n *\n * `createMeshClient` takes options, hands back a `MeshClient`, and also\n * calls `configureMeshState(client.repo)` so `$meshState` works without\n * a second setup step. The WebSocket and RTCPeerConnection implementations\n * are injectable; defaults read from `globalThis` for browser ergonomics.\n * The companion `@fairfox/polly/mesh/node` subpath provides a CLI bootstrap\n * helper that wires werift (or `@roamhq/wrtc` if the consumer prefers) and\n * a file-backed keyring store.\n */\n\nimport { type PeerId, Repo, type StorageAdapterInterface } from \"@automerge/automerge-repo/slim\";\nimport type { KeyringStorage } from \"./keyring-storage\";\nimport { DEFAULT_MESH_KEY_ID, type MeshKeyring, MeshNetworkAdapter } from \"./mesh-network-adapter\";\nimport { MeshSignalingClient, type MeshSignalingClientOptions } from \"./mesh-signaling-client\";\nimport {\n configureMeshState,\n getLastConfiguredRepoPeerId,\n getMeshStateModuleId,\n isMeshStateConfigured,\n wasMeshStateResolved,\n} from \"./mesh-state\";\nimport { MeshWebRTCAdapter, type MeshWebRTCAdapterOptions } from \"./mesh-webrtc-adapter\";\n\n/** Options for {@link createMeshClient}. */\nexport interface CreateMeshClientOptions {\n /** Signalling-server configuration. `peerId` must be the same identity\n * this client's keyring was paired with on other peers. */\n signaling: {\n url: string;\n peerId: string;\n /** Optional WebSocket ctor override (e.g. `ws` on old Node). Defaults\n * to `globalThis.WebSocket`. */\n WebSocket?: MeshSignalingClientOptions[\"WebSocket\"];\n /** Forwarded error callback for diagnostic UI. */\n onError?: MeshSignalingClientOptions[\"onError\"];\n /** Forwarded hook for custom signalling frames. See\n * {@link MeshSignalingClientOptions.onCustomFrame} — consumers who\n * layer application protocols on the signalling socket receive\n * frames of unknown types here. */\n onCustomFrame?: MeshSignalingClientOptions[\"onCustomFrame\"];\n };\n /** WebRTC configuration. On browsers the defaults are fine; in Node or\n * Bun pass the `RTCPeerConnection` ctor from `werift` or `@roamhq/wrtc`. */\n rtc?: {\n RTCPeerConnection?: MeshWebRTCAdapterOptions[\"RTCPeerConnection\"];\n iceServers?: RTCIceServer[];\n /**\n * Async resolver for ICE servers, called once at connect time. Wins\n * over `iceServers` if both are set. The realistic pattern is a\n * consumer fetching short-lived TURN credentials from its own\n * backend before each session — for production WebRTC apps that\n * care about coverage, TURN is the only way two peers behind\n * symmetric NATs (cellular CGNAT, some corporate firewalls) can\n * exchange bytes at all.\n *\n * Common provider shapes:\n *\n * - **Self-hosted coturn**: fetch a HMAC-derived ephemeral\n * `username` / `credential` pair from your backend and return\n * `[{ urls: \"turn:turn.example.com\", username, credential }]`.\n * - **Cloudflare Calls**: hit `/v1/turn/keys/<id>/credentials/generate`\n * from a server route and pass the returned `iceServers` array\n * straight through.\n * - **Twilio NTS**: call the network-traversal-service endpoint\n * server-side and forward `data.iceServers`.\n * - **metered.ca / Xirsys / etc.**: same pattern — credentials live\n * server-side, the resolver is the integration point.\n *\n * Resolution happens once. ICE restart with refreshed credentials\n * is a separate concern that this hook does not yet cover; if your\n * deployment needs it, tear down and rebuild the mesh client when\n * the credential window closes.\n */\n iceCredentialResolver?: () => Promise<RTCIceServer[]>;\n /** Forward of {@link MeshWebRTCAdapterOptions.iceTransportPolicy}.\n * Set to `\"relay\"` to force every candidate pair through TURN; the\n * default leaves the underlying {@link RTCPeerConnection}\n * implementation's default in place. The\n * `examples/mesh-large-initial-sync-turn` harness uses `\"relay\"` to\n * exercise the polly#105 real-transport contract. */\n iceTransportPolicy?: MeshWebRTCAdapterOptions[\"iceTransportPolicy\"];\n /** Forward of {@link MeshWebRTCAdapterOptions.iceRelayEnforcement}.\n * Defaults to `true`. Set to `false` to bypass the polly#105\n * relay-only enforcement layer; the\n * `examples/mesh-large-initial-sync-turn` falsification path\n * (`POLLY_105_DISABLE_TURN_FIX=1`) does this to reproduce the\n * pre-#105 candidate-leak shape. Production callers should leave\n * this at the default. */\n iceRelayEnforcement?: MeshWebRTCAdapterOptions[\"iceRelayEnforcement\"];\n dataChannelLabel?: string;\n /** How often the mesh client re-evaluates whether to dial peers\n * already present in the signalling roster against the live\n * keyring. The sweep is what makes\n * `applyPairingToken(token, keyring)` calls performed *after* the\n * mesh client is up take effect on the WebRTC layer without\n * requiring the consumer to call\n * {@link MeshClient.refreshKnownPeers} by hand — see polly issue\n * #103 for the failure mode this closes. Defaults to 2000ms; set\n * to 0 to disable (the captured-set-only behaviour, kept for\n * migrations and for the pre-fix demonstration shape in\n * `examples/mesh-recovery-pair`). Forwarded straight to\n * {@link MeshWebRTCAdapterOptions.knownPeersRefreshIntervalMs}. */\n knownPeersRefreshIntervalMs?: MeshWebRTCAdapterOptions[\"knownPeersRefreshIntervalMs\"];\n /** Forward of {@link MeshWebRTCAdapterOptions.syncYieldEnabled}.\n * Defaults to `true`. The `examples/mesh-large-initial-sync`\n * example flips this to `false` when `POLLY_104_DISABLE_FIX=1` is\n * set, to demonstrate the pre-#104 tight-loop behaviour against\n * post-fix polly. Production callers should leave this at the\n * default. */\n syncYieldEnabled?: MeshWebRTCAdapterOptions[\"syncYieldEnabled\"];\n /** Forward of\n * {@link MeshWebRTCAdapterOptions.syncFragmentChunkSizeOverride}.\n * Production callers should leave this undefined. The\n * `examples/mesh-large-initial-sync` example passes 64 KiB when\n * `POLLY_104_DISABLE_FIX=1` to recreate the pre-#104\n * fragmentation bug. */\n syncFragmentChunkSizeOverride?: MeshWebRTCAdapterOptions[\"syncFragmentChunkSizeOverride\"];\n };\n /** The local peer's keyring — one of three shapes:\n *\n * - A {@link MeshKeyring} instance. The same object is used for the\n * lifetime of the mesh client; in-place mutations to its `knownPeers`\n * and `documentKeys` maps are visible to the next send and receive\n * (`MeshNetworkAdapter` re-reads the keyring on every message, so\n * `applyPairingToken` and friends take effect without a restart).\n *\n * - `{ storage }`: load the keyring once via the persistence adapter.\n * When `storage.load()` resolves to `null`, the factory throws with\n * a message pointing at the bootstrap helper in\n * `@fairfox/polly/mesh/node`; we deliberately do not generate an\n * identity silently.\n *\n * - `{ source }`: a synchronous function returning the current keyring.\n * Called by `MeshNetworkAdapter` on every send and every receive.\n * This is the shape that lets a long-lived mesh client recover from\n * keyring updates written by a *different* process — wire the\n * `source` to a cached object that a file watcher (or `readFileSync`\n * on each call) refreshes from disk, and a freshly-paired peer\n * becomes visible to the running adapter without any explicit\n * notification path. See polly issue #100. */\n keyring: MeshKeyring | { storage: KeyringStorage } | { source: () => MeshKeyring };\n /** Optional Automerge-Repo storage adapter. Applications that want\n * durable local state pass an IndexedDB adapter in browsers or a\n * filesystem adapter in Node; omitting it keeps the Repo in-memory. */\n repoStorage?: StorageAdapterInterface;\n /** When `false`, signs but does not encrypt. Defaults to `true` — the\n * full $meshState posture where the server is off the data path. */\n encryptionEnabled?: boolean;\n}\n\n/**\n * Resolve the ICE server list a mesh client will use. The resolver wins\n * over a static `iceServers` list because the realistic deployment shape\n * is a consumer fetching short-lived TURN credentials per session — the\n * resolver is the integration point and a static list alongside it would\n * silently mask a broken credential flow. Exported for unit tests; the\n * production call site is inside {@link createMeshClient}.\n */\nexport async function resolveIceServers(\n rtc: CreateMeshClientOptions[\"rtc\"]\n): Promise<RTCIceServer[] | undefined> {\n if (rtc?.iceCredentialResolver) {\n return rtc.iceCredentialResolver();\n }\n return rtc?.iceServers;\n}\n\n/** Build the per-handle entry the polly#107 snapshot enrichment emits.\n * Combines the Repo-side `state` (the canonical lifecycle) with the\n * adapter-side wire timestamps. Extracted from the snapshot mapper to\n * keep the per-peer iteration under the cognitive-complexity ceiling. */\nfunction buildHandleEntry(\n state: string,\n wire:\n | {\n lastSyncMessageOutAt: number | undefined;\n lastSyncMessageInAt: number | undefined;\n lastSyncMessageOutSize: number | undefined;\n lastSyncMessageOutType: string | undefined;\n }\n | undefined\n): MeshClientHandleSnapshot {\n return {\n state,\n announcedToPeer: wire?.lastSyncMessageOutAt !== undefined,\n lastSyncMessageOutAt: wire?.lastSyncMessageOutAt,\n lastSyncMessageInAt: wire?.lastSyncMessageInAt,\n lastSyncMessageOutSize: wire?.lastSyncMessageOutSize,\n lastSyncMessageOutType: wire?.lastSyncMessageOutType,\n };\n}\n\n/** Stringify a Repo handle's `state` value for the enriched snapshot.\n * Handles whose machine snapshot returns an object collapse to a\n * coerced string; in practice polly's $meshState always lands on a\n * leaf string. Returns `\"unknown\"` when the handle entry itself is\n * undefined. */\nfunction stringifyHandleState(handle: { state: unknown } | undefined): string {\n if (handle === undefined) return \"unknown\";\n return typeof handle.state === \"string\" ? handle.state : String(handle.state ?? \"unknown\");\n}\n\n/** Enrich one peer's slot view with the per-handle Repo×adapter merge\n * polly#107 item 7 specifies. Pulled out of the snapshot factory so the\n * outer factory stays under the cognitive-complexity ceiling and so\n * the per-iteration code is testable in isolation. */\nfunction enrichPeerSlot(\n peer: ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number],\n knownHandleIds: string[],\n repoHandles: Record<string, { state: unknown } | undefined>\n): MeshClientPeerStateSnapshot[\"peers\"][number] {\n if (!peer.slot) {\n return { ...peer, slot: undefined } as MeshClientPeerStateSnapshot[\"peers\"][number];\n }\n const enriched: Record<string, MeshClientHandleSnapshot> = {};\n for (const docId of knownHandleIds) {\n enriched[docId] = buildHandleEntry(\n stringifyHandleState(repoHandles[docId]),\n peer.slot.handles[docId]\n );\n }\n for (const docId of Object.keys(peer.slot.handles)) {\n if (enriched[docId]) continue;\n enriched[docId] = buildHandleEntry(\"unknown\", peer.slot.handles[docId]);\n }\n return { ...peer, slot: { ...peer.slot, handles: enriched } };\n}\n\n/** Lift the synchronizer's `reevaluateDocumentShare` method off a Repo\n * through a narrowed structural accessor.\n * `synchronizer.reevaluateDocumentShare` is `@hidden` on the Automerge\n * type, so we reach for it tolerantly — the worst case is the\n * polly#107 fix silently degrades to the pre-fix shape, which the\n * observability layer still surfaces clearly. */\nfunction getReevaluateDocumentShare(repo: Repo): (() => Promise<void>) | undefined {\n const sync = (\n repo as unknown as {\n synchronizer?: { reevaluateDocumentShare?: () => Promise<void> };\n }\n ).synchronizer;\n const fn = sync?.reevaluateDocumentShare;\n if (typeof fn !== \"function\" || sync === undefined) return undefined;\n return () => fn.call(sync);\n}\n\n/** Install the polly#107 peer-candidate hook on a freshly-constructed\n * mesh stack. Hides the falsification-gate branch behind a single call\n * so the outer factory's complexity score stays under the ceiling. */\nfunction installPolly107SyncReevaluation(networkAdapter: MeshNetworkAdapter, repo: Repo): void {\n const disable = typeof process !== \"undefined\" && process.env?.[\"POLLY_107_DISABLE_FIX\"] === \"1\";\n if (disable) return;\n const reevaluate = getReevaluateDocumentShare(repo);\n if (!reevaluate) return;\n networkAdapter.on(\"peer-candidate\", () => {\n void reevaluate().catch(() => {\n // Synchronizer errors are observable through\n // getPeerStateSnapshot; suppressing here keeps a single bad doc\n // from taking down the whole peer-candidate path.\n });\n });\n}\n\n/** Per-peer per-handle enrichment polly#107 adds on top of the\n * {@link MeshWebRTCAdapter} snapshot. `state` and `announcedToPeer`\n * come from the Repo side (which the adapter cannot see); the wire\n * timestamps come from the adapter's per-slot bookkeeping. */\nexport interface MeshClientHandleSnapshot {\n /** The local handle's lifecycle state — `\"ready\"`, `\"loading\"`,\n * `\"unavailable\"`, etc. — as reported by the Repo. `\"unknown\"` is\n * stamped when the wire has seen a sync message for a documentId\n * the local repo hasn't constructed a handle for yet (a remote peer\n * announcing a doc we haven't touched). */\n state: string;\n /** True iff polly's network adapter has dispatched at least one\n * outbound sync message for this document to this peer. Equivalent\n * to `lastSyncMessageOutAt !== undefined` but named for the\n * diagnostic question polly#107 asks the snapshot to answer:\n * \"has Automerge's NetworkSubsystem told this peer about this\n * handle?\". The failing-shape this ticket reports is precisely\n * the case where every entry has `state: \"ready\"` and\n * `announcedToPeer: false`. */\n announcedToPeer: boolean;\n /** `performance.now()` of the most recent outbound sync message for\n * this document to this peer. `undefined` until first send. */\n lastSyncMessageOutAt: number | undefined;\n /** `performance.now()` of the most recent inbound message dispatched\n * upward for this document from this peer. `undefined` until first\n * receive. */\n lastSyncMessageInAt: number | undefined;\n /** Byte length of the most recent outbound message. */\n lastSyncMessageOutSize: number | undefined;\n /** Type field of the most recent outbound message — typically\n * `\"sync\"` after handshake, `\"request\"` while the local side is\n * asking. */\n lastSyncMessageOutType: string | undefined;\n}\n\n/** Polly#107 H5 diagnostics: surfaces the `mesh-state` module\n * instance identity so a single snapshot read tells the operator\n * whether the consumer's `$meshState` wrappers are resolving against\n * the same module instance `createMeshClient` configured. A mismatch\n * here IS the bundle-time module duplication bug. */\nexport interface MeshStateModuleDiagnostics {\n /** The id stamped at import time on the `mesh-state` module\n * instance THIS mesh client was constructed against. Compare to\n * the id seen at the `$meshState` call site (also importable as\n * `MESH_STATE_MODULE_ID` from `@fairfox/polly/mesh`). Two different\n * ids means the consumer is reaching a duplicated copy of\n * `mesh-state.ts` — wrappers register handles against a Repo this\n * mesh client never saw. */\n moduleId: string;\n /** `true` iff THIS module instance has a configured `defaultRepo`.\n * In the H5 scenario, this is `true` for the mesh-client-side\n * snapshot (because `createMeshClient` always calls\n * `configureMeshState` on the module it imports), but the same\n * field read from the consumer's `$meshState` call site would\n * be `false`. */\n configured: boolean;\n /** `peerId` of the most recent Repo wired through\n * `configureMeshState` against THIS module instance. Compared to\n * `client.repo.peerId` and the consumer's wrappers' resolved Repo\n * tells the full story. */\n lastConfiguredRepoPeerId: string | undefined;\n /** `true` if any `$meshState`-family wrapper has been called\n * against THIS module instance at any point. The polly#107 H5\n * fingerprint pair: `configured: true, wasResolved: false` on\n * the mesh-client-side snapshot (the wrappers never reached us);\n * the consumer's wrapper code reading the same field from THEIR\n * `$meshState` import would see `configured: false, wasResolved:\n * true` (they're using a module instance no mesh client ever\n * configured). */\n wasResolved: boolean;\n}\n\n/** The mesh client's enriched per-peer state snapshot. Mirrors the\n * underlying {@link MeshWebRTCAdapter.getPeerStateSnapshot} shape but\n * replaces the slot's `handles` map with the Repo-enriched view\n * polly#107 adds. */\nexport interface MeshClientPeerStateSnapshot {\n localPeerId: string;\n knownPeerIds: string[];\n presentPeerIds: string[];\n sweep: ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"sweep\"];\n peers: Array<\n Omit<ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number], \"slot\"> & {\n slot:\n | undefined\n | (Omit<\n NonNullable<\n ReturnType<MeshWebRTCAdapter[\"getPeerStateSnapshot\"]>[\"peers\"][number][\"slot\"]\n >,\n \"handles\"\n > & {\n handles: Record<string, MeshClientHandleSnapshot>;\n });\n }\n >;\n /** polly#107 H5 diagnostics. See {@link MeshStateModuleDiagnostics}. */\n meshStateModule: MeshStateModuleDiagnostics;\n /** Count of handles known to the Repo this client owns. Compared\n * to the count the consumer's `$meshState` wrappers should have\n * registered: a mismatch (e.g. consumer pre-warmed 14 wrappers,\n * snapshot reports 1) confirms the H5 module-duplication\n * fingerprint without needing a separate read. */\n repoHandleCount: number;\n /** All handle ids the Repo this client owns currently caches.\n * Together with `repoHandleCount` and `meshStateModule.moduleId`,\n * this answers \"did the consumer's wrappers land their handles in\n * THIS Repo?\" in one read. */\n repoHandleIds: string[];\n}\n\n/** Handle returned by {@link createMeshClient}. */\nexport interface MeshClient {\n /** The Automerge Repo. `$meshState` has already been configured against\n * this repo, so primitives just work — but the repo is exposed in case\n * the application needs it directly (server-side cron, bulk exports,\n * migration tools). */\n repo: Repo;\n /** The current keyring. Reads through the same live source the network\n * adapter uses, so the value always reflects the latest snapshot —\n * including changes introduced after construction via in-place mutation\n * or a `{ source }` callback. Applications can inspect or mutate the\n * returned object (add authorised peers, apply revocations) and the\n * next mesh message sees the change. */\n readonly keyring: MeshKeyring;\n /** The signalling client. Exposed for applications that need to hook\n * lifecycle events or send custom signalling payloads. */\n signaling: MeshSignalingClient;\n /** The WebRTC network adapter. Exposed for advanced use (blob store\n * wiring, peer-connection introspection). */\n networkAdapter: MeshNetworkAdapter;\n /** The underlying WebRTC adapter wrapped by {@link networkAdapter}. */\n webrtcAdapter: MeshWebRTCAdapter;\n /** Re-evaluate every peer currently in the signalling roster and\n * dial the ones the keyring now authorises that this client has not\n * already dialled. Equivalent to\n * {@link MeshWebRTCAdapter.refreshKnownPeers}; the periodic sweep\n * inside the WebRTC adapter calls the same code path, so consumers\n * only need this helper when they want to skip the wait between\n * sweeps after applying a pair token. Polly issue #103 — the path\n * the sweep was added to close — is the canonical use case. */\n refreshKnownPeers(): void;\n /** Snapshot of the mesh client's per-peer state — keyring\n * membership, signalling presence, per-slot SDP / ICE /\n * connectionState / data-channel state, queued-send / queued-ICE\n * depth, and per-peer per-handle sync state (state, announcedToPeer,\n * last sync message in/out). Plain data, safe to log or render.\n * Exists so a consumer harness can answer \"is the mesh layer in a\n * known good state, AND has Automerge actually announced every\n * local handle to every connected peer\" without instrumenting polly\n * internals. Polly issue #103 item 7; polly#107 item 7 added the\n * per-handle enrichment that this method overlays on top of the\n * underlying {@link MeshWebRTCAdapter} snapshot. */\n getPeerStateSnapshot(): MeshClientPeerStateSnapshot;\n /** Refresh every active peer slot's transport-level summary —\n * selected ICE candidate pair, SCTP retransmission counters, last\n * data-channel error — and populate it into the next\n * {@link getPeerStateSnapshot}. Walks {@link RTCPeerConnection.getStats}\n * once per peer, so it isn't free; consumers that want continuous\n * visibility should call this on a polling cadence the cost can\n * absorb. Polly issue #105 item 7. */\n refreshTransportStats(): Promise<void>;\n /** Force the Automerge synchronizer to re-evaluate every (handle ×\n * peer) pair and `beginSync` for any pair that should be syncing\n * but isn't. Called automatically on `peer-candidate` post-#107;\n * exposed for explicit invocation by harnesses that need to assert\n * the fix is engaged or that want a deterministic checkpoint after\n * post-construction handle additions.\n *\n * Resolves once the synchronizer's internal `Promise.allSettled`\n * over per-doc reevaluations resolves. Idempotent: if every pair is\n * already syncing this is a no-op. Polly issue #107 item 7. */\n reevaluateAllSync(): Promise<void>;\n /** Close the signalling WebSocket, tear down every RTCPeerConnection,\n * and shut the Repo cleanly. Idempotent. */\n close(): Promise<void>;\n}\n\n/**\n * Construct a fully-wired mesh client. Resolves once the signalling\n * connection is open and the Repo is ready to mutate documents; WebRTC\n * peer connections negotiate asynchronously in the background.\n */\nexport async function createMeshClient(options: CreateMeshClientOptions): Promise<MeshClient> {\n const keyringSource = await resolveKeyringSource(options.keyring);\n const keyring = keyringSource();\n const encryptionEnabled = options.encryptionEnabled ?? true;\n\n // A mesh keyring must carry the per-Repo document key used by\n // MeshNetworkAdapter's encryption layer. We fail loud rather than\n // silently disable encryption when encryptionEnabled is true.\n if (encryptionEnabled && !keyring.documentKeys.has(DEFAULT_MESH_KEY_ID)) {\n throw new Error(\n `createMeshClient: encryption is enabled but the keyring has no document key for \"${DEFAULT_MESH_KEY_ID}\". Bootstrap or apply a pairing token that carries the document key before connecting.`\n );\n }\n\n // Seed the WebRTC adapter with the keyring's current `knownPeers`\n // snapshot AND wire it to the same live keyring source the crypto\n // layer uses. The snapshot is kept for the legacy captured-set path\n // (consumers wiring MeshWebRTCAdapter directly without a source) and\n // as a \"first sweep\" hint; the live source is what closes polly\n // issue #103, where a long-lived daemon's keyring gains entries\n // through `applyPairingToken` after the adapter is already up and\n // the captured Set would otherwise never learn about them. The\n // crypto layer (MeshNetworkAdapter) reads the same source on every\n // send/receive — see mesh-network-adapter.ts for the matching\n // contract.\n const knownPeerIds = [...keyring.knownPeers.keys()].filter(\n (id) => id !== options.signaling.peerId\n );\n\n // The resolver wins when both are set. Failure here surfaces as a\n // create-time rejection rather than a silent fall-through to STUN-only,\n // which would mask broken credential plumbing until a real symmetric\n // NAT user reported \"can't connect\".\n const resolvedIceServers = await resolveIceServers(options.rtc);\n\n const webrtcAdapterOptions: MeshWebRTCAdapterOptions = {\n signaling: undefined as unknown as MeshSignalingClient, // wired after signaling construction\n peerId: options.signaling.peerId,\n knownPeerIds,\n keyringSource,\n ...(resolvedIceServers !== undefined && { iceServers: resolvedIceServers }),\n ...(options.rtc?.iceTransportPolicy !== undefined && {\n iceTransportPolicy: options.rtc.iceTransportPolicy,\n }),\n ...(options.rtc?.iceRelayEnforcement !== undefined && {\n iceRelayEnforcement: options.rtc.iceRelayEnforcement,\n }),\n ...(options.rtc?.dataChannelLabel !== undefined && {\n dataChannelLabel: options.rtc.dataChannelLabel,\n }),\n ...(options.rtc?.RTCPeerConnection !== undefined && {\n RTCPeerConnection: options.rtc.RTCPeerConnection,\n }),\n ...(options.rtc?.knownPeersRefreshIntervalMs !== undefined && {\n knownPeersRefreshIntervalMs: options.rtc.knownPeersRefreshIntervalMs,\n }),\n ...(options.rtc?.syncYieldEnabled !== undefined && {\n syncYieldEnabled: options.rtc.syncYieldEnabled,\n }),\n ...(options.rtc?.syncFragmentChunkSizeOverride !== undefined && {\n syncFragmentChunkSizeOverride: options.rtc.syncFragmentChunkSizeOverride,\n }),\n };\n\n // The signalling client needs a handleSignal callback, but that callback\n // lives on the WebRTC adapter — which itself wants a reference to the\n // signalling client for sending answers. Break the cycle by letting the\n // signalling client's callbacks reach the adapter through a closure\n // over `webrtcAdapter`, which is assigned immediately below. The same\n // closure pattern wires the peer-discovery callbacks\n // (onPeersPresent / onPeerJoined / onPeerLeft) through to the adapter's\n // dispatch methods.\n let webrtcAdapter: MeshWebRTCAdapter | undefined;\n const signaling = new MeshSignalingClient({\n url: options.signaling.url,\n peerId: options.signaling.peerId,\n ...(options.signaling.WebSocket !== undefined && { WebSocket: options.signaling.WebSocket }),\n ...(options.signaling.onError !== undefined && { onError: options.signaling.onError }),\n ...(options.signaling.onCustomFrame !== undefined && {\n onCustomFrame: options.signaling.onCustomFrame,\n }),\n onSignal: (fromPeerId, payload) => {\n webrtcAdapter?.handleSignal(fromPeerId, payload);\n },\n onPeersPresent: (peerIds) => {\n webrtcAdapter?.handlePeersPresent(peerIds);\n },\n onPeerJoined: (peerId) => {\n webrtcAdapter?.handlePeerJoined(peerId);\n },\n onPeerLeft: (peerId) => {\n webrtcAdapter?.handlePeerLeft(peerId);\n },\n });\n\n webrtcAdapterOptions.signaling = signaling;\n webrtcAdapter = new MeshWebRTCAdapter(webrtcAdapterOptions);\n\n const networkAdapter = new MeshNetworkAdapter({\n base: webrtcAdapter,\n keyringSource,\n encryptionEnabled,\n });\n\n // The Repo's peerId MUST match the mesh peer id we signed the keyring\n // against. Automerge would otherwise auto-generate a random \"peer-xxxxx\"\n // identifier, and `MeshNetworkAdapter`'s outgoing envelope would carry\n // that auto-id as its `senderId` — a value the remote keyring has never\n // seen and cannot look up in `knownPeers`. Every message would then fail\n // signature verification silently, and no `$meshState` sync would ever\n // apply.\n const repo = new Repo({\n network: [networkAdapter],\n peerId: options.signaling.peerId as unknown as PeerId,\n ...(options.repoStorage !== undefined && { storage: options.repoStorage }),\n });\n\n configureMeshState(repo);\n\n // polly#107 — on peer-candidate, force the synchronizer to\n // re-evaluate every (handle × peer) pair so any handle whose\n // `addDocument`/`addPeer` ordering race left it un-synced for this\n // peer gets `beginSync` invoked synchronously after the peer is\n // registered. The default Automerge flow IS supposed to handle this\n // through the `addPeer`-iterates-docSynchronizers and\n // `addDocument`-iterates-#peers cross-paths, but the polly#107\n // failing-shape evidence (fourteen pre-warmed handles, peer-candidate\n // fires, firstOutboundSendAt stays `(none)`) shows that path leaves\n // a gap in the realistic case. `reevaluateDocumentShare` walks every\n // docSynchronizer and starts a `beginSync` for every peer that\n // should be syncing but isn't — idempotent for handles that already\n // started, load-bearing for handles that didn't.\n //\n // Falsification gate (POLLY_107_DISABLE_FIX=1): skip the\n // re-evaluation so the pre-fix shape is preserved. The polly#107\n // example asserts that pre-fix-emulated runs produce the named\n // failure \"Automerge never invoked NetworkAdapter.send despite N\n // handles in repo and inbound messages received\", which is exactly\n // the production shape the ticket reports.\n installPolly107SyncReevaluation(networkAdapter, repo);\n\n await signaling.connect();\n\n return {\n repo,\n get keyring(): MeshKeyring {\n return keyringSource();\n },\n signaling,\n networkAdapter,\n webrtcAdapter,\n refreshKnownPeers: () => {\n webrtcAdapter?.refreshKnownPeers();\n },\n getPeerStateSnapshot: () => {\n // The closure-captured `webrtcAdapter` is assigned synchronously\n // before this object is returned, so the optional chain is\n // belt-and-braces against future construction reorderings.\n if (!webrtcAdapter) {\n return {\n localPeerId: options.signaling.peerId,\n knownPeerIds: [],\n presentPeerIds: [],\n sweep: {\n enabled: false,\n intervalMs: 0,\n runCount: 0,\n lastRunAt: undefined,\n },\n peers: [],\n meshStateModule: {\n moduleId: getMeshStateModuleId(),\n configured: isMeshStateConfigured(),\n lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),\n wasResolved: wasMeshStateResolved(),\n },\n repoHandleCount: Object.keys(repo.handles).length,\n repoHandleIds: Object.keys(repo.handles),\n };\n }\n const base = webrtcAdapter.getPeerStateSnapshot() as ReturnType<\n MeshWebRTCAdapter[\"getPeerStateSnapshot\"]\n >;\n // Enrich the adapter view with Repo-side handle state so the\n // polly#107 item 7 contract is observable in one place. The\n // adapter sees only the wire path; the Repo's `handles` map\n // owns the `state` (ready / loading / unavailable) and is the\n // canonical answer to \"what handles does the local replica\n // hold?\". Combining them produces \"for each handle this replica\n // holds, has Automerge announced it to this peer yet?\". The\n // failure shape polly#107 reports is precisely the case where\n // every entry in `repo.handles` is `ready` and every\n // corresponding `slot.handles[docId].lastSyncMessageOutAt` is\n // `undefined`.\n const repoHandles = repo.handles as unknown as Record<string, { state: unknown } | undefined>;\n const knownHandleIds = Object.keys(repoHandles);\n const enrichedPeers: MeshClientPeerStateSnapshot[\"peers\"] = base.peers.map((peer) =>\n enrichPeerSlot(peer, knownHandleIds, repoHandles)\n );\n const out: MeshClientPeerStateSnapshot = {\n localPeerId: base.localPeerId,\n knownPeerIds: base.knownPeerIds,\n presentPeerIds: base.presentPeerIds,\n sweep: base.sweep,\n peers: enrichedPeers,\n meshStateModule: {\n moduleId: getMeshStateModuleId(),\n configured: isMeshStateConfigured(),\n lastConfiguredRepoPeerId: getLastConfiguredRepoPeerId(),\n wasResolved: wasMeshStateResolved(),\n },\n repoHandleCount: knownHandleIds.length,\n repoHandleIds: knownHandleIds,\n };\n return out;\n },\n reevaluateAllSync: async () => {\n const reevaluate = getReevaluateDocumentShare(repo);\n if (!reevaluate) return;\n await reevaluate();\n },\n refreshTransportStats: async () => {\n if (!webrtcAdapter) return;\n await webrtcAdapter.refreshAllTransportStats();\n },\n close: async () => {\n signaling.close();\n webrtcAdapter?.disconnect();\n await repo.shutdown();\n },\n };\n}\n\nasync function resolveKeyringSource(\n source: MeshKeyring | { storage: KeyringStorage } | { source: () => MeshKeyring }\n): Promise<() => MeshKeyring> {\n if (typeof source === \"object\" && source !== null && \"source\" in source) {\n return source.source;\n }\n if (\"storage\" in source) {\n const loaded = await source.storage.load();\n if (loaded === null) {\n throw new Error(\n \"createMeshClient: keyring storage returned null (no saved keyring). In a Node CLI, bootstrap with `bootstrapCliKeyring` from `@fairfox/polly/mesh/node`; in a browser, run your pairing flow first and save the keyring through the storage adapter before constructing the client.\"\n );\n }\n return () => loaded;\n }\n return () => source;\n}\n",
14
14
  "/**\n * mesh-network-adapter — Phase 2 wrapping NetworkAdapter that adds Polly's\n * mesh-transport semantics on top of any underlying Automerge NetworkAdapter.\n *\n * The mesh transport's job is to make every message between peers signed\n * and encrypted before it reaches the wire. Rather than reimplementing the\n * Automerge sync protocol, this adapter takes a base adapter (in production\n * a real WebRTC or WebSocket adapter; in tests an in-memory loopback) and\n * applies the crypto envelope to every message that flows through.\n *\n * Outgoing path (Repo → wire):\n * 1. The Repo's NetworkSubsystem calls send(message) on this adapter.\n * 2. We serialise the message to bytes, encrypt them under the local\n * keyring's document key, sign the resulting blob with the local\n * identity's secret key, and pack the pair into a MeshFrame.\n * 3. We hand the MeshFrame off to the base adapter, which puts it on\n * whatever wire it owns.\n *\n * Incoming path (wire → Repo):\n * 1. The base adapter emits a 'message' event with bytes from the wire.\n * 2. We unpack the MeshFrame, look up the sender's public key in the\n * keyring, verify the signature, look up the document key, decrypt\n * the payload, and deserialise it back to the original message.\n * 3. We re-emit the 'message' event upward to the Repo's NetworkSubsystem\n * with the decrypted message.\n *\n * The keyring is an injected dependency. In production it's backed by\n * persistent storage and populated through the pairing flow. For tests it\n * is just a Map of publicly-known fixtures that both sides share.\n *\n * Caveat for the Phase 2 first cut: Automerge sync messages don't have a\n * stable \"what document does this belong to\" field at the wire level (the\n * documentId is part of the message contents). The mesh adapter therefore\n * uses a single per-Repo encryption key for now rather than per-document\n * keys, and stores the key once in the keyring under the well-known id\n * \"polly-mesh-default\". The plan describes per-document keys as the right\n * end state; that requires either parsing the message to extract the\n * documentId before encrypting (peeking inside the binary protocol) or\n * threading the document context through the network subsystem (which\n * needs upstream support). A follow-up will address this.\n */\n\nimport {\n type Message,\n NetworkAdapter,\n type PeerId,\n type PeerMetadata,\n} from \"@automerge/automerge-repo/slim\";\nimport {\n decodeEncryptedEnvelope,\n encodeEncryptedEnvelope,\n openEnvelope as openEncryptedEnvelope,\n sealEnvelope as sealEncryptedEnvelope,\n} from \"./encryption\";\nimport {\n decodeSignedEnvelope,\n encodeSignedEnvelope,\n openEnvelope as openSignedEnvelope,\n type SigningKeyPair,\n signEnvelope,\n} from \"./signing\";\n\n/** The well-known document id used for the Phase 2 first-cut single-key\n * encryption mode. See the file-level comment for the per-document key\n * follow-up. */\nexport const DEFAULT_MESH_KEY_ID = \"polly-mesh-default\";\n\n/**\n * A mesh keyring holds the local peer's signing identity, the public keys\n * of every peer the local node will accept messages from, the symmetric\n * encryption keys for documents the local node has access to, and the set\n * of peers whose keys have been revoked.\n */\nexport interface MeshKeyring {\n /** The local peer's signing keypair. The secret never leaves this\n * keyring; the public key is gossiped through the access set. */\n identity: SigningKeyPair;\n /** Map from peer id (string) to that peer's signing public key. The\n * mesh adapter rejects messages from peers not present in this map. */\n knownPeers: Map<string, Uint8Array>;\n /** Map from document key id (typically the documentId, or the well-known\n * default for the single-key first cut) to the symmetric encryption key. */\n documentKeys: Map<string, Uint8Array>;\n /** Set of peer ids whose keys have been revoked. The mesh adapter drops\n * incoming messages from any peer in this set, even if the peer is still\n * present in {@link knownPeers}. Revocation is applied via the revocation\n * module; the set is kept separate from knownPeers so that an application\n * can audit who was once authorised without losing the revocation record. */\n revokedPeers: Set<string>;\n /** Optional set of peer ids authorised to issue revocations. When present\n * and non-empty, `decodeRevocation` accepts a signed record only if the\n * issuer is in this set. When undefined or empty, any signed revocation\n * from a known peer is accepted (the Phase 2 first-cut default). This\n * field layers a \"who can revoke whom\" check on top of the signature\n * layer without breaking existing callers. */\n revocationAuthority?: Set<string>;\n}\n\n/**\n * Constructor options for {@link MeshNetworkAdapter}.\n */\nexport interface MeshNetworkAdapterOptions {\n /** The underlying NetworkAdapter that puts crypto-wrapped bytes on the\n * wire. In production this is a WebRTC or WebSocket adapter; in tests\n * it's an in-memory loopback. */\n base: NetworkAdapter;\n /** A synchronous function that returns the keyring to use for the next\n * send or receive. The adapter never caches the value across calls —\n * every {@link MeshNetworkAdapter#send | send} and every incoming\n * message asks the source for the current keyring, so callers that\n * mutate the in-memory keyring (e.g. `applyPairingToken`) or re-issue\n * it entirely (e.g. a long-lived CLI watching a disk-backed keyring\n * file that another process can rewrite) see their updates take effect\n * on the very next message without restarting the adapter.\n *\n * The function must be synchronous because Automerge's\n * `NetworkAdapter.send` is synchronous. Implementations that need to\n * read from disk should maintain a cached object — refreshed by a\n * file watcher, a manual reload, or `readFileSync` per call — and\n * return that cached object from the source. */\n keyringSource: () => MeshKeyring;\n /** When false, the adapter signs but does not encrypt. Outgoing messages\n * carry a signature envelope but the payload is plaintext; incoming\n * messages are verified against the sender's public key without a\n * decryption step. This mode is used by $peerState's `sign: true`\n * option, where the server must still be able to parse Automerge sync\n * messages. Defaults to true (encrypt + sign, the full $meshState\n * posture). */\n encryptionEnabled?: boolean;\n}\n\n/**\n * NetworkAdapter that wraps another adapter with Polly's mesh-transport\n * crypto envelope. Every outgoing message is encrypted then signed; every\n * incoming message is verified then decrypted before being forwarded to\n * the Repo's network subsystem.\n *\n * The adapter delegates lifecycle (connect, disconnect, isReady, peer\n * discovery) to the base adapter unchanged. Only the message body is\n * intercepted.\n */\nexport class MeshNetworkAdapter extends NetworkAdapter {\n readonly base: NetworkAdapter;\n readonly keyringSource: () => MeshKeyring;\n readonly encryptionEnabled: boolean;\n\n /** Read-only view of the current keyring. Each access calls\n * {@link MeshNetworkAdapterOptions.keyringSource}, so the value\n * reflects whatever mutations or swaps the caller has applied since\n * the last access — the same contract the send and receive paths\n * follow internally. */\n get keyring(): MeshKeyring {\n return this.keyringSource();\n }\n\n constructor(options: MeshNetworkAdapterOptions) {\n super();\n this.base = options.base;\n this.keyringSource = options.keyringSource;\n this.encryptionEnabled = options.encryptionEnabled ?? true;\n\n // Forward lifecycle and peer events from the base adapter.\n this.base.on(\"close\", () => this.emit(\"close\"));\n this.base.on(\"peer-candidate\", (payload) => this.emit(\"peer-candidate\", payload));\n this.base.on(\"peer-disconnected\", (payload) => this.emit(\"peer-disconnected\", payload));\n\n // Intercept incoming messages: the base adapter will surface them as\n // 'message' events with crypto-wrapped payloads. We unwrap and re-emit.\n this.base.on(\"message\", (rawMessage) => {\n const unwrapped = this.tryUnwrap(rawMessage);\n if (unwrapped) {\n this.emit(\"message\", unwrapped);\n }\n // Silently drop messages that fail verification or decryption. A\n // production adapter would surface this through a diagnostic channel\n // so the application could prompt the user; the Phase 2 first cut\n // logs through the standard \"drop unknown\" semantics of the network\n // subsystem.\n });\n }\n\n isReady(): boolean {\n return this.base.isReady();\n }\n\n whenReady(): Promise<void> {\n return this.base.whenReady();\n }\n\n connect(peerId: PeerId, peerMetadata?: PeerMetadata): void {\n this.peerId = peerId;\n if (peerMetadata !== undefined) {\n this.peerMetadata = peerMetadata;\n }\n this.base.connect(peerId, peerMetadata);\n }\n\n disconnect(): void {\n this.base.disconnect();\n }\n\n send(message: Message): void {\n const wrapped = this.wrap(message);\n this.base.send(wrapped);\n }\n\n /**\n * Wrap an outgoing Automerge message in an encrypt-then-sign envelope.\n * The wrapped payload is returned as a Message with the original sender\n * and target ids and the crypto blob in the `data` field.\n */\n private wrap(message: Message): Message {\n const keyring = this.keyringSource();\n const serialised = serialiseMessage(message);\n\n let payloadToSign: Uint8Array;\n if (this.encryptionEnabled) {\n const docKey = keyring.documentKeys.get(DEFAULT_MESH_KEY_ID);\n if (!docKey) {\n throw new Error(\n `MeshNetworkAdapter: missing document encryption key under id \"${DEFAULT_MESH_KEY_ID}\". Provision the key in the keyring before sending.`\n );\n }\n const encrypted = sealEncryptedEnvelope(serialised, DEFAULT_MESH_KEY_ID, docKey);\n payloadToSign = encodeEncryptedEnvelope(encrypted);\n } else {\n payloadToSign = serialised;\n }\n\n const signed = signEnvelope(payloadToSign, message.senderId, keyring.identity.secretKey);\n const signedBytes = encodeSignedEnvelope(signed);\n\n // Preserve `documentId` on the outer envelope so the base adapter\n // (MeshWebRTCAdapter) can stamp per-handle wire-level bookkeeping\n // without parsing the encrypted payload. The inner serialised\n // message also carries documentId, which the receiver uses after\n // crypto-unwrap; this outer copy is purely for the sender-side\n // observability path that polly#107 item 7 specifies. The signed\n // envelope still binds the inner copy, so the outer copy cannot\n // forge routing — a peer that mismatches the two is observable as\n // a divergent receive shape, not a routing exploit.\n const outer: Record<string, unknown> = {\n type: message.type,\n senderId: message.senderId,\n targetId: message.targetId,\n data: signedBytes,\n };\n if (\"documentId\" in message && (message as { documentId?: unknown }).documentId !== undefined) {\n outer[\"documentId\"] = (message as { documentId: unknown }).documentId;\n }\n return outer as unknown as Message;\n }\n\n /**\n * Try to unwrap an incoming crypto-wrapped message. Returns the original\n * Message on success, undefined on verification or decryption failure.\n */\n private tryUnwrap(message: Message): Message | undefined {\n if (!message.data) return undefined;\n\n let signed: ReturnType<typeof decodeSignedEnvelope>;\n try {\n signed = decodeSignedEnvelope(message.data);\n } catch {\n return undefined;\n }\n\n // Re-read the keyring on every incoming message. This is what makes a\n // post-construction peer addition take effect — if the caller has\n // mutated the keyring's `knownPeers` map (or swapped the keyring\n // object outright via a file watcher), the new entry is visible here\n // without any restart or explicit notification path. See issue #100.\n const keyring = this.keyringSource();\n\n // Drop messages from peers whose keys have been revoked, even if the\n // public key is still present in knownPeers. The revocation set is the\n // authoritative \"this peer is no longer trusted\" marker.\n if (keyring.revokedPeers.has(signed.senderId)) {\n return undefined;\n }\n\n const senderKey = keyring.knownPeers.get(signed.senderId);\n if (!senderKey) {\n return undefined;\n }\n\n let verifiedPayload: Uint8Array;\n try {\n verifiedPayload = openSignedEnvelope(signed, senderKey);\n } catch {\n return undefined;\n }\n\n if (!this.encryptionEnabled) {\n // Sign-only mode: the verified payload IS the serialised message.\n return deserialiseMessage(verifiedPayload);\n }\n\n // Full encrypt+sign mode: unwrap the encryption envelope.\n let encrypted: ReturnType<typeof decodeEncryptedEnvelope>;\n try {\n encrypted = decodeEncryptedEnvelope(verifiedPayload);\n } catch {\n return undefined;\n }\n\n const docKey = keyring.documentKeys.get(encrypted.documentId);\n if (!docKey) {\n return undefined;\n }\n\n let plaintext: Uint8Array;\n try {\n plaintext = openEncryptedEnvelope(encrypted, docKey);\n } catch {\n return undefined;\n }\n\n return deserialiseMessage(plaintext);\n }\n}\n\n// message serialisation\n\n/**\n * Serialise an Automerge sync message to a binary blob suitable for\n * encryption. The format is a length-prefixed JSON header (carrying the\n * non-binary fields) followed by the raw `data` bytes (which Automerge's\n * sync messages carry as Uint8Array). This avoids round-tripping the\n * binary payload through JSON, which would balloon its size.\n */\nfunction serialiseMessage(message: Message): Uint8Array {\n const headerObj: Record<string, unknown> = {\n type: message.type,\n senderId: message.senderId,\n targetId: message.targetId,\n };\n if (\"documentId\" in message && message.documentId !== undefined) {\n headerObj[\"documentId\"] = message.documentId;\n }\n if (\"count\" in message && message.count !== undefined) {\n headerObj[\"count\"] = message.count;\n }\n if (\"sessionId\" in message && message.sessionId !== undefined) {\n headerObj[\"sessionId\"] = message.sessionId;\n }\n const headerBytes = new TextEncoder().encode(JSON.stringify(headerObj));\n const dataBytes: Uint8Array =\n \"data\" in message && message.data instanceof Uint8Array ? message.data : new Uint8Array(0);\n\n const out = new Uint8Array(4 + headerBytes.length + dataBytes.length);\n const view = new DataView(out.buffer);\n view.setUint32(0, headerBytes.length, false);\n out.set(headerBytes, 4);\n out.set(dataBytes, 4 + headerBytes.length);\n return out;\n}\n\n/**\n * Inverse of {@link serialiseMessage}.\n */\nfunction deserialiseMessage(bytes: Uint8Array): Message {\n if (bytes.length < 4) {\n throw new Error(\"MeshNetworkAdapter: message too short to deserialise.\");\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const headerLen = view.getUint32(0, false);\n if (bytes.length < 4 + headerLen) {\n throw new Error(\"MeshNetworkAdapter: message header truncated.\");\n }\n const header = JSON.parse(new TextDecoder().decode(bytes.subarray(4, 4 + headerLen)));\n const data = bytes.slice(4 + headerLen);\n return { ...header, data } as unknown as Message;\n}\n",
15
15
  "/**\n * signing — Ed25519 signing and verification for Polly's $meshState\n * primitive (Phase 2). Wraps tweetnacl with a small Polly-flavoured API\n * so the rest of the codebase never imports tweetnacl directly.\n *\n * Every operation that flows through a $meshState transport is signed by\n * the originating peer's private key before transmission and verified by\n * every receiving peer against a known public-key set before being applied.\n * This is the Byzantine-tolerance mechanism: a peer whose private key is\n * compromised can be revoked through a further signed operation, after\n * which honest peers reject anything signed by the revoked key.\n *\n * tweetnacl uses the Ed25519 curve. Public keys and signatures are 32 and\n * 64 bytes respectively, which keeps the per-op overhead small enough that\n * signing every Automerge sync message is feasible even on mobile.\n *\n * The shape of the wrapper:\n *\n * - {@link generateSigningKeyPair} produces a new Ed25519 keypair. The\n * private key never leaves the device that generated it; the public\n * key is gossiped through the access set.\n *\n * - {@link sign} produces a 64-byte detached signature over a payload.\n *\n * - {@link verify} checks a payload against a signature and a public\n * key. Returns boolean rather than throwing so call sites can handle\n * verification failure as a normal control-flow case.\n *\n * - {@link signEnvelope} and {@link openEnvelope} package payload + sender\n * id + signature into a single binary envelope, which is what the mesh\n * network adapter actually puts on the wire.\n */\n\nimport nacl from \"tweetnacl\";\n\n/** Length in bytes of an Ed25519 public key. */\nexport const PUBLIC_KEY_BYTES = 32;\n/** Length in bytes of an Ed25519 secret (private) key. */\nexport const SECRET_KEY_BYTES = 64;\n/** Length in bytes of an Ed25519 detached signature. */\nexport const SIGNATURE_BYTES = 64;\n\n/**\n * An Ed25519 keypair. The {@link publicKey} is safe to share with peers;\n * the {@link secretKey} must never leave the device.\n */\nexport interface SigningKeyPair {\n publicKey: Uint8Array;\n secretKey: Uint8Array;\n}\n\n/**\n * A signed envelope. The wire format is the concatenation of the sender id\n * length, the sender id bytes, the signature, and the payload. Callers\n * shouldn't rely on the exact layout — use {@link signEnvelope} and\n * {@link openEnvelope} to round-trip.\n */\nexport interface SignedEnvelope {\n /** Stable sender peer identifier (UTF-8 string). The receiving side uses\n * this to look up the sender's public key in the document's access set. */\n senderId: string;\n /** The original payload bytes, untouched. */\n payload: Uint8Array;\n /** 64-byte Ed25519 signature over the payload. */\n signature: Uint8Array;\n}\n\n/** Errors thrown by the signing subsystem. */\nexport class SigningError extends Error {\n readonly code:\n | \"invalid-secret-key\"\n | \"invalid-public-key\"\n | \"invalid-signature-length\"\n | \"envelope-malformed\";\n\n constructor(message: string, code: SigningError[\"code\"]) {\n super(message);\n this.name = \"SigningError\";\n this.code = code;\n }\n}\n\n/**\n * Generate a fresh Ed25519 keypair. Calls into tweetnacl's CSPRNG.\n */\nexport function generateSigningKeyPair(): SigningKeyPair {\n const pair = nacl.sign.keyPair();\n return {\n publicKey: pair.publicKey,\n secretKey: pair.secretKey,\n };\n}\n\n/**\n * Reconstruct a keypair from an existing 64-byte secret key. Useful for\n * loading keys from persistent storage. Throws if the key is the wrong size.\n */\nexport function signingKeyPairFromSecret(secretKey: Uint8Array): SigningKeyPair {\n if (secretKey.length !== SECRET_KEY_BYTES) {\n throw new SigningError(\n `Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`,\n \"invalid-secret-key\"\n );\n }\n const pair = nacl.sign.keyPair.fromSecretKey(secretKey);\n return {\n publicKey: pair.publicKey,\n secretKey: pair.secretKey,\n };\n}\n\n/**\n * Produce a 64-byte detached signature over the given payload using the\n * supplied secret key.\n */\nexport function sign(payload: Uint8Array, secretKey: Uint8Array): Uint8Array {\n if (secretKey.length !== SECRET_KEY_BYTES) {\n throw new SigningError(\n `Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`,\n \"invalid-secret-key\"\n );\n }\n return nacl.sign.detached(payload, secretKey);\n}\n\n/**\n * Verify a detached signature against a payload and a public key. Returns\n * true if the signature is valid, false otherwise. Wrong-length keys or\n * signatures throw {@link SigningError} so callers can distinguish a bad\n * signature from a misshapen input.\n */\nexport function verify(payload: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean {\n if (publicKey.length !== PUBLIC_KEY_BYTES) {\n throw new SigningError(\n `Ed25519 public key must be ${PUBLIC_KEY_BYTES} bytes, got ${publicKey.length}.`,\n \"invalid-public-key\"\n );\n }\n if (signature.length !== SIGNATURE_BYTES) {\n throw new SigningError(\n `Ed25519 signature must be ${SIGNATURE_BYTES} bytes, got ${signature.length}.`,\n \"invalid-signature-length\"\n );\n }\n return nacl.sign.detached.verify(payload, signature, publicKey);\n}\n\n/**\n * Sign a payload and pack it into a {@link SignedEnvelope} along with the\n * sender id. The mesh network adapter calls this on every outgoing message\n * before handing it to the transport.\n */\nexport function signEnvelope(\n payload: Uint8Array,\n senderId: string,\n secretKey: Uint8Array\n): SignedEnvelope {\n const signature = sign(payload, secretKey);\n return { senderId, payload, signature };\n}\n\n/**\n * Verify a {@link SignedEnvelope} against the sender's known public key.\n * Returns the inner payload on success, throws on failure. The mesh\n * network adapter calls this on every incoming message before forwarding\n * the payload to the underlying Automerge sync subsystem.\n */\nexport function openEnvelope(envelope: SignedEnvelope, publicKey: Uint8Array): Uint8Array {\n const ok = verify(envelope.payload, envelope.signature, publicKey);\n if (!ok) {\n throw new SigningError(\n `Signature verification failed for envelope from ${envelope.senderId}.`,\n \"envelope-malformed\"\n );\n }\n return envelope.payload;\n}\n\n/**\n * Serialise a {@link SignedEnvelope} to a single binary blob suitable for\n * transmission over a network adapter. Wire format:\n *\n * [4 bytes BE: senderId byte length]\n * [N bytes: senderId UTF-8]\n * [64 bytes: signature]\n * [remaining: payload]\n *\n * Callers should not depend on the exact bytes — they should round-trip\n * through {@link encodeSignedEnvelope} / {@link decodeSignedEnvelope}.\n */\nexport function encodeSignedEnvelope(envelope: SignedEnvelope): Uint8Array {\n const senderBytes = new TextEncoder().encode(envelope.senderId);\n const total = 4 + senderBytes.length + SIGNATURE_BYTES + envelope.payload.length;\n const out = new Uint8Array(total);\n const view = new DataView(out.buffer);\n view.setUint32(0, senderBytes.length, false);\n out.set(senderBytes, 4);\n out.set(envelope.signature, 4 + senderBytes.length);\n out.set(envelope.payload, 4 + senderBytes.length + SIGNATURE_BYTES);\n return out;\n}\n\n/**\n * Deserialise a binary envelope produced by {@link encodeSignedEnvelope}.\n * Throws on malformed input.\n */\nexport function decodeSignedEnvelope(bytes: Uint8Array): SignedEnvelope {\n if (bytes.length < 4 + SIGNATURE_BYTES) {\n throw new SigningError(\n `Envelope too short: ${bytes.length} bytes, need at least ${4 + SIGNATURE_BYTES}.`,\n \"envelope-malformed\"\n );\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const senderLen = view.getUint32(0, false);\n if (bytes.length < 4 + senderLen + SIGNATURE_BYTES) {\n throw new SigningError(\n `Envelope truncated: declared sender length ${senderLen}, total ${bytes.length}.`,\n \"envelope-malformed\"\n );\n }\n const senderId = new TextDecoder().decode(bytes.subarray(4, 4 + senderLen));\n const signature = bytes.slice(4 + senderLen, 4 + senderLen + SIGNATURE_BYTES);\n const payload = bytes.slice(4 + senderLen + SIGNATURE_BYTES);\n return { senderId, payload, signature };\n}\n",
16
16
  "/**\n * mesh-signaling-client — browser-side client for Polly's signalingServer\n * Elysia plugin. Connects to the signalling WebSocket, registers a peer\n * id, and relays SDP/ICE messages between local WebRTC connections and\n * remote peers.\n *\n * This module is the companion to {@link signalingServer} from the Elysia\n * plugin family. The server accepts \"join\" and \"signal\" messages; this\n * client produces them. The protocol matches: opening the connection,\n * sending a \"join\" with the local peer id, and then using sendSignal()\n * to forward SDP and ICE messages to specific target peers.\n *\n * Because this client is browser-only in its first incarnation — it\n * assumes the global `WebSocket` is available — it cannot be exercised\n * under bun:test the way the server-side plugin is. The first validation\n * of this code path is either a Playwright harness or a human running\n * the browser-side example that consumes it.\n */\n\n/** A signal message either sent to or received from the signalling server.\n * Matches the wire format produced by the Elysia signalingServer plugin. */\nexport interface SignalingMessage {\n type: \"join\" | \"signal\" | \"error\" | \"peers-present\" | \"peer-joined\" | \"peer-left\";\n peerId?: string;\n peerIds?: string[];\n targetPeerId?: string;\n payload?: unknown;\n reason?: \"unknown-target\" | \"not-joined\" | \"malformed\";\n}\n\n/** A frame whose `type` is outside the built-in {@link SignalingMessage}\n * vocabulary. Consumers who want to layer application protocols on the\n * signalling socket — pairing return tokens, presence pings, anything\n * else that benefits from sharing the existing connection and its\n * reconnect state — receive these through {@link MeshSignalingClientOptions.onCustomFrame}\n * and produce them through {@link MeshSignalingClient.sendCustom}. Polly\n * does not interpret the body; the signalling server routes it per its\n * own conventions. The field `type` is always present; everything else\n * is application-defined. */\nexport interface CustomSignalingFrame {\n type: string;\n [key: string]: unknown;\n}\n\n/** Options for constructing a {@link MeshSignalingClient}. */\nexport interface MeshSignalingClientOptions {\n /** The signalling server URL — unencrypted scheme for local dev, TLS-terminated for production. */\n url: string;\n /** The local peer id that this client will register with on join. */\n peerId: string;\n /** Callback invoked whenever a signal message from another peer arrives.\n * The receiver dispatches to the right PeerConnection based on the\n * `fromPeerId`. */\n onSignal: (fromPeerId: string, payload: unknown) => void;\n /** Optional callback invoked when the server returns an error (for\n * diagnostic UI or reconnection logic). */\n onError?: (reason: string, targetPeerId?: string) => void;\n /** Optional callback for the open and close lifecycle events. */\n onOpen?: () => void;\n onClose?: () => void;\n /** Optional callback invoked once, immediately after the server's\n * response to our `join`, listing every peer already joined at that\n * moment. Empty list when the lobby is otherwise empty. */\n onPeersPresent?: (peerIds: string[]) => void;\n /** Optional callback invoked each time a new peer joins the signalling\n * server after we have already joined. */\n onPeerJoined?: (peerId: string) => void;\n /** Optional callback invoked each time a joined peer's socket closes\n * (including graceful disconnect and abrupt drops detected by the\n * server). Fires at most once per departure. */\n onPeerLeft?: (peerId: string) => void;\n /** Optional callback invoked for any frame whose `type` is outside the\n * built-in {@link SignalingMessage} vocabulary. Consumers use this to\n * layer their own protocol on top of the signalling socket — pairing\n * return tokens, presence pings, anything else that benefits from\n * sharing the existing connection and its reconnect state. A frame\n * that arrives before the join handshake completes or that fails to\n * parse as JSON is dropped silently, as with the built-in types. */\n onCustomFrame?: (frame: CustomSignalingFrame) => void;\n /** WebSocket constructor. Defaults to `globalThis.WebSocket`. Inject a\n * different implementation (e.g. `ws` package's `WebSocket`) when running\n * in an environment without a native WebSocket global, or to use a custom\n * subclass for tests or instrumentation. */\n WebSocket?: typeof WebSocket;\n}\n\n/**\n * Thin wrapper around a WebSocket connection to a Polly signalling server.\n * Handles the join handshake, routes incoming signals to the supplied\n * callback, and exposes a {@link sendSignal} method for outgoing signals.\n *\n * This class is deliberately small. It has no opinion on the signal\n * payload shape (the wire carries it as `unknown`), so it can carry SDP\n * offers, SDP answers, ICE candidates, or any other message the\n * WebRTC adapter wants to exchange with peers.\n */\n/** Base delay (ms) between reconnect attempts. Doubles per attempt up\n * to {@link RECONNECT_MAX_DELAY_MS}. */\nconst RECONNECT_BASE_DELAY_MS = 250;\n/** Ceiling for the exponential backoff so a long outage does not leave\n * the client silent for minutes between probes. */\nconst RECONNECT_MAX_DELAY_MS = 30_000;\n\n/** Parse a raw frame from the socket into a record with a string `type`,\n * or `undefined` if the frame is unparseable or malformed. Extracted so\n * {@link MeshSignalingClient.dispatchFrame} stays below the linter's\n * cognitive-complexity ceiling. */\nfunction parseFrame(raw: unknown): Record<string, unknown> | undefined {\n let parsed: unknown;\n try {\n parsed = typeof raw === \"string\" ? JSON.parse(raw) : raw;\n } catch {\n return undefined;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as unknown as Record<string, unknown>;\n if (typeof record[\"type\"] !== \"string\") {\n return undefined;\n }\n return record;\n}\n\nexport class MeshSignalingClient {\n readonly url: string;\n readonly peerId: string;\n private readonly onSignal: (fromPeerId: string, payload: unknown) => void;\n private readonly onError?: (reason: string, targetPeerId?: string) => void;\n private readonly onOpen?: () => void;\n private readonly onClose?: () => void;\n private readonly onPeersPresent?: (peerIds: string[]) => void;\n private readonly onPeerJoined?: (peerId: string) => void;\n private readonly onPeerLeft?: (peerId: string) => void;\n private readonly onCustomFrame?: (frame: CustomSignalingFrame) => void;\n private socket: WebSocket | undefined;\n private joined = false;\n private stopping = false;\n private reconnectTimer: ReturnType<typeof setTimeout> | undefined;\n private readonly WebSocketCtor: typeof WebSocket;\n\n constructor(options: MeshSignalingClientOptions) {\n this.url = options.url;\n this.peerId = options.peerId;\n this.onSignal = options.onSignal;\n if (options.onError !== undefined) this.onError = options.onError;\n if (options.onOpen !== undefined) this.onOpen = options.onOpen;\n if (options.onClose !== undefined) this.onClose = options.onClose;\n if (options.onPeersPresent !== undefined) this.onPeersPresent = options.onPeersPresent;\n if (options.onPeerJoined !== undefined) this.onPeerJoined = options.onPeerJoined;\n if (options.onPeerLeft !== undefined) this.onPeerLeft = options.onPeerLeft;\n if (options.onCustomFrame !== undefined) this.onCustomFrame = options.onCustomFrame;\n const WS = options.WebSocket ?? globalThis.WebSocket;\n if (typeof WS !== \"function\") {\n throw new Error(\n \"MeshSignalingClient: no WebSocket implementation found. Pass one via options.WebSocket, or run in an environment where `globalThis.WebSocket` exists (Node 21+, Bun, browsers).\"\n );\n }\n this.WebSocketCtor = WS;\n }\n\n /**\n * Open the WebSocket and send the join message. Resolves once the\n * connection is open; callers should not send signals before this\n * promise resolves.\n */\n async connect(): Promise<void> {\n this.stopping = false;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = undefined;\n }\n return new Promise((resolve, reject) => {\n const ws = new this.WebSocketCtor(this.url);\n this.socket = ws;\n let settled = false;\n\n ws.addEventListener(\"open\", () => {\n // Send the join message as the first frame. The server registers\n // the peer id and uses it as the authenticated sender for all\n // subsequent signals on this connection.\n ws.send(JSON.stringify({ type: \"join\", peerId: this.peerId } satisfies SignalingMessage));\n this.joined = true;\n this.onOpen?.();\n if (!settled) {\n settled = true;\n resolve();\n }\n });\n\n ws.addEventListener(\"message\", (event) => {\n this.dispatchFrame(event.data);\n });\n\n ws.addEventListener(\"error\", (err) => {\n // Only the initial connect rejects here. Post-open errors route\n // through the close handler's reconnect path.\n if (!settled) {\n settled = true;\n reject(err);\n }\n });\n\n ws.addEventListener(\"close\", () => {\n const wasOpen = this.joined;\n this.joined = false;\n this.onClose?.();\n // If the caller asked to stop, respect it. Otherwise a close on\n // an established connection — or a close that preempted `open`\n // — kicks off the reconnect loop.\n if (!this.stopping && wasOpen) {\n this.scheduleReconnect(0);\n }\n });\n });\n }\n\n /** Schedule the next reconnect attempt with exponential backoff. */\n private scheduleReconnect(attempt: number): void {\n if (this.stopping) return;\n const delay = Math.min(RECONNECT_MAX_DELAY_MS, RECONNECT_BASE_DELAY_MS * 2 ** attempt);\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = undefined;\n if (this.stopping) return;\n void this.connect().catch(() => {\n this.scheduleReconnect(attempt + 1);\n });\n }, delay);\n }\n\n /**\n * Parse and route an incoming frame. Extracted from the open/message\n * closure in {@link connect} so the discriminated-union switch stays\n * below the linter's cognitive-complexity ceiling.\n */\n private dispatchFrame(raw: unknown): void {\n const record = parseFrame(raw);\n if (record === undefined) {\n return;\n }\n const handler = this.builtInHandler(record[\"type\"]);\n if (handler !== undefined) {\n handler(record);\n return;\n }\n // Unknown types route to the custom-frame handler, which consumers\n // use to layer application protocols on the shared socket. Without\n // a handler the frame is silently dropped, preserving the old\n // behaviour byte-for-byte.\n this.onCustomFrame?.(record as unknown as CustomSignalingFrame);\n }\n\n private builtInHandler(type: unknown): ((record: Record<string, unknown>) => void) | undefined {\n if (type === \"signal\") {\n return (record) => {\n if (typeof record[\"peerId\"] === \"string\") {\n this.onSignal(record[\"peerId\"], record[\"payload\"]);\n }\n };\n }\n if (type === \"peers-present\") {\n return (record) => {\n if (Array.isArray(record[\"peerIds\"])) {\n this.onPeersPresent?.(record[\"peerIds\"] as unknown as string[]);\n }\n };\n }\n if (type === \"peer-joined\") {\n return (record) => {\n if (typeof record[\"peerId\"] === \"string\") {\n this.onPeerJoined?.(record[\"peerId\"]);\n }\n };\n }\n if (type === \"peer-left\") {\n return (record) => {\n if (typeof record[\"peerId\"] === \"string\") {\n this.onPeerLeft?.(record[\"peerId\"]);\n }\n };\n }\n if (type === \"error\") {\n return (record) => {\n if (typeof record[\"reason\"] !== \"string\") {\n return;\n }\n const targetPeerId =\n typeof record[\"targetPeerId\"] === \"string\" ? record[\"targetPeerId\"] : undefined;\n this.onError?.(record[\"reason\"], targetPeerId);\n };\n }\n return undefined;\n }\n\n /**\n * Send a signal to another peer via the signalling server. The server\n * validates the sender (replacing the claimed peerId with the\n * authenticated join id) and routes to the target. Returns true if\n * the message was sent, false if the connection is not open.\n */\n sendSignal(targetPeerId: string, payload: unknown): boolean {\n if (!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || !this.joined) {\n return false;\n }\n const msg: SignalingMessage = {\n type: \"signal\",\n peerId: this.peerId,\n targetPeerId,\n payload,\n };\n this.socket.send(JSON.stringify(msg));\n return true;\n }\n\n /**\n * Send a custom frame over the signalling socket. The frame is serialised\n * as `{ type, ...payload }`. The server must be configured to route this\n * frame type (polly does not interpret it). Returns true if the message\n * was sent, false if the connection is not open.\n *\n * Intended for application-level protocols that want to share the\n * existing signalling connection — for example, a pairing flow that\n * delivers a reciprocal token from the scanner back to the issuer.\n */\n sendCustom(type: string, payload: Record<string, unknown> = {}): boolean {\n if (!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || !this.joined) {\n return false;\n }\n this.socket.send(JSON.stringify({ ...payload, type }));\n return true;\n }\n\n /**\n * Close the underlying WebSocket connection. The server's close handler\n * will evict this peer from its routing table. Also cancels any\n * pending reconnect attempt so the client stays closed until the\n * caller reopens it with another {@link connect} call.\n */\n close(): void {\n this.stopping = true;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = undefined;\n }\n this.socket?.close();\n this.socket = undefined;\n this.joined = false;\n }\n\n /** True if the signalling connection is open and joined. */\n get isConnected(): boolean {\n return this.joined && this.socket?.readyState === this.WebSocketCtor.OPEN;\n }\n}\n",
17
- "/**\n * mesh-state — Phase 2 wrappers exposing $meshState, $meshText, $meshCounter,\n * and $meshList. These are the application-facing constructors for the\n * strongest resilience tier in RFC-041: every device is a full Automerge\n * replica, the server is *not on the data path at all*, and the application\n * functions with zero server uptime once direct peer connections are\n * established.\n *\n * Each primitive wraps the corresponding Phase 0 base ($crdtState, $crdtText,\n * $crdtCounter, $crdtList) with three additions:\n *\n * 1. The `primitive` label is hard-coded to \"meshState\" so the\n * primitive-registry collision detection knows which family the key\n * belongs to.\n *\n * 2. A handle factory that resolves the application's logical key to an\n * Automerge DocumentId by hashing the key into a deterministic,\n * content-addressable id. Every Repo backed by the same storage lands\n * on the same document without needing any extra state, and two devices\n * that have never met converge on the same id for the same key — which\n * also helps first-sync after pairing. (Prior to this change the factory\n * held an in-memory per-Repo `Map<string, DocumentId>`, which meant that\n * a lone-device reload — a very common onboarding state — produced a\n * fresh DocumentId for the same logical key, orphaned the document the\n * storage adapter still held on disk, and silently lost the user's data.)\n *\n * 3. Signing and encryption are mandatory, not optional. Where $peerState\n * accepts encrypt/sign as opt-in flags (currently throwing in Phase 1),\n * $meshState requires every operation to be signed by the originating\n * peer's key and encrypted under the document's symmetric key. The\n * mechanism lives in the wrapping MeshNetworkAdapter that the Repo\n * uses for transport.\n *\n * The Repo itself is supplied by the application via {@link configureMeshState}\n * or per-call via the `repo` option. In Phase 2 the production transport will\n * be a WebRTC mesh adapter wrapping signing+encryption around an in-process\n * RTCDataChannel; for tests and for the early Phase 2 cut, an in-memory\n * loopback adapter pair satisfies the same contract.\n */\n\nimport {\n Automerge,\n type BinaryDocumentId,\n type DocHandle,\n type DocumentId,\n interpretAsDocumentId,\n type Repo,\n} from \"@automerge/automerge-repo/slim\";\nimport nacl from \"tweetnacl\";\nimport type { Access } from \"./access\";\nimport {\n $crdtCounter,\n $crdtList,\n $crdtText,\n type CounterDoc,\n type ListDoc,\n type SpecialisedPrimitive,\n type TextDoc,\n} from \"./crdt-specialised\";\nimport { $crdtState, type CrdtPrimitive } from \"./crdt-state\";\nimport type { Migrations, VersionedDoc } from \"./schema-version\";\n\n/** Common option shape across all four $mesh* primitives. */\nexport interface MeshStateOptions {\n /** Override the default Repo for this primitive. The Repo must be\n * configured with the mesh transport (signing and encryption at the\n * network layer). */\n repo?: Repo;\n /** Schema version target for the application. Migrations run on load. */\n schemaVersion?: number;\n /** Migration table keyed by target version. Required if schemaVersion is set. */\n migrations?: Migrations;\n /** Declarative read/write access. The mesh transport compiles this into\n * a public-key set used by the signing layer to verify incoming ops. */\n access?: Access;\n}\n\nlet defaultRepo: Repo | undefined;\n\n/**\n * Set the default Repo that the $mesh* primitives use when no `repo` option\n * is supplied. Production code typically calls this once at application\n * startup with a Repo configured for the mesh transport. Tests call it\n * before each scenario with an in-memory or loopback Repo.\n */\nexport function configureMeshState(repo: Repo): void {\n defaultRepo = repo;\n}\n\n/**\n * Reset the mesh-state subsystem to its initial unconfigured state.\n * Intended for tests; production code should not call this.\n */\nexport function resetMeshState(): void {\n defaultRepo = undefined;\n}\n\nfunction resolveRepo(option: Repo | undefined): Repo {\n const repo = option ?? defaultRepo;\n if (!repo) {\n throw new Error(\n \"Polly $meshState: no Repo configured. Call configureMeshState(repo) at startup or pass { repo } in the primitive options.\"\n );\n }\n return repo;\n}\n\n/**\n * Domain-separated hash of an application key into a 16-byte\n * {@link BinaryDocumentId}. SHA-512 via tweetnacl (already a dep for signing);\n * the first 16 bytes give a DocumentId with uniform distribution across the\n * Automerge id space. The domain prefix pins the derivation to $meshState so\n * that the same logical key used in a different Polly subsystem would\n * produce a different id.\n */\nconst DOC_ID_DOMAIN = \"polly/meshState/v1\";\nconst keyEncoder = new TextEncoder();\n\nfunction deriveDocumentId(key: string): DocumentId {\n const digest = nacl.hash(keyEncoder.encode(`${DOC_ID_DOMAIN}:${key}`));\n const bytes = digest.slice(0, 16);\n return interpretAsDocumentId(bytes as unknown as BinaryDocumentId);\n}\n\n/**\n * Build a getHandle factory that resolves a logical key to a DocHandle on\n * the supplied Repo via a deterministic DocumentId. On the first call during\n * a process lifetime — whether the device has never written this key or has\n * written it before a prior reload — the factory short-circuits around\n * {@link Repo.find}'s network-request timeout: it peeks directly at the\n * Repo's storage subsystem, hydrates from storage if the bytes are there,\n * and otherwise seeds a fresh document at the deterministic id. Subsequent\n * calls in the same process return the cached handle.\n */\nfunction buildHandleFactory<D>(\n repo: Repo,\n key: string,\n initialDoc: D\n): () => Promise<DocHandle<D>> {\n const documentId = deriveDocumentId(key);\n return async () => {\n const cached = repo.handles[documentId];\n if (cached) {\n await cached.whenReady([\"ready\", \"unavailable\"]);\n if (cached.state === \"ready\") {\n return cached as unknown as DocHandle<D>;\n }\n }\n const stored = await repo.storageSubsystem?.loadDoc<D>(documentId);\n if (stored) {\n return repo.find<D>(documentId, { allowableStates: [\"ready\"] });\n }\n const seeded = Automerge.save(Automerge.from(initialDoc as unknown as Record<string, unknown>));\n const handle = repo.import<D>(seeded, { docId: documentId });\n handle.doneLoading();\n return handle;\n };\n}\n\n// $meshState\n\n/**\n * Create a peer-replicated state primitive backed by Automerge with a mesh\n * transport. Every device holds a full replica; no central server holds a\n * replica. Operations flow peer-to-peer through signed and encrypted\n * messages on the underlying transport.\n *\n * @example\n * ```ts\n * const journal = $meshState<Journal>(\"journal\", { entries: [] });\n * await journal.loaded;\n * journal.value = { entries: [\"my private thoughts\"] };\n * ```\n */\nexport function $meshState<T extends VersionedDoc>(\n key: string,\n initialValue: T,\n options: MeshStateOptions = {}\n): CrdtPrimitive<T> {\n const repo = resolveRepo(options.repo);\n return $crdtState<T>({\n key,\n primitive: \"meshState\",\n initialValue,\n getHandle: buildHandleFactory<T>(repo, key, initialValue),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshText\n\n/**\n * Create a peer-replicated text primitive backed by a mesh transport.\n * Concurrent character-level edits from peers merge cleanly via Automerge's\n * updateText splicing, and every operation is signed and encrypted before\n * leaving the originating peer.\n */\nexport function $meshText(\n key: string,\n initialValue: string,\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<string> {\n const repo = resolveRepo(options.repo);\n return $crdtText(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<TextDoc>(repo, key, { text: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshCounter\n\n/**\n * Create a peer-replicated counter primitive backed by a mesh transport.\n * Concurrent increments commute, and every operation is signed and\n * encrypted before leaving the originating peer.\n */\nexport function $meshCounter(\n key: string,\n initialValue: number,\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<number> {\n const repo = resolveRepo(options.repo);\n return $crdtCounter(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<CounterDoc>(repo, key, {}),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshList\n\n/**\n * Create a peer-replicated list primitive backed by a mesh transport.\n * Phase 0 naive replacement applies to writes for now; Phase 1.1 will\n * refine with structural diff-to-splice for concurrent insert/remove\n * preservation.\n */\nexport function $meshList<T>(\n key: string,\n initialValue: T[],\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<T[]> {\n const repo = resolveRepo(options.repo);\n return $crdtList<T>(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<ListDoc<T>>(repo, key, { items: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n",
17
+ "/**\n * mesh-state — Phase 2 wrappers exposing $meshState, $meshText, $meshCounter,\n * and $meshList. These are the application-facing constructors for the\n * strongest resilience tier in RFC-041: every device is a full Automerge\n * replica, the server is *not on the data path at all*, and the application\n * functions with zero server uptime once direct peer connections are\n * established.\n *\n * Each primitive wraps the corresponding Phase 0 base ($crdtState, $crdtText,\n * $crdtCounter, $crdtList) with three additions:\n *\n * 1. The `primitive` label is hard-coded to \"meshState\" so the\n * primitive-registry collision detection knows which family the key\n * belongs to.\n *\n * 2. A handle factory that resolves the application's logical key to an\n * Automerge DocumentId by hashing the key into a deterministic,\n * content-addressable id. Every Repo backed by the same storage lands\n * on the same document without needing any extra state, and two devices\n * that have never met converge on the same id for the same key — which\n * also helps first-sync after pairing. (Prior to this change the factory\n * held an in-memory per-Repo `Map<string, DocumentId>`, which meant that\n * a lone-device reload — a very common onboarding state — produced a\n * fresh DocumentId for the same logical key, orphaned the document the\n * storage adapter still held on disk, and silently lost the user's data.)\n *\n * 3. Signing and encryption are mandatory, not optional. Where $peerState\n * accepts encrypt/sign as opt-in flags (currently throwing in Phase 1),\n * $meshState requires every operation to be signed by the originating\n * peer's key and encrypted under the document's symmetric key. The\n * mechanism lives in the wrapping MeshNetworkAdapter that the Repo\n * uses for transport.\n *\n * The Repo itself is supplied by the application via {@link configureMeshState}\n * or per-call via the `repo` option. In Phase 2 the production transport will\n * be a WebRTC mesh adapter wrapping signing+encryption around an in-process\n * RTCDataChannel; for tests and for the early Phase 2 cut, an in-memory\n * loopback adapter pair satisfies the same contract.\n */\n\nimport {\n Automerge,\n type BinaryDocumentId,\n type DocHandle,\n type DocumentId,\n interpretAsDocumentId,\n type Repo,\n} from \"@automerge/automerge-repo/slim\";\nimport nacl from \"tweetnacl\";\nimport type { Access } from \"./access\";\nimport {\n $crdtCounter,\n $crdtList,\n $crdtText,\n type CounterDoc,\n type ListDoc,\n type SpecialisedPrimitive,\n type TextDoc,\n} from \"./crdt-specialised\";\nimport { $crdtState, type CrdtPrimitive } from \"./crdt-state\";\nimport type { Migrations, VersionedDoc } from \"./schema-version\";\n\n/** Common option shape across all four $mesh* primitives. */\nexport interface MeshStateOptions {\n /** Override the default Repo for this primitive. The Repo must be\n * configured with the mesh transport (signing and encryption at the\n * network layer). */\n repo?: Repo;\n /** Schema version target for the application. Migrations run on load. */\n schemaVersion?: number;\n /** Migration table keyed by target version. Required if schemaVersion is set. */\n migrations?: Migrations;\n /** Declarative read/write access. The mesh transport compiles this into\n * a public-key set used by the signing layer to verify incoming ops. */\n access?: Access;\n}\n\nlet defaultRepo: Repo | undefined;\n\n/** Per-module-instance identifier stamped at import time. Two distinct\n * module instances (e.g. duplicated under a bundler that hoists\n * differently for the consumer's app code and `@fairfox/polly`'s own\n * imports) produce two different ids — and therefore two different\n * `defaultRepo` globals.\n *\n * The polly#107 fingerprint reading is exactly that: `configureMeshState`\n * runs on one module instance (the one `createMeshClient` imports);\n * the consumer's `$meshState(key, initial)` calls run on a different\n * instance, whose `defaultRepo` was never set. `resolveRepo` either\n * throws (caught silently by consumer wrappers) or returns the\n * unconfigured fallback — either way, the handle that should land\n * in the mesh `Repo` lands somewhere else (or nowhere), Automerge's\n * NetworkSubsystem never sees it, and inbound sync from the daemon\n * has nowhere to go.\n *\n * Exported so consumers can compare the id seen at the `$meshState`\n * call site against the id seen at the `configureMeshState` call\n * site. A mismatch IS the bundle-duplication bug; a match rules it\n * out. The id is also surfaced via {@link getMeshStateModuleId} on\n * every `MeshClient.getPeerStateSnapshot()` so a single one-line\n * read from the failing tab tells the operator which module\n * instance the snapshot is rendered from.\n *\n * Polly issue #107 H5 (mesh-state module duplication). */\nexport const MESH_STATE_MODULE_ID: string = `mesh-state-${\n typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\"\n ? crypto.randomUUID()\n : Math.random().toString(36).slice(2) + Date.now().toString(36)\n}`;\n\n/** Returns the per-module-instance id stamped at import time. See\n * {@link MESH_STATE_MODULE_ID}. */\nexport function getMeshStateModuleId(): string {\n return MESH_STATE_MODULE_ID;\n}\n\n/** Last id passed to {@link configureMeshState}; the Repo's\n * `peerId` is captured at configuration time so a snapshot read can\n * answer \"was this module instance ever wired to a mesh client at\n * all?\". `undefined` means `$meshState` is reachable but no\n * `createMeshClient` call against THIS module instance ever\n * succeeded — the polly#107 H5 fingerprint. */\nlet lastConfiguredRepoPeerId: string | undefined;\n\n/** Returns the `peerId` of the most recent Repo wired through\n * {@link configureMeshState} against this module instance. Surfaced\n * via the mesh client snapshot so a consumer can answer \"did\n * configureMeshState run on the same module instance the wrappers\n * are using\" in one read. */\nexport function getLastConfiguredRepoPeerId(): string | undefined {\n return lastConfiguredRepoPeerId;\n}\n\n/**\n * Set the default Repo that the $mesh* primitives use when no `repo` option\n * is supplied. Production code typically calls this once at application\n * startup with a Repo configured for the mesh transport. Tests call it\n * before each scenario with an in-memory or loopback Repo.\n */\nexport function configureMeshState(repo: Repo): void {\n defaultRepo = repo;\n lastConfiguredRepoPeerId = repo.peerId as unknown as string | undefined;\n}\n\n/**\n * Reset the mesh-state subsystem to its initial unconfigured state.\n * Intended for tests; production code should not call this.\n */\nexport function resetMeshState(): void {\n defaultRepo = undefined;\n lastConfiguredRepoPeerId = undefined;\n}\n\n/** Returns whether this module instance's `defaultRepo` was ever\n * set via {@link configureMeshState}. Distinct from \"was set and\n * then reset\" — `resetMeshState` clears it. The polly#107 H5\n * fingerprint is `false` here on the module instance the consumer's\n * `$meshState` calls resolve from. */\nexport function isMeshStateConfigured(): boolean {\n return defaultRepo !== undefined;\n}\n\n/** Set to `true` once any `$meshState`-family wrapper has been\n * called against this module instance. Surfaced via\n * {@link wasMeshStateResolved} so a snapshot can answer \"did any\n * wrapper code ever reach THIS module\" — the polly#107 H5\n * fingerprint pair (`configured: false` AND `wasResolved: true`)\n * confirms the consumer's wrappers reach a different module instance\n * than `createMeshClient` configured. */\nlet meshStateEverResolved = false;\n\n/** Returns `true` once any `$meshState`-family wrapper has been\n * called against this module instance. See\n * {@link meshStateEverResolved}. */\nexport function wasMeshStateResolved(): boolean {\n return meshStateEverResolved;\n}\n\nfunction resolveRepo(option: Repo | undefined): Repo {\n meshStateEverResolved = true;\n const repo = option ?? defaultRepo;\n if (!repo) {\n // Leave a breadcrumb on the console for the polly#107 H5\n // fingerprint even if the consumer's wrappers catch the throw.\n // The id pinpoints WHICH module instance landed here so the\n // operator can compare against the one `createMeshClient`\n // configured.\n if (typeof console !== \"undefined\" && typeof console.warn === \"function\") {\n console.warn(\n `[polly#107 H5] $meshState resolved against unconfigured module instance ${MESH_STATE_MODULE_ID}. If createMeshClient was called elsewhere, the consumer's wrappers and the mesh client are reaching different module instances — see polly#107.`\n );\n }\n throw new Error(\n `Polly $meshState: no Repo configured (module instance ${MESH_STATE_MODULE_ID}). Call configureMeshState(repo) at startup or pass { repo } in the primitive options. If you have called configureMeshState elsewhere, the most likely cause is that the call resolved to a different module instance than this one — see polly#107.`\n );\n }\n return repo;\n}\n\n/**\n * Domain-separated hash of an application key into a 16-byte\n * {@link BinaryDocumentId}. SHA-512 via tweetnacl (already a dep for signing);\n * the first 16 bytes give a DocumentId with uniform distribution across the\n * Automerge id space. The domain prefix pins the derivation to $meshState so\n * that the same logical key used in a different Polly subsystem would\n * produce a different id.\n */\nconst DOC_ID_DOMAIN = \"polly/meshState/v1\";\nconst keyEncoder = new TextEncoder();\n\nfunction deriveDocumentId(key: string): DocumentId {\n const digest = nacl.hash(keyEncoder.encode(`${DOC_ID_DOMAIN}:${key}`));\n const bytes = digest.slice(0, 16);\n return interpretAsDocumentId(bytes as unknown as BinaryDocumentId);\n}\n\n/**\n * Build a getHandle factory that resolves a logical key to a DocHandle on\n * the supplied Repo via a deterministic DocumentId. On the first call during\n * a process lifetime — whether the device has never written this key or has\n * written it before a prior reload — the factory short-circuits around\n * {@link Repo.find}'s network-request timeout: it peeks directly at the\n * Repo's storage subsystem, hydrates from storage if the bytes are there,\n * and otherwise seeds a fresh document at the deterministic id. Subsequent\n * calls in the same process return the cached handle.\n */\nfunction buildHandleFactory<D>(\n repo: Repo,\n key: string,\n initialDoc: D\n): () => Promise<DocHandle<D>> {\n const documentId = deriveDocumentId(key);\n return async () => {\n const cached = repo.handles[documentId];\n if (cached) {\n await cached.whenReady([\"ready\", \"unavailable\"]);\n if (cached.state === \"ready\") {\n return cached as unknown as DocHandle<D>;\n }\n }\n const stored = await repo.storageSubsystem?.loadDoc<D>(documentId);\n if (stored) {\n return repo.find<D>(documentId, { allowableStates: [\"ready\"] });\n }\n const seeded = Automerge.save(Automerge.from(initialDoc as unknown as Record<string, unknown>));\n const handle = repo.import<D>(seeded, { docId: documentId });\n handle.doneLoading();\n return handle;\n };\n}\n\n// $meshState\n\n/**\n * Create a peer-replicated state primitive backed by Automerge with a mesh\n * transport. Every device holds a full replica; no central server holds a\n * replica. Operations flow peer-to-peer through signed and encrypted\n * messages on the underlying transport.\n *\n * @example\n * ```ts\n * const journal = $meshState<Journal>(\"journal\", { entries: [] });\n * await journal.loaded;\n * journal.value = { entries: [\"my private thoughts\"] };\n * ```\n */\nexport function $meshState<T extends VersionedDoc>(\n key: string,\n initialValue: T,\n options: MeshStateOptions = {}\n): CrdtPrimitive<T> {\n const repo = resolveRepo(options.repo);\n return $crdtState<T>({\n key,\n primitive: \"meshState\",\n initialValue,\n getHandle: buildHandleFactory<T>(repo, key, initialValue),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshText\n\n/**\n * Create a peer-replicated text primitive backed by a mesh transport.\n * Concurrent character-level edits from peers merge cleanly via Automerge's\n * updateText splicing, and every operation is signed and encrypted before\n * leaving the originating peer.\n */\nexport function $meshText(\n key: string,\n initialValue: string,\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<string> {\n const repo = resolveRepo(options.repo);\n return $crdtText(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<TextDoc>(repo, key, { text: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshCounter\n\n/**\n * Create a peer-replicated counter primitive backed by a mesh transport.\n * Concurrent increments commute, and every operation is signed and\n * encrypted before leaving the originating peer.\n */\nexport function $meshCounter(\n key: string,\n initialValue: number,\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<number> {\n const repo = resolveRepo(options.repo);\n return $crdtCounter(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<CounterDoc>(repo, key, {}),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $meshList\n\n/**\n * Create a peer-replicated list primitive backed by a mesh transport.\n * Phase 0 naive replacement applies to writes for now; Phase 1.1 will\n * refine with structural diff-to-splice for concurrent insert/remove\n * preservation.\n */\nexport function $meshList<T>(\n key: string,\n initialValue: T[],\n options: MeshStateOptions = {}\n): SpecialisedPrimitive<T[]> {\n const repo = resolveRepo(options.repo);\n return $crdtList<T>(key, initialValue, {\n primitive: \"meshState\",\n getHandle: buildHandleFactory<ListDoc<T>>(repo, key, { items: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n",
18
18
  "/**\n * crdt-specialised — text, counter, and list variants for Polly's peer-first\n * state primitives.\n *\n * Where the base $crdtState binds a signal to a whole Automerge document with\n * naive top-level structural assignment, the specialised variants each own a\n * single field inside their document and use type-specific Automerge\n * operations to mutate it. This is the difference between \"your write\n * survives a concurrent edit\" and \"your write clobbers the other peer's\n * edit,\" and it matters most for text editing where every keystroke from a\n * concurrent peer would otherwise be lost.\n *\n * - **$crdtText** stores its value in `doc.text` and writes via\n * `Automerge.updateText`, which computes the minimal sequence of character\n * splices between the previous and new strings and records each one as a\n * CRDT operation. Concurrent text edits merge.\n *\n * - **$crdtCounter** stores its value in `doc.count` as an `Automerge.Counter`\n * instance and writes via `counter.increment(delta)`. Increments commute\n * across peers, so two clients each adding 1 to a counter at 5 produce a\n * counter at 7 after merging — last-write-wins semantics on a plain number\n * would lose one of the increments.\n *\n * - **$crdtList** stores its value in `doc.items` and, for the Phase 0 cut,\n * uses naive whole-array replacement on every write. This is correct for\n * single-writer scenarios and good enough to exercise the rest of the\n * pipeline. Phase 1 will replace the write path with proper diff-to-splice\n * logic so that concurrent inserts and removes preserve list ordering.\n *\n * All three variants share a single internal factory that handles the\n * primitive-registry guard, migration-registry guard, schema-version\n * migration, hydration promise, two-way binding with an `updating` flag,\n * and the {@link MigratableState} interface. Variants differ only in the\n * `extractValue` and `applyWrite` hooks they pass.\n */\n\nimport { Counter, type DocHandle, updateText } from \"@automerge/automerge-repo/slim\";\nimport { effect, signal } from \"@preact/signals\";\nimport type { Access } from \"./access\";\nimport { type MigratableState, MigrationError, migrationRegistry } from \"./migrate-primitive\";\nimport { type PrimitiveKind, primitiveRegistry } from \"./primitive-registry\";\nimport { type Migrations, runMigrations, setDocVersion, type VersionedDoc } from \"./schema-version\";\n\n/**\n * Public interface for a specialised primitive. The signal value type V is\n * not the same as the underlying Automerge document — for example, $crdtText\n * exposes a string signal whose value lives at `doc.text` inside the\n * document. Implements {@link MigratableState} so the cross-primitive\n * migration helper can consume it directly.\n */\nexport interface SpecialisedPrimitive<V> extends MigratableState<V> {\n readonly key: string;\n readonly primitive: PrimitiveKind;\n value: V;\n readonly loaded: Promise<void>;\n readonly handle: DocHandle<unknown> | undefined;\n}\n\n/** Internal config shape consumed by {@link createSpecialisedPrimitive}. */\ninterface SpecialisedConfig<V, D extends VersionedDoc> {\n key: string;\n primitive: PrimitiveKind;\n initialValue: V;\n getHandle: () => Promise<DocHandle<D>>;\n /** Read the typed signal value out of the Automerge document. Called once\n * on hydration and again on every remote change. */\n extractValue: (doc: D) => V;\n /** Apply a typed signal value to the Automerge document inside the\n * `handle.change` block. Called every time the local signal is reassigned. */\n applyWrite: (doc: D, value: V) => void;\n schemaVersion?: number;\n migrations?: Migrations;\n access?: Access;\n callSite?: string;\n}\n\n/**\n * Shared factory. Identical guard, hydration, and binding wiring across all\n * three specialised variants; the variants differ only in the extract and\n * apply hooks they supply.\n */\nfunction createSpecialisedPrimitive<V, D extends VersionedDoc>(\n config: SpecialisedConfig<V, D>\n): SpecialisedPrimitive<V> {\n if (migrationRegistry.isMarked(config.key, config.primitive)) {\n throw new MigrationError(\n `Cannot construct $${config.primitive}(\"${config.key}\"): this key has been marked as migrated. Migrations are one-way; use the destination primitive instead.`,\n \"already-migrated\",\n config.key,\n config.primitive\n );\n }\n primitiveRegistry.register(config.key, config.primitive, config.callSite);\n\n const inner = signal<V>(config.initialValue);\n let updating = false;\n let currentHandle: DocHandle<D> | undefined;\n\n const loaded = (async () => {\n const handle = await config.getHandle();\n await handle.whenReady();\n currentHandle = handle;\n\n if (config.schemaVersion !== undefined) {\n const targetVersion = config.schemaVersion;\n const migrations = config.migrations ?? {};\n handle.change((doc) => {\n runMigrations(doc as unknown as Record<string, unknown>, targetVersion, migrations);\n setDocVersion(doc as unknown as Record<string, unknown>, targetVersion);\n });\n }\n\n updating = true;\n try {\n inner.value = config.extractValue(handle.doc());\n } finally {\n updating = false;\n }\n\n handle.on(\"change\", (payload) => {\n if (updating) return;\n updating = true;\n try {\n inner.value = config.extractValue(payload.doc);\n } finally {\n updating = false;\n }\n });\n\n effect(() => {\n const value = inner.value;\n if (updating) return;\n if (!currentHandle) return;\n updating = true;\n try {\n currentHandle.change((doc) => {\n config.applyWrite(doc, value);\n });\n } finally {\n updating = false;\n }\n });\n })();\n\n return {\n key: config.key,\n primitive: config.primitive,\n get value() {\n return inner.value;\n },\n set value(next: V) {\n inner.value = next;\n },\n loaded,\n get handle() {\n return currentHandle as unknown as DocHandle<unknown> | undefined;\n },\n };\n}\n\n// $crdtText\n\n/** The Automerge document shape backing a $crdtText primitive. */\nexport type TextDoc = VersionedDoc & { text?: string };\n\n/** Options for {@link $crdtText}. */\nexport interface CrdtTextOptions {\n /** Primitive kind label. Defaults to \"peerState\"; Phase 2's $meshState\n * wrapper passes \"meshState\" instead. */\n primitive?: PrimitiveKind;\n /** Async factory that returns a ready DocHandle for the text document. */\n getHandle: () => Promise<DocHandle<TextDoc>>;\n schemaVersion?: number;\n migrations?: Migrations;\n access?: Access;\n callSite?: string;\n}\n\n/**\n * Create a CRDT-backed text primitive. The signal exposes a plain string;\n * writes are diffed into character-level splices via `Automerge.updateText`\n * so that concurrent edits from peers merge cleanly rather than clobbering\n * each other.\n */\nexport function $crdtText(\n key: string,\n initialValue: string,\n options: CrdtTextOptions\n): SpecialisedPrimitive<string> {\n return createSpecialisedPrimitive<string, TextDoc>({\n key,\n primitive: options.primitive ?? \"peerState\",\n initialValue,\n getHandle: options.getHandle,\n extractValue: (doc) => doc.text ?? \"\",\n applyWrite: (doc, value) => {\n if (doc.text === undefined) {\n // First write — seed the field. Subsequent writes will use updateText.\n (doc as unknown as TextDoc).text = value;\n } else {\n updateText(doc, [\"text\"], value);\n }\n },\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n callSite: options.callSite,\n });\n}\n\n// $crdtCounter\n\n/** The Automerge document shape backing a $crdtCounter primitive. */\nexport type CounterDoc = VersionedDoc & { count?: Counter };\n\n/** Options for {@link $crdtCounter}. */\nexport interface CrdtCounterOptions {\n primitive?: PrimitiveKind;\n getHandle: () => Promise<DocHandle<CounterDoc>>;\n schemaVersion?: number;\n migrations?: Migrations;\n access?: Access;\n callSite?: string;\n}\n\n/**\n * Create a CRDT-backed counter primitive. The signal exposes a plain number;\n * writes compute the delta from the document's current value and call\n * `counter.increment(delta)` on the underlying `Automerge.Counter`. Concurrent\n * increments from peers commute, so two clients each adding 1 to a counter at\n * 5 produce a counter at 7 after merging.\n *\n * Application code that wants to express increments idiomatically can write\n * `counter.value = counter.value + 1`; the signal's reactivity captures the\n * read-then-write pattern and the factory translates it into a proper CRDT\n * increment operation underneath.\n */\nexport function $crdtCounter(\n key: string,\n initialValue: number,\n options: CrdtCounterOptions\n): SpecialisedPrimitive<number> {\n return createSpecialisedPrimitive<number, CounterDoc>({\n key,\n primitive: options.primitive ?? \"peerState\",\n initialValue,\n getHandle: options.getHandle,\n extractValue: (doc) => {\n const c = doc.count;\n if (c === undefined) return 0;\n return c.value;\n },\n applyWrite: (doc, value) => {\n const existing = doc.count;\n if (existing === undefined) {\n (doc as unknown as CounterDoc).count = new Counter(value);\n } else {\n const delta = value - existing.value;\n if (delta !== 0) {\n existing.increment(delta);\n }\n }\n },\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n callSite: options.callSite,\n });\n}\n\n// $crdtList\n\n/** The Automerge document shape backing a $crdtList primitive. */\nexport type ListDoc<T> = VersionedDoc & { items?: T[] };\n\n/** Options for {@link $crdtList}. */\nexport interface CrdtListOptions<T> {\n primitive?: PrimitiveKind;\n getHandle: () => Promise<DocHandle<ListDoc<T>>>;\n schemaVersion?: number;\n migrations?: Migrations;\n access?: Access;\n callSite?: string;\n}\n\n/**\n * Create a CRDT-backed list primitive. The signal exposes a plain array;\n * for the Phase 0 cut, writes replace the underlying array wholesale inside\n * an `Automerge.change` block. This is correct for single-writer scenarios\n * and is the simplest way to ship a working list primitive on the same\n * pipeline as text and counter.\n *\n * Phase 1 will replace the write path with proper structural diffing into\n * insert and remove operations so that concurrent edits from peers preserve\n * list ordering. Until then, applications using $crdtList in a multi-writer\n * setting should expect last-writer-wins semantics on the array as a whole.\n */\nexport function $crdtList<T>(\n key: string,\n initialValue: T[],\n options: CrdtListOptions<T>\n): SpecialisedPrimitive<T[]> {\n return createSpecialisedPrimitive<T[], ListDoc<T>>({\n key,\n primitive: options.primitive ?? \"peerState\",\n initialValue,\n getHandle: options.getHandle,\n extractValue: (doc) => (doc.items ? [...doc.items] : []),\n applyWrite: (doc, value) => {\n // Phase 0 naive replacement; see the function-level docstring for the\n // refinement plan.\n (doc as unknown as ListDoc<T>).items = [...value];\n },\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n callSite: options.callSite,\n });\n}\n",
19
19
  "/**\n * migrate-primitive — one-way cross-primitive data migration helper.\n *\n * Moving data from one Polly primitive to another ($sharedState to $peerState,\n * $peerState to $meshState, etc.) is a deliberate, one-time, application-authored\n * operation. The three primitive families serialise differently — LWW value plus\n * Lamport clock, plaintext Automerge ops, signed and encrypted Automerge ops —\n * and Polly never silently coerces between them. An application that wants to\n * move data explicitly reads the current value from the source, applies a\n * user-supplied transform, writes the result into the destination, and marks\n * the source as migrated so subsequent reads from it fail loudly rather than\n * returning stale data.\n *\n * This module provides the helper ({@link migratePrimitive}) and the migration\n * registry ({@link migrationRegistry}) that records which (key, primitive kind)\n * pairs have been migrated. Primitive read paths consult the registry at load\n * time and refuse to hydrate sources that have been marked. Migration is one-way\n * by design: there is no rollback, and running a migration twice throws.\n *\n * The registry is in-memory only. Persistence of the migrated flag across page\n * loads is each primitive's own responsibility at its storage boundary; Phase 1\n * and Phase 2 primitives will restore the registry state on startup from their\n * local stores.\n *\n * @example\n * ```ts\n * await migratePrimitive(\n * $sharedState<OldNotes>(\"notes\"),\n * $meshState<NewNotes>(\"notes\", { entries: [] }),\n * (old) => ({ entries: old.entries ?? [] }),\n * );\n * ```\n */\n\nimport type { PrimitiveKind } from \"./primitive-registry\";\n\n/**\n * Minimal interface that every migratable state primitive must satisfy. Real\n * primitive instances will implement this plus everything else their type\n * expects; tests construct plain objects.\n */\nexport interface MigratableState<T> {\n /** Stable logical key the primitive was registered under. */\n readonly key: string;\n /** The primitive kind owning this state. Used to identify entries in the\n * migration registry alongside the key. */\n readonly primitive: PrimitiveKind;\n /** Current value. Must be readable and writable. */\n value: T;\n /** Hydration promise. The migration helper awaits this on both source and\n * destination before reading the source value. */\n readonly loaded: Promise<void>;\n}\n\n/**\n * Error thrown by the migration subsystem. The {@link code} field distinguishes\n * the failure modes so callers can branch on them.\n */\nexport class MigrationError extends Error {\n readonly code: \"already-migrated\" | \"same-primitive-instance\";\n readonly key: string;\n readonly primitive: PrimitiveKind;\n\n constructor(\n message: string,\n code: MigrationError[\"code\"],\n key: string,\n primitive: PrimitiveKind\n ) {\n super(message);\n this.name = \"MigrationError\";\n this.code = code;\n this.key = key;\n this.primitive = primitive;\n }\n}\n\n/**\n * In-memory registry of migrated (key, primitive kind) pairs. Exported as a\n * class so tests can construct fresh instances; application code uses the\n * module-level {@link migrationRegistry} singleton.\n */\nexport class MigrationRegistry {\n private readonly marks = new Set<string>();\n\n private entryKey(key: string, primitive: PrimitiveKind): string {\n return `${primitive}:${key}`;\n }\n\n /** Mark a source primitive as migrated. Idempotent. */\n mark(key: string, primitive: PrimitiveKind): void {\n this.marks.add(this.entryKey(key, primitive));\n }\n\n /** Check whether a source primitive has been marked as migrated. */\n isMarked(key: string, primitive: PrimitiveKind): boolean {\n return this.marks.has(this.entryKey(key, primitive));\n }\n\n /** Drop every mark. Intended for tests; application code should not call this. */\n clear(): void {\n this.marks.clear();\n }\n\n /** Number of recorded marks. Intended for tests. */\n get size(): number {\n return this.marks.size;\n }\n}\n\n/**\n * The process-wide migration registry. Primitives and application migrations\n * both consult it: tests can reset it with {@link MigrationRegistry.clear}.\n */\nexport const migrationRegistry = new MigrationRegistry();\n\n/**\n * Migrate data from one Polly primitive to another. Reads the source's current\n * value, applies the caller's transform, writes the result to the destination,\n * and marks the source as migrated so subsequent reads fail loudly.\n *\n * The helper is one-way and one-time. Running it twice on the same source\n * throws a {@link MigrationError} with code `already-migrated`. Running it\n * with the same object as both source and destination throws with code\n * `same-primitive-instance`.\n *\n * Applications invoke this explicitly on upgrade, once per device, typically\n * inside a startup hook before the primitives that depend on the migrated data\n * are read. It is not a replacement for the schema-version migration protocol\n * inside a single primitive — that handles shape evolution within one primitive\n * family, whereas this helper handles moves between primitive families.\n */\nexport async function migratePrimitive<Source, Destination>(\n source: MigratableState<Source>,\n destination: MigratableState<Destination>,\n transform: (value: Source) => Destination\n): Promise<void> {\n if ((source as unknown as unknown) === (destination as unknown as unknown)) {\n throw new MigrationError(\n `Cannot migrate a primitive to itself: \"${source.key}\" under ${source.primitive}.`,\n \"same-primitive-instance\",\n source.key,\n source.primitive\n );\n }\n if (migrationRegistry.isMarked(source.key, source.primitive)) {\n throw new MigrationError(\n `Cannot migrate: source \"${source.key}\" under $${source.primitive} has already been migrated. Migrations are one-way and one-time.`,\n \"already-migrated\",\n source.key,\n source.primitive\n );\n }\n await source.loaded;\n await destination.loaded;\n const transformed = transform(source.value);\n destination.value = transformed;\n migrationRegistry.mark(source.key, source.primitive);\n}\n",
20
20
  "/**\n * PrimitiveRegistry — runtime namespace collision detection across Polly's\n * synced state primitives.\n *\n * The three primitive families ($sharedState, $peerState, $meshState) each store\n * data under a developer-chosen logical key. If two different primitives both\n * claim the same key, the developer almost certainly has a bug: the on-disk\n * formats are incompatible, no sync happens between them, and whichever primitive\n * resolves first silently \"wins\" from the developer's perspective. By the time\n * the mistake is noticed, data has diverged.\n *\n * The registry catches the mistake at the first mismatched registration and\n * throws a structured error naming the key, both primitives, and (when available)\n * the call site of each registration. This is run-to-failure by design: a\n * collision is always a bug, and the failure should be loud.\n *\n * Same primitive re-registering the same key is allowed and is a no-op — it\n * supports hot module reloading and component re-mounts without spurious errors.\n * Changing the primitive kind of an existing key is still an error; developers\n * doing that during local HMR should hard-reload to reset the registry.\n *\n * @example\n * ```ts\n * primitiveRegistry.register(\"notes\", \"sharedState\", \"src/app.ts:10\");\n * primitiveRegistry.register(\"notes\", \"peerState\", \"src/other.ts:22\");\n * // throws PrimitiveCollisionError — names both primitives and both call sites\n * ```\n */\n\n/**\n * Canonical identifiers for Polly's synced state primitives. The registry\n * uses these as opaque labels; nothing else in Polly needs to match them.\n */\nexport type PrimitiveKind =\n | \"sharedState\"\n | \"syncedState\"\n | \"persistedState\"\n | \"state\"\n | \"peerState\"\n | \"meshState\";\n\n/**\n * Thrown when a logical key is registered under more than one primitive.\n * The message names the key, both primitives, and (when available) the\n * call site of each registration, so the developer can navigate to both\n * sites from the error output.\n */\nexport class PrimitiveCollisionError extends Error {\n readonly key: string;\n readonly firstPrimitive: PrimitiveKind;\n readonly firstCallSite: string | undefined;\n readonly secondPrimitive: PrimitiveKind;\n readonly secondCallSite: string | undefined;\n\n constructor(\n key: string,\n firstPrimitive: PrimitiveKind,\n firstCallSite: string | undefined,\n secondPrimitive: PrimitiveKind,\n secondCallSite: string | undefined\n ) {\n const firstLocation = firstCallSite ? ` (at ${firstCallSite})` : \"\";\n const secondLocation = secondCallSite ? ` (at ${secondCallSite})` : \"\";\n super(\n `Polly primitive key collision: \"${key}\" is already registered as ` +\n `$${firstPrimitive}${firstLocation} and cannot also be registered ` +\n `as $${secondPrimitive}${secondLocation}. Pick a different key or ` +\n `use the same primitive in both places.`\n );\n this.name = \"PrimitiveCollisionError\";\n this.key = key;\n this.firstPrimitive = firstPrimitive;\n this.firstCallSite = firstCallSite;\n this.secondPrimitive = secondPrimitive;\n this.secondCallSite = secondCallSite;\n }\n}\n\ntype RegistryEntry = {\n primitive: PrimitiveKind;\n callSite: string | undefined;\n};\n\n/**\n * A small Map-backed registry of \"logical key → primitive kind\". Exported as\n * a class so tests can construct fresh instances without sharing state; the\n * module-level {@link primitiveRegistry} singleton is what application code\n * actually uses.\n */\nexport class PrimitiveRegistry {\n private readonly entries = new Map<string, RegistryEntry>();\n\n /**\n * Register a key under a primitive kind. Re-registering the same key under\n * the same primitive is a no-op, which is what hot module reloading and\n * component re-mounts produce.\n *\n * @throws {PrimitiveCollisionError} if the key is already registered under\n * a different primitive kind.\n */\n register(key: string, primitive: PrimitiveKind, callSite?: string): void {\n const existing = this.entries.get(key);\n if (existing && existing.primitive !== primitive) {\n throw new PrimitiveCollisionError(\n key,\n existing.primitive,\n existing.callSite,\n primitive,\n callSite\n );\n }\n if (!existing) {\n this.entries.set(key, { primitive, callSite });\n }\n }\n\n /**\n * True if the key has been registered (under any primitive kind).\n */\n has(key: string): boolean {\n return this.entries.has(key);\n }\n\n /**\n * Look up the primitive kind a key is registered under, if any.\n * Returns undefined for unregistered keys.\n */\n kindOf(key: string): PrimitiveKind | undefined {\n return this.entries.get(key)?.primitive;\n }\n\n /**\n * Drop every registration. Intended for test setup and teardown; application\n * code should not call this.\n */\n clear(): void {\n this.entries.clear();\n }\n\n /**\n * Number of registered keys. Intended for tests.\n */\n get size(): number {\n return this.entries.size;\n }\n}\n\n/**\n * The process-wide primitive registry. Application code registers here\n * implicitly via primitive constructors; tests can reset it with `clear()`.\n */\nexport const primitiveRegistry = new PrimitiveRegistry();\n",
@@ -25,7 +25,7 @@
25
25
  "/**\n * pairing — Phase 2 first-cut pairing flow for $meshState.\n *\n * Two devices that want to share a $meshState document must exchange three\n * things before sync can begin: the issuer's Ed25519 signing public key\n * (so the receiver can verify ops authored by the issuer), the symmetric\n * document encryption key (so both sides can encrypt and decrypt the\n * shared document), and the issuer's stable peer id (so the receiver\n * knows which entry in its keyring the public key belongs to). This\n * module packs all three into a {@link PairingToken}, serialises it to a\n * compact binary format suitable for QR codes or copy-paste, and provides\n * the matching parse-and-apply flow on the receiving side.\n *\n * Threat model: pairing tokens are transmitted over an out-of-band channel\n * that the user can authenticate visually — typically a QR code on the\n * issuer's device, scanned by the receiver. Because anyone with the token\n * can decrypt and impersonate, the OOB channel is the only authentication.\n * The token includes a TTL (default 10 minutes) so that a token displayed\n * briefly and then dismissed cannot be replayed by an attacker who later\n * gains access to a screenshot. A production deployment would layer a\n * Short Authentication String (SAS) on top — both devices display a code\n * derived from the shared state, and the user verifies they match — but\n * that is a follow-up.\n *\n * The pairing flow is one-way in the Phase 2 first cut. The issuer\n * generates a token and displays it; the receiver applies it and picks\n * up the issuer's keys. The receiver's own keys reach the issuer through\n * the access set: when the receiver sends its first signed op, the issuer\n * records the receiver's public key alongside its peer id and adds it to\n * the keyring. A bidirectional pairing flow that exchanges both sides'\n * keys in a single QR exchange is straightforward to add later but adds\n * UX surface area that is not needed for the mesh transport to work.\n */\n\nimport { KEY_BYTES as ENCRYPTION_KEY_BYTES, generateDocumentKey } from \"./encryption\";\nimport type { MeshKeyring } from \"./mesh-network-adapter\";\nimport {\n generateSigningKeyPair,\n PUBLIC_KEY_BYTES as SIGNING_PUBLIC_KEY_BYTES,\n type SigningKeyPair,\n} from \"./signing\";\n\n/** Current pairing-token format version. Bumped if the wire format changes. */\nexport const PAIRING_TOKEN_VERSION = 1;\n\n/** Magic header bytes for sanity-checking parsed tokens. ASCII \"PPT1\". */\nexport const PAIRING_TOKEN_MAGIC = new Uint8Array([0x50, 0x50, 0x54, 0x31]);\n\n/** Length of the random nonce embedded in every token. */\nexport const PAIRING_NONCE_BYTES = 16;\n\n/** Default TTL applied when {@link createPairingToken} is called without an\n * explicit `ttlMs` option. */\nexport const DEFAULT_PAIRING_TTL_MS = 10 * 60 * 1000; // 10 minutes\n\n/**\n * The contents of a pairing token. Both sides operate on this shape; the\n * binary serialisation is purely for transport.\n */\nexport interface PairingToken {\n /** Format version. {@link PAIRING_TOKEN_VERSION} at the time of writing. */\n version: number;\n /** Stable peer id of the issuing device. The receiver records this as\n * the lookup key for the issuer's public key in its keyring. */\n issuerPeerId: string;\n /** Issuer's Ed25519 signing public key (32 bytes). */\n issuerPublicKey: Uint8Array;\n /** Shared document encryption key (32 bytes). The receiver stores this\n * under {@link documentKeyId} in its keyring. */\n documentKey: Uint8Array;\n /** Identifier under which the receiver stores the document key. For the\n * Phase 2 first cut this is typically the well-known DEFAULT_MESH_KEY_ID\n * from mesh-network-adapter; per-document keys (one entry per Automerge\n * document) are a follow-up. */\n documentKeyId: string;\n /** Unix timestamp (milliseconds) after which the token is considered\n * expired and {@link applyPairingToken} refuses to use it. */\n expiresAt: number;\n /** 16-byte random nonce. Carried through serialisation so two tokens\n * with otherwise-identical contents are still distinguishable. */\n nonce: Uint8Array;\n}\n\n/** Errors thrown by the pairing subsystem. */\nexport class PairingError extends Error {\n readonly code:\n | \"expired\"\n | \"wrong-magic\"\n | \"unknown-version\"\n | \"truncated\"\n | \"invalid-public-key\"\n | \"invalid-document-key\"\n | \"invalid-nonce\";\n\n constructor(message: string, code: PairingError[\"code\"]) {\n super(message);\n this.name = \"PairingError\";\n this.code = code;\n }\n}\n\n/**\n * Options for {@link createPairingToken}. The signing identity and the\n * document key are required; everything else is optional with sensible\n * defaults.\n */\nexport interface CreatePairingTokenOptions {\n /** The issuing device's signing keypair. Only the public key ends up in\n * the token; the secret never leaves the issuer. */\n identity: SigningKeyPair;\n /** Stable peer id for the issuing device. */\n issuerPeerId: string;\n /** The symmetric document key the receiver should adopt. If omitted, a\n * fresh key is generated and the caller is responsible for using the\n * same key on the issuing side too. */\n documentKey?: Uint8Array;\n /** Identifier under which the receiver stores the document key. */\n documentKeyId: string;\n /** Time-to-live in milliseconds. Defaults to {@link DEFAULT_PAIRING_TTL_MS}. */\n ttlMs?: number;\n /** Override the current time. Intended for tests; production code should\n * not pass this. */\n now?: () => number;\n}\n\n/**\n * Generate a fresh {@link PairingToken}. The token is ready to be\n * serialised and displayed to the receiver via an OOB channel.\n */\nexport function createPairingToken(options: CreatePairingTokenOptions): PairingToken {\n const now = options.now ? options.now() : Date.now();\n const ttlMs = options.ttlMs ?? DEFAULT_PAIRING_TTL_MS;\n const documentKey = options.documentKey ?? generateDocumentKey();\n const nonce = randomBytes(PAIRING_NONCE_BYTES);\n\n return {\n version: PAIRING_TOKEN_VERSION,\n issuerPeerId: options.issuerPeerId,\n issuerPublicKey: options.identity.publicKey,\n documentKey,\n documentKeyId: options.documentKeyId,\n expiresAt: now + ttlMs,\n nonce,\n };\n}\n\n/**\n * Generate a fresh pairing token *and* a fresh signing keypair in one call.\n * Convenience for first-time setup where the device has no existing\n * identity yet. Returns both so the caller can persist the keypair and\n * then display the token.\n */\nexport function createPairingTokenWithFreshIdentity(args: {\n issuerPeerId: string;\n documentKeyId: string;\n ttlMs?: number;\n now?: () => number;\n}): { identity: SigningKeyPair; token: PairingToken } {\n const identity = generateSigningKeyPair();\n const token = createPairingToken({\n identity,\n issuerPeerId: args.issuerPeerId,\n documentKeyId: args.documentKeyId,\n ttlMs: args.ttlMs,\n now: args.now,\n });\n return { identity, token };\n}\n\n/**\n * Check whether a token has expired against the current wall-clock time\n * (or an injected `now`).\n */\nexport function isPairingTokenExpired(token: PairingToken, now?: () => number): boolean {\n const t = now ? now() : Date.now();\n return t >= token.expiresAt;\n}\n\n/**\n * Apply a parsed and validated token to a {@link MeshKeyring}. Mutates the\n * keyring in place: adds the issuer's public key to {@link MeshKeyring.knownPeers}\n * and the document key to {@link MeshKeyring.documentKeys}.\n *\n * Throws {@link PairingError} with code \"expired\" if the token's TTL has\n * elapsed. The receiver is expected to apply the token promptly after\n * scanning; rejecting expired tokens prevents replay of long-lived\n * captures.\n */\nexport function applyPairingToken(\n token: PairingToken,\n keyring: MeshKeyring,\n options: { now?: () => number } = {}\n): void {\n if (isPairingTokenExpired(token, options.now)) {\n throw new PairingError(\n `Pairing token from ${token.issuerPeerId} expired at ${new Date(token.expiresAt).toISOString()}.`,\n \"expired\"\n );\n }\n keyring.knownPeers.set(token.issuerPeerId, token.issuerPublicKey);\n keyring.documentKeys.set(token.documentKeyId, token.documentKey);\n}\n\n// binary serialisation\n\n/**\n * Serialise a token to a binary blob. The wire format is:\n *\n * [4 bytes: magic \"PPT1\"]\n * [1 byte: version]\n * [4 bytes BE: issuer id byte length]\n * [N bytes: issuer id UTF-8]\n * [32 bytes: issuer public key]\n * [32 bytes: document key]\n * [4 bytes BE: document key id byte length]\n * [M bytes: document key id UTF-8]\n * [8 bytes BE: expiresAt (uint64 milliseconds)]\n * [16 bytes: nonce]\n *\n * Use {@link encodePairingToken} to round-trip through a base64 string.\n */\nexport function serialisePairingToken(token: PairingToken): Uint8Array {\n validateForSerialisation(token);\n const issuerBytes = new TextEncoder().encode(token.issuerPeerId);\n const keyIdBytes = new TextEncoder().encode(token.documentKeyId);\n\n const total =\n PAIRING_TOKEN_MAGIC.length +\n 1 + // version\n 4 + // issuer id length\n issuerBytes.length +\n SIGNING_PUBLIC_KEY_BYTES +\n ENCRYPTION_KEY_BYTES +\n 4 + // doc key id length\n keyIdBytes.length +\n 8 + // expiresAt\n PAIRING_NONCE_BYTES;\n\n const out = new Uint8Array(total);\n let offset = 0;\n\n out.set(PAIRING_TOKEN_MAGIC, offset);\n offset += PAIRING_TOKEN_MAGIC.length;\n\n out[offset] = token.version;\n offset += 1;\n\n const view = new DataView(out.buffer);\n view.setUint32(offset, issuerBytes.length, false);\n offset += 4;\n out.set(issuerBytes, offset);\n offset += issuerBytes.length;\n\n out.set(token.issuerPublicKey, offset);\n offset += SIGNING_PUBLIC_KEY_BYTES;\n\n out.set(token.documentKey, offset);\n offset += ENCRYPTION_KEY_BYTES;\n\n view.setUint32(offset, keyIdBytes.length, false);\n offset += 4;\n out.set(keyIdBytes, offset);\n offset += keyIdBytes.length;\n\n // Write expiresAt as uint64 BE. JavaScript numbers are float64 but the\n // value is an integer count of milliseconds, well within 53-bit safe\n // range for any practical timestamp.\n view.setBigUint64(offset, BigInt(token.expiresAt), false);\n offset += 8;\n\n out.set(token.nonce, offset);\n offset += PAIRING_NONCE_BYTES;\n\n return out;\n}\n\n/**\n * Inverse of {@link serialisePairingToken}. Throws {@link PairingError} on\n * malformed input.\n */\nexport function parsePairingToken(bytes: Uint8Array): PairingToken {\n let offset = 0;\n\n // Magic\n if (bytes.length < PAIRING_TOKEN_MAGIC.length) {\n throw new PairingError(`Pairing token too short: ${bytes.length} bytes.`, \"truncated\");\n }\n for (let i = 0; i < PAIRING_TOKEN_MAGIC.length; i++) {\n if (bytes[offset + i] !== PAIRING_TOKEN_MAGIC[i]) {\n throw new PairingError(\n `Pairing token magic mismatch: not a Polly pairing token.`,\n \"wrong-magic\"\n );\n }\n }\n offset += PAIRING_TOKEN_MAGIC.length;\n\n // Version\n if (bytes.length < offset + 1) {\n throw new PairingError(\"Pairing token truncated at version.\", \"truncated\");\n }\n const version = bytes[offset] as unknown as number;\n offset += 1;\n if (version !== PAIRING_TOKEN_VERSION) {\n throw new PairingError(\n `Unknown pairing token version: ${version}. This Polly build supports version ${PAIRING_TOKEN_VERSION}.`,\n \"unknown-version\"\n );\n }\n\n // Issuer id\n if (bytes.length < offset + 4) {\n throw new PairingError(\"Pairing token truncated at issuer id length.\", \"truncated\");\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const issuerLen = view.getUint32(offset, false);\n offset += 4;\n if (bytes.length < offset + issuerLen) {\n throw new PairingError(\"Pairing token truncated at issuer id.\", \"truncated\");\n }\n const issuerPeerId = new TextDecoder().decode(bytes.subarray(offset, offset + issuerLen));\n offset += issuerLen;\n\n // Issuer public key\n if (bytes.length < offset + SIGNING_PUBLIC_KEY_BYTES) {\n throw new PairingError(\"Pairing token truncated at public key.\", \"truncated\");\n }\n const issuerPublicKey = bytes.slice(offset, offset + SIGNING_PUBLIC_KEY_BYTES);\n offset += SIGNING_PUBLIC_KEY_BYTES;\n\n // Document key\n if (bytes.length < offset + ENCRYPTION_KEY_BYTES) {\n throw new PairingError(\"Pairing token truncated at document key.\", \"truncated\");\n }\n const documentKey = bytes.slice(offset, offset + ENCRYPTION_KEY_BYTES);\n offset += ENCRYPTION_KEY_BYTES;\n\n // Document key id\n if (bytes.length < offset + 4) {\n throw new PairingError(\"Pairing token truncated at document key id length.\", \"truncated\");\n }\n const keyIdLen = view.getUint32(offset, false);\n offset += 4;\n if (bytes.length < offset + keyIdLen) {\n throw new PairingError(\"Pairing token truncated at document key id.\", \"truncated\");\n }\n const documentKeyId = new TextDecoder().decode(bytes.subarray(offset, offset + keyIdLen));\n offset += keyIdLen;\n\n // Expires at\n if (bytes.length < offset + 8) {\n throw new PairingError(\"Pairing token truncated at expiry.\", \"truncated\");\n }\n const expiresAtBig = view.getBigUint64(offset, false);\n offset += 8;\n const expiresAt = Number(expiresAtBig);\n\n // Nonce\n if (bytes.length < offset + PAIRING_NONCE_BYTES) {\n throw new PairingError(\"Pairing token truncated at nonce.\", \"truncated\");\n }\n const nonce = bytes.slice(offset, offset + PAIRING_NONCE_BYTES);\n offset += PAIRING_NONCE_BYTES;\n\n return {\n version,\n issuerPeerId,\n issuerPublicKey,\n documentKey,\n documentKeyId,\n expiresAt,\n nonce,\n };\n}\n\n/**\n * Serialise a token and base64-encode it for QR-code or copy-paste display.\n * The encoding uses the standard base64 alphabet (not URL-safe) because\n * QR codes encode bytes directly and do not care about URL safety.\n */\nexport function encodePairingToken(token: PairingToken): string {\n const bytes = serialisePairingToken(token);\n // btoa expects a binary string. Convert via String.fromCharCode per byte;\n // safe for the ~150-byte token size and avoids the spread-into-fromCharCode\n // pattern that runs into argument-count limits on large arrays.\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary);\n}\n\n/**\n * Decode a base64-encoded pairing token produced by {@link encodePairingToken}.\n * Throws {@link PairingError} on malformed input.\n */\nexport function decodePairingToken(encoded: string): PairingToken {\n let binary: string;\n try {\n binary = atob(encoded);\n } catch {\n throw new PairingError(\"Pairing token is not valid base64.\", \"wrong-magic\");\n }\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return parsePairingToken(bytes);\n}\n\n// helpers\n\nfunction validateForSerialisation(token: PairingToken): void {\n if (token.issuerPublicKey.length !== SIGNING_PUBLIC_KEY_BYTES) {\n throw new PairingError(\n `Issuer public key must be ${SIGNING_PUBLIC_KEY_BYTES} bytes, got ${token.issuerPublicKey.length}.`,\n \"invalid-public-key\"\n );\n }\n if (token.documentKey.length !== ENCRYPTION_KEY_BYTES) {\n throw new PairingError(\n `Document key must be ${ENCRYPTION_KEY_BYTES} bytes, got ${token.documentKey.length}.`,\n \"invalid-document-key\"\n );\n }\n if (token.nonce.length !== PAIRING_NONCE_BYTES) {\n throw new PairingError(\n `Nonce must be ${PAIRING_NONCE_BYTES} bytes, got ${token.nonce.length}.`,\n \"invalid-nonce\"\n );\n }\n}\n\nfunction randomBytes(n: number): Uint8Array {\n const out = new Uint8Array(n);\n crypto.getRandomValues(out);\n return out;\n}\n",
26
26
  "/**\n * revocation — Phase 2 key-revocation flow for $meshState.\n *\n * A $meshState deployment is only as secure as the keys it trusts. When a\n * device is lost, stolen, or compromised, its public key needs to be\n * removed from every other peer's trust set so that any operations signed\n * by that key are refused. This module provides the primitive pieces for\n * that flow: a signed revocation record that names the revoked peer id,\n * carries the issuer's identity, and travels between peers through the\n * same channels as any other signed message.\n *\n * A RevocationRecord is produced by a peer that has decided to revoke\n * another peer (typically because the user told their device to do so).\n * It is then serialised to a binary envelope, broadcast to other peers\n * through whatever transport is available, and applied to each receiving\n * keyring via {@link applyRevocation}. Applying a revocation adds the\n * target peer id to the keyring's {@link MeshKeyring.revokedPeers} set;\n * the MeshNetworkAdapter then drops all further messages from that peer,\n * even though the public key is still present in the knownPeers map.\n *\n * Signature layer: every revocation is signed by the *issuer's* key. The\n * receiver verifies the signature against the issuer's public key before\n * applying. This prevents a peer with no authority from forging a\n * revocation, at least in the signature-level threat model — a compromised\n * peer could still forge revocations naming any other peer, which is why\n * production deployments layer an access-set check on top (\"who is\n * authorised to revoke whom\"). That layer is a follow-up; the first cut\n * is signature-only, and any signed revocation from a known peer is\n * accepted.\n *\n * Why revocations are signed but not encrypted: revocations are public\n * in the sense that they name \"peer X is no longer trusted.\" There is no\n * confidentiality requirement — anyone seeing a revocation learns only\n * that someone has been kicked out, which is already observable from\n * the absence of their operations. Encrypting them would add cost without\n * adding security, so the wire format is signed-only.\n */\n\nimport type { MeshKeyring } from \"./mesh-network-adapter\";\nimport {\n decodeSignedEnvelope,\n encodeSignedEnvelope,\n openEnvelope as openSignedEnvelope,\n type SigningKeyPair,\n signEnvelope,\n} from \"./signing\";\n\n/** Current revocation-record format version. */\nexport const REVOCATION_RECORD_VERSION = 1;\n\n/** Magic header bytes for sanity-checking parsed revocations. ASCII \"PRV1\". */\nexport const REVOCATION_MAGIC = new Uint8Array([0x50, 0x52, 0x56, 0x31]);\n\n/**\n * The payload carried inside a signed revocation envelope.\n */\nexport interface RevocationRecord {\n /** Format version. */\n version: number;\n /** The peer id doing the revoking. Becomes the `senderId` of the signed\n * envelope when the record is serialised. */\n issuerPeerId: string;\n /** The peer id being revoked. After a receiver applies this record, its\n * MeshNetworkAdapter will drop all further messages from this peer. */\n revokedPeerId: string;\n /** Unix timestamp (milliseconds) when the revocation was issued. Carried\n * for audit and for tie-breaking in case an issuer issues multiple\n * revocations targeting the same peer. */\n issuedAt: number;\n /** Optional human-readable reason. Not used by the enforcement layer;\n * applications can surface it in audit logs. */\n reason?: string;\n}\n\n/** Errors thrown by the revocation subsystem. */\nexport class RevocationError extends Error {\n readonly code:\n | \"unknown-issuer\"\n | \"unauthorised-issuer\"\n | \"signature-invalid\"\n | \"truncated\"\n | \"wrong-magic\"\n | \"unknown-version\"\n | \"not-signed-by-issuer\";\n\n constructor(message: string, code: RevocationError[\"code\"]) {\n super(message);\n this.name = \"RevocationError\";\n this.code = code;\n }\n}\n\n/** Options for {@link createRevocation}. */\nexport interface CreateRevocationOptions {\n /** Signing keypair of the issuer. The private key signs the record; the\n * public key is looked up by the receiver via `issuerPeerId`. */\n issuer: SigningKeyPair;\n /** Stable peer id of the issuer. */\n issuerPeerId: string;\n /** Peer id to revoke. */\n revokedPeerId: string;\n /** Optional human-readable reason. */\n reason?: string;\n /** Override the current time. Intended for tests. */\n now?: () => number;\n}\n\n/**\n * Build a fresh {@link RevocationRecord}. The returned record is plain\n * data; use {@link encodeRevocation} to wrap it in a signed envelope\n * suitable for transport.\n */\nexport function createRevocation(options: CreateRevocationOptions): RevocationRecord {\n const now = options.now ? options.now() : Date.now();\n return {\n version: REVOCATION_RECORD_VERSION,\n issuerPeerId: options.issuerPeerId,\n revokedPeerId: options.revokedPeerId,\n issuedAt: now,\n ...(options.reason === undefined ? {} : { reason: options.reason }),\n };\n}\n\n/**\n * Apply a verified revocation to a keyring. Mutates the keyring in place:\n * adds the target peer id to {@link MeshKeyring.revokedPeers}. The caller\n * must verify the revocation (via {@link decodeRevocation}) before\n * applying; this function does not revalidate the signature.\n */\nexport function applyRevocation(record: RevocationRecord, keyring: MeshKeyring): void {\n keyring.revokedPeers.add(record.revokedPeerId);\n}\n\n/**\n * Revoke a peer locally without producing a transportable record. Useful\n * for the common case where an application decides to drop a peer on this\n * device without propagating the decision elsewhere (tests, single-device\n * setups). Peers that want the revocation to spread to other devices\n * should use {@link createRevocation} + {@link encodeRevocation}.\n */\nexport function revokePeerLocally(peerId: string, keyring: MeshKeyring): void {\n keyring.revokedPeers.add(peerId);\n}\n\n// binary serialisation\n\n/**\n * Serialise a {@link RevocationRecord} to a binary payload ready for\n * signing. The layout is:\n *\n * [4 bytes: magic \"PRV1\"]\n * [1 byte: version]\n * [4 bytes BE: issuer id byte length]\n * [N bytes: issuer id UTF-8]\n * [4 bytes BE: revoked peer id byte length]\n * [M bytes: revoked peer id UTF-8]\n * [8 bytes BE: issuedAt (uint64 milliseconds)]\n * [4 bytes BE: reason byte length]\n * [R bytes: reason UTF-8]\n */\nexport function serialiseRevocationPayload(record: RevocationRecord): Uint8Array {\n const issuerBytes = new TextEncoder().encode(record.issuerPeerId);\n const revokedBytes = new TextEncoder().encode(record.revokedPeerId);\n const reasonBytes = new TextEncoder().encode(record.reason ?? \"\");\n\n const total =\n REVOCATION_MAGIC.length +\n 1 + // version\n 4 +\n issuerBytes.length +\n 4 +\n revokedBytes.length +\n 8 + // issuedAt\n 4 +\n reasonBytes.length;\n\n const out = new Uint8Array(total);\n let offset = 0;\n\n out.set(REVOCATION_MAGIC, offset);\n offset += REVOCATION_MAGIC.length;\n\n out[offset] = record.version;\n offset += 1;\n\n const view = new DataView(out.buffer);\n view.setUint32(offset, issuerBytes.length, false);\n offset += 4;\n out.set(issuerBytes, offset);\n offset += issuerBytes.length;\n\n view.setUint32(offset, revokedBytes.length, false);\n offset += 4;\n out.set(revokedBytes, offset);\n offset += revokedBytes.length;\n\n view.setBigUint64(offset, BigInt(record.issuedAt), false);\n offset += 8;\n\n view.setUint32(offset, reasonBytes.length, false);\n offset += 4;\n out.set(reasonBytes, offset);\n\n return out;\n}\n\n/** Inverse of {@link serialiseRevocationPayload}. */\nfunction parseRevocationPayload(bytes: Uint8Array): RevocationRecord {\n let offset = 0;\n\n if (bytes.length < REVOCATION_MAGIC.length) {\n throw new RevocationError(\"Revocation record too short for magic.\", \"truncated\");\n }\n for (let i = 0; i < REVOCATION_MAGIC.length; i++) {\n if (bytes[offset + i] !== REVOCATION_MAGIC[i]) {\n throw new RevocationError(\"Revocation record magic mismatch.\", \"wrong-magic\");\n }\n }\n offset += REVOCATION_MAGIC.length;\n\n if (bytes.length < offset + 1) {\n throw new RevocationError(\"Revocation record truncated at version.\", \"truncated\");\n }\n const version = bytes[offset] as unknown as number;\n offset += 1;\n if (version !== REVOCATION_RECORD_VERSION) {\n throw new RevocationError(`Unknown revocation record version: ${version}.`, \"unknown-version\");\n }\n\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n if (bytes.length < offset + 4) {\n throw new RevocationError(\"Revocation record truncated at issuer length.\", \"truncated\");\n }\n const issuerLen = view.getUint32(offset, false);\n offset += 4;\n if (bytes.length < offset + issuerLen) {\n throw new RevocationError(\"Revocation record truncated at issuer id.\", \"truncated\");\n }\n const issuerPeerId = new TextDecoder().decode(bytes.subarray(offset, offset + issuerLen));\n offset += issuerLen;\n\n if (bytes.length < offset + 4) {\n throw new RevocationError(\"Revocation record truncated at revoked id length.\", \"truncated\");\n }\n const revokedLen = view.getUint32(offset, false);\n offset += 4;\n if (bytes.length < offset + revokedLen) {\n throw new RevocationError(\"Revocation record truncated at revoked id.\", \"truncated\");\n }\n const revokedPeerId = new TextDecoder().decode(bytes.subarray(offset, offset + revokedLen));\n offset += revokedLen;\n\n if (bytes.length < offset + 8) {\n throw new RevocationError(\"Revocation record truncated at issuedAt.\", \"truncated\");\n }\n const issuedAt = Number(view.getBigUint64(offset, false));\n offset += 8;\n\n if (bytes.length < offset + 4) {\n throw new RevocationError(\"Revocation record truncated at reason length.\", \"truncated\");\n }\n const reasonLen = view.getUint32(offset, false);\n offset += 4;\n if (bytes.length < offset + reasonLen) {\n throw new RevocationError(\"Revocation record truncated at reason.\", \"truncated\");\n }\n const reason = new TextDecoder().decode(bytes.subarray(offset, offset + reasonLen));\n offset += reasonLen;\n\n return {\n version,\n issuerPeerId,\n revokedPeerId,\n issuedAt,\n ...(reason ? { reason } : {}),\n };\n}\n\n/**\n * Produce a signed, transportable binary blob from a revocation record.\n * Wraps the serialised payload in a {@link SignedEnvelope} signed by the\n * issuer's keypair, then encodes the envelope to bytes.\n */\nexport function encodeRevocation(record: RevocationRecord, issuer: SigningKeyPair): Uint8Array {\n const payload = serialiseRevocationPayload(record);\n const envelope = signEnvelope(payload, record.issuerPeerId, issuer.secretKey);\n return encodeSignedEnvelope(envelope);\n}\n\n/**\n * Parse and verify a signed revocation blob. Returns the decoded record\n * on success; throws {@link RevocationError} on any failure.\n *\n * Verification requires the keyring to already know the issuer's public\n * key (because Polly does not have a global PKI). If the issuer is\n * unknown, the caller receives `unknown-issuer` and can decide whether\n * to cache the revocation for later verification or drop it outright.\n *\n * Authorisation: when the keyring has a non-empty\n * {@link MeshKeyring.revocationAuthority} set, only issuers inside that\n * set can have their revocations accepted. An issuer outside the set\n * produces `unauthorised-issuer`. When the authority set is undefined\n * or empty, any signed revocation from a known peer is accepted — that\n * is the Phase 2 first-cut default, preserved for backward compatibility.\n */\nexport function decodeRevocation(bytes: Uint8Array, keyring: MeshKeyring): RevocationRecord {\n const envelope = decodeSignedEnvelope(bytes);\n const issuerKey = keyring.knownPeers.get(envelope.senderId);\n if (!issuerKey) {\n throw new RevocationError(\n `Revocation issuer ${envelope.senderId} is not in the local keyring.`,\n \"unknown-issuer\"\n );\n }\n if (\n keyring.revocationAuthority !== undefined &&\n keyring.revocationAuthority.size > 0 &&\n !keyring.revocationAuthority.has(envelope.senderId)\n ) {\n throw new RevocationError(\n `Revocation issuer ${envelope.senderId} is not in the keyring's revocation authority set.`,\n \"unauthorised-issuer\"\n );\n }\n let payloadBytes: Uint8Array;\n try {\n payloadBytes = openSignedEnvelope(envelope, issuerKey);\n } catch {\n throw new RevocationError(\n `Revocation signature failed verification for issuer ${envelope.senderId}.`,\n \"signature-invalid\"\n );\n }\n\n const record = parseRevocationPayload(payloadBytes);\n // Paranoid cross-check: the payload's claimed issuer must match the\n // envelope's authenticated sender. Mismatch means a forged payload.\n if (record.issuerPeerId !== envelope.senderId) {\n throw new RevocationError(\n `Revocation payload claims issuer ${record.issuerPeerId} but the envelope was signed by ${envelope.senderId}.`,\n \"not-signed-by-issuer\"\n );\n }\n return record;\n}\n"
27
27
  ],
28
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;AA+BO,SAAS,mBAAmB,GAAe;AAAA,EAChD,OAAO,KAAK,YAAY,SAAS;AAAA;AAQ5B,SAAS,OAAO,CAAC,SAAqB,KAA8B;AAAA,EACzE,IAAI,IAAI,WAAW,WAAW;AAAA,IAC5B,MAAM,IAAI,gBACR,yBAAyB,wBAAwB,IAAI,WACrD,oBACF;AAAA,EACF;AAAA,EACA,MAAM,QAAQ,KAAK,YAAY,WAAW;AAAA,EAC1C,MAAM,aAAa,KAAK,UAAU,SAAS,OAAO,GAAG;AAAA,EACrD,MAAM,MAAM,IAAI,WAAW,cAAc,WAAW,MAAM;AAAA,EAC1D,IAAI,IAAI,OAAO,CAAC;AAAA,EAChB,IAAI,IAAI,YAAY,WAAW;AAAA,EAC/B,OAAO;AAAA;AAcF,SAAS,OAAO,CAAC,QAAqB,KAAyC;AAAA,EACpF,IAAI,IAAI,WAAW,WAAW;AAAA,IAC5B,MAAM,IAAI,gBACR,yBAAyB,wBAAwB,IAAI,WACrD,oBACF;AAAA,EACF;AAAA,EACA,IAAI,OAAO,SAAS,cAAc,WAAW;AAAA,IAC3C;AAAA,EACF;AAAA,EAC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,SAAS,uBAAuB,YAAY;AAAA,EAGlD,IAAI,OAAO,iBAAiB,SAAS,UAAU;AAAA,IAC7C,MAAM,IAAI,gBACR,oCAAoC,OAAO,+CAA+C,SAAS,aACnG,sBACF;AAAA,EACF;AAAA,EACA,OAAO;AAAA;",
29
+ "debugId": "23078FA0DB4C154064756E2164756E21",
30
30
  "names": []
31
31
  }
@@ -197,6 +197,42 @@ export interface MeshClientHandleSnapshot {
197
197
  * asking. */
198
198
  lastSyncMessageOutType: string | undefined;
199
199
  }
200
+ /** Polly#107 H5 diagnostics: surfaces the `mesh-state` module
201
+ * instance identity so a single snapshot read tells the operator
202
+ * whether the consumer's `$meshState` wrappers are resolving against
203
+ * the same module instance `createMeshClient` configured. A mismatch
204
+ * here IS the bundle-time module duplication bug. */
205
+ export interface MeshStateModuleDiagnostics {
206
+ /** The id stamped at import time on the `mesh-state` module
207
+ * instance THIS mesh client was constructed against. Compare to
208
+ * the id seen at the `$meshState` call site (also importable as
209
+ * `MESH_STATE_MODULE_ID` from `@fairfox/polly/mesh`). Two different
210
+ * ids means the consumer is reaching a duplicated copy of
211
+ * `mesh-state.ts` — wrappers register handles against a Repo this
212
+ * mesh client never saw. */
213
+ moduleId: string;
214
+ /** `true` iff THIS module instance has a configured `defaultRepo`.
215
+ * In the H5 scenario, this is `true` for the mesh-client-side
216
+ * snapshot (because `createMeshClient` always calls
217
+ * `configureMeshState` on the module it imports), but the same
218
+ * field read from the consumer's `$meshState` call site would
219
+ * be `false`. */
220
+ configured: boolean;
221
+ /** `peerId` of the most recent Repo wired through
222
+ * `configureMeshState` against THIS module instance. Compared to
223
+ * `client.repo.peerId` and the consumer's wrappers' resolved Repo
224
+ * tells the full story. */
225
+ lastConfiguredRepoPeerId: string | undefined;
226
+ /** `true` if any `$meshState`-family wrapper has been called
227
+ * against THIS module instance at any point. The polly#107 H5
228
+ * fingerprint pair: `configured: true, wasResolved: false` on
229
+ * the mesh-client-side snapshot (the wrappers never reached us);
230
+ * the consumer's wrapper code reading the same field from THEIR
231
+ * `$meshState` import would see `configured: false, wasResolved:
232
+ * true` (they're using a module instance no mesh client ever
233
+ * configured). */
234
+ wasResolved: boolean;
235
+ }
200
236
  /** The mesh client's enriched per-peer state snapshot. Mirrors the
201
237
  * underlying {@link MeshWebRTCAdapter.getPeerStateSnapshot} shape but
202
238
  * replaces the slot's `handles` map with the Repo-enriched view
@@ -211,6 +247,19 @@ export interface MeshClientPeerStateSnapshot {
211
247
  handles: Record<string, MeshClientHandleSnapshot>;
212
248
  });
213
249
  }>;
250
+ /** polly#107 H5 diagnostics. See {@link MeshStateModuleDiagnostics}. */
251
+ meshStateModule: MeshStateModuleDiagnostics;
252
+ /** Count of handles known to the Repo this client owns. Compared
253
+ * to the count the consumer's `$meshState` wrappers should have
254
+ * registered: a mismatch (e.g. consumer pre-warmed 14 wrappers,
255
+ * snapshot reports 1) confirms the H5 module-duplication
256
+ * fingerprint without needing a separate read. */
257
+ repoHandleCount: number;
258
+ /** All handle ids the Repo this client owns currently caches.
259
+ * Together with `repoHandleCount` and `meshStateModule.moduleId`,
260
+ * this answers "did the consumer's wrappers land their handles in
261
+ * THIS Repo?" in one read. */
262
+ repoHandleIds: string[];
214
263
  }
215
264
  /** Handle returned by {@link createMeshClient}. */
216
265
  export interface MeshClient {
@@ -56,6 +56,41 @@ export interface MeshStateOptions {
56
56
  * a public-key set used by the signing layer to verify incoming ops. */
57
57
  access?: Access;
58
58
  }
59
+ /** Per-module-instance identifier stamped at import time. Two distinct
60
+ * module instances (e.g. duplicated under a bundler that hoists
61
+ * differently for the consumer's app code and `@fairfox/polly`'s own
62
+ * imports) produce two different ids — and therefore two different
63
+ * `defaultRepo` globals.
64
+ *
65
+ * The polly#107 fingerprint reading is exactly that: `configureMeshState`
66
+ * runs on one module instance (the one `createMeshClient` imports);
67
+ * the consumer's `$meshState(key, initial)` calls run on a different
68
+ * instance, whose `defaultRepo` was never set. `resolveRepo` either
69
+ * throws (caught silently by consumer wrappers) or returns the
70
+ * unconfigured fallback — either way, the handle that should land
71
+ * in the mesh `Repo` lands somewhere else (or nowhere), Automerge's
72
+ * NetworkSubsystem never sees it, and inbound sync from the daemon
73
+ * has nowhere to go.
74
+ *
75
+ * Exported so consumers can compare the id seen at the `$meshState`
76
+ * call site against the id seen at the `configureMeshState` call
77
+ * site. A mismatch IS the bundle-duplication bug; a match rules it
78
+ * out. The id is also surfaced via {@link getMeshStateModuleId} on
79
+ * every `MeshClient.getPeerStateSnapshot()` so a single one-line
80
+ * read from the failing tab tells the operator which module
81
+ * instance the snapshot is rendered from.
82
+ *
83
+ * Polly issue #107 H5 (mesh-state module duplication). */
84
+ export declare const MESH_STATE_MODULE_ID: string;
85
+ /** Returns the per-module-instance id stamped at import time. See
86
+ * {@link MESH_STATE_MODULE_ID}. */
87
+ export declare function getMeshStateModuleId(): string;
88
+ /** Returns the `peerId` of the most recent Repo wired through
89
+ * {@link configureMeshState} against this module instance. Surfaced
90
+ * via the mesh client snapshot so a consumer can answer "did
91
+ * configureMeshState run on the same module instance the wrappers
92
+ * are using" in one read. */
93
+ export declare function getLastConfiguredRepoPeerId(): string | undefined;
59
94
  /**
60
95
  * Set the default Repo that the $mesh* primitives use when no `repo` option
61
96
  * is supplied. Production code typically calls this once at application
@@ -68,6 +103,16 @@ export declare function configureMeshState(repo: Repo): void;
68
103
  * Intended for tests; production code should not call this.
69
104
  */
70
105
  export declare function resetMeshState(): void;
106
+ /** Returns whether this module instance's `defaultRepo` was ever
107
+ * set via {@link configureMeshState}. Distinct from "was set and
108
+ * then reset" — `resetMeshState` clears it. The polly#107 H5
109
+ * fingerprint is `false` here on the module instance the consumer's
110
+ * `$meshState` calls resolve from. */
111
+ export declare function isMeshStateConfigured(): boolean;
112
+ /** Returns `true` once any `$meshState`-family wrapper has been
113
+ * called against this module instance. See
114
+ * {@link meshStateEverResolved}. */
115
+ export declare function wasMeshStateResolved(): boolean;
71
116
  /**
72
117
  * Create a peer-replicated state primitive backed by Automerge with a mesh
73
118
  * transport. Every device holds a full replica; no central server holds a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairfox/polly",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Multi-execution-context framework with reactive state and cross-context messaging for Chrome extensions, PWAs, and worker-based applications",