From bd13efb581ae8c0fbf4a39c3ebad5ffc51d6298d Mon Sep 17 00:00:00 2001 From: David Angulo Date: Wed, 10 Aug 2022 21:06:36 +0800 Subject: [PATCH] chore: use global bytelength variable --- CHANGELOGS.md | 3 +++ cpp/random-bytes.cpp | 3 ++- package.json | 5 +++-- src/generate-random-bytes.native.ts | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 527cd43..be4d941 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -1,5 +1,8 @@ # Changelogs +## 5.1.0 (2022-08-10) +* Used global bytelength variable. + ## 5.0.1 (2022-08-10) * Removed extra files published to npm. diff --git a/cpp/random-bytes.cpp b/cpp/random-bytes.cpp index bb94e6b..f2ece7e 100644 --- a/cpp/random-bytes.cpp +++ b/cpp/random-bytes.cpp @@ -20,7 +20,8 @@ namespace randombytes const Value *arguments, size_t count) -> Value { - vector buffer(96, 0); + int byteLength = arguments[0].getNumber(); + vector buffer(byteLength, 0); arc4random_buf(&buffer[0], buffer.size()); diff --git a/package.json b/package.json index 22db7bf..25ce4a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-pkce-challenge", - "version": "5.0.2", + "version": "5.1.0", "description": "Proof Key for Code Exchange (PKCE) challenge generator for React Native", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -31,7 +31,8 @@ "react-native-macos", "PKCE", "oauth2", - "jsi" + "jsi", + "c++" ], "repository": { "type": "git", diff --git a/src/generate-random-bytes.native.ts b/src/generate-random-bytes.native.ts index 9edf0ab..31db1d6 100644 --- a/src/generate-random-bytes.native.ts +++ b/src/generate-random-bytes.native.ts @@ -17,7 +17,7 @@ export default function generateRandomBytes(): string { } if ((global as any).RNPkceChallenge) { - const bytes = (global as any).RNPkceChallenge.randomBytes(); + const bytes = (global as any).RNPkceChallenge.randomBytes(BYTE_LENGTH); return bytes; }