@bsv/expo-wallet-toolbox 0.1.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 (240) hide show
  1. package/LICENSE.txt +28 -0
  2. package/README.md +512 -0
  3. package/assets/sounds/payment-receive.wav +0 -0
  4. package/assets/sounds/payment-send.wav +0 -0
  5. package/assets/sounds/vault-close.wav +0 -0
  6. package/assets/sounds/vault-open.wav +0 -0
  7. package/core/amountFormatHelpers.ts +330 -0
  8. package/core/backup/RemoteSyncReader.ts +94 -0
  9. package/core/backup/client.ts +111 -0
  10. package/core/backup/codec.ts +218 -0
  11. package/core/backup/constants.ts +88 -0
  12. package/core/backup/cursor.ts +138 -0
  13. package/core/backup/derive.ts +46 -0
  14. package/core/backup/deviceId.ts +33 -0
  15. package/core/backup/erase.ts +67 -0
  16. package/core/backup/preference.ts +33 -0
  17. package/core/backup/push.ts +295 -0
  18. package/core/backup/restore.ts +152 -0
  19. package/core/backup/restoreOnImport.ts +119 -0
  20. package/core/backup/status.ts +46 -0
  21. package/core/config.tsx +47 -0
  22. package/core/constants.ts +35 -0
  23. package/core/context/ExchangeRateContext.tsx +69 -0
  24. package/core/context/LocalStorageProvider.tsx +225 -0
  25. package/core/context/UserContext.tsx +129 -0
  26. package/core/context/VaultContext.tsx +79 -0
  27. package/core/context/WalletConnectionContext.tsx +454 -0
  28. package/core/context/WalletContext.tsx +2938 -0
  29. package/core/context/buildGeneration.ts +37 -0
  30. package/core/deviceTier.ts +89 -0
  31. package/core/diskSpace.ts +62 -0
  32. package/core/displayCurrencies.ts +56 -0
  33. package/core/headers/OfflineFirstChaintracks.ts +176 -0
  34. package/core/headers/checkpoints.ts +39 -0
  35. package/core/headers/fs.ts +119 -0
  36. package/core/headers/headerStore.ts +333 -0
  37. package/core/headers/prewarm.ts +36 -0
  38. package/core/headers/syncHeaders.ts +73 -0
  39. package/core/hooks/useConfirmationSound.ts +135 -0
  40. package/core/hooks/useHaptics.ts +51 -0
  41. package/core/hooks/usePermissionQueue.ts +69 -0
  42. package/core/i18n/translations.tsx +6692 -0
  43. package/core/index.ts +295 -0
  44. package/core/localpay/blePermissions.ts +32 -0
  45. package/core/localpay/build.ts +392 -0
  46. package/core/localpay/codec.ts +338 -0
  47. package/core/localpay/deviceCaps.ts +175 -0
  48. package/core/localpay/nearbyAdvisory.ts +32 -0
  49. package/core/localpay/nearbyPermissions.ts +34 -0
  50. package/core/localpay/pending.ts +385 -0
  51. package/core/localpay/pendingAborts.ts +67 -0
  52. package/core/localpay/qr.ts +16 -0
  53. package/core/localpay/session.ts +277 -0
  54. package/core/localpay/sessionPolicy.ts +5 -0
  55. package/core/localpay/transport/awdl.ts +11 -0
  56. package/core/localpay/transport/ble.ts +159 -0
  57. package/core/localpay/transport/nearby.ts +12 -0
  58. package/core/localpay/transport/race.ts +110 -0
  59. package/core/localpay/transport/select.ts +128 -0
  60. package/core/localpay/transport/socket.ts +244 -0
  61. package/core/localpay/types.ts +82 -0
  62. package/core/localpay/verify.ts +204 -0
  63. package/core/logging.config.ts +10 -0
  64. package/core/logging.ts +77 -0
  65. package/core/mnemonicWallet.ts +180 -0
  66. package/core/monitor/TaskBackupPush.ts +168 -0
  67. package/core/monitor/TaskCreditInbox.ts +116 -0
  68. package/core/monitor/TaskDrainOutbox.ts +122 -0
  69. package/core/monitor/TaskSendOffline.ts +123 -0
  70. package/core/monitor/unfailRetry.ts +116 -0
  71. package/core/net/chainMatch.ts +34 -0
  72. package/core/net/online.ts +34 -0
  73. package/core/offline/cancelParked.ts +56 -0
  74. package/core/offline/hold.ts +127 -0
  75. package/core/offline/order.ts +109 -0
  76. package/core/offline/payerHold.ts +144 -0
  77. package/core/offline/plan.ts +264 -0
  78. package/core/offline/queueGrace.ts +52 -0
  79. package/core/parsePeerPayURI.ts +119 -0
  80. package/core/pay/beefRepair.ts +106 -0
  81. package/core/pay/creditErrors.ts +46 -0
  82. package/core/pay/creditInbox.ts +202 -0
  83. package/core/pay/damagedInbox.ts +64 -0
  84. package/core/pay/proofNudge.ts +23 -0
  85. package/core/pay/provenTxFromBump.ts +31 -0
  86. package/core/pay/rails/address.ts +329 -0
  87. package/core/pay/rails/handle.ts +617 -0
  88. package/core/pay/rails/index.ts +197 -0
  89. package/core/pay/rails/nearby.ts +79 -0
  90. package/core/pay/receiveFocus.ts +13 -0
  91. package/core/pay/recordProof.ts +91 -0
  92. package/core/pay/refreshProofGuard.ts +34 -0
  93. package/core/pay/sweeper.ts +75 -0
  94. package/core/pay/tokenAmount.ts +18 -0
  95. package/core/pay/userError.ts +18 -0
  96. package/core/pay/watchlist.ts +126 -0
  97. package/core/peerpay/control.ts +122 -0
  98. package/core/peerpay/handleResendRequests.ts +475 -0
  99. package/core/peerpay/inboxAttempts.ts +33 -0
  100. package/core/peerpay/metadataDecryptor.ts +42 -0
  101. package/core/peerpay/offlineNacks.ts +96 -0
  102. package/core/peerpay/outbox.ts +209 -0
  103. package/core/peerpay/rebuildToken.ts +76 -0
  104. package/core/peerpay/resendBeef.ts +115 -0
  105. package/core/services/arcadeBroadcastProvider.ts +214 -0
  106. package/core/services/capWalletArgs.ts +99 -0
  107. package/core/services/exchangeRate.ts +63 -0
  108. package/core/services/secrets/envelope.ts +102 -0
  109. package/core/services/secrets/hkdf.ts +37 -0
  110. package/core/services/secrets/index.ts +63 -0
  111. package/core/services/secrets/kek.ts +274 -0
  112. package/core/services/secrets/migration.ts +188 -0
  113. package/core/services/secrets/policy.ts +120 -0
  114. package/core/services/secrets/storage.ts +54 -0
  115. package/core/services/secrets/store.ts +125 -0
  116. package/core/services/secrets/types.ts +85 -0
  117. package/core/services/usdFxRates.ts +101 -0
  118. package/core/services/vault/VaultKeyService.ts +312 -0
  119. package/core/services/vault/backupAttestation.ts +136 -0
  120. package/core/services/vault/ceremony.ts +972 -0
  121. package/core/services/vault/ceremonyHost.ts +46 -0
  122. package/core/services/vault/devMock.ts +22 -0
  123. package/core/services/vault/driver.ts +197 -0
  124. package/core/services/vault/guard.ts +90 -0
  125. package/core/services/vault/k1.ts +75 -0
  126. package/core/services/vault/mockYubiKey.ts +217 -0
  127. package/core/services/vault/random.ts +20 -0
  128. package/core/services/vault/sealing.ts +84 -0
  129. package/core/services/vault/session.ts +59 -0
  130. package/core/services/vault/transfers.ts +1151 -0
  131. package/core/services/vault/types.ts +109 -0
  132. package/core/services/vault/vaultDerivation.ts +152 -0
  133. package/core/services/vault/vaultPassphrase.ts +287 -0
  134. package/core/services/vault/vaultStore.ts +104 -0
  135. package/core/services/walletArgLimits.ts +234 -0
  136. package/core/services/walletServiceConfig.ts +170 -0
  137. package/core/storage/LocalStorageAdapter.ts +58 -0
  138. package/core/storage/README.md +391 -0
  139. package/core/storage/StorageExpoSQLite.ts +2008 -0
  140. package/core/storage/errors.ts +73 -0
  141. package/core/storage/index.ts +3 -0
  142. package/core/storage/methods/findSql.ts +286 -0
  143. package/core/storage/methods/historyNotes.ts +61 -0
  144. package/core/storage/methods/listActionsSql.ts +212 -0
  145. package/core/storage/methods/listOutputsSql.ts +211 -0
  146. package/core/storage/methods/offlineActions.ts +156 -0
  147. package/core/storage/methods/processOfflineActions.ts +503 -0
  148. package/core/storage/methods/reclaim.ts +135 -0
  149. package/core/storage/methods/reviewStatusSql.ts +167 -0
  150. package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
  151. package/core/storage/methods/walletBalanceSql.ts +55 -0
  152. package/core/storage/schema/createTables.ts +385 -0
  153. package/core/storage/skipQueuedAncestors.ts +29 -0
  154. package/core/storage/sqlUpdateValue.ts +12 -0
  155. package/core/stores/ConnectionStore.ts +71 -0
  156. package/core/theme/ThemeContext.tsx +182 -0
  157. package/core/theme/assertThemeContrast.ts +109 -0
  158. package/core/theme/motion.ts +50 -0
  159. package/core/theme/tokens.ts +232 -0
  160. package/core/theme/useThemeStyles.tsx +156 -0
  161. package/core/walletDbRegistry.ts +110 -0
  162. package/core/walletMonitor.ts +149 -0
  163. package/core/walletRepair/runWalletCheck.ts +195 -0
  164. package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
  165. package/package.json +86 -0
  166. package/ui/backupShares.ts +367 -0
  167. package/ui/components/QRScanner.tsx +353 -0
  168. package/ui/components/pay/AddressReceive.tsx +507 -0
  169. package/ui/components/pay/AvailableBalance.tsx +61 -0
  170. package/ui/components/pay/HandleReceive.tsx +896 -0
  171. package/ui/components/pay/MessageBoxConfig.tsx +256 -0
  172. package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
  173. package/ui/components/pay/NearbyFlow.tsx +2542 -0
  174. package/ui/components/pay/OfflineNotice.tsx +337 -0
  175. package/ui/components/pay/PayCellRow.tsx +101 -0
  176. package/ui/components/pay/PayForm.tsx +223 -0
  177. package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
  178. package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
  179. package/ui/components/pay/RecipientField.tsx +308 -0
  180. package/ui/components/pay/RequestHub.tsx +75 -0
  181. package/ui/components/pay/ResultBanner.tsx +69 -0
  182. package/ui/components/pay/UniversalSend.tsx +687 -0
  183. package/ui/components/pay/useRecipientInput.ts +270 -0
  184. package/ui/components/security/WalletLockNotice.tsx +138 -0
  185. package/ui/components/ui/AlertCard.tsx +223 -0
  186. package/ui/components/ui/AppLogo.tsx +166 -0
  187. package/ui/components/ui/BlurChrome.tsx +72 -0
  188. package/ui/components/ui/Celebration.tsx +84 -0
  189. package/ui/components/ui/ChoiceSheet.ts +69 -0
  190. package/ui/components/ui/CustomSafeArea.tsx +74 -0
  191. package/ui/components/ui/ErrorBoundary.tsx +154 -0
  192. package/ui/components/ui/GroupedList.tsx +125 -0
  193. package/ui/components/ui/IconButton.tsx +105 -0
  194. package/ui/components/ui/ListRow.tsx +197 -0
  195. package/ui/components/ui/PermissionSheet.tsx +920 -0
  196. package/ui/components/ui/PresenceRow.tsx +215 -0
  197. package/ui/components/ui/PressableScale.tsx +105 -0
  198. package/ui/components/ui/ScreenGradient.tsx +47 -0
  199. package/ui/components/ui/ScrollFade.tsx +76 -0
  200. package/ui/components/ui/Sheet.tsx +342 -0
  201. package/ui/components/ui/Toast.tsx +142 -0
  202. package/ui/components/ui/index.ts +8 -0
  203. package/ui/components/vault/EnrollWizard.tsx +627 -0
  204. package/ui/components/vault/PassphraseField.tsx +306 -0
  205. package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
  206. package/ui/components/vault/VaultBackdrop.tsx +354 -0
  207. package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
  208. package/ui/components/wallet/ActivityRow.tsx +408 -0
  209. package/ui/components/wallet/AmountDisplay.tsx +48 -0
  210. package/ui/components/wallet/AmountInput.tsx +256 -0
  211. package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
  212. package/ui/components/wallet/Balance.tsx +144 -0
  213. package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
  214. package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
  215. package/ui/exportDatabases.ts +122 -0
  216. package/ui/exportTransactions.ts +129 -0
  217. package/ui/hooks/useOfflineNoticeActions.ts +136 -0
  218. package/ui/hooks/useOnline.ts +70 -0
  219. package/ui/hooks/useSpendableBalance.ts +58 -0
  220. package/ui/hooks/useVaultBalance.ts +50 -0
  221. package/ui/importDatabases.ts +170 -0
  222. package/ui/index.ts +136 -0
  223. package/ui/isImageUrl.ts +10 -0
  224. package/ui/printRecoveryShares.ts +93 -0
  225. package/ui/resolveIdentity.ts +125 -0
  226. package/ui/screens/ConnectionsScreen.tsx +438 -0
  227. package/ui/screens/LogsScreen.tsx +432 -0
  228. package/ui/screens/PairScreen.tsx +288 -0
  229. package/ui/screens/PayScreen.tsx +479 -0
  230. package/ui/screens/SettingsScreen.tsx +180 -0
  231. package/ui/screens/TrustScreen.tsx +831 -0
  232. package/ui/screens/VaultRecoverScreen.tsx +226 -0
  233. package/ui/screens/VaultScreen.tsx +423 -0
  234. package/ui/screens/VaultTransferScreen.tsx +293 -0
  235. package/ui/screens/WalletCheckScreen.tsx +539 -0
  236. package/ui/screens/WalletConfigScreen.tsx +1095 -0
  237. package/ui/screens/WalletHomeScreen.tsx +1597 -0
  238. package/ui/screens/homeBadges.ts +18 -0
  239. package/ui/txStatus.ts +79 -0
  240. package/ui/validateTrust.ts +44 -0
