Skip to content

Commit

Permalink
Fix uint8ArrayToMixed
Browse files Browse the repository at this point in the history
  • Loading branch information
CMEONE committed Jun 23, 2021
1 parent c5beb93 commit 20681d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions node/tenvoy.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {
if(uint8Array == null) {
return null;
}
if(typeof uint8Array == "object" && uint8Array.constructor == Object) {
let keys = Object.keys(uint8Array);
let newUint8Array = new Uint8Array(keys.length);
for(let i = 0; i < keys.length; i++) {
if(keys[i] != i || !Number.isInteger(uint8Array[keys[i]]) || uint8Array[keys[i]] < 0 || uint8Array[keys[i]] > 255) {
return null;
}
newUint8Array[i] = uint8Array[keys[i]];
}
uint8Array = newUint8Array;
}
if(includeType) {
let paddingOver = false;
let startIndex = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tenvoy",
"version": "7.0.5",
"description": "PGP, NaCl, and PBKDF2 in node.js and the browser (hashing, random, encryption, decryption, signatures, conversions), used by TogaTech.org",
"main": "./node/tenvoy.min.js",
"main": "./node/tenvoy.js",
"browser": {
"./node/tenvoy.js": "./tenvoy.js",
"./node/tenvoy.min.js": "./tenvoy.min.js"
Expand Down
11 changes: 11 additions & 0 deletions tenvoy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46382,6 +46382,17 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {
if(uint8Array == null) {
return null;
}
if(typeof uint8Array == "object" && uint8Array.constructor == Object) {
let keys = Object.keys(uint8Array);
let newUint8Array = new Uint8Array(keys.length);
for(let i = 0; i < keys.length; i++) {
if(keys[i] != i || !Number.isInteger(uint8Array[keys[i]]) || uint8Array[keys[i]] < 0 || uint8Array[keys[i]] > 255) {
return null;
}
newUint8Array[i] = uint8Array[keys[i]];
}
uint8Array = newUint8Array;
}
if(includeType) {
let paddingOver = false;
let startIndex = 0;
Expand Down

0 comments on commit 20681d8

Please sign in to comment.