@bsv/expo-wallet-toolbox 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +292 -0
  2. package/README.md +0 -1
  3. package/assets/sounds/vault-deposit.wav +0 -0
  4. package/assets/sounds/vault-withdraw.wav +0 -0
  5. package/core/config.tsx +9 -1
  6. package/core/context/VaultContext.tsx +8 -11
  7. package/core/context/WalletConnectionContext.tsx +137 -52
  8. package/core/context/WalletContext.tsx +409 -20
  9. package/core/hooks/useConfirmationSound.ts +14 -8
  10. package/core/i18n/translations.tsx +3368 -952
  11. package/core/index.ts +97 -14
  12. package/core/localpay/build.ts +674 -37
  13. package/core/localpay/codec.ts +68 -5
  14. package/core/localpay/pending.ts +240 -22
  15. package/core/localpay/settlementAck.ts +149 -0
  16. package/core/localpay/types.ts +14 -1
  17. package/core/localpay/verify.ts +118 -69
  18. package/core/mandala/abortGuard.ts +134 -0
  19. package/core/mandala/basketMigration.ts +166 -0
  20. package/core/mandala/bundle.ts +244 -0
  21. package/core/mandala/createRuntime.ts +2437 -0
  22. package/core/mandala/drain.ts +670 -0
  23. package/core/mandala/permissionModule.ts +642 -0
  24. package/core/mandala/resendTransfer.ts +175 -0
  25. package/core/mandala/runtime.ts +357 -0
  26. package/core/mandala/settlementStore.ts +412 -0
  27. package/core/mandala/types.ts +290 -0
  28. package/core/offline/cancelParked.ts +94 -1
  29. package/core/offline/payerHold.ts +152 -12
  30. package/core/offline/tokenFrames.ts +197 -0
  31. package/core/parsePeerPayURI.ts +70 -17
  32. package/core/pay/rails/address.ts +51 -3
  33. package/core/pay/rails/handle.ts +88 -9
  34. package/core/pay/rails/index.ts +16 -6
  35. package/core/pay/rails/nearby.ts +114 -4
  36. package/core/services/capWalletArgs.ts +8 -9
  37. package/core/services/externalOrigin.ts +39 -0
  38. package/core/services/vault/VaultKeyService.ts +912 -251
  39. package/core/services/vault/ceremony.ts +435 -367
  40. package/core/services/vault/ceremonyHost.ts +27 -21
  41. package/core/services/vault/devMock.ts +30 -7
  42. package/core/services/vault/driver.ts +95 -41
  43. package/core/services/vault/guard.ts +514 -56
  44. package/core/services/vault/hardwareLease.ts +22 -0
  45. package/core/services/vault/mockYubiKey.ts +258 -90
  46. package/core/services/vault/pivReset.ts +145 -0
  47. package/core/services/vault/r1comb.ts +976 -0
  48. package/core/services/vault/session.ts +93 -26
  49. package/core/services/vault/transfers.ts +2617 -747
  50. package/core/services/vault/types.ts +100 -43
  51. package/core/services/vault/vaultStore.ts +991 -74
  52. package/core/services/walletConnectionValidation.ts +293 -0
  53. package/core/storage/StorageExpoSQLite.ts +382 -56
  54. package/core/storage/dbImage.ts +48 -0
  55. package/core/storage/methods/findSql.ts +0 -54
  56. package/core/storage/methods/listOutputsSql.ts +7 -3
  57. package/core/storage/methods/offlineActions.ts +15 -0
  58. package/core/storage/methods/processOfflineActions.ts +263 -6
  59. package/core/storage/methods/walletBalanceSql.ts +16 -4
  60. package/core/storage/schema/createTables.ts +123 -0
  61. package/core/storage/sqlUpdateValue.ts +24 -0
  62. package/core/toolboxConfig.ts +112 -1
  63. package/core/walletRepair/runWalletCheck.ts +19 -2
  64. package/package.json +25 -24
  65. package/ui/components/QRScanner.tsx +1 -1
  66. package/ui/components/pay/AdmissionNotice.tsx +99 -0
  67. package/ui/components/pay/AssetPicker.tsx +184 -0
  68. package/ui/components/pay/AvailableBalance.tsx +33 -2
  69. package/ui/components/pay/HandleReceive.tsx +213 -50
  70. package/ui/components/pay/NearbyFlow.tsx +616 -69
  71. package/ui/components/pay/PayForm.tsx +73 -8
  72. package/ui/components/pay/PaymentSuccessOverlay.tsx +43 -2
  73. package/ui/components/pay/RecipientField.tsx +49 -4
  74. package/ui/components/pay/RequestHub.tsx +68 -8
  75. package/ui/components/pay/ResultBanner.tsx +41 -4
  76. package/ui/components/pay/UniversalSend.tsx +534 -30
  77. package/ui/components/pay/tokenSendCopy.ts +116 -0
  78. package/ui/components/pay/useRecipientInput.ts +36 -7
  79. package/ui/components/ui/PermissionSheet.tsx +65 -4
  80. package/ui/components/ui/Sheet.tsx +9 -2
  81. package/ui/components/vault/EnrollWizard.tsx +1432 -488
  82. package/ui/components/vault/KeyChooser.tsx +96 -0
  83. package/ui/components/vault/VaultCeremonySheet.tsx +107 -43
  84. package/ui/components/vault/vaultErrorCopy.ts +145 -0
  85. package/ui/components/wallet/ActivityRow.tsx +101 -17
  86. package/ui/components/wallet/AmountInput.tsx +77 -25
  87. package/ui/components/wallet/AssetAmount.tsx +95 -0
  88. package/ui/components/wallet/AssetSwitcherDropdown.tsx +261 -0
  89. package/ui/components/wallet/tokenEviction.ts +65 -0
  90. package/ui/hooks/useExportWalletData.ts +39 -0
  91. package/ui/hooks/useMandala.ts +303 -0
  92. package/ui/hooks/useVaultBalance.ts +105 -7
  93. package/ui/hooks/useVaultCoverage.ts +52 -0
  94. package/ui/importDatabases.ts +7 -3
  95. package/ui/index.ts +50 -7
  96. package/ui/screens/ConnectionsScreen.tsx +46 -29
  97. package/ui/screens/PairScreen.tsx +12 -12
  98. package/ui/screens/PayScreen.tsx +130 -10
  99. package/ui/screens/SettingsScreen.tsx +18 -9
  100. package/ui/screens/VaultScreen.tsx +925 -171
  101. package/ui/screens/VaultTransferScreen.tsx +376 -123
  102. package/ui/screens/WalletCheckScreen.tsx +10 -1
  103. package/ui/screens/WalletConfigScreen.tsx +38 -16
  104. package/ui/screens/WalletHomeScreen.tsx +417 -86
  105. package/ui/screens/homeBadges.ts +9 -1
  106. package/ui/screens/tokenRowTitle.ts +68 -0
  107. package/ui/tokenFormat.ts +108 -0
  108. package/ui/tokenSeen.ts +75 -0
  109. package/ui/tokenStatus.ts +79 -0
  110. package/assets/sounds/vault-close.wav +0 -0
  111. package/assets/sounds/vault-open.wav +0 -0
  112. package/core/services/vault/k1.ts +0 -75
  113. package/core/services/vault/sealing.ts +0 -84
  114. package/core/services/vault/vaultDerivation.ts +0 -152
  115. package/core/services/vault/vaultPassphrase.ts +0 -287
  116. package/ui/components/vault/PassphraseField.tsx +0 -306
  117. package/ui/components/vault/PhraseBackupSheet.tsx +0 -227
  118. package/ui/screens/VaultRecoverScreen.tsx +0 -226
