@ghostlytools/cli 1.11.3 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -30
- package/SKILL.md +4 -2
- package/dist/assets/{api-DBlaoz8i.js → api-DLzCtePC.js} +533 -195
- package/dist/assets/api-DLzCtePC.js.map +1 -0
- package/dist/assets/{api-DgU4MZPD.js → api-DYMKyb1k.js} +2 -2
- package/dist/assets/{apiKit-DesObIDf.js → apiKit-CVaEzKWQ.js} +104 -21
- package/dist/assets/apiKit-CVaEzKWQ.js.map +1 -0
- package/dist/assets/appFetch-D56GsYuq.js +602 -0
- package/dist/assets/appFetch-D56GsYuq.js.map +1 -0
- package/dist/assets/apps-BPFW19Wc.js +1 -0
- package/dist/assets/{apps-DkMjDHML.js → apps-XnZ8VEuj.js} +66 -38
- package/dist/assets/apps-XnZ8VEuj.js.map +1 -0
- package/dist/assets/{argon2id-088uQfnH.js → argon2id-B9wFdSj6.js} +2 -3
- package/dist/assets/{argon2id-088uQfnH.js.map → argon2id-B9wFdSj6.js.map} +1 -1
- package/dist/assets/{arkade-CarKONmH.js → arkade-DryM-q5n.js} +6 -7
- package/dist/assets/arkade-DryM-q5n.js.map +1 -0
- package/dist/assets/backup-COX6j1_W.js +1 -0
- package/dist/assets/{backup-C0OJCJlM.js → backup-DpyvT9Z6.js} +108 -50
- package/dist/assets/backup-DpyvT9Z6.js.map +1 -0
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +5 -0
- package/dist/assets/{bark_ffi_wasm_bg-EY2uc0Bx.js.map → bark_ffi_wasm_bg-CcafsJla.js.map} +1 -1
- package/dist/assets/{bark_ffi_wasm_bg-Bxru_BVW.wasm → bark_ffi_wasm_bg-VNmaJsc9.wasm} +0 -0
- package/dist/assets/{bitcoind-CdSmvy2y.js → bitcoind-DTsrd7TF.js} +4 -5
- package/dist/assets/{bitcoind-CdSmvy2y.js.map → bitcoind-DTsrd7TF.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +5 -0
- package/dist/assets/{bitcoindevkit_bg-B-iLWrmX.js.map → bitcoindevkit_bg-BWQHx7vd.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
- package/dist/assets/{blobFiles-BmsrvZc3.js → blobFiles-DDs34n0r.js} +4 -5
- package/dist/assets/{blobFiles-BmsrvZc3.js.map → blobFiles-DDs34n0r.js.map} +1 -1
- package/dist/assets/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/dist/assets/buttons-Bq7pTXqF.js +1 -0
- package/dist/assets/{buttons-fZTEa_2i.js → buttons-BvWqHJeh.js} +46 -23
- package/dist/assets/buttons-BvWqHJeh.js.map +1 -0
- package/dist/assets/bytes-C1DNGY18.js +132 -0
- package/dist/assets/bytes-C1DNGY18.js.map +1 -0
- package/dist/assets/{childEnv-K_IzUqQx.js → childEnv-C-99hdbL.js} +2 -3
- package/dist/assets/{childEnv-K_IzUqQx.js.map → childEnv-C-99hdbL.js.map} +1 -1
- package/dist/assets/{client-Ibk3-e60.js → client-kGZ3ZdUW.js} +30 -13
- package/dist/assets/client-kGZ3ZdUW.js.map +1 -0
- package/dist/assets/{codec-DMpQqVSt.js → codec-B2rH1mfx.js} +2 -4
- package/dist/assets/{codec-DMpQqVSt.js.map → codec-B2rH1mfx.js.map} +1 -1
- package/dist/assets/domainProofs-BDNP1dIy.js +280 -0
- package/dist/assets/domainProofs-BDNP1dIy.js.map +1 -0
- package/dist/assets/{endpoint-DarqblYE.js → endpoint-B0vE5ojY.js} +421 -420
- package/dist/assets/endpoint-B0vE5ojY.js.map +1 -0
- package/dist/assets/engineErrors--9hfgKlK.js +150 -0
- package/dist/assets/engineErrors--9hfgKlK.js.map +1 -0
- package/dist/assets/{envelope-CvQVCGdf.js → envelope-Bi2kMqbp.js} +3 -4
- package/dist/assets/{envelope-CvQVCGdf.js.map → envelope-Bi2kMqbp.js.map} +1 -1
- package/dist/assets/{errors-Dt-ZnyOX.js → errors-DDLFO4Gf.js} +31 -5
- package/dist/assets/errors-DDLFO4Gf.js.map +1 -0
- package/dist/assets/{fedimintSdk-zV_5Qdqz.js → fedimintSdk-D-6H9Pe7.js} +4 -5
- package/dist/assets/{fedimintSdk-zV_5Qdqz.js.map → fedimintSdk-D-6H9Pe7.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +5 -0
- package/dist/assets/{fedimint_client_wasm_bg-BtHHlFpp.js.map → fedimint_client_wasm_bg-Cr5xGD-w.js.map} +1 -1
- package/dist/assets/fileBytes-CCKbwqG_.js +1 -0
- package/dist/assets/{fileBytes-BLPZq9YU.js → fileBytes-CfvUXdSy.js} +5 -7
- package/dist/assets/fileBytes-CfvUXdSy.js.map +1 -0
- package/dist/assets/{fileBytes-B0z9A6Le.js → fileBytes-tj6-VZcB.js} +3 -4
- package/dist/assets/{fileBytes-B0z9A6Le.js.map → fileBytes-tj6-VZcB.js.map} +1 -1
- package/dist/assets/fileBytesIdb-B0zzJ6p7.js +1 -0
- package/dist/assets/{fileBytesIdb-Bmlrl9EO.js → fileBytesIdb-BJirUAjI.js} +4 -5
- package/dist/assets/{fileBytesIdb-Bmlrl9EO.js.map → fileBytesIdb-BJirUAjI.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-DBS0kbPT.js → fileBytesOpfs-DRUYLER4.js} +4 -5
- package/dist/assets/{fileBytesOpfs-DBS0kbPT.js.map → fileBytesOpfs-DRUYLER4.js.map} +1 -1
- package/dist/assets/{fixedHosts-6gKn8dp2.js → fixedHosts-CPSsGOI2.js} +4 -5
- package/dist/assets/{fixedHosts-6gKn8dp2.js.map → fixedHosts-CPSsGOI2.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js → ghostly_iroh_web-DIj5xGmR.js} +2 -3
- package/dist/assets/{ghostly_iroh_web-BzAXJUYH.js.map → ghostly_iroh_web-DIj5xGmR.js.map} +1 -1
- package/dist/assets/{src-DjVj2ynY.js → groupMeta-DTQAJG50.js} +4879 -23799
- package/dist/assets/groupMeta-DTQAJG50.js.map +1 -0
- package/dist/assets/{host-CYlIiY3r.js → host-z0FAHP9Z.js} +750 -245
- package/dist/assets/host-z0FAHP9Z.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-CdsLcAhY.js → hyperdhtRelay-CvsAfQRQ.js} +5 -6
- package/dist/assets/hyperdhtRelay-CvsAfQRQ.js.map +1 -0
- package/dist/assets/hyperdhtRelay-bjNGacf5.js +32 -0
- package/dist/assets/hyperdhtRelay-bjNGacf5.js.map +1 -0
- package/dist/assets/{idb-CEuoNsTv.js → idb-ewvbqyDI.js} +2 -3
- package/dist/assets/{idb-CEuoNsTv.js.map → idb-ewvbqyDI.js.map} +1 -1
- package/dist/assets/identityProofs-Cksc_K7_.js +940 -0
- package/dist/assets/identityProofs-Cksc_K7_.js.map +1 -0
- package/dist/assets/{irohWeb-D2IuloLL.js → irohWeb-CLBx5MIv.js} +3061 -86
- package/dist/assets/irohWeb-CLBx5MIv.js.map +1 -0
- package/dist/assets/joinTrace-CBr1jbch.js +1 -0
- package/dist/assets/{joinTrace-CjRDFy85.js → joinTrace-xKBe73j9.js} +2 -3
- package/dist/assets/{joinTrace-CjRDFy85.js.map → joinTrace-xKBe73j9.js.map} +1 -1
- package/dist/assets/{legacy_ciphers-JJOu0JXL.js → legacy_ciphers-BnYATjxo.js} +2 -3
- package/dist/assets/{legacy_ciphers-JJOu0JXL.js.map → legacy_ciphers-BnYATjxo.js.map} +1 -1
- package/dist/assets/linkPreview-DdMf-YAc.js +252 -0
- package/dist/assets/linkPreview-DdMf-YAc.js.map +1 -0
- package/dist/assets/{main-C0PfjKTe.js → main-CVqkvuIo.js} +536 -173
- package/dist/assets/main-CVqkvuIo.js.map +1 -0
- package/dist/assets/{mainline-Cu61qcPS.js → mainline-CVrd0C1n.js} +72 -18
- package/dist/assets/mainline-CVrd0C1n.js.map +1 -0
- package/dist/assets/mints-BcBODVVW.js +1 -0
- package/dist/assets/{mints-j5XAOk4f.js → mints-CMDLbMeH.js} +8 -6
- package/dist/assets/mints-CMDLbMeH.js.map +1 -0
- package/dist/assets/{nacl-fast-CDhNCYHs.js → nacl-fast-B1ThWvuM.js} +2 -3
- package/dist/assets/{nacl-fast-CDhNCYHs.js.map → nacl-fast-B1ThWvuM.js.map} +1 -1
- package/dist/assets/{networkReason-Dt7Yx_n4.js → networkReason-Be-hMghr.js} +10 -14
- package/dist/assets/{networkReason-Dt7Yx_n4.js.map → networkReason-Be-hMghr.js.map} +1 -1
- package/dist/assets/{noble_curves-DDWn5AH0.js → noble_curves-DqpNlhAU.js} +3 -4
- package/dist/assets/{noble_curves-DDWn5AH0.js.map → noble_curves-DqpNlhAU.js.map} +1 -1
- package/dist/assets/{noble_hashes-B7AZyFyS.js → noble_hashes-LFe1N2xt.js} +3 -4
- package/dist/assets/{noble_hashes-B7AZyFyS.js.map → noble_hashes-LFe1N2xt.js.map} +1 -1
- package/dist/assets/{nwc-CtZypDcv.js → nwc-DKE2FXr6.js} +5 -6
- package/dist/assets/{nwc-CtZypDcv.js.map → nwc-DKE2FXr6.js.map} +1 -1
- package/dist/assets/nwcProvider-pL2XqSbW.js +208 -0
- package/dist/assets/nwcProvider-pL2XqSbW.js.map +1 -0
- package/dist/assets/{openpgp-BBFr-zHQ.js → openpgp-LkR_Zof0.js} +14 -15
- package/dist/assets/{openpgp-BBFr-zHQ.js.map → openpgp-LkR_Zof0.js.map} +1 -1
- package/dist/assets/ownDid-DY3rYqDI.js +862 -0
- package/dist/assets/ownDid-DY3rYqDI.js.map +1 -0
- package/dist/assets/{ownStatus-D4HC6tNR.js → ownStatus-DMEhrpkd.js} +81 -19
- package/dist/assets/ownStatus-DMEhrpkd.js.map +1 -0
- package/dist/assets/pairedTransports-BKmvlKz1.js +581 -0
- package/dist/assets/pairedTransports-BKmvlKz1.js.map +1 -0
- package/dist/assets/paymentIntent-DySU3Ajm.js +349 -0
- package/dist/assets/paymentIntent-DySU3Ajm.js.map +1 -0
- package/dist/assets/pkarr-BQo4PcCg.js +367 -0
- package/dist/assets/pkarr-BQo4PcCg.js.map +1 -0
- package/dist/assets/{profiles-Ccdq6Xf6.js → profiles-BFSGqDFC.js} +30 -16
- package/dist/assets/profiles-BFSGqDFC.js.map +1 -0
- package/dist/assets/registry-B15Yg_1C.js +1 -0
- package/dist/assets/{registry-LvxsLJ5S.js → registry-rXgaZeNn.js} +1273 -58
- package/dist/assets/registry-rXgaZeNn.js.map +1 -0
- package/dist/assets/relay-Cjfmdec0.js +2219 -0
- package/dist/assets/relay-Cjfmdec0.js.map +1 -0
- package/dist/assets/resolve-CIc3KZMV.js +970 -0
- package/dist/assets/resolve-CIc3KZMV.js.map +1 -0
- package/dist/assets/{restoredRows-C3LcxmOw.js → restoredRows-D_WSHE7H.js} +3 -4
- package/dist/assets/{restoredRows-C3LcxmOw.js.map → restoredRows-D_WSHE7H.js.map} +1 -1
- package/dist/assets/{secretGuard-B7Hj0Kvz.js → secretGuard-B4-LlMjv.js} +75 -16
- package/dist/assets/{secretGuard-B7Hj0Kvz.js.map → secretGuard-B4-LlMjv.js.map} +1 -1
- package/dist/assets/secretGuard-BmmnEbYf.js +1 -0
- package/dist/assets/{server-Q3VcNqGt.js → server-CQR7NLCz.js} +10200 -625
- package/dist/assets/server-CQR7NLCz.js.map +1 -0
- package/dist/assets/{sha512-BYId-G-T.js → sha512-DST9fbWH.js} +2 -3
- package/dist/assets/{sha512-BYId-G-T.js.map → sha512-DST9fbWH.js.map} +1 -1
- package/dist/assets/sshForges-BnvwmNj-.js +539 -0
- package/dist/assets/sshForges-BnvwmNj-.js.map +1 -0
- package/dist/assets/{storage-Bya5b2Xt.js → storage-BpjdxvO2.js} +243 -34
- package/dist/assets/storage-BpjdxvO2.js.map +1 -0
- package/dist/assets/text-li76pThX.js +106 -0
- package/dist/assets/text-li76pThX.js.map +1 -0
- package/dist/assets/{translate-iQZq4TnY.js → translate-BcbSWkuq.js} +21 -26
- package/dist/assets/{translate-iQZq4TnY.js.map → translate-BcbSWkuq.js.map} +1 -1
- package/dist/assets/{tree-store-N362nuzZ.js → tree-store-CAchkO_l.js} +22 -6
- package/dist/assets/tree-store-CAchkO_l.js.map +1 -0
- package/dist/assets/{types-Clyb52K2.js → types-CdWwgvyt.js} +2 -3
- package/dist/assets/{types-Clyb52K2.js.map → types-CdWwgvyt.js.map} +1 -1
- package/dist/assets/{unbzip2-stream-B1C-JX9L.js → unbzip2-stream-BtkYGpC5.js} +2 -3
- package/dist/assets/{unbzip2-stream-B1C-JX9L.js.map → unbzip2-stream-BtkYGpC5.js.map} +1 -1
- package/dist/assets/{usdt-DnyTGdTX.js → usdt-CBJ4Q5Ji.js} +7 -7
- package/dist/assets/usdt-CBJ4Q5Ji.js.map +1 -0
- package/dist/assets/{waitNotice-Cn0WJ-He.js → waitNotice-BGM0QOS2.js} +27 -4
- package/dist/assets/waitNotice-BGM0QOS2.js.map +1 -0
- package/dist/assets/{web-DwgdhfcY.js → web-68CYFCl9.js} +314 -91
- package/dist/assets/web-68CYFCl9.js.map +1 -0
- package/dist/ghostly.mjs +3 -5
- package/dist/ghostly.mjs.map +1 -1
- package/npm-shrinkwrap.json +225 -200
- package/package.json +16 -16
- package/dist/assets/api-DBlaoz8i.js.map +0 -1
- package/dist/assets/apiKit-DesObIDf.js.map +0 -1
- package/dist/assets/appFetch-C8yZIq1e.js +0 -194
- package/dist/assets/appFetch-C8yZIq1e.js.map +0 -1
- package/dist/assets/apps-DkMjDHML.js.map +0 -1
- package/dist/assets/apps-rzxsjfBV.js +0 -2
- package/dist/assets/arkade-CarKONmH.js.map +0 -1
- package/dist/assets/backup-C0OJCJlM.js.map +0 -1
- package/dist/assets/backup-CgWU7x0T.js +0 -2
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js +0 -6
- package/dist/assets/bitcoindProvider-BvoRh0D5.js +0 -97
- package/dist/assets/bitcoindProvider-BvoRh0D5.js.map +0 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js +0 -6
- package/dist/assets/bitcoindevkit_bg-CRkZTSbO.wasm +0 -0
- package/dist/assets/buttons-Cco0Agfa.js +0 -2
- package/dist/assets/buttons-fZTEa_2i.js.map +0 -1
- package/dist/assets/client-Ibk3-e60.js.map +0 -1
- package/dist/assets/endpoint-DarqblYE.js.map +0 -1
- package/dist/assets/errors-Dt-ZnyOX.js.map +0 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js +0 -6
- package/dist/assets/fileBytes-BLPZq9YU.js.map +0 -1
- package/dist/assets/fileBytes-BtIyoDF2.js +0 -2
- package/dist/assets/fileBytesIdb-D8mAK4pF.js +0 -2
- package/dist/assets/host-CYlIiY3r.js.map +0 -1
- package/dist/assets/hyperdhtRelay-1wzya_0L.js +0 -25
- package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +0 -1
- package/dist/assets/hyperdhtRelay-CdsLcAhY.js.map +0 -1
- package/dist/assets/irohWeb-D2IuloLL.js.map +0 -1
- package/dist/assets/joinTrace-D-fnt2p3.js +0 -2
- package/dist/assets/jsonOut-POtMBS_V.js +0 -16
- package/dist/assets/jsonOut-POtMBS_V.js.map +0 -1
- package/dist/assets/main-C0PfjKTe.js.map +0 -1
- package/dist/assets/mainline-Cu61qcPS.js.map +0 -1
- package/dist/assets/mints-BaOmx517.js +0 -2
- package/dist/assets/mints-j5XAOk4f.js.map +0 -1
- package/dist/assets/nwcProvider-DYHkd0iu.js +0 -88
- package/dist/assets/nwcProvider-DYHkd0iu.js.map +0 -1
- package/dist/assets/ownDid-CJ0ta8CL.js +0 -282
- package/dist/assets/ownDid-CJ0ta8CL.js.map +0 -1
- package/dist/assets/ownStatus-D4HC6tNR.js.map +0 -1
- package/dist/assets/profiles-Ccdq6Xf6.js.map +0 -1
- package/dist/assets/registry-CE0PpQAE.js +0 -2
- package/dist/assets/registry-LvxsLJ5S.js.map +0 -1
- package/dist/assets/resolve-6kVu2DE5.js +0 -400
- package/dist/assets/resolve-6kVu2DE5.js.map +0 -1
- package/dist/assets/secretGuard-DUr6bgKc.js +0 -2
- package/dist/assets/server-Q3VcNqGt.js.map +0 -1
- package/dist/assets/src-DjVj2ynY.js.map +0 -1
- package/dist/assets/sshForges-DeZ9cN9Q.js +0 -261
- package/dist/assets/sshForges-DeZ9cN9Q.js.map +0 -1
- package/dist/assets/storage-Bya5b2Xt.js.map +0 -1
- package/dist/assets/tree-store-N362nuzZ.js.map +0 -1
- package/dist/assets/usdt-DnyTGdTX.js.map +0 -1
- package/dist/assets/waitNotice-Cn0WJ-He.js.map +0 -1
- package/dist/assets/web-DwgdhfcY.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mainline-Cu61qcPS.js","names":["verify"],"sources":["../../src/runtime/mainline.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport DHT from \"bittorrent-dht\";\nimport { ed25519 } from \"@noble/curves/ed25519.js\";\nimport {\n BACKGROUND_REQUESTS_PER_MINUTE, DiscoveryBudgetError, HEDGE_MISSING_MS, HEDGE_MS, RelayTransport, RelaysFailedError, SLOW_MS, isDiscoveryBudgetError, newerPacket, parseRelayPayload, publicKeyFromZ32,\n type DiscoveryStatus, type GhostRecord, type Identity, type PkarrRequestOptions, type PkarrTransport, type RelayTransportOptions, type SignedPacket,\n} from \"@ghostly/core\";\n\n/**\n * Pkarr over the Mainline DHT (BEP44), from Node, as the Desktop reaches it from Rust: the relays are HTTP bridges to\n * this same DHT, so a headless Ghostly that speaks it directly keeps finding its contacts while the relays fail (they\n * answered HTTP 500 for more than ten minutes on 2026-09-27, and a group's edges stayed down all that while).\n *\n * A Pkarr packet is a BEP44 mutable item: the key is the Ed25519 public key, the value the DNS packet, the sequence\n * number its timestamp in microseconds, and the signature the one the relay payload already carries (over\n * `3:seqi<seq>e1:v<len>:<v>`). So one signed payload goes to the relays and to the DHT unchanged.\n */\n\nexport interface MainlineOptions {\n /** `host:port` nodes to start from; the public routers when absent; none with `false` (a testnet's first node). */\n bootstrap?: string[] | false;\n /** Address to bind (a loopback testnet binds 127.0.0.1). */\n host?: string;\n /** How long a lookup may take before it is given up, in ms. */\n timeoutMs?: number;\n}\n\nconst SIGNATURE = 64, TIMESTAMP = 8;\nconst verify = (sig: Uint8Array, message: Uint8Array, key: Uint8Array) => { try { return ed25519.verify(sig, message, key); } catch { return false; } };\n/**\n * What a `get` takes from the nodes that answer: a record signed without salt (Pkarr has none). bittorrent-dht reads a\n * reply's `salt` (`Buffer.concat` with the key) only once it is verified, and a number there threw in its socket handler:\n * any node a lookup asked, signing with its own key, raised an error nobody caught. Signed data is `4:salt…` with a salt.\n */\nconst SALTED = Buffer.from(\"4:salt\");\nconst verifyUnsalted = (sig: Uint8Array, message: Uint8Array, key: Uint8Array) =>\n !Buffer.from(message.buffer, message.byteOffset, Math.min(message.length, SALTED.length)).equals(SALTED) && verify(sig, message, key);\n\n/** Queries the node answers, a second: from each address (as libtorrent's default), and from all of them together. */\nconst QUERY_LIMITS = { perAddress: 5, perAddressBurst: 20, total: 50, totalBurst: 200 };\n/** Addresses `DhtQueryLimit` remembers: forged source addresses must not grow it without end. */\nconst ADDRESSES_KEPT = 4_096;\n/** Mutable items others put on the node: as many as bittorrent-dht keeps, each for the two hours BEP44 suggests. */\nconst VALUES_KEPT = { max: 1_000, maxAge: 2 * 60 * 60_000 };\n\n/**\n * The queries a DHT node answers, as token buckets: a burst then a rate per source address, and a total for all. UDP\n * has no handshake, so a query's address can be someone else's: answered without a limit, a stranger who parked a\n * 1000-byte item on the node had it send ~12.5x the bytes of each forged `get` (5-6x with nothing parked) to that\n * address, as fast as they came. Queries past either limit go unanswered, as an overloaded node's do. This node's own\n * lookups (answers to its queries, not queries) are not counted.\n */\nexport class DhtQueryLimit {\n private readonly addresses = new Map<string, { tokens: number; at: number }>();\n private all: { tokens: number; at: number } | null = null;\n\n constructor(private readonly limits: typeof QUERY_LIMITS = QUERY_LIMITS) {}\n\n /** Addresses remembered (`ADDRESSES_KEPT` at most). */\n get size(): number { return this.addresses.size; }\n\n /** Whether a query from `host` is answered now (counted if so). */\n take(host: string, now = Date.now()): boolean {\n const refill = (bucket: { tokens: number; at: number } | null | undefined, rate: number, burst: number) => {\n if (!bucket) return { tokens: burst, at: now };\n // A clock that went back refills nothing, and counts from now on.\n bucket.tokens = Math.min(burst, bucket.tokens + Math.max(0, now - bucket.at) * rate / 1_000);\n bucket.at = now;\n return bucket;\n };\n const all = this.all = refill(this.all, this.limits.total, this.limits.totalBurst);\n const own = refill(this.addresses.get(host), this.limits.perAddress, this.limits.perAddressBurst);\n // Kept in the order last asked: the address not heard from the longest goes first.\n this.addresses.delete(host);\n this.addresses.set(host, own);\n if (this.addresses.size > ADDRESSES_KEPT) this.addresses.delete(this.addresses.keys().next().value!);\n if (own.tokens < 1 || all.tokens < 1) return false;\n own.tokens -= 1; all.tokens -= 1;\n return true;\n }\n}\n\ntype Query = { q?: Buffer | string; a?: { k?: unknown; v?: unknown; seq?: unknown; sig?: unknown; salt?: unknown; target?: unknown; info_hash?: unknown } };\ntype QueryPeer = { address: string; port: number };\n/** The parts of bittorrent-dht's node (no API for them) through which it answers queries. */\ninterface DhtInternals { _onquery(query: Query, peer: QueryPeer): void; _rpc: { error(peer: QueryPeer, query: Query, error: [number, string]): void } }\n\n/**\n * A source on loopback is this machine, never a forged address from outside (a packet from the network claiming one is\n * dropped before it gets here): each of its ports is a node of its own (a loopback testnet's nodes all share the host),\n * counted apart. Any other address is counted whatever its port, as a forged source's port is the sender's choice.\n */\nconst LOOPBACK = /^(127\\.|::1$|::ffff:127\\.)/;\nconst bytes = (value: unknown, length: number): boolean => Buffer.isBuffer(value) && value.length === length;\n/** BEP44's bound on an item's value, which bittorrent-dht checks only on what has a `length` (not a dictionary). */\nconst VALUE_MAX = 1_000;\n\n/**\n * What the node answers strangers: queries at `DhtQueryLimit`'s rate, ping, find_node and get/get_peers as BEP5/BEP44\n * say, and puts of signed mutable items only, which is what Pkarr packets are (the testnet's nodes and the public DHT\n * keep each other's that way). It refuses what the app has no use for and bittorrent-dht kept for anyone and served to\n * anyone: immutable items and peers announced for torrents. A put's value is a string of at most 1000 bytes and its seq\n * a non-negative integer, as every Pkarr packet's: bittorrent-dht bounds only a value with a `length`, so a dictionary\n * of 60 KB was kept and served whole to every get. A query whose hash, key, signature or salt is not the string\n * BEP5/BEP44 say (a put signed without a key, a number for a target) threw out of the socket handler: an error nobody\n * caught, one per datagram. It is refused before bittorrent-dht reads it.\n */\nfunction answerBounded(dht: DHT, limit = new DhtQueryLimit()): void {\n const node = dht as unknown as DhtInternals;\n const answer = node._onquery.bind(dht);\n node._onquery = (query, peer) => {\n if (!query || !peer || !limit.take(LOOPBACK.test(peer.address) ? `${peer.address}:${peer.port}` : peer.address)) return;\n const q = query.q?.toString(), a = query.a ?? {};\n if (q === \"announce_peer\") return node._rpc.error(peer, query, [204, \"announce_peer is not served here\"]);\n if (q === \"put\" && (!bytes(a.k, 32) || !bytes(a.sig, SIGNATURE))) return node._rpc.error(peer, query, [203, \"only signed mutable items are stored here\"]);\n if (q === \"put\" && !(Buffer.isBuffer(a.v) && a.v.length <= VALUE_MAX)) return node._rpc.error(peer, query, [205, \"only values of at most 1000 bytes are stored here\"]);\n const malformed = ((q === \"get\" || q === \"find_node\") && !bytes(a.target, 20)) || (q === \"get_peers\" && !bytes(a.info_hash, 20))\n || (q === \"put\" && !(Number.isSafeInteger(a.seq) && (a.seq as number) >= 0))\n || (q === \"put\" && a.salt !== undefined && !(Buffer.isBuffer(a.salt) && a.salt.length <= 64));\n if (malformed) return node._rpc.error(peer, query, [203, \"malformed query\"]);\n try { answer(query, peer); } catch { /* a query bittorrent-dht could not read goes unanswered */ }\n };\n}\n\n/**\n * Every DHT node asked refused a put for holding a later-dated packet of the key (BEP44 error 302, \"sequence number less\n * than current\"): one put by this key's earlier clock, ahead of this one, before a restart forgot its date.\n */\nexport class DhtRefusedError extends Error {\n constructor(reason: string) {\n super(`The DHT holds a later-dated packet of this key (${reason})`);\n this.name = \"DhtRefusedError\";\n }\n}\n\n/**\n * A DHT node of this process: puts and gets Pkarr packets. The node starts at the first thing asked of it: a command\n * that reads only the profile (`chat list`, `settings get`) or a profile set offline asks nothing, and before, every\n * command bound a UDP port and bootstrapped from the public routers all the same, sending them this machine's address.\n */\nexport class Mainline {\n private node: { dht: DHT; listening: Promise<void> } | null = null;\n private closed = false;\n private readonly timeoutMs: number;\n\n constructor(private readonly options: MainlineOptions = {}) {\n this.timeoutMs = options.timeoutMs ?? 20_000;\n }\n\n private get dht(): DHT { return this.started().dht; }\n\n private started(): { dht: DHT; listening: Promise<void> } {\n if (this.closed) throw new Error(\"The DHT node is closed\");\n if (this.node) return this.node;\n const { host } = this.options;\n const bootstrap = this.options.bootstrap === false ? false : this.options.bootstrap?.length ? this.options.bootstrap : undefined;\n // `maxValues` reaches the `lru` that holds others' items, which takes `{ max, maxAge }` as well as a number.\n const dht = new DHT({ verify, maxValues: VALUES_KEPT, ...(bootstrap !== undefined ? { bootstrap } : {}), ...(host ? { host } : {}) });\n // A node of the table that errors must not end the process.\n dht.on(\"error\", () => {});\n answerBounded(dht);\n this.node = { dht, listening: new Promise((resolve) => dht.listen(0, host, () => resolve())) };\n return this.node;\n }\n\n /** Whether the node started (something was put, got or added). */\n get running(): boolean { return this.node !== null; }\n /** Its UDP socket is bound (starts the node). */\n get listening(): Promise<void> { return this.started().listening; }\n\n /** Adds a node (a testnet's peers). */\n addNode(host: string, port: number): void { this.dht.addNode({ host, port }); }\n address(): { port: number } { return this.dht.address() as { port: number }; }\n\n /** Puts a relay payload (`<signature><timestamp><DNS packet>`) as the mutable item of `pubKeyZ32`; resolves with the nodes that took it. */\n put(pubKeyZ32: string, payload: Uint8Array): Promise<number> {\n const k = Buffer.from(publicKeyFromZ32(pubKeyZ32));\n const sig = Buffer.from(payload.subarray(0, SIGNATURE));\n const seq = Number(new DataView(payload.buffer, payload.byteOffset + SIGNATURE, TIMESTAMP).getBigUint64(0));\n const v = Buffer.from(payload.subarray(SIGNATURE + TIMESTAMP));\n return this.bounded(new Promise((resolve, reject) => {\n this.dht.put({ k, v, seq, sig }, (error, _hash, nodes) => {\n if (error) reject((error as Error & { code?: unknown }).code === 302 ? new DhtRefusedError(error.message) : error);\n else if (!nodes) reject(new Error(\"No DHT node took the packet\")); else resolve(nodes);\n });\n }));\n }\n\n /** The newest packet of `pubKeyZ32` the DHT holds, checked; null when nobody has one. */\n get(pubKeyZ32: string): Promise<SignedPacket | null> {\n const k = Buffer.from(publicKeyFromZ32(pubKeyZ32));\n // A mutable item without salt is found under the SHA-1 of its public key (BEP44).\n const target = createHash(\"sha1\").update(k).digest();\n return this.bounded(new Promise((resolve, reject) => {\n this.dht.get(target, { cache: false, verify: verifyUnsalted }, (error, found) => {\n if (error) return reject(error);\n // A record is what its node sent, checked only by its signature: one signed with no `seq` (bittorrent-dht signs\n // `seq || 0`) or with a dictionary for `v` threw here, out of the socket's handler.\n if (!found || !Buffer.isBuffer(found.v) || !Buffer.isBuffer(found.sig) || !Number.isSafeInteger(found.seq) || found.seq < 0) return resolve(null);\n try {\n const timestamp = new Uint8Array(TIMESTAMP);\n new DataView(timestamp.buffer).setBigUint64(0, BigInt(found.seq));\n const payload = new Uint8Array(SIGNATURE + TIMESTAMP + found.v.length);\n payload.set(found.sig, 0); payload.set(timestamp, SIGNATURE); payload.set(found.v, SIGNATURE + TIMESTAMP);\n resolve(parseRelayPayload(pubKeyZ32, payload));\n } catch { resolve(null); }\n });\n }));\n }\n\n private bounded<T>(work: Promise<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => reject(new Error(\"DHT lookup timed out\")), this.timeoutMs);\n work.then((value) => { clearTimeout(timer); resolve(value); }, (error) => { clearTimeout(timer); reject(error); });\n });\n }\n\n /** Closes the node and its socket, if it started; the next thing asked of it starts it again. */\n stop(): Promise<void> {\n const node = this.node;\n this.node = null;\n return node ? new Promise((resolve) => node.dht.destroy(() => resolve())) : Promise.resolve();\n }\n\n destroy(): Promise<void> {\n this.closed = true;\n return this.stop();\n }\n}\n\n/** Keys a `RelaysAndDht` remembers as found nowhere (`missing`). */\nconst MISSING_KEPT = 256;\n\n/** How long a key that asked for a background DHT read counts among those that share the budget (`DhtBackgroundBudget`). */\nconst ASKERS_WINDOW_MS = 2 * 60_000;\nconst MINUTE_MS = 60_000;\n\n/**\n * Background reads that go to the DHT in the relays' place (every relay failing, or failing this read), within the share\n * the relays would have given them (`BACKGROUND_REQUESTS_PER_MINUTE` a minute on each relay): a minute's lookups at\n * most, and each key in its turn, no sooner than the keys asking share that minute (`n` keys at `perMinute` a minute:\n * once every `n / perMinute` minutes). Without it, a daemon looked up every contact away on the DHT four times a minute\n * for as long as the relays failed (200 lookups a minute at 50 contacts, 1,200 at 300), where with the relays up it\n * made 26-54 relay reads a minute in all; each lookup on the real DHT is dozens of UDP queries.\n * Reads someone waits on (not `background`, or `urgent`, `signal`, `door`, `resume`) never wait for it, nor count.\n */\nexport class DhtBackgroundBudget {\n private readonly spent: number[] = [];\n /** Per key, when it last asked (oldest first) and when its last lookup went. */\n private readonly askedAt = new Map<string, number>();\n private readonly lookedAt = new Map<string, number>();\n /** The time of the last `take`: none of the above is dated after it. */\n private latest = -Infinity;\n\n constructor(private readonly perMinute: () => number) {}\n\n /** 0: the lookup goes now (counted). Otherwise how long until this key's turn, in ms; nothing is counted. */\n take(pubKeyZ32: string, now = Date.now()): number {\n // The clock went back (an NTP step, a clock that ran ahead fixed by hand): what is dated after now counts as of now,\n // as just spent. Counted as it was, an hour's step back held every key's lookup for 56 minutes (bug hunt, 2026-11-07).\n if (now < this.latest) {\n this.spent.forEach((at, i) => { this.spent[i] = Math.min(at, now); });\n for (const times of [this.askedAt, this.lookedAt]) for (const [key, at] of times) if (at > now) times.set(key, now);\n }\n this.latest = now;\n this.askedAt.delete(pubKeyZ32);\n this.askedAt.set(pubKeyZ32, now);\n for (const [key, at] of this.askedAt) {\n if (now - at < ASKERS_WINDOW_MS) break;\n this.askedAt.delete(key);\n this.lookedAt.delete(key);\n }\n while (this.spent.length && now - this.spent[0]! >= MINUTE_MS) this.spent.shift();\n const limit = Math.max(1, this.perMinute());\n const turn = Math.ceil(this.askedAt.size * MINUTE_MS / limit);\n const last = this.lookedAt.get(pubKeyZ32);\n const ownTurn = last === undefined ? 0 : last + turn - now;\n // The minute's lookups are spent (keys new to it, all at once): this key's turn, or the minute's next free one if later.\n const minute = this.spent.length >= limit ? this.spent[0]! + MINUTE_MS - now : 0;\n if (ownTurn > 0 || minute > 0) return Math.max(ownTurn, minute, last === undefined ? turn : 0);\n this.spent.push(now);\n this.lookedAt.set(pubKeyZ32, now);\n return 0;\n }\n}\n\n/** A read nobody waits on: what the relays' budget calls background, and what the DHT's (`DhtBackgroundBudget`) holds. */\nconst waitable = (options: PkarrRequestOptions): boolean =>\n !!options.background && !options.urgent && !options.signal && !options.door && !options.resume;\n\n/**\n * The relays first, as the web app reaches Pkarr (its contacts read only the relays), and the DHT beside them: every\n * packet also goes to the DHT, and a read goes there when every relay is failing, the read failed, or this app's own\n * request budget held it back (the DHT has no budget), or every relay rate limits this address (429). A background read\n * this app's budget holds waits for it. Background reads the DHT answers in the relays' place keep to the relays'\n * background share (`DhtBackgroundBudget`).\n *\n * `pinned`: the relays given are the only ones (`GHOSTLY_PKARR_RELAYS`, a private network): the profile's `relays`\n * setting does not replace them. With no DHT (`dht` null), the relays alone carry every packet.\n */\nexport class RelaysAndDht implements PkarrTransport {\n readonly relays: RelayTransport;\n private lastVia: \"relay\" | \"dht\" = \"relay\";\n /**\n * Keys a hedged read found nowhere: the DHT said so before the relays' slow 404 came, so the next poll of the key\n * hedges late too (`HEDGE_MISSING_MS`), not only once that 404 lands. The newest `MISSING_KEPT`.\n */\n private readonly missing = new Set<string>();\n /** Background reads on the DHT in the relays' place, at their background share (`DhtBackgroundBudget`). */\n private readonly dhtBackground = new DhtBackgroundBudget(() => BACKGROUND_REQUESTS_PER_MINUTE * this.relays.describe().relays.length);\n\n /** Off while the profile keeps to the relays (Hide my IP from contacts, `configure`'s `dhtDirect: false`). */\n private direct = true;\n\n constructor(private readonly mainline: Mainline | null, relays: RelayTransportOptions = {}, private readonly pinned = false) {\n this.relays = new RelayTransport(relays);\n }\n\n /** The DHT this transport reaches now: none while the profile keeps to the relays. */\n private get dht(): Mainline | null { return this.direct ? this.mainline : null; }\n\n async publish(identity: Identity, records: GhostRecord[], options: PkarrRequestOptions = {}): Promise<void> {\n // BEP44 sequence numbers must strictly increase, on the relays and on the DHT alike: one payload for both, dated\n // past every packet put or read under the key (`RelayTransport.publishDated`), whichever clock dated those.\n // With the DHT, the packet goes there whatever the relays' budgets say: signed every time. Without it (a private\n // network's relays only), a publish none of them takes now is not signed at all.\n await this.relays.publishDated(identity, records, (key, payload, timestamp, conflict) => this.putBoth(key, payload, options, conflict, timestamp), options, false, this.dht !== null);\n }\n\n publishPayload(pubKeyZ32: string, payload: Uint8Array, options: PkarrRequestOptions = {}): Promise<void> {\n return this.putBoth(pubKeyZ32, payload, options);\n }\n\n /**\n * `timestamp`: the payload was just signed here (`publish`), dated so; its signature is not checked again on the way\n * to the relays. Without it (`publishPayload`, signed elsewhere) the relays' side checks it to read its date.\n */\n private async putBoth(pubKeyZ32: string, payload: Uint8Array, options: PkarrRequestOptions, conflict?: (relay: string, read?: () => Promise<bigint | null>) => void, timestamp?: bigint): Promise<void> {\n const toRelays = () => timestamp === undefined\n ? this.relays.publishPayload(pubKeyZ32, payload, options, conflict)\n : this.relays.putSigned(pubKeyZ32, payload, timestamp, options, conflict);\n if (!this.dht) return toRelays();\n const onDht = this.dht.put(pubKeyZ32, payload);\n onDht.catch(() => {});\n const onRelays = toRelays();\n onRelays.catch(() => {});\n // Out on the DHT is out (a Pkarr relay reads the DHT for a key it has not got): a relay that takes the request and\n // never answers held each publish for its 10 s timeout, an invite's first among them, while the DHT took it in\n // milliseconds. The relays' copy finishes in the background. A budget's hold is said before any request goes, so\n // it wins this race: once the DHT took the packet, that is out too, and the relays get it when their budget frees\n // (`putLater`; browser contacts read only them). Said held back, the link signed it and put it on the DHT again in\n // 0.25-4 s, at budget 1.5-2.2x the DHT puts of a DHT-only daemon.\n let refused: unknown;\n const tookIt = onDht.then(() => true, (error: unknown) => {\n refused = error;\n // The DHT holds a later-dated packet of this key, as a relay that answers 409 does: its date is read there, and\n // the records go again dated just past it (`publishDated`). After a clock that ran ahead was set right, a\n // restarted CLI had every put refused, tried again every 4 s until the clock caught up (15 a minute per chat), and\n // texts to a contact away stayed queued.\n if (error instanceof DhtRefusedError) conflict?.(\"dht\", () => this.fromDht(pubKeyZ32).then((packet) => packet?.timestampMicros ?? null));\n return false;\n });\n if (await Promise.race([onRelays.then(() => false, () => false), tookIt])) return;\n try {\n await onRelays;\n } catch (error) {\n if (isDiscoveryBudgetError(error)) {\n if (!(await tookIt)) throw error;\n this.relays.putLater(pubKeyZ32, payload, timestamp, options);\n return;\n }\n // The relays failed: the DHT's answer is the publish's, and its refusal is said with theirs.\n if (!(await tookIt)) throw refused instanceof Error ? new Error(`${error instanceof Error ? error.message : String(error)}; ${refused.message}`, { cause: error }) : error;\n }\n }\n\n async resolve(pubKeyZ32: string, options: PkarrRequestOptions = {}, keptOnFailure = true): Promise<SignedPacket | null> {\n if (!this.dht) return this.relays.resolve(pubKeyZ32, options, keptOnFailure);\n let fromRelays: SignedPacket | null = null, failed: unknown = null;\n // Every relay left alone for failing: the relays answer from what they last saw, if anything; the DHT is asked.\n const down = () => this.relays.discovery().relays.every((relay) => relay.state === \"failing\");\n if (!down()) {\n const started = Date.now();\n // A read the relays failed asks the DHT at once, their last copy kept to weigh against its packet. Handed back\n // as their answer, it stood for each 20 s cooldown until the breaker opened: about 40 s of a contact's old packet\n // with the newer one on the DHT (bug hunt, 2026-10-17).\n const relays = this.relays.resolve(pubKeyZ32, options, false).then((packet) => ({ packet, failed: null as unknown }), (error: unknown) => ({ packet: null, failed: error }));\n let timer: ReturnType<typeof setTimeout> | undefined;\n // A key whose last read found nothing: the relays take 3-5 s to say a key is not there\n // (they ask the DHT themselves), and a hedge at HEDGE_MS made every poll of an unused invite's key a DHT lookup\n // of its own (+47 in 10 min: agents#1595). Their own hedge waits as long (`RelayTransport`, `HEDGE_MISSING_MS`).\n const hedgeAfter = this.relays.lastReadMissing(pubKeyZ32) || this.missing.has(pubKeyZ32) ? HEDGE_MISSING_MS : HEDGE_MS;\n const answered = await Promise.race([relays, new Promise<null>((resolve) => { timer = setTimeout(() => resolve(null), hedgeAfter); })]);\n clearTimeout(timer);\n // The relays have not answered within a hedge's time (one that takes requests and never answers held each read\n // for its 10 s timeout): the DHT is asked too.\n if (!answered) {\n const found = await this.hedged(pubKeyZ32, relays, started);\n this.missing.delete(pubKeyZ32);\n if (!found) { this.missing.add(pubKeyZ32); if (this.missing.size > MISSING_KEPT) this.missing.delete(this.missing.values().next().value!); }\n return found;\n }\n ({ packet: fromRelays, failed } = answered);\n // No relay is asked now: each one rate limits this address (429) for as long as it said, or fails. Their answer is\n // what they last saw, or a wait, and the DHT is asked in their place, as when they all fail (a background read\n // at their share). Taken as their answer, a daemon whose relays answered 429 for 10 minutes read none of its 50\n // contacts in that time, and looked none up on the DHT (bug hunt, 2026-11-11).\n const refusing = this.relays.discovery().relays.every((relay) => relay.state !== \"ok\");\n // The relays' budget held the read back: the DHT, which has no budget and already has a contact's first\n // envelope, is asked instead. Waiting for the relays' minute made each pairing past ~10 chats on working relays\n // take 3-18 s (13-37 s on one relay), where DHT-only pairings take 0.1-2.8 s (agents#1715). Found nowhere there,\n // or a background read, it is still a wait.\n if (isDiscoveryBudgetError(failed) && !(refusing && options.background)) return this.heldBack(pubKeyZ32, failed, options);\n if (failed instanceof RelaysFailedError) fromRelays = failed.kept;\n if (!failed) this.lastVia = \"relay\";\n if (!failed && !down() && !refusing) return fromRelays;\n }\n try {\n // A background read the DHT answers instead of the relays waits its turn there (`DhtBackgroundBudget`), as it did\n // on them: held back, as their budget holds one. With no relay set at all the DHT is the only way, not a stand-in.\n if (waitable(options) && this.relays.describe().relays.length > 0) {\n const wait = this.dhtBackground.take(pubKeyZ32);\n if (wait > 0) throw new DiscoveryBudgetError(wait, \"Background DHT reads in the relays' place are at their share; retry shortly\");\n }\n const fromDht = await this.fromDht(pubKeyZ32);\n this.lastVia = \"dht\";\n return newerPacket(fromRelays, fromDht);\n } catch (error) {\n // Nothing answered, the DHT neither: the relays' last copy is the answer, or, for a caller that asks, the failure\n // that carries it (`keptOnFailure`).\n if (fromRelays && (keptOnFailure || !(failed instanceof RelaysFailedError))) return fromRelays;\n throw failed ?? error;\n }\n }\n\n private async heldBack(pubKeyZ32: string, held: unknown, options: PkarrRequestOptions): Promise<SignedPacket> {\n if (options.background) throw held;\n const fromDht = await this.fromDht(pubKeyZ32).catch(() => null);\n if (!fromDht) throw held;\n this.lastVia = \"dht\";\n return fromDht;\n }\n\n private async fromDht(pubKeyZ32: string): Promise<SignedPacket | null> {\n // The switch turned while a read was on its way to the DHT: it does not go.\n if (!this.dht) throw new Error(\"The DHT is not reached while the profile keeps to the relays\");\n const packet = await this.dht.get(pubKeyZ32);\n if (packet) this.relays.sawTimestamp(pubKeyZ32, packet.timestampMicros);\n return packet;\n }\n\n /**\n * A read the relays are slow to answer, the DHT asked beside them. The relays' packet first is the answer, as without\n * the hedge. The DHT's first waits for the relays until a slow relay would have had its say (`SLOW_MS`, a relay\n * fetching the packet from the DHT itself), or until they answer, and the newer of the two is the answer: taken at\n * once, the DHT's older copy won every read over a relay that took 2 s with the newer one (agents#1594). The DHT\n * finding none is the answer once that time is up too, or once the relays answered. Both failing: the relays' reason.\n */\n private async hedged(pubKeyZ32: string, relays: Promise<{ packet: SignedPacket | null; failed: unknown }>, started: number): Promise<SignedPacket | null> {\n const dht = this.fromDht(pubKeyZ32).then((packet) => ({ packet, failed: null as unknown, via: \"dht\" as const }), (error: unknown) => ({ packet: null, failed: error, via: \"dht\" as const }));\n const viaRelays = relays.then((r) => ({ ...r, via: \"relay\" as const }));\n const first = await Promise.race([viaRelays, dht]);\n if (first.packet && first.via === \"relay\") { this.lastVia = \"relay\"; return first.packet; }\n const fromDht = await dht;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const slowAfter = new Promise<null>((resolve) => { timer = setTimeout(() => resolve(null), Math.max(0, SLOW_MS - (Date.now() - started))); });\n const fromRelays = await Promise.race([viaRelays, slowAfter]);\n clearTimeout(timer);\n if (fromDht.packet) {\n const newer = newerPacket(fromRelays?.packet, fromDht.packet);\n this.lastVia = newer === fromDht.packet ? \"dht\" : \"relay\";\n return newer;\n }\n if (fromRelays?.packet) { this.lastVia = \"relay\"; return fromRelays.packet; }\n if (!fromDht.failed) { this.lastVia = \"dht\"; return null; }\n if (!fromRelays) throw fromDht.failed;\n if (!fromRelays.failed) return null;\n throw fromRelays.failed;\n }\n\n describe(): { protocol: string; relays: string[] } {\n return { protocol: this.dht ? \"Pkarr relays (HTTP), and the Mainline DHT (BEP44) directly\" : \"Pkarr relays (HTTP)\", relays: this.relays.describe().relays };\n }\n discovery(): DiscoveryStatus {\n const status = this.relays.discovery();\n return this.lastVia === \"dht\" ? { ...status, path: { via: \"dht\" } } : status;\n }\n subscribe(listener: Parameters<RelayTransport[\"subscribe\"]>[0]): () => void { return this.relays.subscribe(listener); }\n /** A relay's answer only: a packet the DHT hands back when the relays are down may be older than one already read. */\n readAnsweredAt(pubKeyZ32: string): number | undefined { return this.relays.readAnsweredAt(pubKeyZ32); }\n readHeldBackFor(pubKeyZ32: string): number | undefined { return this.relays.readHeldBackFor(pubKeyZ32); }\n /** With the DHT every packet goes there too, whatever the relays' budgets say: nothing is held. */\n publishHeld(pubKeyZ32: string, options?: PkarrRequestOptions): DiscoveryBudgetError | null { return this.dht ? null : this.relays.publishHeld(pubKeyZ32, options); }\n onServerTime(listener: Parameters<RelayTransport[\"onServerTime\"]>[0]): () => void { return this.relays.onServerTime(listener); }\n /**\n * `dhtDirect: false` (Hide my IP from contacts): no packet is put on or read from the DHT, and its node is closed, so\n * no UDP goes from this machine to a DHT node; true again starts it at the next put or read. Absent leaves it as it is.\n */\n configure({ relays, dhtDirect }: { relays: string[]; readRelays: boolean; dhtDirect?: boolean }): void {\n if (!this.pinned) this.relays.setRelays(relays);\n if (dhtDirect === undefined) return;\n this.direct = dhtDirect;\n if (!dhtDirect) this.mainline?.stop().catch(() => {});\n }\n /**\n * The relays' side only: the DHT side keeps nothing per key it puts. What it keeps per key it reads is bounded\n * (`missing`, `MISSING_KEPT`; the background budget's two-minute window).\n */\n forget(keys: Iterable<string>): void { this.relays.forget(keys); }\n}\n"],"mappings":";;;;;AA2BA,IAAM,YAAY;AAAI,IAAA,YAAY;AAClC,IAAMA,YAAU,KAAiB,SAAqB,QAAoB;CAAE,IAAI;EAAE,OAAO,QAAQ,OAAO,KAAK,SAAS,GAAG;CAAG,QAAQ;EAAE,OAAO;CAAO;AAAE;;;;;;AAMtJ,IAAM,SAAS,OAAO,KAAK,QAAQ;AACnC,IAAM,kBAAkB,KAAiB,SAAqB,QAC5D,CAAC,OAAO,KAAK,QAAQ,QAAQ,QAAQ,YAAY,KAAK,IAAI,QAAQ,QAAQ,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAKA,SAAO,KAAK,SAAS,GAAG;;AAGtI,IAAM,eAAe;CAAE,YAAY;CAAG,iBAAiB;CAAI,OAAO;CAAI,YAAY;AAAI;;AAEtF,IAAM,iBAAiB;;AAEvB,IAAM,cAAc;CAAE,KAAK;CAAO,QAAQ;AAAgB;;;;;;;;AAS1D,IAAa,gBAAb,MAA2B;CAII;CAH7B,4BAA6B,IAAI,IAA4C;CAC7E,MAAqD;CAErD,YAAY,SAA+C,cAAc;EAA5C,KAAA,SAAA;CAA6C;;CAG1E,IAAI,OAAe;EAAE,OAAO,KAAK,UAAU;CAAM;;CAGjD,KAAK,MAAc,MAAM,KAAK,IAAI,GAAY;EAC5C,MAAM,UAAU,QAA2D,MAAc,UAAkB;GACzG,IAAI,CAAC,QAAQ,OAAO;IAAE,QAAQ;IAAO,IAAI;GAAI;GAE7C,OAAO,SAAS,KAAK,IA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,WAAW,KAAK,UAAU,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;CACtD;;;;;CAKA,OAAO,MAA8B;EAAE,KAAK,OAAO,OAAO,IAAI;CAAG;AACnE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mints-j5XAOk4f.js","names":[],"sources":["../../../browser/src/shared/mints.ts"],"sourcesContent":["import type { WalletNetwork } from \"@ghostly/core\";\n/**\n * Mints a new wallet starts with, so nobody has to know what a mint is before\n * receiving sats. The first one that answers is where Lightning invoices are\n * created; ecash from any of them is accepted from contacts.\n *\n * A mint is a custodian: it holds the sats. This list is a product decision,\n * to be reviewed regularly. It was picked on 2026-09-18 from the community\n * auditor (https://audit.8333.space): mints with thousands of audited swaps,\n * the highest success rates and an OK state at the time.\n */\nexport const DEFAULT_MINTS = [\n \"https://mint.minibits.cash/Bitcoin\",\n \"https://21mint.me\",\n \"https://mint.mountainlake.io\",\n];\n\n/** Public test mint: worthless sats, invoices settle by themselves. */\nexport const TEST_MINT = \"https://testnut.cashu.space\";\n\n/**\n * Mints whose sats are worth nothing: never counted as money, never mixed with real sats.\n * Mutinynet's mint (cashu.mutinynet.com) would belong here, but on 2026-09-22 it answered with a\n * duplicated Access-Control-Allow-Origin header that every browser and WebView rejects.\n */\nexport const TEST_MINTS: readonly string[] = [TEST_MINT];\nexport const isTestMint = (url: string) => TEST_MINTS.includes(mintUrlSpelling(url));\n\n/**\n * A mint URL spelled as the wallet stores its mints: lower-case scheme and host, no default port, no trailing slash.\n * Another Cashu wallet's token or request names a mint as its user typed it (`HTTPS://Mint.Example:443/`), which is\n * still one of ours. Not a check: `normalizeMintUrl` is the one that refuses a mint.\n */\nexport function mintUrlSpelling(url: string): string {\n try {\n const parsed = new URL(url.trim());\n if (parsed.origin !== \"null\") return `${parsed.origin}${parsed.pathname.replace(/\\/+$/, \"\")}`;\n } catch {\n // not a URL: compared as written\n }\n return url.trim().replace(/\\/+$/, \"\");\n}\n\n/** A mint on this very machine (a local test server): whatever it issues is not money anyone else holds. */\nexport function isLocalMint(url: string): boolean {\n try { return [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(new URL(url).hostname); } catch { return false; }\n}\n\n/**\n * Mints whose sats are worth nothing: the public test mints and mints on this machine. They belong to\n * the Testnet mode, and their ecash never settles a request for real sats. Only the public test mints\n * are ever added by themselves (a contact must not make this app contact a port on this machine).\n */\nexport const isWorthlessMint = (url: string) => isTestMint(url) || isLocalMint(url);\n\n/**\n * A mint whose word \"this invoice is paid\" proves nobody paid it. The public test mint runs a fake Lightning backend\n * that marks every invoice paid by itself, and a mint on this machine is a test server that may do the same. Its\n * invoices are still shown to be paid, but the wallet mints one only once a payer says it paid it (see `held` on\n * StoredQuote); asking it for test coins on purpose is `CashuWallet.testCoins`.\n */\nexport const paysItsOwnInvoices = isWorthlessMint;\n\n/**\n * Mints on this machine the operator declared test servers with a fake Lightning backend (the CLI's\n * `GHOSTLY_TEST_MINTS`, for regtest and e2e stacks). Nothing else declares one: the apps never do.\n */\nconst declaredTestMints = new Set<string>();\nconst bare = (url: string) => url.trim().replace(/\\/+$/, \"\");\nexport function declareTestMints(urls: readonly string[]): void {\n for (const url of urls) if (isLocalMint(bare(url))) declaredTestMints.add(bare(url));\n}\n\n/**\n * Whether a Testnet wallet may pay a Bitcoin (`lnbc`) invoice through this mint. Test mints issue `lnbc` invoices,\n * but so does a real node: only a mint known to fake its Lightning moves nothing real when it pays one. That is the\n * public test mint, or a mint on this machine the operator declared a test server; never any other mint on this\n * machine, which may be a self-hosted mint with real sats behind it.\n */\nexport const fakesLightning = (url: string) => isTestMint(url) || declaredTestMints.has(bare(url));\n\n/** Refused before any mint is asked: see `fakesLightning`. */\nexport const BITCOIN_INVOICE_ON_TESTNET = \"This is a Bitcoin invoice (real money): test sats pay one only through the public test mint. Nothing was sent.\";\n\n/** Real money, or test networks: each wallet has its own (see WalletNetwork in @ghostly/core). */\nexport type WalletMode = WalletNetwork;\n/** The network a Cashu mint's ecash belongs to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|
|
1
|
-
import { n as PROVIDER_PLATFORMS } from "./types-Clyb52K2.js";
|
|
2
|
-
//#region ../browser/src/engine/paymentAdapters/providers/nwcProvider.ts
|
|
3
|
-
/**
|
|
4
|
-
* Nostr Wallet Connect as the source picker lists it, and its connection URI. The client (`./nwc`) and its NIP-04 /
|
|
5
|
-
* NIP-44 encryption load when a wallet connects, not with the app.
|
|
6
|
-
*/
|
|
7
|
-
var MAX_URI = 2048;
|
|
8
|
-
var MAX_RELAYS = 5;
|
|
9
|
-
var HEX64 = /^[0-9a-f]{64}$/;
|
|
10
|
-
var bytes = (text) => Uint8Array.from(text.match(/../g), (b) => parseInt(b, 16));
|
|
11
|
-
/** Only secure relays, except on this machine (a local test relay). */
|
|
12
|
-
function checkRelay(address) {
|
|
13
|
-
let relay;
|
|
14
|
-
try {
|
|
15
|
-
relay = new URL(address);
|
|
16
|
-
} catch {
|
|
17
|
-
throw new Error("The connection URI has a relay that is not a URL");
|
|
18
|
-
}
|
|
19
|
-
if (relay.username || relay.password || relay.hash) throw new Error("The connection URI has a relay with credentials in it");
|
|
20
|
-
const loopback = [
|
|
21
|
-
"127.0.0.1",
|
|
22
|
-
"localhost",
|
|
23
|
-
"[::1]"
|
|
24
|
-
].includes(relay.hostname);
|
|
25
|
-
if (!(relay.protocol === "wss:" || relay.protocol === "ws:" && loopback)) throw new Error("Use a wallet whose relay is secure (wss://)");
|
|
26
|
-
return relay.href;
|
|
27
|
-
}
|
|
28
|
-
/** Reads a `nostr+walletconnect://` URI. Its errors never repeat it: it holds a secret. */
|
|
29
|
-
function parseNwcUri(input) {
|
|
30
|
-
const text = (input ?? "").trim();
|
|
31
|
-
if (text.length > MAX_URI) throw new Error("That connection URI is too long");
|
|
32
|
-
const match = /^(?:nostr\+walletconnect|nostrwalletconnect):(?:\/\/)?([0-9a-fA-F]{64})\/?\?([^#]*)$/.exec(text);
|
|
33
|
-
if (!match) throw new Error("That is not a Nostr Wallet Connect URI (nostr+walletconnect://…)");
|
|
34
|
-
const params = new URLSearchParams(match[2]);
|
|
35
|
-
const secret = (params.get("secret") ?? "").toLowerCase();
|
|
36
|
-
if (!HEX64.test(secret) || /^0+$/.test(secret)) throw new Error("The connection URI has no valid secret");
|
|
37
|
-
const relays = [...new Set(params.getAll("relay").map(checkRelay))];
|
|
38
|
-
if (!relays.length) throw new Error("The connection URI names no relay");
|
|
39
|
-
if (relays.length > MAX_RELAYS) throw new Error("The connection URI names too many relays");
|
|
40
|
-
return {
|
|
41
|
-
walletPubkey: match[1].toLowerCase(),
|
|
42
|
-
relays,
|
|
43
|
-
secret: bytes(secret)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/** The name the NWC client gives its source: the wallet's own name and its relay's host. */
|
|
47
|
-
var nwcAlias = (wallet, relayHost) => `${wallet ?? "NWC wallet"} via ${relayHost}`;
|
|
48
|
-
/** The wallet's own name in an `nwcAlias` ("" when the wallet did not say one). The host never holds a space. */
|
|
49
|
-
function nwcWalletName(alias) {
|
|
50
|
-
const at = alias.lastIndexOf(" via ");
|
|
51
|
-
const wallet = at > 0 ? alias.slice(0, at) : alias;
|
|
52
|
-
return wallet === "NWC wallet" ? "" : wallet;
|
|
53
|
-
}
|
|
54
|
-
var nwc = {
|
|
55
|
-
id: "nwc",
|
|
56
|
-
label: "Nostr Wallet Connect",
|
|
57
|
-
kind: "lightning",
|
|
58
|
-
description: "A wallet you connect with its NWC URI (Alby Hub, a node's NWC service, a hosted wallet). That wallet holds the sats and sets its own fee limit: custodial or not depends on the wallet.",
|
|
59
|
-
networks: [
|
|
60
|
-
"bitcoin",
|
|
61
|
-
"testnet",
|
|
62
|
-
"signet",
|
|
63
|
-
"mutinynet",
|
|
64
|
-
"regtest"
|
|
65
|
-
],
|
|
66
|
-
platforms: PROVIDER_PLATFORMS,
|
|
67
|
-
fields: [{
|
|
68
|
-
name: "uri",
|
|
69
|
-
label: "Connection URI",
|
|
70
|
-
kind: "secret",
|
|
71
|
-
placeholder: "nostr+walletconnect://…",
|
|
72
|
-
help: "From your wallet's app connections. Allow making, paying and looking up invoices, and reading the balance."
|
|
73
|
-
}],
|
|
74
|
-
validate({ secrets }) {
|
|
75
|
-
parseNwcUri(secrets.uri ?? "");
|
|
76
|
-
},
|
|
77
|
-
wallet({ secrets }) {
|
|
78
|
-
return parseNwcUri(secrets.uri ?? "").walletPubkey;
|
|
79
|
-
},
|
|
80
|
-
async create({ secrets }, host) {
|
|
81
|
-
const { NwcLightning } = await import("./nwc-CtZypDcv.js");
|
|
82
|
-
return NwcLightning.connect(secrets.uri, { signal: host.signal });
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
//#endregion
|
|
86
|
-
export { parseNwcUri as i, nwcAlias as n, nwcWalletName as r, nwc as t };
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=nwcProvider-DYHkd0iu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nwcProvider-DYHkd0iu.js","names":[],"sources":["../../../browser/src/engine/paymentAdapters/providers/nwcProvider.ts"],"sourcesContent":["import type { LightningProviderDescriptor } from \"./lightning\";\nimport { PROVIDER_PLATFORMS } from \"./types\";\n\n/**\n * Nostr Wallet Connect as the source picker lists it, and its connection URI. The client (`./nwc`) and its NIP-04 /\n * NIP-44 encryption load when a wallet connects, not with the app.\n */\n\nconst MAX_URI = 2048;\nconst MAX_RELAYS = 5;\nconst HEX64 = /^[0-9a-f]{64}$/;\nconst bytes = (text: string) => Uint8Array.from(text.match(/../g)!, (b) => parseInt(b, 16));\n\nexport interface NwcConnection {\n walletPubkey: string;\n relays: string[];\n /** The client key the wallet granted: a secret. */\n secret: Uint8Array;\n}\n\n/** Only secure relays, except on this machine (a local test relay). */\nfunction checkRelay(address: string): string {\n let relay: URL;\n try { relay = new URL(address); } catch { throw new Error(\"The connection URI has a relay that is not a URL\"); }\n if (relay.username || relay.password || relay.hash) throw new Error(\"The connection URI has a relay with credentials in it\");\n const loopback = [\"127.0.0.1\", \"localhost\", \"[::1]\"].includes(relay.hostname);\n if (!(relay.protocol === \"wss:\" || (relay.protocol === \"ws:\" && loopback))) throw new Error(\"Use a wallet whose relay is secure (wss://)\");\n return relay.href;\n}\n\n/** Reads a `nostr+walletconnect://` URI. Its errors never repeat it: it holds a secret. */\nexport function parseNwcUri(input: string): NwcConnection {\n const text = (input ?? \"\").trim();\n if (text.length > MAX_URI) throw new Error(\"That connection URI is too long\");\n const match = /^(?:nostr\\+walletconnect|nostrwalletconnect):(?:\\/\\/)?([0-9a-fA-F]{64})\\/?\\?([^#]*)$/.exec(text);\n if (!match) throw new Error(\"That is not a Nostr Wallet Connect URI (nostr+walletconnect://…)\");\n const params = new URLSearchParams(match[2]);\n const secret = (params.get(\"secret\") ?? \"\").toLowerCase();\n if (!HEX64.test(secret) || /^0+$/.test(secret)) throw new Error(\"The connection URI has no valid secret\");\n const relays = [...new Set(params.getAll(\"relay\").map(checkRelay))];\n if (!relays.length) throw new Error(\"The connection URI names no relay\");\n if (relays.length > MAX_RELAYS) throw new Error(\"The connection URI names too many relays\");\n return { walletPubkey: match[1].toLowerCase(), relays, secret: bytes(secret) };\n}\n\n/** What an NWC wallet that does not say its name is called. */\nexport const NWC_UNNAMED = \"NWC wallet\";\n\n/** The name the NWC client gives its source: the wallet's own name and its relay's host. */\nexport const nwcAlias = (wallet: string | undefined, relayHost: string) => `${wallet ?? NWC_UNNAMED} via ${relayHost}`;\n\n/** The wallet's own name in an `nwcAlias` (\"\" when the wallet did not say one). The host never holds a space. */\nexport function nwcWalletName(alias: string): string {\n const at = alias.lastIndexOf(\" via \");\n const wallet = at > 0 ? alias.slice(0, at) : alias;\n return wallet === NWC_UNNAMED ? \"\" : wallet;\n}\n\nexport const nwc: LightningProviderDescriptor = {\n id: \"nwc\",\n label: \"Nostr Wallet Connect\",\n kind: \"lightning\",\n description: \"A wallet you connect with its NWC URI (Alby Hub, a node's NWC service, a hosted wallet). That wallet holds the sats and sets its own fee limit: custodial or not depends on the wallet.\",\n networks: [\"bitcoin\", \"testnet\", \"signet\", \"mutinynet\", \"regtest\"],\n platforms: PROVIDER_PLATFORMS,\n fields: [{\n name: \"uri\", label: \"Connection URI\", kind: \"secret\", placeholder: \"nostr+walletconnect://…\",\n help: \"From your wallet's app connections. Allow making, paying and looking up invoices, and reading the balance.\",\n }],\n validate({ secrets }) { parseNwcUri(secrets.uri ?? \"\"); },\n // The wallet's key: the same URI spelled another way, or another app connection to that wallet, reads the same balance.\n wallet({ secrets }) { return parseNwcUri(secrets.uri ?? \"\").walletPubkey; },\n async create({ secrets }, host) {\n const { NwcLightning } = await import(\"./nwc\");\n return NwcLightning.connect(secrets.uri, { signal: host.signal });\n },\n};\n"],"mappings":";;;;;;AAQA,IAAM,UAAU;AAChB,IAAM,aAAa;AACnB,IAAM,QAAQ;AACd,IAAM,SAAS,SAAiB,WAAW,KAAK,KAAK,MAAM,KAAK,IAAK,MAAM,SAAS,GAAG,EAAE,CAAC;;AAU1F,SAAS,WAAW,SAAyB;CAC3C,IAAI;CACJ,IAAI;EAAE,QAAQ,IAAI,IAAI,OAAO;CAAG,QAAQ;EAAE,MAAM,IAAI,MAAM,kDAAkD;CAAG;CAC/G,IAAI,MAAM,YAAY,MAAM,YAAY,MAAM,MAAM,MAAM,IAAI,MAAM,uDAAuD;CAC3H,MAAM,WAAW;EAAC;EAAa;EAAa;CAAO,CAAC,CAAC,SAAS,MAAM,QAAQ;CAC5E,IAAI,EAAE,MAAM,aAAa,UAAW,MAAM,aAAa,SAAS,WAAY,MAAM,IAAI,MAAM,6CAA6C;CACzI,OAAO,MAAM;AACf;;AAGA,SAAgB,YAAY,OAA8B;CACxD,MAAM,QAAQ,SAAS,GAAA,CAAI,KAAK;CAChC,IAAI,KAAK,SAAS,SAAS,MAAM,IAAI,MAAM,iCAAiC;CAC5E,MAAM,QAAQ,uFAAuF,KAAK,IAAI;CAC9G,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,kEAAkE;CAC9F,MAAM,SAAS,IAAI,gBAAgB,MAAM,E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
1
|
-
import { Wi as IdentityCheckUnavailable, qi as boundVerifiedIdentity } from "./src-DjVj2ynY.js";
|
|
2
|
-
import { l as providerDescriptorProblems } from "./types-Clyb52K2.js";
|
|
3
|
-
//#region ../browser/src/shared/features.ts
|
|
4
|
-
/**
|
|
5
|
-
* A build that may be put into test mode: a development build (`import.meta.env.DEV`, which vitest also sets) or the
|
|
6
|
-
* e2e suite's build (`VITE_APPS_TEST`, fixed when the build is made, as the mini-app switch is). A release build is
|
|
7
|
-
* neither: Vite folds this to `false` there, so the storage flags the test fakes answer to are ignored. The fakes
|
|
8
|
-
* themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.
|
|
9
|
-
*/
|
|
10
|
-
var testBuild = () => {
|
|
11
|
-
try {
|
|
12
|
-
return false;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A suite's switch in the page's storage (`localStorage["ghostly-test-…"]`), read only in a test build (`testBuild`): a
|
|
19
|
-
* release build reads none, so a leftover or pasted key changes nothing there. Null when unset, unreadable or released.
|
|
20
|
-
*/
|
|
21
|
-
var testSwitch = (key) => {
|
|
22
|
-
if (!testBuild()) return null;
|
|
23
|
-
try {
|
|
24
|
-
return globalThis.localStorage?.getItem(key) ?? null;
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region ../browser/src/proofs/verify.ts
|
|
31
|
-
var DAY = 86400;
|
|
32
|
-
/**
|
|
33
|
-
* The checks every proof goes through, whatever its provider: known provider, validity within the
|
|
34
|
-
* provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule
|
|
35
|
-
* (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).
|
|
36
|
-
* The engine verifies a contact's proof, and the person's own proof before saving it, only through this.
|
|
37
|
-
*/
|
|
38
|
-
async function verifyIdentity(providers, statement, evidence, ctx) {
|
|
39
|
-
const { binding } = statement;
|
|
40
|
-
const provider = providers.find((p) => p.id === binding.provider);
|
|
41
|
-
if (!provider) throw new Error("This app cannot verify this kind of identity");
|
|
42
|
-
if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, 3456e4)) throw new Error("The proof lasts longer than this kind of identity allows");
|
|
43
|
-
if (JSON.stringify(evidence ?? null).length > 16384) throw new Error("Evidence too large");
|
|
44
|
-
const parsed = provider.parseEvidence(evidence);
|
|
45
|
-
const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));
|
|
46
|
-
if (provider.category === "self-custodied" && verified.subject !== binding.subject) throw new Error("The evidence is for another identity");
|
|
47
|
-
if (provider.category === "provider-attested" && !verified.attester) throw new Error("The evidence does not say who attests it");
|
|
48
|
-
return verified;
|
|
49
|
-
}
|
|
50
|
-
/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */
|
|
51
|
-
function descriptorProblems(p) {
|
|
52
|
-
const problems = [];
|
|
53
|
-
if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push("id must match ^[a-z][a-z0-9-]{0,31}$");
|
|
54
|
-
if (!p.label?.trim()) problems.push("label is empty");
|
|
55
|
-
if (!p.description?.trim()) problems.push("description is empty");
|
|
56
|
-
if (!p.privacy?.trim()) problems.push("privacy is empty: say what verify contacts");
|
|
57
|
-
if (p.category !== "self-custodied" && p.category !== "provider-attested") problems.push("category is unknown");
|
|
58
|
-
if (!p.platforms.length) problems.push("no platforms");
|
|
59
|
-
const { defaultDays, maxDays } = p.validity;
|
|
60
|
-
if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= 3456e4)) problems.push("validity must be whole days, 1 ≤ default ≤ max ≤ 400");
|
|
61
|
-
if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push("recheck.afterSeconds must be at least 60");
|
|
62
|
-
if (p.recheck?.perHour !== void 0 && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push("recheck.perHour must be a whole number, at least 1");
|
|
63
|
-
if (!p.signers.length) problems.push("no signers");
|
|
64
|
-
const ids = p.signers.map((s) => s.id);
|
|
65
|
-
if (new Set(ids).size !== ids.length) problems.push("signer ids are not unique");
|
|
66
|
-
for (const s of p.signers) {
|
|
67
|
-
if (![
|
|
68
|
-
"in-app",
|
|
69
|
-
"external-tool",
|
|
70
|
-
"redirect",
|
|
71
|
-
"publish"
|
|
72
|
-
].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);
|
|
73
|
-
if (s.kind === "in-app" && typeof s.run !== "function") problems.push(`signer ${s.id} has no run()`);
|
|
74
|
-
if (s.kind === "external-tool" && (typeof s.instructions !== "function" || typeof s.parse !== "function")) problems.push(`signer ${s.id} needs instructions() and parse()`);
|
|
75
|
-
if (s.kind === "redirect" && typeof s.start !== "function") problems.push(`signer ${s.id} has no start()`);
|
|
76
|
-
if (s.kind === "publish" && (typeof s.instructions !== "function" || typeof s.evidence !== "function")) problems.push(`signer ${s.id} needs instructions() and evidence()`);
|
|
77
|
-
}
|
|
78
|
-
return problems;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,
|
|
82
|
-
* redirects refused unless asked for.
|
|
83
|
-
* `online` false refuses everything (the person turned the network off).
|
|
84
|
-
*/
|
|
85
|
-
function boundedIdentityFetch(options = { online: () => true }) {
|
|
86
|
-
return async (url, { headers, maxBytes = 65536, signal, redirect = "error" } = {}) => {
|
|
87
|
-
if (!options.online()) throw new IdentityCheckUnavailable("Offline: this identity cannot be checked now");
|
|
88
|
-
const target = new URL(url);
|
|
89
|
-
if (target.protocol !== "https:" || target.username || target.password) throw new Error("Identity checks use HTTPS only");
|
|
90
|
-
const timeout = AbortSignal.timeout(options.timeoutMs ?? 1e4);
|
|
91
|
-
const response = await (options.fetcher ?? fetch)(target.href, {
|
|
92
|
-
headers,
|
|
93
|
-
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
94
|
-
credentials: "omit",
|
|
95
|
-
referrerPolicy: "no-referrer",
|
|
96
|
-
cache: "no-store",
|
|
97
|
-
redirect
|
|
98
|
-
});
|
|
99
|
-
if (Number(response.headers.get("content-length")) > maxBytes) throw new Error("Identity check response too large");
|
|
100
|
-
const reader = response.body?.getReader();
|
|
101
|
-
const parts = [];
|
|
102
|
-
let length = 0;
|
|
103
|
-
if (reader) try {
|
|
104
|
-
for (;;) {
|
|
105
|
-
const { done, value } = await reader.read();
|
|
106
|
-
if (done) break;
|
|
107
|
-
length += value.length;
|
|
108
|
-
if (length > maxBytes) throw new Error("Identity check response too large");
|
|
109
|
-
parts.push(value);
|
|
110
|
-
}
|
|
111
|
-
} finally {
|
|
112
|
-
await reader.cancel().catch(() => {});
|
|
113
|
-
}
|
|
114
|
-
const bytes = new Uint8Array(length);
|
|
115
|
-
let offset = 0;
|
|
116
|
-
for (const part of parts) {
|
|
117
|
-
bytes.set(part, offset);
|
|
118
|
-
offset += part.length;
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
status: response.status,
|
|
122
|
-
contentType: response.headers.get("content-type") ?? "",
|
|
123
|
-
text: new TextDecoder().decode(bytes),
|
|
124
|
-
bytes
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region ../browser/src/plugins/bundled.ts
|
|
130
|
-
/**
|
|
131
|
-
* The adapter plugins compiled into this build. Empty unless the build lists some: `GHOSTLY_PLUGINS`
|
|
132
|
-
* names their modules (comma-separated paths from the repository root, each default-exporting a
|
|
133
|
-
* `GhostlyAdapterPlugin`), and the Vite plugin in `packages/browser/vite-plugin.ts` swaps this module
|
|
134
|
-
* for one that imports them. Release builds never set it; the e2e build carries the SDK example.
|
|
135
|
-
*/
|
|
136
|
-
var BUNDLED_PLUGINS = [];
|
|
137
|
-
var PLUGIN_ID = /^[a-z][a-z0-9-]{0,63}$/;
|
|
138
|
-
var KEY = Symbol.for("ghostly.adapters/1");
|
|
139
|
-
function store() {
|
|
140
|
-
const g = globalThis;
|
|
141
|
-
return g[KEY] ??= {
|
|
142
|
-
plugins: /* @__PURE__ */ new Map(),
|
|
143
|
-
reserved: {
|
|
144
|
-
lightning: /* @__PURE__ */ new Set(),
|
|
145
|
-
onchain: /* @__PURE__ */ new Set(),
|
|
146
|
-
identity: /* @__PURE__ */ new Set()
|
|
147
|
-
},
|
|
148
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
149
|
-
seeded: false
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
var ids = (kind, plugin) => {
|
|
153
|
-
const list = kind === "identity" ? plugin.identities : kind === "lightning" ? plugin.lightning : plugin.onchain;
|
|
154
|
-
return Array.isArray(list) ? list.map((a) => a?.id) : [];
|
|
155
|
-
};
|
|
156
|
-
var KINDS = [
|
|
157
|
-
"lightning",
|
|
158
|
-
"onchain",
|
|
159
|
-
"identity"
|
|
160
|
-
];
|
|
161
|
-
/** Problems with a plugin, empty when it can be registered. Does not look at what is already registered. */
|
|
162
|
-
function pluginProblems(plugin) {
|
|
163
|
-
const problems = [];
|
|
164
|
-
if (!plugin || typeof plugin !== "object") return ["not a plugin object"];
|
|
165
|
-
if (!PLUGIN_ID.test(plugin.id ?? "")) problems.push("plugin id must match ^[a-z][a-z0-9-]{0,63}$");
|
|
166
|
-
if (plugin.sdk !== 1) problems.push(`plugin was written for SDK API ${String(plugin.sdk)}; this app speaks 1`);
|
|
167
|
-
if (plugin.version !== void 0 && (typeof plugin.version !== "string" || plugin.version.length > 64)) problems.push("version must be a short string");
|
|
168
|
-
for (const kind of ["lightning", "onchain"]) {
|
|
169
|
-
const list = plugin[kind];
|
|
170
|
-
if (list === void 0) continue;
|
|
171
|
-
if (!Array.isArray(list)) {
|
|
172
|
-
problems.push(`${kind} must be a list of descriptors`);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
for (const d of list) {
|
|
176
|
-
if (!d || typeof d !== "object") {
|
|
177
|
-
problems.push(`${kind} ${String(d)}: not a descriptor`);
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
const own = providerDescriptorProblems(d);
|
|
181
|
-
if (d?.kind && d.kind !== kind) own.push(`is listed under ${kind} but says kind ${String(d.kind)}`);
|
|
182
|
-
problems.push(...own.map((p) => `${kind} ${String(d?.id)}: ${p}`));
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (plugin.identities !== void 0) {
|
|
186
|
-
if (!Array.isArray(plugin.identities)) problems.push("identities must be a list of providers");
|
|
187
|
-
else for (const p of plugin.identities) if (!p || typeof p !== "object") problems.push(`identity ${String(p)}: not a provider`);
|
|
188
|
-
else problems.push(...descriptorProblems(p).map((m) => `identity ${String(p.id)}: ${m}`));
|
|
189
|
-
}
|
|
190
|
-
for (const kind of KINDS) {
|
|
191
|
-
const list = ids(kind, plugin);
|
|
192
|
-
if (new Set(list).size !== list.length) problems.push(`${kind} ids are not unique within the plugin`);
|
|
193
|
-
}
|
|
194
|
-
if (!KINDS.some((kind) => ids(kind, plugin).length)) problems.push("the plugin brings no adapter");
|
|
195
|
-
return problems;
|
|
196
|
-
}
|
|
197
|
-
/** The built-in registries say which ids are theirs. A plugin using one is refused. */
|
|
198
|
-
function reserveAdapterIds(kind, list) {
|
|
199
|
-
const s = store();
|
|
200
|
-
for (const id of list) s.reserved[kind].add(id);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Registers a plugin's adapters. Throws, registering nothing, when the plugin is malformed, its id or
|
|
204
|
-
* one of its adapters' ids is taken (by a built-in or by another plugin), or its contract generation
|
|
205
|
-
* is another one. Returns the function that unregisters it.
|
|
206
|
-
*/
|
|
207
|
-
function registerAdapters(plugin) {
|
|
208
|
-
const problems = pluginProblems(plugin);
|
|
209
|
-
const s = store();
|
|
210
|
-
if (!problems.length) {
|
|
211
|
-
if (s.plugins.has(plugin.id)) problems.push(`a plugin with id ${plugin.id} is already registered`);
|
|
212
|
-
for (const kind of KINDS) for (const id of ids(kind, plugin)) {
|
|
213
|
-
if (s.reserved[kind].has(id)) problems.push(`${kind} ${id} is a built-in of this app`);
|
|
214
|
-
for (const other of s.plugins.values()) if (ids(kind, other).includes(id)) problems.push(`${kind} ${id} is already registered by plugin ${other.id}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (problems.length) throw new Error(`Cannot register plugin ${String(plugin?.id)}: ${problems.join("; ")}`);
|
|
218
|
-
s.plugins.set(plugin.id, plugin);
|
|
219
|
-
notify(s);
|
|
220
|
-
return () => {
|
|
221
|
-
if (s.plugins.get(plugin.id) === plugin) {
|
|
222
|
-
s.plugins.delete(plugin.id);
|
|
223
|
-
notify(s);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function notify(s) {
|
|
228
|
-
for (const listener of s.listeners) try {
|
|
229
|
-
listener();
|
|
230
|
-
} catch {}
|
|
231
|
-
}
|
|
232
|
-
/** Called when a plugin registers or unregisters: the engine re-reads the lists. */
|
|
233
|
-
function onAdaptersChanged(listener) {
|
|
234
|
-
const s = store();
|
|
235
|
-
s.listeners.add(listener);
|
|
236
|
-
return () => {
|
|
237
|
-
s.listeners.delete(listener);
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
/** Every registered plugin, in registration order (bundled ones first). */
|
|
241
|
-
function registeredPlugins() {
|
|
242
|
-
seed();
|
|
243
|
-
return [...store().plugins.values()];
|
|
244
|
-
}
|
|
245
|
-
function registeredLightningProviders() {
|
|
246
|
-
return registeredPlugins().flatMap((p) => p.lightning ?? []);
|
|
247
|
-
}
|
|
248
|
-
function registeredOnchainProviders() {
|
|
249
|
-
return registeredPlugins().flatMap((p) => p.onchain ?? []);
|
|
250
|
-
}
|
|
251
|
-
function registeredIdentityProviders() {
|
|
252
|
-
return registeredPlugins().flatMap((p) => p.identities ?? []);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* The plugins compiled into this build register once, when they are first asked for. A broken one is
|
|
256
|
-
* reported and skipped rather than taking the app down with it; the e2e that expects it fails instead.
|
|
257
|
-
*/
|
|
258
|
-
function seed() {
|
|
259
|
-
const s = store();
|
|
260
|
-
if (s.seeded) return;
|
|
261
|
-
s.seeded = true;
|
|
262
|
-
for (const plugin of BUNDLED_PLUGINS) try {
|
|
263
|
-
registerAdapters(plugin);
|
|
264
|
-
} catch (error) {
|
|
265
|
-
console.error(`[ghostly] a bundled adapter plugin was not loaded: ${error instanceof Error ? error.message : String(error)}`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region ../browser/src/proofs/ownDid.ts
|
|
270
|
-
/**
|
|
271
|
-
* The profile's own Ghostly did:dht, which the DID provider refuses as an external identity. The UI and the engine each
|
|
272
|
-
* set where to read it. Here, not in the provider, so setting it does not load the providers.
|
|
273
|
-
*/
|
|
274
|
-
var source = () => void 0;
|
|
275
|
-
function setOwnDidSource(read) {
|
|
276
|
-
source = read;
|
|
277
|
-
}
|
|
278
|
-
var ownDid = () => source();
|
|
279
|
-
//#endregion
|
|
280
|
-
export { registeredLightningProviders as a, boundedIdentityFetch as c, testSwitch as d, registeredIdentityProviders as i, verifyIdentity as l, setOwnDidSource as n, registeredOnchainProviders as o, onAdaptersChanged as r, reserveAdapterIds as s, ownDid as t, testBuild as u };
|
|
281
|
-
|
|
282
|
-
//# sourceMappingURL=ownDid-CJ0ta8CL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ownDid-CJ0ta8CL.js","names":[],"sources":["../../../browser/src/shared/features.ts","../../../browser/src/proofs/verify.ts","../../../browser/src/plugins/bundled.ts","../../../browser/src/plugins/registry.ts","../../../browser/src/proofs/ownDid.ts"],"sourcesContent":["/** Release policy: external identity experiments are retained for future work,\n * but must not advertise capabilities, start network lookups, or expose cached\n * external profiles. This does not gate Ghostly participation authentication. */\nexport const EXTERNAL_IDENTITIES_ENABLED: boolean = false;\n\n/** Mini-apps (WISP 1200): `apps/1` on paired sessions and the engine's `app*` calls. On from release 1.2 (a version\n * before 1.2.0 is never cut with it on: `RELEASE_GUARDS` in tools/scripts/changes.mjs). Off, nothing is offered to\n * contacts and every call is refused; a host that runs no apps pins its engine off (`NodeOptions.apps`). */\nexport const APPS_ENABLED: boolean = true;\n\n/**\n * A build that may be put into test mode: a development build (`import.meta.env.DEV`, which vitest also sets) or the\n * e2e suite's build (`VITE_APPS_TEST`, fixed when the build is made, as the mini-app switch is). A release build is\n * neither: Vite folds this to `false` there, so the storage flags the test fakes answer to are ignored. The fakes\n * themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.\n */\nexport const testBuild = (): boolean => { try { return !!import.meta.env?.DEV || import.meta.env?.VITE_APPS_TEST === \"1\"; } catch { return false; } };\n\n/**\n * A suite's switch in the page's storage (`localStorage[\"ghostly-test-…\"]`), read only in a test build (`testBuild`): a\n * release build reads none, so a leftover or pasted key changes nothing there. Null when unset, unreadable or released.\n */\nexport const testSwitch = (key: string): string | null => {\n if (!testBuild()) return null;\n try { return globalThis.localStorage?.getItem(key) ?? null; } catch { return null; }\n};\n","import { boundVerifiedIdentity, IdentityCheckUnavailable, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (p.recheck?.perHour !== undefined && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push(\"recheck.perHour must be a whole number, at least 1\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\" } = {}) => {\n if (!options.online()) throw new IdentityCheckUnavailable(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n if (target.protocol !== \"https:\" || target.username || target.password) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const response = await (options.fetcher ?? fetch)(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n","import type { GhostlyAdapterPlugin } from \"./registry\";\n\n/**\n * The adapter plugins compiled into this build. Empty unless the build lists some: `GHOSTLY_PLUGINS`\n * names their modules (comma-separated paths from the repository root, each default-exporting a\n * `GhostlyAdapterPlugin`), and the Vite plugin in `packages/browser/vite-plugin.ts` swaps this module\n * for one that imports them. Release builds never set it; the e2e build carries the SDK example.\n */\nexport const BUNDLED_PLUGINS: readonly GhostlyAdapterPlugin[] = [];\n","import type { LightningProviderDescriptor } from \"../engine/paymentAdapters/providers/lightning\";\nimport type { OnchainProviderDescriptor } from \"../engine/paymentAdapters/providers/onchain\";\nimport { providerDescriptorProblems, type ProviderDescriptor, type ProviderKind } from \"../engine/paymentAdapters/providers/types\";\nimport type { IdentityProofProvider } from \"../proofs/contract\";\nimport { descriptorProblems } from \"../proofs/verify\";\nimport { BUNDLED_PLUGINS } from \"./bundled\";\n\n/**\n * Adapters written outside the app: wallet sources (Lightning, on-chain) and identity-proof providers\n * that register here instead of being added to the built-in lists. A plugin is a plain object naming\n * its adapters; the registries (`providers/registry.ts`, `proofs/registry.ts`) list what is registered\n * after the built-ins and before the test fakes, and the same platform and mode rules apply to all.\n *\n * Two ways in:\n * - at build time: `GHOSTLY_PLUGINS` lists the modules and `bundled.ts` is swapped for them;\n * - at run time: code already running in the engine's realm calls `registerAdapters` before the\n * pickers are shown (or after: the engine re-reads the lists when something registers).\n *\n * Trust: a plugin runs with the app's privileges, in the app's own JavaScript realm. There is no\n * sandbox, no permission prompt and no store; whoever builds a plugin in, or loads one, trusts its\n * author with everything the app can do, keys and sats included. A manifest with permissions and an\n * isolated runtime are a later phase (docs/wisps/ADAPTER-ROADMAP.md, \"Plugins, apps, catalogs\").\n *\n * The state lives on `globalThis` under a well-known symbol, so a plugin bundled with its own copy of\n * the SDK (a second copy of this module) still registers into the same lists the app reads.\n */\n\n/** The generation of the adapter contracts. A plugin says which one it was written against. */\nexport const SDK_API = 1;\nexport const PLUGIN_ID = /^[a-z][a-z0-9-]{0,63}$/;\n\nexport interface GhostlyAdapterPlugin {\n /** Stable, unique among plugins: `^[a-z][a-z0-9-]{0,63}$`. */\n id: string;\n /** The plugin's own version, for people. */\n version?: string;\n /** The contract generation it was written against: `SDK_API`. Another one is refused. */\n sdk: number;\n lightning?: readonly LightningProviderDescriptor[];\n onchain?: readonly OnchainProviderDescriptor[];\n identities?: readonly IdentityProofProvider[];\n}\n\nexport type AdapterKind = ProviderKind | \"identity\";\n\ninterface Store {\n plugins: Map<string, GhostlyAdapterPlugin>;\n /** Ids the built-in registries own, per kind: a plugin cannot take one. */\n reserved: Record<AdapterKind, Set<string>>;\n listeners: Set<() => void>;\n seeded: boolean;\n}\n\nconst KEY = Symbol.for(\"ghostly.adapters/1\");\nfunction store(): Store {\n const g = globalThis as unknown as Record<symbol, Store | undefined>;\n return (g[KEY] ??= { plugins: new Map(), reserved: { lightning: new Set(), onchain: new Set(), identity: new Set() }, listeners: new Set(), seeded: false });\n}\n\nconst ids = (kind: AdapterKind, plugin: GhostlyAdapterPlugin): string[] => {\n // Not trusted to be well formed: pluginProblems reads it before saying what is wrong with it.\n const list: unknown = kind === \"identity\" ? plugin.identities : kind === \"lightning\" ? plugin.lightning : plugin.onchain;\n return Array.isArray(list) ? list.map((a: { id?: string } | null) => a?.id as string) : [];\n};\nconst KINDS: readonly AdapterKind[] = [\"lightning\", \"onchain\", \"identity\"];\n\n/** Problems with a plugin, empty when it can be registered. Does not look at what is already registered. */\nexport function pluginProblems(plugin: GhostlyAdapterPlugin): string[] {\n const problems: string[] = [];\n if (!plugin || typeof plugin !== \"object\") return [\"not a plugin object\"];\n if (!PLUGIN_ID.test(plugin.id ?? \"\")) problems.push(\"plugin id must match ^[a-z][a-z0-9-]{0,63}$\");\n if (plugin.sdk !== SDK_API) problems.push(`plugin was written for SDK API ${String(plugin.sdk)}; this app speaks ${SDK_API}`);\n if (plugin.version !== undefined && (typeof plugin.version !== \"string\" || plugin.version.length > 64)) problems.push(\"version must be a short string\");\n for (const kind of [\"lightning\", \"onchain\"] as const) {\n const list = plugin[kind];\n if (list === undefined) continue;\n if (!Array.isArray(list)) { problems.push(`${kind} must be a list of descriptors`); continue; }\n for (const d of list as ProviderDescriptor<unknown>[]) {\n if (!d || typeof d !== \"object\") { problems.push(`${kind} ${String(d)}: not a descriptor`); continue; }\n const own = providerDescriptorProblems(d);\n if (d?.kind && d.kind !== kind) own.push(`is listed under ${kind} but says kind ${String(d.kind)}`);\n problems.push(...own.map((p) => `${kind} ${String(d?.id)}: ${p}`));\n }\n }\n if (plugin.identities !== undefined) {\n if (!Array.isArray(plugin.identities)) problems.push(\"identities must be a list of providers\");\n else for (const p of plugin.identities) {\n if (!p || typeof p !== \"object\") problems.push(`identity ${String(p)}: not a provider`);\n else problems.push(...descriptorProblems(p).map((m) => `identity ${String(p.id)}: ${m}`));\n }\n }\n for (const kind of KINDS) {\n const list = ids(kind, plugin);\n if (new Set(list).size !== list.length) problems.push(`${kind} ids are not unique within the plugin`);\n }\n if (!KINDS.some((kind) => ids(kind, plugin).length)) problems.push(\"the plugin brings no adapter\");\n return problems;\n}\n\n/** The built-in registries say which ids are theirs. A plugin using one is refused. */\nexport function reserveAdapterIds(kind: AdapterKind, list: readonly string[]): void {\n const s = store();\n for (const id of list) s.reserved[kind].add(id);\n}\n\n/**\n * Registers a plugin's adapters. Throws, registering nothing, when the plugin is malformed, its id or\n * one of its adapters' ids is taken (by a built-in or by another plugin), or its contract generation\n * is another one. Returns the function that unregisters it.\n */\nexport function registerAdapters(plugin: GhostlyAdapterPlugin): () => void {\n const problems = pluginProblems(plugin);\n const s = store();\n if (!problems.length) {\n if (s.plugins.has(plugin.id)) problems.push(`a plugin with id ${plugin.id} is already registered`);\n for (const kind of KINDS) for (const id of ids(kind, plugin)) {\n if (s.reserved[kind].has(id)) problems.push(`${kind} ${id} is a built-in of this app`);\n for (const other of s.plugins.values()) if (ids(kind, other).includes(id)) problems.push(`${kind} ${id} is already registered by plugin ${other.id}`);\n }\n }\n if (problems.length) throw new Error(`Cannot register plugin ${String(plugin?.id)}: ${problems.join(\"; \")}`);\n s.plugins.set(plugin.id, plugin);\n notify(s);\n return () => { if (s.plugins.get(plugin.id) === plugin) { s.plugins.delete(plugin.id); notify(s); } };\n}\n\nfunction notify(s: Store) { for (const listener of s.listeners) { try { listener(); } catch { /* a listener's problem */ } } }\n\n/** Called when a plugin registers or unregisters: the engine re-reads the lists. */\nexport function onAdaptersChanged(listener: () => void): () => void {\n const s = store();\n s.listeners.add(listener);\n return () => { s.listeners.delete(listener); };\n}\n\n/** Every registered plugin, in registration order (bundled ones first). */\nexport function registeredPlugins(): readonly GhostlyAdapterPlugin[] { seed(); return [...store().plugins.values()]; }\nexport function registeredLightningProviders(): readonly LightningProviderDescriptor[] { return registeredPlugins().flatMap((p) => p.lightning ?? []); }\nexport function registeredOnchainProviders(): readonly OnchainProviderDescriptor[] { return registeredPlugins().flatMap((p) => p.onchain ?? []); }\nexport function registeredIdentityProviders(): readonly IdentityProofProvider[] { return registeredPlugins().flatMap((p) => p.identities ?? []); }\n\n/**\n * The plugins compiled into this build register once, when they are first asked for. A broken one is\n * reported and skipped rather than taking the app down with it; the e2e that expects it fails instead.\n */\nfunction seed() {\n const s = store();\n if (s.seeded) return;\n s.seeded = true;\n for (const plugin of BUNDLED_PLUGINS) {\n try { registerAdapters(plugin); }\n catch (error) { console.error(`[ghostly] a bundled adapter plugin was not loaded: ${error instanceof Error ? error.message : String(error)}`); }\n }\n}\n\n/** Tests only: forget every registration, including the bundled ones. */\nexport function resetAdapterRegistry(): void {\n const s = store();\n s.plugins.clear(); s.seeded = false;\n for (const kind of KINDS) s.reserved[kind].clear();\n notify(s);\n}\n","/**\n * The profile's own Ghostly did:dht, which the DID provider refuses as an external identity. The UI and the engine each\n * set where to read it. Here, not in the provider, so setting it does not load the providers.\n */\nlet source: () => string | undefined = () => undefined;\nexport function setOwnDidSource(read: () => string | undefined): void { source = read; }\nexport const ownDid = (): string | undefined => source();\n"],"mappings":";;;;;;;;;AAgBA,IAAa,kBAA2B;CAAE,IAAI;EAAE,OAAiC;CAAyC,QAAQ;EAAE,OAAO;CAAO;AAAE;;;;;AAMpJ,IAAa,cAAc,QAA+B;CACxD,IAAI,CAAC,UAAU,GAAG,OAAO;CACzB,IAAI;EAAE,OAAO,WAAW,cAAc,QAAQ,GAAG,KAAK;CAAM,QAAQ;EAAE,OAAO;CAAM;AACrF;;;ACtBA,IAAM,MAAM;;;;;;;AAQZ,eAAsB,eAAe,WAA6C,WAA8B,UAAmB,KAA+C;CAChL,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,UAAU,MAAK,MAAK,EAAE,OAAO,QAAQ,QAAQ;CAC9D,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8CAA8C;CAC7E,IAAI,QAAQ,YAAY,QAAQ,WAAW,KAAK,IAAI,SAAS,SAAS,UAAU,KAAA,MAA0B,GAAG,MAAM,IAAI,MAAM,0DAA0D;CACvL,IAAI,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,SAAA,OAAgC,MAAM,IAAI,MAAM,oBAAoB;CACzG,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,MAAM,WAAW,sBAAsB,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG,CAAC;CACpF,IAAI,SAAS,aAAa,oBAAoB,SAAS,YAAY,QAAQ,SAAS,MAAM,IAAI,MAAM,sCAAsC;CAC1I,IAAI,SAAS,aAAa,uBAAuB,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