@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.
- package/LICENSE.txt +28 -0
- package/README.md +512 -0
- package/assets/sounds/payment-receive.wav +0 -0
- package/assets/sounds/payment-send.wav +0 -0
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/amountFormatHelpers.ts +330 -0
- package/core/backup/RemoteSyncReader.ts +94 -0
- package/core/backup/client.ts +111 -0
- package/core/backup/codec.ts +218 -0
- package/core/backup/constants.ts +88 -0
- package/core/backup/cursor.ts +138 -0
- package/core/backup/derive.ts +46 -0
- package/core/backup/deviceId.ts +33 -0
- package/core/backup/erase.ts +67 -0
- package/core/backup/preference.ts +33 -0
- package/core/backup/push.ts +295 -0
- package/core/backup/restore.ts +152 -0
- package/core/backup/restoreOnImport.ts +119 -0
- package/core/backup/status.ts +46 -0
- package/core/config.tsx +47 -0
- package/core/constants.ts +35 -0
- package/core/context/ExchangeRateContext.tsx +69 -0
- package/core/context/LocalStorageProvider.tsx +225 -0
- package/core/context/UserContext.tsx +129 -0
- package/core/context/VaultContext.tsx +79 -0
- package/core/context/WalletConnectionContext.tsx +454 -0
- package/core/context/WalletContext.tsx +2938 -0
- package/core/context/buildGeneration.ts +37 -0
- package/core/deviceTier.ts +89 -0
- package/core/diskSpace.ts +62 -0
- package/core/displayCurrencies.ts +56 -0
- package/core/headers/OfflineFirstChaintracks.ts +176 -0
- package/core/headers/checkpoints.ts +39 -0
- package/core/headers/fs.ts +119 -0
- package/core/headers/headerStore.ts +333 -0
- package/core/headers/prewarm.ts +36 -0
- package/core/headers/syncHeaders.ts +73 -0
- package/core/hooks/useConfirmationSound.ts +135 -0
- package/core/hooks/useHaptics.ts +51 -0
- package/core/hooks/usePermissionQueue.ts +69 -0
- package/core/i18n/translations.tsx +6692 -0
- package/core/index.ts +295 -0
- package/core/localpay/blePermissions.ts +32 -0
- package/core/localpay/build.ts +392 -0
- package/core/localpay/codec.ts +338 -0
- package/core/localpay/deviceCaps.ts +175 -0
- package/core/localpay/nearbyAdvisory.ts +32 -0
- package/core/localpay/nearbyPermissions.ts +34 -0
- package/core/localpay/pending.ts +385 -0
- package/core/localpay/pendingAborts.ts +67 -0
- package/core/localpay/qr.ts +16 -0
- package/core/localpay/session.ts +277 -0
- package/core/localpay/sessionPolicy.ts +5 -0
- package/core/localpay/transport/awdl.ts +11 -0
- package/core/localpay/transport/ble.ts +159 -0
- package/core/localpay/transport/nearby.ts +12 -0
- package/core/localpay/transport/race.ts +110 -0
- package/core/localpay/transport/select.ts +128 -0
- package/core/localpay/transport/socket.ts +244 -0
- package/core/localpay/types.ts +82 -0
- package/core/localpay/verify.ts +204 -0
- package/core/logging.config.ts +10 -0
- package/core/logging.ts +77 -0
- package/core/mnemonicWallet.ts +180 -0
- package/core/monitor/TaskBackupPush.ts +168 -0
- package/core/monitor/TaskCreditInbox.ts +116 -0
- package/core/monitor/TaskDrainOutbox.ts +122 -0
- package/core/monitor/TaskSendOffline.ts +123 -0
- package/core/monitor/unfailRetry.ts +116 -0
- package/core/net/chainMatch.ts +34 -0
- package/core/net/online.ts +34 -0
- package/core/offline/cancelParked.ts +56 -0
- package/core/offline/hold.ts +127 -0
- package/core/offline/order.ts +109 -0
- package/core/offline/payerHold.ts +144 -0
- package/core/offline/plan.ts +264 -0
- package/core/offline/queueGrace.ts +52 -0
- package/core/parsePeerPayURI.ts +119 -0
- package/core/pay/beefRepair.ts +106 -0
- package/core/pay/creditErrors.ts +46 -0
- package/core/pay/creditInbox.ts +202 -0
- package/core/pay/damagedInbox.ts +64 -0
- package/core/pay/proofNudge.ts +23 -0
- package/core/pay/provenTxFromBump.ts +31 -0
- package/core/pay/rails/address.ts +329 -0
- package/core/pay/rails/handle.ts +617 -0
- package/core/pay/rails/index.ts +197 -0
- package/core/pay/rails/nearby.ts +79 -0
- package/core/pay/receiveFocus.ts +13 -0
- package/core/pay/recordProof.ts +91 -0
- package/core/pay/refreshProofGuard.ts +34 -0
- package/core/pay/sweeper.ts +75 -0
- package/core/pay/tokenAmount.ts +18 -0
- package/core/pay/userError.ts +18 -0
- package/core/pay/watchlist.ts +126 -0
- package/core/peerpay/control.ts +122 -0
- package/core/peerpay/handleResendRequests.ts +475 -0
- package/core/peerpay/inboxAttempts.ts +33 -0
- package/core/peerpay/metadataDecryptor.ts +42 -0
- package/core/peerpay/offlineNacks.ts +96 -0
- package/core/peerpay/outbox.ts +209 -0
- package/core/peerpay/rebuildToken.ts +76 -0
- package/core/peerpay/resendBeef.ts +115 -0
- package/core/services/arcadeBroadcastProvider.ts +214 -0
- package/core/services/capWalletArgs.ts +99 -0
- package/core/services/exchangeRate.ts +63 -0
- package/core/services/secrets/envelope.ts +102 -0
- package/core/services/secrets/hkdf.ts +37 -0
- package/core/services/secrets/index.ts +63 -0
- package/core/services/secrets/kek.ts +274 -0
- package/core/services/secrets/migration.ts +188 -0
- package/core/services/secrets/policy.ts +120 -0
- package/core/services/secrets/storage.ts +54 -0
- package/core/services/secrets/store.ts +125 -0
- package/core/services/secrets/types.ts +85 -0
- package/core/services/usdFxRates.ts +101 -0
- package/core/services/vault/VaultKeyService.ts +312 -0
- package/core/services/vault/backupAttestation.ts +136 -0
- package/core/services/vault/ceremony.ts +972 -0
- package/core/services/vault/ceremonyHost.ts +46 -0
- package/core/services/vault/devMock.ts +22 -0
- package/core/services/vault/driver.ts +197 -0
- package/core/services/vault/guard.ts +90 -0
- package/core/services/vault/k1.ts +75 -0
- package/core/services/vault/mockYubiKey.ts +217 -0
- package/core/services/vault/random.ts +20 -0
- package/core/services/vault/sealing.ts +84 -0
- package/core/services/vault/session.ts +59 -0
- package/core/services/vault/transfers.ts +1151 -0
- package/core/services/vault/types.ts +109 -0
- package/core/services/vault/vaultDerivation.ts +152 -0
- package/core/services/vault/vaultPassphrase.ts +287 -0
- package/core/services/vault/vaultStore.ts +104 -0
- package/core/services/walletArgLimits.ts +234 -0
- package/core/services/walletServiceConfig.ts +170 -0
- package/core/storage/LocalStorageAdapter.ts +58 -0
- package/core/storage/README.md +391 -0
- package/core/storage/StorageExpoSQLite.ts +2008 -0
- package/core/storage/errors.ts +73 -0
- package/core/storage/index.ts +3 -0
- package/core/storage/methods/findSql.ts +286 -0
- package/core/storage/methods/historyNotes.ts +61 -0
- package/core/storage/methods/listActionsSql.ts +212 -0
- package/core/storage/methods/listOutputsSql.ts +211 -0
- package/core/storage/methods/offlineActions.ts +156 -0
- package/core/storage/methods/processOfflineActions.ts +503 -0
- package/core/storage/methods/reclaim.ts +135 -0
- package/core/storage/methods/reviewStatusSql.ts +167 -0
- package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
- package/core/storage/methods/walletBalanceSql.ts +55 -0
- package/core/storage/schema/createTables.ts +385 -0
- package/core/storage/skipQueuedAncestors.ts +29 -0
- package/core/storage/sqlUpdateValue.ts +12 -0
- package/core/stores/ConnectionStore.ts +71 -0
- package/core/theme/ThemeContext.tsx +182 -0
- package/core/theme/assertThemeContrast.ts +109 -0
- package/core/theme/motion.ts +50 -0
- package/core/theme/tokens.ts +232 -0
- package/core/theme/useThemeStyles.tsx +156 -0
- package/core/walletDbRegistry.ts +110 -0
- package/core/walletMonitor.ts +149 -0
- package/core/walletRepair/runWalletCheck.ts +195 -0
- package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
- package/package.json +86 -0
- package/ui/backupShares.ts +367 -0
- package/ui/components/QRScanner.tsx +353 -0
- package/ui/components/pay/AddressReceive.tsx +507 -0
- package/ui/components/pay/AvailableBalance.tsx +61 -0
- package/ui/components/pay/HandleReceive.tsx +896 -0
- package/ui/components/pay/MessageBoxConfig.tsx +256 -0
- package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
- package/ui/components/pay/NearbyFlow.tsx +2542 -0
- package/ui/components/pay/OfflineNotice.tsx +337 -0
- package/ui/components/pay/PayCellRow.tsx +101 -0
- package/ui/components/pay/PayForm.tsx +223 -0
- package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
- package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
- package/ui/components/pay/RecipientField.tsx +308 -0
- package/ui/components/pay/RequestHub.tsx +75 -0
- package/ui/components/pay/ResultBanner.tsx +69 -0
- package/ui/components/pay/UniversalSend.tsx +687 -0
- package/ui/components/pay/useRecipientInput.ts +270 -0
- package/ui/components/security/WalletLockNotice.tsx +138 -0
- package/ui/components/ui/AlertCard.tsx +223 -0
- package/ui/components/ui/AppLogo.tsx +166 -0
- package/ui/components/ui/BlurChrome.tsx +72 -0
- package/ui/components/ui/Celebration.tsx +84 -0
- package/ui/components/ui/ChoiceSheet.ts +69 -0
- package/ui/components/ui/CustomSafeArea.tsx +74 -0
- package/ui/components/ui/ErrorBoundary.tsx +154 -0
- package/ui/components/ui/GroupedList.tsx +125 -0
- package/ui/components/ui/IconButton.tsx +105 -0
- package/ui/components/ui/ListRow.tsx +197 -0
- package/ui/components/ui/PermissionSheet.tsx +920 -0
- package/ui/components/ui/PresenceRow.tsx +215 -0
- package/ui/components/ui/PressableScale.tsx +105 -0
- package/ui/components/ui/ScreenGradient.tsx +47 -0
- package/ui/components/ui/ScrollFade.tsx +76 -0
- package/ui/components/ui/Sheet.tsx +342 -0
- package/ui/components/ui/Toast.tsx +142 -0
- package/ui/components/ui/index.ts +8 -0
- package/ui/components/vault/EnrollWizard.tsx +627 -0
- package/ui/components/vault/PassphraseField.tsx +306 -0
- package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
- package/ui/components/vault/VaultBackdrop.tsx +354 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
- package/ui/components/wallet/ActivityRow.tsx +408 -0
- package/ui/components/wallet/AmountDisplay.tsx +48 -0
- package/ui/components/wallet/AmountInput.tsx +256 -0
- package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
- package/ui/components/wallet/Balance.tsx +144 -0
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
- package/ui/exportDatabases.ts +122 -0
- package/ui/exportTransactions.ts +129 -0
- package/ui/hooks/useOfflineNoticeActions.ts +136 -0
- package/ui/hooks/useOnline.ts +70 -0
- package/ui/hooks/useSpendableBalance.ts +58 -0
- package/ui/hooks/useVaultBalance.ts +50 -0
- package/ui/importDatabases.ts +170 -0
- package/ui/index.ts +136 -0
- package/ui/isImageUrl.ts +10 -0
- package/ui/printRecoveryShares.ts +93 -0
- package/ui/resolveIdentity.ts +125 -0
- package/ui/screens/ConnectionsScreen.tsx +438 -0
- package/ui/screens/LogsScreen.tsx +432 -0
- package/ui/screens/PairScreen.tsx +288 -0
- package/ui/screens/PayScreen.tsx +479 -0
- package/ui/screens/SettingsScreen.tsx +180 -0
- package/ui/screens/TrustScreen.tsx +831 -0
- package/ui/screens/VaultRecoverScreen.tsx +226 -0
- package/ui/screens/VaultScreen.tsx +423 -0
- package/ui/screens/VaultTransferScreen.tsx +293 -0
- package/ui/screens/WalletCheckScreen.tsx +539 -0
- package/ui/screens/WalletConfigScreen.tsx +1095 -0
- package/ui/screens/WalletHomeScreen.tsx +1597 -0
- package/ui/screens/homeBadges.ts +18 -0
- package/ui/txStatus.ts +79 -0
- package/ui/validateTrust.ts +44 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Open BSV License version 4
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 BSV Blockchain Association ("Bitcoin Association")
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1 - The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2 - The Software, and any software that is derived from the Software or parts thereof,
|
|
16
|
+
can only be used on the Bitcoin SV blockchains. The Bitcoin SV blockchains are defined,
|
|
17
|
+
for purposes of this license, as the Bitcoin blockchain containing block height #556767
|
|
18
|
+
with the hash "000000000000000001d956714215d96ffc00e0afda4cd0a96c96f8d802b1662b" and
|
|
19
|
+
that contains the longest persistent chain of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin white paper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository or another repository designated by Bitcoin Association,
|
|
20
|
+
as well as the test blockchains that contain the longest persistent chains of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin whitepaper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository, or another repository designated by Bitcoin Association
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
28
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# @bsv/expo-wallet-toolbox
|
|
2
|
+
|
|
3
|
+
Wallet screens and P2P local-payment backend for Expo/React Native apps —
|
|
4
|
+
storage, local WiFi/Bluetooth payment transport, offline queueing, backup,
|
|
5
|
+
hardware-key vault, and the 11 wallet screens, extracted from BSV Wallet so
|
|
6
|
+
a second app (e.g. BSV Browser) can install the same wallet instead of
|
|
7
|
+
re-implementing or forking it.
|
|
8
|
+
|
|
9
|
+
Two subpath exports, one npm package:
|
|
10
|
+
|
|
11
|
+
- `@bsv/expo-wallet-toolbox` (root/`core`) — headless: context providers,
|
|
12
|
+
storage, services, localpay/peerpay/offline/backup/vault logic. No
|
|
13
|
+
screen components.
|
|
14
|
+
- `@bsv/expo-wallet-toolbox/ui` — the 11 screen components and their UI
|
|
15
|
+
dependencies (`components/wallet`, `components/pay`, `components/vault`,
|
|
16
|
+
`components/ui`, `components/security`, `QRScanner`). Imports `core`.
|
|
17
|
+
|
|
18
|
+
This package ships raw TypeScript (not precompiled JS) — Metro and your
|
|
19
|
+
app's own TypeScript config transpile it like any other workspace source.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @bsv/expo-wallet-toolbox react-native-localpay-transport react-native-engine-native react-native-secp-native react-native-nitro-modules
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`react-native-yubikey` is optional — the vault subsystem
|
|
28
|
+
(`services/vault/driver.ts`) detects its absence at runtime and disables
|
|
29
|
+
vault/hardware-key features gracefully; install it only if you want
|
|
30
|
+
YubiKey PIV custody support.
|
|
31
|
+
|
|
32
|
+
**The command above is not the whole story.** `core`/`ui` import roughly
|
|
33
|
+
four dozen packages beyond the four listed — Expo native modules
|
|
34
|
+
(camera, clipboard, secure-store, haptics, ...), state/i18n libraries
|
|
35
|
+
(mobx, i18next), and BSV SDK packages. The **[Peer dependencies](#peer-dependencies)**
|
|
36
|
+
table below is the full, audited list — `package.json`'s `peerDependencies`
|
|
37
|
+
now declares all 49 entries (46 directly imported + 3 required only for
|
|
38
|
+
native linking — see the Nitro row below), so a plain `npm install
|
|
39
|
+
@bsv/expo-wallet-toolbox` surfaces the rest as peer-dependency warnings
|
|
40
|
+
instead of silently missing them.
|
|
41
|
+
|
|
42
|
+
## Peer dependencies
|
|
43
|
+
|
|
44
|
+
Versions shown are what this repo currently builds against (root
|
|
45
|
+
`package.json`) — known-good, not hard requirements; align to your own
|
|
46
|
+
Expo SDK line.
|
|
47
|
+
|
|
48
|
+
### React / Expo core (required)
|
|
49
|
+
|
|
50
|
+
| Package | Version |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `react` | 19.2.0 |
|
|
53
|
+
| `react-native` | 0.83.6 |
|
|
54
|
+
| `expo-router` | ~55.0.16 |
|
|
55
|
+
|
|
56
|
+
### BSV SDK & protocol libraries (required)
|
|
57
|
+
|
|
58
|
+
| Package | Version |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `@bsv/sdk` | ^2.4.1 |
|
|
61
|
+
| `@bsv/wallet-toolbox-mobile` | ^2.4.3 |
|
|
62
|
+
| `@bsv/btms-permission-module` | ^1.1.0 |
|
|
63
|
+
| `@bsv/air-gap` | ^0.1.1 |
|
|
64
|
+
| `@bsv/backup-cache-client` | ^0.1.0 |
|
|
65
|
+
| `@bsv/message-box-client` | ^2.2.1 |
|
|
66
|
+
| `@bsv/templates` | ^1.10.0 |
|
|
67
|
+
| `@noble/curves` | ^2.3.0 |
|
|
68
|
+
| `qrcode` | ^1.5.4 |
|
|
69
|
+
|
|
70
|
+
### Expo native modules (required — each needs its own autolinking/config)
|
|
71
|
+
|
|
72
|
+
| Package | Version |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `expo-sqlite` | ~55.0.16 |
|
|
75
|
+
| `expo-secure-store` | ~55.0.14 |
|
|
76
|
+
| `expo-camera` | ~55.0.19 |
|
|
77
|
+
| `expo-audio` | ~55.0.16 |
|
|
78
|
+
| `expo-clipboard` | ~55.0.13 |
|
|
79
|
+
| `expo-crypto` | ~55.0.15 |
|
|
80
|
+
| `expo-device` | ~55.0.17 |
|
|
81
|
+
| `expo-document-picker` | ~55.0.13 |
|
|
82
|
+
| `expo-file-system` | ~55.0.20 |
|
|
83
|
+
| `expo-haptics` | ~55.0.14 |
|
|
84
|
+
| `expo-local-authentication` | ~55.0.14 |
|
|
85
|
+
| `expo-localization` | ~55.0.15 |
|
|
86
|
+
| `expo-print` | ~55.0.15 |
|
|
87
|
+
| `expo-sharing` | ~55.0.19 |
|
|
88
|
+
| `expo-status-bar` | ~55.0.6 |
|
|
89
|
+
| `expo-blur` | ~55.0.14 |
|
|
90
|
+
| `@expo/vector-icons` | ^15.0.3 |
|
|
91
|
+
|
|
92
|
+
### React Native native modules (required)
|
|
93
|
+
|
|
94
|
+
| Package | Version |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `@react-native-async-storage/async-storage` | 2.2.0 |
|
|
97
|
+
| `@react-native-clipboard/clipboard` | ^1.16.2 |
|
|
98
|
+
| `@react-native-community/netinfo` | 11.5.2 |
|
|
99
|
+
| `react-native-gesture-handler` | ~2.30.0 |
|
|
100
|
+
| `react-native-localize` | ^3.4.1 |
|
|
101
|
+
| `react-native-qrcode-svg` | ^6.3.15 |
|
|
102
|
+
| `react-native-reanimated` | 4.2.1 |
|
|
103
|
+
| `react-native-safe-area-context` | ~5.6.0 |
|
|
104
|
+
| `react-native-svg` | 15.15.3 |
|
|
105
|
+
| `react-native-sse` | ^1.2.1 |
|
|
106
|
+
|
|
107
|
+
### State & i18n (required)
|
|
108
|
+
|
|
109
|
+
| Package | Version |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `mobx` | ^6.13.7 |
|
|
112
|
+
| `mobx-react-lite` | ^4.1.0 |
|
|
113
|
+
| `i18next` | ^25.2.1 |
|
|
114
|
+
| `react-i18next` | ^15.5.3 |
|
|
115
|
+
| `date-fns` | ^4.1.0 |
|
|
116
|
+
|
|
117
|
+
### Nitro native modules — this repo's own packages (required)
|
|
118
|
+
|
|
119
|
+
| Package | Notes |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `react-native-nitro-modules` | ^0.35.2. Nitro codegen runtime the three below build on. |
|
|
122
|
+
| `react-native-localpay-transport` | Local WiFi/Bluetooth P2P payment transport. |
|
|
123
|
+
| `react-native-engine-native` | Native wallet-toolbox engine bindings. |
|
|
124
|
+
| `react-native-secp-native` | Native secp256k1 signing. |
|
|
125
|
+
|
|
126
|
+
These three ship as sibling `packages/` in this repo and are not yet
|
|
127
|
+
published to npm independently — when they are, pin to their published
|
|
128
|
+
version; each declares `react-native` and `react-native-nitro-modules`
|
|
129
|
+
as its own peer dependencies.
|
|
130
|
+
|
|
131
|
+
### Optional
|
|
132
|
+
|
|
133
|
+
| Package | Notes |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| `react-native-yubikey` | Vault/hardware-key support. Absence is detected at runtime and vault features degrade gracefully. |
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import {
|
|
141
|
+
WalletContextProvider,
|
|
142
|
+
ThemeProvider,
|
|
143
|
+
LocalStorageProvider,
|
|
144
|
+
LanguageProvider,
|
|
145
|
+
UserContextProvider,
|
|
146
|
+
ExchangeRateContextProvider,
|
|
147
|
+
WalletConnectionProvider,
|
|
148
|
+
VaultProvider
|
|
149
|
+
} from '@bsv/expo-wallet-toolbox'
|
|
150
|
+
import {
|
|
151
|
+
PermissionSheet,
|
|
152
|
+
VaultCeremonySheet,
|
|
153
|
+
AlertHost,
|
|
154
|
+
ToastHost,
|
|
155
|
+
showToast,
|
|
156
|
+
ErrorBoundary
|
|
157
|
+
} from '@bsv/expo-wallet-toolbox/ui'
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Provider setup
|
|
161
|
+
|
|
162
|
+
Compose the providers in this order (outer→inner) around your
|
|
163
|
+
`expo-router` `<Stack>` — this is the exact nesting `bsv-wallet` itself
|
|
164
|
+
uses in `app/_layout.tsx`:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<LanguageProvider>
|
|
168
|
+
<LocalStorageProvider>
|
|
169
|
+
<UserContextProvider nativeHandlers={nativeHandlers} appVersion={appVersion} appName="Your App">
|
|
170
|
+
<ExchangeRateContextProvider>
|
|
171
|
+
<WalletContextProvider onToast={showToast}>
|
|
172
|
+
<ThemeProvider>
|
|
173
|
+
<WalletConnectionProvider walletName="Your App">
|
|
174
|
+
<VaultProvider onToast={showToast}>
|
|
175
|
+
{/* mount once, anywhere inside VaultProvider: */}
|
|
176
|
+
<PermissionSheet />
|
|
177
|
+
<VaultCeremonySheet />
|
|
178
|
+
<AlertHost />
|
|
179
|
+
|
|
180
|
+
<Stack />
|
|
181
|
+
|
|
182
|
+
<ToastHost />
|
|
183
|
+
</VaultProvider>
|
|
184
|
+
</WalletConnectionProvider>
|
|
185
|
+
</ThemeProvider>
|
|
186
|
+
</WalletContextProvider>
|
|
187
|
+
</ExchangeRateContextProvider>
|
|
188
|
+
</UserContextProvider>
|
|
189
|
+
</LocalStorageProvider>
|
|
190
|
+
</LanguageProvider>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Notes on the non-obvious props (all technically optional with defaults,
|
|
194
|
+
but you almost always want to set them):
|
|
195
|
+
|
|
196
|
+
- `UserContextProvider` — `appVersion`/`appName` default to `'unknown'`/`'App'`;
|
|
197
|
+
pass your own `package.json` version and app name. `nativeHandlers` is an
|
|
198
|
+
optional `NativeHandlers` object (`isFocused`, `onFocusRequested`,
|
|
199
|
+
`onFocusRelinquished`, `onDownloadFile`) — omit it to use no-op defaults.
|
|
200
|
+
- `WalletContextProvider` and `VaultProvider` — `onToast` is an optional
|
|
201
|
+
callback of shape `(message: string, opts?: { type?: 'success' | 'error' | 'info' | ... }) => void`.
|
|
202
|
+
Wire it to `showToast` from `@bsv/expo-wallet-toolbox/ui` (or your own
|
|
203
|
+
toast) so background events (offline-payment internalization, vault
|
|
204
|
+
ceremony results) surface to the user. Neither context imports a UI
|
|
205
|
+
component directly — that's a deliberate `core`/`ui` boundary.
|
|
206
|
+
- `WalletConnectionProvider` — `walletName` defaults to `'App'`; set it to
|
|
207
|
+
your app's display name (shown to QR-paired desktop sessions).
|
|
208
|
+
|
|
209
|
+
## Screens
|
|
210
|
+
|
|
211
|
+
`@bsv/expo-wallet-toolbox/ui` exports 11 screen components. Create thin
|
|
212
|
+
`app/*.tsx` files in your `expo-router` app that just re-export them —
|
|
213
|
+
this is the pattern `bsv-wallet`'s own route files use:
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
// app/index.tsx
|
|
217
|
+
export { WalletHomeScreen as default } from '@bsv/expo-wallet-toolbox/ui'
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
| Screen | Source route in this repo |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `WalletHomeScreen` | `app/index.tsx` |
|
|
223
|
+
| `PayScreen` | `app/pay.tsx` |
|
|
224
|
+
| `SettingsScreen` | `app/settings.tsx` |
|
|
225
|
+
| `WalletConfigScreen` | `app/wallet-config.tsx` |
|
|
226
|
+
| `VaultScreen` | `app/vault.tsx` |
|
|
227
|
+
| `VaultRecoverScreen` | `app/vault-recover.tsx` |
|
|
228
|
+
| `VaultTransferScreen` | `app/vault-transfer.tsx` |
|
|
229
|
+
| `ConnectionsScreen` | `app/connections.tsx` |
|
|
230
|
+
| `PairScreen` | `app/pair.tsx` |
|
|
231
|
+
| `TrustScreen` | `app/trust.tsx` |
|
|
232
|
+
| `LogsScreen` | `app/logs.tsx` |
|
|
233
|
+
|
|
234
|
+
> **Note:** `ConnectionsScreen`'s OS-level deep-link pairing (a desktop
|
|
235
|
+
> session opening the app directly) currently assumes the `bsv-wallet://`
|
|
236
|
+
> URL scheme is hardcoded into its parsing and link-building. A consuming
|
|
237
|
+
> app that registers a different scheme would need that deep-link path
|
|
238
|
+
> updated to match. In-app QR-code scanning of a pairing code is unaffected
|
|
239
|
+
> and works regardless of the consumer's own scheme.
|
|
240
|
+
|
|
241
|
+
Each route file is the one-line `export { XScreen as default } from '@bsv/expo-wallet-toolbox/ui'`
|
|
242
|
+
pattern shown above — no other wiring needed per screen; navigation
|
|
243
|
+
between them uses `expo-router`'s file-based routes, so your route file
|
|
244
|
+
names determine the paths (`/pay`, `/settings`, etc.), not the exported
|
|
245
|
+
screen names.
|
|
246
|
+
|
|
247
|
+
## Required app.json configuration
|
|
248
|
+
|
|
249
|
+
Expo config (Info.plist keys, Android permissions, config plugins,
|
|
250
|
+
`expo-build-properties`) can't be installed by an npm package — it stays
|
|
251
|
+
declared in your own app's `app.json`. This is the exact config
|
|
252
|
+
`bsv-wallet`'s `app.json` and `plugins/` currently carry:
|
|
253
|
+
|
|
254
|
+
### iOS `infoPlist`
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"NSCameraUsageDescription": "This app needs camera access to scan QR codes.",
|
|
259
|
+
"NSPhotoLibraryAddUsageDescription": "This app needs permission to save images to your photo library.",
|
|
260
|
+
"NSMicrophoneUsageDescription": "This app needs microphone access for video recording features.",
|
|
261
|
+
"NSFaceIDUsageDescription": "This app uses Face ID/Touch ID to securely authenticate you and protect your wallet.",
|
|
262
|
+
"NSLocationWhenInUseUsageDescription": "...enable features like discovering nearby devices/services...",
|
|
263
|
+
"NSBonjourServices": ["_bsvpay._tcp"],
|
|
264
|
+
"NSLocalNetworkUsageDescription": "...local network to send and receive payments directly between nearby devices.",
|
|
265
|
+
"NFCReaderUsageDescription": "...NFC to unlock your vault with your YubiKey...",
|
|
266
|
+
"com.apple.developer.nfc.readersession.iso7816.select-identifiers": [
|
|
267
|
+
"A000000308",
|
|
268
|
+
"A000000308000010000100",
|
|
269
|
+
"A0000006472F0001",
|
|
270
|
+
"A0000005272101",
|
|
271
|
+
"A000000527471117",
|
|
272
|
+
"A0000005272001"
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
`NFCReaderUsageDescription` and the AID list are only needed if you ship
|
|
278
|
+
vault/hardware-key support (i.e. installed `react-native-yubikey`); omit
|
|
279
|
+
both if you didn't.
|
|
280
|
+
|
|
281
|
+
Also add `CFBundleURLTypes` for **your own** deep-link scheme(s) — do not
|
|
282
|
+
reuse `bsv-wallet://` or `peerpay://`, those are this repo's own app
|
|
283
|
+
identity, not the package's:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
"CFBundleURLTypes": [
|
|
287
|
+
{ "CFBundleURLName": "com.yourcompany.yourapp", "CFBundleURLSchemes": ["yourapp"] }
|
|
288
|
+
]
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### iOS entitlement
|
|
292
|
+
|
|
293
|
+
`com.apple.developer.nfc.readersession.formats: ["TAG"]` — needed only
|
|
294
|
+
alongside the NFC/vault config above. Add it via a config plugin
|
|
295
|
+
equivalent to this repo's `plugins/withNfcReaderEntitlement.js`, which
|
|
296
|
+
wraps `@expo/config-plugins`' `withEntitlementsPlist`:
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
const { withEntitlementsPlist } = require('@expo/config-plugins')
|
|
300
|
+
|
|
301
|
+
module.exports = (config) =>
|
|
302
|
+
withEntitlementsPlist(config, (mod) => {
|
|
303
|
+
mod.modResults['com.apple.developer.nfc.readersession.formats'] = ['TAG']
|
|
304
|
+
return mod
|
|
305
|
+
})
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
This is a real, provisionable iOS capability ("NFC Tag Reading") — your
|
|
309
|
+
App ID needs it enabled and the provisioning profile regenerated, or
|
|
310
|
+
codesign/App Store submission will reject it.
|
|
311
|
+
|
|
312
|
+
### Android `permissions`
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
[
|
|
316
|
+
"android.permission.INTERNET",
|
|
317
|
+
"android.permission.SYSTEM_ALERT_WINDOW",
|
|
318
|
+
"android.permission.ACCESS_COARSE_LOCATION",
|
|
319
|
+
"android.permission.ACCESS_FINE_LOCATION",
|
|
320
|
+
"android.permission.CAMERA",
|
|
321
|
+
"android.permission.RECORD_AUDIO",
|
|
322
|
+
"android.permission.MODIFY_AUDIO_SETTINGS",
|
|
323
|
+
"android.permission.BLUETOOTH_ADVERTISE",
|
|
324
|
+
"android.permission.BLUETOOTH_CONNECT",
|
|
325
|
+
"android.permission.BLUETOOTH_SCAN",
|
|
326
|
+
"android.permission.NEARBY_WIFI_DEVICES",
|
|
327
|
+
"android.permission.ACCESS_WIFI_STATE",
|
|
328
|
+
"android.permission.CHANGE_WIFI_STATE"
|
|
329
|
+
]
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Android intent filter
|
|
333
|
+
|
|
334
|
+
Register **your own** deep-link scheme (VIEW/BROWSABLE/DEFAULT) — the
|
|
335
|
+
local-payment QR/nearby flows deep-link back into your app, not this
|
|
336
|
+
repo's:
|
|
337
|
+
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"action": "VIEW",
|
|
341
|
+
"data": [{ "scheme": "yourapp" }],
|
|
342
|
+
"category": ["BROWSABLE", "DEFAULT"]
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### `expo-build-properties`
|
|
347
|
+
|
|
348
|
+
```json
|
|
349
|
+
{
|
|
350
|
+
"ios": {
|
|
351
|
+
"useFrameworks": "static",
|
|
352
|
+
"useModularHeaders": true
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Required for the Nitro/xcframework native modules
|
|
358
|
+
(`react-native-localpay-transport`, `react-native-engine-native`,
|
|
359
|
+
`react-native-secp-native`, `react-native-yubikey`) to build on iOS.
|
|
360
|
+
|
|
361
|
+
### `metro.config.js`
|
|
362
|
+
|
|
363
|
+
The package's crypto code expects `node:crypto` to resolve to
|
|
364
|
+
`react-native-quick-crypto`, and `node:buffer`/`node:process` to resolve
|
|
365
|
+
to an empty stub (not the real Node polyfills) — mirror this repo's
|
|
366
|
+
`metro.config.js`:
|
|
367
|
+
|
|
368
|
+
```js
|
|
369
|
+
const { getDefaultConfig } = require('expo/metro-config')
|
|
370
|
+
const path = require('path')
|
|
371
|
+
|
|
372
|
+
const config = getDefaultConfig(__dirname)
|
|
373
|
+
|
|
374
|
+
config.resolver.extraNodeModules = {
|
|
375
|
+
crypto: require.resolve('react-native-quick-crypto'),
|
|
376
|
+
stream: require.resolve('stream-browserify'),
|
|
377
|
+
buffer: require.resolve('buffer'),
|
|
378
|
+
...config.resolver.extraNodeModules
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const emptyShim = path.resolve(__dirname, 'metro-shims/empty.js') // module.exports = {}
|
|
382
|
+
const quickCryptoMain = require.resolve('react-native-quick-crypto')
|
|
383
|
+
|
|
384
|
+
const upstream = config.resolver.resolveRequest
|
|
385
|
+
config.resolver.resolveRequest = (context, moduleName, platform) => {
|
|
386
|
+
if (moduleName === 'node:crypto') {
|
|
387
|
+
return { type: 'sourceFile', filePath: quickCryptoMain }
|
|
388
|
+
}
|
|
389
|
+
if (moduleName === 'node:buffer' || moduleName === 'node:process') {
|
|
390
|
+
return { type: 'sourceFile', filePath: emptyShim }
|
|
391
|
+
}
|
|
392
|
+
if (typeof upstream === 'function') return upstream(context, moduleName, platform)
|
|
393
|
+
return context.resolveRequest(context, moduleName, platform)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
module.exports = config
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
`react-native-quick-crypto`, `stream-browserify`, and `buffer` must be
|
|
400
|
+
installed in your app for the `extraNodeModules` lines above to resolve;
|
|
401
|
+
add them alongside the peer dependencies list.
|
|
402
|
+
|
|
403
|
+
## Jest configuration
|
|
404
|
+
|
|
405
|
+
If your app runs Jest against code that imports this package, two things
|
|
406
|
+
are required — both hard-won during this package's extraction:
|
|
407
|
+
|
|
408
|
+
1. **`transformIgnorePatterns`** must include `@bsv/expo-wallet-toolbox`,
|
|
409
|
+
because this package ships raw TypeScript, not precompiled JS — Jest's
|
|
410
|
+
default `node_modules` exclusion will otherwise fail to transform it.
|
|
411
|
+
This repo's own (proven-working) pattern, verbatim from `package.json`:
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
transformIgnorePatterns: [
|
|
415
|
+
"node_modules/(?!((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|react-native-reanimated|react-native-gesture-handler|react-native-worklets|expo-modules-core|@noble/secp256k1|@noble/curves|@noble/hashes|@bsv/backup-cache-client|@bsv/auth|@bsv/expo-wallet-toolbox)/)",
|
|
416
|
+
"/node_modules/react-native-reanimated/plugin/"
|
|
417
|
+
]
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
The second array entry excludes `react-native-reanimated`'s own babel
|
|
421
|
+
plugin directory from transformation — unrelated to this package
|
|
422
|
+
specifically, but part of the same reference config and needed
|
|
423
|
+
because `react-native-reanimated` is a required peer dependency.
|
|
424
|
+
You don't need every name in that big alternation — most come from
|
|
425
|
+
the `jest-expo` preset's own defaults or other-app concerns — but
|
|
426
|
+
`@bsv/expo-wallet-toolbox` itself and `@bsv/backup-cache-client` (see
|
|
427
|
+
below) must be in whatever pattern you end up with.
|
|
428
|
+
|
|
429
|
+
2. **Native-module and ESM-only-package mocks** — anything the package
|
|
430
|
+
touches that has no pure-JS Jest-safe implementation, or that ships
|
|
431
|
+
as ESM-only with no `require` export condition, needs a
|
|
432
|
+
`moduleNameMapper` entry. This repo's full set, verbatim:
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
moduleNameMapper: {
|
|
436
|
+
'^@bsv/backup-cache-client$':
|
|
437
|
+
'<rootDir>/node_modules/@bsv/backup-cache-client/dist/index.js',
|
|
438
|
+
'^react-native-reanimated$': '<rootDir>/__tests__/__mocks__/reanimated.js',
|
|
439
|
+
'^react-native-worklets$':
|
|
440
|
+
'<rootDir>/node_modules/react-native-worklets/lib/module/mock.js',
|
|
441
|
+
'^expo-audio$': '<rootDir>/__tests__/__mocks__/expo-audio.js',
|
|
442
|
+
'^expo-sqlite$': '<rootDir>/__tests__/__mocks__/expo-sqlite.js',
|
|
443
|
+
'^@react-native-async-storage/async-storage$':
|
|
444
|
+
'<rootDir>/node_modules/@react-native-async-storage/async-storage/jest/async-storage-mock.js'
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
`@bsv/backup-cache-client` is the one entry every consumer needs even
|
|
449
|
+
before writing a single test that touches wallet behavior:
|
|
450
|
+
`core/backup/client.ts` statically imports it, and it's re-exported
|
|
451
|
+
through the core barrel (`core/index.ts`), so any test that imports
|
|
452
|
+
*anything* from `@bsv/expo-wallet-toolbox` pulls it in. The package
|
|
453
|
+
is `"type": "module"` (ESM-only, no CJS `require` export condition),
|
|
454
|
+
which Jest's default CJS-based resolver can't load — hence the
|
|
455
|
+
explicit redirect straight to its `dist/index.js` build. This bites
|
|
456
|
+
on the very first `jest` run in a consumer app, unlike the other
|
|
457
|
+
entries below, which only bite once a test actually exercises that
|
|
458
|
+
native API.
|
|
459
|
+
|
|
460
|
+
`expo-sqlite`/`expo-audio` need hand-written mocks (see this repo's
|
|
461
|
+
`__tests__/__mocks__/` for working examples) since they wrap native
|
|
462
|
+
modules with no official Jest mock; `async-storage` and
|
|
463
|
+
`react-native-worklets` ship their own mock you can point to directly;
|
|
464
|
+
`react-native-reanimated`'s official `jest.setup.js` mock doesn't cover
|
|
465
|
+
every API this package uses, hence the local override.
|
|
466
|
+
|
|
467
|
+
This repo uses the `jest-expo` preset as its base
|
|
468
|
+
(`"preset": "jest-expo"` in `package.json`), which already covers most
|
|
469
|
+
other Expo native modules — start from that preset before adding the
|
|
470
|
+
overrides above.
|
|
471
|
+
|
|
472
|
+
## Publishing notes
|
|
473
|
+
|
|
474
|
+
This package deliberately ships **no `exports` map** in `package.json`.
|
|
475
|
+
Resolution relies on plain `main`/`types` (root → `core/index.ts`) plus
|
|
476
|
+
Node/Metro's default directory-index resolution for the `/ui` subpath
|
|
477
|
+
(`@bsv/expo-wallet-toolbox/ui` → `ui/index.ts`).
|
|
478
|
+
|
|
479
|
+
This is a conscious choice, not an oversight: roughly 50 files under `ui/`
|
|
480
|
+
import shared primitives (`useTheme`, `useWallet`, `spacing`, `haptics`,
|
|
481
|
+
etc.) from the bare `@bsv/expo-wallet-toolbox` specifier — i.e. the
|
|
482
|
+
package imports itself by name, relying on the workspace's self-referencing
|
|
483
|
+
`node_modules/@bsv/expo-wallet-toolbox` symlink (or, once published, plain
|
|
484
|
+
`node_modules` directory-walk resolution — the installed copy sits inside a
|
|
485
|
+
consumer's `node_modules` and is found there like any other dependency, not
|
|
486
|
+
through Node's dedicated package-self-reference feature). That feature only
|
|
487
|
+
kicks in when an `exports` map is present *and* includes a `"."` entry — adding an
|
|
488
|
+
`exports` map without one would silently break every one of those ~50
|
|
489
|
+
imports at publish time, and adding one with only `"."` (no `"./ui"` entry)
|
|
490
|
+
would break every consumer's `/ui` subpath import instead.
|
|
491
|
+
|
|
492
|
+
If a future change adds an `exports` map, it must include at minimum:
|
|
493
|
+
|
|
494
|
+
```json
|
|
495
|
+
"exports": {
|
|
496
|
+
".": "./core/index.ts",
|
|
497
|
+
"./ui": "./ui/index.ts"
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
and must be re-verified against the full Jest suite, the
|
|
502
|
+
`packageResolution.test.ts` canary (`CANARY_UI`/`CANARY_CORE` barrel-import
|
|
503
|
+
check), and a real `npx expo export` Metro bundle — the self-reference
|
|
504
|
+
resolution path is exactly what both currently exercise successfully
|
|
505
|
+
without an `exports` map, and Metro's own `exports` support has its own
|
|
506
|
+
quirks worth re-testing explicitly rather than assuming Node's behavior
|
|
507
|
+
carries over.
|
|
508
|
+
|
|
509
|
+
`files` is `["core", "ui", "assets"]`; npm always includes `package.json`
|
|
510
|
+
and `README.md` regardless of `files`. `__tests__/` and `tsconfig.json`
|
|
511
|
+
live at the package root, outside every `files` entry, so they are
|
|
512
|
+
excluded from the published tarball — confirmed with `npm pack --dry-run`.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|