cryptpad-server 0.0.1 → 0.0.2
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/build/core.js +60 -51
- package/build/core.worker.js +53 -44
- package/build/front.js +60 -51
- package/build/http.js +60 -51
- package/build/http.worker.js +1 -1
- package/build/storage.cluster.js +54 -45
- package/build/storage.js +60 -51
- package/build/storage.worker.js +54 -45
- package/build/websocket.js +35556 -0
- package/build/ws.worker.js +46222 -0
- package/index.js +3 -2
- package/package.json +1 -1
- package/readme.md +41 -44
package/build/storage.cluster.js
CHANGED
|
@@ -2528,60 +2528,69 @@ var hasRequiredCrypto;
|
|
|
2528
2528
|
function requireCrypto() {
|
|
2529
2529
|
if (hasRequiredCrypto) return crypto;
|
|
2530
2530
|
hasRequiredCrypto = 1;
|
|
2531
|
-
|
|
2532
|
-
let
|
|
2533
|
-
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
2534
|
-
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
2535
|
-
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
2536
|
-
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
2531
|
+
const loadSodium = cryptoLib => {
|
|
2532
|
+
let sodiumLib = {};
|
|
2537
2533
|
let SodiumNative, NaCl;
|
|
2538
2534
|
switch (cryptoLib) {
|
|
2539
2535
|
case "sodiumnative":
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
};
|
|
2549
|
-
exports.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
2550
|
-
exports.secretbox = (message, nonce, secretKey) => {
|
|
2551
|
-
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
2552
|
-
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
2553
|
-
return secretBox;
|
|
2554
|
-
};
|
|
2555
|
-
exports.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
2556
|
-
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
2557
|
-
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
2536
|
+
try {
|
|
2537
|
+
SodiumNative = require("sodium-native");
|
|
2538
|
+
sodiumLib.sigVerify = (signedMessage, validateKey) => {
|
|
2539
|
+
let msg = signedMessage.subarray(64);
|
|
2540
|
+
let ok = SodiumNative.crypto_sign_open(msg, signedMessage, validateKey);
|
|
2541
|
+
if (!ok) {
|
|
2542
|
+
return false;
|
|
2543
|
+
}
|
|
2558
2544
|
return msg;
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2545
|
+
};
|
|
2546
|
+
sodiumLib.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
2547
|
+
sodiumLib.secretbox = (message, nonce, secretKey) => {
|
|
2548
|
+
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
2549
|
+
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
2550
|
+
return secretBox;
|
|
2551
|
+
};
|
|
2552
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
2553
|
+
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
2554
|
+
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
2555
|
+
return msg;
|
|
2556
|
+
} else {
|
|
2557
|
+
return void 0;
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => {
|
|
2561
|
+
let pk = new Uint8Array(SodiumNative.crypto_sign_PUBLICKEYBYTES);
|
|
2562
|
+
SodiumNative.crypto_sign_ed25519_sk_to_pk(pk, secretKey);
|
|
2563
|
+
return pk;
|
|
2564
|
+
};
|
|
2565
|
+
sodiumLib.hash = message => {
|
|
2566
|
+
let out = Buffer.alloc(SodiumNative.crypto_hash_sha512_BYTES);
|
|
2567
|
+
SodiumNative.crypto_hash_sha512(out, message);
|
|
2568
|
+
return out;
|
|
2569
|
+
};
|
|
2570
|
+
} catch (err) {
|
|
2571
|
+
console.error("Error in loading sodium-native: fallback on tweetnacl");
|
|
2572
|
+
return loadSodium("");
|
|
2573
|
+
}
|
|
2573
2574
|
break;
|
|
2574
2575
|
|
|
2575
2576
|
default:
|
|
2576
2577
|
NaCl = require$$0$2;
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2578
|
+
sodiumLib.sigVerify = NaCl.sign.open;
|
|
2579
|
+
sodiumLib.detachedVerify = NaCl.sign.detached.verify;
|
|
2580
|
+
sodiumLib.secretbox = NaCl.secretbox;
|
|
2581
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => Buffer.from(NaCl.secretbox.open(secretBox, nonce, secretKey));
|
|
2582
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => NaCl.sign?.keyPair?.fromSecretKey(secretKey)?.publicKey;
|
|
2583
|
+
sodiumLib.hash = msg => Buffer.from(NaCl.hash(msg));
|
|
2583
2584
|
break;
|
|
2584
2585
|
}
|
|
2586
|
+
return sodiumLib;
|
|
2587
|
+
};
|
|
2588
|
+
crypto = cryptoLib => {
|
|
2589
|
+
const exports = loadSodium(cryptoLib);
|
|
2590
|
+
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
2591
|
+
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
2592
|
+
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
2593
|
+
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
2585
2594
|
return exports;
|
|
2586
2595
|
};
|
|
2587
2596
|
return crypto;
|
|
@@ -2853,7 +2862,7 @@ function requireMfa() {
|
|
|
2853
2862
|
return mfa.exports;
|
|
2854
2863
|
}
|
|
2855
2864
|
|
|
2856
|
-
var version = "0.0.
|
|
2865
|
+
var version = "0.0.2";
|
|
2857
2866
|
|
|
2858
2867
|
var require$$2 = {
|
|
2859
2868
|
version
|
package/build/storage.js
CHANGED
|
@@ -5926,60 +5926,69 @@ var hasRequiredCrypto;
|
|
|
5926
5926
|
function requireCrypto() {
|
|
5927
5927
|
if (hasRequiredCrypto) return crypto;
|
|
5928
5928
|
hasRequiredCrypto = 1;
|
|
5929
|
-
|
|
5930
|
-
let
|
|
5931
|
-
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
5932
|
-
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
5933
|
-
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
5934
|
-
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
5929
|
+
const loadSodium = cryptoLib => {
|
|
5930
|
+
let sodiumLib = {};
|
|
5935
5931
|
let SodiumNative, NaCl;
|
|
5936
5932
|
switch (cryptoLib) {
|
|
5937
5933
|
case "sodiumnative":
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
};
|
|
5947
|
-
exports.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
5948
|
-
exports.secretbox = (message, nonce, secretKey) => {
|
|
5949
|
-
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
5950
|
-
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
5951
|
-
return secretBox;
|
|
5952
|
-
};
|
|
5953
|
-
exports.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
5954
|
-
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
5955
|
-
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
5934
|
+
try {
|
|
5935
|
+
SodiumNative = require("sodium-native");
|
|
5936
|
+
sodiumLib.sigVerify = (signedMessage, validateKey) => {
|
|
5937
|
+
let msg = signedMessage.subarray(64);
|
|
5938
|
+
let ok = SodiumNative.crypto_sign_open(msg, signedMessage, validateKey);
|
|
5939
|
+
if (!ok) {
|
|
5940
|
+
return false;
|
|
5941
|
+
}
|
|
5956
5942
|
return msg;
|
|
5957
|
-
}
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5943
|
+
};
|
|
5944
|
+
sodiumLib.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
5945
|
+
sodiumLib.secretbox = (message, nonce, secretKey) => {
|
|
5946
|
+
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
5947
|
+
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
5948
|
+
return secretBox;
|
|
5949
|
+
};
|
|
5950
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
5951
|
+
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
5952
|
+
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
5953
|
+
return msg;
|
|
5954
|
+
} else {
|
|
5955
|
+
return void 0;
|
|
5956
|
+
}
|
|
5957
|
+
};
|
|
5958
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => {
|
|
5959
|
+
let pk = new Uint8Array(SodiumNative.crypto_sign_PUBLICKEYBYTES);
|
|
5960
|
+
SodiumNative.crypto_sign_ed25519_sk_to_pk(pk, secretKey);
|
|
5961
|
+
return pk;
|
|
5962
|
+
};
|
|
5963
|
+
sodiumLib.hash = message => {
|
|
5964
|
+
let out = Buffer.alloc(SodiumNative.crypto_hash_sha512_BYTES);
|
|
5965
|
+
SodiumNative.crypto_hash_sha512(out, message);
|
|
5966
|
+
return out;
|
|
5967
|
+
};
|
|
5968
|
+
} catch (err) {
|
|
5969
|
+
console.error("Error in loading sodium-native: fallback on tweetnacl");
|
|
5970
|
+
return loadSodium("");
|
|
5971
|
+
}
|
|
5971
5972
|
break;
|
|
5972
5973
|
|
|
5973
5974
|
default:
|
|
5974
5975
|
NaCl = require$$6;
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5976
|
+
sodiumLib.sigVerify = NaCl.sign.open;
|
|
5977
|
+
sodiumLib.detachedVerify = NaCl.sign.detached.verify;
|
|
5978
|
+
sodiumLib.secretbox = NaCl.secretbox;
|
|
5979
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => Buffer.from(NaCl.secretbox.open(secretBox, nonce, secretKey));
|
|
5980
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => NaCl.sign?.keyPair?.fromSecretKey(secretKey)?.publicKey;
|
|
5981
|
+
sodiumLib.hash = msg => Buffer.from(NaCl.hash(msg));
|
|
5981
5982
|
break;
|
|
5982
5983
|
}
|
|
5984
|
+
return sodiumLib;
|
|
5985
|
+
};
|
|
5986
|
+
crypto = cryptoLib => {
|
|
5987
|
+
const exports = loadSodium(cryptoLib);
|
|
5988
|
+
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
5989
|
+
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
5990
|
+
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
5991
|
+
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
5983
5992
|
return exports;
|
|
5984
5993
|
};
|
|
5985
5994
|
return crypto;
|
|
@@ -6667,7 +6676,7 @@ function requireMfaManager() {
|
|
|
6667
6676
|
return mfaManager;
|
|
6668
6677
|
}
|
|
6669
6678
|
|
|
6670
|
-
var version = "0.0.
|
|
6679
|
+
var version = "0.0.2";
|
|
6671
6680
|
|
|
6672
6681
|
var require$$2 = {
|
|
6673
6682
|
version
|
|
@@ -7485,13 +7494,13 @@ function require_interface() {
|
|
|
7485
7494
|
return;
|
|
7486
7495
|
}
|
|
7487
7496
|
const {type: rcvType, idx, challenge: challengeBase64, nonce: nonceBase64} = data;
|
|
7488
|
-
const challenge = new Uint8Array(
|
|
7489
|
-
const nonce = new Uint8Array(
|
|
7497
|
+
const challenge = new Uint8Array(Crypto.decodeBase64(challengeBase64));
|
|
7498
|
+
const nonce = new Uint8Array(Crypto.decodeBase64(nonceBase64));
|
|
7490
7499
|
if (ctx.ChallengesCache[challengeBase64]) {
|
|
7491
7500
|
other.disconnect();
|
|
7492
7501
|
return ctx.Log.error("INTERFACE_CHALLENGE_ERROR", "Reused challenge");
|
|
7493
7502
|
}
|
|
7494
|
-
const msg =
|
|
7503
|
+
const msg = Crypto.secretboxOpen(challenge, nonce, ctx.nodes_key);
|
|
7495
7504
|
if (!msg) {
|
|
7496
7505
|
other.disconnect();
|
|
7497
7506
|
return ctx.Log.error("INTERFACE_CHALLENGE_ERROR", "Bad challenge answer");
|
|
@@ -7566,13 +7575,13 @@ function require_interface() {
|
|
|
7566
7575
|
let uid = Util.guid(ctx.pendingConnections);
|
|
7567
7576
|
ctx.pendingConnections[uid] = coreId;
|
|
7568
7577
|
const nonce = NodeCrypto.randomBytes(24);
|
|
7569
|
-
const msg =
|
|
7570
|
-
const challenge = Crypto.secretbox(msg, nonce, ctx.nodes_key)
|
|
7578
|
+
const msg = Crypto.decodeUTF8(`${ctx.myType}:${ctx.myNumber}:${String(Date.now())}`);
|
|
7579
|
+
const challenge = Crypto.encodeBase64(Crypto.secretbox(msg, nonce, ctx.nodes_key));
|
|
7571
7580
|
createHandlers(ctx, other);
|
|
7572
7581
|
other.send([ uid, "IDENTITY", {
|
|
7573
7582
|
type: ctx.myType,
|
|
7574
7583
|
idx: ctx.myNumber,
|
|
7575
|
-
nonce:
|
|
7584
|
+
nonce: Crypto.encodeBase64(nonce),
|
|
7576
7585
|
challenge
|
|
7577
7586
|
} ]);
|
|
7578
7587
|
};
|
package/build/storage.worker.js
CHANGED
|
@@ -4733,7 +4733,7 @@ function requireTasks() {
|
|
|
4733
4733
|
return tasks.exports;
|
|
4734
4734
|
}
|
|
4735
4735
|
|
|
4736
|
-
var version = "0.0.
|
|
4736
|
+
var version = "0.0.2";
|
|
4737
4737
|
|
|
4738
4738
|
var require$$2 = {
|
|
4739
4739
|
version
|
|
@@ -5512,60 +5512,69 @@ var hasRequiredCrypto;
|
|
|
5512
5512
|
function requireCrypto() {
|
|
5513
5513
|
if (hasRequiredCrypto) return crypto;
|
|
5514
5514
|
hasRequiredCrypto = 1;
|
|
5515
|
-
|
|
5516
|
-
let
|
|
5517
|
-
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
5518
|
-
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
5519
|
-
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
5520
|
-
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
5515
|
+
const loadSodium = cryptoLib => {
|
|
5516
|
+
let sodiumLib = {};
|
|
5521
5517
|
let SodiumNative, NaCl;
|
|
5522
5518
|
switch (cryptoLib) {
|
|
5523
5519
|
case "sodiumnative":
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
};
|
|
5533
|
-
exports.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
5534
|
-
exports.secretbox = (message, nonce, secretKey) => {
|
|
5535
|
-
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
5536
|
-
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
5537
|
-
return secretBox;
|
|
5538
|
-
};
|
|
5539
|
-
exports.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
5540
|
-
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
5541
|
-
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
5520
|
+
try {
|
|
5521
|
+
SodiumNative = require("sodium-native");
|
|
5522
|
+
sodiumLib.sigVerify = (signedMessage, validateKey) => {
|
|
5523
|
+
let msg = signedMessage.subarray(64);
|
|
5524
|
+
let ok = SodiumNative.crypto_sign_open(msg, signedMessage, validateKey);
|
|
5525
|
+
if (!ok) {
|
|
5526
|
+
return false;
|
|
5527
|
+
}
|
|
5542
5528
|
return msg;
|
|
5543
|
-
}
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5529
|
+
};
|
|
5530
|
+
sodiumLib.detachedVerify = (signedBuffer, signatureBuffer, validateKey) => SodiumNative.crypto_sign_verify_detached(signatureBuffer, signedBuffer, validateKey);
|
|
5531
|
+
sodiumLib.secretbox = (message, nonce, secretKey) => {
|
|
5532
|
+
let secretBox = Buffer.alloc(message.length + SodiumNative.crypto_box_MACBYTES);
|
|
5533
|
+
SodiumNative.crypto_secretbox_easy(secretBox, message, nonce, secretKey);
|
|
5534
|
+
return secretBox;
|
|
5535
|
+
};
|
|
5536
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => {
|
|
5537
|
+
let msg = Buffer.alloc(secretBox.length - SodiumNative.crypto_secretbox_MACBYTES);
|
|
5538
|
+
if (SodiumNative.crypto_secretbox_open_easy(msg, secretBox, nonce, secretKey)) {
|
|
5539
|
+
return msg;
|
|
5540
|
+
} else {
|
|
5541
|
+
return void 0;
|
|
5542
|
+
}
|
|
5543
|
+
};
|
|
5544
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => {
|
|
5545
|
+
let pk = new Uint8Array(SodiumNative.crypto_sign_PUBLICKEYBYTES);
|
|
5546
|
+
SodiumNative.crypto_sign_ed25519_sk_to_pk(pk, secretKey);
|
|
5547
|
+
return pk;
|
|
5548
|
+
};
|
|
5549
|
+
sodiumLib.hash = message => {
|
|
5550
|
+
let out = Buffer.alloc(SodiumNative.crypto_hash_sha512_BYTES);
|
|
5551
|
+
SodiumNative.crypto_hash_sha512(out, message);
|
|
5552
|
+
return out;
|
|
5553
|
+
};
|
|
5554
|
+
} catch (err) {
|
|
5555
|
+
console.error("Error in loading sodium-native: fallback on tweetnacl");
|
|
5556
|
+
return loadSodium("");
|
|
5557
|
+
}
|
|
5557
5558
|
break;
|
|
5558
5559
|
|
|
5559
5560
|
default:
|
|
5560
5561
|
NaCl = require$$3$1;
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5562
|
+
sodiumLib.sigVerify = NaCl.sign.open;
|
|
5563
|
+
sodiumLib.detachedVerify = NaCl.sign.detached.verify;
|
|
5564
|
+
sodiumLib.secretbox = NaCl.secretbox;
|
|
5565
|
+
sodiumLib.secretboxOpen = (secretBox, nonce, secretKey) => Buffer.from(NaCl.secretbox.open(secretBox, nonce, secretKey));
|
|
5566
|
+
sodiumLib.publicKeyFromSecretKey = secretKey => NaCl.sign?.keyPair?.fromSecretKey(secretKey)?.publicKey;
|
|
5567
|
+
sodiumLib.hash = msg => Buffer.from(NaCl.hash(msg));
|
|
5567
5568
|
break;
|
|
5568
5569
|
}
|
|
5570
|
+
return sodiumLib;
|
|
5571
|
+
};
|
|
5572
|
+
crypto = cryptoLib => {
|
|
5573
|
+
const exports = loadSodium(cryptoLib);
|
|
5574
|
+
exports.decodeBase64 = msg => Buffer.from(msg, "base64");
|
|
5575
|
+
exports.encodeBase64 = msg => Buffer.from(msg).toString("base64");
|
|
5576
|
+
exports.decodeUTF8 = msg => Buffer.from(msg, "utf8");
|
|
5577
|
+
exports.encodeUTF8 = msg => Buffer.from(msg).toString("utf8");
|
|
5569
5578
|
return exports;
|
|
5570
5579
|
};
|
|
5571
5580
|
return crypto;
|