@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type HomeBadgeKind = 'attention' | 'unsent' | 'offline'
|
|
2
|
+
|
|
3
|
+
export type HomeBadge = { kind: HomeBadgeKind; count: number }
|
|
4
|
+
|
|
5
|
+
/** Counts of stuck work to insert as inline home-screen rows. Zero counts are omitted. */
|
|
6
|
+
export function homeBadges(input: {
|
|
7
|
+
attention: number
|
|
8
|
+
unsent: number
|
|
9
|
+
offlineQueued: number
|
|
10
|
+
offlineRejected: number
|
|
11
|
+
}): HomeBadge[] {
|
|
12
|
+
const badges: HomeBadge[] = []
|
|
13
|
+
if (input.attention > 0) badges.push({ kind: 'attention', count: input.attention })
|
|
14
|
+
if (input.unsent > 0) badges.push({ kind: 'unsent', count: input.unsent })
|
|
15
|
+
const offline = input.offlineQueued + input.offlineRejected
|
|
16
|
+
if (offline > 0) badges.push({ kind: 'offline', count: offline })
|
|
17
|
+
return badges
|
|
18
|
+
}
|
package/ui/txStatus.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction status, collapsed into four tones for at-a-glance reading.
|
|
3
|
+
*
|
|
4
|
+
* The old list gave EVERY row a tinted pill, so a healthy wallet was a wall of
|
|
5
|
+
* green and the one row that actually needed the user could not win attention.
|
|
6
|
+
* Here the settled tone carries NO chroma at all: quiet text, no pill. Colour
|
|
7
|
+
* is spent only where the user might have to act.
|
|
8
|
+
*
|
|
9
|
+
* Labels and translation keys are unchanged — this only changes how a status is
|
|
10
|
+
* rendered, never what it is called.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type StatusTone = 'settled' | 'inflight' | 'attention' | 'failed'
|
|
14
|
+
|
|
15
|
+
export interface TxStatusView {
|
|
16
|
+
/** i18n key for the human label. */
|
|
17
|
+
key: string
|
|
18
|
+
tone: StatusTone
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Map a raw action status (and any live offline-queue state) to a tone.
|
|
23
|
+
*
|
|
24
|
+
* The offline queue row outranks the raw status: a held transaction sits at
|
|
25
|
+
* 'unproven' (which would read as a settled "Accepted") or at 'nosend' when
|
|
26
|
+
* payer-side promotion failed, so without this the user would see a confirmed
|
|
27
|
+
* payment that has not actually gone anywhere.
|
|
28
|
+
*/
|
|
29
|
+
export function txStatusView(status: string, offlineStatus?: string): TxStatusView {
|
|
30
|
+
switch (offlineStatus) {
|
|
31
|
+
case 'queued':
|
|
32
|
+
return { key: 'tx_status_offline_queued', tone: 'inflight' }
|
|
33
|
+
case 'posting':
|
|
34
|
+
return { key: 'tx_status_offline_sending', tone: 'inflight' }
|
|
35
|
+
case 'rejected':
|
|
36
|
+
return { key: 'tx_status_offline_rejected', tone: 'failed' }
|
|
37
|
+
// Built and shown as a code, never released. The underlying status is
|
|
38
|
+
// 'nosend' ("Not sent"), which is true but says nothing about why; this
|
|
39
|
+
// says the payment is waiting on a hand-over that may not have happened.
|
|
40
|
+
case 'parked':
|
|
41
|
+
return { key: 'tx_status_parked', tone: 'attention' }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
switch (status) {
|
|
45
|
+
case 'completed':
|
|
46
|
+
return { key: 'tx_status_confirmed', tone: 'settled' }
|
|
47
|
+
case 'unproven':
|
|
48
|
+
return { key: 'tx_status_accepted', tone: 'settled' }
|
|
49
|
+
case 'sending':
|
|
50
|
+
return { key: 'tx_status_broadcasting', tone: 'inflight' }
|
|
51
|
+
case 'nosend':
|
|
52
|
+
return { key: 'tx_status_not_sent', tone: 'attention' }
|
|
53
|
+
case 'unsigned':
|
|
54
|
+
return { key: 'tx_status_unsigned', tone: 'attention' }
|
|
55
|
+
case 'nonfinal':
|
|
56
|
+
return { key: 'tx_status_nonfinal', tone: 'attention' }
|
|
57
|
+
case 'failed':
|
|
58
|
+
return { key: 'tx_status_failed', tone: 'failed' }
|
|
59
|
+
default:
|
|
60
|
+
return { key: status, tone: 'settled' }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Colour for a tone. `settled` deliberately returns the quiet text colour. */
|
|
65
|
+
export function toneColor(tone: StatusTone, colors: Record<string, string>): string {
|
|
66
|
+
switch (tone) {
|
|
67
|
+
case 'settled':
|
|
68
|
+
return colors.textSecondary
|
|
69
|
+
case 'inflight':
|
|
70
|
+
return colors.info
|
|
71
|
+
case 'attention':
|
|
72
|
+
return colors.warning
|
|
73
|
+
case 'failed':
|
|
74
|
+
return colors.error
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Settled rows get no pill — only states the user might act on are boxed. */
|
|
79
|
+
export const tonePill = (tone: StatusTone): boolean => tone !== 'settled'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import isImageUrl from './isImageUrl'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates that a trust object of a domain follows the BRC-68 protocol
|
|
5
|
+
* @param {object} trust - BRC-68 trust object
|
|
6
|
+
* @param {object} obj
|
|
7
|
+
* @param {boolean} [obj.skipNote = false]
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
interface TrustObject {
|
|
11
|
+
name: string
|
|
12
|
+
note?: string
|
|
13
|
+
icon: string
|
|
14
|
+
publicKey: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const validateTrust = async (trust: TrustObject, { skipNote = false } = {}) => {
|
|
18
|
+
if (trust.name.length < 5 || trust.name.length > 30) {
|
|
19
|
+
const e = new Error('Trust validation failed, name must be 5-30 characters')
|
|
20
|
+
;(e as any).field = 'name'
|
|
21
|
+
throw e
|
|
22
|
+
}
|
|
23
|
+
if (!skipNote) {
|
|
24
|
+
if (!trust.note || trust.note.length < 5 || trust.note.length > 50) {
|
|
25
|
+
const e = new Error('Trust validation failed, note must be 5-50 characters')
|
|
26
|
+
;(e as any).field = 'note'
|
|
27
|
+
throw e
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const iconValid = await isImageUrl(trust.icon)
|
|
31
|
+
if (!iconValid) {
|
|
32
|
+
const e = new Error('Trust validation failed, icon image URL is invalid')
|
|
33
|
+
;(e as any).field = 'icon'
|
|
34
|
+
throw e
|
|
35
|
+
}
|
|
36
|
+
if (/^(02|03)[a-f0-9]{64}$/.test(trust.publicKey) !== true) {
|
|
37
|
+
const e = new Error('Trust validation failed, public key is invalid')
|
|
38
|
+
;(e as any).field = 'publicKey'
|
|
39
|
+
throw e
|
|
40
|
+
}
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default validateTrust
|