@bsv/expo-wallet-toolbox 0.21.0 → 0.23.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 (133) hide show
  1. package/CHANGELOG.md +222 -0
  2. package/README.md +82 -13
  3. package/core/bridge/BrowserBridgeProvider.tsx +273 -0
  4. package/core/bridge/bindings.ts +459 -0
  5. package/core/bridge/conformance.ts +222 -0
  6. package/core/bridge/consent.ts +494 -0
  7. package/core/bridge/consentSheetSource.ts +98 -0
  8. package/core/bridge/dispatcher.ts +621 -0
  9. package/core/bridge/inbox.ts +464 -0
  10. package/core/bridge/index.ts +48 -0
  11. package/core/bridge/loopback/cors.ts +57 -0
  12. package/core/bridge/loopback/endpoints.ts +11 -0
  13. package/core/bridge/loopback/hostCheck.ts +25 -0
  14. package/core/bridge/loopback/index.ts +7 -0
  15. package/core/bridge/loopback/launchProof.ts +166 -0
  16. package/core/bridge/loopback/router.ts +770 -0
  17. package/core/bridge/loopback/routerTypes.ts +115 -0
  18. package/core/bridge/loopback/status.ts +52 -0
  19. package/core/bridge/memoryInboxStore.ts +222 -0
  20. package/core/bridge/permissionPolicy.ts +247 -0
  21. package/core/bridge/policy.ts +72 -0
  22. package/core/bridge/protocol/base64url.ts +64 -0
  23. package/core/bridge/protocol/connectionError.ts +79 -0
  24. package/core/bridge/protocol/constants.ts +21 -0
  25. package/core/bridge/protocol/continuity.ts +21 -0
  26. package/core/bridge/protocol/descriptor.ts +395 -0
  27. package/core/bridge/protocol/envelopes.ts +188 -0
  28. package/core/bridge/protocol/errorCodec.ts +164 -0
  29. package/core/bridge/protocol/json.ts +237 -0
  30. package/core/bridge/protocol/limits.ts +43 -0
  31. package/core/bridge/protocol/methods.ts +55 -0
  32. package/core/bridge/protocol/origin.ts +130 -0
  33. package/core/bridge/runtime.ts +642 -0
  34. package/core/bridge/runtimeFlags.ts +34 -0
  35. package/core/bridge/testing/conformanceCases.ts +149 -0
  36. package/core/bridge/testing/pageClient.ts +44 -0
  37. package/core/bridge/unverifiedManager.ts +97 -0
  38. package/core/bridge/unverifiedOriginator.ts +79 -0
  39. package/core/config.tsx +1 -16
  40. package/core/contacts/contactActivity.ts +48 -28
  41. package/core/contacts/contactsStore.ts +2 -2
  42. package/core/context/WalletConnectionContext.tsx +7 -1
  43. package/core/context/WalletContext.tsx +420 -348
  44. package/core/context/sessionTeardown.ts +46 -0
  45. package/core/demo/demoAssets.ts +8 -10
  46. package/core/demo/demoLedger.ts +32 -38
  47. package/core/demo/demoMandalaRuntime.ts +67 -49
  48. package/core/demo/index.ts +1 -1
  49. package/core/hooks/usePermissionQueue.ts +89 -34
  50. package/core/i18n/translations.tsx +983 -12
  51. package/core/index.ts +70 -37
  52. package/core/localpay/build.ts +110 -569
  53. package/core/localpay/codec.ts +190 -93
  54. package/core/localpay/pending.ts +217 -202
  55. package/core/localpay/session.ts +99 -25
  56. package/core/localpay/types.ts +6 -5
  57. package/core/localpay/verify.ts +118 -173
  58. package/core/mandala/abortGuard.ts +97 -120
  59. package/core/mandala/accessPolicy.ts +133 -0
  60. package/core/mandala/assets.ts +370 -0
  61. package/core/mandala/colorGuard.ts +178 -0
  62. package/core/mandala/colorModule.ts +82 -0
  63. package/core/mandala/createRuntime.ts +483 -2392
  64. package/core/mandala/handle.ts +694 -0
  65. package/core/mandala/kvStore.ts +105 -0
  66. package/core/mandala/nearby.ts +185 -0
  67. package/core/mandala/receipt.ts +121 -0
  68. package/core/mandala/runtime.ts +166 -312
  69. package/core/mandala/settle.ts +540 -0
  70. package/core/mandala/transferJournal.ts +395 -0
  71. package/core/mandala/types.ts +61 -311
  72. package/core/networks.ts +5 -5
  73. package/core/offline/cancelParked.ts +80 -63
  74. package/core/offline/payerHold.ts +52 -118
  75. package/core/parsePeerPayURI.ts +25 -12
  76. package/core/pay/rails/handle.ts +15 -14
  77. package/core/pay/rails/index.ts +5 -3
  78. package/core/pay/rails/nearby.ts +25 -87
  79. package/core/profiles/assertProfileEmpty.ts +19 -10
  80. package/core/services/autoApprovePolicy.ts +7 -1
  81. package/core/services/capWalletArgs.ts +2 -1
  82. package/core/services/permissionPrompts.ts +132 -0
  83. package/core/services/signingPermissionPolicy.ts +230 -2
  84. package/core/services/vault/guard.ts +15 -4
  85. package/core/services/walletArgLimits.ts +17 -2
  86. package/core/storage/StorageExpoSQLite.ts +93 -229
  87. package/core/storage/encryptedDbImage.ts +325 -0
  88. package/core/storage/methods/processOfflineActions.ts +86 -136
  89. package/core/storage/schema/createTables.ts +9 -184
  90. package/core/toolboxConfig.ts +18 -1
  91. package/package.json +9 -8
  92. package/ui/bridgeSheet/ContextRelay.tsx +86 -0
  93. package/ui/bridgeSheet/relayedContexts.ts +21 -0
  94. package/ui/components/pay/AssetPicker.tsx +2 -2
  95. package/ui/components/pay/HandleReceive.tsx +4 -4
  96. package/ui/components/pay/NearbyFlow.tsx +324 -239
  97. package/ui/components/pay/RequestHub.tsx +10 -0
  98. package/ui/components/pay/UniversalSend.tsx +31 -28
  99. package/ui/components/pay/useRecipientInput.ts +2 -2
  100. package/ui/components/ui/PermissionSheet.tsx +625 -315
  101. package/ui/components/ui/Sheet.tsx +59 -7
  102. package/ui/components/ui/colorPrompt.ts +236 -0
  103. package/ui/components/ui/sheetResumeSignal.ts +19 -0
  104. package/ui/components/wallet/AmountInput.tsx +9 -6
  105. package/ui/components/wallet/AssetAmount.tsx +6 -6
  106. package/ui/components/wallet/AssetSwitcherDropdown.tsx +26 -7
  107. package/ui/components/wallet/Balance.tsx +3 -1
  108. package/ui/components/wallet/ContactActivityList.tsx +10 -13
  109. package/ui/components/wallet/tokenEviction.ts +9 -9
  110. package/ui/exportDatabases.ts +94 -5
  111. package/ui/hooks/useExportWalletData.ts +37 -24
  112. package/ui/hooks/useMandala.ts +6 -6
  113. package/ui/hooks/useSpendableBalance.ts +3 -1
  114. package/ui/importDatabases.ts +124 -29
  115. package/ui/index.ts +4 -0
  116. package/ui/screens/PayScreen.tsx +14 -20
  117. package/ui/screens/SettingsScreen.tsx +3 -1
  118. package/ui/screens/WalletCheckScreen.tsx +7 -2
  119. package/ui/screens/WalletConfigScreen.tsx +13 -1
  120. package/ui/screens/WalletHomeScreen.tsx +40 -14
  121. package/ui/screens/tokenRowTitle.ts +28 -15
  122. package/ui/tokenFormat.ts +133 -69
  123. package/ui/tokenStatus.ts +5 -8
  124. package/core/localpay/settlementAck.ts +0 -155
  125. package/core/mandala/basketMigration.ts +0 -166
  126. package/core/mandala/bundle.ts +0 -244
  127. package/core/mandala/drain.ts +0 -754
  128. package/core/mandala/inboxPrehold.ts +0 -193
  129. package/core/mandala/permissionModule.ts +0 -931
  130. package/core/mandala/resendTransfer.ts +0 -178
  131. package/core/mandala/settlementStore.ts +0 -434
  132. package/core/mandala/token.ts +0 -45
  133. package/core/offline/tokenFrames.ts +0 -197
