@hivedev/hivesdk 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hive-client.js +1 -1
- package/hive-server.cjs +11 -6
- package/hive-server.js +11 -6
- package/package.json +1 -1
package/hive-client.js
CHANGED
package/hive-server.cjs
CHANGED
|
@@ -238,10 +238,10 @@ var import_fs = require("fs");
|
|
|
238
238
|
|
|
239
239
|
// Server/Utility/DecryptDataWithPassword.js
|
|
240
240
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
241
|
-
async function decryptDataWithPassword(data, password) {
|
|
241
|
+
async function decryptDataWithPassword(data, password, salt = "hive_salt") {
|
|
242
242
|
const iv = data.subarray(0, 16);
|
|
243
243
|
const encrypted = data.subarray(16);
|
|
244
|
-
const key = import_crypto.default.scryptSync(password,
|
|
244
|
+
const key = import_crypto.default.scryptSync(password, salt, 32);
|
|
245
245
|
const decipher = import_crypto.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
246
246
|
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
247
247
|
return decrypted.toString("utf8");
|
|
@@ -448,8 +448,8 @@ var import_path3 = __toESM(require("path"), 1);
|
|
|
448
448
|
|
|
449
449
|
// Server/Utility/EncryptDataWithPassword.js
|
|
450
450
|
var import_crypto2 = __toESM(require("crypto"), 1);
|
|
451
|
-
async function encryptDataWithPassword(data, password) {
|
|
452
|
-
const key = import_crypto2.default.scryptSync(password,
|
|
451
|
+
async function encryptDataWithPassword(data, password, salt = "hive_salt") {
|
|
452
|
+
const key = import_crypto2.default.scryptSync(password, salt, 32);
|
|
453
453
|
const iv = import_crypto2.default.randomBytes(16);
|
|
454
454
|
const cipher = import_crypto2.default.createCipheriv("aes-256-cbc", key, iv);
|
|
455
455
|
const encrypted = Buffer.concat([cipher.update(data, "utf8"), cipher.final()]);
|
|
@@ -554,13 +554,18 @@ async function setupPassword() {
|
|
|
554
554
|
|
|
555
555
|
// Server/InitServer.js
|
|
556
556
|
var bInitialized = false;
|
|
557
|
-
async function initServer({ serviceName, servicePort, remoteUrl }) {
|
|
557
|
+
async function initServer({ serviceName, servicePort, remoteUrl, serverPassword }) {
|
|
558
558
|
if (bInitialized) {
|
|
559
559
|
console.warn("Server already initialized! Skipping...");
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
+
if (!serverPassword) {
|
|
563
|
+
serverPassword = process.env.SERVER_PASSWORD;
|
|
564
|
+
if (!serverPassword) {
|
|
565
|
+
serverPassword = await HiveServerGlobals_default.setupPassword();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
562
568
|
HiveServerGlobals_default.initialize({ serviceName, servicePort, remoteUrl });
|
|
563
|
-
await setupPassword();
|
|
564
569
|
bInitialized = true;
|
|
565
570
|
}
|
|
566
571
|
|
package/hive-server.js
CHANGED
|
@@ -214,10 +214,10 @@ import { promises as fs } from "fs";
|
|
|
214
214
|
|
|
215
215
|
// Server/Utility/DecryptDataWithPassword.js
|
|
216
216
|
import crypto from "crypto";
|
|
217
|
-
async function decryptDataWithPassword(data, password) {
|
|
217
|
+
async function decryptDataWithPassword(data, password, salt = "hive_salt") {
|
|
218
218
|
const iv = data.subarray(0, 16);
|
|
219
219
|
const encrypted = data.subarray(16);
|
|
220
|
-
const key = crypto.scryptSync(password,
|
|
220
|
+
const key = crypto.scryptSync(password, salt, 32);
|
|
221
221
|
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
222
222
|
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
223
223
|
return decrypted.toString("utf8");
|
|
@@ -424,8 +424,8 @@ import path3 from "path";
|
|
|
424
424
|
|
|
425
425
|
// Server/Utility/EncryptDataWithPassword.js
|
|
426
426
|
import crypto2 from "crypto";
|
|
427
|
-
async function encryptDataWithPassword(data, password) {
|
|
428
|
-
const key = crypto2.scryptSync(password,
|
|
427
|
+
async function encryptDataWithPassword(data, password, salt = "hive_salt") {
|
|
428
|
+
const key = crypto2.scryptSync(password, salt, 32);
|
|
429
429
|
const iv = crypto2.randomBytes(16);
|
|
430
430
|
const cipher = crypto2.createCipheriv("aes-256-cbc", key, iv);
|
|
431
431
|
const encrypted = Buffer.concat([cipher.update(data, "utf8"), cipher.final()]);
|
|
@@ -530,13 +530,18 @@ async function setupPassword() {
|
|
|
530
530
|
|
|
531
531
|
// Server/InitServer.js
|
|
532
532
|
var bInitialized = false;
|
|
533
|
-
async function initServer({ serviceName, servicePort, remoteUrl }) {
|
|
533
|
+
async function initServer({ serviceName, servicePort, remoteUrl, serverPassword }) {
|
|
534
534
|
if (bInitialized) {
|
|
535
535
|
console.warn("Server already initialized! Skipping...");
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
538
|
+
if (!serverPassword) {
|
|
539
|
+
serverPassword = process.env.SERVER_PASSWORD;
|
|
540
|
+
if (!serverPassword) {
|
|
541
|
+
serverPassword = await HiveServerGlobals_default.setupPassword();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
538
544
|
HiveServerGlobals_default.initialize({ serviceName, servicePort, remoteUrl });
|
|
539
|
-
await setupPassword();
|
|
540
545
|
bInitialized = true;
|
|
541
546
|
}
|
|
542
547
|
|