From 4457d97f943b56fbd2695f8449a34e1f939d8f6e Mon Sep 17 00:00:00 2001 From: Ty J Everett Date: Tue, 27 Oct 2026 08:54:50 -0700 Subject: [PATCH] Declare complete grouped wallet permissions and unify Mountaintops branding --- README.md | 8 ++ frontend/index.html | 6 +- frontend/public/manifest.json | 96 +++++++++++++++++++ frontend/public/mountaintops-192.png | Bin 0 -> 4164 bytes frontend/public/mountaintops-512.png | Bin 0 -> 15195 bytes frontend/public/mountaintops.svg | 5 + frontend/src/App.tsx | 6 +- frontend/src/actions.ts | 5 +- frontend/src/coins.ts | 3 +- frontend/src/recordActions.ts | 3 +- frontend/src/style.css | 2 +- frontend/src/walletActionState.ts | 37 +++++--- frontend/src/walletScopes.ts | 5 + frontend/test/permissions.test.mjs | 133 +++++++++++++++++++++++++++ 14 files changed, 288 insertions(+), 21 deletions(-) create mode 100644 frontend/public/manifest.json create mode 100644 frontend/public/mountaintops-192.png create mode 100644 frontend/public/mountaintops-512.png create mode 100644 frontend/public/mountaintops.svg create mode 100644 frontend/src/walletScopes.ts create mode 100644 frontend/test/permissions.test.mjs diff --git a/README.md b/README.md index 94a7f3e..89c1643 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,11 @@ npm run deploy The root uses current CARS CLI. Releases require operator-owned Evans safety gates, isolated canary rendering/drain qualification, continuous probes of custom and generated domains, exact deployed-asset verification, and two Ready serving endpoints on distinct nodes. `ops/canary.Dockerfile` supports a Linux/amd64 remote qualification image of the same frontend source; it adds no application backend. Deployment records, images, routing, release credentials and rollback evidence belong in network-ops. After publishing addresses, rollback must preserve this wallet record format, expiration blocks and access to all saved key IDs. Do not roll back to the old single-address frontend. Retain the accepted compatible frontend image and use forward repair or a compatible image rollback; never delete wallet recovery outputs or resume expired-address discovery. + +## Wallet permission group and branding + +`/manifest.json` declares the complete BRC-116 group under `metanet`: identity retrieval, the unchanged Mountaintops derivation/signing protocol, self-only `[2, "mntops v1"]` SDK LocalKVStore encryption/signature checks, both app baskets, all three fixed action-label protocols, and a 100,000-satoshi monthly spending allowance for payments and wallet/network fees. The wallet presents this declaration for user consent; it is not a grant or a hard transfer limit. Above-allowance payments require further wallet approval. No certificate or peer-trust scope is requested. See the [BRC-116 specification](https://github.com/bsv-blockchain/BRCs/blob/master/wallet/0116.md). + +New actions use fixed labels and native TXIDs, avoiding a new label permission for every request. Older UUID-labelled actions remain recoverable by reading the common app label and matching their TXID or legacy label in returned metadata. No transaction UI history is persisted. + +The header and favicon use the same authored `/mountaintops.svg`. Wallet/PWA icons and the touch icon are PNG renders of that source at 192 and 512 pixels. Keep all variants in sync when changing the logo. The unused legacy Vite file remains only for cached old HTML during compatible releases; the current app and manifest never reference it. diff --git a/frontend/index.html b/frontend/index.html index 61fac87..310907e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,7 +3,11 @@ - + + + + + Mountaintops | Shout BSV with no privacy. diff --git a/frontend/public/manifest.json b/frontend/public/manifest.json new file mode 100644 index 0000000..a64864b --- /dev/null +++ b/frontend/public/manifest.json @@ -0,0 +1,96 @@ +{ + "id": "/", + "name": "Mountaintops", + "short_name": "Mountaintops", + "description": "Receive and send public BSV payments with your BRC-100 wallet.", + "start_url": "/", + "scope": "/", + "display": "standalone", + "theme_color": "#142630", + "background_color": "#101b23", + "icons": [ + { + "src": "/mountaintops-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/mountaintops-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/mountaintops.svg", + "sizes": "any", + "type": "image/svg+xml", + "purpose": "any" + } + ], + "metanet": { + "schemaVersion": 1, + "groupPermissions": { + "description": "Use Mountaintops to recover addresses and payments, save receiving choices, and send BSV.", + "protocolPermissions": [ + { + "protocolID": [ + 1, + "identity key retrieval" + ], + "description": "Restore the addresses belonging to your wallet account." + }, + { + "protocolID": [ + 1, + "mountaintops" + ], + "description": "Derive your receiving addresses and sign imports of your coins." + }, + { + "protocolID": [ + 2, + "mntops v1" + ], + "counterparty": "self", + "description": "Encrypt, sign, verify, and recover your saved addresses, receiving choice, and recovery records." + }, + { + "protocolID": [ + 1, + "action label mountaintops actions v1" + ], + "description": "Find unfinished Mountaintops actions and prevent duplicate payments." + }, + { + "protocolID": [ + 1, + "action label mountaintops record v1" + ], + "description": "Identify saved address and recovery records." + }, + { + "protocolID": [ + 1, + "action label mountaintops receipts v1" + ], + "description": "Identify retained payment evidence for your addresses." + } + ], + "basketAccess": [ + { + "basket": "mntops v1", + "description": "Read and save encrypted address and recovery records." + }, + { + "basket": "mountaintops receipts v1", + "description": "Retain and recover transaction evidence for coins sent to your addresses." + } + ], + "spendingAuthorization": { + "amount": 100000, + "description": "Allow up to 100,000 satoshis per month for BSV payments and wallet/network fees. Amounts above the allowance need separate wallet approval." + } + } + } +} diff --git a/frontend/public/mountaintops-192.png b/frontend/public/mountaintops-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b68fd9c64755b28f8db20ce6bb4cc739c303ba88 GIT binary patch literal 4164 zcmX|Fc|26z|G(pEMz#@=tRuU~Sck-n?V+N^z9c;Mog`#w?w~9!mLfwToGN>-+ltet+D1-mi1c=Y2k(&%Ni|_va=OuNZN#3a|nIz;V&oz#ML= zM;8kczMGHvq2T6tkg?rO0AS-ex)4CtGkyR-Z(TIdwG4l@e4Q=Gs^zqf_;Y)$s!QF- zD6FAZXkfTRt&+?0E2+v=eT{$d_R6sG79`}$Fjeat`TLS7KBCpO%`+hLvBD0o8|B;* zP#Pw~s7Zx;{U;@bE3-nlDrNaMSrqE0&6-yWRGv9IF8DWk_)jh&~)_9myyKLNTWu1Ag;SSCrP2|Ke zb)MA|tygtJup-_)jo#Tw598MV@jg97`p$a!a)D;7pA_H71IDTR_+N=^oPMngR~6dp zFTpBr@~U;@rL&2jnQbByazb)r`+QoRRg}6|FNsq=*^E9=6gPQ4lZ2){{u$JJsmL}< zCw!PUBl)|b5B(2*JYrgZM?ww#McUZFq_Q-|F(cPrG)paoNSBR6PxAz7443BL>_mU@ zhO2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tu6S-i=q*az_K0>}z;KI&Q98HZM z$V}OxfO3PItN0l~YdL#3`A0uo6af~R^I)W+$}C&9Jt4nz;#AKXNFKe zjfGFh>IV-V+^_Ju!pH;9oL|0O=+q#1uA;_zc{9mvNME^|Jy?*A@06X1+Cx6phO;S(nGur}sifAhA6zePnVQD@|l z!MUoYvHr-@{;kr_>Q(x8peSfT^QGDKg=H4e$%X6BrPO%6i~G*Abmr)0hMOsPnM?1C zm{@A6A%*6IFT|SDUJ7Wb-Sd&}`5d`r*t8R(Hs~L3;T6C@>C4(`NCs_6z`q56i-uPW J%JiIL{sZYRz7qfd literal 0 HcmV?d00001 diff --git a/frontend/public/mountaintops-512.png b/frontend/public/mountaintops-512.png new file mode 100644 index 0000000000000000000000000000000000000000..042fc25c039c05f1fc3c6648bd6a84157ec2f523 GIT binary patch literal 15195 zcmZ8o2|QHY`@dskizte$^GZZnin1G|5TdkOi$dNI*_RoilFE{@Z@nTEB|?^&7W-PV zX3JXku`grhf9@>u`}fhO+;^&Gx#7PEC_a%7f>4mYj@CJ^#Hl3KXp8I5X7WTI9=P{om5sg8 z>~e%kruNmgqWUALqUUUoJKm+R3%TF}m-%@)nG+qxSk25T5sZSCIUKL<%_XWl>%Yus$TEC;#f72C%t}j3E^9d1Y%Fmj$t|G&3b`$}U2K`OJoD4H|LTlc&g~z~ z!K@bd!&7XH71EOUb(S{7qhuK)%jAukXo-ad>G=eitQj3BO}c9m;4B)tQy34i z+aHlj3`=e_*!WT+6?H=E0M1Q$GRu6_HQs#O)!a0!K*)D8$Le*Gr*fiscwEoXw5-bH z-N8%T;?V+zV#~~t|4IZt#b1S(va2+?YLCSrjqLM0mA{RgjM*n?koY;}HuqGdc$DI{ zNWaQpj|*JgLfyPOej(WL*co=lNTDNKo6D2~>;pA3d#_;-t{rdUTS#3& zVRtD5huJ%;jqG{jO)B~X-OF+>;L>OuU(nZHwIK zYi-2O7dSFz+Ga`?NNh{<`>B&3XluG^d;C)%f^YUYLe*Y${Y`4&{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2n<=fIJ=gv)PaVg`l36h~4mg`z?6s+C}+-oIMg#t?f(N+}+EBA#L*jHp+2|SUdEX z2piZ?-&I$vRr2()J>vLiozOBZ#u~v0g!DHDpAN2eQj#FDTe7oMRd+^C9*CXIi(JPStrRV34?ikB6 zcC$4G`{re?F5SYbC#Vu^q}P_dp`ucrr2JUrmlDp*9lD^t19Md_>V&ywlpGxX;2Ey8 z&c9>g`mI|=(dwtaRD&Z5FGGg~v<_@+p5{A){>eEq(U`XTl(59qd|AfZp5R4#kak0!QF?L3NZR#AOSez3hsKyomERMU>D{`DA+GmA zRW!z{&i3>n+ILMz2!eD>G{gWsx$3Mg=9|uRzZUp|Ds6<{Lw#gS|?ZA`tJV$`&*=t literal 0 HcmV?d00001 diff --git a/frontend/public/mountaintops.svg b/frontend/public/mountaintops.svg new file mode 100644 index 0000000..5e8fc12 --- /dev/null +++ b/frontend/public/mountaintops.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ba28ee9..4697876 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,6 +7,7 @@ import { readCoverage, type Coverage } from './coverageClient.ts' import { refreshCoins, type Coin } from './coins.ts' import { importCoins, sendCoins, unfinishedWalletActions } from './actions.ts' import { preferCompatibleTransport } from './walletClient.ts' +import { assertWalletActionFinal } from './walletActionState.ts' import './style.css' const client = new WalletClient('auto') @@ -217,7 +218,7 @@ export default function Mountaintops() { } return
-

