@onekeyfe/react-native-get-random-values 1.1.22 → 1.1.23

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.
@@ -10,6 +10,10 @@ class ReactNativeGetRandomValues : HybridReactNativeGetRandomValuesSpec() {
10
10
  }
11
11
 
12
12
  override fun getRandomBase64(byteLength: Double): String {
13
+ if (byteLength.isNaN() || byteLength.isInfinite() || byteLength != kotlin.math.floor(byteLength)) {
14
+ OneKeyLog.warn("RandomValues", "byteLength must be an integer value, got: $byteLength")
15
+ throw IllegalArgumentException("byteLength must be an integer value")
16
+ }
13
17
  val length = byteLength.toInt()
14
18
  if (length <= 0 || length > MAX_BYTE_LENGTH) {
15
19
  OneKeyLog.warn("RandomValues", "Invalid byteLength: $byteLength, must be 1..$MAX_BYTE_LENGTH")
@@ -5,6 +5,11 @@ class ReactNativeGetRandomValues: HybridReactNativeGetRandomValuesSpec {
5
5
  private static let maxByteLength = 65536 // 64 KB upper bound
6
6
 
7
7
  func getRandomBase64(byteLength: Double) throws -> String {
8
+ guard byteLength.rounded() == byteLength, !byteLength.isNaN, !byteLength.isInfinite else {
9
+ OneKeyLog.warn("RandomValues", "byteLength must be an integer value, got: \(byteLength)")
10
+ throw NSError(domain: "ReactNativeGetRandomValues", code: -1,
11
+ userInfo: [NSLocalizedDescriptionKey: "byteLength must be an integer value"])
12
+ }
8
13
  let length = Int(byteLength)
9
14
  guard length > 0, length <= ReactNativeGetRandomValues.maxByteLength,
10
15
  let data = NSMutableData(length: length) else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-get-random-values",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "description": "react-native-get-random-values",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
package/README.md DELETED
@@ -1,36 +0,0 @@
1
- # react-native-get-random-values
2
-
3
- react-native-get-random-values
4
-
5
- ## Installation
6
-
7
- ```sh
8
- npm install react-native-get-random-values react-native-nitro-modules
9
-
10
- > `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
11
- ```
12
-
13
- ## Usage
14
-
15
- ```js
16
- import { ReactNativeGetRandomValues } from 'react-native-get-random-values';
17
-
18
- // ...
19
-
20
- const result = await ReactNativeGetRandomValues.hello({ message: 'World' });
21
- console.log(result); // { success: true, data: 'Hello, World!' }
22
- ```
23
-
24
- ## Contributing
25
-
26
- - [Development workflow](CONTRIBUTING.md#development-workflow)
27
- - [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
28
- - [Code of conduct](CODE_OF_CONDUCT.md)
29
-
30
- ## License
31
-
32
- MIT
33
-
34
- ---
35
-
36
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)