@@ -0,0 +1,256 @@
1
+ /**
2
+ * MessageBox server configuration — the state hook and the panel; both now
3
+ * render from Settings › Advanced.
4
+ *
5
+ * Both are copied verbatim out of app/payments.tsx (useMessageBoxConfig and
6
+ * ConfigPanel). The only change: the storage key, the default host and the
7
+ * "no server" sentinel are imported from the handle rail rather than redeclared
8
+ * here, so the screen and the rail cannot disagree about what they mean.
9
+ */
10
+ import React, { useCallback, useEffect, useState } from 'react'
11
+ import { ActivityIndicator, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'
12
+ import AsyncStorage from '@react-native-async-storage/async-storage'
13
+ import { showToast } from '../ui/Toast'
14
+ import {
15
+ spacing,
16
+ typography,
17
+ radii,
18
+ DEFAULT_MESSAGE_BOX_URL,
19
+ LEGACY_MESSAGE_BOX_URL,
20
+ MESSAGE_BOX_URL_KEY,
21
+ NO_MESSAGE_BOX
22
+ } from '@bsv/expo-wallet-toolbox'
23
+
24
+ /**
25
+ * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
26
+ * etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
27
+ * that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
28
+ * Ionicons is loaded lazily, only when actually rendering, same pattern as
29
+ * this package's other native-module-boundary fixes (expo-router, expo-blur).
30
+ */
31
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
32
+ let ioniconsComponent: IoniconsComponent | undefined
33
+ function loadIonicons(): IoniconsComponent {
34
+ if (!ioniconsComponent) {
35
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
36
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
37
+ }
38
+ return ioniconsComponent
39
+ }
40
+
41
+ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next').useTranslation>['t']) {
42
+ const [messageBoxUrl, setMessageBoxUrl] = useState(DEFAULT_MESSAGE_BOX_URL)
43
+ const [urlInput, setUrlInput] = useState(DEFAULT_MESSAGE_BOX_URL)
44
+ const [isSaving, setIsSaving] = useState(false)
45
+ const [showConfig, setShowConfig] = useState(false)
46
+
47
+ useEffect(() => {
48
+ AsyncStorage.getItem(MESSAGE_BOX_URL_KEY).then(saved => {
49
+ // A preference equal to the retired default means "default", not a
50
+ // deliberate choice of that server — follow the new default instead.
51
+ if (saved === LEGACY_MESSAGE_BOX_URL) {
52
+ void AsyncStorage.removeItem(MESSAGE_BOX_URL_KEY)
53
+ return
54
+ }
55
+ if (saved) {
56
+ setMessageBoxUrl(saved)
57
+ setUrlInput(saved)
58
+ if (saved === NO_MESSAGE_BOX) setShowConfig(true)
59
+ }
60
+ })
61
+ }, [])
62
+
63
+ const handleSave = useCallback(
64
+ async (input: string) => {
65
+ const trimmed = input.trim().replace(/\/+$/, '')
66
+ if (!trimmed) {
67
+ showToast(t('enter_valid_url'), { type: 'error' })
68
+ return
69
+ }
70
+ setIsSaving(true)
71
+ try {
72
+ await AsyncStorage.setItem(MESSAGE_BOX_URL_KEY, trimmed)
73
+ setMessageBoxUrl(trimmed)
74
+ setShowConfig(false)
75
+ showToast(t('message_box_saved'), { type: 'success' })
76
+ } catch (error: any) {
77
+ showToast(`Failed to save: ${error.message || 'unknown error'}`, { type: 'error' })
78
+ } finally {
79
+ setIsSaving(false)
80
+ }
81
+ },
82
+ [t]
83
+ )
84
+
85
+ const handleReset = useCallback(async () => {
86
+ await AsyncStorage.removeItem(MESSAGE_BOX_URL_KEY)
87
+ setMessageBoxUrl(DEFAULT_MESSAGE_BOX_URL)
88
+ setUrlInput(DEFAULT_MESSAGE_BOX_URL)
89
+ setShowConfig(false)
90
+ showToast(t('message_box_removed'), { type: 'success' })
91
+ }, [t])
92
+
93
+ const handleNone = useCallback(async () => {
94
+ const noneValue = NO_MESSAGE_BOX
95
+ setIsSaving(true)
96
+ try {
97
+ await AsyncStorage.setItem(MESSAGE_BOX_URL_KEY, noneValue)
98
+ setMessageBoxUrl(noneValue)
99
+ setUrlInput(noneValue)
100
+ setShowConfig(true)
101
+ showToast(t('message_box_removed'), { type: 'success' })
102
+ } catch (error: any) {
103
+ showToast(`Failed to save: ${error.message || 'unknown error'}`, { type: 'error' })
104
+ } finally {
105
+ setIsSaving(false)
106
+ }
107
+ }, [t])
108
+
109
+ return {
110
+ messageBoxUrl,
111
+ urlInput,
112
+ setUrlInput,
113
+ isSaving,
114
+ showConfig,
115
+ setShowConfig,
116
+ handleSave,
117
+ handleReset,
118
+ handleNone
119
+ }
120
+ }
121
+
122
+ interface ConfigPanelProps {
123
+ readonly urlInput: string
124
+ readonly isSaving: boolean
125
+ readonly colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']
126
+ readonly t: ReturnType<typeof import('react-i18next').useTranslation>['t']
127
+ readonly onChangeUrl: (v: string) => void
128
+ readonly onSave: () => void
129
+ readonly onReset: () => void
130
+ readonly onNone: () => void
131
+ }
132
+
133
+ export function ConfigPanel({ urlInput, isSaving, colors, t, onChangeUrl, onSave, onReset, onNone }: ConfigPanelProps) {
134
+ const Ionicons = loadIonicons()
135
+ const hasUrl = !!urlInput.trim()
136
+ const isNonDefault = urlInput.trim() !== DEFAULT_MESSAGE_BOX_URL && urlInput !== NO_MESSAGE_BOX
137
+ return (
138
+ <View style={[styles.configPanel, { backgroundColor: colors.backgroundSecondary }]}>
139
+ <Text style={[styles.configTitle, { color: colors.textPrimary }]}>{t('message_box_server')}</Text>
140
+ <Text style={[styles.configSubtitle, { color: colors.textSecondary }]}>{t('message_box_required')}</Text>
141
+ <TextInput
142
+ value={urlInput}
143
+ onChangeText={onChangeUrl}
144
+ placeholder={DEFAULT_MESSAGE_BOX_URL}
145
+ placeholderTextColor={colors.textTertiary}
146
+ autoCapitalize="none"
147
+ autoCorrect={false}
148
+ keyboardType="url"
149
+ returnKeyType="done"
150
+ onSubmitEditing={onSave}
151
+ style={[
152
+ styles.urlInput,
153
+ { color: colors.textPrimary, backgroundColor: colors.background, borderColor: colors.separator }
154
+ ]}
155
+ />
156
+
157
+ {/* Primary action: Save */}
158
+ <TouchableOpacity
159
+ onPress={onSave}
160
+ disabled={isSaving || !hasUrl}
161
+ style={[
162
+ styles.configButtonPrimary,
163
+ { backgroundColor: hasUrl ? colors.accent : colors.backgroundSecondary, opacity: hasUrl ? 1 : 0.5 }
164
+ ]}
165
+ >
166
+ {isSaving ? (
167
+ <ActivityIndicator size="small" color={hasUrl ? colors.background : colors.textSecondary} />
168
+ ) : (
169
+ <Text style={[styles.configButtonTextPrimary, { color: hasUrl ? colors.background : colors.textSecondary }]}>
170
+ {t('save')}
171
+ </Text>
172
+ )}
173
+ </TouchableOpacity>
174
+
175
+ {/* Secondary / destructive row */}
176
+ <View style={styles.configSecondaryActions}>
177
+ {isNonDefault && (
178
+ <TouchableOpacity onPress={onReset} style={[styles.configResetPill, { borderColor: colors.textSecondary }]}>
179
+ <Ionicons name="refresh" size={12} color={colors.textSecondary} />
180
+ <Text style={[styles.configResetText, { color: colors.textSecondary }]}>Default</Text>
181
+ </TouchableOpacity>
182
+ )}
183
+ <TouchableOpacity
184
+ onPress={onNone}
185
+ disabled={isSaving}
186
+ style={[styles.configNoneLink, { opacity: isSaving ? 0.4 : 1 }]}
187
+ hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
188
+ >
189
+ <Text style={[styles.configNoneText, { color: colors.error }]}>Use no server</Text>
190
+ </TouchableOpacity>
191
+ </View>
192
+ </View>
193
+ )
194
+ }
195
+
196
+ const styles = StyleSheet.create({
197
+ configPanel: {
198
+ padding: spacing.lg,
199
+ borderRadius: radii.md,
200
+ marginBottom: spacing.xl
201
+ },
202
+ configTitle: {
203
+ ...typography.headline,
204
+ marginBottom: spacing.xs
205
+ },
206
+ configSubtitle: {
207
+ ...typography.footnote,
208
+ marginBottom: spacing.md
209
+ },
210
+ urlInput: {
211
+ ...typography.body,
212
+ paddingHorizontal: spacing.md,
213
+ paddingVertical: spacing.md,
214
+ borderRadius: radii.md,
215
+ borderWidth: StyleSheet.hairlineWidth,
216
+ marginBottom: spacing.md
217
+ },
218
+ configButtonPrimary: {
219
+ flex: 2,
220
+ paddingVertical: spacing.sm + 2,
221
+ borderRadius: radii.sm,
222
+ alignItems: 'center',
223
+ justifyContent: 'center'
224
+ },
225
+ configButtonTextPrimary: {
226
+ ...typography.subhead,
227
+ fontWeight: '600'
228
+ },
229
+ // Secondary / destructive row (Reset pill + None link)
230
+ configSecondaryActions: {
231
+ flexDirection: 'row',
232
+ alignItems: 'center',
233
+ justifyContent: 'space-between',
234
+ marginTop: spacing.md
235
+ },
236
+ configResetPill: {
237
+ flexDirection: 'row',
238
+ alignItems: 'center',
239
+ gap: 4,
240
+ paddingHorizontal: spacing.sm,
241
+ paddingVertical: 5,
242
+ borderRadius: radii.sm,
243
+ borderWidth: StyleSheet.hairlineWidth
244
+ },
245
+ configResetText: {
246
+ ...typography.caption1,
247
+ fontWeight: '500'
248
+ },
249
+ configNoneLink: {
250
+ marginLeft: 'auto' as any
251
+ },
252
+ configNoneText: {
253
+ ...typography.caption1,
254
+ fontWeight: '500'
255
+ }
256
+ })
@@ -0,0 +1,111 @@
1
+ /**
2
+ * One-time heads-up shown the first time the user opens a nearby pay/get-paid
3
+ * cell, before the OS-level prompts that flow triggers (iOS Local Network
4
+ * access; Android Bluetooth/nearby-Wi-Fi permissions). Same rationale as
5
+ * BiometricAdvisoryModal: never let an OS permission dialog be the user's
6
+ * first signal that something is happening — explain it, briefly, first.
7
+ *
8
+ * The reassurance matters more than the mechanics here: this looks like the
9
+ * kind of permission that builds a tracking profile, and it is the opposite —
10
+ * strictly local, device-to-device, nothing sent to any server.
11
+ */
12
+ import React from 'react'
13
+ import { Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
14
+ import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
15
+ import PressableScale from '../ui/PressableScale'
16
+
17
+ const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
18
+
19
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
20
+ let ioniconsComponent: IoniconsComponent | undefined
21
+ function loadIonicons(): IoniconsComponent {
22
+ if (!ioniconsComponent) {
23
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
24
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
25
+ }
26
+ return ioniconsComponent
27
+ }
28
+
29
+ export const NearbyAdvisoryModal: React.FC<{
30
+ visible: boolean
31
+ onCancel: () => void
32
+ onContinue: () => void
33
+ }> = ({ visible, onCancel, onContinue }) => {
34
+ const { colors } = useTheme()
35
+ const Ionicons = loadIonicons()
36
+
37
+ if (!visible) return null
38
+
39
+ return (
40
+ <Modal
41
+ transparent
42
+ visible
43
+ animationType="fade"
44
+ onRequestClose={onCancel}
45
+ statusBarTranslucent={Platform.OS === 'android'}
46
+ navigationBarTranslucent={Platform.OS === 'android'}
47
+ >
48
+ <View style={[styles.backdrop, { backgroundColor: colors.scrim }]}>
49
+ <Pressable
50
+ style={StyleSheet.absoluteFill}
51
+ onPress={onCancel}
52
+ accessible={true}
53
+ accessibilityRole="button"
54
+ accessibilityLabel="Close"
55
+ accessibilityHint="Dismisses this advisory"
56
+ />
57
+ <View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
58
+ <View style={[styles.heroIcon, { backgroundColor: colors.fillTertiary }]}>
59
+ <Ionicons name="wifi" size={26} color={colors.accent} />
60
+ </View>
61
+ <Text style={[styles.title, { color: colors.textPrimary }]}>{t('nearby_advisory_title')}</Text>
62
+ <Text style={[styles.body, { color: colors.textSecondary }]}>{t('nearby_advisory_body')}</Text>
63
+
64
+ <PressableScale
65
+ haptic="confirm"
66
+ onPress={onContinue}
67
+ style={[styles.primary, { backgroundColor: colors.accent }]}
68
+ >
69
+ <Text style={[styles.primaryLabel, { color: colors.textOnAccent }]}>{t('continue')}</Text>
70
+ </PressableScale>
71
+
72
+ <PressableScale haptic="tap" onPress={onCancel} style={styles.secondary}>
73
+ <Text style={[styles.secondaryLabel, { color: colors.textSecondary }]}>{t('cancel')}</Text>
74
+ </PressableScale>
75
+ </View>
76
+ </View>
77
+ </Modal>
78
+ )
79
+ }
80
+
81
+ const styles = StyleSheet.create({
82
+ backdrop: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: spacing.xl },
83
+ card: {
84
+ width: '100%',
85
+ maxWidth: 360,
86
+ borderRadius: radii.xl,
87
+ borderWidth: StyleSheet.hairlineWidth,
88
+ padding: spacing.xl,
89
+ alignItems: 'center',
90
+ gap: spacing.md
91
+ },
92
+ heroIcon: {
93
+ width: 56,
94
+ height: 56,
95
+ borderRadius: 28,
96
+ alignItems: 'center',
97
+ justifyContent: 'center',
98
+ marginBottom: spacing.xs
99
+ },
100
+ title: { ...typography.title2, textAlign: 'center' },
101
+ body: { ...typography.subhead, textAlign: 'center', marginBottom: spacing.sm },
102
+ primary: {
103
+ width: '100%',
104
+ borderRadius: radii.md,
105
+ paddingVertical: spacing.lg,
106
+ alignItems: 'center'
107
+ },
108
+ primaryLabel: { ...typography.headline },
109
+ secondary: { paddingVertical: spacing.sm, alignItems: 'center' },
110
+ secondaryLabel: { ...typography.body }
111
+ })