@bsv/expo-wallet-toolbox 0.23.0 → 0.24.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/CHANGELOG.md +133 -0
- package/README.md +1 -4
- package/android/build.gradle +15 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/org/bsv/boundedfetch/BoundedBody.java +19 -0
- package/android/src/main/java/org/bsv/boundedfetch/BoundedConnection.java +28 -0
- package/android/src/main/java/org/bsv/boundedfetch/BsvBoundedFetchModule.kt +114 -0
- package/core/backup/RemoteSyncReader.ts +71 -46
- package/core/backup/client.ts +6 -15
- package/core/backup/codec.ts +78 -13
- package/core/backup/constants.ts +3 -9
- package/core/backup/cursor.ts +8 -0
- package/core/backup/push.ts +26 -16
- package/core/backup/restore.ts +6 -5
- package/core/bridge/inbox.ts +169 -64
- package/core/bridge/memoryInboxStore.ts +10 -1
- package/core/constants.ts +7 -11
- package/core/context/WalletConnectionContext.tsx +85 -48
- package/core/context/WalletContext.tsx +30 -32
- package/core/context/usePairingAttempt.ts +31 -0
- package/core/e2e/broadcaster.ts +25 -0
- package/core/e2e/consentFixture.ts +46 -0
- package/core/e2e/mode.ts +42 -0
- package/core/headers/OfflineFirstChaintracks.ts +57 -107
- package/core/headers/headerConsensus.ts +230 -0
- package/core/headers/headerStore.ts +344 -122
- package/core/headers/prewarm.ts +4 -7
- package/core/headers/syncHeaders.ts +82 -12
- package/core/i18n/translations.tsx +47 -12
- package/core/identity/handleRegistry/client.ts +4 -2
- package/core/identity/handleRegistry/resolver.ts +7 -11
- package/core/index.ts +2 -0
- package/core/localpay/pending.ts +39 -4
- package/core/network/boundedFetch.ts +101 -0
- package/core/networks.ts +11 -13
- package/core/pay/rails/address.ts +5 -4
- package/core/pay/rails/handle.ts +3 -1
- package/core/pay/rails/sweep.ts +791 -0
- package/core/peerpay/brc29.ts +4 -0
- package/core/peerpay/handleResendRequests.ts +15 -2
- package/core/peerpay/outbox.ts +115 -2
- package/core/profiles/assertProfileEmpty.ts +2 -2
- package/core/profiles/profileStore.ts +3 -2
- package/core/services/arcadeBroadcastProvider.ts +260 -114
- package/core/services/secrets/kek.ts +5 -0
- package/core/services/secrets/migration.ts +27 -2
- package/core/services/secrets/policy.ts +6 -0
- package/core/services/vault/VaultKeyService.ts +5 -2
- package/core/services/vault/ceremony.ts +2 -2
- package/core/services/vault/ceremonyHost.ts +1 -1
- package/core/services/vault/guard.ts +10 -0
- package/core/services/vault/outputAuthority.ts +76 -0
- package/core/services/vault/transfers.ts +52 -28
- package/core/services/vault/vaultStore.ts +60 -14
- package/core/services/walletConnectionValidation.ts +13 -1
- package/core/services/walletServiceConfig.ts +8 -7
- package/core/stores/ConnectionStore.ts +17 -0
- package/core/toolboxConfig.ts +60 -1
- package/expo-module.config.json +5 -0
- package/ios/BoundedBody.swift +15 -0
- package/ios/BsvBoundedFetch.podspec +17 -0
- package/ios/BsvBoundedFetchModule.swift +121 -0
- package/package.json +7 -3
- package/ui/components/pay/AddressReceive.tsx +6 -2
- package/ui/components/pay/ImportedOutboxApproval.tsx +142 -0
- package/ui/components/pay/PayCellRow.tsx +3 -1
- package/ui/components/pay/PayForm.tsx +12 -2
- package/ui/components/pay/RecipientField.tsx +1 -0
- package/ui/components/pay/RequestHub.tsx +1 -0
- package/ui/components/pay/UniversalSend.tsx +110 -42
- package/ui/components/ui/ListRow.tsx +10 -2
- package/ui/components/vault/KeyChooser.tsx +1 -1
- package/ui/components/wallet/AmountInput.tsx +4 -1
- package/ui/components/wallet/BackupReminderSheet.tsx +8 -1
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +2 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +6 -1
- package/ui/components/wallet/ProfileButton.tsx +1 -0
- package/ui/importDatabases.ts +31 -6
- package/ui/screens/ConnectionsScreen.tsx +12 -3
- package/ui/screens/PairScreen.tsx +10 -3
- package/ui/screens/PayScreen.tsx +1 -0
- package/ui/screens/TrustScreen.tsx +6 -3
- package/ui/screens/VaultScreen.tsx +13 -3
- package/ui/screens/VaultTransferScreen.tsx +6 -3
- package/ui/screens/WalletConfigScreen.tsx +17 -2
- package/ui/screens/WalletHomeScreen.tsx +7 -1
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { Utils } from '@bsv/sdk'
|
|
13
13
|
import type { HeaderStore } from './headerStore'
|
|
14
|
+
import { parseHeader } from './headerConsensus'
|
|
14
15
|
|
|
15
16
|
export interface HeaderSource {
|
|
16
17
|
getHeaders(height: number, count: number): Promise<string>
|
|
@@ -41,10 +42,35 @@ export async function syncHeaders(args: {
|
|
|
41
42
|
onProgress?: (tipHeight: number, presentHeight: number) => void
|
|
42
43
|
shouldStop?: () => boolean
|
|
43
44
|
}): Promise<SyncHeadersResult> {
|
|
45
|
+
return args.store.withUpdateLock(() => syncHeadersUnlocked(args))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function syncHeadersUnlocked(args: Parameters<typeof syncHeaders>[0]): Promise<SyncHeadersResult> {
|
|
44
49
|
const { store, client, chunkSize = 2000, onProgress, shouldStop } = args
|
|
50
|
+
if (!Number.isSafeInteger(chunkSize) || chunkSize < 1 || chunkSize > 100000)
|
|
51
|
+
throw new Error('Invalid header chunk size')
|
|
45
52
|
const presentHeight = await client.getPresentHeight()
|
|
46
53
|
let added = 0
|
|
47
|
-
|
|
54
|
+
if (!Number.isSafeInteger(presentHeight) || presentHeight < store.anchor.height || presentHeight > 0x7fffffff) {
|
|
55
|
+
throw new Error('Chain source returned an invalid present height')
|
|
56
|
+
}
|
|
57
|
+
if (store.needsContext) {
|
|
58
|
+
const hex = await client.getHeaders(store.contextStartHeight, store.contextCount)
|
|
59
|
+
if (hex.length !== store.contextCount * HEADER_BYTES * 2 || !/^[0-9a-f]+$/i.test(hex)) {
|
|
60
|
+
throw new Error('Header bootstrap context unavailable or malformed')
|
|
61
|
+
}
|
|
62
|
+
await store.initializeContext(new Uint8Array(Utils.toArray(hex, 'hex')))
|
|
63
|
+
}
|
|
64
|
+
// A same-height or shorter competing chain can still have more work. Do not
|
|
65
|
+
// use advertised height as a substitute for comparing locally computed work.
|
|
66
|
+
if (store.count > 0 && presentHeight <= store.tipHeight) {
|
|
67
|
+
const at = Math.min(presentHeight, store.tipHeight)
|
|
68
|
+
const hex = await client.getHeaders(at, 1)
|
|
69
|
+
if (hex.length !== HEADER_BYTES * 2) throw new Error('Chain tip header unavailable')
|
|
70
|
+
if (parseHeader(new Uint8Array(Utils.toArray(hex, 'hex'))).hash !== store.hashForHeight(at)) {
|
|
71
|
+
added += await reconcileBranch(store, client, presentHeight, chunkSize, shouldStop)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
48
74
|
|
|
49
75
|
while (store.tipHeight < presentHeight) {
|
|
50
76
|
if (shouldStop?.()) break
|
|
@@ -66,19 +92,63 @@ export async function syncHeaders(args: {
|
|
|
66
92
|
added += await store.append(bytes, from)
|
|
67
93
|
onProgress?.(store.tipHeight, presentHeight)
|
|
68
94
|
} catch (err) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!isFirstHeaderPrevHashError(err, from)) throw err
|
|
73
|
-
if (store.count > 0 && rewinds < REWIND_CAP) {
|
|
74
|
-
await store.truncateToCount(store.count - 1)
|
|
75
|
-
rewinds++
|
|
76
|
-
continue
|
|
77
|
-
}
|
|
78
|
-
await store.reset()
|
|
79
|
-
throw err
|
|
95
|
+
if (!isFirstHeaderPrevHashError(err, from) || store.count === 0) throw err
|
|
96
|
+
added += await reconcileBranch(store, client, presentHeight, chunkSize, shouldStop)
|
|
97
|
+
onProgress?.(store.tipHeight, presentHeight)
|
|
80
98
|
}
|
|
81
99
|
}
|
|
82
100
|
|
|
83
101
|
return { added, tipHeight: store.tipHeight, presentHeight }
|
|
84
102
|
}
|
|
103
|
+
|
|
104
|
+
/** Find a locally authenticated ancestor, stage/validate, then compare work. */
|
|
105
|
+
async function reconcileBranch(
|
|
106
|
+
store: HeaderStore,
|
|
107
|
+
client: HeaderSource,
|
|
108
|
+
presentHeight: number,
|
|
109
|
+
chunkSize: number,
|
|
110
|
+
shouldStop?: () => boolean
|
|
111
|
+
): Promise<number> {
|
|
112
|
+
let ancestor: number | undefined
|
|
113
|
+
for (
|
|
114
|
+
let height = Math.min(store.tipHeight, presentHeight);
|
|
115
|
+
height >= store.anchor.height && height >= store.tipHeight - REWIND_CAP;
|
|
116
|
+
height--
|
|
117
|
+
) {
|
|
118
|
+
if (shouldStop?.()) return 0
|
|
119
|
+
const hex = await client.getHeaders(height, 1)
|
|
120
|
+
if (hex.length !== HEADER_BYTES * 2 || !/^[0-9a-f]+$/i.test(hex))
|
|
121
|
+
throw new Error('Reorg ancestor header unavailable')
|
|
122
|
+
const header = parseHeader(new Uint8Array(Utils.toArray(hex, 'hex')))
|
|
123
|
+
if (header.hash === store.hashForHeight(height)) {
|
|
124
|
+
ancestor = height
|
|
125
|
+
break
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (ancestor === undefined) throw new Error('No authenticated reorg ancestor within rewind limit')
|
|
129
|
+
let staged = new Uint8Array(0)
|
|
130
|
+
for (let from = ancestor + 1; from <= presentHeight;) {
|
|
131
|
+
if (shouldStop?.()) return 0
|
|
132
|
+
const want = Math.min(chunkSize, presentHeight - from + 1)
|
|
133
|
+
const hex = await client.getHeaders(from, want)
|
|
134
|
+
if (!hex || !/^[0-9a-f]+$/i.test(hex)) throw new Error('Replacement header branch unavailable')
|
|
135
|
+
const bytes = new Uint8Array(Utils.toArray(hex.slice(0, want * HEADER_BYTES * 2), 'hex'))
|
|
136
|
+
if (bytes.length === 0 || bytes.length % HEADER_BYTES !== 0) throw new Error('Malformed replacement header branch')
|
|
137
|
+
const merged = new Uint8Array(staged.length + bytes.length)
|
|
138
|
+
merged.set(staged)
|
|
139
|
+
merged.set(bytes, staged.length)
|
|
140
|
+
staged = merged
|
|
141
|
+
from += bytes.length / HEADER_BYTES
|
|
142
|
+
try {
|
|
143
|
+
return await store.replaceBranch(ancestor + 1, staged)
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (
|
|
146
|
+
!(error instanceof Error) ||
|
|
147
|
+
!error.message.startsWith('Replacement header branch does not have greater accumulated work')
|
|
148
|
+
)
|
|
149
|
+
throw error
|
|
150
|
+
if (from > presentHeight) throw error
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw new Error('Replacement header branch does not have greater accumulated work')
|
|
154
|
+
}
|
|
@@ -300,7 +300,7 @@ const resources = {
|
|
|
300
300
|
vault_withdraw_cta: 'Withdraw',
|
|
301
301
|
vault_deposit_title: 'Deposit to vault',
|
|
302
302
|
vault_withdraw_title: 'Withdraw from vault',
|
|
303
|
-
vault_deposit_sub: 'From your everyday balance.
|
|
303
|
+
vault_deposit_sub: 'From your everyday balance. Confirm with an enrolled YubiKey.',
|
|
304
304
|
vault_withdraw_sub: 'Back to your everyday balance. Tap any of your vault keys.',
|
|
305
305
|
vault_deposit_done: 'Moved to vault',
|
|
306
306
|
vault_reclaim_done: 'Recovered funds from an interrupted vault deposit',
|
|
@@ -684,6 +684,9 @@ const resources = {
|
|
|
684
684
|
display_currency: 'Display Currency',
|
|
685
685
|
no_pending_payments: 'No pending payments',
|
|
686
686
|
outgoing_payments: 'Outgoing',
|
|
687
|
+
review_imported_payment: 'Review imported payment',
|
|
688
|
+
review_imported_payment_detail:
|
|
689
|
+
'This payment came from a backup and may have been canceled. Send {{amount}} satoshis to {{recipient}} now?',
|
|
687
690
|
payment_not_delivered: 'Not delivered',
|
|
688
691
|
payment_delivered: 'Delivered',
|
|
689
692
|
retry: 'Retry',
|
|
@@ -1526,7 +1529,7 @@ const resources = {
|
|
|
1526
1529
|
vault_withdraw_cta: '提取',
|
|
1527
1530
|
vault_deposit_title: '存入保险库',
|
|
1528
1531
|
vault_withdraw_title: '从保险库提取',
|
|
1529
|
-
vault_deposit_sub: '
|
|
1532
|
+
vault_deposit_sub: '来自您的日常余额。请使用已登记的 YubiKey 确认。',
|
|
1530
1533
|
vault_withdraw_sub: '回到您的日常余额。轻触您的任意一把保险库密钥。',
|
|
1531
1534
|
vault_deposit_done: '已转入保险库',
|
|
1532
1535
|
vault_reclaim_done: '已从中断的保险库存入中恢复资金',
|
|
@@ -1865,6 +1868,8 @@ const resources = {
|
|
|
1865
1868
|
display_currency: '显示货币',
|
|
1866
1869
|
no_pending_payments: '没有待处理的付款',
|
|
1867
1870
|
outgoing_payments: '已发出',
|
|
1871
|
+
review_imported_payment: '审核导入的付款',
|
|
1872
|
+
review_imported_payment_detail: '此付款来自备份,可能已被取消。现在向 {{recipient}} 发送 {{amount}} 聪吗?',
|
|
1868
1873
|
payment_not_delivered: '未送达',
|
|
1869
1874
|
payment_delivered: '已送达',
|
|
1870
1875
|
retry: '重试',
|
|
@@ -2686,7 +2691,7 @@ const resources = {
|
|
|
2686
2691
|
vault_withdraw_cta: 'निकालें',
|
|
2687
2692
|
vault_deposit_title: 'वॉल्ट में जमा करें',
|
|
2688
2693
|
vault_withdraw_title: 'वॉल्ट से निकालें',
|
|
2689
|
-
vault_deposit_sub: 'आपके रोज़मर्रा के बैलेंस से। YubiKey
|
|
2694
|
+
vault_deposit_sub: 'आपके रोज़मर्रा के बैलेंस से। पंजीकृत YubiKey से पुष्टि करें।',
|
|
2690
2695
|
vault_withdraw_sub: 'वापस आपके रोज़मर्रा के बैलेंस में। अपनी किसी भी वॉल्ट कुंजी को टैप करें।',
|
|
2691
2696
|
vault_deposit_done: 'वॉल्ट में ले जाया गया',
|
|
2692
2697
|
vault_reclaim_done: 'बाधित वॉल्ट जमा से धनराशि पुनर्प्राप्त की गई',
|
|
@@ -3051,6 +3056,9 @@ const resources = {
|
|
|
3051
3056
|
display_currency: 'प्रदर्शन मुद्रा',
|
|
3052
3057
|
no_pending_payments: 'कोई लंबित भुगतान नहीं',
|
|
3053
3058
|
outgoing_payments: 'भेजे गए',
|
|
3059
|
+
review_imported_payment: 'आयातित भुगतान की समीक्षा करें',
|
|
3060
|
+
review_imported_payment_detail:
|
|
3061
|
+
'यह भुगतान बैकअप से आया है और संभव है कि इसे रद्द कर दिया गया हो। क्या अभी {{recipient}} को {{amount}} सातोशी भेजें?',
|
|
3054
3062
|
payment_not_delivered: 'डिलीवर नहीं हुआ',
|
|
3055
3063
|
payment_delivered: 'डिलीवर हो गया',
|
|
3056
3064
|
retry: 'पुनः प्रयास',
|
|
@@ -3905,7 +3913,7 @@ const resources = {
|
|
|
3905
3913
|
vault_withdraw_cta: 'Retirar',
|
|
3906
3914
|
vault_deposit_title: 'Depositar en la caja fuerte',
|
|
3907
3915
|
vault_withdraw_title: 'Retirar de la caja fuerte',
|
|
3908
|
-
vault_deposit_sub: 'Desde tu saldo diario.
|
|
3916
|
+
vault_deposit_sub: 'Desde tu saldo diario. Confirma con una YubiKey registrada.',
|
|
3909
3917
|
vault_withdraw_sub: 'De vuelta a tu saldo diario. Toca cualquiera de tus llaves de la caja fuerte.',
|
|
3910
3918
|
vault_deposit_done: 'Movido a la caja fuerte',
|
|
3911
3919
|
vault_reclaim_done: 'Fondos recuperados de un depósito interrumpido a la caja fuerte',
|
|
@@ -4280,6 +4288,9 @@ const resources = {
|
|
|
4280
4288
|
display_currency: 'Moneda de visualización',
|
|
4281
4289
|
no_pending_payments: 'No hay pagos pendientes',
|
|
4282
4290
|
outgoing_payments: 'Salientes',
|
|
4291
|
+
review_imported_payment: 'Revisar pago importado',
|
|
4292
|
+
review_imported_payment_detail:
|
|
4293
|
+
'Este pago procede de una copia de seguridad y puede haberse cancelado. ¿Enviar ahora {{amount}} satoshis a {{recipient}}?',
|
|
4283
4294
|
payment_not_delivered: 'No entregado',
|
|
4284
4295
|
payment_delivered: 'Entregado',
|
|
4285
4296
|
retry: 'Reintentar',
|
|
@@ -5153,7 +5164,7 @@ const resources = {
|
|
|
5153
5164
|
vault_withdraw_cta: 'Retirer',
|
|
5154
5165
|
vault_deposit_title: 'Déposer dans le coffre',
|
|
5155
5166
|
vault_withdraw_title: 'Retirer du coffre',
|
|
5156
|
-
vault_deposit_sub: 'Depuis votre solde courant.
|
|
5167
|
+
vault_deposit_sub: 'Depuis votre solde courant. Confirmez avec une YubiKey enregistrée.',
|
|
5157
5168
|
vault_withdraw_sub: 'Retour vers votre solde courant. Approchez n’importe laquelle de vos clés du coffre.',
|
|
5158
5169
|
vault_deposit_done: 'Transféré vers le coffre',
|
|
5159
5170
|
vault_reclaim_done: 'Fonds récupérés d’un dépôt interrompu vers le coffre',
|
|
@@ -5528,6 +5539,9 @@ const resources = {
|
|
|
5528
5539
|
display_currency: "Devise d'affichage",
|
|
5529
5540
|
no_pending_payments: 'Aucun paiement en attente',
|
|
5530
5541
|
outgoing_payments: 'Sortants',
|
|
5542
|
+
review_imported_payment: 'Vérifier le paiement importé',
|
|
5543
|
+
review_imported_payment_detail:
|
|
5544
|
+
'Ce paiement provient d’une sauvegarde et a peut-être été annulé. Envoyer maintenant {{amount}} satoshis à {{recipient}} ?',
|
|
5531
5545
|
payment_not_delivered: 'Non livré',
|
|
5532
5546
|
payment_delivered: 'Livré',
|
|
5533
5547
|
retry: 'Réessayer',
|
|
@@ -6387,7 +6401,7 @@ const resources = {
|
|
|
6387
6401
|
vault_withdraw_cta: 'سحب',
|
|
6388
6402
|
vault_deposit_title: 'إيداع في الخزنة',
|
|
6389
6403
|
vault_withdraw_title: 'سحب من الخزنة',
|
|
6390
|
-
vault_deposit_sub: 'من رصيدك اليومي.
|
|
6404
|
+
vault_deposit_sub: 'من رصيدك اليومي. أكّد باستخدام YubiKey مسجّل.',
|
|
6391
6405
|
vault_withdraw_sub: 'عودة إلى رصيدك اليومي. المس أي مفتاح من مفاتيح خزنتك.',
|
|
6392
6406
|
vault_deposit_done: 'تم النقل إلى الخزنة',
|
|
6393
6407
|
vault_reclaim_done: 'تم استرداد الأموال من إيداع خزنة متقطع',
|
|
@@ -6740,6 +6754,9 @@ const resources = {
|
|
|
6740
6754
|
display_currency: 'عملة العرض',
|
|
6741
6755
|
no_pending_payments: 'لا توجد مدفوعات معلقة',
|
|
6742
6756
|
outgoing_payments: 'صادرة',
|
|
6757
|
+
review_imported_payment: 'مراجعة الدفعة المستوردة',
|
|
6758
|
+
review_imported_payment_detail:
|
|
6759
|
+
'جاءت هذه الدفعة من نسخة احتياطية وربما أُلغيت. هل تريد إرسال {{amount}} ساتوشي إلى {{recipient}} الآن؟',
|
|
6743
6760
|
payment_not_delivered: 'لم يتم التسليم',
|
|
6744
6761
|
payment_delivered: 'تم التسليم',
|
|
6745
6762
|
retry: 'إعادة المحاولة',
|
|
@@ -7578,7 +7595,7 @@ const resources = {
|
|
|
7578
7595
|
vault_withdraw_cta: 'Retirar',
|
|
7579
7596
|
vault_deposit_title: 'Depositar no cofre',
|
|
7580
7597
|
vault_withdraw_title: 'Retirar do cofre',
|
|
7581
|
-
vault_deposit_sub: 'Do seu saldo do dia a dia.
|
|
7598
|
+
vault_deposit_sub: 'Do seu saldo do dia a dia. Confirme com uma YubiKey cadastrada.',
|
|
7582
7599
|
vault_withdraw_sub: 'De volta ao seu saldo do dia a dia. Encoste qualquer uma das suas chaves do cofre.',
|
|
7583
7600
|
vault_deposit_done: 'Movido para o cofre',
|
|
7584
7601
|
vault_reclaim_done: 'Fundos recuperados de um depósito interrompido no cofre',
|
|
@@ -7950,6 +7967,9 @@ const resources = {
|
|
|
7950
7967
|
display_currency: 'Moeda de exibição',
|
|
7951
7968
|
no_pending_payments: 'Nenhum pagamento pendente',
|
|
7952
7969
|
outgoing_payments: 'Saídas',
|
|
7970
|
+
review_imported_payment: 'Rever pagamento importado',
|
|
7971
|
+
review_imported_payment_detail:
|
|
7972
|
+
'Este pagamento veio de uma cópia de segurança e pode ter sido cancelado. Enviar agora {{amount}} satoshis para {{recipient}}?',
|
|
7953
7973
|
payment_not_delivered: 'Não entregue',
|
|
7954
7974
|
payment_delivered: 'Entregue',
|
|
7955
7975
|
retry: 'Tentar novamente',
|
|
@@ -8818,7 +8838,7 @@ const resources = {
|
|
|
8818
8838
|
vault_withdraw_cta: 'উত্তোলন',
|
|
8819
8839
|
vault_deposit_title: 'ভল্টে জমা করুন',
|
|
8820
8840
|
vault_withdraw_title: 'ভল্ট থেকে উত্তোলন',
|
|
8821
|
-
vault_deposit_sub: 'আপনার দৈনন্দিন ব্যালেন্স থেকে। YubiKey
|
|
8841
|
+
vault_deposit_sub: 'আপনার দৈনন্দিন ব্যালেন্স থেকে। নিবন্ধিত YubiKey দিয়ে নিশ্চিত করুন।',
|
|
8822
8842
|
vault_withdraw_sub: 'আপনার দৈনন্দিন ব্যালেন্সে ফেরত। আপনার যেকোনো ভল্ট কী ট্যাপ করুন।',
|
|
8823
8843
|
vault_deposit_done: 'ভল্টে সরানো হয়েছে',
|
|
8824
8844
|
vault_reclaim_done: 'বাধাপ্রাপ্ত ভল্ট জমা থেকে তহবিল পুনরুদ্ধার করা হয়েছে',
|
|
@@ -9175,6 +9195,9 @@ const resources = {
|
|
|
9175
9195
|
display_currency: 'প্রদর্শন মুদ্রা',
|
|
9176
9196
|
no_pending_payments: 'কোনো মুলতুবি পেমেন্ট নেই',
|
|
9177
9197
|
outgoing_payments: 'বহির্গামী',
|
|
9198
|
+
review_imported_payment: 'আমদানি করা পেমেন্ট যাচাই করুন',
|
|
9199
|
+
review_imported_payment_detail:
|
|
9200
|
+
'এই পেমেন্টটি ব্যাকআপ থেকে এসেছে এবং হয়তো বাতিল করা হয়েছে। এখন {{recipient}}-কে {{amount}} সাতোশি পাঠাবেন?',
|
|
9178
9201
|
payment_not_delivered: 'ডেলিভারি হয়নি',
|
|
9179
9202
|
payment_delivered: 'ডেলিভারি হয়েছে',
|
|
9180
9203
|
retry: 'পুনরায় চেষ্টা',
|
|
@@ -10031,7 +10054,7 @@ const resources = {
|
|
|
10031
10054
|
vault_withdraw_cta: 'Вывести',
|
|
10032
10055
|
vault_deposit_title: 'Пополнить хранилище',
|
|
10033
10056
|
vault_withdraw_title: 'Вывести из хранилища',
|
|
10034
|
-
vault_deposit_sub: 'С вашего обычного баланса.
|
|
10057
|
+
vault_deposit_sub: 'С вашего обычного баланса. Подтвердите с помощью зарегистрированного YubiKey.',
|
|
10035
10058
|
vault_withdraw_sub: 'Обратно на обычный баланс. Приложите любой из ключей хранилища.',
|
|
10036
10059
|
vault_deposit_done: 'Перемещено в хранилище',
|
|
10037
10060
|
vault_reclaim_done: 'Средства возвращены из прерванного пополнения хранилища',
|
|
@@ -10400,6 +10423,9 @@ const resources = {
|
|
|
10400
10423
|
display_currency: 'Валюта отображения',
|
|
10401
10424
|
no_pending_payments: 'Нет ожидающих платежей',
|
|
10402
10425
|
outgoing_payments: 'Исходящие',
|
|
10426
|
+
review_imported_payment: 'Проверить импортированный платёж',
|
|
10427
|
+
review_imported_payment_detail:
|
|
10428
|
+
'Этот платёж восстановлен из резервной копии и мог быть отменён. Отправить сейчас {{amount}} сатоши получателю {{recipient}}?',
|
|
10403
10429
|
payment_not_delivered: 'Не доставлено',
|
|
10404
10430
|
payment_delivered: 'Доставлено',
|
|
10405
10431
|
retry: 'Повторить',
|
|
@@ -11262,7 +11288,7 @@ const resources = {
|
|
|
11262
11288
|
vault_withdraw_cta: 'Tarik',
|
|
11263
11289
|
vault_deposit_title: 'Setor ke brankas',
|
|
11264
11290
|
vault_withdraw_title: 'Tarik dari brankas',
|
|
11265
|
-
vault_deposit_sub: 'Dari saldo harian Anda.
|
|
11291
|
+
vault_deposit_sub: 'Dari saldo harian Anda. Konfirmasi dengan YubiKey terdaftar.',
|
|
11266
11292
|
vault_withdraw_sub: 'Kembali ke saldo harian Anda. Tempelkan salah satu kunci brankas Anda.',
|
|
11267
11293
|
vault_deposit_done: 'Dipindahkan ke brankas',
|
|
11268
11294
|
vault_reclaim_done: 'Dana dipulihkan dari setoran brankas yang terputus',
|
|
@@ -11630,6 +11656,9 @@ const resources = {
|
|
|
11630
11656
|
display_currency: 'Mata uang tampilan',
|
|
11631
11657
|
no_pending_payments: 'Tidak ada pembayaran tertunda',
|
|
11632
11658
|
outgoing_payments: 'Keluar',
|
|
11659
|
+
review_imported_payment: 'Tinjau pembayaran yang diimpor',
|
|
11660
|
+
review_imported_payment_detail:
|
|
11661
|
+
'Pembayaran ini berasal dari cadangan dan mungkin telah dibatalkan. Kirim {{amount}} satoshi ke {{recipient}} sekarang?',
|
|
11633
11662
|
payment_not_delivered: 'Belum terkirim',
|
|
11634
11663
|
payment_delivered: 'Terkirim',
|
|
11635
11664
|
retry: 'Coba lagi',
|
|
@@ -12496,7 +12525,7 @@ const resources = {
|
|
|
12496
12525
|
vault_withdraw_cta: '出金',
|
|
12497
12526
|
vault_deposit_title: '保管庫に入金',
|
|
12498
12527
|
vault_withdraw_title: '保管庫から出金',
|
|
12499
|
-
vault_deposit_sub: '
|
|
12528
|
+
vault_deposit_sub: '普段の残高から。登録済みの YubiKey で確認してください。',
|
|
12500
12529
|
vault_withdraw_sub: '普段の残高に戻します。保管庫の鍵のいずれかをかざしてください。',
|
|
12501
12530
|
vault_deposit_done: '保管庫に移動しました',
|
|
12502
12531
|
vault_reclaim_done: '中断された保管庫への入金から資金を回収しました',
|
|
@@ -12864,6 +12893,9 @@ const resources = {
|
|
|
12864
12893
|
display_currency: '表示通貨',
|
|
12865
12894
|
no_pending_payments: '保留中の支払いはありません',
|
|
12866
12895
|
outgoing_payments: '送信済み',
|
|
12896
|
+
review_imported_payment: 'インポートした支払いを確認',
|
|
12897
|
+
review_imported_payment_detail:
|
|
12898
|
+
'この支払いはバックアップから復元されたもので、キャンセル済みの可能性があります。今すぐ {{recipient}} に {{amount}} サトシを送信しますか?',
|
|
12867
12899
|
payment_not_delivered: '未配信',
|
|
12868
12900
|
payment_delivered: '配信済み',
|
|
12869
12901
|
retry: '再試行',
|
|
@@ -13733,7 +13765,7 @@ const resources = {
|
|
|
13733
13765
|
vault_withdraw_cta: 'Wypłać',
|
|
13734
13766
|
vault_deposit_title: 'Wpłać do sejfu',
|
|
13735
13767
|
vault_withdraw_title: 'Wypłać z sejfu',
|
|
13736
|
-
vault_deposit_sub: 'Z Twojego codziennego salda.
|
|
13768
|
+
vault_deposit_sub: 'Z Twojego codziennego salda. Potwierdź zarejestrowanym kluczem YubiKey.',
|
|
13737
13769
|
vault_withdraw_sub: 'Z powrotem na codzienne saldo. Przyłóż dowolny z kluczy sejfu.',
|
|
13738
13770
|
vault_deposit_done: 'Przeniesiono do sejfu',
|
|
13739
13771
|
vault_reclaim_done: 'Środki odzyskane z przerwanej wpłaty do sejfu',
|
|
@@ -14104,6 +14136,9 @@ const resources = {
|
|
|
14104
14136
|
display_currency: 'Waluta wyświetlania',
|
|
14105
14137
|
no_pending_payments: 'Brak oczekujących płatności',
|
|
14106
14138
|
outgoing_payments: 'Wychodzące',
|
|
14139
|
+
review_imported_payment: 'Sprawdź zaimportowaną płatność',
|
|
14140
|
+
review_imported_payment_detail:
|
|
14141
|
+
'Ta płatność pochodzi z kopii zapasowej i mogła zostać anulowana. Wysłać teraz {{amount}} satoshi do {{recipient}}?',
|
|
14107
14142
|
payment_not_delivered: 'Nie dostarczono',
|
|
14108
14143
|
payment_delivered: 'Dostarczono',
|
|
14109
14144
|
retry: 'Ponów',
|
|
@@ -21,9 +21,10 @@ import {
|
|
|
21
21
|
looksLikeDomain
|
|
22
22
|
} from './rules'
|
|
23
23
|
import { verifyProfileCertificate, type ProfileCertJson, type RegistryProfile } from './profileCert'
|
|
24
|
-
import { createRegistryResolver, fetchWithTimeout, type RegistryPin, type RegistryResolver } from './resolver'
|
|
24
|
+
import { createRegistryResolver, fetchWithTimeout, REGISTRY_MAX_BODY_BYTES, type RegistryPin, type RegistryResolver } from './resolver'
|
|
25
25
|
import { createKeyPinStore, type KeyPinStore } from './keyPinStore'
|
|
26
26
|
import { trimTrailingSlashes } from '../../net/trimTrailingSlashes'
|
|
27
|
+
import { createBoundedNativeFetch } from '../../network/boundedFetch'
|
|
27
28
|
|
|
28
29
|
/** Why a handle is not free. The server's `stale` arrives as `cooldown`. */
|
|
29
30
|
export type AvailabilityReason = 'taken' | 'too_similar' | 'reserved' | 'invalid' | 'cooldown'
|
|
@@ -83,12 +84,13 @@ function reasonOf(raw: unknown): AvailabilityReason | null {
|
|
|
83
84
|
|
|
84
85
|
export function createHandleRegistryClient(args: {
|
|
85
86
|
pinned: RegistryPin
|
|
87
|
+
/** Trusted test transport; production must retain the native byte ceiling. */
|
|
86
88
|
fetchImpl?: typeof fetch
|
|
87
89
|
now?: () => number
|
|
88
90
|
resolver?: RegistryResolver
|
|
89
91
|
pinStore?: KeyPinStore
|
|
90
92
|
}): HandleRegistryClient {
|
|
91
|
-
const fetchImpl = args.fetchImpl ?? (
|
|
93
|
+
const fetchImpl = args.fetchImpl ?? createBoundedNativeFetch(REGISTRY_MAX_BODY_BYTES)
|
|
92
94
|
const now = args.now ?? (() => Date.now())
|
|
93
95
|
const domain = args.pinned.domain.trim().toLowerCase()
|
|
94
96
|
const origin = trimTrailingSlashes(args.pinned.url.trim())
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { BRFC_LOOKUP, BRFC_REVERSE_LOOKUP, looksLikeDomain } from './rules'
|
|
15
15
|
import { isPublicHttpsUrl } from '../../net/publicDestination'
|
|
16
16
|
import { trimTrailingSlashes } from '../../net/trimTrailingSlashes'
|
|
17
|
+
import { createBoundedNativeFetch } from '../../network/boundedFetch'
|
|
17
18
|
|
|
18
19
|
/** The domain this build's own handles live under, and the host serving it. */
|
|
19
20
|
export interface RegistryPin {
|
|
@@ -52,16 +53,10 @@ const NOERROR = 0
|
|
|
52
53
|
const NXDOMAIN = 3
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* total crosses the cap — an untrusted host cannot make this allocate more
|
|
60
|
-
* than the cap regardless of what it claims or how it paces the bytes
|
|
61
|
-
* (XR-077 / SEC2-027). `fallback` (the original, unbounded `response.json`)
|
|
62
|
-
* is used only when the runtime gives no stream to count from at all, which
|
|
63
|
-
* this feature's own test doubles do — a floor, not a firewall, on a runtime
|
|
64
|
-
* where nothing better is available.
|
|
56
|
+
* Decode a response already receive-bounded by the production native transport.
|
|
57
|
+
* The streaming check also bounds trusted injected test transports. On native
|
|
58
|
+
* Response implementations without a WHATWG stream, the original JSON reader
|
|
59
|
+
* is safe because accumulation was capped before the Response was returned.
|
|
65
60
|
*/
|
|
66
61
|
async function readBoundedJson(res: Response, fallback: () => Promise<unknown>, url: string): Promise<unknown> {
|
|
67
62
|
const declared = res.headers?.get?.('content-length')
|
|
@@ -209,11 +204,12 @@ function templateOf(value: unknown, placeholder: string): string | null {
|
|
|
209
204
|
|
|
210
205
|
export function createRegistryResolver(args: {
|
|
211
206
|
pinned?: RegistryPin
|
|
207
|
+
/** Trusted test transport; production must retain the native byte ceiling. */
|
|
212
208
|
fetchImpl?: typeof fetch
|
|
213
209
|
now?: () => number
|
|
214
210
|
dohEndpoints?: readonly string[]
|
|
215
211
|
}): RegistryResolver {
|
|
216
|
-
const fetchImpl = args.fetchImpl ?? (
|
|
212
|
+
const fetchImpl = args.fetchImpl ?? createBoundedNativeFetch(REGISTRY_MAX_BODY_BYTES)
|
|
217
213
|
const now = args.now ?? (() => Date.now())
|
|
218
214
|
const dohEndpoints = args.dohEndpoints ?? DOH_ENDPOINTS
|
|
219
215
|
const pinnedDomain = args.pinned?.domain.trim().toLowerCase() ?? ''
|
package/core/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ export {
|
|
|
68
68
|
isVaultAvailable,
|
|
69
69
|
resetToolboxConfig
|
|
70
70
|
} from './toolboxConfig'
|
|
71
|
+
export { isE2eBuild, getE2eBroadcasterUrl, e2eSafeChain } from './e2e/mode'
|
|
71
72
|
export type {
|
|
72
73
|
ToolboxConfig,
|
|
73
74
|
ToolboxServiceConfig,
|
|
@@ -305,6 +306,7 @@ export * from './pay/userError'
|
|
|
305
306
|
export * from './pay/patp'
|
|
306
307
|
export * from './pay/counterparty'
|
|
307
308
|
export * from './pay/rails/address'
|
|
309
|
+
export * from './pay/rails/sweep'
|
|
308
310
|
export * from './pay/rails/handle'
|
|
309
311
|
export * from './pay/rails/direct'
|
|
310
312
|
// nearby.ts is a pure re-export barrel over localpay/* (already exported above)
|
package/core/localpay/pending.ts
CHANGED
|
@@ -67,14 +67,48 @@ const descriptionDecoder = new TextDecoder()
|
|
|
67
67
|
/**
|
|
68
68
|
* Truncates on the UTF-8 byte boundary, not the JS string index — slicing by
|
|
69
69
|
* character count alone can still overshoot the byte ceiling for non-ASCII
|
|
70
|
-
* text.
|
|
71
|
-
* U+FFFD
|
|
72
|
-
* is fine here: this is a display fallback, not the payment amount.
|
|
70
|
+
* text. Drop an incomplete trailing scalar: decoding its partial bytes would
|
|
71
|
+
* insert U+FFFD, whose three bytes can exceed the original byte budget.
|
|
73
72
|
*/
|
|
74
73
|
export function truncateUtf8Bytes(s: string, maxBytes: number): string {
|
|
75
74
|
const bytes = descriptionEncoder.encode(s)
|
|
76
75
|
if (bytes.length <= maxBytes) return s
|
|
77
|
-
|
|
76
|
+
let end = Math.max(0, Math.floor(maxBytes))
|
|
77
|
+
while (end > 0 && (bytes[end] & 0xc0) === 0x80) end--
|
|
78
|
+
return descriptionDecoder.decode(bytes.subarray(0, end))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Repair only exhausted BSV entries affected by the old description truncation. */
|
|
82
|
+
async function repairDescriptionFailures(storage: KVStorage): Promise<void> {
|
|
83
|
+
await withQueueLock(async () => {
|
|
84
|
+
let repaired = false
|
|
85
|
+
const next = (await readAll(storage)).map(p => {
|
|
86
|
+
const reason = p.failureReason ?? ''
|
|
87
|
+
if (
|
|
88
|
+
p.frame.kind !== 'bsv' ||
|
|
89
|
+
!isPendingExhausted(p) ||
|
|
90
|
+
!/description/i.test(reason) ||
|
|
91
|
+
!/2000|byte|length/i.test(reason)
|
|
92
|
+
)
|
|
93
|
+
return p
|
|
94
|
+
const note = p.frame.note?.trim()
|
|
95
|
+
if (!note) return p
|
|
96
|
+
const bytes = descriptionEncoder.encode(note.padEnd(5))
|
|
97
|
+
if (bytes.length <= MAX_INTERNALIZE_DESCRIPTION_BYTES) return p
|
|
98
|
+
const previous = descriptionDecoder.decode(bytes.subarray(0, MAX_INTERNALIZE_DESCRIPTION_BYTES))
|
|
99
|
+
if (descriptionEncoder.encode(previous).length <= MAX_INTERNALIZE_DESCRIPTION_BYTES) return p
|
|
100
|
+
repaired = true
|
|
101
|
+
return {
|
|
102
|
+
...p,
|
|
103
|
+
frame: { ...p.frame, note: truncateUtf8Bytes(note, MAX_INTERNALIZE_DESCRIPTION_BYTES) },
|
|
104
|
+
status: 'pending' as const,
|
|
105
|
+
attempts: 0,
|
|
106
|
+
failureReason: undefined
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
// Persist the normalized note so this migration cannot reset retries again.
|
|
110
|
+
if (repaired) await writeAll(storage, next)
|
|
111
|
+
})
|
|
78
112
|
}
|
|
79
113
|
|
|
80
114
|
export interface PendingSummary {
|
|
@@ -595,6 +629,7 @@ export async function processPending(
|
|
|
595
629
|
*/
|
|
596
630
|
acceptToken?: TokenAcceptHook
|
|
597
631
|
): Promise<{ id: string; success: boolean; error?: string }[]> {
|
|
632
|
+
await repairDescriptionFailures(storage)
|
|
598
633
|
const results: { id: string; success: boolean; error?: string }[] = []
|
|
599
634
|
for (const p of await getRetryable(storage)) {
|
|
600
635
|
await updateStatus(storage, p.id, 'processing')
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Utils } from '@bsv/sdk'
|
|
2
|
+
|
|
3
|
+
interface NativeReply {
|
|
4
|
+
status: number
|
|
5
|
+
headers: [string, string][]
|
|
6
|
+
body: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface BoundedFetchNative {
|
|
10
|
+
request(options: {
|
|
11
|
+
id: string
|
|
12
|
+
url: string
|
|
13
|
+
method: string
|
|
14
|
+
headers: [string, string][]
|
|
15
|
+
body: string | null
|
|
16
|
+
maxBytes: number
|
|
17
|
+
}): Promise<NativeReply>
|
|
18
|
+
cancel(id: string): Promise<void>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let nextRequest = 0
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fetch-shaped transport with an actual native receive ceiling. Both native
|
|
25
|
+
* implementations count decoded bytes before appending, never stream events
|
|
26
|
+
* to an unbounded JS queue, and return at most maxBytes. Missing or dishonest
|
|
27
|
+
* Content-Length cannot bypass the ceiling. Redirects are returned as 3xx:
|
|
28
|
+
* signed backup credentials must never be forwarded to a different endpoint.
|
|
29
|
+
* There is deliberately no fallback to React Native's buffering global fetch.
|
|
30
|
+
*/
|
|
31
|
+
export function createBoundedNativeFetch(maxBytes: number): typeof fetch {
|
|
32
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0 || maxBytes > 64 * 1024 * 1024) {
|
|
33
|
+
throw new RangeError('Invalid native response byte ceiling')
|
|
34
|
+
}
|
|
35
|
+
return async (input, init) => {
|
|
36
|
+
const original = typeof Request !== 'undefined' && input instanceof Request ? input : undefined
|
|
37
|
+
const signal = init?.signal ?? original?.signal
|
|
38
|
+
if (signal?.aborted) throw signal.reason ?? new Error('Request aborted')
|
|
39
|
+
// Loading lazily allows tests and unsupported platforms to import the
|
|
40
|
+
// toolbox. A missing native module fails before any network request.
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
42
|
+
const { requireNativeModule } = require('expo-modules-core') as typeof import('expo-modules-core')
|
|
43
|
+
const native = requireNativeModule<BoundedFetchNative>('BsvBoundedFetch')
|
|
44
|
+
const body = init?.body
|
|
45
|
+
let bytes: Uint8Array | undefined
|
|
46
|
+
if (typeof body === 'string') bytes = new TextEncoder().encode(body)
|
|
47
|
+
else if (body instanceof Uint8Array) bytes = body
|
|
48
|
+
else if (body instanceof ArrayBuffer) bytes = new Uint8Array(body)
|
|
49
|
+
else if (typeof Blob !== 'undefined' && body instanceof Blob) bytes = new Uint8Array(await body.arrayBuffer())
|
|
50
|
+
else if (body != null || original?.body != null) throw new TypeError('Unsupported bounded request body')
|
|
51
|
+
if (signal?.aborted) throw signal.reason ?? new Error('Request aborted')
|
|
52
|
+
const id = String(++nextRequest)
|
|
53
|
+
let rejectAborted!: (reason: unknown) => void
|
|
54
|
+
const aborted = new Promise<never>((_resolve, reject) => { rejectAborted = reject })
|
|
55
|
+
const onAbort = () => {
|
|
56
|
+
rejectAborted(signal?.reason ?? new Error('Request aborted'))
|
|
57
|
+
void native.cancel(id).catch(() => {})
|
|
58
|
+
}
|
|
59
|
+
const headers: [string, string][] = []
|
|
60
|
+
new Headers(init?.headers ?? original?.headers).forEach((value, key) => headers.push([key, value]))
|
|
61
|
+
signal?.addEventListener('abort', onAbort)
|
|
62
|
+
try {
|
|
63
|
+
const reply = await Promise.race([
|
|
64
|
+
native.request({
|
|
65
|
+
id,
|
|
66
|
+
url: original?.url ?? String(input),
|
|
67
|
+
method: init?.method ?? original?.method ?? 'GET',
|
|
68
|
+
headers,
|
|
69
|
+
body: bytes ? encodeBody(bytes) : null,
|
|
70
|
+
maxBytes
|
|
71
|
+
}),
|
|
72
|
+
aborted
|
|
73
|
+
])
|
|
74
|
+
// The native receiver has already enforced the cap, before this decoding
|
|
75
|
+
// or any JSON parsing. The Response readers cannot bypass that boundary.
|
|
76
|
+
const responseBody = Uint8Array.from(atob(reply.body), value => value.charCodeAt(0))
|
|
77
|
+
const response = new Response([204, 205, 304].includes(reply.status) ? null : responseBody, {
|
|
78
|
+
status: reply.status,
|
|
79
|
+
headers: reply.headers
|
|
80
|
+
})
|
|
81
|
+
// RN's whatwg-fetch buffer-to-text reader maps bytes as Latin-1. Decode
|
|
82
|
+
// explicitly, through the original byte reader so bodyUsed/one-shot reads
|
|
83
|
+
// still work and binary backup blobs remain byte-exact.
|
|
84
|
+
response.text = async () => new TextDecoder().decode(await response.arrayBuffer())
|
|
85
|
+
response.json = async () => JSON.parse(await response.text())
|
|
86
|
+
return response
|
|
87
|
+
} finally {
|
|
88
|
+
signal?.removeEventListener('abort', onAbort)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Keep SDK number[] conversion bounded for large backup uploads. All complete
|
|
94
|
+
// base64 chunks are multiples of three bytes so concatenation preserves bytes.
|
|
95
|
+
function encodeBody(bytes: Uint8Array): string {
|
|
96
|
+
const chunks: string[] = []
|
|
97
|
+
for (let offset = 0; offset < bytes.length; offset += 24_576) {
|
|
98
|
+
chunks.push(Utils.toBase64(Array.from(bytes.subarray(offset, offset + 24_576))))
|
|
99
|
+
}
|
|
100
|
+
return chunks.join('')
|
|
101
|
+
}
|