@bsv/expo-wallet-toolbox 0.24.0 → 0.24.1
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 +14 -0
- package/ios/BsvBoundedFetchModule.swift +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.24.1
|
|
6
|
+
|
|
7
|
+
One fix: the iOS native fetch. Hosts must rebuild their native apps.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **iOS: `BsvBoundedFetch` refused every request** with `ERR_INVALID_REQUEST`
|
|
12
|
+
("Invalid bounded HTTPS request"). The module read `maxBytes` from an untyped
|
|
13
|
+
dictionary with `as? Int`; over JSI the value is a Swift `Double`, and that
|
|
14
|
+
cast is always nil. Backup, handle registry and trust-list requests all go
|
|
15
|
+
through this module, so none of them worked on iOS in 0.24.0. The value is
|
|
16
|
+
now read as a whole number from either representation. Android was not
|
|
17
|
+
affected (it uses a typed record).
|
|
18
|
+
|
|
5
19
|
## 0.24.0
|
|
6
20
|
|
|
7
21
|
BSV Broadcaster as the broadcast path (#97), sweep of external keys (#93), the
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import Foundation
|
|
3
3
|
|
|
4
|
+
/// A JS number in an untyped dictionary arrives as a Swift `Double` over JSI
|
|
5
|
+
/// and as an `NSNumber` over the old bridge. `Double as? Int` is always nil, so
|
|
6
|
+
/// a plain cast refused every request on the JSI path. Whole, finite values in
|
|
7
|
+
/// the JS safe-integer range are accepted; anything else is not a byte count.
|
|
8
|
+
private func wholeNumber(_ value: Any?) -> Int? {
|
|
9
|
+
if let int = value as? Int { return int }
|
|
10
|
+
if let double = value as? Double, double.isFinite, double == double.rounded(),
|
|
11
|
+
abs(double) <= 9_007_199_254_740_991 {
|
|
12
|
+
return Int(double)
|
|
13
|
+
}
|
|
14
|
+
return nil
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
public final class BsvBoundedFetchModule: Module {
|
|
5
18
|
private let lock = NSLock()
|
|
6
19
|
private var requests: [String: BoundedRequest] = [:]
|
|
@@ -12,7 +25,7 @@ public final class BsvBoundedFetchModule: Module {
|
|
|
12
25
|
guard let id = options["id"] as? String,
|
|
13
26
|
let address = options["url"] as? String,
|
|
14
27
|
let url = URL(string: address), url.scheme == "https",
|
|
15
|
-
let limit = options["maxBytes"]
|
|
28
|
+
let limit = wholeNumber(options["maxBytes"]), (0...67108864).contains(limit) else {
|
|
16
29
|
promise.reject("ERR_INVALID_REQUEST", "Invalid bounded HTTPS request")
|
|
17
30
|
return
|
|
18
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/expo-wallet-toolbox",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|