Mountaintops

Public BSV payments.

+

Mountaintops

Public BSV payments.

{!session ?

Your BSV, ready to receive.

Connect your wallet to find your addresses and payments.

Use the same BRC-100 wallet on any device.

: <> {pendingActions.length > 0 &&

Check your wallet before continuing

A previous payment has no final result yet. Do not send it again.

{pendingActions.map(action =>
Payment details

{String(action.state)} {action.txid ? `· ${String(action.txid)}` : ''}

)}
} diff --git a/frontend/src/actions.ts b/frontend/src/actions.ts index 2aa6ff6..d2bfcef 100644 --- a/frontend/src/actions.ts +++ b/frontend/src/actions.ts @@ -7,6 +7,7 @@ import Importer from './Importer.ts' import type { WalletRecords } from './walletRecords.ts' import { assertInputsUnspent } from './inputChecks.ts' import { unfinishedWalletActions } from './walletActionState.ts' +import { ACTION_LABEL } from './walletScopes.ts' export { unfinishedWalletActions } from './walletActionState.ts' export function parseSatoshis(bsv: string): number { @@ -34,8 +35,6 @@ export function assertSameTemplate(before: Transaction, after: Transaction): voi // external coins. Signed noSend actions can be aborted by TXID on a fresh device. export async function eligibleAction(wallet: WalletInterface, store: WalletRecords, args: CreateActionArgs, coverage: Coverage, progress: Progress, coins: Coin[] = [], recipient?: string): Promise { - const id = crypto.randomUUID() - const requestLabel = `mountaintops request ${id}` if ((await unfinishedWalletActions(wallet, store.network)).length) throw new Error('Review the unfinished wallet action before another payment.') let reference: string | undefined let signedTxid: string | undefined @@ -45,7 +44,7 @@ export async function eligibleAction(wallet: WalletInterface, store: WalletRecor let nonce = 0 while (performance.now() - started < 30_000) { progress(`Preparing an eligible transaction (attempt ${nonce + 1}). Your wallet may request permission; payment fees apply to the submitted payment.`) - const prepared = await wallet.createAction({ ...args, version: 1, lockTime: nonce++, labels: [...(args.labels ?? []), 'mountaintops actions v1', requestLabel], options: { signAndProcess: false, noSend: true, returnTXIDOnly: false, randomizeOutputs: false } }) + const prepared = await wallet.createAction({ ...args, version: 1, lockTime: nonce++, labels: [...(args.labels ?? []), ACTION_LABEL], options: { signAndProcess: false, noSend: true, returnTXIDOnly: false, randomizeOutputs: false } }) if (!prepared.signableTransaction) throw new Error('The wallet did not return a signable transaction; no automatic retry is safe.') reference = prepared.signableTransaction.reference const tx = Transaction.fromAtomicBEEF(prepared.signableTransaction.tx) diff --git a/frontend/src/coins.ts b/frontend/src/coins.ts index 8a418af..42030d0 100644 --- a/frontend/src/coins.ts +++ b/frontend/src/coins.ts @@ -5,6 +5,7 @@ import { addressMatches, assertReceivable, canonicalKeyID, transactionMatches } import { validateAddress } from './addressBook.ts' import { whatsOnChainFetch } from './whatsOnChainClient.ts' import getBeefForTxid from './getBeefForTxid.ts' +import { RECEIPT_LABEL } from './walletScopes.ts' import type { WalletRecords } from './walletRecords.ts' export const COIN_BASKET = 'mountaintops receipts v1' @@ -72,7 +73,7 @@ async function retainCoins(wallet: WalletInterface, entry: AddressRecord, coins: async function saveCoinEvidence(wallet: WalletInterface, entry: AddressRecord, beef: Beef, outputs: Coin[]): Promise { const txid = outputs[0].txid await wallet.internalizeAction({ - tx: beef.toBinaryAtomic(txid), description: 'Retain Mountaintops deposit evidence', labels: ['mountaintops receipts v1'], + tx: beef.toBinaryAtomic(txid), description: 'Retain Mountaintops deposit evidence', labels: [RECEIPT_LABEL], outputs: outputs.map(coin => ({ outputIndex: coin.vout, protocol: 'basket insertion', insertionRemittance: { basket: COIN_BASKET, tags: [`address ${entry.address}`], customInstructions: JSON.stringify({ v: 1, network: entry.network, ...coin }) } })) diff --git a/frontend/src/recordActions.ts b/frontend/src/recordActions.ts index 5320a42..eb09216 100644 --- a/frontend/src/recordActions.ts +++ b/frontend/src/recordActions.ts @@ -1,6 +1,7 @@ import { Transaction, type WalletInterface } from '@bsv/sdk' import type { Network } from '../../shared/brc234.ts' import { assertInputsUnspent } from './inputChecks.ts' +import { ACTION_LABEL, RECORD_LABEL } from './walletScopes.ts' type Prepared = { tx: Transaction; txid?: string; submitted: boolean } @@ -19,7 +20,7 @@ export class RecordActions { this.wallet = new Proxy(original, { get: (target, property) => { if (property === 'createAction') return async (...[args, originator]: Parameters) => { if (args.options?.signAndProcess !== false || args.options?.sendWith?.length) throw new Error('Wallet record must be prepared before submission.') - const result = await original.createAction({ ...args, labels: [...(args.labels ?? []), 'mountaintops actions v1', 'mountaintops record v1', `mountaintops request ${crypto.randomUUID()}`], options: { ...args.options, noSend: true, returnTXIDOnly: false } }, originator) + const result = await original.createAction({ ...args, labels: [...(args.labels ?? []), ACTION_LABEL, RECORD_LABEL], options: { ...args.options, noSend: true, returnTXIDOnly: false } }, originator) if (result.signableTransaction) this.prepared.set(result.signableTransaction.reference, { tx: Transaction.fromAtomicBEEF(result.signableTransaction.tx), submitted: false }) return result } diff --git a/frontend/src/style.css b/frontend/src/style.css index 1cd1854..131d577 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -1,3 +1,3 @@ -:root{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#edf3f5;background:#101b23;font-synthesis:none;color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:linear-gradient(#101b2355,#101b23ee 680px),url('/mountains.jpg') center top/cover fixed;min-height:100vh}main{max-width:760px;margin:auto;padding:40px 24px 32px}header{margin:0 0 32px}.brand{display:flex;align-items:center;gap:10px}.mountain-mark{font-size:2.5rem;line-height:1;color:#b9dbd1}h1{font-size:1.6rem;letter-spacing:-.04em;margin:0}header p{color:#b7c9cd;font-size:.95rem;margin:8px 0 0 42px}h2{font-size:1.55rem;letter-spacing:-.03em;margin:0 0 12px}h3{font-size:1.05rem;margin:0}p{line-height:1.55;margin:12px 0}section{background:#142630f7;border:1px solid #344b55;border-radius:18px;padding:28px;margin:18px 0;box-shadow:0 16px 48px #0002}.view-tabs{display:flex;align-items:center;gap:4px;border-bottom:1px solid #40535a;padding-bottom:10px}.view-tabs button{background:transparent;color:#b8cbd1;padding:9px 22px}.view-tabs button[aria-pressed=true]{background:#e2f1ed;color:#15342e}.connection{margin-left:auto;font-size:.8rem;color:#a6c0b6}.receive-panel{padding:0;overflow:hidden}.address-card{padding:24px;border:1px solid #3b535d;border-radius:12px;background:#19303a;margin:14px 0}.address-card.selected{background:transparent;margin:0;border:0;border-radius:0;padding:28px}.card-heading{display:flex;align-items:center;gap:12px;justify-content:space-between;margin-bottom:18px}.selected h3{font-size:1.3rem;letter-spacing:-.02em}.badge{background:#264d43;color:#b9e4d2;border-radius:20px;padding:4px 9px;font-size:.72rem;font-weight:650;white-space:nowrap}.badge.caution{background:#61422c;color:#ffe0b1}.address{display:block;overflow-wrap:anywhere;background:#0e2029;border:1px solid #344e59;border-radius:9px;padding:16px;font-size:clamp(.9rem,2.6vw,1.05rem);letter-spacing:.01em;line-height:1.6}.coverage{color:#c6dbd8;font-size:.9rem;margin-bottom:4px}.coverage-comparison{margin:0}.expired{border-color:#c38c57}.expiry-warning{color:#ffd29a;font-weight:600}.buttons{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0 0}button{font:inherit;font-size:.9rem;font-weight:650;cursor:pointer;background:#deebe9;color:#15342e;border:1px solid transparent;border-radius:8px;padding:11px 16px;margin:0}button:hover:not(:disabled){background:#fff}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid #ffd39a;outline-offset:3px}button:disabled{opacity:.45;cursor:default}.accent{background:#aee1cf;color:#113d30}.secondary{background:transparent;border-color:#58717b;color:#d4e5e7}.secondary:hover:not(:disabled){background:#29434c}.small{color:#a9c1c8;font-size:.82rem}.fee-note{display:block;margin:9px 0 0}.funds-row{display:flex;align-items:center;justify-content:space-between;gap:16px;border-top:1px solid #344b55;padding-top:20px;margin-top:22px}.funds-row>div{display:flex;flex-direction:column;gap:3px}.funds{font-size:1.55rem;letter-spacing:-.025em}.funds-row button{flex-shrink:0}.import-row{display:flex;align-items:center;gap:12px;margin-top:16px}.technical{font-size:.82rem;color:#adc3c9;margin:20px 0 0}.technical p{font-size:.82rem}.technical summary{font-weight:400}.mining{border-top:1px solid #344b55;padding:24px 28px;background:#172c35}.section-heading{display:flex;align-items:center;justify-content:space-between;gap:20px}.section-heading p{margin:5px 0 0}.section-heading button{flex-shrink:0}.result{padding:20px;margin:20px 0 0;background:#203e46;border:1px solid #6c9e9b;border-radius:12px}.result p{font-size:.9rem}.result .address-card{margin-bottom:0;padding:16px}.result-title{font-weight:650}.advanced{font-size:.82rem;color:#a9c1c8;margin:20px 0 0}.advanced label{font-size:.85rem}.saved-preview{margin-top:16px;font-size:.85rem}.address-list{padding:22px 28px;margin:0;border-top:1px solid #344b55}.count{font-size:.75rem;font-weight:400;background:#334c56;padding:2px 7px;border-radius:20px;margin-left:6px;color:#ccdadf}.ownership-note{text-align:center;font-size:.8rem;color:#abc5c8;padding:18px;margin:0;border-top:1px solid #344b55}.empty-state{padding:28px}.activity,.help{padding:19px 0;border-bottom:1px solid #344b55;margin:0;color:#c6d8dd;font-size:.88rem}.help h3{font-size:.95rem;margin-top:24px}.help p{font-size:.85rem;color:#b7cbd0}.help details{font-size:.82rem;margin-top:20px}.connect{padding:40px 28px}.connect>p{color:#b9cdd2;max-width:420px}.connect>button{margin:12px 0}.connect .small{font-size:.82rem}.feedback{margin-top:16px}.notice,.error{border-radius:10px;padding:12px 16px;overflow-wrap:anywhere;font-size:.87rem}.notice{background:#1b3844;border:1px solid #3e6778;margin:0 0 12px}.error{background:#481e2c;border:1px solid #e99aaa}.warning{border-color:#c38c57}.warning h2{font-size:1.15rem}.warning p{font-size:.9rem}.warning details{margin:12px 0}label{display:block;line-height:1.6;font-weight:600;font-size:.9rem;margin:20px 0}input,select{display:block;width:100%;font:inherit;color:#edf3f5;background:#0e2029;border:1px solid #58717b;border-radius:8px;padding:12px;margin-top:7px}select{white-space:normal}.send-panel>button{width:100%;margin-top:8px}summary{cursor:pointer;font-weight:550}summary::marker{color:#91b1bb}.transaction{overflow-wrap:anywhere;background:#0e2029;padding:12px;border-radius:8px;font-size:.82rem}a{color:#aed8df}footer{display:flex;justify-content:space-between;flex-wrap:wrap;gap:16px;color:#8faab4;font-size:.75rem;padding:28px 0;line-height:1.6}footer div{display:flex;gap:18px}footer a{color:#a9c3ca}@media(max-width:520px){main{padding:24px 16px}header{margin-bottom:24px}.brand h1{font-size:1.4rem}.connection{font-size:.7rem}.view-tabs button{padding:9px 17px}.address-card.selected,.mining,.address-list{padding:22px 18px}.address-card{padding:18px}.card-heading{gap:8px}.selected h3{font-size:1.15rem}.address{padding:12px;font-size:.78rem}.section-heading{align-items:flex-start;flex-direction:column;gap:14px}.section-heading button{width:100%}.funds-row{gap:10px}.funds-row button{max-width:150px;font-size:.8rem}.funds-row .small{font-size:.73rem}.result{padding:16px}.import-row{flex-wrap:wrap}.connect{padding:30px 22px}section{padding:22px}.ownership-note{font-size:.75rem}} +:root{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#edf3f5;background:#101b23;font-synthesis:none;color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:linear-gradient(#101b2355,#101b23ee 680px),url('/mountains.jpg') center top/cover fixed;min-height:100vh}main{max-width:760px;margin:auto;padding:40px 24px 32px}header{margin:0 0 32px}.brand{display:flex;align-items:center;gap:10px}.mountain-mark{display:block;width:40px;height:40px;flex-shrink:0}h1{font-size:1.6rem;letter-spacing:-.04em;margin:0}header p{color:#b7c9cd;font-size:.95rem;margin:8px 0 0 50px}h2{font-size:1.55rem;letter-spacing:-.03em;margin:0 0 12px}h3{font-size:1.05rem;margin:0}p{line-height:1.55;margin:12px 0}section{background:#142630f7;border:1px solid #344b55;border-radius:18px;padding:28px;margin:18px 0;box-shadow:0 16px 48px #0002}.view-tabs{display:flex;align-items:center;gap:4px;border-bottom:1px solid #40535a;padding-bottom:10px}.view-tabs button{background:transparent;color:#b8cbd1;padding:9px 22px}.view-tabs button[aria-pressed=true]{background:#e2f1ed;color:#15342e}.connection{margin-left:auto;font-size:.8rem;color:#a6c0b6}.receive-panel{padding:0;overflow:hidden}.address-card{padding:24px;border:1px solid #3b535d;border-radius:12px;background:#19303a;margin:14px 0}.address-card.selected{background:transparent;margin:0;border:0;border-radius:0;padding:28px}.card-heading{display:flex;align-items:center;gap:12px;justify-content:space-between;margin-bottom:18px}.selected h3{font-size:1.3rem;letter-spacing:-.02em}.badge{background:#264d43;color:#b9e4d2;border-radius:20px;padding:4px 9px;font-size:.72rem;font-weight:650;white-space:nowrap}.badge.caution{background:#61422c;color:#ffe0b1}.address{display:block;overflow-wrap:anywhere;background:#0e2029;border:1px solid #344e59;border-radius:9px;padding:16px;font-size:clamp(.9rem,2.6vw,1.05rem);letter-spacing:.01em;line-height:1.6}.coverage{color:#c6dbd8;font-size:.9rem;margin-bottom:4px}.coverage-comparison{margin:0}.expired{border-color:#c38c57}.expiry-warning{color:#ffd29a;font-weight:600}.buttons{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0 0}button{font:inherit;font-size:.9rem;font-weight:650;cursor:pointer;background:#deebe9;color:#15342e;border:1px solid transparent;border-radius:8px;padding:11px 16px;margin:0}button:hover:not(:disabled){background:#fff}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid #ffd39a;outline-offset:3px}button:disabled{opacity:.45;cursor:default}.accent{background:#aee1cf;color:#113d30}.secondary{background:transparent;border-color:#58717b;color:#d4e5e7}.secondary:hover:not(:disabled){background:#29434c}.small{color:#a9c1c8;font-size:.82rem}.fee-note{display:block;margin:9px 0 0}.funds-row{display:flex;align-items:center;justify-content:space-between;gap:16px;border-top:1px solid #344b55;padding-top:20px;margin-top:22px}.funds-row>div{display:flex;flex-direction:column;gap:3px}.funds{font-size:1.55rem;letter-spacing:-.025em}.funds-row button{flex-shrink:0}.import-row{display:flex;align-items:center;gap:12px;margin-top:16px}.technical{font-size:.82rem;color:#adc3c9;margin:20px 0 0}.technical p{font-size:.82rem}.technical summary{font-weight:400}.mining{border-top:1px solid #344b55;padding:24px 28px;background:#172c35}.section-heading{display:flex;align-items:center;justify-content:space-between;gap:20px}.section-heading p{margin:5px 0 0}.section-heading button{flex-shrink:0}.result{padding:20px;margin:20px 0 0;background:#203e46;border:1px solid #6c9e9b;border-radius:12px}.result p{font-size:.9rem}.result .address-card{margin-bottom:0;padding:16px}.result-title{font-weight:650}.advanced{font-size:.82rem;color:#a9c1c8;margin:20px 0 0}.advanced label{font-size:.85rem}.saved-preview{margin-top:16px;font-size:.85rem}.address-list{padding:22px 28px;margin:0;border-top:1px solid #344b55}.count{font-size:.75rem;font-weight:400;background:#334c56;padding:2px 7px;border-radius:20px;margin-left:6px;color:#ccdadf}.ownership-note{text-align:center;font-size:.8rem;color:#abc5c8;padding:18px;margin:0;border-top:1px solid #344b55}.empty-state{padding:28px}.activity,.help{padding:19px 0;border-bottom:1px solid #344b55;margin:0;color:#c6d8dd;font-size:.88rem}.help h3{font-size:.95rem;margin-top:24px}.help p{font-size:.85rem;color:#b7cbd0}.help details{font-size:.82rem;margin-top:20px}.connect{padding:40px 28px}.connect>p{color:#b9cdd2;max-width:420px}.connect>button{margin:12px 0}.connect .small{font-size:.82rem}.feedback{margin-top:16px}.notice,.error{border-radius:10px;padding:12px 16px;overflow-wrap:anywhere;font-size:.87rem}.notice{background:#1b3844;border:1px solid #3e6778;margin:0 0 12px}.error{background:#481e2c;border:1px solid #e99aaa}.warning{border-color:#c38c57}.warning h2{font-size:1.15rem}.warning p{font-size:.9rem}.warning details{margin:12px 0}label{display:block;line-height:1.6;font-weight:600;font-size:.9rem;margin:20px 0}input,select{display:block;width:100%;font:inherit;color:#edf3f5;background:#0e2029;border:1px solid #58717b;border-radius:8px;padding:12px;margin-top:7px}select{white-space:normal}.send-panel>button{width:100%;margin-top:8px}summary{cursor:pointer;font-weight:550}summary::marker{color:#91b1bb}.transaction{overflow-wrap:anywhere;background:#0e2029;padding:12px;border-radius:8px;font-size:.82rem}a{color:#aed8df}footer{display:flex;justify-content:space-between;flex-wrap:wrap;gap:16px;color:#8faab4;font-size:.75rem;padding:28px 0;line-height:1.6}footer div{display:flex;gap:18px}footer a{color:#a9c3ca}@media(max-width:520px){main{padding:24px 16px}header{margin-bottom:24px}.brand h1{font-size:1.4rem}.connection{font-size:.7rem}.view-tabs button{padding:9px 17px}.address-card.selected,.mining,.address-list{padding:22px 18px}.address-card{padding:18px}.card-heading{gap:8px}.selected h3{font-size:1.15rem}.address{padding:12px;font-size:.78rem}.section-heading{align-items:flex-start;flex-direction:column;gap:14px}.section-heading button{width:100%}.funds-row{gap:10px}.funds-row button{max-width:150px;font-size:.8rem}.funds-row .small{font-size:.73rem}.result{padding:16px}.import-row{flex-wrap:wrap}.connect{padding:30px 22px}section{padding:22px}.ownership-note{font-size:.75rem}} .payments-panel{padding:24px 28px;border-top:1px solid #344b55}.payments-panel .section-heading{align-items:center}.payment-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:18px}.payment-row>div{display:flex;flex-direction:column;gap:4px}.payment-row strong{font-size:1.4rem}.payment-row button{flex-shrink:0}@media(max-width:520px){.payments-panel{padding:22px 18px}.payments-panel .section-heading{flex-direction:row;gap:8px}.payments-panel .section-heading h3{font-size:.9rem}.payments-panel .section-heading button{width:auto;font-size:.8rem}.payment-row{gap:10px}.payment-row button{font-size:.8rem}.payment-row strong{font-size:1.2rem}} diff --git a/frontend/src/walletActionState.ts b/frontend/src/walletActionState.ts index 9811f0f..107f8c4 100644 --- a/frontend/src/walletActionState.ts +++ b/frontend/src/walletActionState.ts @@ -1,20 +1,35 @@ import type { WalletInterface } from '@bsv/sdk' import type { RecoveryRecord, WalletRecords } from './walletRecords.ts' +import { ACTION_LABEL, RECORD_LABEL } from './walletScopes.ts' -export async function unfinishedWalletActions(wallet: WalletInterface, network: WalletRecords['network']): Promise { - const pending: RecoveryRecord[] = [] +async function walletActions(wallet: WalletInterface) { + const actions = [] for (let offset = 0; ; offset += 100) { - const page = await wallet.listActions({ labels: ['mountaintops actions v1'], includeLabels: true, limit: 100, offset }) - for (const action of page.actions) { - if (!['unsigned', 'nosend', 'nonfinal', 'unprocessed', 'sending', 'unproven'].includes(action.status)) continue - if (action.status === 'unproven' && action.labels?.includes('mountaintops record v1')) continue - const id = action.labels?.find(x => x.startsWith('mountaintops request '))?.slice(21) ?? action.txid - const canAbort = action.status === 'nosend' && /^[a-f0-9]{64}$/.test(action.txid) - pending.push({ v: 1, network, kind: 'action', clock: 0, data: { id, state: canAbort ? 'prepared' : 'needs wallet review', reference: canAbort ? action.txid : null, txid: action.txid } }) - } - if (offset + page.actions.length >= page.totalActions) break + const page = await wallet.listActions({ labels: [ACTION_LABEL], includeLabels: true, limit: 100, offset }) + if (!Number.isSafeInteger(page.totalActions) || page.totalActions < offset + page.actions.length) throw new Error('Wallet action history is incomplete. Check the wallet before another payment.') + actions.push(...page.actions) + if (offset + page.actions.length >= page.totalActions) return actions if (page.actions.length !== 100 || offset >= 10000) throw new Error('Wallet action history is incomplete. Check the wallet before another payment.') } +} + +export async function assertWalletActionFinal(wallet: WalletInterface, action: Record): Promise { + // Read legacy UUID labels from results without requesting that dynamic scope. + const actions = (await walletActions(wallet)).filter(x => action.txid + ? x.txid === action.txid + : typeof action.id === 'string' && x.labels?.includes(`mountaintops request ${action.id}`)) + if (!actions.length || actions.some(x => !['completed', 'failed'].includes(x.status))) throw new Error('Your wallet has no final result yet. Do not retry this payment.') +} + +export async function unfinishedWalletActions(wallet: WalletInterface, network: WalletRecords['network']): Promise { + const pending: RecoveryRecord[] = [] + for (const action of await walletActions(wallet)) { + if (!['unsigned', 'nosend', 'nonfinal', 'unprocessed', 'sending', 'unproven'].includes(action.status)) continue + if (action.status === 'unproven' && action.labels?.includes(RECORD_LABEL)) continue + const id = action.labels?.find(x => x.startsWith('mountaintops request '))?.slice(21) ?? action.txid + const canAbort = action.status === 'nosend' && /^[a-f0-9]{64}$/.test(action.txid) + pending.push({ v: 1, network, kind: 'action', clock: 0, data: { id, state: canAbort ? 'prepared' : 'needs wallet review', reference: canAbort ? action.txid : null, txid: action.txid } }) + } return pending } diff --git a/frontend/src/walletScopes.ts b/frontend/src/walletScopes.ts new file mode 100644 index 0000000..d759bb7 --- /dev/null +++ b/frontend/src/walletScopes.ts @@ -0,0 +1,5 @@ +// Fixed scopes keep all wallet operations covered by the grouped manifest. +// Request-specific identifiers belong in native TXIDs, never permission labels. +export const ACTION_LABEL = 'mountaintops actions v1' +export const RECORD_LABEL = 'mountaintops record v1' +export const RECEIPT_LABEL = 'mountaintops receipts v1' diff --git a/frontend/test/permissions.test.mjs b/frontend/test/permissions.test.mjs new file mode 100644 index 0000000..ed00b5b --- /dev/null +++ b/frontend/test/permissions.test.mjs @@ -0,0 +1,133 @@ +import assert from 'node:assert/strict' +import fs from 'node:fs' +import test from 'node:test' +import { PrivateKey } from '@bsv/sdk' +import { WalletPermissionsManager } from '@bsv/wallet-toolbox-client' +import { FixtureWallet } from './fixtureWallet.mjs' +import { WalletRecords } from '../src/walletRecords.ts' +import { sendCoins } from '../src/actions.ts' +import { assertWalletActionFinal, unfinishedWalletActions } from '../src/walletActionState.ts' +import { ACTION_LABEL, RECORD_LABEL, RECEIPT_LABEL } from '../src/walletScopes.ts' +import { publicDeriver } from '../src/derivation.ts' + +const manifest = JSON.parse(fs.readFileSync(new URL('../public/manifest.json', import.meta.url))) +const group = manifest.metanet.groupPermissions +const labelNames = [ACTION_LABEL, RECORD_LABEL, RECEIPT_LABEL] +const coveredProtocol = (protocolID, counterparty = 'self') => group.protocolPermissions.some(x => x.protocolID[0] === protocolID[0] && x.protocolID[1] === protocolID[1] && (protocolID[0] === 1 || x.counterparty === counterparty)) + +function scopedWallet(wallet) { + return new Proxy(wallet, { get(target, method) { + const value = target[method] + if (typeof value !== 'function') return value + return async (...args) => { + const request = args[0] ?? {} + if (request.identityKey) assert.ok(coveredProtocol([1, 'identity key retrieval'])) + if (request.protocolID) assert.ok(coveredProtocol(request.protocolID, request.counterparty), `Undeclared protocol ${request.protocolID}`) + const baskets = [request.basket, ...(request.outputs ?? []).map(x => x.basket ?? x.insertionRemittance?.basket)].filter(Boolean) + for (const basket of baskets) assert.ok(group.basketAccess.some(x => x.basket === basket), `Undeclared basket ${basket}`) + for (const label of request.labels ?? []) { + assert.ok(labelNames.includes(label), `Request-specific permission label ${label}`) + assert.ok(coveredProtocol([1, `action label ${label}`])) + } + if (method === 'createAction') assert.ok(group.spendingAuthorization.amount > 0) + return value.apply(target, args) + } + } }) +} + +test('manifest uses current grouped schema and a consistent authored mountain logo', () => { + assert.equal(manifest.name, 'Mountaintops') + assert.equal(manifest.metanet.schemaVersion, 1) + assert.equal(manifest.babbage, undefined) + assert.equal(group.certificateAccess, undefined) + assert.equal(manifest.metanet.counterpartyPermissions, undefined) + assert.equal(group.spendingAuthorization.amount, 100000) + assert.match(group.spendingAuthorization.description, /100,000 satoshis per month/) + assert.deepEqual(group.basketAccess.map(x => x.basket).sort(), ['mntops v1', 'mountaintops receipts v1']) + const html = fs.readFileSync(new URL('../index.html', import.meta.url), 'utf8') + const app = fs.readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8') + assert.match(html, /rel="manifest" href="\/manifest.json"/) + assert.match(html, /rel="icon"[^>]+href="\/mountaintops.svg"/) + assert.match(app, /className="mountain-mark" src="\/mountaintops.svg"/) + assert.doesNotMatch(html, /vite.svg/) + for (const size of [192, 512]) { + const icon = manifest.icons.find(x => x.sizes === `${size}x${size}`) + const bytes = fs.readFileSync(new URL(`../public${icon.src}`, import.meta.url)) + assert.equal(bytes.subarray(1, 4).toString(), 'PNG') + assert.equal(bytes.readUInt32BE(16), size); assert.equal(bytes.readUInt32BE(20), size) + } +}) + +test('real SDK encrypted save, fresh recovery, derivation and payment use only declared scopes', async () => { + const previous = globalThis.fetch + globalThis.fetch = async url => String(url).endsWith('/spent') ? new Response('', { status: 404 }) : Response.json({ blocks: 972777, bestblockhash: 'a'.repeat(64) }) + try { + const raw = new FixtureWallet(), wallet = scopedWallet(raw) + const identity = (await wallet.getPublicKey({ identityKey: true })).publicKey + await wallet.getPublicKey({ protocolID: [1, 'mountaintops'], keyID: '1', counterparty: 'anyone', forSelf: true }) + const store = new WalletRecords(wallet, identity, 'mainnet') + await store.append('address', { keyID: '17', address: publicDeriver(identity)('17', 'mainnet'), targetStage: 0, useForReceiving: true }) + const restored = new WalletRecords(scopedWallet(new FixtureWallet(raw.state)), identity, 'mainnet') + assert.equal((await restored.load()).length, 1) + await wallet.listOutputs({ basket: 'mountaintops receipts v1' }) + const txid = await sendCoins(wallet, store, new PrivateKey(43).toPublicKey().toAddress(), '0.00001000', { stage: 0, state: null }, () => {}) + const pending = await unfinishedWalletActions(wallet, 'mainnet') + assert.equal(pending[0].data.id, txid) + assert.deepEqual(raw.state.actions.at(-1).labels, [ACTION_LABEL]) + assert.deepEqual(raw.state.actions[0].labels, [ACTION_LABEL, RECORD_LABEL]) + } finally { globalThis.fetch = previous } +}) + +test('wallet permission manager groups every declared capability, with no individual fallback', { timeout: 10000 }, async () => { + const previous = globalThis.fetch + globalThis.fetch = async url => { + assert.equal(String(url), 'http://localhost/manifest.json') + return Response.json(manifest) + } + try { + const requests = [ + ...group.protocolPermissions.map(p => manager => manager.ensureProtocolPermission({ originator: 'localhost', privileged: false, protocolID: p.protocolID, counterparty: p.counterparty ?? 'self', usageType: 'generic' })), + ...group.basketAccess.map(b => manager => manager.ensureBasketAccess({ originator: 'localhost', basket: b.basket, usageType: 'listing' })), + manager => manager.ensureSpendingAuthorization({ originator: 'localhost', satoshis: 1000 }) + ] + for (const request of requests) { + const manager = new WalletPermissionsManager(new FixtureWallet(), 'wallet.test') + let grouped = 0, individual = 0, callbackError + manager.bindCallback('onGroupedPermissionRequested', async r => { + grouped++ + try { + // A self-only Level 2 renewal may use the wallet's narrower grouped + // path. The first identity request presents the complete app group. + if (r.requestID.startsWith('group-peer:')) { + assert.deepEqual(r.permissions.protocolPermissions, group.protocolPermissions.filter(x => x.protocolID[0] === 2)) + } else { + assert.equal(r.permissions.protocolPermissions.length, group.protocolPermissions.length) + assert.equal(r.permissions.basketAccess.length, 2) + assert.equal(r.permissions.spendingAuthorization.amount, 100000) + } + } catch (error) { callbackError = error } + finally { await manager.denyGroupedPermission(r.requestID) } + }) + for (const event of ['onProtocolPermissionRequested', 'onBasketAccessRequested', 'onSpendingAuthorizationRequested']) manager.bindCallback(event, async r => { individual++; await manager.denyPermission(r.requestID) }) + // Deny in the disposable manager so the test creates no permission tokens. + await assert.rejects(request(manager), error => error.code === 'ERR_PERMISSION_DENIED') + if (callbackError) throw callbackError + assert.equal(grouped, 1); assert.equal(individual, 0) + } + } finally { globalThis.fetch = previous } +}) + +test('legacy and new pending actions resolve using one fixed label across pages', async () => { + const actions = Array.from({ length: 101 }, (_, i) => ({ txid: i.toString(16).padStart(64, '0'), status: 'failed', labels: [ACTION_LABEL] })) + actions[100].labels.push('mountaintops request old-request') + const wallet = { listActions: async args => { + assert.deepEqual(args.labels, [ACTION_LABEL]) + return { totalActions: actions.length, actions: actions.slice(args.offset, args.offset + args.limit) } + } } + await assertWalletActionFinal(wallet, { id: 'old-request' }) + await assertWalletActionFinal(wallet, { txid: actions[100].txid }) + actions[100].status = 'unproven' + await assert.rejects(assertWalletActionFinal(wallet, { id: 'old-request' }), /no final result/) + await assert.rejects(assertWalletActionFinal(wallet, { txid: 'f'.repeat(64) }), /no final result/) + await assert.rejects(unfinishedWalletActions({ listActions: async () => ({ totalActions: 200, actions: [] }) }, 'mainnet'), /incomplete/) +})