@hiveio/dhive 1.2.7 → 1.2.9
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/dist/dhive.d.ts +12 -0
- package/dist/dhive.js.gz +0 -0
- package/dist/dhive.js.map +1 -1
- package/lib/helpers/aes.d.ts +12 -0
- package/lib/helpers/aes.js +4 -4
- package/lib/utils.js +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/dist/dhive.js +0 -2
package/lib/helpers/aes.d.ts
CHANGED
|
@@ -2,3 +2,15 @@
|
|
|
2
2
|
import { PrivateKey, PublicKey } from '../crypto';
|
|
3
3
|
export declare const encrypt: (private_key: PrivateKey, public_key: PublicKey, message: Buffer, nonce?: string) => any;
|
|
4
4
|
export declare const decrypt: (private_key: PrivateKey, public_key: PublicKey, nonce: any, message: any, checksum: number) => any;
|
|
5
|
+
/**
|
|
6
|
+
* This method does not use a checksum, the returned data must be validated some other way.
|
|
7
|
+
* @arg {string|Buffer} ciphertext - binary format
|
|
8
|
+
* @return {Buffer} the decrypted message
|
|
9
|
+
*/
|
|
10
|
+
export declare const cryptoJsDecrypt: (message: Buffer, tag: any, iv: any) => Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* This method does not use a checksum, the returned data must be validated some other way.
|
|
13
|
+
* @arg {string|Buffer} plaintext - binary format
|
|
14
|
+
* @return {Buffer} binary
|
|
15
|
+
*/
|
|
16
|
+
export declare const cryptoJsEncrypt: (message: Buffer, tag: any, iv: any) => Buffer;
|
package/lib/helpers/aes.js
CHANGED
|
@@ -30,10 +30,10 @@ const crypt = (private_key, public_key, nonce, message, checksum) => {
|
|
|
30
30
|
if (check32 !== checksum) {
|
|
31
31
|
throw new Error('Invalid key');
|
|
32
32
|
}
|
|
33
|
-
message = cryptoJsDecrypt(message, tag, iv);
|
|
33
|
+
message = exports.cryptoJsDecrypt(message, tag, iv);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
message = cryptoJsEncrypt(message, tag, iv);
|
|
36
|
+
message = exports.cryptoJsEncrypt(message, tag, iv);
|
|
37
37
|
}
|
|
38
38
|
return { nonce: nonceL, message, checksum: check32 };
|
|
39
39
|
};
|
|
@@ -42,7 +42,7 @@ const crypt = (private_key, public_key, nonce, message, checksum) => {
|
|
|
42
42
|
* @arg {string|Buffer} ciphertext - binary format
|
|
43
43
|
* @return {Buffer} the decrypted message
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
exports.cryptoJsDecrypt = (message, tag, iv) => {
|
|
46
46
|
assert(message, 'Missing cipher text');
|
|
47
47
|
let messageBuffer = message;
|
|
48
48
|
const decipher = crypto_1.createDecipheriv('aes-256-cbc', tag, iv);
|
|
@@ -54,7 +54,7 @@ const cryptoJsDecrypt = (message, tag, iv) => {
|
|
|
54
54
|
* @arg {string|Buffer} plaintext - binary format
|
|
55
55
|
* @return {Buffer} binary
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
exports.cryptoJsEncrypt = (message, tag, iv) => {
|
|
58
58
|
assert(message, 'Missing plain text');
|
|
59
59
|
let messageBuffer = message;
|
|
60
60
|
const cipher = crypto_1.createCipheriv('aes-256-cbc', tag, iv);
|
package/lib/utils.js
CHANGED
|
@@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
const cross_fetch_1 = require("cross-fetch");
|
|
54
54
|
const stream_1 = require("stream");
|
|
55
55
|
// TODO: Add more errors that should trigger a failover
|
|
56
|
-
const timeoutErrors = ['timeout', 'ENOTFOUND', 'ECONNREFUSED', 'database lock', 'CERT_HAS_EXPIRED', 'EHOSTUNREACH', 'ECONNRESET'];
|
|
56
|
+
const timeoutErrors = ['timeout', 'ENOTFOUND', 'ECONNREFUSED', 'database lock', 'CERT_HAS_EXPIRED', 'EHOSTUNREACH', 'ECONNRESET', 'ERR_TLS_CERT_ALTNAME_INVALID'];
|
|
57
57
|
/**
|
|
58
58
|
* Return a promise that will resove when a specific event is emitted.
|
|
59
59
|
*/
|
package/lib/version.js
CHANGED