ismx-nexo-node-app 0.4.180 → 0.4.182

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.
@@ -72,7 +72,7 @@ class CryptoUtils {
72
72
  });
73
73
  }
74
74
  /** Asymmetric encryption (RSA) */
75
- asymEncrypt(value, publicKey) {
75
+ static asymEncrypt(value, publicKey) {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
77
  const buffer = Buffer.from(value, 'utf8');
78
78
  const encrypted = (0, node_crypto_1.publicEncrypt)(publicKey, buffer);
@@ -80,7 +80,7 @@ class CryptoUtils {
80
80
  });
81
81
  }
82
82
  /** Asymmetric decryption (RSA) */
83
- asymDecrypt(hash, privateKey) {
83
+ static asymDecrypt(hash, privateKey) {
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
85
  const buffer = Buffer.from(hash, 'base64');
86
86
  const decrypted = (0, node_crypto_1.privateDecrypt)(privateKey, buffer);
@@ -1,11 +1,12 @@
1
+ import { KeyLike, RsaPrivateKey } from "crypto";
1
2
  export default abstract class CryptoUtils {
2
3
  private static crypto;
3
4
  private static zeroPad;
4
5
  static symEncrypt(key: string, message: string): Promise<Buffer>;
5
6
  static symDecrypt(key: string, encrypted: Buffer): Promise<string>;
6
7
  /** Asymmetric encryption (RSA) */
7
- asymEncrypt(value: string, publicKey: string): Promise<string>;
8
+ static asymEncrypt(value: string, publicKey: RsaPrivateKey | KeyLike): Promise<string>;
8
9
  /** Asymmetric decryption (RSA) */
9
- asymDecrypt(hash: string, privateKey: string): Promise<string>;
10
+ static asymDecrypt(hash: string, privateKey: RsaPrivateKey | KeyLike): Promise<string>;
10
11
  private static sha256Sign;
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.180",
3
+ "version": "0.4.182",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -1,4 +1,5 @@
1
1
  import {privateDecrypt, publicEncrypt} from "node:crypto";
2
+ import {KeyLike, RsaPrivateKey} from "crypto";
2
3
 
3
4
  export default abstract class CryptoUtils {
4
5
 
@@ -48,14 +49,14 @@ export default abstract class CryptoUtils {
48
49
  }
49
50
 
50
51
  /** Asymmetric encryption (RSA) */
51
- async asymEncrypt(value: string, publicKey: string): Promise<string> {
52
+ static async asymEncrypt(value: string, publicKey: RsaPrivateKey | KeyLike): Promise<string> {
52
53
  const buffer = Buffer.from(value, 'utf8');
53
54
  const encrypted = publicEncrypt(publicKey, buffer);
54
55
  return encrypted.toString('base64');
55
56
  }
56
57
 
57
58
  /** Asymmetric decryption (RSA) */
58
- async asymDecrypt(hash: string, privateKey: string): Promise<string> {
59
+ static async asymDecrypt(hash: string, privateKey: RsaPrivateKey | KeyLike): Promise<string> {
59
60
  const buffer = Buffer.from(hash, 'base64');
60
61
  const decrypted = privateDecrypt(privateKey, buffer);
61
62
  return decrypted.toString('utf8');