Skip to content

Commit

Permalink
Fix mixedToUint8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
CMEONE committed Jun 23, 2021
1 parent 4162b6d commit fde66c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion node/tenvoy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {

Object.defineProperty(this, "version", {
get: () => {
return "v7.0.6";
return "v7.0.7";
}
});

Expand Down Expand Up @@ -205,6 +205,21 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {
if(mixed == null) {
throw "tEnvoy Fatal Error: argument mixed of method util.mixedToUint8Array is required and does not have a default value.";
}
let isObjectArray = true;
if(typeof mixed == "object" && mixed.constructor == Object) {
let keys = Object.keys(mixed);
let returnUint8Array = new Uint8Array(keys.length);
for(let i = 0; i < keys.length && isObjectArray; i++) {
if(keys[i] != i || !Number.isInteger(mixed[keys[i]]) || mixed[keys[i]] < 0 || mixed[keys[i]] > 255) {
isObjectArray = false;
} else {
returnUint8Array[i] = mixed[keys[i]];
}
}
if(isObjectArray) {
return returnUint8Array;
}
}
if(mixed instanceof Uint8Array) {
if(includeType) {
let returnUint8Array = new Uint8Array(mixed.length + 1);
Expand Down
17 changes: 16 additions & 1 deletion tenvoy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46033,7 +46033,7 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {

Object.defineProperty(this, "version", {
get: () => {
return "v7.0.6";
return "v7.0.7";
}
});

Expand Down Expand Up @@ -46222,6 +46222,21 @@ function tEnvoy(openpgpRef = openpgp, naclRef = nacl, sha256Ref = sha256) {
if(mixed == null) {
throw "tEnvoy Fatal Error: argument mixed of method util.mixedToUint8Array is required and does not have a default value.";
}
let isObjectArray = true;
if(typeof mixed == "object" && mixed.constructor == Object) {
let keys = Object.keys(mixed);
let returnUint8Array = new Uint8Array(keys.length);
for(let i = 0; i < keys.length && isObjectArray; i++) {
if(keys[i] != i || !Number.isInteger(mixed[keys[i]]) || mixed[keys[i]] < 0 || mixed[keys[i]] > 255) {
isObjectArray = false;
} else {
returnUint8Array[i] = mixed[keys[i]];
}
}
if(isObjectArray) {
return returnUint8Array;
}
}
if(mixed instanceof Uint8Array) {
if(includeType) {
let returnUint8Array = new Uint8Array(mixed.length + 1);
Expand Down

0 comments on commit fde66c8

Please sign in to comment.