@open-norantec/utilities 1.0.1-alpha.14 → 1.0.1-alpha.16

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,10 +2,10 @@
2
2
  /// <reference types="node" />
3
3
  import * as crypto from 'node:crypto';
4
4
  export declare class ECDHUtil {
5
- protected readonly privateKey: Buffer;
5
+ private readonly curveName;
6
+ readonly ecdh: crypto.ECDH;
6
7
  protected readonly ALGORITHM: crypto.CipherGCMTypes;
7
- protected readonly ecdh: crypto.ECDH;
8
- constructor(privateKey: Buffer);
8
+ constructor(curveName?: string);
9
9
  encrypt(data: string, otherPublicKey: Buffer): string;
10
10
  decrypt(encryptedData: string, otherPublicKey: Buffer): string;
11
11
  }
@@ -3,11 +3,10 @@ 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(privateKey) {
7
- this.privateKey = privateKey;
6
+ constructor(curveName = 'prime256v1') {
7
+ this.curveName = curveName;
8
+ this.ecdh = crypto.createECDH(this.curveName);
8
9
  this.ALGORITHM = 'aes-256-gcm';
9
- this.ecdh = crypto.createECDH('secp256k1');
10
- this.ecdh.setPrivateKey(new Uint8Array(privateKey));
11
10
  }
12
11
  encrypt(data, otherPublicKey) {
13
12
  const sharedKey = this.ecdh.computeSecret(new Uint8Array(otherPublicKey));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/utilities",
3
- "version": "1.0.1-alpha.14",
3
+ "version": "1.0.1-alpha.16",
4
4
  "description": "NoranTec Utilities",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {