@ghostlytools/cli 1.12.0 → 1.13.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.
Files changed (76) hide show
  1. package/README.md +5 -5
  2. package/dist/assets/{api-DYMKyb1k.js → api-CVtg7MpI.js} +2 -2
  3. package/dist/assets/{api-DLzCtePC.js → api-CjOaoG-v.js} +53 -27
  4. package/dist/assets/api-CjOaoG-v.js.map +1 -0
  5. package/dist/assets/{apiKit-CVaEzKWQ.js → apiKit-BAGvlQtm.js} +2 -2
  6. package/dist/assets/{apiKit-CVaEzKWQ.js.map → apiKit-BAGvlQtm.js.map} +1 -1
  7. package/dist/assets/{appFetch-D56GsYuq.js → appFetch-BwJd-kNq.js} +2 -2
  8. package/dist/assets/{appFetch-D56GsYuq.js.map → appFetch-BwJd-kNq.js.map} +1 -1
  9. package/dist/assets/{apps-XnZ8VEuj.js → apps-Cuk45sz5.js} +6 -6
  10. package/dist/assets/{apps-XnZ8VEuj.js.map → apps-Cuk45sz5.js.map} +1 -1
  11. package/dist/assets/{apps-BPFW19Wc.js → apps-DjY095Af.js} +1 -1
  12. package/dist/assets/{backup-COX6j1_W.js → backup-B56sQqoQ.js} +1 -1
  13. package/dist/assets/{backup-DpyvT9Z6.js → backup-DekVCDWv.js} +47 -8
  14. package/dist/assets/backup-DekVCDWv.js.map +1 -0
  15. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -1
  16. package/dist/assets/{bitcoind-DTsrd7TF.js → bitcoind-B2bbVSzh.js} +2 -2
  17. package/dist/assets/{bitcoind-DTsrd7TF.js.map → bitcoind-B2bbVSzh.js.map} +1 -1
  18. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -1
  19. package/dist/assets/{buttons-BvWqHJeh.js → buttons-BGxzOtrq.js} +27 -6
  20. package/dist/assets/buttons-BGxzOtrq.js.map +1 -0
  21. package/dist/assets/buttons-CsN2WJOf.js +1 -0
  22. package/dist/assets/{client-kGZ3ZdUW.js → client-DcQAfc3h.js} +2 -2
  23. package/dist/assets/{client-kGZ3ZdUW.js.map → client-DcQAfc3h.js.map} +1 -1
  24. package/dist/assets/{endpoint-B0vE5ojY.js → endpoint-Cvu-taMs.js} +42 -5
  25. package/dist/assets/{endpoint-B0vE5ojY.js.map → endpoint-Cvu-taMs.js.map} +1 -1
  26. package/dist/assets/{fixedHosts-CPSsGOI2.js → fixedHosts-C3hBliM9.js} +2 -2
  27. package/dist/assets/{fixedHosts-CPSsGOI2.js.map → fixedHosts-C3hBliM9.js.map} +1 -1
  28. package/dist/assets/{groupMeta-DTQAJG50.js → groupMeta-goASqzOt.js} +135 -37
  29. package/dist/assets/groupMeta-goASqzOt.js.map +1 -0
  30. package/dist/assets/{host-z0FAHP9Z.js → host-C2WRKj3g.js} +105 -32
  31. package/dist/assets/host-C2WRKj3g.js.map +1 -0
  32. package/dist/assets/{hyperdhtRelay-CvsAfQRQ.js → hyperdhtRelay-DLUiwfnt.js} +32 -4
  33. package/dist/assets/hyperdhtRelay-DLUiwfnt.js.map +1 -0
  34. package/dist/assets/{irohWeb-CLBx5MIv.js → irohWeb-NfthOL98.js} +178 -9
  35. package/dist/assets/irohWeb-NfthOL98.js.map +1 -0
  36. package/dist/assets/{main-CVqkvuIo.js → main-Dh7fePd8.js} +49 -32
  37. package/dist/assets/main-Dh7fePd8.js.map +1 -0
  38. package/dist/assets/{mainline-CVrd0C1n.js → mainline-DY95WbuK.js} +2 -2
  39. package/dist/assets/{mainline-CVrd0C1n.js.map → mainline-DY95WbuK.js.map} +1 -1
  40. package/dist/assets/{ownDid-DY3rYqDI.js → ownDid-BErplN7N.js} +2 -2
  41. package/dist/assets/{ownDid-DY3rYqDI.js.map → ownDid-BErplN7N.js.map} +1 -1
  42. package/dist/assets/{ownStatus-DMEhrpkd.js → ownStatus-ClrFjd7h.js} +5 -3
  43. package/dist/assets/ownStatus-ClrFjd7h.js.map +1 -0
  44. package/dist/assets/{profiles-BFSGqDFC.js → profiles-B8xO8-oj.js} +2 -2
  45. package/dist/assets/{profiles-BFSGqDFC.js.map → profiles-B8xO8-oj.js.map} +1 -1
  46. package/dist/assets/{registry-B15Yg_1C.js → registry--Rg2YvOH.js} +1 -1
  47. package/dist/assets/{registry-rXgaZeNn.js → registry-CU8PevhI.js} +38 -30
  48. package/dist/assets/registry-CU8PevhI.js.map +1 -0
  49. package/dist/assets/{relay-Cjfmdec0.js → relay-CHWg5hpZ.js} +73 -11
  50. package/dist/assets/relay-CHWg5hpZ.js.map +1 -0
  51. package/dist/assets/{resolve-CIc3KZMV.js → resolve-B1upovPM.js} +2 -2
  52. package/dist/assets/{resolve-CIc3KZMV.js.map → resolve-B1upovPM.js.map} +1 -1
  53. package/dist/assets/secretGuard-Bm6nci0I.js +1 -0
  54. package/dist/assets/{secretGuard-B4-LlMjv.js → secretGuard-BrATm_gl.js} +33 -9
  55. package/dist/assets/{secretGuard-B4-LlMjv.js.map → secretGuard-BrATm_gl.js.map} +1 -1
  56. package/dist/assets/{server-CQR7NLCz.js → server-Dgxx_DaN.js} +473 -60
  57. package/dist/assets/server-Dgxx_DaN.js.map +1 -0
  58. package/dist/assets/{waitNotice-BGM0QOS2.js → waitNotice-ylU3XwjO.js} +2 -2
  59. package/dist/assets/{waitNotice-BGM0QOS2.js.map → waitNotice-ylU3XwjO.js.map} +1 -1
  60. package/dist/ghostly.mjs +1 -1
  61. package/npm-shrinkwrap.json +2 -2
  62. package/package.json +1 -1
  63. package/dist/assets/api-DLzCtePC.js.map +0 -1
  64. package/dist/assets/backup-DpyvT9Z6.js.map +0 -1
  65. package/dist/assets/buttons-Bq7pTXqF.js +0 -1
  66. package/dist/assets/buttons-BvWqHJeh.js.map +0 -1
  67. package/dist/assets/groupMeta-DTQAJG50.js.map +0 -1
  68. package/dist/assets/host-z0FAHP9Z.js.map +0 -1
  69. package/dist/assets/hyperdhtRelay-CvsAfQRQ.js.map +0 -1
  70. package/dist/assets/irohWeb-CLBx5MIv.js.map +0 -1
  71. package/dist/assets/main-CVqkvuIo.js.map +0 -1
  72. package/dist/assets/ownStatus-DMEhrpkd.js.map +0 -1
  73. package/dist/assets/registry-rXgaZeNn.js.map +0 -1
  74. package/dist/assets/relay-Cjfmdec0.js.map +0 -1
  75. package/dist/assets/secretGuard-BmmnEbYf.js +0 -1
  76. package/dist/assets/server-CQR7NLCz.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ownDid-DY3rYqDI.js","names":[],"sources":["../../../core/src/pubkyProofs.ts","../../../core/src/didDht.ts","../../../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":["import { fromZ32, randomBytes, toZ32 } from \"./bytes\";\nimport type { IdentityStatement } from \"./identityProofs\";\n\n/**\n * A Pubky identity proof, by publication (WISP 302, docs/wisps/302-pubky.md). Neither Pubky Ring nor Pubky\n * Passport signs arbitrary text: they approve standard Pubky auth requests. So Ghostly asks, through one of them,\n * for write access to ONE fresh folder of the key's homeserver, `/pub/ghostly.app/proofs/<folder>/`, and writes the\n * identity statement there (the #80 statement: the Pubky key authorizes this profile's per-proof key). A contact's\n * app reads the file back, finding the homeserver through the key's own signed PKDNS records (pkdns.ts), never\n * through a host or URL from the proof. The folder is random, so the path says nothing about the profile.\n */\n\nexport const PUBKY_PROOF_ROOT = \"/pub/ghostly.app/proofs/\";\n/** The file is the statement, a few hundred bytes: anything larger is not ours. */\nexport const PUBKY_PROOF_MAX_BYTES = 1024;\nconst Z32 = /^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/;\nconst FOLDER = /^[a-f0-9]{64}$/;\nconst STATEMENT_ID = /^[a-f0-9]{64}$/;\n\n/** A canonical Pubky key: 52 characters of z-base-32 that decode to 32 bytes and back. */\nexport function isPubkyKey(value: unknown): value is string {\n if (typeof value !== \"string\" || !Z32.test(value)) return false;\n try { return toZ32(fromZ32(value)) === value; } catch { return false; }\n}\n\n/** The z-base-32 key for what a person typed or pasted: the bare key, `pubky<key>`, `pk:<key>` or `pubky://<key>`. */\nexport function normalizePubkyKey(input: string): string {\n const match = /^(?:pubky:\\/\\/|pubky|pk:)?([a-z0-9]{52})\\/?$/i.exec(typeof input === \"string\" ? input.trim() : \"\");\n const key = match?.[1].toLowerCase();\n if (!key || !isPubkyKey(key)) throw new Error(\"That is not a Pubky key: 52 characters, like the one Pubky Ring shows\");\n return key;\n}\n\nexport const isPubkyProofFolder = (value: unknown): value is string => typeof value === \"string\" && FOLDER.test(value);\n\n/** A fresh folder name: 32 random bytes, hex. One per proof, so two proofs never share a path. */\nexport const newPubkyProofFolder = () => Array.from(randomBytes(32), b => b.toString(16).padStart(2, \"0\")).join(\"\");\n\n/** The only capability Ghostly ever asks for: write access to one proof folder. */\nexport function pubkyProofCapability(folder: string): `/pub/${string}/:w` {\n if (!isPubkyProofFolder(folder)) throw new Error(\"Invalid Pubky proof folder\");\n return `${PUBKY_PROOF_ROOT}${folder}/:w`;\n}\n\n/** Where the statement goes: in its folder, named by the statement id. */\nexport function pubkyProofPath(folder: string, statementId: string): `/pub/${string}` {\n if (!isPubkyProofFolder(folder) || !STATEMENT_ID.test(statementId)) throw new Error(\"Invalid Pubky proof path\");\n return `${PUBKY_PROOF_ROOT}${folder}/${statementId}.txt`;\n}\n\n/** The file's exact contents: the statement's one line, nothing added. The verifier compares bytes. */\nexport const pubkyProofFile = (statement: IdentityStatement): string => statement.text;\n","import { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesEqual, fromBase64Url, fromZ32, toBase64Url, toZ32, utf8Encode } from \"./bytes\";\nimport { decodeTxtPacket, encodeTxtPacket, type NsRecord, type TxtRecord } from \"./dns\";\nimport type { Identity } from \"./identity\";\nimport { MAX_DNS_PACKET_BYTES, PacketTooLargeError, openRelayPayload, signRelayPayload } from \"./pkarr\";\nimport { DEFAULT_RELAYS, normalizeRelayUrl } from \"./relay\";\n\n/**\n * did:dht (the DIF method, https://github.com/decentralized-identity/did-dht/blob/main/spec/spec.md): a W3C DID document written as DNS records into the\n * Pkarr packet of an Ed25519 key, the BEP44 mutable item Ghostly already publishes chats under. This\n * module maps a document to that packet and back (strictly: a malformed packet is an error, never a\n * guess) and resolves a did:dht through Pkarr relays. WISP 310-did-dht describes Ghostly's use.\n */\n\nexport const DID_DHT_PREFIX = \"did:dht:\";\n/** The TTL the spec recommends: Mainline's default record lifetime. */\nexport const DID_DHT_TTL = 7200;\n/** The spec version this module writes and the only one it reads (`v=0`). */\nexport const DID_DHT_VERSION = \"0\";\n/** A relay answer: 64 bytes of signature, 8 of sequence number, then at most 1000 of DNS packet. */\nexport const DID_DHT_MAX_PAYLOAD = 64 + 8 + MAX_DNS_PACKET_BYTES;\n\nexport interface DidDhtJwk {\n kty: \"OKP\" | \"EC\";\n crv: \"Ed25519\" | \"secp256k1\" | \"P-256\" | \"X25519\";\n x: string;\n y?: string;\n alg: string;\n kid: string;\n}\n\nexport interface DidDhtVerificationMethod {\n id: string;\n type: \"JsonWebKey\";\n controller: string;\n publicKeyJwk: DidDhtJwk;\n}\n\nexport interface DidDhtService {\n id: string;\n type: string;\n serviceEndpoint: string[];\n /** Registered extra properties (the spec's registry): which keys sign and encrypt for it. */\n sig?: string | string[];\n enc?: string | string[];\n}\n\n/** A did:dht document in W3C DID Core JSON: no `@context`, every reference fully qualified. */\nexport interface DidDhtDocument {\n id: string;\n controller?: string | string[];\n alsoKnownAs?: string[];\n verificationMethod: DidDhtVerificationMethod[];\n authentication?: string[];\n assertionMethod?: string[];\n keyAgreement?: string[];\n capabilityInvocation?: string[];\n capabilityDelegation?: string[];\n service?: DidDhtService[];\n}\n\n/** Why a did:dht could not be read: the message is meant for a person. */\nexport class DidDhtError extends Error {\n constructor(message: string, readonly code: \"invalid-did\" | \"not-found\" | \"invalid-signature\" | \"malformed\" | \"unreachable\") {\n super(message);\n this.name = \"DidDhtError\";\n }\n}\n\nconst malformed = (detail: string) => new DidDhtError(`The did:dht document is malformed: ${detail}`, \"malformed\");\n\n// ── Identifiers ───────────────────────────────────────────────────────────────────────────────────────\n\n/** `did:dht:<z-base-32 of the Ed25519 public key>`. */\nexport function didDhtFromPublicKey(publicKey: Uint8Array): string {\n if (publicKey.length !== 32) throw new Error(\"A did:dht identity key is 32 bytes of Ed25519 public key\");\n return DID_DHT_PREFIX + toZ32(publicKey);\n}\n\n/** The identity key of a did:dht. Only the exact DID: no path, query or fragment, canonical z-base-32. */\nexport function didDhtKey(did: string): { z32: string; publicKey: Uint8Array } {\n const invalid = () => new DidDhtError(\"This is not a valid did:dht\", \"invalid-did\");\n if (typeof did !== \"string\" || !did.startsWith(DID_DHT_PREFIX)) throw invalid();\n const z32 = did.slice(DID_DHT_PREFIX.length);\n if (!/^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/.test(z32)) throw invalid();\n const publicKey = fromZ32(z32);\n // 52 characters carry 260 bits: the last four must be zero, or two DIDs would name one key.\n if (toZ32(publicKey) !== z32) throw invalid();\n // Nor a point of small order: no secret key goes with one, and it \"verifies\" a constant signature of any packet.\n let fit: boolean;\n try { fit = !ed25519.Point.fromBytes(publicKey).isSmallOrder(); } catch { fit = false; }\n if (!fit) throw invalid();\n return { z32, publicKey };\n}\n\n// ── Documents ─────────────────────────────────────────────────────────────────────────────────────────\n\nconst KEY_TYPES = [\n { kty: \"OKP\", crv: \"Ed25519\", alg: \"EdDSA\" },\n { kty: \"EC\", crv: \"secp256k1\", alg: \"ES256K\" },\n { kty: \"EC\", crv: \"P-256\", alg: \"ES256\" },\n { kty: \"OKP\", crv: \"X25519\", alg: \"ECDH-ES+A256KW\" },\n] as const;\n\nconst RELATIONSHIPS = [\n [\"auth\", \"authentication\"],\n [\"asm\", \"assertionMethod\"],\n [\"agm\", \"keyAgreement\"],\n [\"inv\", \"capabilityInvocation\"],\n [\"del\", \"capabilityDelegation\"],\n] as const;\n\n/**\n * The document of an identity key alone, as the spec's Create step makes it: the key as `#0`, with the\n * four relationships it requires (authentication, assertion, capability invocation and delegation).\n * `alsoKnownAs` adds other identifiers of the same subject (URIs), which the document makes public.\n */\nexport function didDhtDocument(publicKey: Uint8Array, options: { alsoKnownAs?: string[] } = {}): DidDhtDocument {\n const id = didDhtFromPublicKey(publicKey);\n const key = `${id}#0`;\n return {\n id,\n ...(options.alsoKnownAs?.length ? { alsoKnownAs: [...options.alsoKnownAs] } : {}),\n verificationMethod: [{\n id: key,\n type: \"JsonWebKey\",\n controller: id,\n publicKeyJwk: { kty: \"OKP\", crv: \"Ed25519\", x: toBase64Url(publicKey), alg: \"EdDSA\", kid: \"0\" },\n }],\n authentication: [key],\n assertionMethod: [key],\n capabilityInvocation: [key],\n capabilityDelegation: [key],\n };\n}\n\n/** RFC 7638 thumbprint: SHA-256 of the required members in lexicographic order. */\nexport function jwkThumbprint(jwk: Pick<DidDhtJwk, \"kty\" | \"crv\" | \"x\" | \"y\">): string {\n const members = jwk.kty === \"EC\" ? { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y } : { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n return toBase64Url(sha256(utf8Encode(JSON.stringify(members))));\n}\n\nfunction publicKeyBytes(type: number, jwk: DidDhtJwk): Uint8Array {\n const x = fromBase64Url(jwk.x);\n if (type === 0 || type === 3) return x;\n // Compressed point: the x-coordinate and the sign of y (the spec's size rule).\n const curve = type === 1 ? secp256k1 : p256;\n return curve.Point.fromAffine({ x: bigintOf(x), y: bigintOf(fromBase64Url(jwk.y ?? \"\")) }).toBytes(true);\n}\n\nfunction bigintOf(bytes: Uint8Array): bigint {\n let n = 0n;\n for (const b of bytes) n = (n << 8n) | BigInt(b);\n return n;\n}\n\nfunction jwkOf(type: number, bytes: Uint8Array, alg: string, kid: string): DidDhtJwk {\n const kind = KEY_TYPES[type];\n if (type === 0) {\n if (bytes.length !== 32) throw malformed(\"an Ed25519 key is not 32 bytes\");\n let smallOrder: boolean;\n try { smallOrder = ed25519.Point.fromBytes(bytes).isSmallOrder(); } catch { throw malformed(\"an Ed25519 key is not a point of the curve\"); }\n if (smallOrder) throw malformed(\"an Ed25519 key is a point of small order, which no secret key goes with\");\n return { kty: \"OKP\", crv: \"Ed25519\", x: toBase64Url(bytes), alg, kid };\n }\n if (type === 3) {\n if (bytes.length !== 32) throw malformed(\"an X25519 key is not 32 bytes\");\n return { kty: \"OKP\", crv: \"X25519\", x: toBase64Url(bytes), alg, kid };\n }\n if (bytes.length !== 33 && bytes.length !== 65) throw malformed(`a ${kind.crv} key is neither a compressed nor an uncompressed point`);\n let raw: Uint8Array;\n try {\n raw = (type === 1 ? secp256k1 : p256).Point.fromBytes(bytes).toBytes(false);\n } catch {\n throw malformed(`a ${kind.crv} key is not a point of the curve`);\n }\n return { kty: \"EC\", crv: kind.crv, x: toBase64Url(raw.subarray(1, 33)), y: toBase64Url(raw.subarray(33)), alg, kid };\n}\n\n// ── Document → DNS records ────────────────────────────────────────────────────────────────────────────\n\nexport interface DidDhtPacketOptions {\n /** Type indexing (`_typ._did.`), integers from the spec's registry. */\n types?: number[];\n /** Authoritative gateways, as NS records of the root name. */\n gateways?: string[];\n /**\n * Other records of the same key. A key has exactly one packet: whatever else it publishes goes in\n * with the document, and the whole must fit the 1000 bytes.\n */\n extra?: TxtRecord[];\n}\n\nconst fragmentOf = (documentId: string, ref: string, what: string): string => {\n if (!ref.startsWith(`${documentId}#`)) throw new Error(`${what} ${ref} is not a fragment of ${documentId}`);\n const fragment = ref.slice(documentId.length + 1);\n if (!FRAGMENT.test(fragment)) throw new Error(`${what} ${ref} has an unusable fragment`);\n return fragment;\n};\n\nconst listValue = (values: string[], what: string): string => {\n for (const v of values) if (!v || /[,;\\s]/.test(v)) throw new Error(`${what} ${JSON.stringify(v)} cannot be written into a did:dht record`);\n return values.join(\",\");\n};\n\n/**\n * The DNS records of a document, in the spec's layout (names `_did.<ID>.` and `_kN._did.`). The root\n * record comes after the records it names, gateways last: the order @web5/dids writes, and the only one\n * it reads correctly (it resolves `vm`/`auth` references in packet order). Order-free readers don't mind.\n */\nexport function didDhtRecords(document: DidDhtDocument, options: DidDhtPacketOptions = {}): (TxtRecord | NsRecord)[] {\n const { z32, publicKey } = didDhtKey(document.id);\n const methods = document.verificationMethod;\n const first = methods[0];\n if (!first || first.id !== `${document.id}#0` || first.publicKeyJwk.crv !== \"Ed25519\" || !bytesEqual(fromBase64Url(first.publicKeyJwk.x), publicKey)) {\n throw new Error(\"The first verification method of a did:dht document is its identity key, #0\");\n }\n\n const aliases = new Map<string, string>();\n const keyRecords: TxtRecord[] = methods.map((method, index) => {\n const alias = `k${index}`;\n if (aliases.has(method.id)) throw new Error(`Verification method ${method.id} appears twice`);\n aliases.set(method.id, alias);\n const fragment = fragmentOf(document.id, method.id, \"Verification method\");\n const type = KEY_TYPES.findIndex((k) => k.crv === method.publicKeyJwk.crv);\n if (type < 0) throw new Error(`Key type ${method.publicKeyJwk.crv} has no did:dht index`);\n const jwk = method.publicKeyJwk;\n const parts: string[] = [];\n // The identity key's id is always 0, and one that is the thumbprint can be computed back: both are left out.\n if (index > 0 && fragment !== jwkThumbprint(jwk)) parts.push(`id=${fragment}`);\n parts.push(`t=${type}`, `k=${toBase64Url(publicKeyBytes(type, jwk))}`);\n if (jwk.alg !== KEY_TYPES[type].alg) parts.push(`a=${jwk.alg}`);\n if (method.controller !== document.id) parts.push(`c=${listValue([method.controller], \"Controller\")}`);\n return { name: `_${alias}._did.`, value: parts.join(\";\"), ttl: DID_DHT_TTL };\n });\n\n const services = document.service ?? [];\n const serviceRecords: TxtRecord[] = services.map((service, index) => {\n const parts = [\n `id=${fragmentOf(document.id, service.id, \"Service\")}`,\n `t=${listValue([service.type], \"Service type\")}`,\n `se=${listValue(service.serviceEndpoint, \"Service endpoint\")}`,\n ];\n for (const extra of [\"sig\", \"enc\"] as const) {\n const v = service[extra];\n if (v !== undefined) parts.push(`${extra}=${listValue(Array.isArray(v) ? v : [v], `Service ${extra}`)}`);\n }\n return { name: `_s${index}._did.`, value: parts.join(\";\"), ttl: DID_DHT_TTL };\n });\n\n const root = [`v=${DID_DHT_VERSION}`, `vm=${keyRecords.map((_, i) => `k${i}`).join(\",\")}`];\n for (const [short, property] of RELATIONSHIPS) {\n const refs = document[property] ?? [];\n if (refs.length === 0) continue;\n root.push(`${short}=${refs.map((ref) => {\n const alias = aliases.get(ref);\n if (!alias) throw new Error(`${property} refers to ${ref}, which is not a verification method of the document`);\n return alias;\n }).join(\",\")}`);\n }\n if (serviceRecords.length) root.push(`svc=${serviceRecords.map((_, i) => `s${i}`).join(\",\")}`);\n\n const records: (TxtRecord | NsRecord)[] = [];\n if (document.alsoKnownAs?.length) records.push({ name: \"_aka._did.\", value: listValue(document.alsoKnownAs, \"Also-known-as\"), ttl: DID_DHT_TTL });\n if (document.controller !== undefined) {\n const controllers = Array.isArray(document.controller) ? document.controller : [document.controller];\n records.push({ name: \"_cnt._did.\", value: listValue(controllers, \"Controller\"), ttl: DID_DHT_TTL });\n }\n records.push(...keyRecords, ...serviceRecords);\n if (options.types?.length) {\n for (const t of options.types) if (!Number.isSafeInteger(t) || t < 0) throw new Error(`Type ${t} is not a registry integer`);\n records.push({ name: \"_typ._did.\", value: `id=${options.types.join(\",\")}`, ttl: DID_DHT_TTL });\n }\n records.push({ name: `_did.${z32}.`, value: root.join(\";\"), ttl: DID_DHT_TTL });\n for (const host of options.gateways ?? []) records.push({ type: \"NS\", name: `_did.${z32}.`, host, ttl: DID_DHT_TTL });\n records.push(...(options.extra ?? []));\n return records;\n}\n\n/** The compressed, authoritative DNS packet of a document. Throws `PacketTooLargeError` past 1000 bytes. */\nexport function encodeDidDhtPacket(document: DidDhtDocument, options: DidDhtPacketOptions = {}): Uint8Array {\n const packet = encodeTxtPacket(didDhtRecords(document, options), { authoritative: true });\n if (packet.length > MAX_DNS_PACKET_BYTES) throw new PacketTooLargeError(packet.length);\n return packet;\n}\n\n/**\n * The packet that ends a DID: its root record alone, reading `deactivated`. Resolvers then answer with\n * `deactivated: true` and a document holding the id alone, until the record leaves the DHT.\n */\nexport function encodeDidDhtDeactivated(publicKey: Uint8Array): Uint8Array {\n const { z32 } = didDhtKey(didDhtFromPublicKey(publicKey));\n return encodeTxtPacket([{ name: `_did.${z32}.`, value: \"deactivated\", ttl: DID_DHT_TTL }], { authoritative: true });\n}\n\n/**\n * The relay payload of a document: its packet, signed by the identity key. `seq` is the BEP44 sequence\n * number, which did:dht defines as the UNIX time in seconds (Ghostly's chat records use microseconds).\n */\nexport function signDidDhtPacket(identity: Identity, dnsPacket: Uint8Array, seq: number): Uint8Array {\n if (!Number.isSafeInteger(seq) || seq < 0) throw new Error(\"A did:dht sequence number is a UNIX time in seconds\");\n return signRelayPayload(identity, dnsPacket, BigInt(seq));\n}\n\n// ── DNS records → document ────────────────────────────────────────────────────────────────────────────\n\nconst FRAGMENT = /^[A-Za-z0-9._~-]{1,64}$/;\nconst ALG = /^[A-Za-z0-9+._-]{1,32}$/;\nconst DID = /^did:[a-z0-9]+:[A-Za-z0-9._:%-]+$/;\nconst URI = /^[A-Za-z][A-Za-z0-9+.-]*:[^\\s,;]+$/;\n\n/** `a=1;b=x,y`: each property once, names in lower case. */\nfunction properties(value: string, where: string): Map<string, string> {\n const out = new Map<string, string>();\n for (const pair of value.split(\";\")) {\n const at = pair.indexOf(\"=\");\n const name = pair.slice(0, at);\n if (at <= 0 || !/^[a-z]+$/.test(name)) throw malformed(`${where} has a property that is not name=value`);\n if (out.has(name)) throw malformed(`${where} has ${name} twice`);\n out.set(name, pair.slice(at + 1));\n }\n return out;\n}\n\nfunction list(value: string | undefined, where: string, item: RegExp): string[] {\n if (value === undefined) return [];\n const items = value.split(\",\");\n for (const v of items) if (!item.test(v)) throw malformed(`${where} has an unexpected value`);\n return items;\n}\n\nexport interface DecodedDidDht {\n document: DidDhtDocument;\n /** The root record says `deactivated`: the document holds the id alone. */\n deactivated: boolean;\n /** Type indexing integers (`_typ._did.`), when present. */\n types?: number[];\n}\n\n/**\n * The document in a did:dht DNS packet. Other records of the key (anything not ending in `_did`) are\n * ignored, and so are did:dht records this version does not know (`_prv`, future ones); everything it\n * does know must be well formed and consistent, or the packet is refused.\n */\nexport function decodeDidDhtPacket(did: string, dnsPacket: Uint8Array): DecodedDidDht {\n const { z32, publicKey } = didDhtKey(did);\n let txt: TxtRecord[];\n try {\n txt = decodeTxtPacket(dnsPacket);\n } catch (error) {\n throw malformed(`not a DNS packet (${error instanceof Error ? error.message : String(error)})`);\n }\n\n // `_k0._did` as the spec writes it, or `_k0._did.<ID>` as a Pkarr client that appends its origin does.\n const byName = new Map<string, string>();\n let rootValue: string | undefined;\n for (const record of txt) {\n const name = record.name.toLowerCase().replace(/\\.$/, \"\");\n if (name === `_did.${z32}`) {\n if (rootValue !== undefined) throw malformed(\"two root records\");\n rootValue = record.value;\n continue;\n }\n const match = /^(_[a-z0-9]+)\\._did(?:\\.([a-z0-9]+))?$/.exec(name);\n if (!match || (match[2] !== undefined && match[2] !== z32)) continue;\n if (byName.has(match[1])) throw malformed(`two ${match[1]} records`);\n byName.set(match[1], record.value);\n }\n if (rootValue === undefined) throw malformed(\"no root record\");\n if (rootValue === \"deactivated\") return { document: { id: did, verificationMethod: [] }, deactivated: true };\n\n const root = properties(rootValue, \"the root record\");\n if (root.get(\"v\") !== DID_DHT_VERSION) throw malformed(`version ${root.get(\"v\") ?? \"(none)\"} is not supported`);\n const vm = list(root.get(\"vm\"), \"the root record's vm\", /^k\\d{1,3}$/);\n if (!vm.includes(\"k0\")) throw malformed(\"the identity key k0 is not listed\");\n if (new Set(vm).size !== vm.length) throw malformed(\"a key is listed twice\");\n\n const document: DidDhtDocument = { id: did, verificationMethod: [] };\n const methodIds = new Map<string, string>();\n for (const alias of vm) {\n const value = byName.get(`_${alias}`);\n if (value === undefined) throw malformed(`the key ${alias} has no record`);\n const props = properties(value, `the key ${alias}`);\n const type = Number(props.get(\"t\"));\n if (!/^[0-3]$/.test(props.get(\"t\") ?? \"\")) throw malformed(`the key ${alias} has an unknown type`);\n const alg = props.get(\"a\") ?? KEY_TYPES[type].alg;\n if (!ALG.test(alg)) throw malformed(`the key ${alias} has an unusable algorithm`);\n const k = props.get(\"k\") ?? \"\";\n // 4n+1 characters encode no byte string: atob would throw a DOMException, not a DidDhtError.\n const bytes = /^[A-Za-z0-9_-]+$/.test(k) && k.length % 4 !== 1 ? fromBase64Url(k) : new Uint8Array();\n if (bytes.length === 0 || toBase64Url(bytes) !== k) throw malformed(`the key ${alias} is not unpadded base64url`);\n const controller = props.get(\"c\") ?? did;\n if (!DID.test(controller)) throw malformed(`the key ${alias} has a controller that is not a DID`);\n\n let fragment: string;\n let jwk: DidDhtJwk;\n if (alias === \"k0\") {\n if (type !== 0 || !bytesEqual(bytes, publicKey)) throw malformed(\"k0 is not the DID's identity key\");\n if (props.has(\"id\") && props.get(\"id\") !== \"0\") throw malformed(\"the identity key's id is not 0\");\n fragment = \"0\";\n jwk = jwkOf(type, bytes, alg, fragment);\n } else {\n const provisional = jwkOf(type, bytes, alg, \"\");\n fragment = props.get(\"id\") ?? jwkThumbprint(provisional);\n if (!FRAGMENT.test(fragment)) throw malformed(`the key ${alias} has an unusable id`);\n jwk = { ...provisional, kid: fragment };\n }\n const id = `${did}#${fragment}`;\n if ([...methodIds.values()].includes(id)) throw malformed(`two keys have the id ${fragment}`);\n methodIds.set(alias, id);\n document.verificationMethod.push({ id, type: \"JsonWebKey\", controller, publicKeyJwk: jwk });\n }\n\n for (const [short, property] of RELATIONSHIPS) {\n const refs = list(root.get(short), `the root record's ${short}`, /^k\\d{1,3}$/);\n if (refs.length === 0) continue;\n document[property] = refs.map((alias) => {\n const id = methodIds.get(alias);\n if (!id) throw malformed(`${short} names ${alias}, which is not a listed key`);\n return id;\n });\n }\n\n const services = list(root.get(\"svc\"), \"the root record's svc\", /^s\\d{1,3}$/);\n if (new Set(services).size !== services.length) throw malformed(\"a service is listed twice\");\n for (const alias of services) {\n const value = byName.get(`_${alias}`);\n if (value === undefined) throw malformed(`the service ${alias} has no record`);\n const props = properties(value, `the service ${alias}`);\n const fragment = props.get(\"id\") ?? \"\";\n const type = props.get(\"t\") ?? \"\";\n if (!FRAGMENT.test(fragment)) throw malformed(`the service ${alias} has an unusable id`);\n if (!/^[A-Za-z0-9._:/-]{1,64}$/.test(type)) throw malformed(`the service ${alias} has an unusable type`);\n const service: DidDhtService = { id: `${did}#${fragment}`, type, serviceEndpoint: list(props.get(\"se\") ?? \"\", `the service ${alias}'s endpoint`, URI) };\n for (const extra of [\"sig\", \"enc\"] as const) {\n const v = props.get(extra);\n if (v !== undefined) service[extra] = v.includes(\",\") ? list(v, `the service ${alias}'s ${extra}`, /^[^\\s,;]+$/) : v;\n }\n if (document.service?.some((s) => s.id === service.id)) throw malformed(`two services have the id ${fragment}`);\n (document.service ??= []).push(service);\n }\n\n const controller = byName.get(\"_cnt\");\n if (controller !== undefined) {\n const controllers = list(controller, \"the controller record\", DID);\n document.controller = controllers.length === 1 ? controllers[0] : controllers;\n }\n const aka = byName.get(\"_aka\");\n if (aka !== undefined) document.alsoKnownAs = list(aka, \"the also-known-as record\", URI);\n\n const decoded: DecodedDidDht = { document, deactivated: false };\n const typ = byName.get(\"_typ\");\n if (typ !== undefined) {\n const props = properties(typ, \"the type record\");\n decoded.types = list(props.get(\"id\"), \"the type record\", /^\\d{1,9}$/).map(Number);\n }\n return decoded;\n}\n\n// ── Resolution ────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DidDhtFetchResponse { status: number; bytes: Uint8Array }\n/** A bounded GET (the identity proofs' `ctx.fetch` is one). */\nexport type DidDhtFetch = (url: string, options?: { maxBytes?: number; signal?: AbortSignal; redirect?: \"error\" }) => Promise<DidDhtFetchResponse>;\n\nexport interface ResolveDidDhtOptions {\n fetch: DidDhtFetch;\n /** Pkarr relays (or did:dht gateways, which answer the same GET) to ask, all of them. Default: `DEFAULT_RELAYS`. */\n relays?: string[];\n signal?: AbortSignal;\n}\n\nexport interface DidDhtMetadata {\n /** The BEP44 sequence number. */\n versionId: string;\n /** When it was published, from the sequence number. */\n updated: string;\n deactivated?: true;\n types?: number[];\n}\n\nexport interface DidDhtResolution {\n document: DidDhtDocument;\n metadata: DidDhtMetadata;\n /** The relay that answered. */\n relay: string;\n}\n\n/** A packet opened and decoded: the signature is the identity key's, the document well formed. */\nexport function openDidDhtPayload(did: string, payload: Uint8Array): DecodedDidDht & { seq: bigint } {\n const { z32 } = didDhtKey(did);\n let opened: { seq: bigint; dnsPacket: Uint8Array };\n try {\n opened = openRelayPayload(z32, payload);\n } catch (error) {\n if (error instanceof Error && error.message === \"Invalid signature\") {\n throw new DidDhtError(\"The did:dht record is not signed by the DID's key\", \"invalid-signature\");\n }\n throw malformed(error instanceof Error ? error.message : String(error));\n }\n return { ...decodeDidDhtPacket(did, opened.dnsPacket), seq: opened.seq };\n}\n\n/** The spec's `seq` is in seconds; Pkarr clients write microseconds. Either way, a date. */\nfunction seqDate(seq: bigint): string {\n const n = Number(seq);\n const ms = n < 1e11 ? n * 1000 : n < 1e14 ? n : n / 1000;\n const date = new Date(ms);\n return Number.isNaN(date.getTime()) ? new Date(0).toISOString() : date.toISOString();\n}\n\n/**\n * Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that\n * checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding\n * an older version cannot bring back a removed key or undo a deactivation. Each answer is bounded to\n * a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay\n * that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID\n * resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.\n */\nexport async function resolveDidDht(did: string, options: ResolveDidDhtOptions): Promise<DidDhtResolution> {\n const { z32 } = didDhtKey(did);\n const relays = [...new Set((options.relays ?? DEFAULT_RELAYS).map(normalizeRelayUrl).filter((r): r is string => r !== null))];\n if (relays.length === 0) throw new DidDhtError(\"No Pkarr relay to ask\", \"unreachable\");\n options.signal?.throwIfAborted();\n\n const responses = await Promise.all(relays.map((relay) =>\n options.fetch(`${relay}/${z32}`, { maxBytes: DID_DHT_MAX_PAYLOAD, signal: options.signal, redirect: \"error\" }).catch(() => undefined)));\n options.signal?.throwIfAborted();\n\n let notFound = false;\n let refused: DidDhtError | undefined;\n let newest: (DecodedDidDht & { seq: bigint; relay: string }) | undefined;\n for (const [i, relay] of relays.entries()) {\n const response = responses[i];\n if (response?.status === 404) notFound = true;\n if (response?.status !== 200) continue;\n try {\n const opened = openDidDhtPayload(did, response.bytes);\n if (!newest || opened.seq > newest.seq) newest = { ...opened, relay };\n } catch (error) {\n if (!(error instanceof DidDhtError)) throw error;\n refused = error;\n }\n }\n if (newest) {\n return {\n document: newest.document,\n metadata: {\n versionId: newest.seq.toString(),\n updated: seqDate(newest.seq),\n ...(newest.deactivated ? { deactivated: true as const } : {}),\n ...(newest.types ? { types: newest.types } : {}),\n },\n relay: newest.relay,\n };\n }\n if (refused) throw refused;\n if (notFound) throw new DidDhtError(\"No document is published for this did:dht\", \"not-found\");\n throw new DidDhtError(\"No Pkarr relay answered for this did:dht\", \"unreachable\");\n}\n","/** 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":";;;;;;;;;;;;;;;;;;AAYA,IAAa,mBAAmB;;AAEhC,IAAa,wBAAwB;AACrC,IAAM,MAAM;AACZ,IAAM,SAAS;AACf,IAAM,eAAe;;AAGrB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,EAAE,WAAa,IAAI;EAAE,SAAS;CAAG,QAAQ,CAA6B;AAAI;;AAG7H,SAAgB,kBAAkB,UAAkC;CAClE,MAAM,IAAI,MAAM;CAChB,EAAE,UAAU,IAAI,QAAQ;CACxB,aAAa;EAAE,EAAE,UAAU,OAAO,QAAQ;CAAG;AAC/C;;AAGA,SAAgB,oBAAqD;CAAE,KAAK;CAAG,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,OAAO,CAAC;AAAG;AACrH,SAAgB,+BAAuE;CAAE,OAAO,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,aAAa,CAAC,CAAC;AAAG;AACvJ,SAAgB,6BAAmE;CAAE,OAAO,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,CAAC,CAAC;AAAG;AACjJ,SAAgB,8BAAgE;CAAE,OAAO,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,cAAc,CAAC,CAAC;AAAG;;;;;AAMjJ,SAAS,OAAO;CACd,MAAM,IAAI,MAAM;CAChB,IAAI,EAAE,QAAQ;CACd,EAAE,SAAS;CACX,KAAK,MAAM,UAAU,iBACnB,IAAI;EAAE,iBAAiB,MAAM;CAAG,SACzB,OAAO;EAAE,QAAQ,MAAM,sDAAsD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CAAG;AAEnJ;;;;;;ACrJA,IAAI,eAAyC,KAAA;AAC7C,SAAgB,gBAAgB,MAAsC;CAAE,SAAS;AAAM;AACvF,IAAa,eAAmC,OAAO"}
