@open-norantec/utilities 1.0.1-alpha.15 → 1.0.1-alpha.17
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.
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import * as crypto from 'node:crypto';
|
|
4
4
|
export declare class ECDHUtil {
|
|
5
|
+
private readonly curveName;
|
|
5
6
|
readonly ecdh: crypto.ECDH;
|
|
6
7
|
protected readonly ALGORITHM: crypto.CipherGCMTypes;
|
|
8
|
+
constructor(curveName?: string);
|
|
7
9
|
encrypt(data: string, otherPublicKey: Buffer): string;
|
|
8
10
|
decrypt(encryptedData: string, otherPublicKey: Buffer): string;
|
|
9
11
|
}
|
package/dist/ecdh-util.class.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ECDHUtil = void 0;
|
|
4
4
|
const crypto = require("node:crypto");
|
|
5
5
|
class ECDHUtil {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.
|
|
6
|
+
constructor(curveName = 'prime256v1') {
|
|
7
|
+
this.curveName = curveName;
|
|
8
|
+
this.ecdh = crypto.createECDH(this.curveName);
|
|
8
9
|
this.ALGORITHM = 'aes-256-gcm';
|
|
9
10
|
}
|
|
10
11
|
encrypt(data, otherPublicKey) {
|
package/dist/error-util.class.js
CHANGED
|
@@ -4,9 +4,14 @@ exports.ErrorUtil = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
class ErrorUtil {
|
|
6
6
|
static getErrorMessage(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (error instanceof zod_1.ZodError) {
|
|
8
|
+
try {
|
|
9
|
+
return `Parameters failed to pass validator rules: ${error.errors.map((subError) => subError.path.join('.')).join(', ')}`;
|
|
10
|
+
}
|
|
11
|
+
catch (_a) {
|
|
12
|
+
return 'Parameters validation error';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
10
15
|
return (error === null || error === void 0 ? void 0 : error.message) || 'An unknown error occurred';
|
|
11
16
|
}
|
|
12
17
|
}
|