@@ -1,227 +0,0 @@
1
- /**
2
- * Reveals the recovery phrase and takes the user's word that they wrote it
3
- * down.
4
- *
5
- * No verification quiz by design: the person needs to be held accountable, but
6
- * verification should not be painful. The confirm is an attestation, and the
7
- * caller records it as such.
8
- *
9
- * The caller is responsible for reading the mnemonic out of secure storage —
10
- * getMnemonic() is already behind the biometric latch, so this component never
11
- * touches storage and never holds the phrase beyond its own mount.
12
- */
13
- import React, { useState } from 'react'
14
- import { View, Text, StyleSheet, ScrollView } from 'react-native'
15
- import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
16
- import PressableScale from '../ui/PressableScale'
17
- import { showToast } from '../ui/Toast'
18
-
19
- const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
20
-
21
- /**
22
- * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
23
- * etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
24
- * that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
25
- * Ionicons is loaded lazily, only when actually rendering, same pattern as
26
- * this package's other native-module-boundary fixes (expo-router, expo-blur).
27
- */
28
- type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
29
- let ioniconsComponent: IoniconsComponent | undefined
30
- function loadIonicons(): IoniconsComponent {
31
- if (!ioniconsComponent) {
32
- // eslint-disable-next-line @typescript-eslint/no-require-imports
33
- ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
34
- }
35
- return ioniconsComponent
36
- }
37
-
38
- /**
39
- * @react-native-clipboard/clipboard reaches for its native TurboModule at
40
- * import time (`TurboModuleRegistry.getEnforcing`), which throws under Jest
41
- * (no native binary registered there) even though the module itself
42
- * transforms fine. Required lazily, only when a handler actually copies
43
- * something, so importing the `ui` barrel never touches the native module.
44
- * Same pattern as WalletHomeScreen.tsx's lazy clipboard load.
45
- */
46
- type ClipboardModule = typeof import('@react-native-clipboard/clipboard').default
47
- let clipboardModule: ClipboardModule | undefined
48
- function loadClipboard(): ClipboardModule {
49
- if (!clipboardModule) {
50
- // eslint-disable-next-line @typescript-eslint/no-require-imports
51
- clipboardModule = require('@react-native-clipboard/clipboard').default as ClipboardModule
52
- }
53
- return clipboardModule
54
- }
55
-
56
- export const PhraseBackupSheet: React.FC<{
57
- mnemonic: string
58
- onAttest: () => void
59
- onCancel: () => void
60
- }> = ({ mnemonic, onAttest, onCancel }) => {
61
- const { colors } = useTheme()
62
- const [acknowledged, setAcknowledged] = useState(false)
63
- const words = mnemonic.trim().split(/\s+/)
64
- const Ionicons = loadIonicons()
65
-
66
- return (
67
- <ScrollView contentContainerStyle={styles.body}>
68
- <Text style={[styles.p, { color: colors.textSecondary }]}>
69
- {t('vault_phrase_intro', { count: words.length })}
70
- </Text>
71
-
72
- {/* Two fixed columns with the index in its own right-aligned gutter, so
73
- every word starts on the same x. The old grid let each cell size to
74
- its own content, which put the words on a ragged left edge and made a
75
- list you have to hunt through rather than one you can read down.
76
- Inverted (warning-tinted fill, high-contrast text) rather than the
77
- page's ordinary card styling — this is the one block of content the
78
- user actually has to act on (copy to paper), so it needs to read as
79
- distinct from the surrounding chrome, not blend into it. */}
80
- <View style={[styles.grid, { backgroundColor: colors.warning, borderColor: colors.warning }]}>
81
- {words.map((word, i) => (
82
- <View key={i} style={styles.wordCell}>
83
- <Text style={[styles.wordIndex, { color: colors.textOnAccent, opacity: 0.6 }]}>{i + 1}</Text>
84
- <Text style={[styles.word, { color: colors.textOnAccent }]}>{word}</Text>
85
- </View>
86
- ))}
87
- </View>
88
-
89
- {/* Copy is deliberately the quietest control on the screen. The screen is
90
- asking for pen and paper; a full-width button offering the clipboard
91
- instead argues against its own instruction. */}
92
- <PressableScale
93
- onPress={() => {
94
- loadClipboard().setString(mnemonic)
95
- showToast(t('vault_phrase_copied'), { type: 'success' })
96
- }}
97
- style={styles.copyRow}
98
- >
99
- <Ionicons name="copy-outline" size={15} color={colors.textSecondary} />
100
- <Text style={[styles.copyLabel, { color: colors.textSecondary }]}>{t('vault_phrase_copy')}</Text>
101
- </PressableScale>
102
-
103
- {/* Tinted rather than outlined: the border box read as an error state on
104
- a screen where nothing has gone wrong. */}
105
- <View style={[styles.warnBox, { backgroundColor: colors.warning + '14' }]}>
106
- <Ionicons name="warning-outline" size={16} color={colors.warning} />
107
- <Text style={[styles.warnText, { color: colors.textSecondary }]}>
108
- {t('vault_phrase_warning')}
109
- </Text>
110
- </View>
111
-
112
- <PressableScale
113
- onPress={() => setAcknowledged(a => !a)}
114
- style={[
115
- styles.checkRow,
116
- {
117
- // colors.fill, not `colors.accent + '14'`: accent is the NAMED colour
118
- // 'white' (dark) / 'black' (light), so appending hex alpha produced
119
- // "white14" and Reanimated threw on the animated style. fill is the
120
- // theme's own translucent overlay and is valid in both themes.
121
- backgroundColor: acknowledged ? colors.fill : colors.backgroundSecondary,
122
- borderColor: acknowledged ? colors.accent : colors.separator
123
- }
124
- ]}
125
- >
126
- <Ionicons
127
- name={acknowledged ? 'checkmark-circle' : 'ellipse-outline'}
128
- size={22}
129
- color={acknowledged ? colors.accent : colors.textTertiary}
130
- />
131
- <Text style={[styles.checkLabel, { color: colors.textPrimary }]}>
132
- {t('vault_phrase_attest')}
133
- </Text>
134
- </PressableScale>
135
-
136
- <PressableScale
137
- haptic="confirm"
138
- onPress={acknowledged ? onAttest : undefined}
139
- style={[
140
- styles.primary,
141
- // Outlined until the box is ticked, matching the enrolment gate: a
142
- // disabled fill in the secondary background is invisible in dark mode.
143
- {
144
- backgroundColor: acknowledged ? colors.accent : 'transparent',
145
- borderWidth: acknowledged ? 0 : StyleSheet.hairlineWidth,
146
- borderColor: colors.separator
147
- }
148
- ]}
149
- >
150
- <Text
151
- style={[
152
- styles.primaryLabel,
153
- { color: acknowledged ? colors.textOnAccent : colors.textTertiary }
154
- ]}
155
- >
156
- {t('vault_phrase_done')}
157
- </Text>
158
- </PressableScale>
159
-
160
- <PressableScale onPress={onCancel} style={styles.secondary}>
161
- <Text style={[styles.secondaryLabel, { color: colors.textSecondary }]}>
162
- {t('vault_back')}
163
- </Text>
164
- </PressableScale>
165
- </ScrollView>
166
- )
167
- }
168
-
169
- const styles = StyleSheet.create({
170
- body: { padding: spacing.xl, gap: spacing.lg },
171
- p: { ...typography.subhead, textAlign: 'center' },
172
- grid: {
173
- flexDirection: 'row',
174
- flexWrap: 'wrap',
175
- rowGap: spacing.md,
176
- borderRadius: radii.md,
177
- borderWidth: StyleSheet.hairlineWidth,
178
- paddingVertical: spacing.lg,
179
- paddingHorizontal: spacing.md
180
- },
181
- wordCell: {
182
- width: '50%',
183
- flexDirection: 'row',
184
- alignItems: 'baseline',
185
- gap: spacing.sm,
186
- paddingHorizontal: spacing.sm
187
- },
188
- // Fixed gutter, right-aligned: 1 and 12 then occupy the same width and the
189
- // words line up in two clean columns.
190
- wordIndex: { ...typography.caption2, width: 20, textAlign: 'right' },
191
- word: { ...typography.body, fontWeight: '600' },
192
- copyRow: {
193
- flexDirection: 'row',
194
- alignItems: 'center',
195
- alignSelf: 'center',
196
- gap: spacing.xs,
197
- paddingVertical: spacing.xs,
198
- paddingHorizontal: spacing.sm
199
- },
200
- copyLabel: { ...typography.footnote },
201
- warnBox: {
202
- flexDirection: 'row',
203
- gap: spacing.sm,
204
- alignItems: 'flex-start',
205
- borderRadius: radii.md,
206
- padding: spacing.md
207
- },
208
- warnText: { ...typography.footnote, flex: 1 },
209
- checkRow: {
210
- flexDirection: 'row',
211
- alignItems: 'center',
212
- gap: spacing.md,
213
- borderRadius: radii.md,
214
- borderWidth: StyleSheet.hairlineWidth,
215
- padding: spacing.lg
216
- },
217
- checkLabel: { ...typography.subhead, flex: 1 },
218
- primary: {
219
- width: '100%',
220
- borderRadius: radii.md,
221
- paddingVertical: spacing.lg,
222
- alignItems: 'center'
223
- },
224
- primaryLabel: { ...typography.headline },
225
- secondary: { paddingVertical: spacing.md, alignItems: 'center' },
226
- secondaryLabel: { ...typography.body }
227
- })
@@ -1,226 +0,0 @@
1
- /**
2
- * Vault recovery — full screen, not a drawer.
3
- *
4
- * The escape hatch when the hardware key is lost or its PIV applet is bricked.
5
- * It sweeps the vault to the everyday balance WITHOUT the key, then clears the
6
- * vault.
7
- *
8
- * Requires the wallet's own recovery phrase (already on this device) plus the
9
- * vault passphrase chosen at enrollment. BIP39 passphrases have no checksum,
10
- * so a typo silently derives a different, valid, empty vault node rather than
11
- * throwing. v4 vault meta stores no key material to catch that here anymore —
12
- * the sweep itself catches it instead: every vault output mismatches a wrong
13
- * key (transfers.ts's prepareSpends), and the resulting
14
- * VaultError('wrong-key') is mapped below to the passphrase copy the user
15
- * actually needs to see.
16
- */
17
- import React, { useCallback, useState } from 'react'
18
- import { View, Text, StyleSheet, TextInput, ScrollView, ActivityIndicator, TouchableOpacity } from 'react-native'
19
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
20
- import PressableScale from '../components/ui/PressableScale'
21
- import { showToast } from '../components/ui/Toast'
22
- import {
23
- useTheme,
24
- spacing,
25
- radii,
26
- typography,
27
- haptics,
28
- useWallet,
29
- useLocalStorage,
30
- disableVault,
31
- recoverVaultHD,
32
- sweepVaultWithHD,
33
- type VaultWallet,
34
- VaultError,
35
- i18n
36
- } from '@bsv/expo-wallet-toolbox'
37
-
38
- const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
39
-
40
- /**
41
- * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
42
- * etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
43
- * that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
44
- * Ionicons is loaded lazily, only when actually rendering, same pattern as
45
- * this package's other native-module-boundary fixes (expo-router, expo-blur).
46
- */
47
- type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
48
- let ioniconsComponent: IoniconsComponent | undefined
49
- function loadIonicons(): IoniconsComponent {
50
- if (!ioniconsComponent) {
51
- // eslint-disable-next-line @typescript-eslint/no-require-imports
52
- ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
53
- }
54
- return ioniconsComponent
55
- }
56
-
57
- /**
58
- * expo-router is required lazily rather than imported at module scope: this
59
- * file is barrel-exported from the package's `ui` entry point, and a static
60
- * top-level `import` of expo-router pulls in its own untransformed JSX
61
- * source (Navigator.js etc.), which Jest cannot parse for any consumer of the
62
- * barrel, even one that never navigates. Same pattern as
63
- * core/context/WalletContext.tsx's and WalletHomeScreen.tsx's lazy
64
- * expo-router load.
65
- */
66
- type ExpoRouterModule = typeof import('expo-router')
67
- let expoRouterMod: ExpoRouterModule | undefined
68
- function loadExpoRouter(): ExpoRouterModule {
69
- if (!expoRouterMod) {
70
- // eslint-disable-next-line @typescript-eslint/no-require-imports
71
- expoRouterMod = require('expo-router') as ExpoRouterModule
72
- }
73
- return expoRouterMod
74
- }
75
-
76
- export function VaultRecoverScreen() {
77
- const { colors } = useTheme()
78
- const insets = useSafeAreaInsets()
79
- const { router } = loadExpoRouter()
80
- const Ionicons = loadIonicons()
81
- const { managers, adminOriginator } = useWallet()
82
- const { getMnemonic } = useLocalStorage()
83
-
84
- const [passphrase, setPassphrase] = useState('')
85
- const [busy, setBusy] = useState(false)
86
- const [error, setError] = useState<string | null>(null)
87
-
88
- const run = useCallback(async () => {
89
- const pm = managers?.permissionsManager
90
- if (!pm) return
91
- setBusy(true)
92
- setError(null)
93
- try {
94
- const mnemonic = await getMnemonic()
95
- if (!mnemonic) throw new VaultError('bad-mnemonic', t('vault_requires_mnemonic'))
96
- const hd = await recoverVaultHD(mnemonic, passphrase)
97
-
98
- // sweepVaultWithHD caps at VAULT_MAX_INPUTS per call (see transfers.ts) and
99
- // reports how many vault outputs it left behind. A vault holding more than
100
- // that cap needs several sweeps, so repeat until either call reports
101
- // nothing left to do: `null` means the vault was already empty when that
102
- // sweep ran, and `remainingInputs === 0` means the sweep that just ran
103
- // cleared the last of it. Each successful iteration strictly reduces the
104
- // number of vault outputs still held (it spends min(remaining,
105
- // VAULT_MAX_INPUTS) > 0 of them), so remainingInputs decreases every pass
106
- // and the loop is guaranteed to terminate at 0 or null. A thrown error
107
- // (e.g. 'wrong-key' from a mismatched passphrase) exits the loop and the
108
- // catch below runs instead — disableVault() is never reached, and the
109
- // vault is left exactly as it was before the failed iteration.
110
- let result = await sweepVaultWithHD(pm as unknown as VaultWallet, adminOriginator, hd, t('vault_recover_reason'))
111
- while (result !== null && result.remainingInputs > 0) {
112
- result = await sweepVaultWithHD(pm as unknown as VaultWallet, adminOriginator, hd, t('vault_recover_reason'))
113
- }
114
-
115
- await disableVault()
116
- haptics.success()
117
- showToast(t('vault_recovered_toast'), { type: 'success' })
118
- setPassphrase('')
119
- router.back()
120
- } catch (e) {
121
- const code = e instanceof VaultError ? e.code : undefined
122
- // The sweep's prepareSpends throws 'wrong-key' when every vault output
123
- // mismatches the derived key — on this screen that always means the
124
- // typed passphrase does not match the one this vault was enrolled
125
- // with (there is no YubiKey involved here to be the "wrong" one), so
126
- // show the passphrase-specific copy rather than the sweep's own
127
- // generic wrong-key message.
128
- const msg =
129
- code === 'wrong-key'
130
- ? t('vault_recover_wrong_passphrase')
131
- : e instanceof VaultError
132
- ? e.message || t(`vault_err_${e.code.replace(/-/g, '_')}`)
133
- : t('vault_recover_failed')
134
- setError(msg)
135
- haptics.error()
136
- } finally {
137
- setBusy(false)
138
- }
139
- }, [passphrase, managers?.permissionsManager, adminOriginator, getMnemonic])
140
-
141
- const canRun = passphrase.length > 0
142
-
143
- return (
144
- <View style={[styles.container, { backgroundColor: colors.backgroundSecondary, paddingTop: insets.top }]}>
145
- <View style={[styles.header, { borderBottomColor: colors.separator }]}>
146
- <TouchableOpacity onPress={() => router.back()} style={styles.iconBtn}>
147
- <Ionicons name="chevron-back" size={24} color={colors.textSecondary} />
148
- </TouchableOpacity>
149
- <Text style={[styles.headerTitle, { color: colors.textPrimary }]}>{t('vault_recover_title')}</Text>
150
- <View style={styles.iconBtn} />
151
- </View>
152
-
153
- <ScrollView contentContainerStyle={styles.body} keyboardShouldPersistTaps="handled">
154
- <Text style={[styles.sub, { color: colors.textSecondary }]}>{t('vault_recover_sub')}</Text>
155
-
156
- <Text style={[styles.label, { color: colors.textPrimary }]}>{t('vault_recover_passphrase_label')}</Text>
157
- <Text style={[styles.fine, { color: colors.textSecondary }]}>{t('vault_recover_passphrase_help')}</Text>
158
- <TextInput
159
- style={[styles.input, { color: colors.textPrimary, backgroundColor: colors.backgroundElevated }]}
160
- value={passphrase}
161
- onChangeText={setPassphrase}
162
- placeholder={t('vault_recover_passphrase_placeholder')}
163
- placeholderTextColor={colors.textTertiary}
164
- autoCapitalize="none"
165
- autoCorrect={false}
166
- spellCheck={false}
167
- secureTextEntry
168
- />
169
-
170
- {error && <Text style={[styles.err, { color: colors.error }]}>{error}</Text>}
171
-
172
- <PressableScale
173
- haptic="confirm"
174
- onPress={canRun && !busy ? run : undefined}
175
- style={[
176
- styles.primary,
177
- {
178
- backgroundColor: canRun ? colors.accent : colors.backgroundElevated,
179
- opacity: busy ? 0.6 : 1
180
- }
181
- ]}
182
- >
183
- {busy ? (
184
- <ActivityIndicator color={colors.textOnAccent} />
185
- ) : (
186
- <Text style={[styles.primaryLabel, { color: canRun ? colors.textOnAccent : colors.textTertiary }]}>
187
- {t('vault_recover_cta')}
188
- </Text>
189
- )}
190
- </PressableScale>
191
- </ScrollView>
192
- </View>
193
- )
194
- }
195
-
196
- const styles = StyleSheet.create({
197
- container: { flex: 1 },
198
- header: {
199
- flexDirection: 'row',
200
- alignItems: 'center',
201
- justifyContent: 'space-between',
202
- paddingHorizontal: spacing.sm,
203
- paddingVertical: spacing.md,
204
- borderBottomWidth: StyleSheet.hairlineWidth
205
- },
206
- iconBtn: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' },
207
- headerTitle: { ...typography.headline },
208
- body: { padding: spacing.xl, gap: spacing.md },
209
- sub: { ...typography.subhead },
210
- label: { ...typography.footnote, fontWeight: '600', textTransform: 'uppercase' },
211
- fine: { ...typography.footnote },
212
- input: {
213
- borderRadius: radii.md,
214
- paddingHorizontal: spacing.lg,
215
- paddingVertical: spacing.md,
216
- ...typography.body
217
- },
218
- err: { ...typography.footnote },
219
- primary: {
220
- borderRadius: radii.md,
221
- paddingVertical: spacing.lg,
222
- alignItems: 'center',
223
- marginTop: spacing.sm
224
- },
225
- primaryLabel: { ...typography.headline }
226
- })