@bsv/expo-wallet-toolbox 0.15.2 → 0.17.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 (52) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/core/backup/appData.ts +5 -1
  3. package/core/backup/codec.ts +9 -3
  4. package/core/backup/contactsBackup.ts +145 -0
  5. package/core/backup/push.ts +14 -0
  6. package/core/backup/restore.ts +26 -4
  7. package/core/backup/restoreOnImport.ts +28 -4
  8. package/core/contacts/contactsStore.ts +47 -3
  9. package/core/context/LocalStorageProvider.tsx +3 -1
  10. package/core/context/WalletContext.tsx +256 -76
  11. package/core/context/startupPrewarm.ts +54 -0
  12. package/core/directpay/dialFailure.ts +56 -0
  13. package/core/directpay/index.ts +7 -0
  14. package/core/directpay/payFlow.ts +117 -0
  15. package/core/directpay/paymentKey.ts +16 -0
  16. package/core/directpay/settings.ts +253 -0
  17. package/core/directpay/status.ts +52 -0
  18. package/core/directpay/types.ts +128 -0
  19. package/core/hooks/useConfirmationSound.ts +7 -0
  20. package/core/i18n/translations.tsx +354 -12
  21. package/core/identity/handleRegistry/client.ts +2 -1
  22. package/core/identity/handleRegistry/profileKeys.ts +16 -0
  23. package/core/identity/handleRegistry/resolver.ts +2 -1
  24. package/core/identity/handleRegistry/rules.ts +7 -3
  25. package/core/index.ts +14 -2
  26. package/core/localpay/build.ts +4 -3
  27. package/core/localpay/session.ts +6 -0
  28. package/core/localpay/transport/select.ts +64 -3
  29. package/core/localpay/verify.ts +2 -1
  30. package/core/net/trimTrailingSlashes.ts +13 -0
  31. package/core/parsePeerPayURI.ts +25 -2
  32. package/core/pay/creditInbox.ts +31 -1
  33. package/core/pay/rails/address.ts +3 -2
  34. package/core/pay/rails/handle.ts +8 -2
  35. package/core/pay/rails/index.ts +6 -4
  36. package/core/pos/protocol.ts +172 -0
  37. package/core/profiles/discovery.ts +17 -8
  38. package/core/profiles/profileStore.ts +34 -7
  39. package/core/profiles/removalProblems.ts +41 -0
  40. package/core/push/registration.ts +2 -1
  41. package/core/services/callbackToken.ts +7 -0
  42. package/core/services/revokeConnection.ts +98 -0
  43. package/core/storage/schema/createTables.ts +24 -0
  44. package/core/toolboxConfig.ts +85 -5
  45. package/package.json +1 -1
  46. package/ui/components/pay/MessageBoxConfig.tsx +2 -1
  47. package/ui/components/pay/NearbyFlow.tsx +410 -7
  48. package/ui/exportTransactions.ts +26 -13
  49. package/ui/index.ts +2 -2
  50. package/ui/screens/ConnectionsScreen.tsx +8 -63
  51. package/ui/screens/ProfileScreen.tsx +2 -40
  52. package/ui/screens/WalletConfigScreen.tsx +57 -51
@@ -44,7 +44,7 @@ import { makeIdentityClient, resolveIdentity } from '../resolveIdentity'
44
44
  import { getHandleRegistryConfig } from '../../core/toolboxConfig'
45
45
  import { bindOriginator } from '../../core/mandala/createRuntime'
46
46
  import { profileLabel } from '../../core/profiles/profileLabel'
47
- import type { RemovalBlocker } from '../../core/profiles/assertProfileEmpty'
47
+ import { removalProblemKeys, type RemovalProblem } from '../../core/profiles/removalProblems'
48
48
  import type { ProfileRemovalCheck, RemoveProfileResult } from '../../core/profiles/removeProfile'
