From 66c6107dccfe35b799999edbc571bb948a6e85ce Mon Sep 17 00:00:00 2001 From: jagadishkamathk <30925665+jagadishkamathk@users.noreply.github.com> Date: Fri, 17 Dec 2021 20:11:47 +0530 Subject: [PATCH 1/3] Fixes string converted date and buffer --- utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.js b/utils.js index 757accc..b96c43f 100644 --- a/utils.js +++ b/utils.js @@ -173,6 +173,9 @@ function camelify(str) { } function formatDate(date) { + if (typeof date === "string") { + date = new Date(date); + } const YYYY = date.getUTCFullYear(); const MM = ('0' + (date.getUTCMonth() + 1)).slice(-2); const DD = ('0' + date.getUTCDate()).slice(-2); From aad552bb58123a5b97c7b00c17cc29584561e4b3 Mon Sep 17 00:00:00 2001 From: jagadishkamathk <30925665+jagadishkamathk@users.noreply.github.com> Date: Fri, 17 Dec 2021 20:15:42 +0530 Subject: [PATCH 2/3] Fixed buffer converted to string --- utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.js b/utils.js index b96c43f..2cb30ec 100644 --- a/utils.js +++ b/utils.js @@ -75,6 +75,9 @@ function hexToByteSequence(str) { } function byteSequenceToHex(sequence, start = 0, end = sequence.length) { + if (typeof sequence === "string") { + sequence = Buffer.from(sequence); + } if (end <= start) { THROW(new Error(`end must be larger than start : start=${start}, end=${end}`)); } From 3c51878f957d2cfb47f4e8e8ef37e70077ec8a52 Mon Sep 17 00:00:00 2001 From: jagadishkamathk <30925665+jagadishkamathk@users.noreply.github.com> Date: Sat, 18 Dec 2021 13:44:37 +0530 Subject: [PATCH 3/3] Correct IV handling --- utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index 2cb30ec..015de5b 100644 --- a/utils.js +++ b/utils.js @@ -75,8 +75,9 @@ function hexToByteSequence(str) { } function byteSequenceToHex(sequence, start = 0, end = sequence.length) { - if (typeof sequence === "string") { + if (sequence instanceof Buffer === false) { sequence = Buffer.from(sequence); + end = sequence.length; } if (end <= start) { THROW(new Error(`end must be larger than start : start=${start}, end=${end}`));