From 20681d865953c6463d039fd4bbea9bc09abf3ffc Mon Sep 17 00:00:00 2001 From: CMEONE Date: Wed, 23 Jun 2021 08:58:55 -0700 Subject: [PATCH] Fix uint8ArrayToMixed --- node/tenvoy.js | 11 +++++++++++ package.json | 2 +- tenvoy.js | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/node/tenvoy.js b/node/tenvoy.js index abe921c1..4cc880e3 100644 --- a/node/tenvoy.js +++ b/node/tenvoy.js @@ -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; diff --git a/package.json b/package.json index d4a04fd5..42cec82f 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tenvoy.js b/tenvoy.js index 9bbb1946..19be8cae 100644 --- a/tenvoy.js +++ b/tenvoy.js @@ -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;