package/core/index.ts CHANGED
@@ -132,6 +132,8 @@ export * from './directpay/deviceStore'
132
132
  export * from './directpay/receive'
133
133
  export * from './directpay/DirectPayManager'
134
134
  export * from './directpay/DirectPayProvider'
135
+ // The browser bridge's public API (BRC-185 core): see './bridge/index'.
136
+ export * from './bridge'
135
137
  export * from './peerpay/outbox'
136
138
  export * from './peerpay/control'
137
139
  export * from './peerpay/handleResendRequests'
@@ -146,7 +148,6 @@ export * from './offline/hold'
146
148
  export * from './offline/order'
147
149
  export * from './offline/plan'
148
150
  export * from './offline/payerHold'
149
- export * from './offline/tokenFrames'
150
151
  export {
151
152
  cancelParkedPayment,
152
153
  chainAlreadyKnows,
@@ -156,81 +157,113 @@ export {
156
157
  type CancelParkedSettlementDeps
157
158
  } from './offline/cancelParked'
158
159
 
159
- // Mandala token settlement — the four evidence tables, and the
160
- // submit-before-broadcast drain over them.
160
+ // 1Color transfers — the journal types, the `color_transfers` journal (the
161
+ // one key for the broadcast hold and the abort refusal), and the one-time
162
+ // migration off the Mandala settlement tables.
161
163
  export * from './mandala/types'
162
- export { createSettlementStore, type SettlementDb, type SqlSettlementStore } from './mandala/settlementStore'
164
+ export {
165
+ createTransferJournal,
166
+ migrateMandalaToColor,
167
+ COLOR_MIGRATION_MARKER,
168
+ type JournalDb,
169
+ type TransferJournal
170
+ } from './mandala/transferJournal'
163
171
  // Guard #4: an abortAction may not release the inputs of a token payment the
164
172
  // overlay already has (the 2026-09-15 incident).
165
173
  export {
166
174
  abortIsBlockedBy,
167
175
  wrapAbortActionForSettlements,
168
- ABORT_BLOCKED_SETTLEMENT_STATES,
176
+ ABORT_BLOCKED_TRANSFER_STATES,
169
177
  type AbortableManager,
170
- type SettlementStoreLookup
178
+ type TransferJournalLookup,
179
+ type TokenSettlementPossible
171
180
  } from './mandala/abortGuard'
172
- export {
173
- deriveTokenEdges,
174
- isRetriableInternalizeFailure,
175
- listStuckSettlements,
176
- populateEvidenceFromFrame,
177
- postTokenStep,
178
- reconcileSettlements,
179
- NON_TERMINAL_SETTLEMENT_STATES,
180
- TERMINAL_SETTLEMENT_STATES,
181
- type EvidenceFrame,
182
- type EvidencePopulated,
183
- type EvidenceTokenBlock,
184
- type EvidenceTrustAnchor,
185
- type TokenFrameSource,
186
- type TokenStepDeps
187
- } from './mandala/drain'
188
181
  // The runtime the UI consumes: its pure interface, and its one construction
189
182
  // site. `useMandala()` reads `useWallet().mandala`; nothing above this line in
190
183
  // an app may import `@bsv/mandala` itself.
191
184
  export type {
192
185
  MandalaRuntime,
186
+ NearbyTokenDeps,
193
187
  TokenActivityRow,
194
188
  TokenActivityStatus,
195
189
  TokenAssetInfo,
190
+ TokenAssetStatus,
196
191
  TokenBalance,
197
- TokenSendResult
192
+ TokenHoldingsReview,
193
+ TokenSendResult,
194
+ TokenSettleState
198
195
  } from './mandala/runtime'
196
+ export {
197
+ createAssetMetadata,
198
+ offlineUnitsOf,
199
+ readAvailable,
200
+ readInventory,
201
+ readPending,
202
+ shortAssetId,
203
+ type InventoryRecord
204
+ } from './mandala/assets'
199
205
  export {
200
206
  activityStatusOf,
201
207
  bindOriginator,
202
208
  createMandalaKvStorage,
203
209
  createMandalaRuntime,
204
- verdictFromError,
205
210
  type CreateMandalaRuntimeArgs,
206
211
  type MandalaKvStorage,
207
212
  type MandalaMessageBox
208
213
  } from './mandala/createRuntime'
214
+ // The BRC-207 color module as WalletContext registers it
215
+ // (`permissionModules.color`): the module with the Mandala issuer-v1 profile
216
+ // and the host ledger it credits from (B7), its `ColorModuleStore` over
217
+ // `key_value_store`, and the host consent policy. A host that builds its own
218
+ // permissions manager needs all of them to give `createMandalaRuntime` a
219
+ // module, a provider and a ledger.
220
+ export { buildColorModule, type BuildColorModuleArgs, type BuiltColorModule } from './mandala/colorModule'
221
+ export { createColorModuleStore, type WalletKv } from './mandala/kvStore'
209
222
  export {
210
- assembleBundle,
211
- coverFromFrame,
212
- tokenParentsOf,
213
- type AdmissionBundle,
214
- type BundleStore,
215
- type CoverBundle,
216
- type CoverTip,
217
- type CoverVerifier
218
- } from './mandala/bundle'
223
+ createColorAccessPolicy,
224
+ colorPromptType,
225
+ COLOR_PROMPT_TYPES,
226
+ type ColorAccessPolicyOptions,
227
+ type ColorPromptType
228
+ } from './mandala/accessPolicy'
229
+ // A nearby token frame as the v4 hand-over body (B7, IC §7.3), and how a
230
+ // failed receipt is classified.
231
+ export {
232
+ bodyFromFrame,
233
+ isRetriableReceiptFailure,
234
+ isTransportReceiptFailure,
235
+ receiptFailureCode,
236
+ tokenPaymentOfHandover
237
+ } from './mandala/receipt'
238
+ export { createHandoverBodies, handoverBodyKey, type HandoverBodies } from './mandala/handle'
219
239
 