1
+ {"version":3,"file":"ownDid-BErplN7N.js","names":[],"sources":["../../../core/src/pubkyProofs.ts","../../../core/src/didDht.ts","../../../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":["import { fromZ32, randomBytes, toZ32 } from \"./bytes\";\nimport type { IdentityStatement } from \"./identityProofs\";\n\n/**\n * A Pubky identity proof, by publication (WISP 302, docs/wisps/302-pubky.md). Neither Pubky Ring nor Pubky\n * Passport signs arbitrary text: they approve standard Pubky auth requests. So Ghostly asks, through one of them,\n * for write access to ONE fresh folder of the key's homeserver, `/pub/ghostly.app/proofs/<folder>/`, and writes the\n * identity statement there (the #80 statement: the Pubky key authorizes this profile's per-proof key). A contact's\n * app reads the file back, finding the homeserver through the key's own signed PKDNS records (pkdns.ts), never\n * through a host or URL from the proof. The folder is random, so the path says nothing about the profile.\n */\n\nexport const PUBKY_PROOF_ROOT = \"/pub/ghostly.app/proofs/\";\n/** The file is the statement, a few hundred bytes: anything larger is not ours. */\nexport const PUBKY_PROOF_MAX_BYTES = 1024;\nconst Z32 = /^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/;\nconst FOLDER = /^[a-f0-9]{64}$/;\nconst STATEMENT_ID = /^[a-f0-9]{64}$/;\n\n/** A canonical Pubky key: 52 characters of z-base-32 that decode to 32 bytes and back. */\nexport function isPubkyKey(value: unknown): value is string {\n if (typeof value !== \"string\" || !Z32.test(value)) return false;\n try { return toZ32(fromZ32(value)) === value; } catch { return false; }\n}\n\n/** The z-base-32 key for what a person typed or pasted: the bare key, `pubky<key>`, `pk:<key>` or `pubky://<key>`. */\nexport function normalizePubkyKey(input: string): string {\n const match = /^(?:pubky:\\/\\/|pubky|pk:)?([a-z0-9]{52})\\/?$/i.exec(typeof input === \"string\" ? input.trim() : \"\");\n const key = match?.[1].toLowerCase();\n if (!key || !isPubkyKey(key)) throw new Error(\"That is not a Pubky key: 52 characters, like the one Pubky Ring shows\");\n return key;\n}\n\nexport const isPubkyProofFolder = (value: unknown): value is string => typeof value === \"string\" && FOLDER.test(value);\n\n/** A fresh folder name: 32 random bytes, hex. One per proof, so two proofs never share a path. */\nexport const newPubkyProofFolder = () => Array.from(randomBytes(32), b => b.toString(16).padStart(2, \"0\")).join(\"\");\n\n/** The only capability Ghostly ever asks for: write access to one proof folder. */\nexport function pubkyProofCapability(folder: string): `/pub/${string}/:w` {\n if (!isPubkyProofFolder(folder)) throw new Error(\"Invalid Pubky proof folder\");\n return `${PUBKY_PROOF_ROOT}${folder}/:w`;\n}\n\n/** Where the statement goes: in its folder, named by the statement id. */\nexport function pubkyProofPath(folder: string, statementId: string): `/pub/${string}` {\n if (!isPubkyProofFolder(folder) || !STATEMENT_ID.test(statementId)) throw new Error(\"Invalid Pubky proof path\");\n return `${PUBKY_PROOF_ROOT}${folder}/${statementId}.txt`;\n}\n\n/** The file's exact contents: the statement's one line, nothing added. The verifier compares bytes. */\nexport const pubkyProofFile = (statement: IdentityStatement): string => statement.text;\n","import { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesEqual, fromBase64Url, fromZ32, toBase64Url, toZ32, utf8Encode } from \"./bytes\";\nimport { decodeTxtPacket, encodeTxtPacket, type NsRecord, type TxtRecord } from \"./dns\";\nimport type { Identity } from \"./identity\";\nimport { MAX_DNS_PACKET_BYTES, PacketTooLargeError, openRelayPayload, signRelayPayload } from \"./pkarr\";\nimport { DEFAULT_RELAYS, normalizeRelayUrl } from \"./relay\";\n\n/**\n * did:dht (the DIF method, https://github.com/decentralized-identity/did-dht/blob/main/spec/spec.md): a W3C DID document written as DNS records into the\n * Pkarr packet of an Ed25519 key, the BEP44 mutable item Ghostly already publishes chats under. This\n * module maps a document to that packet and back (strictly: a malformed packet is an error, never a\n * guess) and resolves a did:dht through Pkarr relays. WISP 310-did-dht describes Ghostly's use.\n */\n\nexport const DID_DHT_PREFIX = \"did:dht:\";\n/** The TTL the spec recommends: Mainline's default record lifetime. */\nexport const DID_DHT_TTL = 7200;\n/** The spec version this module writes and the only one it reads (`v=0`). */\nexport const DID_DHT_VERSION = \"0\";\n/** A relay answer: 64 bytes of signature, 8 of sequence number, then at most 1000 of DNS packet. */\nexport const DID_DHT_MAX_PAYLOAD = 64 + 8 + MAX_DNS_PACKET_BYTES;\n\nexport interface DidDhtJwk {\n kty: \"OKP\" | \"EC\";\n crv: \"Ed25519\" | \"secp256k1\" | \"P-256\" | \"X25519\";\n x: string;\n y?: string;\n alg: string;\n kid: string;\n}\n\nexport interface DidDhtVerificationMethod {\n id: string;\n type: \"JsonWebKey\";\n controller: string;\n publicKeyJwk: DidDhtJwk;\n}\n\nexport interface DidDhtService {\n id: string;\n type: string;\n serviceEndpoint: string[];\n /** Registered extra properties (the spec's registry): which keys sign and encrypt for it. */\n sig?: string | string[];\n enc?: string | string[];\n}\n\n/** A did:dht document in W3C DID Core JSON: no `@context`, every reference fully qualified. */\nexport interface DidDhtDocument {\n id: string;\n controller?: string | string[];\n alsoKnownAs?: string[];\n verificationMethod: DidDhtVerificationMethod[];\n authentication?: string[];\n assertionMethod?: string[];\n keyAgreement?: string[];\n capabilityInvocation?: string[];\n capabilityDelegation?: string[];\n service?: DidDhtService[];\n}\n\n/** Why a did:dht could not be read: the message is meant for a person. */\nexport class DidDhtError extends Error {\n constructor(message: string, readonly code: \"invalid-did\" | \"not-found\" | \"invalid-signature\" | \"malformed\" | \"unreachable\") {\n super(message);\n this.name = \"DidDhtError\";\n }\n}\n\nconst malformed = (detail: string) => new DidDhtError(`The did:dht document is malformed: ${detail}`, \"malformed\");\n\n// ── Identifiers ───────────────────────────────────────────────────────────────────────────────────────\n\n/** `did:dht:<z-base-32 of the Ed25519 public key>`. */\nexport function didDhtFromPublicKey(publicKey: Uint8Array): string {\n if (publicKey.length !== 32) throw new Error(\"A did:dht identity key is 32 bytes of Ed25519 public key\");\n return DID_DHT_PREFIX + toZ32(publicKey);\n}\n\n/** The identity key of a did:dht. Only the exact DID: no path, query or fragment, canonical z-base-32. */\nexport function didDhtKey(did: string): { z32: string; publicKey: Uint8Array } {\n const invalid = () => new DidDhtError(\"This is not a valid did:dht\", \"invalid-did\");\n if (typeof did !== \"string\" || !did.startsWith(DID_DHT_PREFIX)) throw invalid();\n const z32 = did.slice(DID_DHT_PREFIX.length);\n if (!/^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/.test(z32)) throw invalid();\n const publicKey = fromZ32(z32);\n // 52 characters carry 260 bits: the last four must be zero, or two DIDs would name one key.\n if (toZ32(publicKey) !== z32) throw invalid();\n // Nor a point of small order: no secret key goes with one, and it \"verifies\" a constant signature of any packet.\n let fit: boolean;\n try { fit = !ed25519.Point.fromBytes(publicKey).isSmallOrder(); } catch { fit = false; }\n if (!fit) throw invalid();\n return { z32, publicKey };\n}\n\n// ── Documents ─────────────────────────────────────────────────────────────────────────────────────────\n\nconst KEY_TYPES = [\n { kty: \"OKP\", crv: \"Ed25519\", alg: \"EdDSA\" },\n { kty: \"EC\", crv: \"secp256k1\", alg: \"ES256K\" },\n { kty: \"EC\", crv: \"P-256\", alg: \"ES256\" },\n { kty: \"OKP\", crv: \"X25519\", alg: \"ECDH-ES+A256KW\" },\n] as const;\n\nconst RELATIONSHIPS = [\n [\"auth\", \"authentication\"],\n [\"asm\", \"assertionMethod\"],\n [\"agm\", \"keyAgreement\"],\n [\"inv\", \"capabilityInvocation\"],\n [\"del\", \"capabilityDelegation\"],\n] as const;\n\n/**\n * The document of an identity key alone, as the spec's Create step makes it: the key as `#0`, with the\n * four relationships it requires (authentication, assertion, capability invocation and delegation).\n * `alsoKnownAs` adds other identifiers of the same subject (URIs), which the document makes public.\n */\nexport function didDhtDocument(publicKey: Uint8Array, options: { alsoKnownAs?: string[] } = {}): DidDhtDocument {\n const id = didDhtFromPublicKey(publicKey);\n const key = `${id}#0`;\n return {\n id,\n ...(options.alsoKnownAs?.length ? { alsoKnownAs: [...options.alsoKnownAs] } : {}),\n verificationMethod: [{\n id: key,\n type: \"JsonWebKey\",\n controller: id,\n publicKeyJwk: { kty: \"OKP\", crv: \"Ed25519\", x: toBase64Url(publicKey), alg: \"EdDSA\", kid: \"0\" },\n }],\n authentication: [key],\n assertionMethod: [key],\n capabilityInvocation: [key],\n capabilityDelegation: [key],\n };\n}\n\n/** RFC 7638 thumbprint: SHA-256 of the required members in lexicographic order. */\nexport function jwkThumbprint(jwk: Pick<DidDhtJwk, \"kty\" | \"crv\" | \"x\" | \"y\">): string {\n const members = jwk.kty === \"EC\" ? { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y } : { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n return toBase64Url(sha256(utf8Encode(JSON.stringify(members))));\n}\n\nfunction publicKeyBytes(type: number, jwk: DidDhtJwk): Uint8Array {\n const x = fromBase64Url(jwk.x);\n if (type === 0 || type === 3) return x;\n // Compressed point: the x-coordinate and the sign of y (the spec's size rule).\n const curve = type === 1 ? secp256k1 : p256;\n return curve.Point.fromAffine({ x: bigintOf(x), y: bigintOf(fromBase64Url(jwk.y ?? \"\")) }).toBytes(true);\n}\n\nfunction bigintOf(bytes: Uint8Array): bigint {\n let n = 0n;\n for (const b of bytes) n = (n << 8n) | BigInt(b);\n return n;\n}\n\nfunction jwkOf(type: number, bytes: Uint8Array, alg: string, kid: string): DidDhtJwk {\n const kind = KEY_TYPES[type];\n if (type === 0) {\n if (bytes.length !== 32) throw malformed(\"an Ed25519 key is not 32 bytes\");\n let smallOrder: boolean;\n try { smallOrder = ed25519.Point.fromBytes(bytes).isSmallOrder(); } catch { throw malformed(\"an Ed25519 key is not a point of the curve\"); }\n if (smallOrder) throw malformed(\"an Ed25519 key is a point of small order, which no secret key goes with\");\n return { kty: \"OKP\", crv: \"Ed25519\", x: toBase64Url(bytes), alg, kid };\n }\n if (type === 3) {\n if (bytes.length !== 32) throw malformed(\"an X25519 key is not 32 bytes\");\n return { kty: \"OKP\", crv: \"X25519\", x: toBase64Url(bytes), alg, kid };\n }\n if (bytes.length !== 33 && bytes.length !== 65) throw malformed(`a ${kind.crv} key is neither a compressed nor an uncompressed point`);\n let raw: Uint8Array;\n try {\n raw = (type === 1 ? secp256k1 : p256).Point.fromBytes(bytes).toBytes(false);\n } catch {\n throw malformed(`a ${kind.crv} key is not a point of the curve`);\n }\n return { kty: \"EC\", crv: kind.crv, x: toBase64Url(raw.subarray(1, 33)), y: toBase64Url(raw.subarray(33)), alg, kid };\n}\n\n// ── Document → DNS records ────────────────────────────────────────────────────────────────────────────\n\nexport interface DidDhtPacketOptions {\n /** Type indexing (`_typ._did.`), integers from the spec's registry. */\n types?: number[];\n /** Authoritative gateways, as NS records of the root name. */\n gateways?: string[];\n /**\n * Other records of the same key. A key has exactly one packet: whatever else it publishes goes in\n * with the document, and the whole must fit the 1000 bytes.\n */\n extra?: TxtRecord[];\n}\n\nconst fragmentOf = (documentId: string, ref: string, what: string): string => {\n if (!ref.startsWith(`${documentId}#`)) throw new Error(`${what} ${ref} is not a fragment of ${documentId}`);\n const fragment = ref.slice(documentId.length + 1);\n if (!FRAGMENT.test(fragment)) throw new Error(`${what} ${ref} has an unusable fragment`);\n return fragment;\n};\n\nconst listValue = (values: string[], what: string): string => {\n for (const v of values) if (!v || /[,;\\s]/.test(v)) throw new Error(`${what} ${JSON.stringify(v)} cannot be written into a did:dht record`);\n return values.join(\",\");\n};\n\n/**\n * The DNS records of a document, in the spec's layout (names `_did.<ID>.` and `_kN._did.`). The root\n * record comes after the records it names, gateways last: the order @web5/dids writes, and the only one\n * it reads correctly (it resolves `vm`/`auth` references in packet order). Order-free readers don't mind.\n */\nexport function didDhtRecords(document: DidDhtDocument, options: DidDhtPacketOptions = {}): (TxtRecord | NsRecord)[] {\n const { z32, publicKey } = didDhtKey(document.id);\n const methods = document.verificationMethod;\n const first = methods[0];\n if (!first || first.id !== `${document.id}#0` || first.publicKeyJwk.crv !== \"Ed25519\" || !bytesEqual(fromBase64Url(first.publicKeyJwk.x), publicKey)) {\n throw new Error(\"The first verification method of a did:dht document is its identity key, #0\");\n }\n\n const aliases = new Map<string, string>();\n const keyRecords: TxtRecord[] = methods.map((method, index) => {\n const alias = `k${index}`;\n if (aliases.has(method.id)) throw new Error(`Verification method ${method.id} appears twice`);\n aliases.set(method.id, alias);\n const fragment = fragmentOf(document.id, method.id, \"Verification method\");\n const type = KEY_TYPES.findIndex((k) => k.crv === method.publicKeyJwk.crv);\n if (type < 0) throw new Error(`Key type ${method.publicKeyJwk.crv} has no did:dht index`);\n const jwk = method.publicKeyJwk;\n const parts: string[] = [];\n // The identity key's id is always 0, and one that is the thumbprint can be computed back: both are left out.\n if (index > 0 && fragment !== jwkThumbprint(jwk)) parts.push(`id=${fragment}`);\n parts.push(`t=${type}`, `k=${toBase64Url(publicKeyBytes(type, jwk))}`);\n if (jwk.alg !== KEY_TYPES[type].alg) parts.push(`a=${jwk.alg}`);\n if (method.controller !== document.id) parts.push(`c=${listValue([method.controller], \"Controller\")}`);\n return { name: `_${alias}._did.`, value: parts.join(\";\"), ttl: DID_DHT_TTL };\n });\n\n const services = document.service ?? [];\n const serviceRecords: TxtRecord[] = services.map((service, index) => {\n const parts = [\n `id=${fragmentOf(document.id, service.id, \"Service\")}`,\n `t=${listValue([service.type], \"Service type\")}`,\n `se=${listValue(service.serviceEndpoint, \"Service endpoint\")}`,\n ];\n for (const extra of [\"sig\", \"enc\"] as const) {\n const v = service[extra];\n if (v !== undefined) parts.push(`${extra}=${listValue(Array.isArray(v) ? v : [v], `Service ${extra}`)}`);\n }\n return { name: `_s${index}._did.`, value: parts.join(\";\"), ttl: DID_DHT_TTL };\n });\n\n const root = [`v=${DID_DHT_VERSION}`, `vm=${keyRecords.map((_, i) => `k${i}`).join(\",\")}`];\n for (const [short, property] of RELATIONSHIPS) {\n const refs = document[property] ?? [];\n if (refs.length === 0) continue;\n root.push(`${short}=${refs.map((ref) => {\n const alias = aliases.get(ref);\n if (!alias) throw new Error(`${property} refers to ${ref}, which is not a verification method of the document`);\n return alias;\n }).join(\",\")}`);\n }\n if (serviceRecords.length) root.push(`svc=${serviceRecords.map((_, i) => `s${i}`).join(\",\")}`);\n\n const records: (TxtRecord | NsRecord)[] = [];\n if (document.alsoKnownAs?.length) records.push({ name: \"_aka._did.\", value: listValue(document.alsoKnownAs, \"Also-known-as\"), ttl: DID_DHT_TTL });\n if (document.controller !== undefined) {\n const controllers = Array.isArray(document.controller) ? document.controller : [document.controller];\n records.push({ name: \"_cnt._did.\", value: listValue(controllers, \"Controller\"), ttl: DID_DHT_TTL });\n }\n records.push(...keyRecords, ...serviceRecords);\n if (options.types?.length) {\n for (const t of options.types) if (!Number.isSafeInteger(t) || t < 0) throw new Error(`Type ${t} is not a registry integer`);\n records.push({ name: \"_typ._did.\", value: `id=${options.types.join(\",\")}`, ttl: DID_DHT_TTL });\n }\n records.push({ name: `_did.${z32}.`, value: root.join(\";\"), ttl: DID_DHT_TTL });\n for (const host of options.gateways ?? []) records.push({ type: \"NS\", name: `_did.${z32}.`, host, ttl: DID_DHT_TTL });\n records.push(...(options.extra ?? []));\n return records;\n}\n\n/** The compressed, authoritative DNS packet of a document. Throws `PacketTooLargeError` past 1000 bytes. */\nexport function encodeDidDhtPacket(document: DidDhtDocument, options: DidDhtPacketOptions = {}): Uint8Array {\n const packet = encodeTxtPacket(didDhtRecords(document, options), { authoritative: true });\n if (packet.length > MAX_DNS_PACKET_BYTES) throw new PacketTooLargeError(packet.length);\n return packet;\n}\n\n/**\n * The packet that ends a DID: its root record alone, reading `deactivated`. Resolvers then answer with\n * `deactivated: true` and a document holding the id alone, until the record leaves the DHT.\n */\nexport function encodeDidDhtDeactivated(publicKey: Uint8Array): Uint8Array {\n const { z32 } = didDhtKey(didDhtFromPublicKey(publicKey));\n return encodeTxtPacket([{ name: `_did.${z32}.`, value: \"deactivated\", ttl: DID_DHT_TTL }], { authoritative: true });\n}\n\n/**\n * The relay payload of a document: its packet, signed by the identity key. `seq` is the BEP44 sequence\n * number, which did:dht defines as the UNIX time in seconds (Ghostly's chat records use microseconds).\n */\nexport function signDidDhtPacket(identity: Identity, dnsPacket: Uint8Array, seq: number): Uint8Array {\n if (!Number.isSafeInteger(seq) || seq < 0) throw new Error(\"A did:dht sequence number is a UNIX time in seconds\");\n return signRelayPayload(identity, dnsPacket, BigInt(seq));\n}\n\n// ── DNS records → document ────────────────────────────────────────────────────────────────────────────\n\nconst FRAGMENT = /^[A-Za-z0-9._~-]{1,64}$/;\nconst ALG = /^[A-Za-z0-9+._-]{1,32}$/;\nconst DID = /^did:[a-z0-9]+:[A-Za-z0-9._:%-]+$/;\nconst URI = /^[A-Za-z][A-Za-z0-9+.-]*:[^\\s,;]+$/;\n\n/** `a=1;b=x,y`: each property once, names in lower case. */\nfunction properties(value: string, where: string): Map<string, string> {\n const out = new Map<string, string>();\n for (const pair of value.split(\";\")) {\n const at = pair.indexOf(\"=\");\n const name = pair.slice(0, at);\n if (at <= 0 || !/^[a-z]+$/.test(name)) throw malformed(`${where} has a property that is not name=value`);\n if (out.has(name)) throw malformed(`${where} has ${name} twice`);\n out.set(name, pair.slice(at + 1));\n }\n return out;\n}\n\nfunction list(value: string | undefined, where: string, item: RegExp): string[] {\n if (value === undefined) return [];\n const items = value.split(\",\");\n for (const v of items) if (!item.test(v)) throw malformed(`${where} has an unexpected value`);\n return items;\n}\n\nexport interface DecodedDidDht {\n document: DidDhtDocument;\n /** The root record says `deactivated`: the document holds the id alone. */\n deactivated: boolean;\n /** Type indexing integers (`_typ._did.`), when present. */\n types?: number[];\n}\n\n/**\n * The document in a did:dht DNS packet. Other records of the key (anything not ending in `_did`) are\n * ignored, and so are did:dht records this version does not know (`_prv`, future ones); everything it\n * does know must be well formed and consistent, or the packet is refused.\n */\nexport function decodeDidDhtPacket(did: string, dnsPacket: Uint8Array): DecodedDidDht {\n const { z32, publicKey } = didDhtKey(did);\n let txt: TxtRecord[];\n try {\n txt = decodeTxtPacket(dnsPacket);\n } catch (error) {\n throw malformed(`not a DNS packet (${error instanceof Error ? error.message : String(error)})`);\n }\n\n // `_k0._did` as the spec writes it, or `_k0._did.<ID>` as a Pkarr client that appends its origin does.\n const byName = new Map<string, string>();\n let rootValue: string | undefined;\n for (const record of txt) {\n const name = record.name.toLowerCase().replace(/\\.$/, \"\");\n if (name === `_did.${z32}`) {\n if (rootValue !== undefined) throw malformed(\"two root records\");\n rootValue = record.value;\n continue;\n }\n const match = /^(_[a-z0-9]+)\\._did(?:\\.([a-z0-9]+))?$/.exec(name);\n if (!match || (match[2] !== undefined && match[2] !== z32)) continue;\n if (byName.has(match[1])) throw malformed(`two ${match[1]} records`);\n byName.set(match[1], record.value);\n }\n if (rootValue === undefined) throw malformed(\"no root record\");\n if (rootValue === \"deactivated\") return { document: { id: did, verificationMethod: [] }, deactivated: true };\n\n const root = properties(rootValue, \"the root record\");\n if (root.get(\"v\") !== DID_DHT_VERSION) throw malformed(`version ${root.get(\"v\") ?? \"(none)\"} is not supported`);\n const vm = list(root.get(\"vm\"), \"the root record's vm\", /^k\\d{1,3}$/);\n if (!vm.includes(\"k0\")) throw malformed(\"the identity key k0 is not listed\");\n if (new Set(vm).size !== vm.length) throw malformed(\"a key is listed twice\");\n\n const document: DidDhtDocument = { id: did, verificationMethod: [] };\n const methodIds = new Map<string, string>();\n for (const alias of vm) {\n const value = byName.get(`_${alias}`);\n if (value === undefined) throw malformed(`the key ${alias} has no record`);\n const props = properties(value, `the key ${alias}`);\n const type = Number(props.get(\"t\"));\n if (!/^[0-3]$/.test(props.get(\"t\") ?? \"\")) throw malformed(`the key ${alias} has an unknown type`);\n const alg = props.get(\"a\") ?? KEY_TYPES[type].alg;\n if (!ALG.test(alg)) throw malformed(`the key ${alias} has an unusable algorithm`);\n const k = props.get(\"k\") ?? \"\";\n // 4n+1 characters encode no byte string: atob would throw a DOMException, not a DidDhtError.\n const bytes = /^[A-Za-z0-9_-]+$/.test(k) && k.length % 4 !== 1 ? fromBase64Url(k) : new Uint8Array();\n if (bytes.length === 0 || toBase64Url(bytes) !== k) throw malformed(`the key ${alias} is not unpadded base64url`);\n const controller = props.get(\"c\") ?? did;\n if (!DID.test(controller)) throw malformed(`the key ${alias} has a controller that is not a DID`);\n\n let fragment: string;\n let jwk: DidDhtJwk;\n if (alias === \"k0\") {\n if (type !== 0 || !bytesEqual(bytes, publicKey)) throw malformed(\"k0 is not the DID's identity key\");\n if (props.has(\"id\") && props.get(\"id\") !== \"0\") throw malformed(\"the identity key's id is not 0\");\n fragment = \"0\";\n jwk = jwkOf(type, bytes, alg, fragment);\n } else {\n const provisional = jwkOf(type, bytes, alg, \"\");\n fragment = props.get(\"id\") ?? jwkThumbprint(provisional);\n if (!FRAGMENT.test(fragment)) throw malformed(`the key ${alias} has an unusable id`);\n jwk = { ...provisional, kid: fragment };\n }\n const id = `${did}#${fragment}`;\n if ([...methodIds.values()].includes(id)) throw malformed(`two keys have the id ${fragment}`);\n methodIds.set(alias, id);\n document.verificationMethod.push({ id, type: \"JsonWebKey\", controller, publicKeyJwk: jwk });\n }\n\n for (const [short, property] of RELATIONSHIPS) {\n const refs = list(root.get(short), `the root record's ${short}`, /^k\\d{1,3}$/);\n if (refs.length === 0) continue;\n document[property] = refs.map((alias) => {\n const id = methodIds.get(alias);\n if (!id) throw malformed(`${short} names ${alias}, which is not a listed key`);\n return id;\n });\n }\n\n const services = list(root.get(\"svc\"), \"the root record's svc\", /^s\\d{1,3}$/);\n if (new Set(services).size !== services.length) throw malformed(\"a service is listed twice\");\n for (const alias of services) {\n const value = byName.get(`_${alias}`);\n if (value === undefined) throw malformed(`the service ${alias} has no record`);\n const props = properties(value, `the service ${alias}`);\n const fragment = props.get(\"id\") ?? \"\";\n const type = props.get(\"t\") ?? \"\";\n if (!FRAGMENT.test(fragment)) throw malformed(`the service ${alias} has an unusable id`);\n if (!/^[A-Za-z0-9._:/-]{1,64}$/.test(type)) throw malformed(`the service ${alias} has an unusable type`);\n const service: DidDhtService = { id: `${did}#${fragment}`, type, serviceEndpoint: list(props.get(\"se\") ?? \"\", `the service ${alias}'s endpoint`, URI) };\n for (const extra of [\"sig\", \"enc\"] as const) {\n const v = props.get(extra);\n if (v !== undefined) service[extra] = v.includes(\",\") ? list(v, `the service ${alias}'s ${extra}`, /^[^\\s,;]+$/) : v;\n }\n if (document.service?.some((s) => s.id === service.id)) throw malformed(`two services have the id ${fragment}`);\n (document.service ??= []).push(service);\n }\n\n const controller = byName.get(\"_cnt\");\n if (controller !== undefined) {\n const controllers = list(controller, \"the controller record\", DID);\n document.controller = controllers.length === 1 ? controllers[0] : controllers;\n }\n const aka = byName.get(\"_aka\");\n if (aka !== undefined) document.alsoKnownAs = list(aka, \"the also-known-as record\", URI);\n\n const decoded: DecodedDidDht = { document, deactivated: false };\n const typ = byName.get(\"_typ\");\n if (typ !== undefined) {\n const props = properties(typ, \"the type record\");\n decoded.types = list(props.get(\"id\"), \"the type record\", /^\\d{1,9}$/).map(Number);\n }\n return decoded;\n}\n\n// ── Resolution ────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DidDhtFetchResponse { status: number; bytes: Uint8Array }\n/** A bounded GET (the identity proofs' `ctx.fetch` is one). */\nexport type DidDhtFetch = (url: string, options?: { maxBytes?: number; signal?: AbortSignal; redirect?: \"error\" }) => Promise<DidDhtFetchResponse>;\n\nexport interface ResolveDidDhtOptions {\n fetch: DidDhtFetch;\n /** Pkarr relays (or did:dht gateways, which answer the same GET) to ask, all of them. Default: `DEFAULT_RELAYS`. */\n relays?: string[];\n signal?: AbortSignal;\n}\n\nexport interface DidDhtMetadata {\n /** The BEP44 sequence number. */\n versionId: string;\n /** When it was published, from the sequence number. */\n updated: string;\n deactivated?: true;\n types?: number[];\n}\n\nexport interface DidDhtResolution {\n document: DidDhtDocument;\n metadata: DidDhtMetadata;\n /** The relay that answered. */\n relay: string;\n}\n\n/** A packet opened and decoded: the signature is the identity key's, the document well formed. */\nexport function openDidDhtPayload(did: string, payload: Uint8Array): DecodedDidDht & { seq: bigint } {\n const { z32 } = didDhtKey(did);\n let opened: { seq: bigint; dnsPacket: Uint8Array };\n try {\n opened = openRelayPayload(z32, payload);\n } catch (error) {\n if (error instanceof Error && error.message === \"Invalid signature\") {\n throw new DidDhtError(\"The did:dht record is not signed by the DID's key\", \"invalid-signature\");\n }\n throw malformed(error instanceof Error ? error.message : String(error));\n }\n return { ...decodeDidDhtPacket(did, opened.dnsPacket), seq: opened.seq };\n}\n\n/** The spec's `seq` is in seconds; Pkarr clients write microseconds. Either way, a date. */\nfunction seqDate(seq: bigint): string {\n const n = Number(seq);\n const ms = n < 1e11 ? n * 1000 : n < 1e14 ? n : n / 1000;\n const date = new Date(ms);\n return Number.isNaN(date.getTime()) ? new Date(0).toISOString() : date.toISOString();\n}\n\n/**\n * Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that\n * checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding\n * an older version cannot bring back a removed key or undo a deactivation. Each answer is bounded to\n * a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay\n * that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID\n * resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.\n */\nexport async function resolveDidDht(did: string, options: ResolveDidDhtOptions): Promise<DidDhtResolution> {\n const { z32 } = didDhtKey(did);\n const relays = [...new Set((options.relays ?? DEFAULT_RELAYS).map(normalizeRelayUrl).filter((r): r is string => r !== null))];\n if (relays.length === 0) throw new DidDhtError(\"No Pkarr relay to ask\", \"unreachable\");\n options.signal?.throwIfAborted();\n\n const responses = await Promise.all(relays.map((relay) =>\n options.fetch(`${relay}/${z32}`, { maxBytes: DID_DHT_MAX_PAYLOAD, signal: options.signal, redirect: \"error\" }).catch(() => undefined)));\n options.signal?.throwIfAborted();\n\n let notFound = false;\n let refused: DidDhtError | undefined;\n let newest: (DecodedDidDht & { seq: bigint; relay: string }) | undefined;\n for (const [i, relay] of relays.entries()) {\n const response = responses[i];\n if (response?.status === 404) notFound = true;\n if (response?.status !== 200) continue;\n try {\n const opened = openDidDhtPayload(did, response.bytes);\n if (!newest || opened.seq > newest.seq) newest = { ...opened, relay };\n } catch (error) {\n if (!(error instanceof DidDhtError)) throw error;\n refused = error;\n }\n }\n if (newest) {\n return {\n document: newest.document,\n metadata: {\n versionId: newest.seq.toString(),\n updated: seqDate(newest.seq),\n ...(newest.deactivated ? { deactivated: true as const } : {}),\n ...(newest.types ? { types: newest.types } : {}),\n },\n relay: newest.relay,\n };\n }\n if (refused) throw refused;\n if (notFound) throw new DidDhtError(\"No document is published for this did:dht\", \"not-found\");\n throw new DidDhtError(\"No Pkarr relay answered for this did:dht\", \"unreachable\");\n}\n","/** 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":";;;;;;;;;;;;;;;;;;AAYA,IAAa,mBAAmB;;AAEhC,IAAa,wBAAwB;AACrC,IAAM,MAAM;AACZ,IAAM,SAAS;AACf,IAAM,eAAe;;AAGrB,SAAgB,WAAW,OAAiC;CAC1D,IAAI,OAAO,UAAU,YAAY,CAAC,IAAI,KAAK,KAAK,GAAG,OAAO;CAC1D,IAAI;EAAE,OAAO,MAAM,QAAQ,KAAK,CAAC,MAAM;CAAO,QAAQ;EAAE,OAAO;CAAO;AACxE;;AAGA,SAAgB,kBAAkB,OAAuB;CAEvD,MAAM,MADQ,gDAAgD,KAAK,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI,EAClG,CAAA,GAAQ,EAAE,CAAC,YAAY;CACnC,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,uEAAuE;CACrH,OAAO;AACT;AAEA,IAAa,sBAAsB,UAAoC,OAAO,UAAU,YAAY,OAAO,KAAK,KAAK;;AAGrH,IAAa,4BAA4B,MAAM,KAAK,YAAY,EAAE,IAA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OAAO,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,cAAc,CAAC,CAAC;AAAG;;;;;AAMjJ,SAAS,OAAO;CACd,MAAM,IAAI,MAAM;CAChB,IAAI,EAAE,QAAQ;CACd,EAAE,SAAS;CACX,KAAK,MAAM,UAAU,iBACnB,IAAI;EAAE,iBAAiB,MAAM;CAAG,SACzB,OAAO;EAAE,QAAQ,MAAM,sDAAsD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CAAG;AAEnJ;;;;;;ACrJA,IAAI,eAAyC,KAAA;AAC7C,SAAgB,gBAAgB,MAAsC;CAAE,SAAS;AAAM;AACvF,IAAa,eAAmC,OAAO"}
@@ -1,7 +1,7 @@
1
1
  import { r as sanitizeDisplayText } from "./text-li76pThX.js";
2
- import { Zn as reactionEmoji, bt as STATUS_AVAILABILITIES, gr as STATUS_CARD_LIMITS, wt as sanitizeStatusText } from "./groupMeta-DTQAJG50.js";
2
+ import { Zn as reactionEmoji, bt as STATUS_AVAILABILITIES, gr as STATUS_CARD_LIMITS, wt as sanitizeStatusText } from "./groupMeta-goASqzOt.js";
3
3
  import { t as CliError } from "./errors-DDLFO4Gf.js";
4
- import { T as node, p as groupOf, r as chatOrGroup } from "./apiKit-CVaEzKWQ.js";
4
+ import { T as node, p as groupOf, r as chatOrGroup } from "./apiKit-BAGvlQtm.js";
5
5
  import { createHash } from "node:crypto";
6
6
  // src/engineMethods.ts
7
7
  /**
@@ -209,6 +209,7 @@ var ENGINE_PARAMS = {
209
209
  setGroupCall: "{ groupId, sfu, e2ee? }",
210
210
  groupCallToken: "{ groupId }",
211
211
  groupCallKey: "{ groupId }",
212
+ groupCallModerate: "{ groupId, act, target?, src? }",
212
213
  forgetGroup: "{ groupId }",
213
214
  setGroupManage: "{ groupId, on }",
214
215
  deviceEnrollInvite: "{ name }",
@@ -299,6 +300,7 @@ var DESTRUCTIVE_CALLS = /* @__PURE__ */ new Map([
299
300
  ["removeLink", "deletes a chat's keys and history on this device"],
300
301
  ["leaveGroup", "deletes a group's history and files on this device"],
301
302
  ["forgetGroup", "deletes a group's history on this device"],
303
+ ["switchGroup", "leaves the group held under this id and deletes its history on this device"],
302
304
  ["deviceRemove", "takes a device off this profile"]
303
305
  ]);
304
306
  /**
@@ -540,4 +542,4 @@ function statusJson(status) {
540
542
  }
541
543
  export { hideSecretFields as _, PAY_METHODS as a, turnRef as c, ENGINE_METHODS as d, ENGINE_PARAMS as f, engineParamsProblem as g, SECRET_RESULTS as h, CHAT_METHODS as i, withStoredIds as l, READ_PARAMS as m, statusJson as n, TRANSPORT_NAMES as o, ENGINE_READS as p, ADDRESS_TYPES as r, WALLET_TYPES as s, checkOwnStatus as t, DESTRUCTIVE_CALLS as u };
542
544
 
543
- //# sourceMappingURL=ownStatus-DMEhrpkd.js.map
545
+ //# sourceMappingURL=ownStatus-ClrFjd7h.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownStatus-ClrFjd7h.js","names":[],"sources":["../../src/engineMethods.ts","../../src/turnRefs.ts","../../src/words.ts","../../src/ownStatus.ts"],"sourcesContent":["/**\n * What each call of the app's `EngineApi` (packages/browser/src/shared/rpc.ts) takes, as `engine --list --verbose`\n * shows it: `{ linkId, label }` an object with these keys (`?` an optional one), a type's name for an object of that\n * type, \"\" nothing; a trailing `?` when the object may be left out. `engineMethods.test.ts` reads it out of rpc.ts and\n * keeps the two equal. The device calls (WISP 06): a CLI profile is always on one device, so they answer `single` or refuse.\n */\nexport const ENGINE_PARAMS: Readonly<Record<string, string>> = {\n usdtCreate: \"UsdtCreate\",\n usdtUnlock: \"{ password, network? }\",\n usdtReveal: \"{ password?, network? }\",\n usdtLock: \"{ network? }?\",\n usdtRefresh: \"{ network? }?\",\n usdtExportBackup: \"{ password, network? }\",\n usdtRestoreBackup: \"{ text, password, network? }\",\n arkCreate: \"ArkCreate\",\n arkUnlock: \"{ password, network? }\",\n arkLock: \"{ network? }?\",\n arkBackup: \"{ password?, network? }\",\n arkExportBackup: \"{ password, network? }\",\n arkRestoreBackup: \"{ text, password, network? }\",\n arkRefresh: \"{ network? }?\",\n arkRecover: \"{ network? }?\",\n barkCreate: \"BarkCreate\",\n barkBackup: \"{ network? }?\",\n barkExportBackup: \"{ password, network? }\",\n barkRestoreBackup: \"{ text, password, network? }\",\n barkRefresh: \"{ network? }?\",\n barkBoard: \"{ network? }?\",\n fedimintPreview: \"{ invite, network? }\",\n fedimintJoin: \"{ invite, recover?, network? }\",\n fedimintLeave: \"{ federation }\",\n fedimintRefresh: \"{ network? }?\",\n fedimintSpendNotes: \"{ federation, amount, confirmedReal? }\",\n fedimintReceiveNotes: \"{ notes, network? }\",\n fedimintInvoice: \"{ federation, amount, memo? }\",\n fedimintTakeBack: \"{ federation, operation }\",\n fedimintBackup: \"{ network? }?\",\n fedimintExportBackup: \"{ password, network? }\",\n fedimintRestoreBackup: \"{ text, password, network? }\",\n fedimintRestorePhrase: \"{ mnemonic, invites, network? }\",\n sparkCreate: \"SparkCreate\",\n sparkBackup: \"{ network? }?\",\n sparkExportBackup: \"{ password, network? }\",\n sparkRestoreBackup: \"{ text, password, apiKey?, network? }\",\n sparkRefresh: \"{ network? }?\",\n sparkUseForLightning: \"{ network? }?\",\n preparePayment: \"{ target, amount, feeCap, payee, linkId?, requestId?, memo?, network? }\",\n approvePayment: \"{ id, confirmedReal? }\",\n reconcilePayment: \"{ id }\",\n cancelPayment: \"{ id }\",\n refreshPublicProfiles: \"{ linkId, force? }\",\n choosePublicProfile: \"{ linkId, choice }\",\n preparePeerProof: \"{ linkId, externalKey, adapter? }\",\n submitPeerProof: \"{ linkId, challenge, event }\",\n withdrawPeerProof: \"{ linkId, adapter? }\",\n beginIdentityProof: \"{ provider, subject, validityDays? }\",\n completeIdentityProof: \"{ draftId, evidence }\",\n cancelIdentityProof: \"{ draftId }\",\n removeIdentityProof: \"{ id }\",\n shareIdentityProof: \"{ linkId, id }\",\n withdrawIdentityProof: \"{ linkId, id }\",\n recheckIdentityProof: \"{ linkId, id }\",\n lookupIdentityDisplay: \"{ linkId, id }\",\n loadPublicProfile: \"{ provider, subject, force? }\",\n loadPublicPosts: \"{ provider, subject, more?, force? }\",\n loadPublicGraph: \"{ provider, subject, force? }\",\n loadPublicPostImage: \"{ provider, subject, postId, index }\",\n clearProfileData: \"\",\n setDidListed: \"{ id, listed }\",\n nostrLoadContact: \"{ linkId, subject, what, more? }\",\n nostrForgetContact: \"{ linkId, subject }\",\n nostrLoadOwn: \"{ subject }\",\n nostrOwnFollows: \"{ subject }\",\n nostrContactNotes: \"{ linkId, subject }\",\n nostrLookup: \"NostrLookupRequest\",\n nostrDraft: \"NostrDraftRequest\",\n nostrPublish: \"{ draftId, event }\",\n createLink: \"\",\n takeInvite: \"\",\n joinLink: \"{ inviteCode }\",\n ensureLink: \"LinkParams & { inviteCode?: string }\",\n confirmPair: \"{ linkId, code }\",\n pollNow: \"{ linkId }\",\n removeLink: \"{ linkId }\",\n renameLink: \"{ linkId, label }\",\n setActiveLink: \"{ linkId }\",\n sendMessage: \"{ linkId, text, timestamp?, preview?, replyTo?, card? }\",\n editMessage: \"{ linkId, messageId, text, preview?, mentions?, card? }\",\n retryMessage: \"{ linkId, messageId }\",\n react: \"{ linkId, messageId, emoji }\",\n pinMessage: \"{ linkId, messageId?, remove? }\",\n appId: \"{ linkId, ref }\",\n appOpen: \"{ linkId, ref, version, digest? }\",\n appClose: \"{ linkId, ref }\",\n appSend: \"{ linkId, ref, data, digest? }\",\n appServe: \"{ linkId, ref, file, digest? }\",\n appUnserve: \"{ linkId, serve }\",\n appRangeAnswer: \"{ linkId, app, request, bytes?, size?, error? }\",\n appRemoteRead: \"{ linkId, ref, serve, offset, length, digest? }\",\n messageDetails: \"{ linkId, messageId }\",\n deleteMessage: \"{ linkId, messageId }\",\n removeMessage: \"{ linkId, messageId }\",\n exportLinks: \"\",\n sendFile: \"{ linkId, file, timestamp, replyTo?, forwarded? }\",\n sendGroupFile: \"{ groupId, file, caption?, replyTo?, forwarded? }\",\n groupFileCheck: \"{ groupId }\",\n forwardMessages: \"{ linkId, messageIds, to }\",\n fileAction: \"{ linkId, fileId, action }\",\n setDeliveryMode: \"{ linkId, mode }\",\n setTransportPreference: \"{ linkId, preferred, fallback }\",\n setChatTransport: \"{ linkId, transport }\",\n setChatPaymentMethods: \"{ linkId, methods, networks? }\",\n setChatHold: \"{ linkId, enabled }\",\n connect: \"{ linkId }\",\n walletAddMint: \"{ url, primary?, network? }\",\n walletCreate: \"WalletCreate\",\n walletRemove: \"WalletRemove\",\n walletTestCoins: \"WalletTestCoins\",\n walletSetupRetry: \"{ type }\",\n walletSetupDismiss: \"{ type }\",\n wake: \"{ network? }?\",\n peekProfile: \"{ profile, dbName }\",\n walletSetPrimaryMint: \"{ url }\",\n walletRemoveMint: \"{ url, acceptLoss? }\",\n walletReceiveLightning: \"{ amount, via?, network?, card? }\",\n walletWatchInvoice: \"{ invoice, network? }\",\n walletQuoteInvoice: \"{ invoice, via?, network?, card?, amount? }\",\n walletPayQuote: \"{ quote, mint, note?, confirmedReal?, linkId?, invoice? }\",\n lnurlResolve: \"{ text, network? }\",\n lnurlInvoice: \"{ id, amount, comment?, network? }\",\n checkPayment: \"{ linkId, paymentId }\",\n lightningSetSource: \"{ providerId, values, network?, card? }\",\n lightningClearSource: \"{ network?, card? }?\",\n lightningRetrySource: \"{ network?, card? }?\",\n lightningReconfigureSource: \"{ values, network?, card? }\",\n lightningRefresh: \"{ network?, card? }?\",\n lightningSetReceive: \"{ network, card }\",\n lightningRename: \"{ network, card, name }\",\n bitcoinSetSource: \"{ providerId, values, network? }\",\n bitcoinClearSource: \"{ network? }?\",\n bitcoinRetrySource: \"{ network? }?\",\n bitcoinReconfigureSource: \"{ values, network? }\",\n bitcoinReceiveAddress: \"{ network? }?\",\n bitcoinRefresh: \"{ network? }?\",\n walletReceiveToken: \"{ token }\",\n walletInspectCashu: \"{ text }\",\n walletExport: \"{ network? }?\",\n walletBackupReminder: \"{ event: \\\"later\\\"; wallet: string } | { event: \\\"profile\\\" }\",\n sendPayment: \"{ linkId, amount, memo?, timestamp, network?, confirmedReal? }\",\n requestPayment: \"{ linkId, amount, memo?, timestamp, method?, rail?, network?, card? }\",\n requestGroupPayment: \"{ groupId, amount, memo?, timestamp, rail, network?, card? }\",\n groupPaymentHello: \"{ groupId, member }\",\n askToPay: \"{ linkId, amount, method, memo?, timestamp, network? }\",\n payRequest: \"{ linkId, paymentId, via?, maxFee?, network?, confirmedReal?, card? }\",\n reclaimPayment: \"{ paymentId }\",\n disconnect: \"{ linkId }\",\n addService: \"{ name, target }\",\n removeService: \"{ serviceId }\",\n setServiceEnabled: \"{ serviceId, enabled }\",\n setServiceShared: \"{ serviceId, peerPubKeyZ32, shared }\",\n updateSettings: \"{ settings }\",\n setCallSignal: \"{ linkId, signal }\",\n callOfferHeld: \"{ linkId, ts }\",\n setTyping: \"{ linkId, typing, kind?, status? }\",\n setGroupTyping: \"{ groupId, typing, kind?, status? }\",\n setPresence: \"{ presence }\",\n setOwnStatus: \"{ status }\",\n clearOwnStatus: \"\",\n getOwnStatus: \"\",\n setWakeSubscription: \"{ subscription }\",\n wakeConfirm: \"{ endpoint }\",\n setWakeMuted: \"{ linkId, muted }\",\n setWakeOnline: \"{ on }\",\n wakeForCall: \"{ linkId }\",\n setCallOn: \"{ on }\",\n setFastPoll: \"{ linkId, fast }\",\n createGroup: \"{ name, profile? }\",\n inviteToGroup: \"{ groupId, linkId }\",\n acceptGroupInvitation: \"{ groupId }\",\n declineGroupInvitation: \"{ groupId }\",\n keepGroup: \"{ groupId }\",\n switchGroup: \"{ groupId, to }\",\n enableGroupLink: \"{ groupId, reset? }\",\n disableGroupLink: \"{ groupId }\",\n joinGroupByLink: \"{ link }\",\n sendGroupMessage: \"{ groupId, text, mentions?, replyTo?, card? }\",\n pressButton: \"{ linkId, messageId, buttonId }\",\n groupTaken: \"{ groupId, messageId, edit?, reaction?, pin? }\",\n chatUnconfirmed: \"{ linkId }\",\n groupMessages: \"{ groupId }\",\n messagePage: \"{ linkId, limit?, before?, after? }\",\n chatsFound: \"{ query, linkIds }\",\n statusCardIndex: \"\",\n saveMessage: \"{ linkId, messageId, remove? }\",\n savedMessages: \"\",\n leaveGroup: \"{ groupId }\",\n removeGroupMember: \"{ groupId, key }\",\n makeGroupAdmin: \"{ groupId, key }\",\n setGroupHub: \"{ groupId, key, role }\",\n rotateGroup: \"{ groupId }\",\n setGroupPicture: \"{ groupId, picture }\",\n renameGroup: \"{ groupId, name }\",\n setGroupCall: \"{ groupId, sfu, e2ee? }\",\n groupCallToken: \"{ groupId }\",\n groupCallKey: \"{ groupId }\",\n groupCallModerate: \"{ groupId, act, target?, src? }\",\n forgetGroup: \"{ groupId }\",\n setGroupManage: \"{ groupId, on }\",\n deviceEnrollInvite: \"{ name }\",\n deviceEnrollConfirm: \"{ match }\",\n deviceEnrollCancel: \"\",\n deviceEnrollView: \"\",\n deviceEnrollJoin: \"{ code, name, kind?, app? }\",\n deviceEnrollReady: \"\",\n deviceEnrollFinish: \"\",\n deviceEnrollRemove: \"\",\n deviceSet: \"\",\n devicePing: \"{ key }\",\n devicePushState: \"\",\n devicePushSet: \"{ subscription }\",\n deviceHandoffVerifier: \"{ password, current? }\",\n deviceHandoffPush: \"{ key }\",\n deviceHandoffPull: \"{ password, later? }\",\n deviceHandoffAccept: \"{ later? }\",\n deviceHandoffSettle: \"\",\n deviceHandoffCancel: \"\",\n deviceHandoffView: \"\",\n deviceHandoffAllow: \"{ key }\",\n deviceTakeoverInfo: \"\",\n deviceTakeover: \"{ password, name, lost? }\",\n deviceTurnPeek: \"{ d }\",\n deviceForkDiscard: \"{ database }\",\n deviceRestoreStartOwn: \"\",\n deviceRemove: \"{ key }\",\n deviceRename: \"{ key, name }\",\n deviceNewSecret: \"\",\n deviceSecretOfferDismiss: \"\",\n deviceTurnCheck: \"\",\n deviceSetNoticeSeen: \"{ wrong? }\",\n appList: \"\",\n appBuiltIns: \"\",\n appStoreList: \"\",\n appStorePreview: \"{ url }\",\n appStoreAdd: \"{ url, key? }\",\n appStoreRemove: \"{ key }\",\n appStoreRefresh: \"{ key? }?\",\n appPreview: \"AppSource\",\n appInstall: \"{ stage?, digest, grant, asks? }\",\n appUpdateAccept: \"{ ref, sequence?, added? }\",\n appCheckUpdates: \"\",\n appUninstall: \"{ ref }\",\n appRunCheck: \"{ ref }\",\n appFetchFiles: \"{ ref }\",\n appEntry: \"{ ref, runAnyway? }\",\n appFile: \"{ ref, path, digest? }\",\n appFileAt: \"{ ref, path, digest? }\",\n appStorageGet: \"{ ref, scope, key, digest? }\",\n appStorageSet: \"{ ref, scope, key, value, digest? }\",\n appStorageDelete: \"{ ref, scope, key, digest? }\",\n appStorageKeys: \"{ ref, scope, digest? }\",\n appDataExport: \"{ ref }\",\n appDataExportText: \"{ ref }\",\n};\n\n/**\n * The engine's calls the daemon passes through as `engine.<method>` (WISP 1100 § Local control API): exactly the\n * app's `EngineApi`, plus two reads every host has. Nothing else on the engine object is reachable.\n */\nexport const ENGINE_METHODS: readonly string[] = Object.keys(ENGINE_PARAMS);\n\n/** Reads the hosts use outside `EngineApi`: the whole state, and one chat's stored messages. */\nexport const ENGINE_READS: readonly string[] = [\"getState\", \"getMessages\"];\n\n/** What the two reads take, in `ENGINE_PARAMS`' words. */\nexport const READ_PARAMS: Readonly<Record<string, string>> = { getState: \"\", getMessages: \"{ linkId }\" };\n\n/**\n * Why `params` is not what `method` takes: missing when it takes some, or a key it needs not there (a key holding\n * null is there: `setActiveLink { linkId: null }`). Undefined when it is, or when the shape names a type, which is not\n * looked into here.\n */\nexport function engineParamsProblem(method: string, params: Record<string, unknown> | undefined): string | undefined {\n const takes = ENGINE_PARAMS[method] ?? READ_PARAMS[method];\n if (!takes) return undefined;\n if (params === undefined) return takes.endsWith(\"?\") ? undefined : \"no parameters given\";\n const keys = /^\\{ ([\\w?, ]*) \\}\\??$/.exec(takes)?.[1].split(\", \") ?? [];\n const missing = keys.filter((key) => !key.endsWith(\"?\") && params[key] === undefined);\n return missing.length ? `${missing.join(\", \")} missing` : undefined;\n}\n\n/**\n * Calls that delete what this device holds, by what they delete: they go only with `--yes` (`yes: true` over the\n * socket), as `chat remove`, `group leave` and `group forget` ask for it.\n */\nexport const DESTRUCTIVE_CALLS: ReadonlyMap<string, string> = new Map([\n [\"clearProfileData\", \"deletes every chat and group on this device (the wallets stay)\"],\n [\"removeLink\", \"deletes a chat's keys and history on this device\"],\n [\"leaveGroup\", \"deletes a group's history and files on this device\"],\n [\"forgetGroup\", \"deletes a group's history on this device\"],\n [\"switchGroup\", \"leaves the group held under this id and deletes its history on this device\"],\n [\"deviceRemove\", \"takes a device off this profile\"],\n]);\n\n/**\n * Calls whose answer holds a secret (chat seeds, wallet phrases and keys, ecash, backups): the CLI prints their\n * result only with `--show-secret`.\n */\nexport const SECRET_RESULTS: ReadonlySet<string> = new Set([\n \"exportLinks\", \"takeInvite\", \"walletExport\", \"usdtReveal\",\n \"arkBackup\", \"barkBackup\", \"sparkBackup\", \"fedimintBackup\",\n \"usdtExportBackup\", \"arkExportBackup\", \"barkExportBackup\", \"sparkExportBackup\", \"fedimintExportBackup\",\n \"fedimintSpendNotes\",\n]);\n\n/**\n * Calls whose answer holds one secret among what a script needs: the CLI prints it `<hidden>` unless `--show-secret`,\n * as `wallet receive` leaves it out. A Cashu mint quote's id is not locked to a key: whoever holds it can mint the\n * ecash its invoice pays for. A group call's pass (`token`) lets whoever holds it into the call as this member until\n * it expires, and the node's TURN servers come with their passwords, as `settings get` hides them. A group's call key\n * (`groupCallKey`) opens the group's sealed call media. `a[].b` is the `b` of each entry in the list `a`.\n */\nconst SECRET_FIELDS: Readonly<Record<string, readonly string[]>> = {\n walletReceiveLightning: [\"quote\"],\n groupCallToken: [\"token\", \"iceServers[].credential\"],\n groupCallKey: [\"key\"],\n};\n\nexport function hideSecretFields(method: string, result: unknown, showSecret = false): unknown {\n const fields = SECRET_FIELDS[method];\n if (!fields || showSecret || !result || typeof result !== \"object\") return result;\n const shown = { ...(result as Record<string, unknown>) };\n for (const field of fields) {\n const [list, inner] = field.split(\"[].\");\n if (inner === undefined) { if (shown[field] !== undefined) shown[field] = \"<hidden>\"; continue; }\n const entries = shown[list];\n if (Array.isArray(entries)) shown[list] = entries.map((entry: unknown) => entry && typeof entry === \"object\" && (entry as Record<string, unknown>)[inner] !== undefined ? { ...entry, [inner]: \"<hidden>\" } : entry);\n }\n return shown;\n}\n","import { createHash } from \"node:crypto\";\nimport { chatOrGroup, groupOf, node, type ApiContext, type Params } from \"./apiKit\";\n\n/**\n * The id an agent turn names its message by (docs/CLI.md § Agent turns). A message is stored under an id its sender\n * chose most of (`peer_<the id they sent>`), so a turn carries this one instead, made here from the chat (or group) and\n * that id: `t_` and 32 hex digits, in which nobody can write a word. Every command that takes a message's id takes it.\n */\nexport function turnRef(where: string, messageId: string): string {\n return \"t_\" + createHash(\"sha256\").update(`${where}\\n${messageId}`).digest(\"hex\").slice(0, 32);\n}\n\nconst TURN_REF = /^t_[0-9a-f]{32}$/;\nconst isRef = (value: unknown): value is string => typeof value === \"string\" && TURN_REF.test(value);\n\n/** How many turns' ids, older than the newest page, a profile's daemon keeps the answer for. */\nconst REMEMBERED = 1000;\n/**\n * Per node, `<chat or group>\\n<turn's id>` → the id its message is stored under, or null for none: what reading a whole\n * history found, so the reply, reaction and pin of one old turn read it once, and a turn whose message was deleted for\n * everyone (never stored again) once at all. Oldest asked first out.\n */\nconst remembered = new WeakMap<object, Map<string, string | null>>();\n\n/**\n * `params` with each turn's id in `message`, `reply`, `messages`, `before` and `after` as the id its message is stored\n * under: looked for among the chat's (or group's) newest messages first, where a turn's almost always is, then in what an\n * earlier read of all of them found, then in all of them. One that names no message stays as given, and its command says\n * so as for any unknown id. A timestamp in `before` or `after` is no turn's id and stays as it is.\n */\nexport async function withStoredIds(ctx: ApiContext, params: Params): Promise<Params> {\n const wanted = new Set([params.message, params.reply, params.before, params.after, ...(Array.isArray(params.messages) ? params.messages : [])].filter(isRef));\n if (!wanted.size) return params;\n let target: { id: string; linkId: string; group: boolean } | null = null;\n try {\n if (typeof params.group === \"string\") { const group = groupOf(ctx, { group: params.group }); target = { id: group.id, linkId: `group:${group.id}`, group: true }; }\n else if (typeof params.chat === \"string\") target = chatOrGroup(ctx, params.chat);\n } catch { /* the command says what is wrong with its chat or group */ }\n if (!target) return params;\n const { id, linkId, group } = target;\n const found = new Map<string, string>();\n const look = (messages: readonly { id: string }[]) => {\n for (const message of messages) { const ref = turnRef(id, message.id); if (wanted.has(ref)) found.set(ref, message.id); }\n return found.size === wanted.size;\n };\n if (!look((await node(ctx).messagePage({ linkId, limit: 200 })).messages)) {\n let known = remembered.get(node(ctx));\n if (!known) remembered.set(node(ctx), known = new Map());\n const unknown = new Set<string>();\n for (const ref of wanted) {\n if (found.has(ref)) continue;\n const key = `${id}\\n${ref}`, kept = known.get(key);\n if (kept === undefined) { unknown.add(ref); continue; }\n known.delete(key);\n // Deleted since: it names none now (and its refusal names the turn's id, not the one its sender chose).\n const now = kept !== null && await node(ctx).getMessage(linkId, kept) ? kept : null;\n known.set(key, now);\n if (now !== null) found.set(ref, now);\n }\n if (unknown.size) {\n look(group ? await node(ctx).groupMessages({ groupId: id }) : await node(ctx).getMessages(linkId));\n for (const ref of unknown) {\n known.set(`${id}\\n${ref}`, found.get(ref) ?? null);\n if (known.size > REMEMBERED) known.delete(known.keys().next().value!);\n }\n }\n }\n const stored = (value: unknown) => (isRef(value) ? found.get(value) ?? value : value);\n return {\n ...params,\n ...(params.message !== undefined && { message: stored(params.message) }),\n ...(params.reply !== undefined && { reply: stored(params.reply) }),\n ...(params.before !== undefined && { before: stored(params.before) }),\n ...(params.after !== undefined && { after: stored(params.after) }),\n ...(Array.isArray(params.messages) && { messages: params.messages.map(stored) }),\n };\n}\n","import type { PairedTransport } from \"@ghostly/core\";\n\n/**\n * The words an argument takes, for the API's methods and the command table both: the command line refuses any other\n * before the profile opens (`commands/index.ts` positionals), and the socket keeps its own refusal for its callers.\n * Its own module, with no code from the package: the command table is read by every command.\n */\n\nexport const WALLET_TYPES = [\"cashu\", \"lightning\", \"arkade\", \"bark\", \"spark\", \"bitcoin\", \"fedimint\", \"usdt\"] as const;\n/** The wallets that have an address to be paid on (`wallet address`). */\nexport const ADDRESS_TYPES = [\"bitcoin\", \"arkade\", \"spark\", \"usdt\"] as const;\n/** What a payment request may name as its way of paying (`chat request --method`). */\nexport const PAY_METHODS = [\"cashu\", \"arkade\", \"usdt\", \"bark\", \"bitcoin\", \"fedimint\", \"spark\"] as const;\n/** The ways of paying a chat takes (`chat accept`). */\nexport const CHAT_METHODS = [\"cashu\", \"lightning\", ...PAY_METHODS.filter((m) => m !== \"cashu\")] as const;\n\n/** A chat's transport by the name the command line gives it (`chat transport`). */\nexport const TRANSPORT_NAMES: Record<string, PairedTransport | \"auto\" | \"dht\"> = {\n auto: \"auto\", dht: \"dht\", webrtc: \"webrtc/1\", iroh: \"iroh/1\", hyperdht: \"hyperdht/1\",\n \"webrtc/1\": \"webrtc/1\", \"iroh/1\": \"iroh/1\", \"hyperdht/1\": \"hyperdht/1\",\n};\n","import { reactionEmoji, sanitizeDisplayText, sanitizeStatusText, STATUS_AVAILABILITIES, STATUS_TEXT_MAX, type PersonStatus, type StatusAvailability } from \"@ghostly/core\";\nimport { STATUS_CARD_LIMITS } from \"@ghostly/core/statusCards\";\nimport { CliError, type ErrorCode } from \"./errors\";\n\n/**\n * This profile's status (WISP 401 § Presence and status): a text, one emoji, an availability and when it ends, said to\n * every paired contact whose app offers `status/1`: `status set|clear|show`, and the socket's `status.set|clear|get`.\n * These never say presence (active or idle): only a daemon does, and only with `settings set daemonPresence true`\n * (daemonPresence.ts); otherwise a headless profile never reads as online.\n */\n\n/** What `status set` was given, before it is checked. */\nexport interface StatusInput { text?: string; emoji?: string; availability?: string; until?: number }\n\n/**\n * The status as the engine keeps it (`personStatus`), checked first: the engine drops a field that does not hold\n * without a word (a long text cut, a word that is not one emoji left out, an end already past clearing the whole\n * status), so here each is refused instead, named by `name` (the command's option, or the socket's parameter).\n */\nexport function checkOwnStatus(input: StatusInput, name: (field: keyof StatusInput) => string, code: ErrorCode, now = Date.now()): PersonStatus {\n const fail = (field: keyof StatusInput, rule: string) => new CliError(code, `${name(field)} ${rule}`);\n const status: PersonStatus = {};\n if (input.availability !== undefined) {\n if (!(STATUS_AVAILABILITIES as readonly string[]).includes(input.availability)) throw fail(\"availability\", `takes ${STATUS_AVAILABILITIES.join(\", \")}, not ${JSON.stringify(input.availability)}`);\n status.availability = input.availability as StatusAvailability;\n }\n if (input.emoji !== undefined) {\n const emoji = reactionEmoji(input.emoji);\n if (!emoji) throw fail(\"emoji\", `takes one emoji, not ${JSON.stringify(input.emoji)}`);\n status.emoji = emoji;\n }\n // One line, as contacts see it: a line break or a run of spaces is one space; invisible characters are not counted.\n const oneLine = input.text?.replace(/\\s+/g, \" \").trim();\n if (oneLine) {\n const shown = sanitizeDisplayText(oneLine, Infinity) ?? \"\";\n const length = [...shown].length;\n if (length > STATUS_TEXT_MAX) throw fail(\"text\", `is up to ${STATUS_TEXT_MAX} characters, not ${length} characters`);\n if (!shown) throw fail(\"text\", \"needs a character that shows\");\n // The text as counted: the raw one could lose characters that fit to the engine's cut of invisible padding.\n const text = sanitizeStatusText(shown);\n if (!text) throw fail(\"text\", \"is plain text: no link or markup\");\n status.text = text;\n }\n if (!status.text && !status.emoji && !status.availability) {\n throw new CliError(code, `Nothing to set: give a ${name(\"text\")}, ${name(\"emoji\")} or ${name(\"availability\")}`);\n }\n if (input.until !== undefined) {\n if (!Number.isSafeInteger(input.until) || input.until <= now) throw fail(\"until\", \"is a time to come: a status that ended is none\");\n // As the command line's --until, so the socket cannot keep an end past the last time a Date holds.\n if (input.until > now + STATUS_CARD_LIMITS.nextRunMs) throw fail(\"until\", \"is a time within a year from now\");\n status.until = input.until;\n }\n return status;\n}\n\n/** What `status set|clear|show` answer: the status with every field (null when not set), or null when there is none. */\nexport function statusJson(status: PersonStatus | undefined): { status: { text: string | null; emoji: string | null; availability: StatusAvailability | null; until: number | null } | null } {\n return { status: status ? { text: status.text ?? null, emoji: status.emoji ?? null, availability: status.availability ?? null, until: status.until ?? null } : null };\n}\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,gBAAkD;CAC7D,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CACb,kBAAkB;CAClB,mBAAmB;CACnB,WAAW;CACX,WAAW;CACX,SAAS;CACT,WAAW;CACX,iBAAiB;CACjB,kBAAkB;CAClB,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,kBAAkB;CAClB,mBAAmB;CACnB,aAAa;CACb,WAAW;CACX,iBAAiB;CACjB,cAAc;CACd,eAAe;CACf,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,iBAAiB;CACjB,kBAAkB;CAClB,gBAAgB;CAChB,sBAAsB;CACtB,uBAAuB;CACvB,uBAAuB;CACvB,aAAa;CACb,aAAa;CACb,mBAAmB;CACnB,oBAAoB;CACpB,cAAc;CACd,sBAAsB;CACtB,gBAAgB;CAChB,gBAAgB;CAChB,kBAAkB;CAClB,eAAe;CACf,uBAAuB;CACvB,qBAAqB;CACrB,kBAAkB;CAClB,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,uBAAuB;CACvB,qBAAqB;CACrB,qBAAqB;CACrB,oBAAoB;CACpB,uBAAuB;CACvB,sBAAsB;CACtB,uBAAuB;CACvB,mBAAmB;CACnB,iBAAiB;CACjB,iBAAiB;CACjB,qBAAqB;CACrB,kBAAkB;CAClB,cAAc;CACd,kBAAkB;CAClB,oBAAoB;CACpB,cAAc;CACd,iBAAiB;CACjB,mBAAmB;CACnB,aAAa;CACb,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,YAAY;CACZ,eAAe;CACf,aAAa;CACb,aAAa;CACb,cAAc;CACd,OAAO;CACP,YAAY;CACZ,OAAO;CACP,SAA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2
2
  import { t as childEnv } from "./childEnv-C-99hdbL.js";
3
3
  import { t as CliError } from "./errors-DDLFO4Gf.js";
4
4
  import { execFileSync } from "node:child_process";
@@ -539,4 +539,4 @@ function holder(file, lock) {
539
539
  }
540
540
  export { ownFolder as C, runtimePath as D, privateFolder as E, userPath as S, ownSocket as T, profileExists as _, checkShownName as a, startingDaemon as b, createProfile as c, daemonClaim as d, ghostlyHome as f, noProfile as g, lockPath as h, checkProfileName as i, currentProfile as l, lockOwner as m, RESTORED_MARK as n, checkShownNameOption as o, listProfiles as p, acquireLock as r, claimForDaemon as s, DEFAULT_PROFILE as t, currentProfileOrNone as u, profilePaths as v, ownProfile as w, startingPath as x, selectProfile as y };
541
541
 
542
- //# sourceMappingURL=profiles-BFSGqDFC.js.map
542
+ //# sourceMappingURL=profiles-B8xO8-oj.js.map