@ghostlytools/cli 1.13.1 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -12
- package/dist/assets/api-DO0YMLiB.js +3 -0
- package/dist/assets/{api-Dnq86JAA.js → api-Dz2cw7WD.js} +512 -103
- package/dist/assets/api-Dz2cw7WD.js.map +1 -0
- package/dist/assets/{apiKit-nLK4jeTq.js → apiKit-DAFsWtyk.js} +53 -7
- package/dist/assets/apiKit-DAFsWtyk.js.map +1 -0
- package/dist/assets/{appFetch-wqBWi3Ry.js → appFetch-BQO5Pk7W.js} +2 -2
- package/dist/assets/{appFetch-wqBWi3Ry.js.map → appFetch-BQO5Pk7W.js.map} +1 -1
- package/dist/assets/{apps-DBVhKpfe.js → apps-B88rYWRm.js} +51 -23
- package/dist/assets/apps-B88rYWRm.js.map +1 -0
- package/dist/assets/{apps-nLtyhC2f.js → apps-D4KRpZB4.js} +1 -1
- package/dist/assets/{arkade-DryM-q5n.js → arkade-B6UNf5HI.js} +2 -2
- package/dist/assets/{arkade-DryM-q5n.js.map → arkade-B6UNf5HI.js.map} +1 -1
- package/dist/assets/{backup-D6s0LQdg.js → backup-BeXBtbVL.js} +1 -1
- package/dist/assets/{backup-Bczllmzf.js → backup-CNLY905d.js} +15 -8
- package/dist/assets/backup-CNLY905d.js.map +1 -0
- package/dist/assets/bark_ffi_wasm_bg-CjjCN3FD.js +5 -0
- package/dist/assets/{bitcoind-DML_-Xbv.js → bitcoind-BXZdQ1wZ.js} +2 -2
- package/dist/assets/{bitcoind-DML_-Xbv.js.map → bitcoind-BXZdQ1wZ.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-D6IFIaJi.js +5 -0
- package/dist/assets/{buttons-B3C3vdhH.js → buttons-BKojbx0Q.js} +4 -4
- package/dist/assets/{buttons-B3C3vdhH.js.map → buttons-BKojbx0Q.js.map} +1 -1
- package/dist/assets/buttons-_5Fw8uHn.js +1 -0
- package/dist/assets/{client-B7jRrSnb.js → client-BtPhfWjK.js} +2 -2
- package/dist/assets/{client-B7jRrSnb.js.map → client-BtPhfWjK.js.map} +1 -1
- package/dist/assets/{engineErrors--9hfgKlK.js → engineErrors-wWlLy54D.js} +11 -3
- package/dist/assets/engineErrors-wWlLy54D.js.map +1 -0
- package/dist/assets/{fedimintSdk-D-6H9Pe7.js → fedimintSdk-eLXBrj9i.js} +2 -2
- package/dist/assets/{fedimintSdk-D-6H9Pe7.js.map → fedimintSdk-eLXBrj9i.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-CRQlnJdu.js +5 -0
- package/dist/assets/{fixedHosts-H3i6o9Iy.js → fixedHosts-BJFL8Ell.js} +3 -3
- package/dist/assets/{fixedHosts-H3i6o9Iy.js.map → fixedHosts-BJFL8Ell.js.map} +1 -1
- package/dist/assets/{groupMeta--fxSh792.js → groupMeta-Cz95F6sX.js} +201 -43
- package/dist/assets/groupMeta-Cz95F6sX.js.map +1 -0
- package/dist/assets/{host-CGzVFfMz.js → host-BsBWxTtW.js} +276 -53
- package/dist/assets/host-BsBWxTtW.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js → hyperdhtRelay-B34Zhz4P.js} +2 -2
- package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js.map → hyperdhtRelay-B34Zhz4P.js.map} +1 -1
- package/dist/assets/{hyperdhtRelay-B4_wdCtx.js → hyperdhtRelay-DDwU5b4P.js} +2 -2
- package/dist/assets/{hyperdhtRelay-B4_wdCtx.js.map → hyperdhtRelay-DDwU5b4P.js.map} +1 -1
- package/dist/assets/{identityProofs-Cksc_K7_.js → identityProofs-zI_Iy9uI.js} +154 -27
- package/dist/assets/identityProofs-zI_Iy9uI.js.map +1 -0
- package/dist/assets/{irohWeb-Dp1i8v6n.js → irohWeb-BLDcHwYz.js} +10866 -4829
- package/dist/assets/irohWeb-BLDcHwYz.js.map +1 -0
- package/dist/assets/{linkPreview-DdMf-YAc.js → linkPreview-5kHmKUTN.js} +20 -8
- package/dist/assets/linkPreview-5kHmKUTN.js.map +1 -0
- package/dist/assets/{main-C8J53SwH.js → main-D48Ben7C.js} +122 -49
- package/dist/assets/main-D48Ben7C.js.map +1 -0
- package/dist/assets/{mainline-DY95WbuK.js → mainline-CDUXtV-I.js} +2 -2
- package/dist/assets/{mainline-DY95WbuK.js.map → mainline-CDUXtV-I.js.map} +1 -1
- package/dist/assets/{networkReason-Be-hMghr.js → networkReason-DYlPZS5M.js} +2 -2
- package/dist/assets/{networkReason-Be-hMghr.js.map → networkReason-DYlPZS5M.js.map} +1 -1
- package/dist/assets/{ownDid-oa-T2vmZ.js → ownDid-CwxFBzOH.js} +6 -5
- package/dist/assets/ownDid-CwxFBzOH.js.map +1 -0
- package/dist/assets/{ownStatus-Bc08eNJY.js → ownStatus-DjD0sQKF.js} +34 -11
- package/dist/assets/ownStatus-DjD0sQKF.js.map +1 -0
- package/dist/assets/{pairedTransports-Dppn8lUN.js → pairedTransports-DAzupLYo.js} +21 -15
- package/dist/assets/pairedTransports-DAzupLYo.js.map +1 -0
- package/dist/assets/{paymentIntent-DySU3Ajm.js → paymentIntent-Cr3uZa_0.js} +2 -2
- package/dist/assets/{paymentIntent-DySU3Ajm.js.map → paymentIntent-Cr3uZa_0.js.map} +1 -1
- package/dist/assets/{profiles-B2uy04ph.js → profiles-BAJf0c9E.js} +33 -8
- package/dist/assets/profiles-BAJf0c9E.js.map +1 -0
- package/dist/assets/{registry-bLIfG619.js → registry-CHwHTWbK.js} +1 -1
- package/dist/assets/{registry-DbTLLs3y.js → registry-CPuexTle.js} +25 -13
- package/dist/assets/registry-CPuexTle.js.map +1 -0
- package/dist/assets/{relay-CHWg5hpZ.js → relay-gJTOYQJZ.js} +93 -7
- package/dist/assets/relay-gJTOYQJZ.js.map +1 -0
- package/dist/assets/{resolve-DNX-eecG.js → resolve-BqmGXKn4.js} +3 -3
- package/dist/assets/{resolve-DNX-eecG.js.map → resolve-BqmGXKn4.js.map} +1 -1
- package/dist/assets/{server-DWJ4RzJn.js → server-e4oKeNez.js} +901 -6262
- package/dist/assets/server-e4oKeNez.js.map +1 -0
- package/dist/assets/{sshForges-BnvwmNj-.js → sshForges-Cqt3qfWe.js} +2 -2
- package/dist/assets/{sshForges-BnvwmNj-.js.map → sshForges-Cqt3qfWe.js.map} +1 -1
- package/dist/assets/{translate-CHj_PdLg.js → translate-DnuQMfj0.js} +10 -4
- package/dist/assets/translate-DnuQMfj0.js.map +1 -0
- package/dist/assets/{usdt-CBJ4Q5Ji.js → usdt-DLmtf8F9.js} +4 -4
- package/dist/assets/{usdt-CBJ4Q5Ji.js.map → usdt-DLmtf8F9.js.map} +1 -1
- package/dist/assets/{waitNotice-Cvz5CiKR.js → waitNotice-mB0Ym145.js} +2 -2
- package/dist/assets/{waitNotice-Cvz5CiKR.js.map → waitNotice-mB0Ym145.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-DF36rBJK.js +0 -3
- package/dist/assets/api-Dnq86JAA.js.map +0 -1
- package/dist/assets/apiKit-nLK4jeTq.js.map +0 -1
- package/dist/assets/apps-DBVhKpfe.js.map +0 -1
- package/dist/assets/backup-Bczllmzf.js.map +0 -1
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +0 -5
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +0 -1
- package/dist/assets/bark_ffi_wasm_bg-VNmaJsc9.wasm +0 -0
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +0 -5
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +0 -1
- package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
- package/dist/assets/buttons-DaY5FYlV.js +0 -1
- package/dist/assets/engineErrors--9hfgKlK.js.map +0 -1
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +0 -5
- package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js.map +0 -1
- package/dist/assets/fedimint_client_wasm_bg-DeFtkIv6.wasm +0 -0
- package/dist/assets/groupMeta--fxSh792.js.map +0 -1
- package/dist/assets/host-CGzVFfMz.js.map +0 -1
- package/dist/assets/identityProofs-Cksc_K7_.js.map +0 -1
- package/dist/assets/irohWeb-Dp1i8v6n.js.map +0 -1
- package/dist/assets/linkPreview-DdMf-YAc.js.map +0 -1
- package/dist/assets/main-C8J53SwH.js.map +0 -1
- package/dist/assets/ownDid-oa-T2vmZ.js.map +0 -1
- package/dist/assets/ownStatus-Bc08eNJY.js.map +0 -1
- package/dist/assets/pairedTransports-Dppn8lUN.js.map +0 -1
- package/dist/assets/profiles-B2uy04ph.js.map +0 -1
- package/dist/assets/registry-DbTLLs3y.js.map +0 -1
- package/dist/assets/relay-CHWg5hpZ.js.map +0 -1
- package/dist/assets/server-DWJ4RzJn.js.map +0 -1
- package/dist/assets/translate-CHj_PdLg.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentIntent-DySU3Ajm.js","names":[],"sources":["../../../core/src/payments.ts","../../../core/src/bitcoinAddress.ts","../../../core/src/sparkAddress.ts","../../../core/src/paymentIntent.ts"],"sourcesContent":["import type { WireEndpoint } from \"./frames\";\n\n/**\n * Payments between two linked peers. Ghostly does not move money itself: it\n * carries payment requests, in-band payments such as ecash tokens, and\n * receipts over the data link, and a platform wallet executes them.\n *\n * Vocabulary and identifiers follow Pubky's Paykit so that publishing the same\n * endpoints through Paykit later is a change of transport, not of model:\n * an endpoint is an identifier plus a payload, an amount is decimal text plus\n * an asset.\n */\nexport const ENDPOINT = {\n /** Payload: a BOLT11 invoice. */\n bolt11: \"btc-lightning-bolt11\",\n /**\n * Payload in a request: JSON `{ \"mints\": [\"https://…\"] }`, the mints the\n * payee accepts ecash from. Payload in a payment: a `cashuB…` token.\n */\n cashu: \"cashu\",\n arkade: \"btc-arkade/1\",\n /** Second's Ark (Bark). Payload in a request: a payment target; in a payment: a receipt hint. */\n bark: \"btc-bark/1\",\n usdt: \"usdt-erc20/1\",\n /** On-chain Bitcoin. Payload in a request: a payment target (a fresh address); in a payment: a receipt hint `{ txid }`. */\n bitcoin: \"btc-onchain/1\",\n /**\n * Fedimint ecash. Payload in a request: JSON `{ \"federations\": [\"<federation id>\", …] }`, the federations the\n * payee has joined and takes ecash from. Payload in a payment: the notes themselves (out-of-band notes, a\n * bearer string only the federation that issued them redeems).\n */\n fedimint: \"fedimint-ecash/1\",\n /**\n * Spark, wallet to wallet. Payload in a request: a payment target whose address is a Spark invoice made for\n * that request; in a payment: a receipt hint `{ id }` (the payer's transfer id).\n */\n spark: \"btc-spark/1\",\n} as const;\n\nexport interface PaymentAmount {\n /** Decimal text; whole numbers for `sat`. */\n value: string;\n asset: string;\n}\n\nexport interface PaymentRequest {\n id: string;\n timestamp: number;\n amount: PaymentAmount;\n memo?: string;\n endpoints: WireEndpoint[];\n /** The ask this request answers, when the contact asked to pay (see {@link PaymentAsk}). */\n ask?: string;\n /** Real money or test coins: only a wallet of this network pays it. Absent from older apps. */\n network?: \"mainnet\" | \"testnet\";\n}\n\n/**\n * \"I want to pay you this much this way\": sent by a payer who has no address to pay to (Ark, USDT).\n * The payee's app answers with an ordinary payment request carrying `ask`, which the payer\n * then reviews and approves like any other.\n */\nexport interface PaymentAsk {\n id: string;\n timestamp: number;\n amount: PaymentAmount;\n method: \"arkade\" | \"usdt\" | \"bark\" | \"bitcoin\" | \"fedimint\" | \"spark\";\n memo?: string;\n /** The network the payer pays from. Absent from older apps. */\n network?: \"mainnet\" | \"testnet\";\n}\n\nexport interface Payment {\n id: string;\n timestamp: number;\n requestId?: string;\n amount: PaymentAmount;\n memo?: string;\n endpoint: WireEndpoint;\n}\n\nexport interface PaymentResult {\n /** Id of the payment or request this is about. */\n id: string;\n ok: boolean;\n /** Amount credited when it differs from the amount sent. */\n credited?: string;\n error?: string;\n /**\n * On a request (`ok` false): its payee closed it for good, and a payment made to it now is lost. Only the payee of a\n * request says it; the payer stops offering to pay it.\n */\n closed?: boolean;\n}\n\nexport function cashuRequestPayload(mints: string[]): string {\n return JSON.stringify({ mints });\n}\n\n/** Mints named by a `cashu` endpoint of a request. Anything malformed yields none. */\nexport function parseCashuRequestPayload(payload: string): string[] {\n try {\n const { mints } = JSON.parse(payload) as { mints?: unknown };\n if (!Array.isArray(mints)) return [];\n return mints.filter((m): m is string => typeof m === \"string\" && /^https?:\\/\\//.test(m)).slice(0, 8);\n } catch {\n return [];\n }\n}\n\n/** A Fedimint federation id: 32 bytes, lowercase hex. */\nexport const isFederationId = (value: unknown): value is string => typeof value === \"string\" && /^[0-9a-f]{64}$/.test(value);\n\nexport function fedimintRequestPayload(federations: string[]): string {\n return JSON.stringify({ federations });\n}\n\n/** Federations named by a `fedimint-ecash/1` endpoint of a request. Anything malformed yields none. */\nexport function parseFedimintRequestPayload(payload: string): string[] {\n try {\n const { federations } = JSON.parse(payload) as { federations?: unknown };\n if (!Array.isArray(federations)) return [];\n return [...new Set(federations.filter(isFederationId))].slice(0, 8);\n } catch {\n return [];\n }\n}\n\nexport function findEndpoint(endpoints: WireEndpoint[], identifier: string): string | undefined {\n return endpoints.find(([id]) => id === identifier)?.[1];\n}\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bech32, bech32m, createBase58check } from \"@scure/base\";\n\n/** The Bitcoin networks an on-chain wallet can be on. Only `bitcoin` is real money. */\nexport type BitcoinNetwork = \"bitcoin\" | \"signet\" | \"testnet\" | \"regtest\" | \"mutinynet\";\nexport const BITCOIN_NETWORKS: readonly BitcoinNetwork[] = [\"bitcoin\", \"signet\", \"testnet\", \"regtest\", \"mutinynet\"];\n\n/** Mutinynet is a signet: it shares signet's (and testnet's) address prefixes. */\nconst SEGWIT_HRP: Record<BitcoinNetwork, string> = { bitcoin: \"bc\", signet: \"tb\", testnet: \"tb\", mutinynet: \"tb\", regtest: \"bcrt\" };\nconst BASE58_VERSIONS: Record<BitcoinNetwork, readonly number[]> = { bitcoin: [0x00, 0x05], signet: [0x6f, 0xc4], testnet: [0x6f, 0xc4], mutinynet: [0x6f, 0xc4], regtest: [0x6f, 0xc4] };\nconst base58check = createBase58check(sha256);\n\nfunction segwit(address: string, hrp: string): boolean {\n // BIP 173: one case only. The checksum is over the lower-case form.\n if (address !== address.toLowerCase() && address !== address.toUpperCase()) return false;\n const lower = address.toLowerCase();\n if (!lower.startsWith(`${hrp}1`) || lower.length > 90) return false;\n // Version 0 is bech32 (BIP 173), every later version bech32m (BIP 350); the wrong one is refused.\n for (const [coder, v0] of [[bech32, true], [bech32m, false]] as const) {\n let decoded: { prefix: string; words: number[] };\n try { decoded = coder.decode(lower as `${string}1${string}`, 90); } catch { continue; }\n if (decoded.prefix !== hrp || decoded.words.length < 1) return false;\n const version = decoded.words[0];\n if (version > 16 || (version === 0) !== v0) return false;\n let program: Uint8Array;\n try { program = coder.fromWords(decoded.words.slice(1)); } catch { return false; }\n if (version === 0) return program.length === 20 || program.length === 32;\n return program.length >= 2 && program.length <= 40;\n }\n return false;\n}\n\n/** Whether `address` is a valid address on `network`: checksums, witness versions, lengths and prefixes. */\nexport function isBitcoinAddress(address: unknown, network: BitcoinNetwork): boolean {\n if (typeof address !== \"string\" || !BITCOIN_NETWORKS.includes(network) || address.length < 14 || address.length > 90) return false;\n if (segwit(address, SEGWIT_HRP[network])) return true;\n let payload: Uint8Array;\n try { payload = base58check.decode(address); } catch { return false; }\n return payload.length === 21 && BASE58_VERSIONS[network].includes(payload[0]);\n}\n","import { bech32m } from \"@scure/base\";\n\n/**\n * Spark (https://spark.money): a Bitcoin layer 2 where a transfer between two Spark wallets is instant and\n * off-chain. Ghostly's Spark wallets run on Bitcoin (real sats, Breez API key) or on regtest (Breez and\n * Lightspark's hosted test network, worthless sats). Spark's own testnet and signet are not offered by the\n * Breez SDK, so they are not payment networks here.\n */\nexport type SparkNetwork = \"bitcoin\" | \"regtest\";\nexport const SPARK_NETWORKS: readonly SparkNetwork[] = [\"bitcoin\", \"regtest\"];\n/**\n * The `provider` of a Spark target. Spark is one network per chain (its operators are the same for every\n * wallet), so any Spark wallet on the same network pays any Spark address: the payee names no service.\n */\nexport const SPARK_PROVIDER = \"spark\";\n\nconst HRP: Record<SparkNetwork, string> = { bitcoin: \"spark\", regtest: \"sparkrt\" };\n/** Long enough for an invoice with a 140-character memo and its signature. */\nconst MAX_LENGTH = 1024;\n\n/**\n * What a Spark string is on `network`: a wallet's `address` (its identity key, the same every time) or an\n * `invoice` (an address plus an amount, an expiry, a memo and a unique id, signed by the payee). Undefined\n * when it is neither, or belongs to another network. Structure only: the wallet's SDK checks the rest.\n */\nexport function sparkAddressKind(address: unknown, network: SparkNetwork): \"address\" | \"invoice\" | undefined {\n if (typeof address !== \"string\" || !SPARK_NETWORKS.includes(network) || address.length > MAX_LENGTH) return undefined;\n // One case only, and Spark writes lower case.\n if (address !== address.toLowerCase() || !address.startsWith(`${HRP[network]}1`)) return undefined;\n let payload: Uint8Array;\n try {\n const decoded = bech32m.decode(address as `${string}1${string}`, MAX_LENGTH);\n if (decoded.prefix !== HRP[network]) return undefined;\n payload = bech32m.fromWords(decoded.words);\n } catch { return undefined; }\n // Protobuf: field 1, 33 bytes, a compressed public key (the wallet's identity).\n if (payload.length < 35 || payload[0] !== 0x0a || payload[1] !== 0x21 || (payload[2] !== 0x02 && payload[2] !== 0x03)) return undefined;\n if (payload.length === 35) return \"address\";\n // Field 2: the invoice's fields. Anything else after the key is not a Spark string Ghostly knows.\n return payload[35] === 0x12 ? \"invoice\" : undefined;\n}\n\nexport const isSparkAddress = (address: unknown, network: SparkNetwork): boolean => sparkAddressKind(address, network) !== undefined;\n\n/** The Spark network a string belongs to, from its prefix alone (`spark1…` Bitcoin, `sparkrt1…` regtest). */\nexport function sparkNetworkOf(address: string): SparkNetwork | undefined {\n return SPARK_NETWORKS.find((network) => sparkAddressKind(address, network) !== undefined);\n}\n\n/** What a Spark invoice asks for, read from the invoice itself (the payer's wallet checks it again). */\nexport interface SparkInvoiceDetails {\n /** Sats asked; absent when the payer chooses. */\n amount?: number;\n memo?: string;\n /** Milliseconds. */\n expiresAt?: number;\n /** An invoice for a token (not sats): Ghostly does not pay those. */\n token: boolean;\n}\n\n/** Protobuf, just enough of it: `[field, wire type, value]` of each field of a message, or undefined when malformed. */\nfunction fields(bytes: Uint8Array): [number, number, Uint8Array | bigint][] | undefined {\n const out: [number, number, Uint8Array | bigint][] = [];\n let at = 0;\n const varint = (): bigint | undefined => {\n let value = 0n, shift = 0n;\n for (let i = 0; i < 10; i++) {\n if (at >= bytes.length) return undefined;\n const b = bytes[at++];\n value |= BigInt(b & 0x7f) << shift;\n if (!(b & 0x80)) return value;\n shift += 7n;\n }\n return undefined;\n };\n while (at < bytes.length) {\n const key = varint();\n if (key === undefined) return undefined;\n const field = Number(key >> 3n), wire = Number(key & 7n);\n if (wire === 0) { const v = varint(); if (v === undefined) return undefined; out.push([field, wire, v]); }\n else if (wire === 2) {\n const length = varint();\n if (length === undefined || at + Number(length) > bytes.length) return undefined;\n out.push([field, wire, bytes.slice(at, at + Number(length))]); at += Number(length);\n } else return undefined;\n }\n return out;\n}\n\n/**\n * The amount, memo and expiry a Spark invoice carries (SparkInvoiceFields: 4 sats payment, 3 tokens payment, 5 memo,\n * 7 expiry time), or undefined when `invoice` is not an invoice of `network`.\n */\nexport function sparkInvoiceDetails(invoice: string, network: SparkNetwork): SparkInvoiceDetails | undefined {\n if (sparkAddressKind(invoice, network) !== \"invoice\") return undefined;\n const top = fields(bech32m.fromWords(bech32m.decode(invoice as `${string}1${string}`, MAX_LENGTH).words));\n const body = top?.find(([field, wire]) => field === 2 && wire === 2)?.[2];\n const inner = body instanceof Uint8Array ? fields(body) : undefined;\n if (!inner) return undefined;\n const details: SparkInvoiceDetails = { token: false };\n for (const [field, wire, value] of inner) {\n if (wire !== 2 || !(value instanceof Uint8Array)) continue;\n if (field === 3) details.token = true;\n else if (field === 4) {\n const amount = fields(value)?.find(([f, w]) => f === 1 && w === 0)?.[2];\n if (typeof amount === \"bigint\") { if (amount > BigInt(Number.MAX_SAFE_INTEGER)) return undefined; details.amount = Number(amount); }\n } else if (field === 5) details.memo = new TextDecoder().decode(value).slice(0, 140);\n else if (field === 7) {\n const seconds = fields(value)?.find(([f, w]) => f === 1 && w === 0)?.[2];\n if (typeof seconds === \"bigint\" && seconds < 1n << 40n) details.expiresAt = Number(seconds) * 1000;\n }\n }\n return details;\n}\n","import { BITCOIN_NETWORKS, isBitcoinAddress, type BitcoinNetwork } from \"./bitcoinAddress\";\nimport { engineError } from \"./engineErrors\";\nimport { isFederationId } from \"./payments\";\nimport { SPARK_NETWORKS, SPARK_PROVIDER, isSparkAddress, type SparkNetwork } from \"./sparkAddress\";\n\n/** Local wallet contract. Capability support is never authorization to spend. */\nexport type PaymentMethod = \"cashu\" | \"arkade\" | \"usdt\" | \"bark\" | \"bitcoin\" | \"fedimint\" | \"spark\";\nexport type PaymentNetwork = \"bitcoin\" | \"signet\" | \"testnet\" | \"mutinynet\" | \"regtest\" | \"cashu-test\" | \"ethereum\" | \"sepolia\" | \"evm-local\";\n/**\n * Real money, or test coins: what every wallet is, whatever chain it runs on. A payment never crosses from one\n * to the other: a test wallet never settles a request for real money, nor the reverse.\n */\nexport type WalletNetwork = \"mainnet\" | \"testnet\";\nexport const WALLET_NETWORKS: readonly WalletNetwork[] = [\"mainnet\", \"testnet\"];\n/** Bitcoin and Ethereum carry real money; every other chain of a payment target is a test network. */\nexport const walletNetworkOf = (network: PaymentNetwork | string): WalletNetwork => network === \"bitcoin\" || network === \"ethereum\" ? \"mainnet\" : \"testnet\";\nexport const isWalletNetwork = (value: unknown): value is WalletNetwork => value === \"mainnet\" || value === \"testnet\";\n/**\n * The `provider` of an on-chain target. Anyone can pay a Bitcoin address from any wallet, so the payee\n * names no service; which wallet pays is the payer's own choice (its active on-chain source).\n */\nexport const ONCHAIN_PROVIDER = \"onchain\";\nexport type IntentState = \"pending\" | \"submitted\" | \"settled\" | \"failed\" | \"unknown\" | \"cancelled\";\nexport interface PaymentTarget {\n method: PaymentMethod;\n network: PaymentNetwork;\n provider: string;\n asset: \"BTC\" | \"USDT\" | \"TEST-USDT\";\n unit: \"sat\" | \"token-base\";\n chainId?: number;\n token?: string;\n decimals?: number;\n issuedAt?: number;\n address: string;\n expiresAt: number;\n}\nexport interface PaymentReview extends PaymentTarget {\n id: string;\n requestId?: string;\n linkId?: string;\n payee: string;\n /** What the payment is for, as the payer wrote it (at most 140 characters). */\n memo?: string;\n amount: number;\n fee: number;\n feeCap: number;\n createdAt: number;\n /** When it was approved (claimed for spending): how old an attempt whose outcome is unknown is, across a reload. */\n submittedAt?: number;\n state: IntentState;\n txid?: string;\n error?: string;\n /** A refused Cashu send whose ecash came back: what came back, and the fee the mint kept for taking it in. */\n returned?: { amount: number; fee: number };\n evm?: { from: string; nonce: number; gasLimit: string; maxFeePerGas: string; maxPriorityFeePerGas: string; confirmations: number };\n /**\n * Parked (WISP 06 § Forced takeover): an attempt that holds signed bytes or a signed transaction, found unfinished by\n * a copy of the profile started from older state (a forced takeover, a restored backup). It is never broadcast again\n * nor reconciled by broadcast: it waits for the person.\n */\n parked?: true;\n}\nexport interface PaymentAdapter<Prepared = unknown> {\n method: PaymentMethod;\n prepare(target: PaymentTarget, amount: number, feeCap: number): Promise<{ fee: number; prepared: Prepared; evm?: PaymentReview[\"evm\"] }>;\n execute(review: PaymentReview, prepared: Prepared, persist?: () => Promise<void>): Promise<PaymentExecution>;\n reconcile(review: PaymentReview, prepared: Prepared, persist?:()=>Promise<void>): Promise<PaymentExecution>;\n /** A review cancelled before approval: give back what `prepare` reserved (locked coins). Nothing was spent. */\n release?(review: PaymentReview, prepared: Prepared): Promise<void>;\n}\nexport interface PaymentExecution { txid?: string; settled: boolean; pending?: boolean; failed?: boolean; error?: string }\n/** Only use before signing/broadcasting, when no spend could have happened. */\nexport class PaymentPreflightError extends Error {}\nexport const ETHEREUM_USDT = \"0xdAC17F958D2ee523a2206206994597C13D831ec7\";\n/** Each chain's public RPC, which needs no key: the token wallet's defaults, and the `provider` its requests name. */\nexport const USDT_PUBLIC_RPC = { ethereum: \"https://ethereum.publicnode.com\", sepolia: \"https://ethereum-sepolia-rpc.publicnode.com\" } as const;\n/** Test networks for the token wallet and their chain IDs. Their tokens are worthless and not issued by Tether. */\nexport const EVM_TEST_CHAINS = { sepolia: 11155111, \"evm-local\": 31337 } as const;\n/** Aave's Sepolia test USDT (6 decimals): anyone can mint it from Aave's faucet, so a test needs only Sepolia ETH. */\nexport const SEPOLIA_TEST_USDT = \"0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0\";\n/** Aave's public test-token faucet on Sepolia: `mint(token, to, amount)`, open to anyone who pays the gas. */\nexport const SEPOLIA_TEST_USDT_FAUCET = \"0xC959483DBa39aa9E78757139af0e9a2EDEb3f42D\";\n/** What one \"Get test USDT\" asks for: 1,000 TEST-USDT (6 decimals). */\nexport const TEST_USDT_FAUCET_AMOUNT = 1_000_000_000;\nexport function parsePaymentAmount(value: string, decimals: number): number {\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18 || !/^\\d+(?:\\.\\d+)?$/.test(value)) throw new Error(\"Enter a valid amount\");\n const [whole, fraction = \"\"] = value.split(\".\");\n if (fraction.length > decimals) throw new Error(`Use at most ${decimals} decimal places`);\n const units = BigInt(whole) * 10n ** BigInt(decimals) + BigInt(fraction.padEnd(decimals, \"0\") || \"0\");\n if (units > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(\"Amount exceeds the wallet limit\");\n return Number(units);\n}\nexport function formatPaymentAmount(value: number | string, decimals = 0): string {\n const digits = BigInt(value).toString().padStart(decimals + 1, \"0\");\n if (!decimals) return digits;\n const fraction = digits.slice(-decimals).replace(/0+$/, \"\");\n return digits.slice(0, -decimals) + (fraction ? `.${fraction}` : \"\");\n}\nexport function assertTokenUnits(amount: number): void {\n if (!Number.isSafeInteger(amount) || amount <= 0) throw new Error(\"Enter a positive amount within the token precision and wallet limit\");\n}\nexport function assertWholeSats(amount: number): void {\n if (!Number.isSafeInteger(amount) || amount <= 0 || amount > 2_100_000_000_000_000) throw new Error(\"Enter a positive whole amount in sats\");\n}\n/** Arkade and Bark addresses are bech32m with `ark` on Bitcoin and `tark` on the test networks (one case only). */\nexport const arkAddressPrefix = (network: string) => network === \"bitcoin\" ? \"ark1\" : \"tark1\";\nexport function validatePaymentTarget(value: unknown, now = Date.now()): PaymentTarget {\n if (!value || typeof value !== \"object\") throw new Error(\"Invalid payment target\");\n const t = value as PaymentTarget;\n const evm = t.method === \"usdt\";\n if (t.method === \"bitcoin\") {\n if (!BITCOIN_NETWORKS.includes(t.network as BitcoinNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\" || t.provider !== ONCHAIN_PROVIDER) throw new Error(\"Unsupported payment method, asset or network\");\n if (!isBitcoinAddress(t.address, t.network as BitcoinNetwork)) throw new Error(`That is not a ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network} address`);\n } else if (t.method === \"fedimint\") {\n // The provider is the federation (its id); the address is what the payment answers: the request, or the contact.\n if (!BITCOIN_NETWORKS.includes(t.network as BitcoinNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\") throw new Error(\"Unsupported payment method, asset or network\");\n if (!isFederationId(t.provider)) throw new Error(\"That is not a Fedimint federation id\");\n } else if (t.method === \"spark\") {\n // Any Spark wallet of the network pays any Spark address or invoice of it: no provider to name.\n if (!SPARK_NETWORKS.includes(t.network as SparkNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\" || t.provider !== SPARK_PROVIDER) throw new Error(\"Unsupported payment method, asset or network\");\n if (!isSparkAddress(t.address, t.network as SparkNetwork)) throw new Error(`That is not a Spark address on ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network}`);\n } else if (evm) {\n if (![\"ethereum\", \"sepolia\", \"evm-local\"].includes(t.network) || t.unit !== \"token-base\" || !/^0x[0-9a-fA-F]{40}$/.test(t.token ?? \"\") || !/^0x[0-9a-fA-F]{40}$/.test(t.address) || /^0x0{40}$/i.test(t.address)) throw new Error(\"Invalid token, recipient or EVM network\");\n // Only Ethereum carries real USDT; Sepolia and a local chain carry worthless test tokens.\n if (t.network === \"ethereum\" ? t.chainId !== 1 || t.asset !== \"USDT\" || t.token!.toLowerCase() !== ETHEREUM_USDT.toLowerCase() || t.decimals !== 6 : t.chainId !== EVM_TEST_CHAINS[t.network as \"sepolia\" | \"evm-local\"] || t.asset !== \"TEST-USDT\" || !Number.isInteger(t.decimals) || t.decimals! < 0 || t.decimals! > 18) throw new Error(\"Token metadata does not match the network\");\n if (!Number.isSafeInteger(t.issuedAt) || t.issuedAt! < 0 || t.issuedAt! > now + 30000 || t.issuedAt! >= t.expiresAt) throw new Error(\"Invalid token request time\");\n } else if (![\"arkade\", \"cashu\", \"bark\"].includes(t.method) || ![\"bitcoin\", \"signet\", \"mutinynet\", \"regtest\", \"cashu-test\"].includes(t.network) || t.asset !== \"BTC\" || t.unit !== \"sat\") throw new Error(\"Unsupported payment method, asset or network\");\n // Second's Ark servers run on Bitcoin, signet and regtest only.\n if (t.method === \"bark\" && ![\"bitcoin\", \"signet\", \"regtest\"].includes(t.network)) throw new Error(\"Unsupported Bark network\");\n if (typeof t.address !== \"string\" || !t.address || t.address.length > 4096 || typeof t.provider !== \"string\" || t.provider.length > 512) throw new Error(\"Invalid payment destination\");\n if ((t.method === \"arkade\" || t.method === \"bark\") && ((t.address !== t.address.toLowerCase() && t.address !== t.address.toUpperCase()) || !t.address.toLowerCase().startsWith(arkAddressPrefix(t.network)))) throw new Error(`That is not an Ark address on ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network}`);\n if (t.method !== \"bitcoin\" && t.method !== \"fedimint\" && t.method !== \"spark\") {\n const url = new URL(t.provider);\n if (url.username || url.password || url.search || url.hash || (url.protocol !== \"https:\" && !(url.protocol === \"http:\" && [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)))) throw new Error(\"Use HTTPS or a local test provider\");\n }\n if (!Number.isSafeInteger(t.expiresAt) || t.expiresAt <= now || t.expiresAt > now + 24 * 60 * 60 * 1000) throw engineError(\"paymentExpired\");\n return { method:t.method,network:t.network,provider:t.provider,asset:t.asset,unit:t.unit,address:t.address,expiresAt:t.expiresAt, ...(evm ? {chainId:t.chainId,token:t.token,decimals:t.decimals,issuedAt:t.issuedAt} : {}) };\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAa,WAAW;;CAEtB,QAAQ;;;;;CAKR,OAAO;CACP,QAAQ;;CAER,MAAM;CACN,MAAM;;CAEN,SAAS;;;;;;CAMT,UAAU;;;;;CAKV,OAAO;AACT;AA0DA,SAAgB,oBAAoB,OAAyB;CAC3D,OAAO,KAAK,UAAU,EAAE,MAAM,CAAC;AACjC;;AAGA,SAAgB,yBAAyB,SAA2B;CAClE,IAAI;EACF,MAAM,EAAE,UAAU,KAAK,MAAM,OAAO;EACpC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;EACnC,OAAO,MAAM,QAAQ,MAAmB,OAAO,MAAM,YAAY,eAAe,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;CACrG,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;AAGA,IAAa,kBAAkB,UAAoC,OAAO,UAAU,YAAY,iBAAiB,KAAK,KAAK;AAE3H,SAAgB,uBAAuB,aAA+B;CACpE,OAAO,KAAK,UAAU,EAAE,YAAY,CAAC;AACvC;;AAGA,SAAgB,4BAA4B,SAA2B;CACrE,IAAI;EACF,MAAM,EAAE,gBAAgB,KAAK,MAAM,OAAO;EAC1C,IAAI,CAAC,MAAM,QAAQ,WAAW,GAAG,OAAO,CAAC;EACzC,OAAO,CAAC,GAAG,IAAI,IAAI,YAAY,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;CACpE,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAgB,aAAa,WAA2B,YAAwC;CAC9F,OAAO,UAAU,MAAM,CAAC,QAAQ,OAAO,UAAU,CAAC,GAAG;AAC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,KAAK,EAAE,aAAa,OAAO,EAAE,YAAY,MAAM,OAAqB,MAAM,YAAY,gBAAgB;CAC3I,OAAO;EAAE,QAAO,EAAE;EAAO,SAAQ,EAAE;EAAQ,UAAS,EAAE;EAAS,OAAM,EAAE;EAAM,MAAK,EAAE;EAAK,SAAQ,EAAE;EAAQ,WAAU,EAAE;EAAW,GAAI,MAAM;GAAC,SAAQ,EAAE;GAAQ,OAAM,EAAE;GAAM,UAAS,EAAE;GAAS,UAAS,EAAE;EAAQ,IAAI,CAAC;CAAG;AAC9N"}
|
|
1
|
+
{"version":3,"file":"paymentIntent-Cr3uZa_0.js","names":[],"sources":["../../../core/src/payments.ts","../../../core/src/bitcoinAddress.ts","../../../core/src/sparkAddress.ts","../../../core/src/paymentIntent.ts"],"sourcesContent":["import type { WireEndpoint } from \"./frames\";\n\n/**\n * Payments between two linked peers. Ghostly does not move money itself: it\n * carries payment requests, in-band payments such as ecash tokens, and\n * receipts over the data link, and a platform wallet executes them.\n *\n * Vocabulary and identifiers follow Pubky's Paykit so that publishing the same\n * endpoints through Paykit later is a change of transport, not of model:\n * an endpoint is an identifier plus a payload, an amount is decimal text plus\n * an asset.\n */\nexport const ENDPOINT = {\n /** Payload: a BOLT11 invoice. */\n bolt11: \"btc-lightning-bolt11\",\n /**\n * Payload in a request: JSON `{ \"mints\": [\"https://…\"] }`, the mints the\n * payee accepts ecash from. Payload in a payment: a `cashuB…` token.\n */\n cashu: \"cashu\",\n arkade: \"btc-arkade/1\",\n /** Second's Ark (Bark). Payload in a request: a payment target; in a payment: a receipt hint. */\n bark: \"btc-bark/1\",\n usdt: \"usdt-erc20/1\",\n /** On-chain Bitcoin. Payload in a request: a payment target (a fresh address); in a payment: a receipt hint `{ txid }`. */\n bitcoin: \"btc-onchain/1\",\n /**\n * Fedimint ecash. Payload in a request: JSON `{ \"federations\": [\"<federation id>\", …] }`, the federations the\n * payee has joined and takes ecash from. Payload in a payment: the notes themselves (out-of-band notes, a\n * bearer string only the federation that issued them redeems).\n */\n fedimint: \"fedimint-ecash/1\",\n /**\n * Spark, wallet to wallet. Payload in a request: a payment target whose address is a Spark invoice made for\n * that request; in a payment: a receipt hint `{ id }` (the payer's transfer id).\n */\n spark: \"btc-spark/1\",\n} as const;\n\nexport interface PaymentAmount {\n /** Decimal text; whole numbers for `sat`. */\n value: string;\n asset: string;\n}\n\nexport interface PaymentRequest {\n id: string;\n timestamp: number;\n amount: PaymentAmount;\n memo?: string;\n endpoints: WireEndpoint[];\n /** The ask this request answers, when the contact asked to pay (see {@link PaymentAsk}). */\n ask?: string;\n /** Real money or test coins: only a wallet of this network pays it. Absent from older apps. */\n network?: \"mainnet\" | \"testnet\";\n}\n\n/**\n * \"I want to pay you this much this way\": sent by a payer who has no address to pay to (Ark, USDT).\n * The payee's app answers with an ordinary payment request carrying `ask`, which the payer\n * then reviews and approves like any other.\n */\nexport interface PaymentAsk {\n id: string;\n timestamp: number;\n amount: PaymentAmount;\n method: \"arkade\" | \"usdt\" | \"bark\" | \"bitcoin\" | \"fedimint\" | \"spark\";\n memo?: string;\n /** The network the payer pays from. Absent from older apps. */\n network?: \"mainnet\" | \"testnet\";\n}\n\nexport interface Payment {\n id: string;\n timestamp: number;\n requestId?: string;\n amount: PaymentAmount;\n memo?: string;\n endpoint: WireEndpoint;\n}\n\nexport interface PaymentResult {\n /** Id of the payment or request this is about. */\n id: string;\n ok: boolean;\n /** Amount credited when it differs from the amount sent. */\n credited?: string;\n error?: string;\n /**\n * On a request (`ok` false): its payee closed it for good, and a payment made to it now is lost. Only the payee of a\n * request says it; the payer stops offering to pay it.\n */\n closed?: boolean;\n}\n\nexport function cashuRequestPayload(mints: string[]): string {\n return JSON.stringify({ mints });\n}\n\n/** Mints named by a `cashu` endpoint of a request. Anything malformed yields none. */\nexport function parseCashuRequestPayload(payload: string): string[] {\n try {\n const { mints } = JSON.parse(payload) as { mints?: unknown };\n if (!Array.isArray(mints)) return [];\n return mints.filter((m): m is string => typeof m === \"string\" && /^https?:\\/\\//.test(m)).slice(0, 8);\n } catch {\n return [];\n }\n}\n\n/** A Fedimint federation id: 32 bytes, lowercase hex. */\nexport const isFederationId = (value: unknown): value is string => typeof value === \"string\" && /^[0-9a-f]{64}$/.test(value);\n\nexport function fedimintRequestPayload(federations: string[]): string {\n return JSON.stringify({ federations });\n}\n\n/** Federations named by a `fedimint-ecash/1` endpoint of a request. Anything malformed yields none. */\nexport function parseFedimintRequestPayload(payload: string): string[] {\n try {\n const { federations } = JSON.parse(payload) as { federations?: unknown };\n if (!Array.isArray(federations)) return [];\n return [...new Set(federations.filter(isFederationId))].slice(0, 8);\n } catch {\n return [];\n }\n}\n\nexport function findEndpoint(endpoints: WireEndpoint[], identifier: string): string | undefined {\n return endpoints.find(([id]) => id === identifier)?.[1];\n}\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bech32, bech32m, createBase58check } from \"@scure/base\";\n\n/** The Bitcoin networks an on-chain wallet can be on. Only `bitcoin` is real money. */\nexport type BitcoinNetwork = \"bitcoin\" | \"signet\" | \"testnet\" | \"regtest\" | \"mutinynet\";\nexport const BITCOIN_NETWORKS: readonly BitcoinNetwork[] = [\"bitcoin\", \"signet\", \"testnet\", \"regtest\", \"mutinynet\"];\n\n/** Mutinynet is a signet: it shares signet's (and testnet's) address prefixes. */\nconst SEGWIT_HRP: Record<BitcoinNetwork, string> = { bitcoin: \"bc\", signet: \"tb\", testnet: \"tb\", mutinynet: \"tb\", regtest: \"bcrt\" };\nconst BASE58_VERSIONS: Record<BitcoinNetwork, readonly number[]> = { bitcoin: [0x00, 0x05], signet: [0x6f, 0xc4], testnet: [0x6f, 0xc4], mutinynet: [0x6f, 0xc4], regtest: [0x6f, 0xc4] };\nconst base58check = createBase58check(sha256);\n\nfunction segwit(address: string, hrp: string): boolean {\n // BIP 173: one case only. The checksum is over the lower-case form.\n if (address !== address.toLowerCase() && address !== address.toUpperCase()) return false;\n const lower = address.toLowerCase();\n if (!lower.startsWith(`${hrp}1`) || lower.length > 90) return false;\n // Version 0 is bech32 (BIP 173), every later version bech32m (BIP 350); the wrong one is refused.\n for (const [coder, v0] of [[bech32, true], [bech32m, false]] as const) {\n let decoded: { prefix: string; words: number[] };\n try { decoded = coder.decode(lower as `${string}1${string}`, 90); } catch { continue; }\n if (decoded.prefix !== hrp || decoded.words.length < 1) return false;\n const version = decoded.words[0];\n if (version > 16 || (version === 0) !== v0) return false;\n let program: Uint8Array;\n try { program = coder.fromWords(decoded.words.slice(1)); } catch { return false; }\n if (version === 0) return program.length === 20 || program.length === 32;\n return program.length >= 2 && program.length <= 40;\n }\n return false;\n}\n\n/** Whether `address` is a valid address on `network`: checksums, witness versions, lengths and prefixes. */\nexport function isBitcoinAddress(address: unknown, network: BitcoinNetwork): boolean {\n if (typeof address !== \"string\" || !BITCOIN_NETWORKS.includes(network) || address.length < 14 || address.length > 90) return false;\n if (segwit(address, SEGWIT_HRP[network])) return true;\n let payload: Uint8Array;\n try { payload = base58check.decode(address); } catch { return false; }\n return payload.length === 21 && BASE58_VERSIONS[network].includes(payload[0]);\n}\n","import { bech32m } from \"@scure/base\";\n\n/**\n * Spark (https://spark.money): a Bitcoin layer 2 where a transfer between two Spark wallets is instant and\n * off-chain. Ghostly's Spark wallets run on Bitcoin (real sats, Breez API key) or on regtest (Breez and\n * Lightspark's hosted test network, worthless sats). Spark's own testnet and signet are not offered by the\n * Breez SDK, so they are not payment networks here.\n */\nexport type SparkNetwork = \"bitcoin\" | \"regtest\";\nexport const SPARK_NETWORKS: readonly SparkNetwork[] = [\"bitcoin\", \"regtest\"];\n/**\n * The `provider` of a Spark target. Spark is one network per chain (its operators are the same for every\n * wallet), so any Spark wallet on the same network pays any Spark address: the payee names no service.\n */\nexport const SPARK_PROVIDER = \"spark\";\n\nconst HRP: Record<SparkNetwork, string> = { bitcoin: \"spark\", regtest: \"sparkrt\" };\n/** Long enough for an invoice with a 140-character memo and its signature. */\nconst MAX_LENGTH = 1024;\n\n/**\n * What a Spark string is on `network`: a wallet's `address` (its identity key, the same every time) or an\n * `invoice` (an address plus an amount, an expiry, a memo and a unique id, signed by the payee). Undefined\n * when it is neither, or belongs to another network. Structure only: the wallet's SDK checks the rest.\n */\nexport function sparkAddressKind(address: unknown, network: SparkNetwork): \"address\" | \"invoice\" | undefined {\n if (typeof address !== \"string\" || !SPARK_NETWORKS.includes(network) || address.length > MAX_LENGTH) return undefined;\n // One case only, and Spark writes lower case.\n if (address !== address.toLowerCase() || !address.startsWith(`${HRP[network]}1`)) return undefined;\n let payload: Uint8Array;\n try {\n const decoded = bech32m.decode(address as `${string}1${string}`, MAX_LENGTH);\n if (decoded.prefix !== HRP[network]) return undefined;\n payload = bech32m.fromWords(decoded.words);\n } catch { return undefined; }\n // Protobuf: field 1, 33 bytes, a compressed public key (the wallet's identity).\n if (payload.length < 35 || payload[0] !== 0x0a || payload[1] !== 0x21 || (payload[2] !== 0x02 && payload[2] !== 0x03)) return undefined;\n if (payload.length === 35) return \"address\";\n // Field 2: the invoice's fields. Anything else after the key is not a Spark string Ghostly knows.\n return payload[35] === 0x12 ? \"invoice\" : undefined;\n}\n\nexport const isSparkAddress = (address: unknown, network: SparkNetwork): boolean => sparkAddressKind(address, network) !== undefined;\n\n/** The Spark network a string belongs to, from its prefix alone (`spark1…` Bitcoin, `sparkrt1…` regtest). */\nexport function sparkNetworkOf(address: string): SparkNetwork | undefined {\n return SPARK_NETWORKS.find((network) => sparkAddressKind(address, network) !== undefined);\n}\n\n/** What a Spark invoice asks for, read from the invoice itself (the payer's wallet checks it again). */\nexport interface SparkInvoiceDetails {\n /** Sats asked; absent when the payer chooses. */\n amount?: number;\n memo?: string;\n /** Milliseconds. */\n expiresAt?: number;\n /** An invoice for a token (not sats): Ghostly does not pay those. */\n token: boolean;\n}\n\n/** Protobuf, just enough of it: `[field, wire type, value]` of each field of a message, or undefined when malformed. */\nfunction fields(bytes: Uint8Array): [number, number, Uint8Array | bigint][] | undefined {\n const out: [number, number, Uint8Array | bigint][] = [];\n let at = 0;\n const varint = (): bigint | undefined => {\n let value = 0n, shift = 0n;\n for (let i = 0; i < 10; i++) {\n if (at >= bytes.length) return undefined;\n const b = bytes[at++];\n value |= BigInt(b & 0x7f) << shift;\n if (!(b & 0x80)) return value;\n shift += 7n;\n }\n return undefined;\n };\n while (at < bytes.length) {\n const key = varint();\n if (key === undefined) return undefined;\n const field = Number(key >> 3n), wire = Number(key & 7n);\n if (wire === 0) { const v = varint(); if (v === undefined) return undefined; out.push([field, wire, v]); }\n else if (wire === 2) {\n const length = varint();\n if (length === undefined || at + Number(length) > bytes.length) return undefined;\n out.push([field, wire, bytes.slice(at, at + Number(length))]); at += Number(length);\n } else return undefined;\n }\n return out;\n}\n\n/**\n * The amount, memo and expiry a Spark invoice carries (SparkInvoiceFields: 4 sats payment, 3 tokens payment, 5 memo,\n * 7 expiry time), or undefined when `invoice` is not an invoice of `network`.\n */\nexport function sparkInvoiceDetails(invoice: string, network: SparkNetwork): SparkInvoiceDetails | undefined {\n if (sparkAddressKind(invoice, network) !== \"invoice\") return undefined;\n const top = fields(bech32m.fromWords(bech32m.decode(invoice as `${string}1${string}`, MAX_LENGTH).words));\n const body = top?.find(([field, wire]) => field === 2 && wire === 2)?.[2];\n const inner = body instanceof Uint8Array ? fields(body) : undefined;\n if (!inner) return undefined;\n const details: SparkInvoiceDetails = { token: false };\n for (const [field, wire, value] of inner) {\n if (wire !== 2 || !(value instanceof Uint8Array)) continue;\n if (field === 3) details.token = true;\n else if (field === 4) {\n const amount = fields(value)?.find(([f, w]) => f === 1 && w === 0)?.[2];\n if (typeof amount === \"bigint\") { if (amount > BigInt(Number.MAX_SAFE_INTEGER)) return undefined; details.amount = Number(amount); }\n } else if (field === 5) details.memo = new TextDecoder().decode(value).slice(0, 140);\n else if (field === 7) {\n const seconds = fields(value)?.find(([f, w]) => f === 1 && w === 0)?.[2];\n if (typeof seconds === \"bigint\" && seconds < 1n << 40n) details.expiresAt = Number(seconds) * 1000;\n }\n }\n return details;\n}\n","import { BITCOIN_NETWORKS, isBitcoinAddress, type BitcoinNetwork } from \"./bitcoinAddress\";\nimport { engineError } from \"./engineErrors\";\nimport { isFederationId } from \"./payments\";\nimport { SPARK_NETWORKS, SPARK_PROVIDER, isSparkAddress, type SparkNetwork } from \"./sparkAddress\";\n\n/** Local wallet contract. Capability support is never authorization to spend. */\nexport type PaymentMethod = \"cashu\" | \"arkade\" | \"usdt\" | \"bark\" | \"bitcoin\" | \"fedimint\" | \"spark\";\nexport type PaymentNetwork = \"bitcoin\" | \"signet\" | \"testnet\" | \"mutinynet\" | \"regtest\" | \"cashu-test\" | \"ethereum\" | \"sepolia\" | \"evm-local\";\n/**\n * Real money, or test coins: what every wallet is, whatever chain it runs on. A payment never crosses from one\n * to the other: a test wallet never settles a request for real money, nor the reverse.\n */\nexport type WalletNetwork = \"mainnet\" | \"testnet\";\nexport const WALLET_NETWORKS: readonly WalletNetwork[] = [\"mainnet\", \"testnet\"];\n/** Bitcoin and Ethereum carry real money; every other chain of a payment target is a test network. */\nexport const walletNetworkOf = (network: PaymentNetwork | string): WalletNetwork => network === \"bitcoin\" || network === \"ethereum\" ? \"mainnet\" : \"testnet\";\nexport const isWalletNetwork = (value: unknown): value is WalletNetwork => value === \"mainnet\" || value === \"testnet\";\n/**\n * The `provider` of an on-chain target. Anyone can pay a Bitcoin address from any wallet, so the payee\n * names no service; which wallet pays is the payer's own choice (its active on-chain source).\n */\nexport const ONCHAIN_PROVIDER = \"onchain\";\nexport type IntentState = \"pending\" | \"submitted\" | \"settled\" | \"failed\" | \"unknown\" | \"cancelled\";\nexport interface PaymentTarget {\n method: PaymentMethod;\n network: PaymentNetwork;\n provider: string;\n asset: \"BTC\" | \"USDT\" | \"TEST-USDT\";\n unit: \"sat\" | \"token-base\";\n chainId?: number;\n token?: string;\n decimals?: number;\n issuedAt?: number;\n address: string;\n expiresAt: number;\n}\nexport interface PaymentReview extends PaymentTarget {\n id: string;\n requestId?: string;\n linkId?: string;\n payee: string;\n /** What the payment is for, as the payer wrote it (at most 140 characters). */\n memo?: string;\n amount: number;\n fee: number;\n feeCap: number;\n createdAt: number;\n /** When it was approved (claimed for spending): how old an attempt whose outcome is unknown is, across a reload. */\n submittedAt?: number;\n state: IntentState;\n txid?: string;\n error?: string;\n /** A refused Cashu send whose ecash came back: what came back, and the fee the mint kept for taking it in. */\n returned?: { amount: number; fee: number };\n evm?: { from: string; nonce: number; gasLimit: string; maxFeePerGas: string; maxPriorityFeePerGas: string; confirmations: number };\n /**\n * Parked (WISP 06 § Forced takeover): an attempt that holds signed bytes or a signed transaction, found unfinished by\n * a copy of the profile started from older state (a forced takeover, a restored backup). It is never broadcast again\n * nor reconciled by broadcast: it waits for the person.\n */\n parked?: true;\n}\nexport interface PaymentAdapter<Prepared = unknown> {\n method: PaymentMethod;\n prepare(target: PaymentTarget, amount: number, feeCap: number): Promise<{ fee: number; prepared: Prepared; evm?: PaymentReview[\"evm\"] }>;\n execute(review: PaymentReview, prepared: Prepared, persist?: () => Promise<void>): Promise<PaymentExecution>;\n reconcile(review: PaymentReview, prepared: Prepared, persist?:()=>Promise<void>): Promise<PaymentExecution>;\n /** A review cancelled before approval: give back what `prepare` reserved (locked coins). Nothing was spent. */\n release?(review: PaymentReview, prepared: Prepared): Promise<void>;\n}\nexport interface PaymentExecution { txid?: string; settled: boolean; pending?: boolean; failed?: boolean; error?: string }\n/** Only use before signing/broadcasting, when no spend could have happened. */\nexport class PaymentPreflightError extends Error {}\nexport const ETHEREUM_USDT = \"0xdAC17F958D2ee523a2206206994597C13D831ec7\";\n/** Each chain's public RPC, which needs no key: the token wallet's defaults, and the `provider` its requests name. */\nexport const USDT_PUBLIC_RPC = { ethereum: \"https://ethereum.publicnode.com\", sepolia: \"https://ethereum-sepolia-rpc.publicnode.com\" } as const;\n/** Test networks for the token wallet and their chain IDs. Their tokens are worthless and not issued by Tether. */\nexport const EVM_TEST_CHAINS = { sepolia: 11155111, \"evm-local\": 31337 } as const;\n/** Aave's Sepolia test USDT (6 decimals): anyone can mint it from Aave's faucet, so a test needs only Sepolia ETH. */\nexport const SEPOLIA_TEST_USDT = \"0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0\";\n/** Aave's public test-token faucet on Sepolia: `mint(token, to, amount)`, open to anyone who pays the gas. */\nexport const SEPOLIA_TEST_USDT_FAUCET = \"0xC959483DBa39aa9E78757139af0e9a2EDEb3f42D\";\n/** What one \"Get test USDT\" asks for: 1,000 TEST-USDT (6 decimals). */\nexport const TEST_USDT_FAUCET_AMOUNT = 1_000_000_000;\nexport function parsePaymentAmount(value: string, decimals: number): number {\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18 || !/^\\d+(?:\\.\\d+)?$/.test(value)) throw new Error(\"Enter a valid amount\");\n const [whole, fraction = \"\"] = value.split(\".\");\n if (fraction.length > decimals) throw new Error(`Use at most ${decimals} decimal places`);\n const units = BigInt(whole) * 10n ** BigInt(decimals) + BigInt(fraction.padEnd(decimals, \"0\") || \"0\");\n if (units > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(\"Amount exceeds the wallet limit\");\n return Number(units);\n}\nexport function formatPaymentAmount(value: number | string, decimals = 0): string {\n const digits = BigInt(value).toString().padStart(decimals + 1, \"0\");\n if (!decimals) return digits;\n const fraction = digits.slice(-decimals).replace(/0+$/, \"\");\n return digits.slice(0, -decimals) + (fraction ? `.${fraction}` : \"\");\n}\nexport function assertTokenUnits(amount: number): void {\n if (!Number.isSafeInteger(amount) || amount <= 0) throw new Error(\"Enter a positive amount within the token precision and wallet limit\");\n}\nexport function assertWholeSats(amount: number): void {\n if (!Number.isSafeInteger(amount) || amount <= 0 || amount > 2_100_000_000_000_000) throw new Error(\"Enter a positive whole amount in sats\");\n}\n/** Arkade and Bark addresses are bech32m with `ark` on Bitcoin and `tark` on the test networks (one case only). */\nexport const arkAddressPrefix = (network: string) => network === \"bitcoin\" ? \"ark1\" : \"tark1\";\nexport function validatePaymentTarget(value: unknown, now = Date.now()): PaymentTarget {\n if (!value || typeof value !== \"object\") throw new Error(\"Invalid payment target\");\n const t = value as PaymentTarget;\n const evm = t.method === \"usdt\";\n if (t.method === \"bitcoin\") {\n if (!BITCOIN_NETWORKS.includes(t.network as BitcoinNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\" || t.provider !== ONCHAIN_PROVIDER) throw new Error(\"Unsupported payment method, asset or network\");\n if (!isBitcoinAddress(t.address, t.network as BitcoinNetwork)) throw new Error(`That is not a ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network} address`);\n } else if (t.method === \"fedimint\") {\n // The provider is the federation (its id); the address is what the payment answers: the request, or the contact.\n if (!BITCOIN_NETWORKS.includes(t.network as BitcoinNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\") throw new Error(\"Unsupported payment method, asset or network\");\n if (!isFederationId(t.provider)) throw new Error(\"That is not a Fedimint federation id\");\n } else if (t.method === \"spark\") {\n // Any Spark wallet of the network pays any Spark address or invoice of it: no provider to name.\n if (!SPARK_NETWORKS.includes(t.network as SparkNetwork) || t.asset !== \"BTC\" || t.unit !== \"sat\" || t.provider !== SPARK_PROVIDER) throw new Error(\"Unsupported payment method, asset or network\");\n if (!isSparkAddress(t.address, t.network as SparkNetwork)) throw new Error(`That is not a Spark address on ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network}`);\n } else if (evm) {\n if (![\"ethereum\", \"sepolia\", \"evm-local\"].includes(t.network) || t.unit !== \"token-base\" || !/^0x[0-9a-fA-F]{40}$/.test(t.token ?? \"\") || !/^0x[0-9a-fA-F]{40}$/.test(t.address) || /^0x0{40}$/i.test(t.address)) throw new Error(\"Invalid token, recipient or EVM network\");\n // Only Ethereum carries real USDT; Sepolia and a local chain carry worthless test tokens.\n if (t.network === \"ethereum\" ? t.chainId !== 1 || t.asset !== \"USDT\" || t.token!.toLowerCase() !== ETHEREUM_USDT.toLowerCase() || t.decimals !== 6 : t.chainId !== EVM_TEST_CHAINS[t.network as \"sepolia\" | \"evm-local\"] || t.asset !== \"TEST-USDT\" || !Number.isInteger(t.decimals) || t.decimals! < 0 || t.decimals! > 18) throw new Error(\"Token metadata does not match the network\");\n if (!Number.isSafeInteger(t.issuedAt) || t.issuedAt! < 0 || t.issuedAt! > now + 30000 || t.issuedAt! >= t.expiresAt) throw new Error(\"Invalid token request time\");\n } else if (![\"arkade\", \"cashu\", \"bark\"].includes(t.method) || ![\"bitcoin\", \"signet\", \"mutinynet\", \"regtest\", \"cashu-test\"].includes(t.network) || t.asset !== \"BTC\" || t.unit !== \"sat\") throw new Error(\"Unsupported payment method, asset or network\");\n // Second's Ark servers run on Bitcoin, signet and regtest only.\n if (t.method === \"bark\" && ![\"bitcoin\", \"signet\", \"regtest\"].includes(t.network)) throw new Error(\"Unsupported Bark network\");\n if (typeof t.address !== \"string\" || !t.address || t.address.length > 4096 || typeof t.provider !== \"string\" || t.provider.length > 512) throw new Error(\"Invalid payment destination\");\n if ((t.method === \"arkade\" || t.method === \"bark\") && ((t.address !== t.address.toLowerCase() && t.address !== t.address.toUpperCase()) || !t.address.toLowerCase().startsWith(arkAddressPrefix(t.network)))) throw new Error(`That is not an Ark address on ${t.network === \"bitcoin\" ? \"Bitcoin\" : t.network}`);\n if (t.method !== \"bitcoin\" && t.method !== \"fedimint\" && t.method !== \"spark\") {\n const url = new URL(t.provider);\n if (url.username || url.password || url.search || url.hash || (url.protocol !== \"https:\" && !(url.protocol === \"http:\" && [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)))) throw new Error(\"Use HTTPS or a local test provider\");\n }\n if (!Number.isSafeInteger(t.expiresAt) || t.expiresAt <= now || t.expiresAt > now + 24 * 60 * 60 * 1000) throw engineError(\"paymentExpired\");\n return { method:t.method,network:t.network,provider:t.provider,asset:t.asset,unit:t.unit,address:t.address,expiresAt:t.expiresAt, ...(evm ? {chainId:t.chainId,token:t.token,decimals:t.decimals,issuedAt:t.issuedAt} : {}) };\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAa,WAAW;;CAEtB,QAAQ;;;;;CAKR,OAAO;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OAAM,EAAE;GAAM,UAAS,EAAE;GAAS,UAAS,EAAE;EAAQ,IAAI,CAAC;CAAG;AAC9N"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as shownName, i as cleanName } from "./apiKit-DAFsWtyk.js";
|
|
2
2
|
import { t as childEnv } from "./childEnv-C-99hdbL.js";
|
|
3
3
|
import { t as CliError } from "./errors-JVJsO8Iu.js";
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
|
-
import { chmodSync, closeSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
5
|
+
import { chmodSync, closeSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -11,16 +11,39 @@ import { homedir, tmpdir } from "node:os";
|
|
|
11
11
|
* Where a socket goes when its path in the profile is longer than a Unix socket may be: `<base>/<prefix>-<hash of the
|
|
12
12
|
* profile>/<leaf>`, in `$XDG_RUNTIME_DIR` or else the temp folder (macOS gives each user one) when that folder is the
|
|
13
13
|
* user's alone, so no other user can make the folder first. When neither is, or the path would still be too long:
|
|
14
|
-
* `/tmp/<prefix>-<uid>-<hash>/<leaf>`. Either way `privateFolder` checks the folder before use
|
|
14
|
+
* `/tmp/<prefix>-<uid>-<hash>/<leaf>`. Either way `privateFolder` checks the folder before use, and
|
|
15
|
+
* `dropRuntimeFolder` removes it once its socket is gone.
|
|
15
16
|
*/
|
|
16
17
|
function runtimePath(prefix, profileDir, leaf) {
|
|
17
18
|
const hash = createHash("sha256").update(profileDir).digest("hex").slice(0, 24);
|
|
18
19
|
for (const base of [process.env.XDG_RUNTIME_DIR, tmpdir()]) {
|
|
19
20
|
if (!base || !isAbsolute(base) || !usersAlone(base)) continue;
|
|
20
21
|
const path = join(base, `${prefix}-${hash}`, leaf);
|
|
21
|
-
if (Buffer.byteLength(path) <= 100) return path;
|
|
22
|
+
if (Buffer.byteLength(path) <= 100) return runtimeFolder(path);
|
|
22
23
|
}
|
|
23
|
-
return join("/tmp", `${prefix}-${process.getuid?.() ?? 0}-${hash}`, leaf);
|
|
24
|
+
return runtimeFolder(join("/tmp", `${prefix}-${process.getuid?.() ?? 0}-${hash}`, leaf));
|
|
25
|
+
}
|
|
26
|
+
/** The folders `runtimePath` gave in this process: the only ones `dropRuntimeFolder` removes. */
|
|
27
|
+
var runtimeFolders = /* @__PURE__ */ new Set();
|
|
28
|
+
function runtimeFolder(path) {
|
|
29
|
+
runtimeFolders.add(dirname(path));
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes the folder `runtimePath` gave for `socket`, once that socket is gone (a daemon that stopped, a call that
|
|
34
|
+
* ended): left behind, one empty folder per long-path profile piled up in the temp folder. Only an empty folder of this
|
|
35
|
+
* user's that is not a link goes (`rmdir`, never what is in it): another socket in it (another call of the daemon's)
|
|
36
|
+
* keeps it, and it goes with the last one. Any other folder (the profile's own, `GHOSTLY_CALL_SOCKET_DIR`) is left
|
|
37
|
+
* alone. Nothing here fails the stop: a folder that cannot go stays, and is used again.
|
|
38
|
+
*/
|
|
39
|
+
function dropRuntimeFolder(socket) {
|
|
40
|
+
const folder = dirname(socket);
|
|
41
|
+
if (process.platform === "win32" || !runtimeFolders.has(folder)) return;
|
|
42
|
+
try {
|
|
43
|
+
const info = lstatSync(folder);
|
|
44
|
+
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) return;
|
|
45
|
+
rmdirSync(folder);
|
|
46
|
+
} catch {}
|
|
24
47
|
}
|
|
25
48
|
function usersAlone(path) {
|
|
26
49
|
try {
|
|
@@ -33,7 +56,8 @@ function usersAlone(path) {
|
|
|
33
56
|
/**
|
|
34
57
|
* A folder for a socket outside the profile (when the profile's path is too long for one): made owner-only, and
|
|
35
58
|
* refused when it is a link, someone else made it, or anyone else may enter it: `refused`, as the profile's own checks
|
|
36
|
-
* (`ownProfile`), with the way out. It holds only sockets, so removing it loses nothing; it is made again.
|
|
59
|
+
* (`ownProfile`), with the way out. It holds only sockets, so removing it loses nothing; it is made again. A folder
|
|
60
|
+
* another account made can't be removed or closed (/tmp is sticky): the way out is a socket somewhere else.
|
|
37
61
|
*/
|
|
38
62
|
function privateFolder(path, what) {
|
|
39
63
|
mkdirSync(path, {
|
|
@@ -41,6 +65,7 @@ function privateFolder(path, what) {
|
|
|
41
65
|
mode: 448
|
|
42
66
|
});
|
|
43
67
|
const info = lstatSync(path);
|
|
68
|
+
if (info.isDirectory() && process.getuid && info.uid !== process.getuid()) throw new CliError("refused", `${path} is not a folder of this user's alone, another account made it: ${what}. Set XDG_RUNTIME_DIR to a folder only this user can enter, or use a shorter --home, then try again`);
|
|
44
69
|
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid() || (info.mode & 63) !== 0) throw new CliError("refused", `${path} is not a folder of this user's alone: ${what}. Run \`rm -r ${path}\` (ghostly makes it again), or if it is this user's folder, \`chmod 700 ${path}\`, then try again`);
|
|
45
70
|
}
|
|
46
71
|
/**
|
|
@@ -537,6 +562,6 @@ function holder(file, lock) {
|
|
|
537
562
|
const now = processStart(pid);
|
|
538
563
|
return recorded && now !== null && now !== recorded ? null : pid;
|
|
539
564
|
}
|
|
540
|
-
export {
|
|
565
|
+
export { dropRuntimeFolder as C, privateFolder as D, ownSocket as E, runtimePath as O, userPath as S, ownProfile 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, ownFolder as w, startingPath as x, selectProfile as y };
|
|
541
566
|
|
|
542
|
-
//# sourceMappingURL=profiles-
|
|
567
|
+
//# sourceMappingURL=profiles-BAJf0c9E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles-BAJf0c9E.js","names":[],"sources":["../../src/privateFolder.ts","../../src/profiles.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, lstatSync, mkdirSync, readdirSync, rmdirSync, statSync, type Stats } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join } from \"node:path\";\nimport { CliError } from \"./errors\";\n\n/**\n * Where a socket goes when its path in the profile is longer than a Unix socket may be: `<base>/<prefix>-<hash of the\n * profile>/<leaf>`, in `$XDG_RUNTIME_DIR` or else the temp folder (macOS gives each user one) when that folder is the\n * user's alone, so no other user can make the folder first. When neither is, or the path would still be too long:\n * `/tmp/<prefix>-<uid>-<hash>/<leaf>`. Either way `privateFolder` checks the folder before use, and\n * `dropRuntimeFolder` removes it once its socket is gone.\n */\nexport function runtimePath(prefix: string, profileDir: string, leaf: string): string {\n const hash = createHash(\"sha256\").update(profileDir).digest(\"hex\").slice(0, 24);\n for (const base of [process.env.XDG_RUNTIME_DIR, tmpdir()]) {\n if (!base || !isAbsolute(base) || !usersAlone(base)) continue;\n const path = join(base, `${prefix}-${hash}`, leaf);\n if (Buffer.byteLength(path) <= 100) return runtimeFolder(path);\n }\n return runtimeFolder(join(\"/tmp\", `${prefix}-${process.getuid?.() ?? 0}-${hash}`, leaf));\n}\n\n/** The folders `runtimePath` gave in this process: the only ones `dropRuntimeFolder` removes. */\nconst runtimeFolders = new Set<string>();\n\nfunction runtimeFolder(path: string): string {\n runtimeFolders.add(dirname(path));\n return path;\n}\n\n/**\n * Removes the folder `runtimePath` gave for `socket`, once that socket is gone (a daemon that stopped, a call that\n * ended): left behind, one empty folder per long-path profile piled up in the temp folder. Only an empty folder of this\n * user's that is not a link goes (`rmdir`, never what is in it): another socket in it (another call of the daemon's)\n * keeps it, and it goes with the last one. Any other folder (the profile's own, `GHOSTLY_CALL_SOCKET_DIR`) is left\n * alone. Nothing here fails the stop: a folder that cannot go stays, and is used again.\n */\nexport function dropRuntimeFolder(socket: string): void {\n const folder = dirname(socket);\n if (process.platform === \"win32\" || !runtimeFolders.has(folder)) return;\n try {\n const info = lstatSync(folder);\n if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid())) return;\n rmdirSync(folder);\n } catch {\n // Not empty (ENOTEMPTY: another socket or file in it), or gone already (ENOENT): it stays as it is.\n }\n}\n\nfunction usersAlone(path: string): boolean {\n try {\n const info = statSync(path);\n return info.isDirectory() && (!process.getuid || info.uid === process.getuid()) && (info.mode & 0o077) === 0;\n } catch {\n return false;\n }\n}\n\n/**\n * A folder for a socket outside the profile (when the profile's path is too long for one): made owner-only, and\n * refused when it is a link, someone else made it, or anyone else may enter it: `refused`, as the profile's own checks\n * (`ownProfile`), with the way out. It holds only sockets, so removing it loses nothing; it is made again. A folder\n * another account made can't be removed or closed (/tmp is sticky): the way out is a socket somewhere else.\n */\nexport function privateFolder(path: string, what: string): void {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n const info = lstatSync(path);\n if (info.isDirectory() && process.getuid && info.uid !== process.getuid()) {\n throw new CliError(\"refused\", `${path} is not a folder of this user's alone, another account made it: ${what}. Set XDG_RUNTIME_DIR to a folder only this user can enter, or use a shorter --home, then try again`);\n }\n if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid()) || (info.mode & 0o077) !== 0) {\n throw new CliError(\"refused\", `${path} is not a folder of this user's alone: ${what}. Run \\`rm -r ${path}\\` (ghostly makes it again), or if it is this user's folder, \\`chmod 700 ${path}\\`, then try again`);\n }\n}\n\n/**\n * The profile's own folder, made owner-only again before the daemon's socket goes in it: a folder made by an older\n * release, or opened up by hand, is closed rather than trusted. Refused when it is a link or someone else's.\n */\nexport function ownFolder(path: string, what: string): void {\n const info = lstatSync(path);\n if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid())) throw new CliError(\"refused\", `${path} is not a folder of this user's: ${what}`);\n if ((info.mode & 0o077) !== 0) chmodSync(path, 0o700);\n}\n\n/**\n * A profile's folders and files, checked before a command (a one-shot as much as the daemon) takes its lock or opens\n * its store, which append to the files in place and follow a link: the home and its `profiles/` must be this user's\n * (a link to a folder of this user's is one); the home is closed to others' writes, `profiles/` to 0700. The profile's\n * folder and its `db/` must be this user's and not links, and are closed to 0700; what is in them must be this user's\n * and not a link, and a file is closed to 0600. A home, profile or journal opened up by hand, or made by another\n * account in a folder it could write, was used as it was: the events journal (message texts) stayed readable by others.\n */\nexport function ownProfile(dir: string): void {\n if (process.platform === \"win32\") return;\n const what = \"ghostly will not open the profile there\";\n const profiles = dirname(dir), home = dirname(profiles);\n const mine = (info: Stats) => !process.getuid || info.uid === process.getuid();\n for (const folder of [home, profiles]) {\n const info = statSync(folder);\n if (!info.isDirectory() || !mine(info)) throw new CliError(\"refused\", `${folder} is not a folder of this user's: ${what}`);\n const open = folder === home ? 0o022 : 0o077;\n if ((info.mode & open) !== 0) chmodSync(folder, info.mode & 0o777 & ~open);\n }\n const db = join(dir, \"db\");\n for (const folder of [dir, db]) {\n let info;\n try { info = lstatSync(folder); } catch (error) { if (folder === db && (error as NodeJS.ErrnoException).code === \"ENOENT\") continue; throw error; }\n if (!info.isDirectory() || !mine(info)) throw new CliError(\"refused\", `${folder} is not a folder of this user's: ${what}`);\n if ((info.mode & 0o077) !== 0) chmodSync(folder, 0o700);\n for (const name of readdirSync(folder)) {\n // Another command at once on the profile removes its lock's draft, start and stale files as it goes: one gone\n // since the listing is passed over, not the command's error.\n const path = join(folder, name), entry = lstatSync(path, { throwIfNoEntry: false });\n if (!entry) continue;\n if (entry.isSymbolicLink() || !mine(entry)) throw new CliError(\"refused\", `${path} is a link or another user's: ${what}`);\n if (entry.isFile() && (entry.mode & 0o077) !== 0) {\n try { chmodSync(path, 0o600); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error; }\n }\n }\n }\n}\n\n/** False when `path` is there but is not a socket of this user's: nothing to connect to. */\nexport function ownSocket(path: string): boolean {\n if (process.platform === \"win32\") return true;\n let info;\n try { info = lstatSync(path); } catch { return true; }\n return info.isSocket() && (!process.getuid || info.uid === process.getuid());\n}\n","import { execFileSync } from \"node:child_process\";\nimport { closeSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, rmSync, statSync, utimesSync, writeFileSync, writeSync, type Stats } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { MAX_NICK_LENGTH } from \"@ghostly/core\";\nimport { cleanName, shownName } from \"./apiKit\";\nimport { childEnv } from \"./childEnv\";\nimport { CliError } from \"./errors\";\nimport { runtimePath } from \"./privateFolder\";\n\n/**\n * Profiles on disk (WISP 1100 § Profiles and files): `<home>/profiles/<name>/`, 0700, one engine store each.\n * `<home>/current` names the profile commands use when none is given.\n */\nexport const DEFAULT_PROFILE = \"default\";\nconst NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/i;\n\n/**\n * An empty `--home` or `--profile` (an unset variable in a script) is a usage error: taken as not given, it ran the\n * command in the current folder, or as the current profile. An empty variable of the environment counts as unset.\n */\nexport function ghostlyHome(option?: string): string {\n if (option === \"\") throw new CliError(\"usage\", \"--home needs a folder\");\n return userPath(option ?? (process.env.GHOSTLY_HOME || join(homedir(), \".ghostly\")), true);\n}\n\n/**\n * A path the CLI was given, made absolute. A `~` the shell left alone (`--home=~/bots`, a quoted variable, a unit\n * file's `Environment=` line) is the user's home, as the shell reads it: it was a folder named `~` in the current one.\n * `~user/…` is a usage error, not a guess at another user's home, unless it is there under this folder. Any other name\n * that starts with `~` is a file here, as the shell and every other tool read it (`~notes.txt`, Office's\n * `~$report.docx`, a new `~cursor`): all of them were refused (agents#1604). `home`: the profiles' folder, where a bare\n * `~bob` that is not there is refused too, as a new profile would be made in a folder of that name.\n */\nexport function userPath(path: string, home = false): string {\n if (path === \"~\" || path.startsWith(\"~/\")) return join(homedir(), path.slice(1));\n if (path.startsWith(\"~\") && (home || path.includes(\"/\")) && !existsSync(resolve(path))) {\n throw new CliError(\"usage\", `${path}: ~user is not read here: write the ${home || path.endsWith(\"/\") ? \"folder\" : \"path\"} in full`);\n }\n return resolve(path);\n}\n\nconst isProfileName = (name: string): boolean => NAME.test(name) && !name.includes(\"..\");\n\nexport function checkProfileName(name: string): string {\n if (!isProfileName(name)) throw new CliError(\"usage\", `Not a profile name: ${JSON.stringify(name)} (letters, digits, \".\", \"_\" and \"-\", up to 64)`);\n return name;\n}\n\n/**\n * The name a profile shows its contacts, whichever command sets it (`--name`, `profile.set`, `settings set nick`):\n * cleaned as a group's name is (`shownName`: a tab or a line break is a space, invisible characters go), then up to 64\n * characters as stored; empty (or spaces) is no name. `settings set nick` took any length and every one took a line\n * break, printed whole by `status`; a name with nothing that shows was kept as given, and contacts saw no name. `field`\n * names it in the refusal.\n */\nexport function checkShownName(name: unknown, field = \"name\"): string {\n if (typeof name !== \"string\") throw new CliError(\"bad_request\", `${field} must be up to ${MAX_NICK_LENGTH} characters on one line`);\n if (!name.trim()) return \"\";\n return shownName(name, MAX_NICK_LENGTH, field, \" (an empty one is no name)\");\n}\n\n/**\n * `--name` of `profile create` and `profile set`, checked before the profile opens: `checkShownName`'s rule, counted as\n * it counts (code points once cleaned, so a line break is a space and e + a combining accent is one), refused as a\n * usage error (exit 2) that names the option, as `app init --title` is. It was the engine's `bad_request` (exit 1),\n * \"name must be up to 64 characters on one line\", which named neither the option nor the length given.\n */\nexport function checkShownNameOption(name: string): string {\n const shown = cleanName(name, Infinity) ?? \"\";\n const length = [...shown].length;\n if (length > MAX_NICK_LENGTH) throw new CliError(\"usage\", `--name is up to ${MAX_NICK_LENGTH} characters, not ${length} characters`);\n if (name.trim() && !shown) throw new CliError(\"usage\", \"--name needs a character that shows (an empty one is no name)\");\n return checkShownName(name);\n}\n\nexport function currentProfile(home: string, option?: string): string {\n if (option === \"\") throw new CliError(\"usage\", \"--profile needs a profile name\");\n if (option !== undefined) return checkProfileName(option);\n const env = process.env.GHOSTLY_PROFILE;\n // Nobody typed it on this line: refused naming the variable and the way out, not as a `--profile` given here.\n if (env && !isProfileName(env)) {\n throw new CliError(\"usage\", `GHOSTLY_PROFILE names no profile (${JSON.stringify(env)}): set it to a profile's name (letters, digits, \".\", \"_\" and \"-\", up to 64), or unset it`);\n }\n if (env) return env;\n const file = join(home, \"current\");\n if (existsSync(file)) {\n const name = readFileSync(file, \"utf8\").trim();\n // Nobody typed it: refused naming the file and the way out, not a usage error of a name the command never had.\n if (name && !isProfileName(name)) {\n throw new CliError(\"refused\", `${file} names no profile (${JSON.stringify(name)}): ghostly profile use <name> or ghostly profile create <name> --use replaces it, or delete the file`, { file });\n }\n if (name) return name;\n }\n return DEFAULT_PROFILE;\n}\n\n/**\n * The current profile, or null when `<home>/current` names none: for the commands that list profiles or replace that\n * file (`profile list`, `use`, `create`, `restore`), which a bad name there would otherwise block.\n */\nexport function currentProfileOrNone(home: string, option?: string): string | null {\n try {\n return currentProfile(home, option);\n } catch (error) {\n if (error instanceof CliError && error.details?.file) return null;\n throw error;\n }\n}\n\nexport function profileDir(home: string, name: string): string {\n return join(home, \"profiles\", checkProfileName(name));\n}\n\nexport interface ProfilePaths { name: string; dir: string; db: string; socket: string; lock: string; events: string; files: string; log: string }\nexport function profilePaths(home: string, name: string): ProfilePaths {\n const dir = profileDir(home, name);\n return {\n name, dir, db: join(dir, \"db\"), socket: socketPath(dir), lock: lockPath(dir),\n events: join(dir, \"events.jsonl\"), files: join(dir, \"files\"), log: join(dir, \"daemon.log\"),\n };\n}\n\n/** The file that says which process holds the profile (`acquireLock`). */\nexport function lockPath(dir: string): string {\n return join(dir, \"daemon.lock\");\n}\n\n/** The file in which a daemon says it is starting: its pid, from the lock it took until its socket listens. */\nexport function startingPath(dir: string): string {\n return join(dir, \"daemon.starting\");\n}\n\n/**\n * The pid of the profile's daemon while it starts (its engine, before its socket listens): the lock's holder, when it\n * marked its start. Null otherwise: nobody holds the profile, a one-shot command does, or the mark is a dead daemon's.\n */\nexport function startingDaemon(paths: ProfilePaths): number | null {\n let pid: number;\n try { pid = Number(readFileSync(startingPath(paths.dir), \"utf8\").trim()); } catch { return null; }\n // Alive, and this profile's: the lock's holder is.\n return Number.isInteger(pid) && pid > 0 && pid === lockOwner(paths) ? pid : null;\n}\n\n/**\n * The file in which `daemon restart` or `daemon --detach` keeps the profile for the daemon it starts (`claimForDaemon`):\n * its pid, the file touched every CLAIM_TOUCH_MS while it waits.\n */\nexport function claimPath(dir: string): string {\n return join(dir, \"daemon.claim\");\n}\n\nconst CLAIM_TOUCH_MS = 1_000;\n/** A claim not touched for that long is a start that ended without removing it (killed): none. */\nconst CLAIM_FRESH_MS = 10_000;\n\n/**\n * The pid of the `daemon restart` or `daemon --detach` that keeps the profile for the daemon it starts, from the stop\n * of the old one until the new one holds the profile: the lock is free in between, and one-shot commands that kept\n * taking it in turn (a bot's typing indicator every few seconds) left the new daemon, seconds to boot, never finding\n * it free. Null when no live start claims it.\n */\nexport function daemonClaim(paths: ProfilePaths): number | null {\n const file = claimPath(paths.dir);\n let pid: number;\n try {\n if (Date.now() - statSync(file).mtimeMs > CLAIM_FRESH_MS) return null;\n pid = Number(readFileSync(file, \"utf8\").trim());\n } catch { return null; }\n if (!Number.isInteger(pid) || pid <= 0) return null;\n try { process.kill(pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EPERM\") return null; }\n return pid;\n}\n\n/**\n * Keeps the profile for the daemon this process starts (`daemonClaim`): until the function it returns is called, only\n * this process and its children take the profile's lock; any other command waits for the daemon's socket instead.\n * Another live start's claim stands (its daemon is the one that comes up); a claim that cannot be written is none.\n */\nexport function claimForDaemon(paths: ProfilePaths): () => void {\n if (daemonClaim(paths) !== null) return () => {};\n const mine = String(process.pid), file = claimPath(paths.dir), draft = `${file}.${mine}`;\n try {\n writeFileSync(draft, mine, { mode: 0o600 });\n renameSync(draft, file);\n } catch {\n rmSync(draft, { force: true });\n return () => {};\n }\n const ours = () => { try { return readFileSync(file, \"utf8\").trim() === mine; } catch { return false; } };\n const touch = setInterval(() => {\n if (!ours()) return;\n const now = new Date();\n try { utimesSync(file, now, now); } catch { /* removed meanwhile */ }\n }, CLAIM_TOUCH_MS);\n touch.unref();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n clearInterval(touch);\n if (ours()) rmSync(file, { force: true });\n };\n}\n\n/**\n * The daemon's socket: in the profile's folder, unless that path is longer than a Unix socket may be (104 bytes on\n * macOS); then in a folder of the user's runtime folder named after the profile's (`runtimePath`), which the daemon\n * makes owner-only and checks before use (`privateFolder`), and whose socket a client connects to only when it is this\n * user's (`ownSocket`).\n */\nfunction socketPath(dir: string): string {\n const inside = join(dir, \"daemon.sock\");\n if (process.platform === \"win32\") return `\\\\\\\\.\\\\pipe\\\\ghostly-${createHash(\"sha256\").update(dir).digest(\"hex\").slice(0, 24)}`;\n if (Buffer.byteLength(inside) <= 100) return inside;\n return runtimePath(\"ghostly\", dir, \"daemon.sock\");\n}\n\nfunction ensureFolder(path: string): void {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n}\n\n/** Makes the profile's folder; refused when it exists and `existing` is not allowed. */\nexport function createProfile(home: string, name: string, { existing = false } = {}): ProfilePaths {\n const paths = profilePaths(home, name);\n if (existsSync(paths.dir) && !existing) throw new CliError(\"refused\", `Profile ${name} exists`);\n ensureFolder(join(home, \"profiles\"));\n ensureFolder(paths.dir);\n return paths;\n}\n\n/**\n * A file in the folder of a profile a restore made, until its engine starts for the first time: the store came back\n * whole, as the backup held it, and the money in it is then treated as every restore treats it (WISP 05 § Restoring).\n */\nexport const RESTORED_MARK = \"restored\";\n\nexport function profileExists(home: string, name: string): boolean {\n return existsSync(profileDir(home, name));\n}\n\nexport function listProfiles(home: string): string[] {\n const root = join(home, \"profiles\");\n if (!existsSync(root)) return [];\n return readdirSync(root).filter((name) => NAME.test(name) && statSync(join(root, name)).isDirectory()).sort();\n}\n\n/** A profile this home lacks, as `profile use` and `--profile` both say it: quoted, with how to list or make one. */\nexport const noProfile = (name: string): CliError =>\n new CliError(\"not_found\", `No profile ${JSON.stringify(name)} (ghostly profile list, or ghostly profile create ${name})`);\n\nexport function selectProfile(home: string, name: string): void {\n if (!profileExists(home, name)) throw noProfile(name);\n ensureFolder(home);\n writeFileSync(join(home, \"current\"), name + \"\\n\", { mode: 0o600 });\n}\n\n/**\n * One process per profile: the daemon or a one-shot command. The lock holds the owner's pid; a lock whose\n * process is gone is taken over.\n *\n * The lock is a link to a file that already holds the pid, so it never exists empty (agents#1642): one made by\n * `openSync` + `writeSync` was empty for a moment, and another process read that as nobody's and removed it under its\n * owner. An empty lock younger than `EMPTY_LOCK_GRACE_MS` is still an older release's being written: busy. A stale\n * lock is moved aside before it is removed, and only when what was moved is the file judged stale: one that vanished,\n * or that another process made since, is no longer removed.\n *\n * The lock stays the bare pid, as older releases read it; beside it, `<lock>.<pid>.start` holds when that process\n * started (`processStart`). A lock left by a process that died without releasing it (kill -9, Ctrl-C of a one-shot, a\n * reboot) whose pid now belongs to another process is then stale too: it held the profile for good, every command busy\n * until someone found the file. It is written before the lock is placed, so a lock of this release never lacks it for\n * a moment; one without it (an older release's) is held while its pid is alive, as before.\n *\n * While a `daemon restart` or `daemon --detach` keeps the profile for the daemon it starts (`daemonClaim`), it is busy\n * for every other process: a one-shot then waits for that daemon's socket (`openOneShot`).\n */\nexport function acquireLock(paths: ProfilePaths): () => void {\n // Kept for the daemon a start brings up (`daemonClaim`): its own process and the daemon it spawns take it, no other.\n const claim = daemonClaim(paths);\n if (claim !== null && claim !== process.pid && claim !== process.ppid) throw new CliError(\"busy\", `Profile ${paths.name} is kept for the daemon that process ${claim} starts`, { pid: claim });\n const mine = String(process.pid);\n const draft = `${paths.lock}.${mine}`;\n const start = startPath(paths.lock, process.pid);\n const started = processStart(process.pid);\n let placed = false;\n writeFileSync(draft, mine, { mode: 0o600 });\n if (started !== null) writeFileSync(start, started, { mode: 0o600 });\n try {\n for (let attempt = 0; attempt < 3; attempt++) {\n if (placeLock(draft, paths.lock, mine)) {\n placed = true;\n heldHere.add(paths.lock);\n let released = false;\n return () => {\n if (released) return;\n released = true;\n heldHere.delete(paths.lock);\n try { if (readFileSync(paths.lock, \"utf8\").trim() === mine) rmSync(paths.lock, { force: true }); } catch { /* gone already */ }\n rmSync(start, { force: true });\n };\n }\n let seen: Stats;\n try { seen = lstatSync(paths.lock); } catch { continue; }\n const owner = lockOwner(paths);\n if (owner !== null) throw new CliError(\"busy\", `Profile ${paths.name} is in use by process ${owner}`, { pid: owner });\n if (seen.size === 0 && Date.now() - seen.mtimeMs < EMPTY_LOCK_GRACE_MS) break;\n removeStaleLock(paths.lock, seen);\n }\n } finally {\n rmSync(draft, { force: true });\n if (!placed) rmSync(start, { force: true });\n }\n throw new CliError(\"busy\", `Profile ${paths.name} is in use`);\n}\n\n/** The locks this process holds: a lock naming this pid that is not one of them is a dead holder's whose pid it has now. */\nconst heldHere = new Set<string>();\n\nfunction startPath(lock: string, pid: number): string {\n return `${lock}.${pid}.start`;\n}\n\n/**\n * When the process `pid` started, as a text that is the same for as long as it runs and another for the next process\n * given that pid; null where it cannot be read (Windows, a `/proc` that hides others' processes, no `ps`). On Linux the\n * boot's id and `/proc/<pid>/stat`'s start time (clock ticks since boot); elsewhere `ps -o lstart=`.\n */\nexport function processStart(pid: number): string | null {\n try {\n if (process.platform === \"linux\") {\n const stat = readFileSync(`/proc/${pid}/stat`, \"utf8\");\n // Fields after the command, which may hold spaces and parentheses: the start time is field 22.\n const ticks = stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n if (!ticks || !/^\\d+$/.test(ticks)) return null;\n return `${readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\").trim()} ${ticks}`;\n }\n if (process.platform === \"win32\") return null;\n const lstart = execFileSync(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(pid)], {\n encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"], timeout: 2_000, env: { ...childEnv(), LC_ALL: \"C\" },\n }).trim();\n return lstart || null;\n } catch {\n return null;\n }\n}\n\n/** How long an empty lock is taken for one an older release is still writing its pid into. */\nconst EMPTY_LOCK_GRACE_MS = 1_000;\n\n/**\n * Links `draft` (which holds `mine`) as the lock; false when there is a lock already. Where the file system has no\n * hard links, the lock is made in place, as before.\n */\nfunction placeLock(draft: string, lock: string, mine: string): boolean {\n try {\n linkSync(draft, lock);\n return true;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === \"EEXIST\") return false;\n if (![\"EPERM\", \"ENOTSUP\", \"EOPNOTSUPP\", \"ENOSYS\"].includes(code ?? \"\")) throw error;\n }\n let fd: number;\n try { fd = openSync(lock, \"wx\", 0o600); } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"EEXIST\") return false;\n throw error;\n }\n writeSync(fd, mine);\n closeSync(fd);\n return true;\n}\n\n/**\n * Removes the lock judged stale (`seen`): it is moved aside first, and removed only when what was moved is that same\n * file and holds no live pid (a freed inode is soon reused). A lock another process made in the meantime is put back.\n */\nfunction removeStaleLock(lock: string, seen: Stats): void {\n const aside = `${lock}.stale.${process.pid}`;\n try { renameSync(lock, aside); } catch { return; }\n try {\n const moved = lstatSync(aside);\n if (moved.ino === seen.ino && moved.dev === seen.dev && holder(aside, lock) === null && moved.size === seen.size) {\n const pid = lockPid(aside);\n if (pid !== null && pid !== process.pid) rmSync(startPath(lock, pid), { force: true });\n return;\n }\n try { linkSync(aside, lock); } catch { /* another lock is there already */ }\n } finally {\n rmSync(aside, { force: true });\n }\n}\n\n/**\n * The pid holding the profile, or null when nobody does: the lock's process is gone, or its pid is another process's\n * now (it started at another time than the lock's holder, or it is this process, which does not hold the lock).\n */\nexport function lockOwner(paths: ProfilePaths): number | null {\n return holder(paths.lock, paths.lock);\n}\n\nfunction lockPid(file: string): number | null {\n let pid: number;\n try { pid = Number(readFileSync(file, \"utf8\").trim()); } catch { return null; }\n return Number.isInteger(pid) && pid > 0 ? pid : null;\n}\n\n/** `file`: the lock, or the stale one moved aside; `lock`: the lock's own path, beside which its start is. */\nfunction holder(file: string, lock: string): number | null {\n const pid = lockPid(file);\n if (pid === null) return null;\n if (pid === process.pid) return heldHere.has(lock) ? pid : null;\n try { process.kill(pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EPERM\") return null; }\n let recorded: string;\n try { recorded = readFileSync(startPath(lock, pid), \"utf8\").trim(); } catch { return pid; }\n const now = processStart(pid);\n return recorded && now !== null && now !== recorded ? null : pid;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAaA,SAAgB,YAAY,QAAgB,YAAoB,MAAsB;CACpF,MAAM,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;CAC9E,KAAK,MAAM,QAAQ,CAAC,QAAQ,IAAI,iBAAiB,OAAO,CAAC,GAAG;EAC1D,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,IAAI,GAAG;EACrD,MAAM,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ,IAAI;EACjD,IAAI,OAAO,WAAW,IAAI,KAAK,KAAK,OAAO,cAAc,IAAI;CAC/D;CACA,OAAO,cAAc,KAAK,QAAQ,GAAG,OAAO,GAAG,QAAQ,SAAS,KAAK,EAAE,GAAG,QAAQ,IAAI,CAAC;AACzF;;AAGA,IAAM,iCAAiB,IAAI,IAAY;AAEvC,SAAS,cAAc,MAAsB;CAC3C,eAAe,IAAI,QAAQ,IAAI,CAAC;CAChC,OAAO;AACT;;;;;;;;AASA,SAAgB,kBAAkB,QAAsB;CACtD,MAAM,SAAS,QAAQ,MAAM;CAC7B,IAAI,QAAQ,aAAa,WAAW,CAAC,eAAe,IAAI,MAAM,GAAG;CACjE,IAAI;EAC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ider, r as identityProviders } from "./registry-
|
|
1
|
+
export { t as IDENTITY_PROVIDERS, n as identityProvider, r as identityProviders } from "./registry-CPuexTle.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as fromZ32, d as utf8Decode, f as utf8Encode, i as fromBase64Url, l as toBase64Url, n as concatBytes, o as isZ32Key, s as randomBytes, t as bytesEqual, u as toZ32 } from "./bytes-C1DNGY18.js";
|
|
2
2
|
import { a as domainWellKnownFile, i as domainTxtRecord, l as normalizeDomain, m as wellKnownUrl, r as dnsProofName } from "./domainProofs-b3Y1Gj9g.js";
|
|
3
|
-
import { C as isAtprotoDid, D as verifyAtprotoRecordProof, E as AtprotoProofError, S as checkAtprotoProofRecord, T as shortAtprotoDid, _ as ATPROTO_FULL_SCOPE, a as verifiedAtprotoHandle, b as atprotoProofRecord, c as assertDomainRecord, d as chosenResolver, f as resolverById, g as ATPROTO_DECLARED_SCOPE, i as resolveAtprotoHandle, l as assertNip05, m as pkarrRelays, r as resolveAtprotoDid, s as DomainCheckError, t as assertPublicServer, u as assertPublicHost, v as ATPROTO_PROOF_COLLECTION, w as normalizeAtprotoHandle, x as atprotoProofRkey, y as ATPROTO_PROOF_SCOPE } from "./resolve-
|
|
4
|
-
import { _ as sshSignCommand, a as PUBKY_RELAYS, c as isConfigured, d as providerForIssuer, g as parseSshSignature, h as parseSshPublicKey, i as validForgeLogin, l as issuerFor, m as SshSigError, n as SSH_FORGE_LABEL, o as audiences, p as SSHSIG_NAMESPACE, r as checkSshForge, s as clientIdFor, t as SSH_FORGE_HOST, u as oidcProviders, v as verifySshSignature } from "./sshForges-
|
|
5
|
-
import { s as IdentityCheckUnavailable } from "./identityProofs-
|
|
6
|
-
import { C as normalizePubkyKey, E as pubkyProofPath, S as newPubkyProofFolder, T as pubkyProofFile, _ as resolveDidDht, b as isPubkyKey, c as boundedIdentityFetch, f as DidDhtError, i as registeredIdentityProviders, s as reserveAdapterIds, t as ownDid, u as testBuild, w as pubkyProofCapability, x as isPubkyProofFolder, y as PUBKY_PROOF_MAX_BYTES } from "./ownDid-
|
|
3
|
+
import { C as isAtprotoDid, D as verifyAtprotoRecordProof, E as AtprotoProofError, S as checkAtprotoProofRecord, T as shortAtprotoDid, _ as ATPROTO_FULL_SCOPE, a as verifiedAtprotoHandle, b as atprotoProofRecord, c as assertDomainRecord, d as chosenResolver, f as resolverById, g as ATPROTO_DECLARED_SCOPE, i as resolveAtprotoHandle, l as assertNip05, m as pkarrRelays, r as resolveAtprotoDid, s as DomainCheckError, t as assertPublicServer, u as assertPublicHost, v as ATPROTO_PROOF_COLLECTION, w as normalizeAtprotoHandle, x as atprotoProofRkey, y as ATPROTO_PROOF_SCOPE } from "./resolve-BqmGXKn4.js";
|
|
4
|
+
import { _ as sshSignCommand, a as PUBKY_RELAYS, c as isConfigured, d as providerForIssuer, g as parseSshSignature, h as parseSshPublicKey, i as validForgeLogin, l as issuerFor, m as SshSigError, n as SSH_FORGE_LABEL, o as audiences, p as SSHSIG_NAMESPACE, r as checkSshForge, s as clientIdFor, t as SSH_FORGE_HOST, u as oidcProviders, v as verifySshSignature } from "./sshForges-Cqt3qfWe.js";
|
|
5
|
+
import { s as IdentityCheckUnavailable } from "./identityProofs-zI_Iy9uI.js";
|
|
6
|
+
import { C as normalizePubkyKey, E as pubkyProofPath, S as newPubkyProofFolder, T as pubkyProofFile, _ as resolveDidDht, b as isPubkyKey, c as boundedIdentityFetch, f as DidDhtError, i as registeredIdentityProviders, s as reserveAdapterIds, t as ownDid, u as testBuild, w as pubkyProofCapability, x as isPubkyProofFolder, y as PUBKY_PROOF_MAX_BYTES } from "./ownDid-CwxFBzOH.js";
|
|
7
7
|
import { c as openRelayPayload, f as decodeDnsAnswers, h as readDnsName, i as RELAY_PAYLOAD_MAX_BYTES } from "./pkarr-BQo4PcCg.js";
|
|
8
8
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
9
9
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
@@ -3699,25 +3699,37 @@ function previewOf(r, say) {
|
|
|
3699
3699
|
const unusable = r.document.keys.length - keys.length + r.document.skipped;
|
|
3700
3700
|
if (!keys.length && r.method !== "web") throw new DidError("This DID lists no Ed25519, secp256k1 or P-256 key for authentication or assertionMethod, so it cannot sign");
|
|
3701
3701
|
const method = `did:${r.method}`;
|
|
3702
|
-
const facts = [{
|
|
3702
|
+
const facts = [r.method === "key" || r.method === "jwk" ? {
|
|
3703
3703
|
label: say("preview.method", "Method"),
|
|
3704
|
-
value:
|
|
3704
|
+
value: say("preview.keyIsIdentifier", "{{method}}, the key is the identifier", { method })
|
|
3705
|
+
} : {
|
|
3706
|
+
label: say("preview.method", "Method"),
|
|
3707
|
+
value: method,
|
|
3708
|
+
code: true
|
|
3705
3709
|
}];
|
|
3706
3710
|
if (r.host) facts.push({
|
|
3707
3711
|
label: say("preview.domain", "Domain"),
|
|
3708
|
-
value: r.host
|
|
3712
|
+
value: r.host,
|
|
3713
|
+
code: true
|
|
3709
3714
|
});
|
|
3710
3715
|
if (r.documentUrl) facts.push({
|
|
3711
3716
|
label: say("preview.document", "Document"),
|
|
3712
|
-
value: r.documentUrl
|
|
3717
|
+
value: r.documentUrl,
|
|
3718
|
+
code: true
|
|
3713
3719
|
});
|
|
3714
3720
|
if (r.relay) facts.push({
|
|
3715
3721
|
label: say("preview.relay", "Relay"),
|
|
3716
|
-
value: r.relay.replace(/^https:\/\//, "")
|
|
3722
|
+
value: r.relay.replace(/^https:\/\//, ""),
|
|
3723
|
+
code: true
|
|
3717
3724
|
});
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3725
|
+
const label = keys.length === 1 ? say("preview.key", "Key") : say("preview.keys", "Keys");
|
|
3726
|
+
facts.push(keys.length ? {
|
|
3727
|
+
label,
|
|
3728
|
+
value: keys.map((k) => `${fragment(k.id)} (${k.curve})`).join(", "),
|
|
3729
|
+
code: true
|
|
3730
|
+
} : {
|
|
3731
|
+
label,
|
|
3732
|
+
value: say("preview.noKeys", "none that can sign: publish instead")
|
|
3721
3733
|
});
|
|
3722
3734
|
if (unusable > 0) facts.push({
|
|
3723
3735
|
label: say("preview.notUsable", "Not usable"),
|
|
@@ -5027,4 +5039,4 @@ function identityProvider(id, providers = identityProviders()) {
|
|
|
5027
5039
|
}
|
|
5028
5040
|
export { SignerTimeout as a, parseProofBunker as i, identityProvider as n, identityProviders as r, IDENTITY_PROVIDERS as t };
|
|
5029
5041
|
|
|
5030
|
-
//# sourceMappingURL=registry-
|
|
5042
|
+
//# sourceMappingURL=registry-CPuexTle.js.map
|