Skip to content

Commit 270544f

Browse files
committed
perf: add encrypt parameter type checks , to convert numbers as strings
convert fatal error to warning in pushNewJob method
1 parent d7a6e80 commit 270544f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Crypt.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ class Crypt {
88
}
99

1010
encrypt(text) {
11+
let textToEncrypt = text;
1112
try {
13+
if (typeof textToEncrypt === 'number')
14+
textToEncrypt = textToEncrypt.toString();
1215
const cipher = crypto.createCipheriv(
1316
'aes-256-cbc',
1417
Buffer.from(this.getKey()),
1518
this.getIv()
1619
);
17-
let encrypted = cipher.update(text);
20+
let encrypted = cipher.update(textToEncrypt);
1821
encrypted = Buffer.concat([encrypted, cipher.final()]);
1922
return {
2023
iv: this.getIv().toString('hex'),

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class Master {
163163
async pushNewJob(payload) {
164164
return new Promise((resolve, reject) => {
165165
if (typeof payload === 'undefined') {
166-
this.log.fatal('pushNewJob:', 'payload is undefined');
166+
this.log.warn('pushNewJob:', 'payload is undefined');
167167
reject(Error('payload is undefined'));
168168
}
169169
let payloadJson = payload;

0 commit comments

Comments
 (0)