@fairfox/polly 0.72.0 → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/elysia/index.js +464 -4
- package/dist/src/elysia/index.js.map +6 -4
- package/dist/src/peer.d.ts +2 -0
- package/dist/src/peer.js +468 -4
- package/dist/src/peer.js.map +8 -5
- package/dist/src/polly-ui/ActionInput.d.ts +2 -1
- package/dist/src/polly-ui/ActionSelect.d.ts +2 -1
- package/dist/src/polly-ui/Button.d.ts +4 -0
- package/dist/src/polly-ui/Cluster.d.ts +2 -1
- package/dist/src/polly-ui/Code.d.ts +2 -1
- package/dist/src/polly-ui/Dropdown.d.ts +6 -0
- package/dist/src/polly-ui/Surface.d.ts +12 -1
- package/dist/src/polly-ui/Text.d.ts +23 -11
- package/dist/src/polly-ui/index.css +44 -18
- package/dist/src/polly-ui/index.js +118 -12
- package/dist/src/polly-ui/index.js.map +12 -11
- package/dist/src/polly-ui/internal/passthrough.d.ts +25 -0
- package/dist/src/polly-ui/styles.css +59 -18
- package/dist/src/polly-ui/theme.css +1 -0
- package/dist/src/shared/lib/peer-repo-server.d.ts +18 -0
- package/dist/src/shared/lib/sweep-sealed.d.ts +111 -0
- package/dist/tools/test/src/browser/run.js +42 -33
- package/dist/tools/test/src/browser/run.js.map +6 -5
- package/dist/tools/test/src/browser/runner-core.d.ts +32 -0
- package/dist/tools/test/src/e2e-mesh/index.js +193 -171
- package/dist/tools/test/src/e2e-mesh/index.js.map +4 -4
- package/dist/tools/test/src/visual/index.js +248 -229
- package/dist/tools/test/src/visual/index.js.map +5 -5
- package/dist/tools/verify/specs/tla/MeshSeed.cfg +27 -0
- package/dist/tools/verify/specs/tla/MeshSeed.tla +179 -0
- package/dist/tools/verify/specs/tla/README.md +11 -1
- package/dist/tools/verify/src/cli.js +79 -2
- package/dist/tools/verify/src/cli.js.map +7 -6
- package/dist/tools/visualize/src/cli.js +179 -3
- package/dist/tools/visualize/src/cli.js.map +6 -6
- package/package.json +3 -2
package/dist/src/peer.js.map
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/shared/lib/encryption.ts", "../src/shared/lib/wasm-init.ts", "../src/shared/lib/crdt-specialised.ts", "../src/shared/lib/migrate-primitive.ts", "../src/shared/lib/primitive-registry.ts", "../src/shared/lib/schema-version.ts", "../src/shared/lib/crdt-state.ts", "../src/shared/lib/peer-relay-adapter.ts", "../src/shared/lib/mesh-network-adapter.ts", "../src/shared/lib/mesh-diagnostics.ts", "../src/shared/lib/signing.ts", "../src/shared/lib/peer-repo-server.ts", "../src/shared/lib/peer-state.ts"],
|
|
3
|
+
"sources": ["../src/shared/lib/encryption.ts", "node:path", "../src/shared/lib/sweep-sealed.ts", "../src/shared/lib/wasm-init.ts", "../src/shared/lib/crdt-specialised.ts", "../src/shared/lib/migrate-primitive.ts", "../src/shared/lib/primitive-registry.ts", "../src/shared/lib/schema-version.ts", "../src/shared/lib/crdt-state.ts", "../src/shared/lib/peer-relay-adapter.ts", "../src/shared/lib/mesh-network-adapter.ts", "../src/shared/lib/mesh-diagnostics.ts", "../src/shared/lib/signing.ts", "../src/shared/lib/peer-repo-server.ts", "../src/shared/lib/peer-state.ts", "../src/peer.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * encryption — symmetric authenticated encryption for Polly's $meshState\n * primitive (Phase 2). Wraps tweetnacl's secretbox (XSalsa20-Poly1305) with\n * a small Polly-flavoured API so the rest of the codebase never imports\n * tweetnacl directly.\n *\n * Every $meshState document has a per-document symmetric key that is\n * provisioned to authorised peers at pairing time and never held by any\n * server. Outgoing operations are encrypted under this key before they\n * touch the network adapter; incoming operations are decrypted on receipt.\n * The signing layer in {@link signing.ts} provides authenticity (proof of\n * who sent the message); this layer provides confidentiality (the bytes\n * are unreadable to anything that does not hold the document key).\n *\n * tweetnacl's secretbox uses a 32-byte symmetric key and a 24-byte nonce.\n * The output of `nacl.secretbox` is the ciphertext concatenated with a\n * 16-byte Poly1305 authentication tag. We package the nonce + ciphertext\n * into a single binary blob using a small length-prefixed envelope so the\n * receiver can recover the nonce without out-of-band coordination.\n *\n * - {@link generateDocumentKey} returns a fresh 32-byte symmetric key.\n *\n * - {@link encrypt} produces a sealed blob from a payload and a key.\n *\n * - {@link decrypt} recovers the payload from a sealed blob and a key.\n * Returns undefined if the blob is malformed or the authentication\n * tag does not match (i.e. wrong key or tampered ciphertext) — the\n * undefined signal lets call sites distinguish \"wrong key\" from\n * \"structurally invalid\" without throwing.\n *\n * - {@link sealEnvelope} and {@link openEnvelope} are convenience helpers\n * that wrap encrypt/decrypt in a structured EncryptedEnvelope shape so\n * the mesh transport layer can handle the binary plumbing uniformly.\n */\n\nimport nacl from \"tweetnacl\";\n\n/** Length in bytes of a secretbox symmetric key. */\nexport const KEY_BYTES = 32;\n/** Length in bytes of a secretbox nonce. */\nexport const NONCE_BYTES = 24;\n/** Length in bytes of the Poly1305 authentication tag. */\nexport const TAG_BYTES = 16;\n\n/**\n * A sealed blob suitable for storage or network transmission. The wire\n * layout is the concatenation of the nonce and the ciphertext+tag from\n * tweetnacl. Callers should not depend on the exact bytes — round-trip\n * through {@link encrypt} / {@link decrypt} or the envelope helpers.\n */\nexport type SealedBytes = Uint8Array;\n\n/** Errors thrown by the encryption subsystem. */\nexport class EncryptionError extends Error {\n readonly code: \"invalid-key-length\" | \"decrypt-failed\" | \"envelope-malformed\";\n constructor(message: string, code: EncryptionError[\"code\"]) {\n super(message);\n this.name = \"EncryptionError\";\n this.code = code;\n }\n}\n\n/**\n * Generate a fresh 32-byte symmetric document key. Calls into tweetnacl's\n * CSPRNG.\n */\nexport function generateDocumentKey(): Uint8Array {\n return nacl.randomBytes(KEY_BYTES);\n}\n\n/**\n * Encrypt a payload under a symmetric key. The returned blob includes a\n * fresh nonce so the receiver does not need any out-of-band coordination\n * to decrypt.\n */\nexport function encrypt(payload: Uint8Array, key: Uint8Array): SealedBytes {\n if (key.length !== KEY_BYTES) {\n throw new EncryptionError(\n `secretbox key must be ${KEY_BYTES} bytes, got ${key.length}.`,\n \"invalid-key-length\"\n );\n }\n const nonce = nacl.randomBytes(NONCE_BYTES);\n const ciphertext = nacl.secretbox(payload, nonce, key);\n const out = new Uint8Array(NONCE_BYTES + ciphertext.length);\n out.set(nonce, 0);\n out.set(ciphertext, NONCE_BYTES);\n return out;\n}\n\n/**\n * Decrypt a sealed blob under a symmetric key. Returns the original\n * payload on success. Returns undefined if the blob is too short to\n * contain a nonce and tag, or if the authentication tag does not match\n * (which indicates either a wrong key or a tampered ciphertext).\n *\n * The undefined return is deliberate: call sites typically want to fall\n * back to a different key or surface a \"could not decrypt\" message rather\n * than catching an exception. Use {@link decryptOrThrow} when an exception\n * is preferred.\n */\nexport function decrypt(sealed: SealedBytes, key: Uint8Array): Uint8Array | undefined {\n if (key.length !== KEY_BYTES) {\n throw new EncryptionError(\n `secretbox key must be ${KEY_BYTES} bytes, got ${key.length}.`,\n \"invalid-key-length\"\n );\n }\n if (sealed.length < NONCE_BYTES + TAG_BYTES) {\n return undefined;\n }\n const nonce = sealed.subarray(0, NONCE_BYTES);\n const ciphertext = sealed.subarray(NONCE_BYTES);\n const opened = nacl.secretbox.open(ciphertext, nonce, key);\n return opened ?? undefined;\n}\n\n/**\n * Decrypt a sealed blob, throwing {@link EncryptionError} on failure\n * instead of returning undefined.\n */\nexport function decryptOrThrow(sealed: SealedBytes, key: Uint8Array): Uint8Array {\n const opened = decrypt(sealed, key);\n if (!opened) {\n throw new EncryptionError(\n `Failed to decrypt sealed blob: wrong key, malformed input, or tampered ciphertext.`,\n \"decrypt-failed\"\n );\n }\n return opened;\n}\n\n/**\n * A high-level structured envelope combining encryption with a small\n * amount of metadata the receiver needs to find the right key. The mesh\n * network adapter uses this shape on the wire.\n */\nexport interface EncryptedEnvelope {\n /** Stable identifier for the document this payload belongs to. The\n * receiver looks this up in its local key store to find the right key. */\n documentId: string;\n /** Sealed blob containing the encrypted payload plus its nonce. */\n sealed: SealedBytes;\n}\n\n/**\n * Encrypt a payload and pack it into an {@link EncryptedEnvelope} along\n * with the document id.\n */\nexport function sealEnvelope(\n payload: Uint8Array,\n documentId: string,\n key: Uint8Array\n): EncryptedEnvelope {\n return {\n documentId,\n sealed: encrypt(payload, key),\n };\n}\n\n/**\n * Decrypt an {@link EncryptedEnvelope} using the given key. Throws on\n * failure for symmetry with {@link sealEnvelope}.\n */\nexport function openEnvelope(envelope: EncryptedEnvelope, key: Uint8Array): Uint8Array {\n return decryptOrThrow(envelope.sealed, key);\n}\n\n/**\n * Serialise an {@link EncryptedEnvelope} to a single binary blob.\n *\n * Wire format:\n *\n * [4 bytes BE: documentId byte length]\n * [N bytes: documentId UTF-8]\n * [remaining: sealed blob (nonce + ciphertext + tag)]\n */\nexport function encodeEncryptedEnvelope(envelope: EncryptedEnvelope): Uint8Array {\n const idBytes = new TextEncoder().encode(envelope.documentId);\n const out = new Uint8Array(4 + idBytes.length + envelope.sealed.length);\n const view = new DataView(out.buffer);\n view.setUint32(0, idBytes.length, false);\n out.set(idBytes, 4);\n out.set(envelope.sealed, 4 + idBytes.length);\n return out;\n}\n\n/**\n * Deserialise a binary envelope produced by {@link encodeEncryptedEnvelope}.\n * Throws on malformed input.\n */\nexport function decodeEncryptedEnvelope(bytes: Uint8Array): EncryptedEnvelope {\n if (bytes.length < 4) {\n throw new EncryptionError(\n `Encrypted envelope too short: ${bytes.length} bytes.`,\n \"envelope-malformed\"\n );\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const idLen = view.getUint32(0, false);\n if (bytes.length < 4 + idLen) {\n throw new EncryptionError(\n `Encrypted envelope truncated: declared id length ${idLen}, total ${bytes.length}.`,\n \"envelope-malformed\"\n );\n }\n const documentId = new TextDecoder().decode(bytes.subarray(4, 4 + idLen));\n const sealed = bytes.slice(4 + idLen);\n return { documentId, sealed };\n}\n",
|
|
6
|
+
"function assertPath(path){if(typeof path!==\"string\")throw TypeError(\"Path must be a string. Received \"+JSON.stringify(path))}function normalizeStringPosix(path,allowAboveRoot){var res=\"\",lastSegmentLength=0,lastSlash=-1,dots=0,code;for(var i=0;i<=path.length;++i){if(i<path.length)code=path.charCodeAt(i);else if(code===47)break;else code=47;if(code===47){if(lastSlash===i-1||dots===1);else if(lastSlash!==i-1&&dots===2){if(res.length<2||lastSegmentLength!==2||res.charCodeAt(res.length-1)!==46||res.charCodeAt(res.length-2)!==46){if(res.length>2){var lastSlashIndex=res.lastIndexOf(\"/\");if(lastSlashIndex!==res.length-1){if(lastSlashIndex===-1)res=\"\",lastSegmentLength=0;else res=res.slice(0,lastSlashIndex),lastSegmentLength=res.length-1-res.lastIndexOf(\"/\");lastSlash=i,dots=0;continue}}else if(res.length===2||res.length===1){res=\"\",lastSegmentLength=0,lastSlash=i,dots=0;continue}}if(allowAboveRoot){if(res.length>0)res+=\"/..\";else res=\"..\";lastSegmentLength=2}}else{if(res.length>0)res+=\"/\"+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1}lastSlash=i,dots=0}else if(code===46&&dots!==-1)++dots;else dots=-1}return res}function _format(sep,pathObject){var dir=pathObject.dir||pathObject.root,base=pathObject.base||(pathObject.name||\"\")+(pathObject.ext||\"\");if(!dir)return base;if(dir===pathObject.root)return dir+base;return dir+sep+base}function resolve(){var resolvedPath=\"\",resolvedAbsolute=!1,cwd;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path;if(i>=0)path=arguments[i];else{if(cwd===void 0)cwd=process.cwd();path=cwd}if(assertPath(path),path.length===0)continue;resolvedPath=path+\"/\"+resolvedPath,resolvedAbsolute=path.charCodeAt(0)===47}if(resolvedPath=normalizeStringPosix(resolvedPath,!resolvedAbsolute),resolvedAbsolute)if(resolvedPath.length>0)return\"/\"+resolvedPath;else return\"/\";else if(resolvedPath.length>0)return resolvedPath;else return\".\"}function normalize(path){if(assertPath(path),path.length===0)return\".\";var isAbsolute=path.charCodeAt(0)===47,trailingSeparator=path.charCodeAt(path.length-1)===47;if(path=normalizeStringPosix(path,!isAbsolute),path.length===0&&!isAbsolute)path=\".\";if(path.length>0&&trailingSeparator)path+=\"/\";if(isAbsolute)return\"/\"+path;return path}function isAbsolute(path){return assertPath(path),path.length>0&&path.charCodeAt(0)===47}function join(){if(arguments.length===0)return\".\";var joined;for(var i=0;i<arguments.length;++i){var arg=arguments[i];if(assertPath(arg),arg.length>0)if(joined===void 0)joined=arg;else joined+=\"/\"+arg}if(joined===void 0)return\".\";return normalize(joined)}function relative(from,to){if(assertPath(from),assertPath(to),from===to)return\"\";if(from=resolve(from),to=resolve(to),from===to)return\"\";var fromStart=1;for(;fromStart<from.length;++fromStart)if(from.charCodeAt(fromStart)!==47)break;var fromEnd=from.length,fromLen=fromEnd-fromStart,toStart=1;for(;toStart<to.length;++toStart)if(to.charCodeAt(toStart)!==47)break;var toEnd=to.length,toLen=toEnd-toStart,length=fromLen<toLen?fromLen:toLen,lastCommonSep=-1,i=0;for(;i<=length;++i){if(i===length){if(toLen>length){if(to.charCodeAt(toStart+i)===47)return to.slice(toStart+i+1);else if(i===0)return to.slice(toStart+i)}else if(fromLen>length){if(from.charCodeAt(fromStart+i)===47)lastCommonSep=i;else if(i===0)lastCommonSep=0}break}var fromCode=from.charCodeAt(fromStart+i),toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===47)lastCommonSep=i}var out=\"\";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i)if(i===fromEnd||from.charCodeAt(i)===47)if(out.length===0)out+=\"..\";else out+=\"/..\";if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{if(toStart+=lastCommonSep,to.charCodeAt(toStart)===47)++toStart;return to.slice(toStart)}}function _makeLong(path){return path}function dirname(path){if(assertPath(path),path.length===0)return\".\";var code=path.charCodeAt(0),hasRoot=code===47,end=-1,matchedSlash=!0;for(var i=path.length-1;i>=1;--i)if(code=path.charCodeAt(i),code===47){if(!matchedSlash){end=i;break}}else matchedSlash=!1;if(end===-1)return hasRoot?\"/\":\".\";if(hasRoot&&end===1)return\"//\";return path.slice(0,end)}function basename(path,ext){if(ext!==void 0&&typeof ext!==\"string\")throw TypeError('\"ext\" argument must be a string');assertPath(path);var start=0,end=-1,matchedSlash=!0,i;if(ext!==void 0&&ext.length>0&&ext.length<=path.length){if(ext.length===path.length&&ext===path)return\"\";var extIdx=ext.length-1,firstNonSlashEnd=-1;for(i=path.length-1;i>=0;--i){var code=path.charCodeAt(i);if(code===47){if(!matchedSlash){start=i+1;break}}else{if(firstNonSlashEnd===-1)matchedSlash=!1,firstNonSlashEnd=i+1;if(extIdx>=0)if(code===ext.charCodeAt(extIdx)){if(--extIdx===-1)end=i}else extIdx=-1,end=firstNonSlashEnd}}if(start===end)end=firstNonSlashEnd;else if(end===-1)end=path.length;return path.slice(start,end)}else{for(i=path.length-1;i>=0;--i)if(path.charCodeAt(i)===47){if(!matchedSlash){start=i+1;break}}else if(end===-1)matchedSlash=!1,end=i+1;if(end===-1)return\"\";return path.slice(start,end)}}function extname(path){assertPath(path);var startDot=-1,startPart=0,end=-1,matchedSlash=!0,preDotState=0;for(var i=path.length-1;i>=0;--i){var code=path.charCodeAt(i);if(code===47){if(!matchedSlash){startPart=i+1;break}continue}if(end===-1)matchedSlash=!1,end=i+1;if(code===46){if(startDot===-1)startDot=i;else if(preDotState!==1)preDotState=1}else if(startDot!==-1)preDotState=-1}if(startDot===-1||end===-1||preDotState===0||preDotState===1&&startDot===end-1&&startDot===startPart+1)return\"\";return path.slice(startDot,end)}function format(pathObject){if(pathObject===null||typeof pathObject!==\"object\")throw TypeError('The \"pathObject\" argument must be of type Object. Received type '+typeof pathObject);return _format(\"/\",pathObject)}function parse(path){assertPath(path);var ret={root:\"\",dir:\"\",base:\"\",ext:\"\",name:\"\"};if(path.length===0)return ret;var code=path.charCodeAt(0),isAbsolute2=code===47,start;if(isAbsolute2)ret.root=\"/\",start=1;else start=0;var startDot=-1,startPart=0,end=-1,matchedSlash=!0,i=path.length-1,preDotState=0;for(;i>=start;--i){if(code=path.charCodeAt(i),code===47){if(!matchedSlash){startPart=i+1;break}continue}if(end===-1)matchedSlash=!1,end=i+1;if(code===46){if(startDot===-1)startDot=i;else if(preDotState!==1)preDotState=1}else if(startDot!==-1)preDotState=-1}if(startDot===-1||end===-1||preDotState===0||preDotState===1&&startDot===end-1&&startDot===startPart+1){if(end!==-1)if(startPart===0&&isAbsolute2)ret.base=ret.name=path.slice(1,end);else ret.base=ret.name=path.slice(startPart,end)}else{if(startPart===0&&isAbsolute2)ret.name=path.slice(1,startDot),ret.base=path.slice(1,end);else ret.name=path.slice(startPart,startDot),ret.base=path.slice(startPart,end);ret.ext=path.slice(startDot,end)}if(startPart>0)ret.dir=path.slice(0,startPart-1);else if(isAbsolute2)ret.dir=\"/\";return ret}var sep=\"/\",delimiter=\":\",posix=((p)=>(p.posix=p,p))({resolve,normalize,isAbsolute,join,relative,_makeLong,dirname,basename,extname,format,parse,sep,delimiter,win32:null,posix:null});var path_default=posix;export{sep,resolve,relative,posix,parse,normalize,join,isAbsolute,format,extname,dirname,delimiter,path_default as default,basename,_makeLong};",
|
|
7
|
+
"/**\n * `sweepSealed` — storage-adapter garbage collection of sealed mesh-doc\n * bytes (polly#121).\n *\n * When a consumer compacts a `$meshState` document it seeds a fresh\n * successor and leaves an in-band sentinel in the old document. polly's\n * {@link RedirectDetector} follows that sentinel so live wrappers rebind\n * transparently — but the old document's bytes then sit in storage\n * forever, because nothing removes them.\n *\n * `sweepSealed` is that missing GC step. polly owns the walk, the\n * open-handle gate, the age window, the dry-run report and the byte\n * removal. The consumer owns the sentinel shape — it is the very\n * document the consumer's {@link RedirectDetector} already inspects —\n * supplied here as the {@link SweepSealedOptions.isSealed} predicate.\n * polly deliberately does not define a canonical sentinel format: that\n * would compete with the one consumers' detectors already read.\n *\n * polly never runs this on a timer. The consumer calls it explicitly.\n *\n * ## Redirect-index-not-yet-synced hazard\n *\n * A peer whose redirect index (`mesh:document-index`) has not yet synced\n * may still reach for a sealed document by its *old* docId. If the sweep\n * has just removed that document's bytes, the peer gets a\n * missing-document error instead of a redirect. Two gates bound the risk,\n * and the caller must size them deliberately:\n *\n * - `olderThan` — only documents sealed longer ago than this window are\n * swept. Make it comfortably larger than the worst-case time a peer\n * can stay offline-then-resync, so any peer that could still hold the\n * old docId has had the redirect delivered.\n * - the open-handle gate — a document with a live handle on the supplied\n * `repo` is never swept, regardless of age.\n *\n * Neither gate can see a peer that is currently offline; `olderThan` is\n * the only protection there. Choose it conservatively.\n */\n\nimport type {\n Chunk,\n DocumentId,\n Repo,\n StorageAdapterInterface,\n} from \"@automerge/automerge-repo/slim\";\nimport { Automerge } from \"@automerge/automerge-repo/slim\";\n\nexport interface SweepSealedOptions {\n /** The Repo whose storage is swept. Its open handles gate removal. */\n repo: Repo;\n /** The storage adapter backing {@link repo}. */\n storage: StorageAdapterInterface;\n /**\n * Predicate that recognises a sealed document. Given a materialised\n * document, returns the epoch-ms timestamp at which it was sealed, or\n * `undefined` if the document is not sealed.\n *\n * This is the same document the consumer's {@link RedirectDetector}\n * inspects: the consumer owns the sentinel shape, polly never defines\n * it. The returned timestamp feeds both the {@link olderThan} filter\n * and the dry-run report.\n */\n isSealed: (doc: unknown) => number | undefined;\n /** Sweep only documents sealed more than this many milliseconds ago. */\n olderThan: number;\n /**\n * The candidate documents to consider. When omitted, the sweep\n * enumerates the whole adapter via `storage.loadRange([])`.\n *\n * That whole-adapter enumeration works for the IndexedDB and\n * in-memory adapters but **not** the NodeFS adapter, whose `loadRange`\n * requires at least a documentId prefix. Server-side callers should\n * use {@link PeerRepoServer.sweepSealed}, which enumerates the\n * filesystem and supplies this list; per-document `loadRange` then\n * works on every adapter.\n */\n documentIds?: Iterable<string>;\n /** When true, report candidates without removing anything. */\n dryRun?: boolean;\n /** Clock source, injectable for tests. Defaults to {@link Date.now}. */\n now?: () => number;\n}\n\n/** A document removed by the sweep — or, under `dryRun`, that would be. */\nexport interface SweptDoc {\n documentId: DocumentId;\n /** Epoch-ms the document was sealed, as reported by `isSealed`. */\n sealedAt: number;\n /** Total bytes across the document's storage chunks. */\n byteSize: number;\n}\n\n/** Why a sealed document was left in place rather than swept. */\nexport type KeptReason = \"open-handle\" | \"too-recent\";\n\n/** A sealed document the sweep deliberately did not remove. */\nexport interface KeptDoc {\n documentId: DocumentId;\n reason: KeptReason;\n}\n\nexport interface SweepResult {\n /** Documents removed — or, under `dryRun`, that would be removed. */\n swept: SweptDoc[];\n /** Sealed documents deliberately left in place, with the reason. */\n kept: KeptDoc[];\n /** Echoes the `dryRun` flag the sweep ran under. */\n dryRun: boolean;\n}\n\n/** Concatenate chunk payloads into one buffer for a single load call. */\nfunction concat(parts: Uint8Array[]): Uint8Array {\n let total = 0;\n for (const part of parts) total += part.byteLength;\n const out = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n\n/**\n * Materialise a document from its storage chunks. Snapshot chunks are\n * loaded before incrementals so the loader has its base first;\n * `sync-state` chunks are not document data and are excluded. A document\n * whose bytes fail to load (corrupt or partial) yields `undefined` and\n * is left untouched by the sweep.\n */\nfunction materialise(chunks: Chunk[]): unknown | undefined {\n const content = chunks\n .filter((chunk) => chunk.key[1] !== \"sync-state\" && chunk.data !== undefined)\n .sort((a, b) => (a.key[1] === \"snapshot\" ? 0 : 1) - (b.key[1] === \"snapshot\" ? 0 : 1));\n if (content.length === 0) return undefined;\n try {\n return Automerge.loadIncremental(\n Automerge.init(),\n concat(content.map((chunk) => chunk.data as Uint8Array))\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * Load the storage chunks for every candidate document and group the\n * flat chunk stream back into documents keyed by documentId.\n *\n * Each storage key is `[documentId, chunkType, chunkId]`. With an\n * explicit `documentIds` list each document is loaded by its own prefix\n * (supported by every adapter); without one, a whole-adapter\n * `loadRange([])` is used (supported by IndexedDB and in-memory adapters,\n * but not NodeFS — see {@link SweepSealedOptions.documentIds}).\n */\nasync function collectChunksByDocument(\n storage: StorageAdapterInterface,\n documentIds: Iterable<string> | undefined\n): Promise<Map<string, Chunk[]>> {\n const chunks: Chunk[] = [];\n if (documentIds === undefined) {\n chunks.push(...(await storage.loadRange([])));\n } else {\n for (const documentId of documentIds) {\n chunks.push(...(await storage.loadRange([documentId])));\n }\n }\n\n const byDocument = new Map<string, Chunk[]>();\n for (const chunk of chunks) {\n const documentId = chunk.key[0];\n if (documentId === undefined) continue;\n const existing = byDocument.get(documentId);\n if (existing) existing.push(chunk);\n else byDocument.set(documentId, [chunk]);\n }\n return byDocument;\n}\n\n/** The sweep's decision for one document. */\ntype Verdict =\n | { action: \"sweep\"; entry: SweptDoc }\n | { action: \"keep\"; entry: KeptDoc }\n | { action: \"ignore\" };\n\n/**\n * Decide what to do with one document: ignore it if it does not load or\n * is not sealed; keep it if it has an open handle or was sealed too\n * recently; otherwise mark it for sweeping.\n */\nfunction classifyDocument(\n documentId: string,\n chunks: Chunk[],\n context: {\n repo: Repo;\n isSealed: (doc: unknown) => number | undefined;\n olderThan: number;\n at: number;\n }\n): Verdict {\n const doc = materialise(chunks);\n if (doc === undefined) return { action: \"ignore\" };\n\n const sealedAt = context.isSealed(doc);\n if (sealedAt === undefined) return { action: \"ignore\" }; // not sealed — never swept\n\n const id = documentId as DocumentId;\n\n // Open-handle gate: a document with a live handle on this Repo is\n // never swept, regardless of age.\n if (context.repo.handles[id] !== undefined) {\n return { action: \"keep\", entry: { documentId: id, reason: \"open-handle\" } };\n }\n\n // Age gate: only documents sealed longer ago than the window.\n if (context.at - sealedAt < context.olderThan) {\n return { action: \"keep\", entry: { documentId: id, reason: \"too-recent\" } };\n }\n\n const byteSize = chunks.reduce((sum, chunk) => sum + (chunk.data?.byteLength ?? 0), 0);\n return { action: \"sweep\", entry: { documentId: id, sealedAt, byteSize } };\n}\n\n/**\n * Garbage-collect sealed mesh-doc bytes from a Repo's storage adapter.\n *\n * Walks every candidate document, materialises it, and asks\n * {@link SweepSealedOptions.isSealed} whether it is sealed. A sealed\n * document is removed only when it has no open handle on the Repo *and*\n * was sealed longer ago than `olderThan`; otherwise it is reported under\n * `kept` with the reason. Unsealed documents are never touched and never\n * reported. With `dryRun`, candidates are reported but nothing is removed.\n *\n * See the module doc comment for the redirect-index-not-yet-synced\n * hazard that `olderThan` and the open-handle gate exist to bound.\n */\nexport async function sweepSealed(options: SweepSealedOptions): Promise<SweepResult> {\n const { repo, storage, isSealed, olderThan } = options;\n const dryRun = options.dryRun ?? false;\n const now = options.now ?? Date.now;\n\n const byDocument = await collectChunksByDocument(storage, options.documentIds);\n\n const swept: SweptDoc[] = [];\n const kept: KeptDoc[] = [];\n const at = now();\n\n for (const [documentId, chunks] of byDocument) {\n const verdict = classifyDocument(documentId, chunks, { repo, isSealed, olderThan, at });\n if (verdict.action === \"keep\") {\n kept.push(verdict.entry);\n } else if (verdict.action === \"sweep\") {\n swept.push(verdict.entry);\n if (!dryRun) await storage.removeRange([documentId]);\n }\n }\n\n return { swept, kept, dryRun };\n}\n",
|
|
6
8
|
"/**\n * Eagerly initialise Automerge's WebAssembly runtime by pointing the library\n * at the raw `.wasm` file shipped in `@automerge/automerge`.\n *\n * The `import.meta.url` pattern below is recognised by every modern bundler\n * (Bun, Vite, webpack 5+, esbuild) as an asset reference: the `.wasm` gets\n * copied into the consumer's output alongside the JavaScript, and the URL is\n * rewritten to point at the copied file. `initializeWasm` then fetches and\n * instantiates it at runtime. That keeps the WebAssembly out of the JavaScript\n * bundle entirely — no megabyte-scale base64 string inlined per subpath — and\n * lets the browser parse the JS and stream-compile the `.wasm` in parallel.\n *\n * The top-level `await` makes this module async so any consumer that\n * transitively imports it inherits the \"wait for WASM\" behaviour through the\n * import graph, without needing an explicit init call.\n */\n\nimport wasmPath from \"@automerge/automerge/automerge.wasm\";\nimport { initializeWasm } from \"@automerge/automerge-repo/slim\";\n\n// Bun's file loader returns a relative path; resolving it against the\n// current module's URL yields an absolute URL that fetches correctly\n// regardless of where the consumer's bundler places the script.\nconst wasmUrl = new URL(wasmPath, import.meta.url).href;\n\nawait initializeWasm(wasmUrl);\n",
|
|
7
9
|
"/**\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 { Automerge, 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 /** Number of Automerge changes recorded on the current doc, or\n * `undefined` while {@link loaded} is still pending. Stable proxy\n * for the incremental-chunk count the storage adapter writes. See\n * the matching field on {@link CrdtPrimitive} and RFC-041\n * §History growth. */\n readonly changeCount: number | 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 get changeCount() {\n if (!currentHandle) return undefined;\n const doc = currentHandle.doc();\n if (!doc) return undefined;\n return Automerge.getAllChanges(doc).length;\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",
|
|
8
10
|
"/**\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",
|
|
@@ -13,10 +15,11 @@
|
|
|
13
15
|
"/**\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 { emitMeshDiagnostic } from \"./mesh-diagnostics\";\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 * Control-message type tags. Every mesh message carries a single tag\n * byte at the front of its plaintext payload, after decryption and\n * signature verification. The tag discriminates the inner contents so\n * future control flows (RFC-043 revocation propagation, future RFCs)\n * can share the same encrypted-signed envelope without re-versioning.\n *\n * 0x00 is the default Automerge sync-message channel that polly has\n * carried since the first cut. 0x01 and 0x02 are reserved for the\n * revocation flow designed in RFC-043; the adapter recognises them at\n * receive time but does not yet act on the payload — that lands in\n * the second RFC-043 PR. Tags 0x03 and above are unassigned; a\n * receiver that sees one emits `drop:unknown-control-type` and the\n * message is dropped.\n *\n * Wire format break: polly 0.70 and earlier do not prepend the tag\n * and do not strip it on receive. Mixing 0.70 and 0.71-plus peers on\n * the same mesh produces garbage on both sides. The break is\n * acknowledged in RFC-043 and required for the protocol-level\n * revocation feature; the alternative (a separate WebRTC data\n * channel) doubles transport complexity.\n */\nexport const MESH_CONTROL_TYPE = {\n /** Automerge sync message — the default channel. */\n Sync: 0x00,\n /** A signed RevocationRecord (RFC-043). Receive-side dispatch is\n * wired in this PR; the apply-and-persist behaviour lands in the\n * next RFC-043 PR. */\n Revocation: 0x01,\n /** A revocation-set summary exchanged on every new peer connection\n * to gossip revocations to peers that were offline at issue-time\n * (RFC-043). Same staging as Revocation. */\n RevocationSummary: 0x02,\n} as const;\nexport type MeshControlType = (typeof MESH_CONTROL_TYPE)[keyof typeof MESH_CONTROL_TYPE];\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 * Optional handler for non-Sync control messages (RFC-043). Called\n * after signature verification and decryption with the type tag,\n * the body bytes that followed the tag, and the verified senderId.\n * The handler owns the apply-and-persist behaviour for whichever\n * control flow the tag belongs to; the adapter routes only.\n *\n * The handler is called *after* the corresponding `ctrl:*-received`\n * diagnostic fires, so subscribers observing the low-level signal\n * see the event before the handler mutates any application state.\n * Handler exceptions are swallowed by the adapter — a buggy handler\n * cannot tear the network path — but a diagnostic\n * `drop:control-handler-threw` is emitted so the failure is\n * observable.\n */\n onControlMessage?: (tag: number, body: Uint8Array, senderId: string) => void;\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 readonly onControlMessage:\n | ((tag: number, body: Uint8Array, senderId: string) => void)\n | undefined;\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 this.onControlMessage = options.onControlMessage;\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 * The serialised Automerge message is prefixed with a one-byte\n * control-type tag (RFC-043). For outgoing Automerge sync this is\n * always {@link MESH_CONTROL_TYPE.Sync} (0x00); the tag exists so\n * future control flows (revocation propagation, revocation-set\n * summaries) can share the same encrypted-signed envelope without\n * re-versioning the wire format.\n */\n private wrap(message: Message): Message {\n const keyring = this.keyringSource();\n const serialised = serialiseMessage(message);\n const tagged = prependControlTag(MESH_CONTROL_TYPE.Sync, serialised);\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(tagged, DEFAULT_MESH_KEY_ID, docKey);\n payloadToSign = encodeEncryptedEnvelope(encrypted);\n } else {\n payloadToSign = tagged;\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 // Try to unwrap an incoming crypto-wrapped message. Returns the original\n // Message on success, undefined on verification or decryption failure.\n // Each silent-drop branch emits one typed diagnostic via\n // mesh-diagnostics; the per-branch mapping is the contract that module\n // advertises, which is why the function reads as seven sequential\n // checks rather than a collapsed helper.\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: seven silent-drop branches each emit one typed diagnostic — the per-branch contract is the source of truth the mesh-diagnostics stream advertises.\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 (err) {\n emitMeshDiagnostic({\n kind: \"drop:malformed-signed-envelope\",\n reason: err instanceof Error ? err.message : String(err),\n });\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 emitMeshDiagnostic({\n kind: \"drop:revoked-peer\",\n senderId: signed.senderId,\n });\n return undefined;\n }\n\n const senderKey = keyring.knownPeers.get(signed.senderId);\n if (!senderKey) {\n emitMeshDiagnostic({\n kind: \"drop:unknown-peer\",\n senderId: signed.senderId,\n });\n return undefined;\n }\n\n let verifiedPayload: Uint8Array;\n try {\n verifiedPayload = openSignedEnvelope(signed, senderKey);\n } catch (err) {\n emitMeshDiagnostic({\n kind: \"drop:bad-signature\",\n senderId: signed.senderId,\n reason: err instanceof Error ? err.message : String(err),\n });\n return undefined;\n }\n\n if (!this.encryptionEnabled) {\n // Sign-only mode: the verified payload IS the tagged plaintext.\n return this.dispatchTaggedPayload(verifiedPayload, signed.senderId);\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 (err) {\n emitMeshDiagnostic({\n kind: \"drop:malformed-encrypted-envelope\",\n senderId: signed.senderId,\n reason: err instanceof Error ? err.message : String(err),\n });\n return undefined;\n }\n\n const docKey = keyring.documentKeys.get(encrypted.documentId);\n if (!docKey) {\n emitMeshDiagnostic({\n kind: \"drop:missing-doc-key\",\n senderId: signed.senderId,\n documentId: encrypted.documentId,\n });\n return undefined;\n }\n\n let plaintext: Uint8Array;\n try {\n plaintext = openEncryptedEnvelope(encrypted, docKey);\n } catch (err) {\n emitMeshDiagnostic({\n kind: \"drop:bad-decryption\",\n senderId: signed.senderId,\n documentId: encrypted.documentId,\n reason: err instanceof Error ? err.message : String(err),\n });\n return undefined;\n }\n\n return this.dispatchTaggedPayload(plaintext, signed.senderId);\n }\n\n /**\n * Dispatch a verified-and-decrypted plaintext payload based on its\n * one-byte control-type tag (RFC-043). For {@link MESH_CONTROL_TYPE.Sync}\n * the remainder is the serialised Automerge message and is returned\n * to the caller. For revocation tags the dispatch emits a\n * `ctrl:*-received` diagnostic and drops the payload at this layer\n * pending the next RFC-043 PR. Unknown tags emit\n * `drop:unknown-control-type` and drop.\n */\n private dispatchTaggedPayload(payload: Uint8Array, senderId: string): Message | undefined {\n if (payload.byteLength < 1) {\n emitMeshDiagnostic({ kind: \"drop:empty-control-payload\", senderId });\n return undefined;\n }\n const tag = payload[0] as number;\n const body = payload.subarray(1);\n switch (tag) {\n case MESH_CONTROL_TYPE.Sync:\n return deserialiseMessage(body);\n case MESH_CONTROL_TYPE.Revocation:\n emitMeshDiagnostic({ kind: \"ctrl:revocation-received\", senderId });\n this.invokeControlHandler(tag, body, senderId);\n return undefined;\n case MESH_CONTROL_TYPE.RevocationSummary:\n emitMeshDiagnostic({\n kind: \"ctrl:revocation-summary-received\",\n senderId,\n });\n this.invokeControlHandler(tag, body, senderId);\n return undefined;\n default:\n emitMeshDiagnostic({\n kind: \"drop:unknown-control-type\",\n senderId,\n tag,\n });\n return undefined;\n }\n }\n\n private invokeControlHandler(tag: number, body: Uint8Array, senderId: string): void {\n if (!this.onControlMessage) return;\n try {\n this.onControlMessage(tag, body, senderId);\n } catch (err) {\n emitMeshDiagnostic({\n kind: \"drop:control-handler-threw\",\n senderId,\n tag,\n reason: err instanceof Error ? err.message : String(err),\n });\n }\n }\n\n /**\n * Send a control message (RFC-043) to a list of connected peers.\n * The body is wrapped in the same encrypt-sign envelope Automerge\n * sync uses; the type tag goes in front so receivers route it to\n * {@link MeshNetworkAdapterOptions.onControlMessage}.\n *\n * The base adapter does not surface its connected-peer set on the\n * NetworkAdapter interface, so the caller passes the targets\n * explicitly. The MeshClient layer maintains that list from the\n * `peer-candidate` / `peer-disconnected` events.\n */\n sendControlMessage(\n tag: MeshControlType,\n body: Uint8Array,\n targetPeerIds: ReadonlyArray<PeerId>\n ): void {\n if (targetPeerIds.length === 0) return;\n const keyring = this.keyringSource();\n const tagged = prependControlTag(tag, body);\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.sendControlMessage: missing document encryption key under id \"${DEFAULT_MESH_KEY_ID}\".`\n );\n }\n const encrypted = sealEncryptedEnvelope(tagged, DEFAULT_MESH_KEY_ID, docKey);\n payloadToSign = encodeEncryptedEnvelope(encrypted);\n } else {\n payloadToSign = tagged;\n }\n\n const senderId = (this.peerId ?? \"\") as PeerId;\n const signed = signEnvelope(payloadToSign, senderId, keyring.identity.secretKey);\n const signedBytes = encodeSignedEnvelope(signed);\n\n for (const targetId of targetPeerIds) {\n const outer: Record<string, unknown> = {\n type: \"sync\",\n senderId,\n targetId,\n data: signedBytes,\n };\n this.base.send(outer as unknown as Message);\n }\n }\n}\n\n/**\n * Prepend a one-byte control-type tag to a payload. The tag goes\n * inside the encrypted-signed envelope (or directly inside the signed\n * envelope in sign-only mode), so it is both confidential (encrypted\n * when encryption is enabled) and authenticated (covered by the\n * signature). Exposed so future RFC-043 issue helpers can build\n * tagged payloads without rebuilding this primitive.\n */\nexport function prependControlTag(tag: MeshControlType, body: Uint8Array): Uint8Array {\n const out = new Uint8Array(body.byteLength + 1);\n out[0] = tag;\n out.set(body, 1);\n return out;\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",
|
|
14
16
|
"/**\n * mesh-diagnostics — typed event stream for observable mesh failures and\n * state transitions.\n *\n * The mesh network adapter's incoming path has seven branches that drop a\n * message and return undefined: a malformed signed envelope, a revoked\n * peer, an unknown peer, a bad signature, a malformed encrypted envelope,\n * a missing document key, and a bad decryption. Each branch is correct —\n * the adapter must not surface tampered or unidentifiable bytes to the\n * Repo — but the drop is invisible to anything observing the application.\n * The classic symptom is \"the other peer typed something and nothing\n * arrived\" with no error anywhere.\n *\n * This module exposes a typed emit-and-subscribe stream that the adapter\n * (and the pairing and revocation paths) write to. Tests subscribe to\n * assert that exactly the expected diagnostics fired and no others;\n * production code can attach an observability sink that turns the stream\n * into telemetry or a user-visible diagnostic surface.\n *\n * The stream is module-level. Listeners are deduplicated by reference;\n * subscribe returns an unsubscribe function. Listener exceptions are\n * caught and dropped so a buggy observer cannot tear the network path.\n */\n\n/** All diagnostic event kinds, discriminated by the `kind` field. */\nexport type MeshDiagnostic =\n // Incoming-message silent drops in MeshNetworkAdapter.tryUnwrap.\n | { kind: \"drop:malformed-signed-envelope\"; reason?: string }\n | { kind: \"drop:revoked-peer\"; senderId: string }\n | { kind: \"drop:unknown-peer\"; senderId: string }\n | { kind: \"drop:bad-signature\"; senderId: string; reason?: string }\n | {\n kind: \"drop:malformed-encrypted-envelope\";\n senderId: string;\n reason?: string;\n }\n | {\n kind: \"drop:missing-doc-key\";\n senderId: string;\n documentId: string;\n }\n | {\n kind: \"drop:bad-decryption\";\n senderId: string;\n documentId: string;\n reason?: string;\n }\n // Control-message dispatch (RFC-043). After signature verification\n // and decryption, every plaintext payload begins with a one-byte\n // type tag; the adapter dispatches on it. Tags whose handlers are\n // not yet wired (revocation, revocation-summary) emit a\n // `ctrl:*-received` diagnostic and the message is dropped at this\n // layer until the next RFC-043 PR lands the apply path. Unknown\n // tags emit `drop:unknown-control-type`. An empty payload (no tag\n // byte at all) emits `drop:empty-control-payload`.\n | { kind: \"drop:unknown-control-type\"; senderId: string; tag: number }\n | { kind: \"drop:empty-control-payload\"; senderId: string }\n | { kind: \"drop:control-handler-threw\"; senderId: string; tag: number; reason: string }\n | { kind: \"ctrl:revocation-received\"; senderId: string }\n | { kind: \"ctrl:revocation-summary-received\"; senderId: string }\n // Revocation lifecycle (RFC-043). `revoke:applied` fires when a\n // remote revocation lands in the local keyring; `revoke:duplicate`\n // fires when an already-known revocation arrives again;\n // `revoke:rejected` fires when verification fails and carries the\n // RevocationError.code; `revoke:self-targeted` fires when the\n // local peer is the revocation's target and is the signal that\n // wakes the application's \"you have been revoked\" UX.\n | { kind: \"revoke:duplicate\"; revokedPeerId: string; issuerId: string }\n | {\n kind: \"revoke:rejected\";\n senderId: string;\n reason: string;\n }\n | {\n kind: \"revoke:self-targeted\";\n issuerId: string;\n reason?: string;\n issuedAt: number;\n }\n // Pairing-flow transitions.\n | { kind: \"pair:invite-issued\"; peerId: string }\n | { kind: \"pair:invite-accepted\"; peerId: string; issuerId: string }\n // Revocation-flow transitions.\n | { kind: \"revoke:issued\"; revokedPeerId: string; issuerId: string }\n | { kind: \"revoke:applied\"; revokedPeerId: string };\n\n/** A diagnostic event with the wall-clock timestamp the emitter stamped. */\nexport type MeshDiagnosticEvent = MeshDiagnostic & { timestamp: number };\n\n/** Callback shape for subscribers. */\nexport type MeshDiagnosticListener = (event: MeshDiagnosticEvent) => void;\n\nconst listeners = new Set<MeshDiagnosticListener>();\n\n/**\n * Emit a diagnostic to every active subscriber. Synchronous. Listener\n * exceptions are swallowed.\n */\nexport function emitMeshDiagnostic(diagnostic: MeshDiagnostic): void {\n const event: MeshDiagnosticEvent = { ...diagnostic, timestamp: Date.now() };\n for (const listener of listeners) {\n try {\n listener(event);\n } catch {\n // A buggy listener must not break the network path. The diagnostic\n // is intentionally a side-channel; if telemetry collapses, the mesh\n // keeps moving messages.\n }\n }\n}\n\n/**\n * Subscribe a listener. Returns an unsubscribe function. Idempotent on\n * the same listener reference — subscribing the same function twice\n * registers it once.\n */\nexport function subscribeToMeshDiagnostics(listener: MeshDiagnosticListener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/**\n * Convenience for tests and trace recorders: subscribe, collect every\n * event into an array, return the array and a stop function that\n * unsubscribes. The returned array is the live capture buffer — reads\n * see new events the moment they fire.\n */\nexport function recordMeshDiagnostics(): {\n events: ReadonlyArray<MeshDiagnosticEvent>;\n stop: () => void;\n} {\n const captured: MeshDiagnosticEvent[] = [];\n const stop = subscribeToMeshDiagnostics((event) => {\n captured.push(event);\n });\n return { events: captured, stop };\n}\n\n/**\n * Test-only: drop every subscriber. Use in `afterEach` to guarantee\n * isolation between tests when a stop function was missed. Not exported\n * from the mesh subpath in production builds — tests reach in directly.\n */\nexport function clearMeshDiagnosticListeners(): void {\n listeners.clear();\n}\n",
|
|
15
17
|
"/**\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
|
-
"/**\n * peer-repo-server — Phase 1 server-side factory for the Polly peer-relay\n * transport. Constructs an Automerge-Repo `Repo` wired to a WebSocket server\n * and a NodeFS storage backend, ready to relay sync messages between\n * connected $peerState clients.\n *\n * The \"always-on peer\" role for $peerState lives here. The server holds a\n * full Automerge replica of every document, participates in the sync protocol\n * as an ordinary peer, and persists state to disk so the next process restart\n * picks up where the previous one left off. Server-side cron, HTTP handlers,\n * and other compute can open document handles on the returned Repo and mutate\n * them; mutations propagate to connected clients through the same sync\n * protocol that handles client-to-client traffic.\n *\n * The plan originally called this an \"Elysia plugin,\" but Automerge's\n * `WebSocketServerAdapter` requires an `isomorphic-ws` `WebSocketServer`\n * instance — not Elysia's native WebSocket — so the cleanest first cut is a\n * standalone factory that runs its own `ws` server. Elysia integration for\n * authenticated upgrades is a Phase 1.1 follow-up that wraps this factory.\n *\n * @example\n * ```ts\n * import { createPeerRepoServer } from \"@fairfox/polly\";\n *\n * const server = await createPeerRepoServer({\n * port: 3030,\n * storagePath: \"./data/polly-peer\",\n * });\n *\n * // Open a document handle on the server's Repo for cron or compute work.\n * const handle = server.repo.create({ counter: 0 });\n *\n * // On shutdown:\n * await server.close();\n * ```\n */\n\n// Heavy peer-relay dependencies (@automerge/automerge-repo, ws) are dynamic\n// imports loaded only when createPeerRepoServer is actually called. Static\n// imports at this file's top level were hoisted into @fairfox/polly/elysia's\n// module-init chain, breaking Elysia apps that don't use peer state and\n// don't install the automerge peer deps. Types come from the static package\n// references — TypeScript only reads them for shape, so no runtime cost is\n// incurred.\nimport type { Repo as RepoType } from \"@automerge/automerge-repo/slim\";\nimport type { WebSocketServerAdapter as WebSocketServerAdapterType } from \"@automerge/automerge-repo-network-websocket\";\nimport type { NodeFSStorageAdapter as NodeFSStorageAdapterType } from \"@automerge/automerge-repo-storage-nodefs\";\nimport type * as wsType from \"ws\";\n\n// `@types/ws` uses CJS `export = WebSocket` with WebSocketServer hanging off\n// the namespace. Under the project's bundler module resolution, the\n// namespace alias gives us access to both the constructor and the type.\ntype WebSocketServer = wsType.WebSocketServer;\n\nexport interface CreatePeerRepoServerOptions {\n /** Port to listen on. The factory creates its own `WebSocketServer` and\n * binds to this port. */\n port: number;\n /** Filesystem directory for the NodeFS storage adapter. The directory is\n * created on demand. Defaults to `./automerge-repo-data` (Automerge's own\n * default). */\n storagePath?: string;\n /** Hostname interface to bind to. Defaults to all interfaces. */\n host?: string;\n /** Override the `WebSocketServer` instance entirely. When provided, `port`\n * and `host` are ignored and the caller is responsible for the lifecycle.\n * Useful for tests that want to bind to a random port. */\n webSocketServer?: WebSocketServer;\n}\n\nexport interface PeerRepoServer {\n /** A configured Repo participating as the always-on peer. Server-side\n * cron and HTTP handlers can open document handles on this directly. */\n repo: RepoType;\n /** The underlying WebSocket server. Exposed for advanced use such as\n * health checks or graceful shutdown coordination. */\n webSocketServer: WebSocketServer;\n /** The Automerge network adapter wrapping the WebSocket server. */\n adapter: WebSocketServerAdapterType;\n /** The NodeFS storage adapter writing to {@link CreatePeerRepoServerOptions.storagePath}. */\n storage: NodeFSStorageAdapterType;\n /** Tear down the server: disconnect peers, flush storage, close the\n * underlying WebSocket server. Returns a promise that resolves once the\n * tear-down is complete. */\n close: () => Promise<void>;\n}\n\n/**\n * Construct a Polly peer-relay server. Returns a Repo that participates as\n * the always-on peer, the underlying WebSocket server and storage adapter\n * for advanced use, and a close function for orderly shutdown.\n *\n * Applications typically call this once at startup, hold the returned\n * `repo` reference for cron and compute work, and wire the close function\n * into their process shutdown signal handlers.\n */\nexport async function createPeerRepoServer(\n options: CreatePeerRepoServerOptions\n): Promise<PeerRepoServer> {\n // Dynamic imports keep automerge-repo and ws out of the static module\n // graph. Apps that never call this function — which is most of them —\n // never pay the dependency cost and don't need the peer packages\n // installed at all.\n const [{ Repo }, { WebSocketServerAdapter }, { NodeFSStorageAdapter }, ws] = await Promise.all([\n import(\"@automerge/automerge-repo/slim\"),\n import(\"@automerge/automerge-repo-network-websocket\"),\n import(\"@automerge/automerge-repo-storage-nodefs\"),\n import(\"ws\"),\n ]);\n\n // Construct the WebSocket server first and wait until it is actually\n // listening before wiring up the Repo. Using the constructor callback\n // avoids the race where the 'listening' event fires before our listener\n // is attached (the callback form is reliable across Node and Bun).\n const wss = await (options.webSocketServer\n ? Promise.resolve(options.webSocketServer)\n : new Promise<WebSocketServer>((resolve, reject) => {\n const created: WebSocketServer = new ws.WebSocketServer(\n {\n port: options.port,\n ...(options.host !== undefined && { host: options.host }),\n },\n () => resolve(created)\n );\n created.once(\"error\", reject);\n }));\n\n // The cast bridges a @types/ws identity quirk: Automerge's adapter type\n // expects WebSocketServer with options.WebSocket typed via isomorphic-ws's\n // CJS-style namespace, and our direct `ws` import resolves through a\n // different path with the same runtime shape but a structurally distinct\n // TypeScript type. The runtime is identical, the cast names that fact.\n const adapter = new WebSocketServerAdapter(\n wss as unknown as ConstructorParameters<typeof WebSocketServerAdapter>[0]\n );\n const storage = new NodeFSStorageAdapter(options.storagePath);\n\n const repo = new Repo({\n network: [adapter],\n storage,\n });\n\n // Force the storage subsystem to finish initialising before returning. The\n // Repo constructor is synchronous, but its NetworkSubsystem holds back the\n // peer-metadata JOIN until storageSubsystem.id() resolves. If a client\n // connects before that resolution lands, the handshake stalls indefinitely.\n // Awaiting storageId() drains the relevant microtask chain and guarantees\n // the server is ready to accept peers when this factory returns.\n await repo.storageId();\n\n return {\n repo,\n webSocketServer: wss,\n adapter,\n storage,\n close: async () => {\n // Forcibly terminate any still-open client sockets before closing the\n // server, otherwise wss.close() can hang waiting for orderly drain when\n // a peer disappeared without a clean disconnect. We then fire the\n // server close without awaiting its callback — the underlying socket\n // is released immediately by terminate(), and waiting for the close\n // callback can hang under Bun even after every client is gone.\n for (const client of wss.clients) {\n try {\n client.terminate();\n } catch {\n // best effort\n }\n }\n try {\n await repo.shutdown();\n } catch {\n // best effort — automerge-repo's xstate DocHandle machine can\n // throw \"Cycle detected\" during teardown when sync messages are\n // still in flight.\n }\n try {\n wss.close();\n } catch {\n // best effort\n }\n },\n };\n}\n",
|
|
17
|
-
"/**\n * peer-state — Phase 1 wrappers exposing $peerState, $peerText, $peerCounter,\n * and $peerList. These are the application-facing constructors for the middle\n * resilience tier in RFC-041: every device is a full Automerge replica, the\n * server included, and server-side code can read and mutate document contents\n * because the server participates in the data plane as an ordinary peer.\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 \"peerState\" 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 via a per-Repo key map. The first time a key is\n * registered, the factory creates a new document on the configured Repo\n * and records the mapping. On subsequent constructions of the same key,\n * the factory looks up the existing DocumentId and finds the handle.\n *\n * 3. The `sign` option field validates that the configured Repo was\n * created with signing enabled (via createPeerStateClient with\n * `sign: true`). Signing adds Byzantine defence at the transport\n * level without preventing the server from reading document\n * contents. Encryption is not offered on $peerState because it\n * would prevent the server from participating as an Automerge\n * peer; applications that want encrypted state should use $meshState.\n *\n * The Repo itself is supplied by the application via {@link configurePeerState}\n * or per-call via the `repo` option. There is no transport in this Phase 1\n * cut — applications use a local-only Repo and document operations stay\n * inside the calling process. Phase 1's WebSocket relay adapter will plug in\n * via the same configuration path; Phase 2's mesh adapter does the same for\n * $meshState.\n */\n\nimport type { DocHandle, DocumentId, Repo } from \"@automerge/automerge-repo/slim\";\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 $peer* primitives. */\nexport interface PeerStateOptions<T> {\n /** Override the default Repo for this primitive. Useful for tests and for\n * applications that maintain multiple Repos (rare). */\n repo?: Repo;\n /** Request per-op Ed25519 signing for this primitive. Signing is a\n * transport-level concern: pass `sign: true` to `createPeerStateClient`\n * to enable it for all primitives on that Repo. Passing `sign: true`\n * here validates that the configured Repo was created with signing\n * enabled and throws if it was not. */\n sign?: boolean;\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. Compiled into a server share policy\n * once the relay transport is wired in. */\n access?: Access;\n /** Initial value used when this primitive's key has not been registered\n * before. Phase 0 callers passed this positionally; Phase 1 application\n * code does the same. */\n initialValue?: T;\n}\n\n/** Internal: per-Repo key → DocumentId map. Cleared by configurePeerState. */\nconst keyMapsByRepo = new WeakMap<Repo, Map<string, DocumentId>>();\n/** Internal: set of Repos configured with signing enabled. */\nconst signingEnabledRepos = new WeakSet<Repo>();\nlet defaultRepo: Repo | undefined;\n\n/**\n * Set the default Repo that the $peer* primitives use when no `repo` option\n * is supplied. Calling this with a new Repo clears the per-Repo key map so\n * that tests start each scenario with a fresh document space.\n *\n * Production code typically calls this once at application startup with a\n * Repo configured for the relay transport. Tests call it before each scenario\n * with an in-memory Repo.\n */\nexport function configurePeerState(repo: Repo, options?: { signEnabled?: boolean }): void {\n defaultRepo = repo;\n keyMapsByRepo.set(repo, new Map());\n if (options?.signEnabled) {\n signingEnabledRepos.add(repo);\n }\n}\n\n/**\n * Reset the peer-state subsystem to its initial unconfigured state. Intended\n * for tests; production code should not call this.\n */\nexport function resetPeerState(): 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 $peerState: no Repo configured. Call configurePeerState(repo) at startup or pass { repo } in the primitive options.\"\n );\n }\n return repo;\n}\n\nfunction getKeyMap(repo: Repo): Map<string, DocumentId> {\n let map = keyMapsByRepo.get(repo);\n if (!map) {\n map = new Map();\n keyMapsByRepo.set(repo, map);\n }\n return map;\n}\n\nfunction validateSignOption(options: PeerStateOptions<unknown>, repo: Repo): void {\n if (!options.sign) return;\n if (!signingEnabledRepos.has(repo)) {\n throw new Error(\n \"Polly $peerState: { sign: true } was passed to the primitive but the configured Repo does not have signing enabled. \" +\n \"Pass { sign: true, keyring: ... } to createPeerStateClient to enable signing at the transport level, \" +\n \"then call configurePeerState(client.repo, { signEnabled: true }).\"\n );\n }\n}\n\n/**\n * Build a getHandle factory that resolves a logical key to a DocHandle on\n * the supplied Repo. The first call creates a new document seeded with the\n * given initial value and records the (key → DocumentId) mapping; subsequent\n * calls look up the existing DocumentId and find the handle.\n */\nfunction buildHandleFactory<D>(\n repo: Repo,\n key: string,\n initialDoc: D\n): () => Promise<DocHandle<D>> {\n return async () => {\n const map = getKeyMap(repo);\n const existingId = map.get(key);\n if (existingId !== undefined) {\n return repo.find<D>(existingId);\n }\n const handle = repo.create<D>(initialDoc);\n map.set(key, handle.documentId);\n return handle;\n };\n}\n\n// $peerState\n\n/**\n * Create a peer-replicated state primitive backed by Automerge. Every device\n * holds a full replica; the server, when one is configured via the relay\n * transport, holds one too and participates in the sync protocol as an\n * ordinary peer. Server-side code can read and mutate document contents.\n *\n * @example\n * ```ts\n * const settings = $peerState<Settings>(\"settings\", { theme: \"dark\" });\n * await settings.loaded;\n * settings.value = { theme: \"light\" };\n * ```\n */\nexport function $peerState<T extends VersionedDoc>(\n key: string,\n initialValue: T,\n options: PeerStateOptions<T> = {}\n): CrdtPrimitive<T> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtState<T>({\n key,\n primitive: \"peerState\",\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// $peerText\n\nexport interface PeerTextOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated text primitive. Concurrent character-level edits\n * from peers merge cleanly via Automerge's updateText splicing.\n */\nexport function $peerText(\n key: string,\n initialValue: string,\n options: PeerTextOptions = {}\n): SpecialisedPrimitive<string> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtText(key, initialValue, {\n primitive: \"peerState\",\n getHandle: buildHandleFactory<TextDoc>(repo, key, { text: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $peerCounter\n\nexport interface PeerCounterOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated counter primitive. Concurrent increments from\n * peers commute, so two clients each adding 1 to a counter at 5 produce a\n * counter at 7 after merging.\n */\nexport function $peerCounter(\n key: string,\n initialValue: number,\n options: PeerCounterOptions = {}\n): SpecialisedPrimitive<number> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtCounter(key, initialValue, {\n primitive: \"peerState\",\n getHandle: buildHandleFactory<CounterDoc>(repo, key, {}),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $peerList\n\nexport interface PeerListOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated list primitive. The Phase 0 base uses naive\n * whole-array replacement; Phase 1.1 will refine the write path with\n * structural diff-to-splice for concurrent insert/remove preservation.\n */\nexport function $peerList<T>(\n key: string,\n initialValue: T[],\n options: PeerListOptions = {}\n): SpecialisedPrimitive<T[]> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtList<T>(key, initialValue, {\n primitive: \"peerState\",\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
|
+
"/**\n * peer-repo-server — Phase 1 server-side factory for the Polly peer-relay\n * transport. Constructs an Automerge-Repo `Repo` wired to a WebSocket server\n * and a NodeFS storage backend, ready to relay sync messages between\n * connected $peerState clients.\n *\n * The \"always-on peer\" role for $peerState lives here. The server holds a\n * full Automerge replica of every document, participates in the sync protocol\n * as an ordinary peer, and persists state to disk so the next process restart\n * picks up where the previous one left off. Server-side cron, HTTP handlers,\n * and other compute can open document handles on the returned Repo and mutate\n * them; mutations propagate to connected clients through the same sync\n * protocol that handles client-to-client traffic.\n *\n * The plan originally called this an \"Elysia plugin,\" but Automerge's\n * `WebSocketServerAdapter` requires an `isomorphic-ws` `WebSocketServer`\n * instance — not Elysia's native WebSocket — so the cleanest first cut is a\n * standalone factory that runs its own `ws` server. Elysia integration for\n * authenticated upgrades is a Phase 1.1 follow-up that wraps this factory.\n *\n * @example\n * ```ts\n * import { createPeerRepoServer } from \"@fairfox/polly\";\n *\n * const server = await createPeerRepoServer({\n * port: 3030,\n * storagePath: \"./data/polly-peer\",\n * });\n *\n * // Open a document handle on the server's Repo for cron or compute work.\n * const handle = server.repo.create({ counter: 0 });\n *\n * // On shutdown:\n * await server.close();\n * ```\n */\n\n// Heavy peer-relay dependencies (@automerge/automerge-repo, ws) are dynamic\n// imports loaded only when createPeerRepoServer is actually called. Static\n// imports at this file's top level were hoisted into @fairfox/polly/elysia's\n// module-init chain, breaking Elysia apps that don't use peer state and\n// don't install the automerge peer deps. Types come from the static package\n// references — TypeScript only reads them for shape, so no runtime cost is\n// incurred.\nimport type { Repo as RepoType } from \"@automerge/automerge-repo/slim\";\nimport type { WebSocketServerAdapter as WebSocketServerAdapterType } from \"@automerge/automerge-repo-network-websocket\";\nimport type { NodeFSStorageAdapter as NodeFSStorageAdapterType } from \"@automerge/automerge-repo-storage-nodefs\";\nimport type * as wsType from \"ws\";\nimport type { SweepResult } from \"./sweep-sealed\";\n\n// `@types/ws` uses CJS `export = WebSocket` with WebSocketServer hanging off\n// the namespace. Under the project's bundler module resolution, the\n// namespace alias gives us access to both the constructor and the type.\ntype WebSocketServer = wsType.WebSocketServer;\n\nexport interface CreatePeerRepoServerOptions {\n /** Port to listen on. The factory creates its own `WebSocketServer` and\n * binds to this port. */\n port: number;\n /** Filesystem directory for the NodeFS storage adapter. The directory is\n * created on demand. Defaults to `./automerge-repo-data` (Automerge's own\n * default). */\n storagePath?: string;\n /** Hostname interface to bind to. Defaults to all interfaces. */\n host?: string;\n /** Override the `WebSocketServer` instance entirely. When provided, `port`\n * and `host` are ignored and the caller is responsible for the lifecycle.\n * Useful for tests that want to bind to a random port. */\n webSocketServer?: WebSocketServer;\n}\n\nexport interface PeerRepoServer {\n /** A configured Repo participating as the always-on peer. Server-side\n * cron and HTTP handlers can open document handles on this directly. */\n repo: RepoType;\n /** The underlying WebSocket server. Exposed for advanced use such as\n * health checks or graceful shutdown coordination. */\n webSocketServer: WebSocketServer;\n /** The Automerge network adapter wrapping the WebSocket server. */\n adapter: WebSocketServerAdapterType;\n /** The NodeFS storage adapter writing to {@link CreatePeerRepoServerOptions.storagePath}. */\n storage: NodeFSStorageAdapterType;\n /** Tear down the server: disconnect peers, flush storage, close the\n * underlying WebSocket server. Returns a promise that resolves once the\n * tear-down is complete. */\n close: () => Promise<void>;\n /**\n * Garbage-collect sealed mesh-doc bytes from {@link storage}. Walks the\n * storage adapter, removes documents the `isSealed` predicate\n * recognises as sealed longer ago than `olderThan`, and skips any\n * document with an open handle on {@link repo}. With `dryRun`, reports\n * the candidates without removing anything.\n *\n * Convenience binding of the standalone `sweepSealed` to this server's\n * `repo` and `storage`. See `sweepSealed` for the full contract,\n * including the redirect-index-not-yet-synced hazard that `olderThan`\n * is sized to bound. polly never runs this on a timer — call it\n * explicitly. */\n sweepSealed: (options: {\n isSealed: (doc: unknown) => number | undefined;\n olderThan: number;\n dryRun?: boolean;\n }) => Promise<SweepResult>;\n}\n\n/**\n * Recover every documentId from a NodeFS storage tree.\n *\n * automerge-repo's NodeFS adapter shards each document two levels deep —\n * the first two characters of the documentId, then the remainder — so\n * the directory structure is itself the document list. A real document\n * is a directory (holding `snapshot` / `incremental` chunk\n * subdirectories); flat files such as the storage-adapter-id are\n * skipped. A missing storage directory (a server that has never\n * written) yields an empty list.\n */\nasync function listNodeFSDocumentIds(baseDirectory: string): Promise<string[]> {\n const [{ readdir }, { join }] = await Promise.all([\n import(\"node:fs/promises\"),\n import(\"node:path\"),\n ]);\n let shards: string[];\n try {\n shards = await readdir(baseDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n throw error;\n }\n const documentIds: string[] = [];\n for (const shard of shards) {\n const entries = await readdir(join(baseDirectory, shard), {\n withFileTypes: true,\n }).catch((): import(\"node:fs\").Dirent[] => []);\n for (const entry of entries) {\n if (entry.isDirectory()) documentIds.push(shard + entry.name);\n }\n }\n return documentIds;\n}\n\n/**\n * Construct a Polly peer-relay server. Returns a Repo that participates as\n * the always-on peer, the underlying WebSocket server and storage adapter\n * for advanced use, and a close function for orderly shutdown.\n *\n * Applications typically call this once at startup, hold the returned\n * `repo` reference for cron and compute work, and wire the close function\n * into their process shutdown signal handlers.\n */\nexport async function createPeerRepoServer(\n options: CreatePeerRepoServerOptions\n): Promise<PeerRepoServer> {\n // Dynamic imports keep automerge-repo and ws out of the static module\n // graph. Apps that never call this function — which is most of them —\n // never pay the dependency cost and don't need the peer packages\n // installed at all.\n const [{ Repo }, { WebSocketServerAdapter }, { NodeFSStorageAdapter }, ws] = await Promise.all([\n import(\"@automerge/automerge-repo/slim\"),\n import(\"@automerge/automerge-repo-network-websocket\"),\n import(\"@automerge/automerge-repo-storage-nodefs\"),\n import(\"ws\"),\n ]);\n\n // Construct the WebSocket server first and wait until it is actually\n // listening before wiring up the Repo. Using the constructor callback\n // avoids the race where the 'listening' event fires before our listener\n // is attached (the callback form is reliable across Node and Bun).\n const wss = await (options.webSocketServer\n ? Promise.resolve(options.webSocketServer)\n : new Promise<WebSocketServer>((resolve, reject) => {\n const created: WebSocketServer = new ws.WebSocketServer(\n {\n port: options.port,\n ...(options.host !== undefined && { host: options.host }),\n },\n () => resolve(created)\n );\n created.once(\"error\", reject);\n }));\n\n // The cast bridges a @types/ws identity quirk: Automerge's adapter type\n // expects WebSocketServer with options.WebSocket typed via isomorphic-ws's\n // CJS-style namespace, and our direct `ws` import resolves through a\n // different path with the same runtime shape but a structurally distinct\n // TypeScript type. The runtime is identical, the cast names that fact.\n const adapter = new WebSocketServerAdapter(\n wss as unknown as ConstructorParameters<typeof WebSocketServerAdapter>[0]\n );\n // Resolve the storage path explicitly so sweepSealed can enumerate the\n // directory: NodeFSStorageAdapter keeps its baseDirectory private, and\n // its default (when storagePath is omitted) is \"automerge-repo-data\".\n const storagePath = options.storagePath ?? \"automerge-repo-data\";\n const storage = new NodeFSStorageAdapter(storagePath);\n\n const repo = new Repo({\n network: [adapter],\n storage,\n });\n\n // Force the storage subsystem to finish initialising before returning. The\n // Repo constructor is synchronous, but its NetworkSubsystem holds back the\n // peer-metadata JOIN until storageSubsystem.id() resolves. If a client\n // connects before that resolution lands, the handshake stalls indefinitely.\n // Awaiting storageId() drains the relevant microtask chain and guarantees\n // the server is ready to accept peers when this factory returns.\n await repo.storageId();\n\n return {\n repo,\n webSocketServer: wss,\n adapter,\n storage,\n sweepSealed: async (sweepOptions) => {\n // The NodeFS adapter's loadRange can't take an empty prefix, so the\n // generic sweep can't enumerate it. Recover the documentId list\n // from the storage directory and hand it to the sweep, which then\n // loads each document by its own prefix.\n const documentIds = await listNodeFSDocumentIds(storagePath);\n // Dynamic import keeps sweep-sealed.ts — which statically imports\n // Automerge — out of this file's module graph, preserving the\n // no-static-automerge property the rest of this file relies on.\n const { sweepSealed } = await import(\"./sweep-sealed\");\n return sweepSealed({ repo, storage, documentIds, ...sweepOptions });\n },\n close: async () => {\n // Forcibly terminate any still-open client sockets before closing the\n // server, otherwise wss.close() can hang waiting for orderly drain when\n // a peer disappeared without a clean disconnect. We then fire the\n // server close without awaiting its callback — the underlying socket\n // is released immediately by terminate(), and waiting for the close\n // callback can hang under Bun even after every client is gone.\n for (const client of wss.clients) {\n try {\n client.terminate();\n } catch {\n // best effort\n }\n }\n try {\n await repo.shutdown();\n } catch {\n // best effort — automerge-repo's xstate DocHandle machine can\n // throw \"Cycle detected\" during teardown when sync messages are\n // still in flight.\n }\n try {\n wss.close();\n } catch {\n // best effort\n }\n },\n };\n}\n",
|
|
19
|
+
"/**\n * peer-state — Phase 1 wrappers exposing $peerState, $peerText, $peerCounter,\n * and $peerList. These are the application-facing constructors for the middle\n * resilience tier in RFC-041: every device is a full Automerge replica, the\n * server included, and server-side code can read and mutate document contents\n * because the server participates in the data plane as an ordinary peer.\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 \"peerState\" 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 via a per-Repo key map. The first time a key is\n * registered, the factory creates a new document on the configured Repo\n * and records the mapping. On subsequent constructions of the same key,\n * the factory looks up the existing DocumentId and finds the handle.\n *\n * 3. The `sign` option field validates that the configured Repo was\n * created with signing enabled (via createPeerStateClient with\n * `sign: true`). Signing adds Byzantine defence at the transport\n * level without preventing the server from reading document\n * contents. Encryption is not offered on $peerState because it\n * would prevent the server from participating as an Automerge\n * peer; applications that want encrypted state should use $meshState.\n *\n * The Repo itself is supplied by the application via {@link configurePeerState}\n * or per-call via the `repo` option. There is no transport in this Phase 1\n * cut — applications use a local-only Repo and document operations stay\n * inside the calling process. Phase 1's WebSocket relay adapter will plug in\n * via the same configuration path; Phase 2's mesh adapter does the same for\n * $meshState.\n */\n\nimport type { DocHandle, DocumentId, Repo } from \"@automerge/automerge-repo/slim\";\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 $peer* primitives. */\nexport interface PeerStateOptions<T> {\n /** Override the default Repo for this primitive. Useful for tests and for\n * applications that maintain multiple Repos (rare). */\n repo?: Repo;\n /** Request per-op Ed25519 signing for this primitive. Signing is a\n * transport-level concern: pass `sign: true` to `createPeerStateClient`\n * to enable it for all primitives on that Repo. Passing `sign: true`\n * here validates that the configured Repo was created with signing\n * enabled and throws if it was not. */\n sign?: boolean;\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. Compiled into a server share policy\n * once the relay transport is wired in. */\n access?: Access;\n /** Initial value used when this primitive's key has not been registered\n * before. Phase 0 callers passed this positionally; Phase 1 application\n * code does the same. */\n initialValue?: T;\n}\n\n/** Internal: per-Repo key → DocumentId map. Cleared by configurePeerState. */\nconst keyMapsByRepo = new WeakMap<Repo, Map<string, DocumentId>>();\n/** Internal: set of Repos configured with signing enabled. */\nconst signingEnabledRepos = new WeakSet<Repo>();\nlet defaultRepo: Repo | undefined;\n\n/**\n * Set the default Repo that the $peer* primitives use when no `repo` option\n * is supplied. Calling this with a new Repo clears the per-Repo key map so\n * that tests start each scenario with a fresh document space.\n *\n * Production code typically calls this once at application startup with a\n * Repo configured for the relay transport. Tests call it before each scenario\n * with an in-memory Repo.\n */\nexport function configurePeerState(repo: Repo, options?: { signEnabled?: boolean }): void {\n defaultRepo = repo;\n keyMapsByRepo.set(repo, new Map());\n if (options?.signEnabled) {\n signingEnabledRepos.add(repo);\n }\n}\n\n/**\n * Reset the peer-state subsystem to its initial unconfigured state. Intended\n * for tests; production code should not call this.\n */\nexport function resetPeerState(): 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 $peerState: no Repo configured. Call configurePeerState(repo) at startup or pass { repo } in the primitive options.\"\n );\n }\n return repo;\n}\n\nfunction getKeyMap(repo: Repo): Map<string, DocumentId> {\n let map = keyMapsByRepo.get(repo);\n if (!map) {\n map = new Map();\n keyMapsByRepo.set(repo, map);\n }\n return map;\n}\n\nfunction validateSignOption(options: PeerStateOptions<unknown>, repo: Repo): void {\n if (!options.sign) return;\n if (!signingEnabledRepos.has(repo)) {\n throw new Error(\n \"Polly $peerState: { sign: true } was passed to the primitive but the configured Repo does not have signing enabled. \" +\n \"Pass { sign: true, keyring: ... } to createPeerStateClient to enable signing at the transport level, \" +\n \"then call configurePeerState(client.repo, { signEnabled: true }).\"\n );\n }\n}\n\n/**\n * Build a getHandle factory that resolves a logical key to a DocHandle on\n * the supplied Repo. The first call creates a new document seeded with the\n * given initial value and records the (key → DocumentId) mapping; subsequent\n * calls look up the existing DocumentId and find the handle.\n */\nfunction buildHandleFactory<D>(\n repo: Repo,\n key: string,\n initialDoc: D\n): () => Promise<DocHandle<D>> {\n return async () => {\n const map = getKeyMap(repo);\n const existingId = map.get(key);\n if (existingId !== undefined) {\n return repo.find<D>(existingId);\n }\n const handle = repo.create<D>(initialDoc);\n map.set(key, handle.documentId);\n return handle;\n };\n}\n\n// $peerState\n\n/**\n * Create a peer-replicated state primitive backed by Automerge. Every device\n * holds a full replica; the server, when one is configured via the relay\n * transport, holds one too and participates in the sync protocol as an\n * ordinary peer. Server-side code can read and mutate document contents.\n *\n * @example\n * ```ts\n * const settings = $peerState<Settings>(\"settings\", { theme: \"dark\" });\n * await settings.loaded;\n * settings.value = { theme: \"light\" };\n * ```\n */\nexport function $peerState<T extends VersionedDoc>(\n key: string,\n initialValue: T,\n options: PeerStateOptions<T> = {}\n): CrdtPrimitive<T> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtState<T>({\n key,\n primitive: \"peerState\",\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// $peerText\n\nexport interface PeerTextOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated text primitive. Concurrent character-level edits\n * from peers merge cleanly via Automerge's updateText splicing.\n */\nexport function $peerText(\n key: string,\n initialValue: string,\n options: PeerTextOptions = {}\n): SpecialisedPrimitive<string> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtText(key, initialValue, {\n primitive: \"peerState\",\n getHandle: buildHandleFactory<TextDoc>(repo, key, { text: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $peerCounter\n\nexport interface PeerCounterOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated counter primitive. Concurrent increments from\n * peers commute, so two clients each adding 1 to a counter at 5 produce a\n * counter at 7 after merging.\n */\nexport function $peerCounter(\n key: string,\n initialValue: number,\n options: PeerCounterOptions = {}\n): SpecialisedPrimitive<number> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtCounter(key, initialValue, {\n primitive: \"peerState\",\n getHandle: buildHandleFactory<CounterDoc>(repo, key, {}),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n\n// $peerList\n\nexport interface PeerListOptions extends Omit<PeerStateOptions<unknown>, \"initialValue\"> {}\n\n/**\n * Create a peer-replicated list primitive. The Phase 0 base uses naive\n * whole-array replacement; Phase 1.1 will refine the write path with\n * structural diff-to-splice for concurrent insert/remove preservation.\n */\nexport function $peerList<T>(\n key: string,\n initialValue: T[],\n options: PeerListOptions = {}\n): SpecialisedPrimitive<T[]> {\n const repo = resolveRepo(options.repo);\n validateSignOption(options, repo);\n return $crdtList<T>(key, initialValue, {\n primitive: \"peerState\",\n getHandle: buildHandleFactory<ListDoc<T>>(repo, key, { items: initialValue }),\n schemaVersion: options.schemaVersion,\n migrations: options.migrations,\n access: options.access,\n });\n}\n",
|
|
20
|
+
"/**\n * @fairfox/polly/peer — peer-first CRDT state primitives.\n *\n * Automerge-backed reactive state that syncs via a relay server.\n * This subpath export isolates the @automerge/* dependency tree so\n * consumers who only use $sharedState / $syncedState / $resource\n * never pull in automerge.\n *\n * @example\n * ```typescript\n * import { $peerState, configurePeerState } from \"@fairfox/polly/peer\";\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\n// Base CRDT primitives (transport-agnostic, caller-supplied handle factory)\nexport type {\n CounterDoc,\n CrdtCounterOptions,\n CrdtListOptions,\n CrdtTextOptions,\n ListDoc,\n SpecialisedPrimitive,\n TextDoc,\n} from \"./shared/lib/crdt-specialised\";\nexport { $crdtCounter, $crdtList, $crdtText } from \"./shared/lib/crdt-specialised\";\nexport type { CrdtPrimitive, CrdtStateOptions } from \"./shared/lib/crdt-state\";\nexport { $crdtState } from \"./shared/lib/crdt-state\";\n// Migration support (needed for CRDT schema versioning)\nexport type { MigratableState } from \"./shared/lib/migrate-primitive\";\nexport { MigrationError, migratePrimitive } from \"./shared/lib/migrate-primitive\";\n\n// Relay adapter and server\nexport type {\n CreatePeerStateClientOptions,\n PeerRelayConnectionState,\n PeerStateClient,\n} from \"./shared/lib/peer-relay-adapter\";\nexport { createPeerStateClient } from \"./shared/lib/peer-relay-adapter\";\nexport type {\n CreatePeerRepoServerOptions,\n PeerRepoServer,\n} from \"./shared/lib/peer-repo-server\";\nexport { createPeerRepoServer } from \"./shared/lib/peer-repo-server\";\n// Peer-state wrappers (key→DocumentId mapping per Repo, relay transport)\nexport type {\n PeerCounterOptions,\n PeerListOptions,\n PeerStateOptions,\n PeerTextOptions,\n} from \"./shared/lib/peer-state\";\nexport {\n $peerCounter,\n $peerList,\n $peerState,\n $peerText,\n configurePeerState,\n resetPeerState,\n} from \"./shared/lib/peer-state\";\n// Primitive registry (needed for CRDT primitive kinds)\nexport type { PrimitiveKind } from \"./shared/lib/primitive-registry\";\nexport { PrimitiveCollisionError } from \"./shared/lib/primitive-registry\";\nexport type {\n Migration,\n Migrations,\n OpVersionCheck,\n VersionedDoc,\n} from \"./shared/lib/schema-version\";\nexport {\n assertOpVersion,\n checkOpVersion,\n getDocVersion,\n SCHEMA_VERSION_FIELD,\n SchemaVersionError,\n} from \"./shared/lib/schema-version\";\n// Sealed-doc storage GC (polly#121)\nexport type {\n KeptDoc,\n KeptReason,\n SweepResult,\n SweepSealedOptions,\n SweptDoc,\n} from \"./shared/lib/sweep-sealed\";\nexport { sweepSealed } from \"./shared/lib/sweep-sealed\";\n"
|
|
18
21
|
],
|
|
19
|
-
"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,IAA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Q;AAAA,IACvB,YAAY,QAAQ;AAAA,IACpB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAAA;;;AChLH;",
|
|
23
|
+
"debugId": "F8EEAB6080033B3464756E2164756E21",
|
|
21
24
|
"names": []
|
|
22
25
|
}
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
* font, and line-height so the toggle causes no reflow.
|
|
25
25
|
*/
|
|
26
26
|
import type { JSX } from "preact";
|
|
27
|
+
import { type PassthroughAttrs } from "./internal/passthrough.ts";
|
|
27
28
|
export type ActionInputSaveOn = "blur" | "enter" | "cmd-enter" | "explicit" | "input";
|
|
28
29
|
export type ActionInputVariant = "single" | "multi";
|
|
29
30
|
export type ActionInputType = "text" | "date" | "datetime-local" | "time" | "month" | "week" | "number" | "email" | "url" | "tel";
|
|
30
|
-
export type ActionInputProps = {
|
|
31
|
+
export type ActionInputProps = PassthroughAttrs & {
|
|
31
32
|
/** Current value to render in view mode and seed the edit buffer. */
|
|
32
33
|
value: string;
|
|
33
34
|
/** Action name to dispatch on commit. Receives data-action-value=<new value>. */
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* interactive element. A disabled ActionSelect renders as static text.
|
|
15
15
|
*/
|
|
16
16
|
import type { JSX } from "preact";
|
|
17
|
+
import { type PassthroughAttrs } from "./internal/passthrough.ts";
|
|
17
18
|
import type { SelectOption } from "./Select.tsx";
|
|
18
|
-
export type ActionSelectProps = {
|
|
19
|
+
export type ActionSelectProps = PassthroughAttrs & {
|
|
19
20
|
/** Current value — matched against `options` to render the trigger label. */
|
|
20
21
|
value: string;
|
|
21
22
|
/** Selectable options. */
|
|
@@ -40,12 +40,16 @@ type ButtonAsButton = BaseButtonProps & {
|
|
|
40
40
|
href?: never;
|
|
41
41
|
target?: never;
|
|
42
42
|
rel?: never;
|
|
43
|
+
download?: never;
|
|
43
44
|
type?: "button" | "submit" | "reset";
|
|
44
45
|
};
|
|
45
46
|
type ButtonAsLink = BaseButtonProps & {
|
|
46
47
|
href: string;
|
|
47
48
|
target?: string;
|
|
48
49
|
rel?: string;
|
|
50
|
+
/** Forwarded to the rendered <a> so a Button-as-link can offer a file
|
|
51
|
+
* download. An empty string uses the resource's own filename. */
|
|
52
|
+
download?: string;
|
|
49
53
|
type?: never;
|
|
50
54
|
};
|
|
51
55
|
export type ButtonProps = ButtonAsButton | ButtonAsLink;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* through <Layout>, a wrapping cluster goes through <Cluster>.
|
|
15
15
|
*/
|
|
16
16
|
import { type ComponentChildren, type JSX } from "preact";
|
|
17
|
-
|
|
17
|
+
import { type PassthroughAttrs } from "./internal/passthrough.ts";
|
|
18
|
+
export type ClusterProps = PassthroughAttrs & {
|
|
18
19
|
children: ComponentChildren;
|
|
19
20
|
/** Polymorphic element (div, nav, ul, …). Defaults to 'div'. */
|
|
20
21
|
as?: keyof JSX.IntrinsicElements;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* blocks, pass `block`, which switches to a pre-wrapped <pre><code>.
|
|
8
8
|
*/
|
|
9
9
|
import type { ComponentChildren, JSX } from "preact";
|
|
10
|
-
|
|
10
|
+
import { type PassthroughAttrs } from "./internal/passthrough.ts";
|
|
11
|
+
export type CodeProps = PassthroughAttrs & {
|
|
11
12
|
children: ComponentChildren;
|
|
12
13
|
/** Render as a block (<pre><code>) instead of an inline span. */
|
|
13
14
|
block?: boolean;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dropdown — trigger button + popover menu using the native Popover API.
|
|
3
3
|
*
|
|
4
|
+
* A shown popover is promoted to the browser's top layer, where CSS
|
|
5
|
+
* positioning resolves against the viewport rather than the `.dropdown`
|
|
6
|
+
* wrapper — so the menu cannot be placed with `position: absolute`
|
|
7
|
+
* alone. Instead it is pinned with `position: fixed` and coordinates
|
|
8
|
+
* measured from the trigger; see `positionMenu` below (issue #128).
|
|
9
|
+
*
|
|
4
10
|
* The menu element gets `popover="auto"` and a unique `data-overlay-id`.
|
|
5
11
|
* `closeTopOverlay()` from @fairfox/polly/actions finds the topmost
|
|
6
12
|
* `[data-overlay-id]` element and dispatches `overlay:close` — the
|
|
@@ -18,7 +18,9 @@ type Border = "none" | "default" | "strong";
|
|
|
18
18
|
type BorderWidth = "none" | "default" | "medium" | "thick";
|
|
19
19
|
type BorderSides = "all" | "block-start" | "block-end" | "inline-start" | "inline-end" | "block" | "inline";
|
|
20
20
|
type Shadow = "none" | "sm" | "md" | "lg";
|
|
21
|
-
type Position = "static" | "relative" | "sticky" | "fixed";
|
|
21
|
+
type Position = "static" | "relative" | "absolute" | "sticky" | "fixed";
|
|
22
|
+
type BorderStyle = "solid" | "dashed";
|
|
23
|
+
type Overflow = "visible" | "hidden" | "auto" | "scroll";
|
|
22
24
|
/**
|
|
23
25
|
* Arbitrary `data-*` and `aria-*` attributes forwarded to the rendered element
|
|
24
26
|
* so consumers (Modal, Toast, Card, etc.) can compose Surface without losing
|
|
@@ -42,16 +44,25 @@ export type SurfaceProps = SurfaceDataAttrs & {
|
|
|
42
44
|
border?: Border;
|
|
43
45
|
borderWidth?: BorderWidth;
|
|
44
46
|
borderSides?: BorderSides;
|
|
47
|
+
/** Border line style. Default: `'solid'`. */
|
|
48
|
+
borderStyle?: BorderStyle;
|
|
45
49
|
shadow?: Shadow;
|
|
46
50
|
/** display: inline-block — Surface flows inline with surrounding text. */
|
|
47
51
|
inline?: boolean;
|
|
48
52
|
width?: string;
|
|
49
53
|
height?: string;
|
|
50
54
|
minHeight?: string;
|
|
55
|
+
/** Maximum block size — a Surface that shrinks to content but is capped. */
|
|
56
|
+
maxHeight?: string;
|
|
51
57
|
maxInlineSize?: string;
|
|
58
|
+
/** Overflow behaviour. `'auto'` makes a height-capped Surface scroll. */
|
|
59
|
+
overflow?: Overflow;
|
|
52
60
|
position?: Position;
|
|
53
61
|
/** Any CSS inset value (`'0'`, `'auto auto 1rem 1rem'`, `'1rem'`, …). */
|
|
54
62
|
inset?: string;
|
|
63
|
+
/** CSS transform — e.g. `'translateX(-50%)'` to centre a fixed banner
|
|
64
|
+
* paired with `inset: '… auto … 50%'`. The sanctioned transform escape. */
|
|
65
|
+
transform?: string;
|
|
55
66
|
zIndex?: number;
|
|
56
67
|
className?: string;
|
|
57
68
|
/**
|