@bsv/expo-wallet-toolbox 0.23.0 → 0.24.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 +133 -0
- package/README.md +1 -4
- package/android/build.gradle +15 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/org/bsv/boundedfetch/BoundedBody.java +19 -0
- package/android/src/main/java/org/bsv/boundedfetch/BoundedConnection.java +28 -0
- package/android/src/main/java/org/bsv/boundedfetch/BsvBoundedFetchModule.kt +114 -0
- package/core/backup/RemoteSyncReader.ts +71 -46
- package/core/backup/client.ts +6 -15
- package/core/backup/codec.ts +78 -13
- package/core/backup/constants.ts +3 -9
- package/core/backup/cursor.ts +8 -0
- package/core/backup/push.ts +26 -16
- package/core/backup/restore.ts +6 -5
- package/core/bridge/inbox.ts +169 -64
- package/core/bridge/memoryInboxStore.ts +10 -1
- package/core/constants.ts +7 -11
- package/core/context/WalletConnectionContext.tsx +85 -48
- package/core/context/WalletContext.tsx +30 -32
- package/core/context/usePairingAttempt.ts +31 -0
- package/core/e2e/broadcaster.ts +25 -0
- package/core/e2e/consentFixture.ts +46 -0
- package/core/e2e/mode.ts +42 -0
- package/core/headers/OfflineFirstChaintracks.ts +57 -107
- package/core/headers/headerConsensus.ts +230 -0
- package/core/headers/headerStore.ts +344 -122
- package/core/headers/prewarm.ts +4 -7
- package/core/headers/syncHeaders.ts +82 -12
- package/core/i18n/translations.tsx +47 -12
- package/core/identity/handleRegistry/client.ts +4 -2
- package/core/identity/handleRegistry/resolver.ts +7 -11
- package/core/index.ts +2 -0
- package/core/localpay/pending.ts +39 -4
- package/core/network/boundedFetch.ts +101 -0
- package/core/networks.ts +11 -13
- package/core/pay/rails/address.ts +5 -4
- package/core/pay/rails/handle.ts +3 -1
- package/core/pay/rails/sweep.ts +791 -0
- package/core/peerpay/brc29.ts +4 -0
- package/core/peerpay/handleResendRequests.ts +15 -2
- package/core/peerpay/outbox.ts +115 -2
- package/core/profiles/assertProfileEmpty.ts +2 -2
- package/core/profiles/profileStore.ts +3 -2
- package/core/services/arcadeBroadcastProvider.ts +260 -114
- package/core/services/secrets/kek.ts +5 -0
- package/core/services/secrets/migration.ts +27 -2
- package/core/services/secrets/policy.ts +6 -0
- package/core/services/vault/VaultKeyService.ts +5 -2
- package/core/services/vault/ceremony.ts +2 -2
- package/core/services/vault/ceremonyHost.ts +1 -1
- package/core/services/vault/guard.ts +10 -0
- package/core/services/vault/outputAuthority.ts +76 -0
- package/core/services/vault/transfers.ts +52 -28
- package/core/services/vault/vaultStore.ts +60 -14
- package/core/services/walletConnectionValidation.ts +13 -1
- package/core/services/walletServiceConfig.ts +8 -7
- package/core/stores/ConnectionStore.ts +17 -0
- package/core/toolboxConfig.ts +60 -1
- package/expo-module.config.json +5 -0
- package/ios/BoundedBody.swift +15 -0
- package/ios/BsvBoundedFetch.podspec +17 -0
- package/ios/BsvBoundedFetchModule.swift +121 -0
- package/package.json +7 -3
- package/ui/components/pay/AddressReceive.tsx +6 -2
- package/ui/components/pay/ImportedOutboxApproval.tsx +142 -0
- package/ui/components/pay/PayCellRow.tsx +3 -1
- package/ui/components/pay/PayForm.tsx +12 -2
- package/ui/components/pay/RecipientField.tsx +1 -0
- package/ui/components/pay/RequestHub.tsx +1 -0
- package/ui/components/pay/UniversalSend.tsx +110 -42
- package/ui/components/ui/ListRow.tsx +10 -2
- package/ui/components/vault/KeyChooser.tsx +1 -1
- package/ui/components/wallet/AmountInput.tsx +4 -1
- package/ui/components/wallet/BackupReminderSheet.tsx +8 -1
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +2 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +6 -1
- package/ui/components/wallet/ProfileButton.tsx +1 -0
- package/ui/importDatabases.ts +31 -6
- package/ui/screens/ConnectionsScreen.tsx +12 -3
- package/ui/screens/PairScreen.tsx +10 -3
- package/ui/screens/PayScreen.tsx +1 -0
- package/ui/screens/TrustScreen.tsx +6 -3
- package/ui/screens/VaultScreen.tsx +13 -3
- package/ui/screens/VaultTransferScreen.tsx +6 -3
- package/ui/screens/WalletConfigScreen.tsx +17 -2
- package/ui/screens/WalletHomeScreen.tsx +7 -1
|
@@ -29,11 +29,14 @@ import { useDirectPay } from '../../../core/directpay/DirectPayProvider'
|
|
|
29
29
|
import { fallbackPrompt, payIdentity } from '../../../core/directpay/payFlow'
|
|
30
30
|
import type { PayOutcome } from '../../../core/directpay/types'
|
|
31
31
|
import { userFacingPayError } from '../../../core/pay/userError'
|
|
32
|
+
import { postE2eBroadcast } from '../../../core/e2e/broadcaster'
|
|
33
|
+
import { isE2eBuild } from '../../../core/e2e/mode'
|
|
32
34
|
import PressableScale from '../ui/PressableScale'
|
|
33
35
|
import { showToast } from '../ui/Toast'
|
|
34
36
|
import { ConsequenceNote, PayAmountField, PayCta, PayField } from './PayForm'
|
|
35
37
|
import PaymentSuccessOverlay from './PaymentSuccessOverlay'
|
|
36
38
|
import ResultBanner from './ResultBanner'
|
|
39
|
+
import ImportedOutboxApproval from './ImportedOutboxApproval'
|
|
37
40
|
import RecipientField, { type RecipientRow } from './RecipientField'
|
|
38
41
|
import StepBar, { type PayStep } from './StepBar'
|
|
39
42
|
import { useMessageBoxConfig } from './MessageBoxConfig'
|
|
@@ -71,7 +74,6 @@ import {
|
|
|
71
74
|
sendToAddress,
|
|
72
75
|
getOutboxEntries,
|
|
73
76
|
pruneExpiredSent,
|
|
74
|
-
unsentEntries,
|
|
75
77
|
type OutboxEntry,
|
|
76
78
|
type Session,
|
|
77
79
|
haptics,
|
|
@@ -146,9 +148,18 @@ interface OutgoingSectionProps {
|
|
|
146
148
|
readonly t: ReturnType<typeof import('react-i18next').useTranslation>['t']
|
|
147
149
|
readonly onRetry: (entry: OutboxEntry) => void
|
|
148
150
|
readonly onCancel: (entry: OutboxEntry) => void
|
|
151
|
+
readonly renderImportedApproval: (entry: OutboxEntry) => React.ReactNode
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
function OutgoingSection({
|
|
154
|
+
function OutgoingSection({
|
|
155
|
+
entries,
|
|
156
|
+
retryingId,
|
|
157
|
+
colors,
|
|
158
|
+
t,
|
|
159
|
+
onRetry,
|
|
160
|
+
onCancel,
|
|
161
|
+
renderImportedApproval
|
|
162
|
+
}: OutgoingSectionProps) {
|
|
152
163
|
if (entries.length === 0) return null
|
|
153
164
|
|
|
154
165
|
return (
|
|
@@ -159,7 +170,11 @@ function OutgoingSection({ entries, retryingId, colors, t, onRetry, onCancel }:
|
|
|
159
170
|
const isLast = idx === entries.length - 1
|
|
160
171
|
// Unsent rows: delivery and/or broadcast still outstanding.
|
|
161
172
|
const accentColor = colors.warning
|
|
162
|
-
|
|
173
|
+
// Imported amount/recipient fields are shown only by the validating approval component.
|
|
174
|
+
const truncated =
|
|
175
|
+
entry.status === 'import_hold'
|
|
176
|
+
? t('review_imported_payment')
|
|
177
|
+
: `${entry.recipient.slice(0, 8)}…${entry.recipient.slice(-4)}`
|
|
163
178
|
return (
|
|
164
179
|
<View
|
|
165
180
|
key={entry.id}
|
|
@@ -175,46 +190,56 @@ function OutgoingSection({ entries, retryingId, colors, t, onRetry, onCancel }:
|
|
|
175
190
|
<Text style={[styles.outgoingRecipient, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
176
191
|
{truncated}
|
|
177
192
|
</Text>
|
|
178
|
-
|
|
179
|
-
<
|
|
180
|
-
|
|
193
|
+
{entry.status !== 'import_hold' && (
|
|
194
|
+
<Text style={[styles.outgoingAmount, { color: accentColor }]}>
|
|
195
|
+
<AmountDisplay>{entry.token.amount}</AmountDisplay>
|
|
196
|
+
</Text>
|
|
197
|
+
)}
|
|
181
198
|
</View>
|
|
182
199
|
|
|
183
200
|
{/* Status / error text */}
|
|
184
201
|
<Text style={[styles.outgoingStatusText, { color: colors.textSecondary }]} numberOfLines={2}>
|
|
185
|
-
{entry.
|
|
186
|
-
?
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
{entry.status === 'import_hold'
|
|
203
|
+
? t('tx_status_import_hold')
|
|
204
|
+
: entry.lastError
|
|
205
|
+
? isMessageBoxNetworkError(entry.lastError)
|
|
206
|
+
? t('message_box_unreachable')
|
|
207
|
+
: entry.lastError
|
|
208
|
+
: t('payment_not_delivered')}
|
|
190
209
|
</Text>
|
|
191
210
|
|
|
192
211
|
{/* Action buttons — full-width row, easy tap targets */}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
{entry.status === 'import_hold' ? (
|
|
213
|
+
renderImportedApproval(entry)
|
|
214
|
+
) : (
|
|
215
|
+
<View style={[styles.outgoingButtons, { borderTopColor: colors.separator }]}>
|
|
216
|
+
<PressableScale
|
|
217
|
+
onPress={() => onCancel(entry)}
|
|
218
|
+
disabled={isRetrying}
|
|
219
|
+
haptic="tap"
|
|
220
|
+
style={[styles.outgoingDismissButton, { borderRightColor: colors.separator }]}
|
|
221
|
+
>
|
|
222
|
+
<Text style={[styles.outgoingDismissText, { color: colors.textSecondary }]}>{t('cancel')}</Text>
|
|
223
|
+
</PressableScale>
|
|
224
|
+
<PressableScale
|
|
225
|
+
onPress={() => onRetry(entry)}
|
|
226
|
+
disabled={isRetrying}
|
|
227
|
+
haptic="tap"
|
|
228
|
+
style={styles.outgoingRetryButton}
|
|
229
|
+
>
|
|
230
|
+
{isRetrying ? (
|
|
231
|
+
<View style={styles.outgoingRetryBusy}>
|
|
232
|
+
<ActivityIndicator size="small" color={colors.accent} />
|
|
233
|
+
<Text style={[styles.outgoingRetryText, { color: colors.accent }]}>{t('resending')}</Text>
|
|
234
|
+
</View>
|
|
235
|
+
) : (
|
|
236
|
+
<Text style={[styles.outgoingRetryText, { color: colors.accent }]}>
|
|
237
|
+
{t('retry')}
|
|
238
|
+
</Text>
|
|
239
|
+
)}
|
|
240
|
+
</PressableScale>
|
|
241
|
+
</View>
|
|
242
|
+
)}
|
|
218
243
|
</View>
|
|
219
244
|
</View>
|
|
220
245
|
)
|
|
@@ -394,6 +419,8 @@ function UniversalSendInner(
|
|
|
394
419
|
// read-and-set before any await.
|
|
395
420
|
const sendingRef = useRef(false)
|
|
396
421
|
const [sendResult, setSendResult] = useState<{ type: 'success' | 'error'; message: string } | null>(null)
|
|
422
|
+
/** Stays on the review step after the mock broadcaster accepts. Production never sets it. */
|
|
423
|
+
const [e2eReceipt, setE2eReceipt] = useState<string | null>(null)
|
|
397
424
|
/**
|
|
398
425
|
* The failed-token-send note, kept apart from `sendResult` because it carries
|
|
399
426
|
* an action ("Check again") that a plain banner has nowhere to put.
|
|
@@ -817,7 +844,9 @@ function UniversalSendInner(
|
|
|
817
844
|
const loadOutbox = useCallback(async () => {
|
|
818
845
|
if (!storage) return
|
|
819
846
|
await pruneExpiredSent(storage)
|
|
820
|
-
setOutbox(
|
|
847
|
+
setOutbox(
|
|
848
|
+
(await getOutboxEntries(storage)).filter(entry => entry.status === 'unsent' || entry.status === 'import_hold')
|
|
849
|
+
)
|
|
821
850
|
}, [storage])
|
|
822
851
|
|
|
823
852
|
useEffect(() => {
|
|
@@ -1077,6 +1106,14 @@ function UniversalSendInner(
|
|
|
1077
1106
|
if (target.kind !== 'handle' || units === undefined) return
|
|
1078
1107
|
const sent = await sendToken(target, units)
|
|
1079
1108
|
if (!sent) return
|
|
1109
|
+
} else if (isE2eBuild() && target.kind === 'address') {
|
|
1110
|
+
// The harness has no coins. Confirm posts a description to the mock
|
|
1111
|
+
// broadcaster and stays on this step so the receipt can be asserted.
|
|
1112
|
+
// The real address rail is not called, and the mock does not relay.
|
|
1113
|
+
const txid = await postE2eBroadcast(target.address, amount)
|
|
1114
|
+
setE2eReceipt(txid)
|
|
1115
|
+
flashResult({ type: 'success', message: 'Test broadcaster accepted' })
|
|
1116
|
+
return
|
|
1080
1117
|
} else if (target.kind === 'handle') await sendHandle(target, amount)
|
|
1081
1118
|
else await sendAddress(target, amount)
|
|
1082
1119
|
setFigure(current => ({ ...current, text: '' }))
|
|
@@ -1131,8 +1168,19 @@ function UniversalSendInner(
|
|
|
1131
1168
|
storage
|
|
1132
1169
|
])
|
|
1133
1170
|
|
|
1171
|
+
const handleRetryError = useCallback(
|
|
1172
|
+
async (e: any) => {
|
|
1173
|
+
if (await handleWalletCheck(e)) return
|
|
1174
|
+
const reason = isMessageBoxNetworkError(e) ? t('message_box_unreachable') : e?.message || t('unknown_error')
|
|
1175
|
+
showToast(`${t('retry_failed')}: ${reason}`, { type: 'error' })
|
|
1176
|
+
},
|
|
1177
|
+
[t, handleWalletCheck]
|
|
1178
|
+
)
|
|
1179
|
+
|
|
1134
1180
|
const handleRetry = useCallback(
|
|
1135
1181
|
async (entry: OutboxEntry) => {
|
|
1182
|
+
// Held rows can become actionable only through the validated inline approval.
|
|
1183
|
+
if (entry.status !== 'unsent') return
|
|
1136
1184
|
// `peerPayClient` is built from the CURRENT setting, so it wins: the
|
|
1137
1185
|
// configured host may have changed since this entry was minted, and the
|
|
1138
1186
|
// client re-resolves the recipient's advertised inbox on every send
|
|
@@ -1157,15 +1205,13 @@ function UniversalSendInner(
|
|
|
1157
1205
|
await retryDelivery({ wallet: wallet as any, adminOriginator, client, storage, entry })
|
|
1158
1206
|
setSent({ amount: entry.token.amount, recipientIdentityKey: entry.recipient })
|
|
1159
1207
|
} catch (e: any) {
|
|
1160
|
-
|
|
1161
|
-
const reason = isMessageBoxNetworkError(e) ? t('message_box_unreachable') : e?.message || t('unknown_error')
|
|
1162
|
-
showToast(`${t('retry_failed')}: ${reason}`, { type: 'error' })
|
|
1208
|
+
await handleRetryError(e)
|
|
1163
1209
|
} finally {
|
|
1164
1210
|
setRetryingId(null)
|
|
1165
1211
|
await loadOutbox()
|
|
1166
1212
|
}
|
|
1167
1213
|
},
|
|
1168
|
-
[peerPayClient, storage, loadOutbox, wallet, adminOriginator, t,
|
|
1214
|
+
[peerPayClient, storage, loadOutbox, wallet, adminOriginator, t, handleRetryError, selectedNetwork]
|
|
1169
1215
|
)
|
|
1170
1216
|
|
|
1171
1217
|
const handleCancel = useCallback(
|
|
@@ -1493,11 +1539,13 @@ function UniversalSendInner(
|
|
|
1493
1539
|
busy={false}
|
|
1494
1540
|
label={t('pay_step_continue')}
|
|
1495
1541
|
icon="arrow-forward"
|
|
1542
|
+
testID="pay-continue"
|
|
1496
1543
|
/>
|
|
1497
1544
|
) : (
|
|
1498
1545
|
<PressableScale
|
|
1499
1546
|
onPress={() => loadExpoRouter().router.push('/contacts' as never)}
|
|
1500
1547
|
haptic="tap"
|
|
1548
|
+
testID="pay-contacts"
|
|
1501
1549
|
style={[
|
|
1502
1550
|
styles.outlineBtn,
|
|
1503
1551
|
{ backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }
|
|
@@ -1517,6 +1565,20 @@ function UniversalSendInner(
|
|
|
1517
1565
|
t={t}
|
|
1518
1566
|
onRetry={handleRetry}
|
|
1519
1567
|
onCancel={handleCancel}
|
|
1568
|
+
renderImportedApproval={entry => (
|
|
1569
|
+
<ImportedOutboxApproval
|
|
1570
|
+
entry={entry}
|
|
1571
|
+
storage={storage}
|
|
1572
|
+
wallet={wallet}
|
|
1573
|
+
adminOriginator={adminOriginator}
|
|
1574
|
+
colors={colors}
|
|
1575
|
+
t={t}
|
|
1576
|
+
disabled={retryingId !== null}
|
|
1577
|
+
onApproved={handleRetry}
|
|
1578
|
+
onCancel={() => void handleCancel(entry)}
|
|
1579
|
+
onError={handleRetryError}
|
|
1580
|
+
/>
|
|
1581
|
+
)}
|
|
1520
1582
|
/>
|
|
1521
1583
|
)}
|
|
1522
1584
|
</>
|
|
@@ -1540,6 +1602,7 @@ function UniversalSendInner(
|
|
|
1540
1602
|
busy={false}
|
|
1541
1603
|
label={t('pay_step_continue')}
|
|
1542
1604
|
icon="arrow-forward"
|
|
1605
|
+
testID="pay-continue"
|
|
1543
1606
|
/>
|
|
1544
1607
|
</>
|
|
1545
1608
|
)}
|
|
@@ -1687,7 +1750,12 @@ function UniversalSendInner(
|
|
|
1687
1750
|
<Text style={[styles.consequence, { color: colors.textSecondary }]}>{t('finish_or_cancel_outgoing')}</Text>
|
|
1688
1751
|
)}
|
|
1689
1752
|
|
|
1690
|
-
<PayCta onPress={handleSend} disabled={!canSend} busy={isSending} labelKey="send" />
|
|
1753
|
+
<PayCta onPress={handleSend} disabled={!canSend} busy={isSending} labelKey="send" testID="pay-send" />
|
|
1754
|
+
{e2eReceipt ? (
|
|
1755
|
+
<Text testID="e2e-broadcast-receipt" accessibilityLabel={`Test broadcaster accepted ${e2eReceipt}`}>
|
|
1756
|
+
Test broadcaster accepted
|
|
1757
|
+
</Text>
|
|
1758
|
+
) : null}
|
|
1691
1759
|
|
|
1692
1760
|
{/* A failed token send, in the app's own failure channel: error tone,
|
|
1693
1761
|
dismissible, and carrying at most one affordance. "Check again"
|
|
@@ -49,6 +49,7 @@ interface ListRowProps {
|
|
|
49
49
|
destructive?: boolean
|
|
50
50
|
trailing?: React.ReactNode
|
|
51
51
|
isLast?: boolean
|
|
52
|
+
testID?: string
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
@@ -67,7 +68,8 @@ export const ListRow: React.FC<ListRowProps> = ({
|
|
|
67
68
|
chevronDown = false,
|
|
68
69
|
destructive = false,
|
|
69
70
|
trailing,
|
|
70
|
-
isLast = false
|
|
71
|
+
isLast = false,
|
|
72
|
+
testID
|
|
71
73
|
}) => {
|
|
72
74
|
const { colors } = useTheme()
|
|
73
75
|
const Ionicons = loadIonicons()
|
|
@@ -135,7 +137,13 @@ export const ListRow: React.FC<ListRowProps> = ({
|
|
|
135
137
|
|
|
136
138
|
if (onPress) {
|
|
137
139
|
return (
|
|
138
|
-
<PressableScale
|
|
140
|
+
<PressableScale
|
|
141
|
+
onPress={onPress}
|
|
142
|
+
scaleTo={0.98}
|
|
143
|
+
haptic="tap"
|
|
144
|
+
testID={testID}
|
|
145
|
+
accessibilityLabel={value ? `${label}, ${value}` : label}
|
|
146
|
+
>
|
|
139
147
|
{content}
|
|
140
148
|
</PressableScale>
|
|
141
149
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* "Which key will you tap?" — a radio list of the vault's enrolled keys, used
|
|
3
|
-
* before a withdrawal (spec §4.2 step 1)
|
|
3
|
+
* before a deposit, a withdrawal (spec §4.2 step 1), or a re-lock (§4.3). Keys are
|
|
4
4
|
* shown everywhere as `nickname · …serialTail4` (§3.3), which is what
|
|
5
5
|
* `vaultKeyLabel` produces; the wizard, the vault screen and the transfer
|
|
6
6
|
* screen all import it from here so the format is written once.
|
|
@@ -75,6 +75,7 @@ interface AmountInputProps {
|
|
|
75
75
|
* fee comes out of BSV.
|
|
76
76
|
*/
|
|
77
77
|
maxValue?: string
|
|
78
|
+
testID?: string
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -93,7 +94,8 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
93
94
|
showMax = true,
|
|
94
95
|
maxLabelKey = 'entire_wallet_balance',
|
|
95
96
|
asset,
|
|
96
|
-
maxValue
|
|
97
|
+
maxValue,
|
|
98
|
+
testID
|
|
97
99
|
}) => {
|
|
98
100
|
const { t } = useTranslation()
|
|
99
101
|
const { colors } = useTheme()
|
|
@@ -245,6 +247,7 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
245
247
|
placeholderTextColor={colors.textTertiary}
|
|
246
248
|
keyboardType={keyboardType}
|
|
247
249
|
returnKeyType="done"
|
|
250
|
+
testID={testID}
|
|
248
251
|
style={[styles.input, { color: colors.textPrimary }]}
|
|
249
252
|
/>
|
|
250
253
|
<View style={styles.unitLabelPressable}>
|
|
@@ -83,7 +83,14 @@ export const BackupReminderSheet: React.FC<{
|
|
|
83
83
|
<Animated.View
|
|
84
84
|
style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.warning }, cardStyle]}
|
|
85
85
|
>
|
|
86
|
-
<PressableScale
|
|
86
|
+
<PressableScale
|
|
87
|
+
haptic="tap"
|
|
88
|
+
onPress={onClose}
|
|
89
|
+
testID="backup-reminder-close"
|
|
90
|
+
accessibilityRole="button"
|
|
91
|
+
accessibilityLabel="Close"
|
|
92
|
+
style={styles.closeButton}
|
|
93
|
+
>
|
|
87
94
|
<Ionicons name="close" size={20} color={colors.textSecondary} />
|
|
88
95
|
</PressableScale>
|
|
89
96
|
|
|
@@ -88,6 +88,7 @@ export const BiometricAdvisoryModal: React.FC<{
|
|
|
88
88
|
haptic="confirm"
|
|
89
89
|
onPress={loading ? undefined : onContinue}
|
|
90
90
|
disabled={loading}
|
|
91
|
+
testID="biometric-continue"
|
|
91
92
|
style={[styles.primary, { backgroundColor: colors.accent, opacity: loading ? 0.7 : 1 }]}
|
|
92
93
|
>
|
|
93
94
|
{loading ? (
|
|
@@ -101,6 +102,7 @@ export const BiometricAdvisoryModal: React.FC<{
|
|
|
101
102
|
haptic="tap"
|
|
102
103
|
onPress={loading ? undefined : onCancel}
|
|
103
104
|
disabled={loading}
|
|
105
|
+
testID="biometric-cancel"
|
|
104
106
|
style={styles.secondary}
|
|
105
107
|
>
|
|
106
108
|
<Text style={[styles.secondaryLabel, { color: loading ? colors.textTertiary : colors.textSecondary }]}>
|
|
@@ -46,7 +46,12 @@ export const ImportFromBackupPrompt: React.FC<{
|
|
|
46
46
|
<Text style={[styles.title, { color: colors.textPrimary }]}>{t('import_prompt_title')}</Text>
|
|
47
47
|
<Text style={[styles.body, { color: colors.textSecondary }]}>{t('import_prompt_body')}</Text>
|
|
48
48
|
</View>
|
|
49
|
-
<PressableScale
|
|
49
|
+
<PressableScale
|
|
50
|
+
haptic="tap"
|
|
51
|
+
onPress={onImport}
|
|
52
|
+
testID="import-from-backup"
|
|
53
|
+
style={[styles.button, { borderColor: colors.accent }]}
|
|
54
|
+
>
|
|
50
55
|
<Text style={[styles.buttonLabel, { color: colors.accent }]}>{t('import_prompt_action')}</Text>
|
|
51
56
|
</PressableScale>
|
|
52
57
|
</View>
|
|
@@ -86,6 +86,7 @@ export default function ProfileButton() {
|
|
|
86
86
|
onPress={onPress}
|
|
87
87
|
haptic="tap"
|
|
88
88
|
hitSlop={5}
|
|
89
|
+
testID="profile-button"
|
|
89
90
|
style={[styles.disc, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
90
91
|
accessibilityRole="button"
|
|
91
92
|
accessibilityLabel={profilesSupported ? t('profile_switcher_a11y') : t('profile')}
|
package/ui/importDatabases.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from '@bsv/expo-wallet-toolbox'
|
|
20
20
|
import { showAlert } from './components/ui/AlertCard'
|
|
21
21
|
import { showToast } from './components/ui/Toast'
|
|
22
|
+
import { OUTBOX_KEY, quarantineImportedOutbox } from '../core/peerpay/outbox'
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* expo-file-system and expo-document-picker both ship untransformed ESM/raw-TS
|
|
@@ -259,14 +260,21 @@ async function isSchemaTrusted(sourceDb: SQLite.SQLiteDatabase): Promise<boolean
|
|
|
259
260
|
try {
|
|
260
261
|
refDb = await SQLite.openDatabaseAsync(':memory:')
|
|
261
262
|
await createTables(refDb)
|
|
262
|
-
const allowedRows = (await refDb.getAllAsync(
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
const allowedRows = (await refDb.getAllAsync(`SELECT type, name, sql FROM sqlite_master`)) as Array<{
|
|
264
|
+
type: string
|
|
265
|
+
name: string
|
|
266
|
+
sql: string | null
|
|
267
|
+
}>
|
|
265
268
|
const allowed = new Map(allowedRows.map(r => [r.name, { type: r.type, sql: r.sql }]))
|
|
266
269
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
// Inspect every object. LIKE's '_' wildcard also hides legal attacker
|
|
271
|
+
// names such as sqliteXbackdoor; genuine internal objects must match the
|
|
272
|
+
// canonical reference rather than being exempted by a name prefix.
|
|
273
|
+
const objects = (await sourceDb.getAllAsync(`SELECT type, name, sql FROM sqlite_master`)) as Array<{
|
|
274
|
+
type: string
|
|
275
|
+
name: string
|
|
276
|
+
sql: string | null
|
|
277
|
+
}>
|
|
270
278
|
for (const obj of objects) {
|
|
271
279
|
if (obj.type === 'trigger' || obj.type === 'view') return false
|
|
272
280
|
if (obj.sql && /^\s*create\s+virtual\s+table/i.test(obj.sql)) return false
|
|
@@ -557,6 +565,23 @@ export async function importWalletDatabase(
|
|
|
557
565
|
// never delete or otherwise mutate the row, since it may already have
|
|
558
566
|
// been broadcast (XR-085).
|
|
559
567
|
await destDb.runAsync(`UPDATE offline_actions SET status = 'import_hold' WHERE status IN ('queued', 'posting')`)
|
|
568
|
+
|
|
569
|
+
// Preserve signed PeerPay history, but never restore old outgoing
|
|
570
|
+
// authority (including a snapshot taken before cancellation).
|
|
571
|
+
const importedDb = destDb
|
|
572
|
+
await quarantineImportedOutbox({
|
|
573
|
+
getKeyValue: async key => {
|
|
574
|
+
const row = await importedDb.getFirstAsync<{ value: string }>(
|
|
575
|
+
'SELECT value FROM key_value_store WHERE key = ?',
|
|
576
|
+
[key]
|
|
577
|
+
)
|
|
578
|
+
return row?.value
|
|
579
|
+
},
|
|
580
|
+
setKeyValue: async (key, value) => {
|
|
581
|
+
if (key !== OUTBOX_KEY) throw new Error('Unexpected import quarantine key')
|
|
582
|
+
await importedDb.runAsync('UPDATE key_value_store SET value = ? WHERE key = ?', [value, key])
|
|
583
|
+
}
|
|
584
|
+
})
|
|
560
585
|
}
|
|
561
586
|
} catch (e: any) {
|
|
562
587
|
console.error('[importDatabases] Failed to place database:', e.message)
|
|
@@ -2,7 +2,6 @@ import React, { useState } from 'react'
|
|
|
2
2
|
import { View, Text, TouchableOpacity, StyleSheet, Modal, ScrollView } from 'react-native'
|
|
3
3
|
import { observer } from 'mobx-react-lite'
|
|
4
4
|
import { WalletClient } from '@bsv/sdk'
|
|
5
|
-
import * as SecureStore from 'expo-secure-store'
|
|
6
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
7
6
|
import { useTranslation } from 'react-i18next'
|
|
8
7
|
import { GroupedSection } from '../components/ui/GroupedList'
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
import { validateStoredConnectionAuthorityTag } from '../../core/services/walletConnectionValidation'
|
|
29
28
|
import { computeConnectionAuthorityTag, verifyConnectionAuthorityTag } from '../../core/services/connectionAuthority'
|
|
30
29
|
import { revokeConnection } from '../../core/services/revokeConnection'
|
|
30
|
+
import { usePairingAttempt } from '../../core/context/usePairingAttempt'
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* expo-clipboard ships an untransformed ESM build (its Clipboard.js imports
|
|
@@ -156,6 +156,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
156
156
|
const { t } = useTranslation()
|
|
157
157
|
const { managers } = useWallet()
|
|
158
158
|
const { connect, reconnect, disconnect, sessionMeta } = useWalletConnection()
|
|
159
|
+
const pairingAttempt = usePairingAttempt()
|
|
159
160
|
const insets = useSafeAreaInsets()
|
|
160
161
|
const [scanning, setScanning] = useState(false)
|
|
161
162
|
const { router } = loadExpoRouter()
|
|
@@ -180,6 +181,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
180
181
|
showToast(`${t('wallet_not_ready')}: ${t('please_log_in_first')}`, { type: 'error' })
|
|
181
182
|
return
|
|
182
183
|
}
|
|
184
|
+
const isCurrent = pairingAttempt.begin(result.params.topic)
|
|
183
185
|
try {
|
|
184
186
|
const external = parseExternalOrigin(result.params.origin)
|
|
185
187
|
const wallet = new WalletClient(
|
|
@@ -200,13 +202,16 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
200
202
|
protocolID: result.params.protocolID,
|
|
201
203
|
backendIdentityKey: result.params.backendIdentityKey
|
|
202
204
|
})
|
|
205
|
+
if (!isCurrent()) return
|
|
203
206
|
connectionStore.stageAuthorityTag(result.params.topic, tag)
|
|
204
207
|
} catch (err) {
|
|
208
|
+
if (!isCurrent()) return
|
|
205
209
|
console.warn('[connections] failed to compute connection authority tag', err)
|
|
206
210
|
connectionStore.discardStagedAuthorityTag(result.params.topic)
|
|
207
211
|
}
|
|
208
212
|
await connect({ ...result.params, origin: external.origin }, wallet)
|
|
209
213
|
} catch (err) {
|
|
214
|
+
if (!isCurrent()) return
|
|
210
215
|
showToast(`${t('connection_failed')}: ${err instanceof Error ? err.message : t('unknown_error')}`, {
|
|
211
216
|
type: 'error'
|
|
212
217
|
})
|
|
@@ -230,6 +235,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
230
235
|
|
|
231
236
|
async function handleReconnect(conn: Connection) {
|
|
232
237
|
if (!managers.permissionsManager) return
|
|
238
|
+
const isCurrent = pairingAttempt.begin(conn.sessionId)
|
|
233
239
|
let external: ReturnType<typeof parseExternalOrigin>
|
|
234
240
|
try {
|
|
235
241
|
external = parseExternalOrigin(conn.origin)
|
|
@@ -268,6 +274,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
268
274
|
},
|
|
269
275
|
storedTag
|
|
270
276
|
)
|
|
277
|
+
if (!isCurrent()) return
|
|
271
278
|
if (!authentic) {
|
|
272
279
|
showToast(t('reconnect_needs_reapproval'), { type: 'error' })
|
|
273
280
|
return
|
|
@@ -284,7 +291,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
284
291
|
{ text: t('cancel'), key: 'cancel', style: 'cancel' }
|
|
285
292
|
]
|
|
286
293
|
})
|
|
287
|
-
if (choice !== 'reconnect') return
|
|
294
|
+
if (choice !== 'reconnect' || !isCurrent()) return
|
|
288
295
|
try {
|
|
289
296
|
const wallet = new WalletClient(
|
|
290
297
|
capWalletArgs(guardVaultAccess(managers.permissionsManager as any, ADMIN_ORIGINATOR)),
|
|
@@ -293,6 +300,7 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
293
300
|
conn = { ...conn, origin: external.origin }
|
|
294
301
|
await reconnect(conn, wallet)
|
|
295
302
|
} catch (err) {
|
|
303
|
+
if (!isCurrent()) return
|
|
296
304
|
showToast(`${t('reconnect_failed')}: ${err instanceof Error ? err.message : t('unknown_error')}`, {
|
|
297
305
|
type: 'error'
|
|
298
306
|
})
|
|
@@ -367,7 +375,6 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
367
375
|
</TouchableOpacity>
|
|
368
376
|
<TouchableOpacity
|
|
369
377
|
onPress={() => {
|
|
370
|
-
void SecureStore.deleteItemAsync(lastSeqKey(item.sessionId))
|
|
371
378
|
connectionStore.remove(item.sessionId)
|
|
372
379
|
}}
|
|
373
380
|
style={[styles.trailingAction, { marginLeft: spacing.md }]}
|
|
@@ -396,7 +403,9 @@ export const ConnectionsScreen = observer(function ConnectionsScreen() {
|
|
|
396
403
|
<TouchableOpacity
|
|
397
404
|
style={[styles.pasteBtn, { borderColor: colors.separator }]}
|
|
398
405
|
onPress={async () => {
|
|
406
|
+
const isCurrent = pairingAttempt.begin()
|
|
399
407
|
const text = await loadExpoClipboard().getStringAsync()
|
|
408
|
+
if (!isCurrent()) return
|
|
400
409
|
if (text) handleScan(text.trim())
|
|
401
410
|
}}
|
|
402
411
|
>
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from '@bsv/expo-wallet-toolbox'
|
|
21
21
|
import { computeConnectionAuthorityTag } from '../../core/services/connectionAuthority'
|
|
22
22
|
import { profileScopedKey } from '../../core/profiles/profileStore'
|
|
23
|
+
import { usePairingAttempt } from '../../core/context/usePairingAttempt'
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* expo-router is required lazily rather than imported at module scope: this
|
|
@@ -54,6 +55,7 @@ export function PairScreen() {
|
|
|
54
55
|
}>()
|
|
55
56
|
|
|
56
57
|
const { status, sessionMeta, errorMsg, connect, disconnect, startNavTimer, cancelNavTimer } = useWalletConnection()
|
|
58
|
+
const pairingAttempt = usePairingAttempt()
|
|
57
59
|
|
|
58
60
|
// Pre-connection validation error (before connect() is called)
|
|
59
61
|
const [preConnectError, setPreConnectError] = useState<string | null>(null)
|
|
@@ -130,6 +132,7 @@ export function PairScreen() {
|
|
|
130
132
|
setPreConnectError('Wallet not ready — please log in first')
|
|
131
133
|
return
|
|
132
134
|
}
|
|
135
|
+
const isCurrent = pairingAttempt.begin(params.topic)
|
|
133
136
|
try {
|
|
134
137
|
const external = parseExternalOrigin(params.origin)
|
|
135
138
|
// Guarded exactly like every sibling call site (connections.tsx): this is
|
|
@@ -160,8 +163,10 @@ export function PairScreen() {
|
|
|
160
163
|
protocolID: params.protocolID,
|
|
161
164
|
backendIdentityKey: params.backendIdentityKey
|
|
162
165
|
})
|
|
166
|
+
if (!isCurrent()) return
|
|
163
167
|
connectionStore.stageAuthorityTag(params.topic, tag)
|
|
164
168
|
} catch (err) {
|
|
169
|
+
if (!isCurrent()) return
|
|
165
170
|
console.warn('[PairScreen] failed to compute connection authority tag', err)
|
|
166
171
|
connectionStore.discardStagedAuthorityTag(params.topic)
|
|
167
172
|
}
|
|
@@ -177,11 +182,13 @@ export function PairScreen() {
|
|
|
177
182
|
wallet
|
|
178
183
|
)
|
|
179
184
|
} catch (err) {
|
|
185
|
+
if (!isCurrent()) return
|
|
180
186
|
setPreConnectError(err instanceof Error ? err.message : 'Connection failed')
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
|
|
184
190
|
function handleReject() {
|
|
191
|
+
pairingAttempt.cancel()
|
|
185
192
|
disconnect()
|
|
186
193
|
router.back()
|
|
187
194
|
}
|
|
@@ -242,7 +249,7 @@ export function PairScreen() {
|
|
|
242
249
|
keeps the registrable-domain suffix visible even for a long
|
|
243
250
|
attacker-chosen hostname designed to hide it behind a
|
|
244
251
|
trustworthy-looking prefix. */}
|
|
245
|
-
<Text style={styles.infoValue} numberOfLines={1} ellipsizeMode="middle">
|
|
252
|
+
<Text testID="pair-origin" style={styles.infoValue} numberOfLines={1} ellipsizeMode="middle">
|
|
246
253
|
{canonicalOrigin ?? ''}
|
|
247
254
|
</Text>
|
|
248
255
|
</View>
|
|
@@ -266,10 +273,10 @@ export function PairScreen() {
|
|
|
266
273
|
</View>
|
|
267
274
|
|
|
268
275
|
<View style={styles.buttonRow}>
|
|
269
|
-
<TouchableOpacity style={styles.rejectBtn} onPress={handleReject}>
|
|
276
|
+
<TouchableOpacity testID="pair-reject" style={styles.rejectBtn} onPress={handleReject}>
|
|
270
277
|
<Text style={styles.rejectBtnText}>Reject</Text>
|
|
271
278
|
</TouchableOpacity>
|
|
272
|
-
<TouchableOpacity style={styles.approveBtn} onPress={() => void handleApprove()}>
|
|
279
|
+
<TouchableOpacity testID="pair-approve" style={styles.approveBtn} onPress={() => void handleApprove()}>
|
|
273
280
|
<Text style={styles.approveBtnText}>Approve</Text>
|
|
274
281
|
</TouchableOpacity>
|
|
275
282
|
</View>
|
package/ui/screens/PayScreen.tsx
CHANGED