220
240
  // Contacts
221
241
  export { mergeContactCache, type ContactCache } from './contacts/contactCache'
222
242
 
223
243
  // Local SQLite storage layer
224
244
  export { StorageExpoSQLite } from './storage/StorageExpoSQLite'
225
- export type { StorageExpoSQLiteOptions, TokenTransactionRepair } from './storage/StorageExpoSQLite'
226
- export { createTables, ensureOfflineActionsColumns, ensureTokenSettlementColumns } from './storage/schema/createTables'
245
+ export type { StorageExpoSQLiteOptions } from './storage/StorageExpoSQLite'
246
+ export { createTables, ensureOfflineActionsColumns } from './storage/schema/createTables'
227
247
  export { findOfflineActions, findOfflineActionByTxid, updateOfflineAction } from './storage/methods/offlineActions'
228
248
  export type { OfflineActionRow, OfflineActionStatus, BindValue } from './storage/methods/offlineActions'
229
249
  export { readWalletBalance } from './storage/methods/walletBalanceSql'
230
- export { processOfflineActions, type OfflineTokenDeps } from './storage/methods/processOfflineActions'
231
- export { createMandalaSettlementTables } from './storage/schema/createTables'
250
+ export { processOfflineActions } from './storage/methods/processOfflineActions'
251
+ export { colorHeldTxids, txHasColorOutput } from './mandala/colorGuard'
232
252
  export * from './storage/skipQueuedAncestors'
233
253
  export { prepareSqliteImageForDeserialize } from './storage/dbImage'
254
+ export {
255
+ encryptDbImage,
256
+ decryptDbImage,
257
+ isEncryptedDbImage,
258
+ EncryptedDbError,
259
+ ENCRYPTED_DB_EXTENSION,
260
+ DB_EXPORT_PROTOCOL,
261
+ type DbExportWallet,
262
+ type EncryptedDbErrorCode,
263
+ type EncryptedDbOptions,
264
+ type ByteSource,
265
+ type ByteSink
266
+ } from './storage/encryptedDbImage'
234
267
 
235
268
  // Local secrets storage
236
269
  export {