@bsv/expo-wallet-toolbox 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1745 -0
- package/README.md +47 -1
- package/core/amountFormatHelpers.ts +20 -2
- package/core/backup/RemoteSyncReader.ts +131 -19
- package/core/backup/appData.ts +157 -0
- package/core/backup/client.ts +15 -1
- package/core/backup/codec.ts +147 -9
- package/core/backup/constants.ts +30 -1
- package/core/backup/cursor.ts +31 -2
- package/core/backup/push.ts +70 -4
- package/core/backup/restore.ts +104 -16
- package/core/backup/restoreOnImport.ts +94 -30
- package/core/backup/status.ts +13 -8
- package/core/constants.ts +14 -1
- package/core/context/ExchangeRateContext.tsx +34 -27
- package/core/context/LocalStorageProvider.tsx +43 -40
- package/core/context/UserContext.tsx +18 -7
- package/core/context/VaultContext.tsx +49 -2
- package/core/context/WalletConnectionContext.tsx +203 -11
- package/core/context/WalletContext.tsx +631 -162
- package/core/headers/OfflineFirstChaintracks.ts +48 -4
- package/core/headers/headerStore.ts +26 -4
- package/core/headers/syncHeaders.ts +12 -1
- package/core/i18n/translations.tsx +953 -25
- package/core/identity/handleRegistry/client.ts +31 -2
- package/core/identity/handleRegistry/keyPinStore.ts +70 -0
- package/core/identity/handleRegistry/resolver.ts +71 -3
- package/core/index.ts +33 -3
- package/core/localpay/build.ts +225 -24
- package/core/localpay/pending.ts +110 -7
- package/core/localpay/pendingAbortAuthority.ts +95 -0
- package/core/localpay/pendingAborts.ts +264 -28
- package/core/localpay/session.ts +42 -17
- package/core/localpay/settlementAck.ts +10 -1
- package/core/localpay/transport/socket.ts +52 -3
- package/core/localpay/verify.ts +100 -10
- package/core/mandala/abortGuard.ts +96 -20
- package/core/mandala/createRuntime.ts +206 -33
- package/core/mandala/drain.ts +89 -11
- package/core/mandala/inboxPrehold.ts +186 -0
- package/core/mandala/permissionModule.ts +202 -20
- package/core/mandala/settlementStore.ts +24 -2
- package/core/mandala/types.ts +40 -5
- package/core/monitor/TaskBackupPush.ts +14 -0
- package/core/monitor/TaskDrainOutbox.ts +14 -0
- package/core/monitor/TaskSendOffline.ts +14 -0
- package/core/net/publicDestination.ts +91 -0
- package/core/net/validateArcUrl.ts +22 -0
- package/core/offline/cancelParked.ts +134 -13
- package/core/offline/payerHold.ts +100 -24
- package/core/offline/plan.ts +36 -7
- package/core/pay/beefRepair.ts +6 -2
- package/core/pay/damagedInbox.ts +24 -0
- package/core/pay/rails/address.ts +107 -12
- package/core/pay/rails/handle.ts +117 -22
- package/core/pay/rails/index.ts +45 -7
- package/core/pay/rails/nativeIntent.ts +61 -0
- package/core/pay/receiveHistory.ts +93 -0
- package/core/pay/recordProof.ts +19 -1
- package/core/pay/refreshProofGuard.ts +42 -1
- package/core/pay/watchlist.ts +5 -2
- package/core/peerpay/control.ts +17 -18
- package/core/peerpay/handleResendRequests.ts +58 -4
- package/core/peerpay/outbox.ts +3 -1
- package/core/recovery/backupMaterial.ts +61 -0
- package/core/recovery/createWallet.ts +95 -0
- package/core/recovery/recoverWallet.ts +120 -0
- package/core/recovery/restoreWallet.ts +170 -0
- package/core/recovery/secret.ts +92 -0
- package/core/recovery/shareCollector.ts +71 -0
- package/core/recovery/shareParsing.ts +87 -0
- package/core/recovery/shares.ts +116 -0
- package/core/recovery/useRecoveryDeps.ts +70 -0
- package/core/services/arcTokenStorage.ts +52 -0
- package/core/services/arcadeBroadcastProvider.ts +232 -48
- package/core/services/autoApprovePolicy.ts +105 -0
- package/core/services/callbackToken.ts +19 -0
- package/core/services/capWalletArgs.ts +14 -2
- package/core/services/connectionAuthority.ts +98 -0
- package/core/services/exchangeRate.ts +35 -12
- package/core/services/externalOrigin.ts +11 -0
- package/core/services/secrets/kek.ts +126 -29
- package/core/services/secrets/migration.ts +16 -4
- package/core/services/secrets/store.ts +42 -14
- package/core/services/vault/VaultKeyService.ts +228 -45
- package/core/services/vault/chainRecovery.ts +483 -0
- package/core/services/vault/driver.ts +9 -1
- package/core/services/vault/enrolledSerialRegistry.ts +150 -0
- package/core/services/vault/guard.ts +218 -32
- package/core/services/vault/hardwareLease.ts +19 -0
- package/core/services/vault/metaAuthority.ts +210 -0
- package/core/services/vault/pivReset.ts +64 -23
- package/core/services/vault/r1comb.ts +139 -3
- package/core/services/vault/session.ts +25 -4
- package/core/services/vault/transfers.ts +866 -170
- package/core/services/vault/types.ts +19 -4
- package/core/services/vault/vaultStore.ts +256 -29
- package/core/services/walletArgLimits.ts +45 -2
- package/core/services/walletConnectionValidation.ts +76 -6
- package/core/services/walletServiceConfig.ts +10 -8
- package/core/storage/StorageExpoSQLite.ts +47 -13
- package/core/storage/methods/findSql.ts +21 -2
- package/core/storage/methods/offlineActions.ts +10 -1
- package/core/storage/methods/processOfflineActions.ts +116 -23
- package/core/storage/schema/createTables.ts +126 -2
- package/core/stores/ConnectionStore.ts +34 -0
- package/core/toolboxConfig.ts +45 -11
- package/core/walletDbRegistry.ts +63 -0
- package/core/walletMonitor.ts +17 -1
- package/core/walletRepair/releaseStuckReservations.ts +72 -0
- package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
- package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
- package/package.json +2 -2
- package/ui/backupShares.ts +26 -169
- package/ui/components/pay/AddressReceive.tsx +13 -6
- package/ui/components/pay/AssetPicker.tsx +30 -9
- package/ui/components/pay/MessageBoxConfig.tsx +16 -0
- package/ui/components/pay/NearbyFlow.tsx +480 -243
- package/ui/components/pay/PaymentSuccessOverlay.tsx +39 -4
- package/ui/components/pay/UniversalSend.tsx +167 -73
- package/ui/components/ui/AlertCard.tsx +38 -5
- package/ui/components/ui/PermissionSheet.tsx +197 -66
- package/ui/components/vault/EnrollWizard.tsx +61 -13
- package/ui/components/vault/vaultErrorCopy.ts +3 -1
- package/ui/components/wallet/ActivityRow.tsx +5 -3
- package/ui/components/wallet/AmountInput.tsx +8 -2
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
- package/ui/components/wallet/Balance.tsx +42 -23
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
- package/ui/exportTransactions.ts +36 -4
- package/ui/hooks/useExportWalletData.ts +25 -2
- package/ui/importDatabases.ts +339 -24
- package/ui/index.ts +9 -3
- package/ui/isImageUrl.ts +6 -0
- package/ui/printRecoveryShares.ts +9 -10
- package/ui/recoveryPrompts.ts +91 -0
- package/ui/resolveIdentity.ts +31 -9
- package/ui/screens/ConnectionsScreen.tsx +86 -19
- package/ui/screens/IdentifierScreen.tsx +30 -8
- package/ui/screens/PairScreen.tsx +74 -2
- package/ui/screens/SettingsScreen.tsx +10 -4
- package/ui/screens/TrustScreen.tsx +99 -4
- package/ui/screens/VaultScreen.tsx +410 -61
- package/ui/screens/VaultTransferScreen.tsx +59 -7
- package/ui/screens/WalletCheckScreen.tsx +17 -6
- package/ui/screens/WalletConfigScreen.tsx +82 -28
- package/ui/screens/WalletHomeScreen.tsx +179 -88
- package/ui/screens/detailActionKeys.ts +55 -0
- package/ui/tokenFormat.ts +44 -4
- package/ui/txStatus.ts +5 -0
- package/core/storage/LocalStorageAdapter.ts +0 -58
package/ui/backupShares.ts
CHANGED
|
@@ -1,170 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Re-export shim.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* entropy(16) || sha256(entropy)[0..16]
|
|
13
|
-
*
|
|
14
|
-
* The tag exists so recovery can tell new paper from old WITHOUT a version
|
|
15
|
-
* marker on the printed page, which would break every sheet already in a
|
|
16
|
-
* drawer. Length cannot do that job: PrivateKey is a BigNumber and drops
|
|
17
|
-
* leading zero bytes (~1 payload in 256), and an imported 24-word phrase
|
|
18
|
-
* yields 32 bytes of entropy — the exact width of a legacy primary key.
|
|
19
|
-
*
|
|
20
|
-
* Do NOT try to validate the entropy branch by rebuilding a mnemonic and
|
|
21
|
-
* checking its BIP39 checksum. Mnemonic.fromEntropy COMPUTES that checksum, so
|
|
22
|
-
* it accepts any 16 bytes and can never reject a misclassification.
|
|
4
|
+
* Share parsing, compatibility checks and recombination are pure TypeScript
|
|
5
|
+
* with no UI dependency, so they moved to `core/recovery/shares.ts` where the
|
|
6
|
+
* headless recovery module (core-only, never imports `ui/`) can reach them
|
|
7
|
+
* without crossing the core→ui boundary. `@bsv/expo-wallet-toolbox/ui`
|
|
8
|
+
* consumers (printRecoveryShares.ts, __tests__/ui/backupShares.test.ts) keep
|
|
9
|
+
* importing from here unaffected. `generatePrintHTML` stays here: it renders
|
|
10
|
+
* HTML/SVG for `expo-print`, which is presentation, not a recovery primitive.
|
|
23
11
|
*/
|
|
12
|
+
export * from '../core/recovery/shares'
|
|
24
13
|
|
|
25
|
-
import { PrivateKey, Hash } from '@bsv/sdk'
|
|
26
14
|
import QRCode from 'qrcode'
|
|
27
15
|
|
|
28
|
-
// ── Payload framing ──────────────────────────────────────────────────────────
|
|
29
|
-
|
|
30
|
-
/** Entropy of a 12-word BIP39 phrase. The only width v2 shares support. */
|
|
31
|
-
export const ENTROPY_BYTES = 16
|
|
32
|
-
/** Fixed width of the split secret. Never varies, never inferred. */
|
|
33
|
-
export const PAYLOAD_BYTES = 32
|
|
34
|
-
|
|
35
|
-
/** What a recombined payload turned out to be. */
|
|
36
|
-
export type RecoveredSecret =
|
|
37
|
-
| { kind: 'entropy'; entropy: number[] }
|
|
38
|
-
| { kind: 'legacy'; primaryKey: number[] }
|
|
39
|
-
|
|
40
|
-
/** Wrap 16 bytes of entropy in the tagged 32-byte payload. */
|
|
41
|
-
export function frameEntropy(entropy: number[]): number[] {
|
|
42
|
-
if (entropy.length !== ENTROPY_BYTES) {
|
|
43
|
-
throw new Error(`frameEntropy: expected ${ENTROPY_BYTES} bytes, got ${entropy.length}`)
|
|
44
|
-
}
|
|
45
|
-
return [...entropy, ...Hash.sha256(entropy).slice(0, PAYLOAD_BYTES - ENTROPY_BYTES)]
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Restore a recombined payload to full width.
|
|
50
|
-
*
|
|
51
|
-
* Shamir recombination yields a PrivateKey, whose toArray() drops leading zero
|
|
52
|
-
* bytes. Without this pad, roughly one payload in 256 decodes short and fails
|
|
53
|
-
* to match anything.
|
|
54
|
-
*/
|
|
55
|
-
export function padPayload(bytes: number[]): number[] {
|
|
56
|
-
if (bytes.length > PAYLOAD_BYTES) {
|
|
57
|
-
throw new Error(`padPayload: payload exceeds ${PAYLOAD_BYTES} bytes`)
|
|
58
|
-
}
|
|
59
|
-
return [...new Array(PAYLOAD_BYTES - bytes.length).fill(0), ...bytes]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Decide whether a recombined payload is framed entropy or a legacy key. */
|
|
63
|
-
export function classifyPayload(raw: number[]): RecoveredSecret {
|
|
64
|
-
const payload = padPayload(raw)
|
|
65
|
-
const entropy = payload.slice(0, ENTROPY_BYTES)
|
|
66
|
-
const tag = payload.slice(ENTROPY_BYTES)
|
|
67
|
-
const expected = Hash.sha256(entropy).slice(0, PAYLOAD_BYTES - ENTROPY_BYTES)
|
|
68
|
-
|
|
69
|
-
return tag.every((b, i) => b === expected[i])
|
|
70
|
-
? { kind: 'entropy', entropy }
|
|
71
|
-
: { kind: 'legacy', primaryKey: payload }
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ── Share generation ─────────────────────────────────────────────────────────
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Split mnemonic entropy into backup shares (the current format).
|
|
78
|
-
* @param entropy 16 bytes, from Mnemonic.toEntropy()
|
|
79
|
-
* @returns Share strings in the format base58(x).base58(y).threshold.integrity
|
|
80
|
-
*/
|
|
81
|
-
export function generateEntropyShares(
|
|
82
|
-
entropy: number[],
|
|
83
|
-
threshold: number = 2,
|
|
84
|
-
totalShares: number = 3
|
|
85
|
-
): string[] {
|
|
86
|
-
return new PrivateKey(frameEntropy(entropy)).toBackupShares(threshold, totalShares)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Split a raw private key (the legacy format).
|
|
91
|
-
*
|
|
92
|
-
* Still reachable for wallets that were themselves restored from legacy paper
|
|
93
|
-
* and therefore have no mnemonic to frame. Removing it would leave that cohort
|
|
94
|
-
* with no way to back up at all; the tag check routes their shares back to the
|
|
95
|
-
* legacy branch on recovery, so this stays self-consistent.
|
|
96
|
-
*/
|
|
97
|
-
export function generateLegacyKeyShares(
|
|
98
|
-
privateKeyBytes: number[],
|
|
99
|
-
threshold: number = 2,
|
|
100
|
-
totalShares: number = 3
|
|
101
|
-
): string[] {
|
|
102
|
-
return new PrivateKey(privateKeyBytes).toBackupShares(threshold, totalShares)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ── Share validation ─────────────────────────────────────────────────────────
|
|
106
|
-
|
|
107
|
-
export interface ParsedShare {
|
|
108
|
-
raw: string
|
|
109
|
-
x: string
|
|
110
|
-
y: string
|
|
111
|
-
threshold: number
|
|
112
|
-
integrity: string
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Parse and validate a single backup share string.
|
|
117
|
-
* @returns Parsed share or null if invalid format
|
|
118
|
-
*/
|
|
119
|
-
export function parseShare(shareString: string): ParsedShare | null {
|
|
120
|
-
const parts = shareString.trim().split('.')
|
|
121
|
-
if (parts.length !== 4) return null
|
|
122
|
-
|
|
123
|
-
const [x, y, thresholdStr, integrity] = parts
|
|
124
|
-
const threshold = Number(thresholdStr)
|
|
125
|
-
|
|
126
|
-
if (!x || !y || isNaN(threshold) || threshold < 2 || !integrity) return null
|
|
127
|
-
|
|
128
|
-
return { raw: shareString.trim(), x, y, threshold, integrity }
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Validate that a new share is compatible with previously collected shares.
|
|
133
|
-
* @returns Error message string or null if valid
|
|
134
|
-
*/
|
|
135
|
-
export function validateShareCompatibility(newShare: ParsedShare, existingShares: ParsedShare[]): string | null {
|
|
136
|
-
if (existingShares.length === 0) return null
|
|
137
|
-
|
|
138
|
-
const first = existingShares[0]
|
|
139
|
-
|
|
140
|
-
if (newShare.threshold !== first.threshold) {
|
|
141
|
-
return 'Threshold does not match previous shares'
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (newShare.integrity !== first.integrity) {
|
|
145
|
-
return 'Integrity hash does not match — shares are from different keys'
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Check for duplicate (same x.y point)
|
|
149
|
-
const isDuplicate = existingShares.some(s => s.x === newShare.x && s.y === newShare.y)
|
|
150
|
-
if (isDuplicate) {
|
|
151
|
-
return 'This share has already been scanned'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return null
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Recombine shares and say what came out.
|
|
159
|
-
* @param shareStrings At least `threshold` raw share strings
|
|
160
|
-
* @throws If the shares are invalid or their integrity hashes disagree
|
|
161
|
-
*/
|
|
162
|
-
export function recoverSecretFromShares(shareStrings: string[]): RecoveredSecret {
|
|
163
|
-
return classifyPayload(Array.from(PrivateKey.fromBackupShares(shareStrings).toArray()))
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// ── Print HTML generation ────────────────────────────────────────────────────
|
|
167
|
-
|
|
168
16
|
/**
|
|
169
17
|
* Generate a QR code as an inline SVG string.
|
|
170
18
|
* Uses the `qrcode` package which does pure-JS SVG string generation.
|
|
@@ -189,25 +37,34 @@ async function generateQRCodeSVG(data: string, size: number = 180): Promise<stri
|
|
|
189
37
|
* - Recovery instructions footer
|
|
190
38
|
*
|
|
191
39
|
* Pages are separated by CSS page-break-after for print dialogue.
|
|
40
|
+
*
|
|
41
|
+
* `only`, when given, renders a single page (share index `only` of `shares`,
|
|
42
|
+
* still labelled "Share <only+1> of <shares.length>") as a standalone
|
|
43
|
+
* one-page document instead of every share in one multi-page document. See
|
|
44
|
+
* printRecoveryShares.ts (XR-110): the default flow calls this once per
|
|
45
|
+
* share so no single print job carries more than one of the threshold.
|
|
192
46
|
*/
|
|
193
47
|
export async function generatePrintHTML(
|
|
194
48
|
shares: string[],
|
|
195
49
|
identityKey: string,
|
|
196
50
|
format: 'entropy' | 'legacy' = 'entropy',
|
|
197
|
-
appName: string = 'your wallet app'
|
|
51
|
+
appName: string = 'your wallet app',
|
|
52
|
+
only?: number
|
|
198
53
|
): Promise<string> {
|
|
199
54
|
const now = new Date()
|
|
200
55
|
const date = now.toISOString().split('T')[0]
|
|
201
56
|
const time = now.toISOString().split('T')[1].split('.')[0]
|
|
202
57
|
const dateStamp = `${date} ${time}`
|
|
203
58
|
|
|
204
|
-
|
|
205
|
-
|
|
59
|
+
const indices = only === undefined ? shares.map((_, i) => i) : [only]
|
|
60
|
+
|
|
61
|
+
// Pre-generate the QR codes this document actually needs.
|
|
62
|
+
const shareQRs = await Promise.all(indices.map(i => generateQRCodeSVG(shares[i], 180)))
|
|
206
63
|
const identityQR = await generateQRCodeSVG(identityKey, 150)
|
|
207
64
|
|
|
208
|
-
const pages =
|
|
209
|
-
(
|
|
210
|
-
<div class="page${
|
|
65
|
+
const pages = indices.map(
|
|
66
|
+
(i, renderIdx) => `
|
|
67
|
+
<div class="page${renderIdx < indices.length - 1 ? '' : ' last'}">
|
|
211
68
|
<div class="header">
|
|
212
69
|
<span class="share-label">Share ${i + 1} of ${shares.length}</span>
|
|
213
70
|
<span class="date-stamp">${dateStamp}</span>
|
|
@@ -226,10 +83,10 @@ export async function generatePrintHTML(
|
|
|
226
83
|
|
|
227
84
|
<div class="section">
|
|
228
85
|
<div class="qr-container">
|
|
229
|
-
${shareQRs[
|
|
86
|
+
${shareQRs[renderIdx]}
|
|
230
87
|
</div>
|
|
231
88
|
<div class="data-label">Backup Share</div>
|
|
232
|
-
<div class="data-value share-text">${
|
|
89
|
+
<div class="data-value share-text">${shares[i]}</div>
|
|
233
90
|
</div>
|
|
234
91
|
|
|
235
92
|
<div class="divider"></div>
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
spacing,
|
|
23
23
|
typography,
|
|
24
24
|
useWallet,
|
|
25
|
-
|
|
25
|
+
MAX_MANUAL_RECOVERY_DAYS,
|
|
26
26
|
derivationPrefixFor,
|
|
27
27
|
getCurrentDate,
|
|
28
28
|
getPaymentAddress,
|
|
@@ -30,7 +30,8 @@ import {
|
|
|
30
30
|
sweepAddress,
|
|
31
31
|
wocConfigFor,
|
|
32
32
|
type ProcessedTx,
|
|
33
|
-
watchAddress
|
|
33
|
+
watchAddress,
|
|
34
|
+
recordIssuedDate
|
|
34
35
|
} from '@bsv/expo-wallet-toolbox'
|
|
35
36
|
import type { DismissTarget } from '../../dismissTarget'
|
|
36
37
|
|
|
@@ -183,7 +184,13 @@ export default function AddressReceive({
|
|
|
183
184
|
setAddress(next)
|
|
184
185
|
// Registering is what makes the background sweeper poll it. Every
|
|
185
186
|
// address the user is shown gets watched — including a recovered one.
|
|
186
|
-
if (storage)
|
|
187
|
+
if (storage) {
|
|
188
|
+
await watchAddress(storage as any, { address: next, date, derivationPrefix })
|
|
189
|
+
// XR-055: remembered durably (count-capped, not the watchlist's 7-day age
|
|
190
|
+
// cap) so recovery can scan every date this device has ever issued, and so
|
|
191
|
+
// it survives encrypted backup/restore — see pay/receiveHistory.ts.
|
|
192
|
+
await recordIssuedDate(storage as any, date)
|
|
193
|
+
}
|
|
187
194
|
const rows = await getProcessedTransactions(wallet as any, adminOriginator, next)
|
|
188
195
|
setProcessed(rows)
|
|
189
196
|
// A different address means a different history: re-baseline, or stepping
|
|
@@ -397,15 +404,15 @@ export default function AddressReceive({
|
|
|
397
404
|
<View style={styles.recovery}>
|
|
398
405
|
<View style={styles.dateRow}>
|
|
399
406
|
<TouchableOpacity
|
|
400
|
-
onPress={() => void load(Math.min(
|
|
401
|
-
disabled={daysOffset >=
|
|
407
|
+
onPress={() => void load(Math.min(MAX_MANUAL_RECOVERY_DAYS, daysOffset + 1))}
|
|
408
|
+
disabled={daysOffset >= MAX_MANUAL_RECOVERY_DAYS}
|
|
402
409
|
hitSlop={8}
|
|
403
410
|
style={styles.dateArrow}
|
|
404
411
|
>
|
|
405
412
|
<Ionicons
|
|
406
413
|
name="chevron-back"
|
|
407
414
|
size={20}
|
|
408
|
-
color={daysOffset >=
|
|
415
|
+
color={daysOffset >= MAX_MANUAL_RECOVERY_DAYS ? colors.textQuaternary : colors.accent}
|
|
409
416
|
/>
|
|
410
417
|
</TouchableOpacity>
|
|
411
418
|
<Text style={[styles.dateText, { color: colors.textSecondary }]}>{getCurrentDate(daysOffset)}</Text>
|
|
@@ -26,7 +26,7 @@ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
|
26
26
|
import { hitTargets, spacing, typography, useTheme } from '@bsv/expo-wallet-toolbox'
|
|
27
27
|
import type { TokenBalance } from '../../../core/mandala/runtime'
|
|
28
28
|
import { ListRow } from '../ui/ListRow'
|
|
29
|
-
import { formatTokenAmountWithUnit } from '../../tokenFormat'
|
|
29
|
+
import { formatTokenAmountWithUnit, shortAssetId } from '../../tokenFormat'
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
|
|
@@ -78,9 +78,7 @@ export default function AssetPicker({
|
|
|
78
78
|
|
|
79
79
|
const current = balances.find(b => b.asset.assetId === selected) ?? null
|
|
80
80
|
const currentLabel = current ? current.asset.label || current.asset.ticker : BSV_LABEL
|
|
81
|
-
const currentFigure = current
|
|
82
|
-
? formatTokenAmountWithUnit(current.baseUnits, current.asset)
|
|
83
|
-
: bsvBalanceText
|
|
81
|
+
const currentFigure = current ? formatTokenAmountWithUnit(current.baseUnits, current.asset) : bsvBalanceText
|
|
84
82
|
|
|
85
83
|
const choose = (assetId: string | null) => {
|
|
86
84
|
onSelect(assetId)
|
|
@@ -117,6 +115,8 @@ export default function AssetPicker({
|
|
|
117
115
|
<AssetOption
|
|
118
116
|
key={b.asset.assetId}
|
|
119
117
|
label={b.asset.label || b.asset.ticker}
|
|
118
|
+
issuerName={b.asset.issuerName}
|
|
119
|
+
fingerprint={shortAssetId(b.asset.assetId)}
|
|
120
120
|
figure={showFigures ? formatTokenAmountWithUnit(b.baseUnits, b.asset) : null}
|
|
121
121
|
selected={selected === b.asset.assetId}
|
|
122
122
|
onPress={() => choose(b.asset.assetId)}
|
|
@@ -130,17 +130,27 @@ export default function AssetPicker({
|
|
|
130
130
|
|
|
131
131
|
function AssetOption({
|
|
132
132
|
label,
|
|
133
|
+
issuerName,
|
|
134
|
+
fingerprint,
|
|
133
135
|
figure,
|
|
134
136
|
selected,
|
|
135
137
|
onPress
|
|
136
138
|
}: {
|
|
137
139
|
label: string
|
|
140
|
+
/** XR-044: unverified, issuer-supplied — shown alongside the fingerprint, never in place of it. */
|
|
141
|
+
issuerName?: string
|
|
142
|
+
/** XR-044: `shortAssetId(assetId)` — the one thing a look-alike asset cannot share. Absent for BSV. */
|
|
143
|
+
fingerprint?: string
|
|
138
144
|
figure?: string | null
|
|
139
145
|
selected: boolean
|
|
140
146
|
onPress: () => void
|
|
141
147
|
}) {
|
|
142
148
|
const { colors } = useTheme()
|
|
143
149
|
const Ionicons = loadIonicons()
|
|
150
|
+
// "Acme Bank · a1b2c3d4…ef01.0", or just the fingerprint when the issuer
|
|
151
|
+
// name could not be resolved — never the fingerprint alone dropped in favor
|
|
152
|
+
// of an unverified name.
|
|
153
|
+
const identityLine = [issuerName, fingerprint].filter(Boolean).join(' · ')
|
|
144
154
|
return (
|
|
145
155
|
<TouchableOpacity
|
|
146
156
|
style={styles.option}
|
|
@@ -149,11 +159,18 @@ function AssetOption({
|
|
|
149
159
|
accessibilityRole="button"
|
|
150
160
|
// The checkmark is not the only signal: state travels with the element.
|
|
151
161
|
accessibilityState={{ selected }}
|
|
152
|
-
accessibilityLabel={[label, figure].filter(Boolean).join(', ')}
|
|
162
|
+
accessibilityLabel={[label, identityLine, figure].filter(Boolean).join(', ')}
|
|
153
163
|
>
|
|
154
|
-
<
|
|
155
|
-
{
|
|
156
|
-
|
|
164
|
+
<View style={styles.optionBody}>
|
|
165
|
+
<Text style={[styles.optionLabel, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
166
|
+
{label}
|
|
167
|
+
</Text>
|
|
168
|
+
{!!identityLine && (
|
|
169
|
+
<Text style={[styles.optionIdentity, { color: colors.textTertiary }]} numberOfLines={1}>
|
|
170
|
+
{identityLine}
|
|
171
|
+
</Text>
|
|
172
|
+
)}
|
|
173
|
+
</View>
|
|
157
174
|
{!!figure && (
|
|
158
175
|
<Text style={[styles.optionFigure, { color: colors.textSecondary }]} numberOfLines={1}>
|
|
159
176
|
{figure}
|
|
@@ -178,7 +195,11 @@ const styles = StyleSheet.create({
|
|
|
178
195
|
paddingVertical: spacing.md,
|
|
179
196
|
paddingHorizontal: spacing.lg
|
|
180
197
|
},
|
|
181
|
-
|
|
198
|
+
optionBody: { flex: 1 },
|
|
199
|
+
optionLabel: { ...typography.body },
|
|
200
|
+
// XR-044: smaller and dimmer than the label — provenance for the rare
|
|
201
|
+
// collision, not something every glance needs.
|
|
202
|
+
optionIdentity: { ...typography.caption2, marginTop: 1, fontVariant: ['tabular-nums'] },
|
|
182
203
|
optionFigure: { ...typography.footnote, fontVariant: ['tabular-nums'] },
|
|
183
204
|
check: { marginLeft: spacing.xs }
|
|
184
205
|
})
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
spacing,
|
|
16
16
|
typography,
|
|
17
17
|
radii,
|
|
18
|
+
isAllowedServiceOrigin,
|
|
18
19
|
DEFAULT_MESSAGE_BOX_URL,
|
|
19
20
|
LEGACY_MESSAGE_BOX_URL,
|
|
20
21
|
MESSAGE_BOX_URL_KEY,
|
|
@@ -67,6 +68,21 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
|
|
|
67
68
|
showToast(t('enter_valid_url'), { type: 'error' })
|
|
68
69
|
return
|
|
69
70
|
}
|
|
71
|
+
// XR-065 (SEC2-074): this host carries every handle-rail MessageBox
|
|
72
|
+
// request -- a plain http: origin or one carrying embedded credentials
|
|
73
|
+
// had no policy at all before this, unlike the ARC endpoint's own
|
|
74
|
+
// https-except-local-dev check (validateArcUrl, XR-064).
|
|
75
|
+
let parsedUrl: URL
|
|
76
|
+
try {
|
|
77
|
+
parsedUrl = new URL(trimmed)
|
|
78
|
+
} catch {
|
|
79
|
+
showToast(t('enter_valid_url'), { type: 'error' })
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
if (!isAllowedServiceOrigin(parsedUrl)) {
|
|
83
|
+
showToast(t('enter_valid_url'), { type: 'error' })
|
|
84
|
+
return
|
|
85
|
+
}
|
|
70
86
|
setIsSaving(true)
|
|
71
87
|
try {
|
|
72
88
|
await AsyncStorage.setItem(MESSAGE_BOX_URL_KEY, trimmed)
|