49
49
  import {
50
50
  MAX_PROFILE_NAME_LENGTH,
@@ -53,6 +53,7 @@ import {
53
53
  } from '../../core/profiles/profileStore'
54
54
  import { isValidHandleFormat, parsePaymail } from '../../core/identity/handleRegistry/rules'
55
55
  import type { ProfileSigner } from '../../core/identity/handleRegistry/profileCert'
56
+ import { DISPLAY_NAME_KV_KEY, HANDLE_KV_KEY } from '../../core/identity/handleRegistry/profileKeys'
56
57
  import { createHandleRegistryClient, type AvailabilityReason } from '../../core/identity/handleRegistry/client'
57
58
  import {
58
59
  changeHandle,
@@ -86,29 +87,9 @@ function loadExpoRouter(): ExpoRouterModule {
86
87
  return expoRouterMod
87
88
  }
88
89
 
89
- /** The full `handle@domain`, cached for a cold start. The registry decides. */
90
- const HANDLE_KV_KEY = 'profile_registered_handle'
91
- /**
92
- * The display name lives here on this device, and — once a handle is
93
- * registered — as a PUBLIC plaintext field of the profile certificate
94
- * (2026-09-18 ruling). The identity overlay's `name` is only a fallback for a
95
- * wallet that has never set one.
96
- */
97
- const DISPLAY_NAME_KV_KEY = 'profile_display_name'
98
90
  const HANDLE_CHECK_DEBOUNCE_MS = 400
99
91
 
100
- /** What can stand in the way of removing a profile, grouped the way the user is told about it. */
101
- const FUNDS_BLOCKERS: RemovalBlocker[] = ['spendable-outputs', 'token-balance']
102
- const PENDING_BLOCKERS: RemovalBlocker[] = [
103
- 'pending-transactions',
104
- 'offline-queue',
105
- 'token-settlements',
106
- 'localpay-pending',
107
- 'peerpay-outbox',
108
- 'inbox-pending'
109
- ]
110
92
 
111
- type RemovalProblem = Exclude<ProfileRemovalCheck, { kind: 'ok' }> | Exclude<RemoveProfileResult, { kind: 'removed' }>
112
93
 
113
94
  /**
114
95
  * How long the switch cover takes to leave. A removal runs under it (a Modal on
@@ -121,25 +102,6 @@ type RemovalProblem = Exclude<ProfileRemovalCheck, { kind: 'ok' }> | Exclude<Rem
121
102
  export const PROFILE_COVER_FADE_MS = 500
122
103
  const untilCoverGone = () => new Promise<void>(resolve => setTimeout(resolve, PROFILE_COVER_FADE_MS))
123
104
 
124
- /** The i18n keys that explain a refusal or failure, one paragraph per kind of reason. */
125
- function removalProblemKeys(problem: RemovalProblem): string[] {
126
- if (problem.kind === 'refused')
127
- return [problem.reason === 'offline' ? 'profile_remove_offline' : 'profile_remove_failed']
128
- if (problem.kind === 'handle-failed') return ['profile_remove_failed_handle']
129
- if (problem.kind === 'blocked') {
130
- const keys: string[] = []
131
- const has = (group: RemovalBlocker[]) => problem.reasons.some(r => group.includes(r))
132
- if (has(FUNDS_BLOCKERS)) keys.push('profile_remove_blocked_funds')
133
- if (has(PENDING_BLOCKERS)) keys.push('profile_remove_blocked_pending')
134
- // Funds or pending activity in the databases of its other networks, which the open one never shows.
135
- if (problem.reasons.includes('other-network')) keys.push('profile_remove_blocked_network')
136
- // An unfinished handle write is the same thing to the user as a handle that would not release.
137
- if (problem.reasons.includes('handle-journal')) keys.push('profile_remove_failed_handle')
138
- if (problem.reasons.includes('check-failed')) keys.push('profile_remove_blocked_check')
139
- if (keys.length > 0) return keys
140
- }
141
- return ['profile_remove_failed']
142
- }
143
105
 
144
106
  export function ProfileScreen() {
145
107
  const { t } = useTranslation()
@@ -132,7 +132,11 @@ const NEXT_MOCK_KEY: Record<MockPresentKey, MockPresentKey> = {
132
132
  'MOCK-DEV-3': 'MOCK-DEV-1'
133
133
  }
134
134
 
135
- export function WalletConfigScreen() {
135
+ /**
136
+ * `hideLogout`: for an app that forgets wallets its own way (and shows this
137
+ * screen only as developer tools), the Log Out row is left out.
138
+ */
139
+ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolean } = {}) {
136
140
  const versionLabel = useMemo(() => appVersionLabel(), [])
137
141
  const { t } = useTranslation()
138
142
  const { colors } = useTheme()
@@ -1004,57 +1008,59 @@ export function WalletConfigScreen() {
1004
1008
  )}
1005
1009
 
1006
1010
  {/* ── Account ── */}
1007
- <GroupedSection>
1008
- <ListRow
1009
- label={t('log_out')}
1010
- icon="log-out-outline"
1011
- iconColor={colors.error}
1012
- onPress={async () => {
1013
- if (loggingOut) return
1014
- const choice = await showAlert({
1015
- title: t('delete_wallet_warning_title'),
1016
- message: t('delete_wallet_warning_body'),
1017
- buttons: [
1018
- { text: t('cancel'), style: 'cancel', key: 'cancel' },
1019
- { text: t('delete_wallet_confirm'), style: 'destructive', key: 'delete' },
1020
- ],
1021
- })
1022
- if (choice !== 'delete') return
1023
- setLoggingOut(true)
1024
- // No artificial yield before this call, unlike the wallet-creation
1025
- // spinner: logout()'s synchronous prefix (which stops the
1026
- // background monitor's task loop) still runs before its first
1027
- // await, exactly as before — a gap here let the monitor's own
1028
- // pending tick sneak in a fresh task run against storage that
1029
- // was about to be torn down (WERR_UNKNOWN "Database not
1030
- // initialized" from a task caught mid-flight). Awaiting the
1031
- // result below only affects what happens AFTER that teardown.
1032
- //
1033
- // XR-107: logout() now resolves to whether the secrets layer
1034
- // verified every legacy plaintext item erased. A persistent
1035
- // SecureStore delete failure must be reported, not silently
1036
- // treated as a completed "Delete Wallet" — the user needs to
1037
- // know and be able to retry, rather than being navigated away
1038
- // as though nothing were left behind.
1039
- const erased = await logout()
1040
- if (!erased) {
1041
- setLoggingOut(false)
1042
- await showAlert({
1043
- title: t('delete_wallet_failed_title'),
1044
- message: t('delete_wallet_failed_body'),
1045
- buttons: [{ text: t('vault_ok'), key: 'ok' }],
1011
+ {!hideLogout && (
1012
+ <GroupedSection>
1013
+ <ListRow
1014
+ label={t('log_out')}
1015
+ icon="log-out-outline"
1016
+ iconColor={colors.error}
1017
+ onPress={async () => {
1018
+ if (loggingOut) return
1019
+ const choice = await showAlert({
1020
+ title: t('delete_wallet_warning_title'),
1021
+ message: t('delete_wallet_warning_body'),
1022
+ buttons: [
1023
+ { text: t('cancel'), style: 'cancel', key: 'cancel' },
1024
+ { text: t('delete_wallet_confirm'), style: 'destructive', key: 'delete' },
1025
+ ],
1046
1026
  })
1047
- }
1048
- // On success logout() has already navigated away — the screen
1049
- // that owns `loggingOut` is gone, so there is nothing left to
1050
- // reset here.
1051
- }}
1052
- destructive
1053
- showChevron={false}
1054
- trailing={loggingOut ? <ActivityIndicator size="small" color={colors.error} /> : undefined}
1055
- isLast
1056
- />
1057
- </GroupedSection>
1027
+ if (choice !== 'delete') return
1028
+ setLoggingOut(true)
1029
+ // No artificial yield before this call, unlike the wallet-creation
1030
+ // spinner: logout()'s synchronous prefix (which stops the
1031
+ // background monitor's task loop) still runs before its first
1032
+ // await, exactly as before — a gap here let the monitor's own
1033
+ // pending tick sneak in a fresh task run against storage that
1034
+ // was about to be torn down (WERR_UNKNOWN "Database not
1035
+ // initialized" from a task caught mid-flight). Awaiting the
1036
+ // result below only affects what happens AFTER that teardown.
1037
+ //
1038
+ // XR-107: logout() now resolves to whether the secrets layer
1039
+ // verified every legacy plaintext item erased. A persistent
1040
+ // SecureStore delete failure must be reported, not silently
1041
+ // treated as a completed "Delete Wallet" — the user needs to
1042
+ // know and be able to retry, rather than being navigated away
1043
+ // as though nothing were left behind.
1044
+ const erased = await logout()
1045
+ if (!erased) {
1046
+ setLoggingOut(false)
1047
+ await showAlert({
1048
+ title: t('delete_wallet_failed_title'),
1049
+ message: t('delete_wallet_failed_body'),
1050
+ buttons: [{ text: t('vault_ok'), key: 'ok' }],
1051
+ })
1052
+ }
1053
+ // On success logout() has already navigated away — the screen
1054
+ // that owns `loggingOut` is gone, so there is nothing left to
1055
+ // reset here.
1056
+ }}
1057
+ destructive
1058
+ showChevron={false}
1059
+ trailing={loggingOut ? <ActivityIndicator size="small" color={colors.error} /> : undefined}
1060
+ isLast
1061
+ />
1062
+ </GroupedSection>
1063
+ )}
1058
1064
 
1059
1065
  {/* The number we ask people to quote when something goes wrong, so it is
1060
1066
  always to hand without being something to read. Quiet on purpose: