From b868b9e1aec54f2d5497a294c906268476d2b4e7 Mon Sep 17 00:00:00 2001
From: Zdravko Iliev <zdravko.iliev@vereign.com>
Date: Thu, 2 Jun 2022 17:39:39 +0300
Subject: [PATCH] fix interface for crypto service

---
 dist/services/CryptoService/CryptoServiceNode.d.ts |  4 ++--
 dist/services/CryptoService/CryptoServiceWeb.d.ts  |  5 +++--
 dist/services/CryptoService/ICryptoService.d.ts    |  2 +-
 src/services/CryptoService/CryptoServiceNode.ts    | 12 ++++++++++--
 src/services/CryptoService/CryptoServiceWeb.ts     | 12 ++++++++++--
 src/services/CryptoService/ICryptoService.ts       |  2 +-
 6 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/dist/services/CryptoService/CryptoServiceNode.d.ts b/dist/services/CryptoService/CryptoServiceNode.d.ts
index 9b91b3c..882cbc3 100644
--- a/dist/services/CryptoService/CryptoServiceNode.d.ts
+++ b/dist/services/CryptoService/CryptoServiceNode.d.ts
@@ -1,8 +1,8 @@
 /// <reference types="node" />
 import { AESGCMOutput, RSAKeys, ICryptoService } from "./ICryptoService";
 declare class CryptoServiceNode implements ICryptoService {
-    encryptAESGCM(data: string): Promise<AESGCMOutput>;
-    encryptAESGCM(data: ArrayBuffer): Promise<AESGCMOutput>;
+    encryptAESGCM(data: string, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
+    encryptAESGCM(data: ArrayBuffer, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
     decryptAESGCM(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer): Promise<string>;
     decryptAESGCM(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer, returnBuffer: true): Promise<ArrayBuffer>;
     generateRSAKeys(): Promise<RSAKeys>;
diff --git a/dist/services/CryptoService/CryptoServiceWeb.d.ts b/dist/services/CryptoService/CryptoServiceWeb.d.ts
index 3ab743b..3db528f 100644
--- a/dist/services/CryptoService/CryptoServiceWeb.d.ts
+++ b/dist/services/CryptoService/CryptoServiceWeb.d.ts
@@ -1,7 +1,8 @@
+/// <reference types="node" />
 import { AESGCMOutput, ICryptoService, RSAKeys } from "./ICryptoService";
 declare class CryptoServiceWeb implements ICryptoService {
-    encryptAESGCM(data: string): Promise<AESGCMOutput>;
-    encryptAESGCM(data: ArrayBuffer): Promise<AESGCMOutput>;
+    encryptAESGCM(data: string, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
+    encryptAESGCM(data: ArrayBuffer, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
     decryptAESGCM(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer): Promise<string>;
     decryptAESGCM(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer, returnBuffer: true): Promise<ArrayBuffer>;
     verifyRSASignature(publicKeyPEM: string, data: ArrayBuffer, signature: ArrayBuffer): Promise<boolean>;
diff --git a/dist/services/CryptoService/ICryptoService.d.ts b/dist/services/CryptoService/ICryptoService.d.ts
index 9bbea01..8193da9 100644
--- a/dist/services/CryptoService/ICryptoService.d.ts
+++ b/dist/services/CryptoService/ICryptoService.d.ts
@@ -10,7 +10,7 @@ export interface RSAKeys {
 }
 export interface ICryptoService {
     encryptAESGCM: {
-        (data: string): Promise<AESGCMOutput>;
+        (data: string, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
         (data: ArrayBuffer, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
     };
     decryptAESGCM: {
diff --git a/src/services/CryptoService/CryptoServiceNode.ts b/src/services/CryptoService/CryptoServiceNode.ts
index 5f5163d..addea23 100644
--- a/src/services/CryptoService/CryptoServiceNode.ts
+++ b/src/services/CryptoService/CryptoServiceNode.ts
@@ -23,8 +23,16 @@ const getBytes = (
 };
 
 class CryptoServiceNode implements ICryptoService {
-  public async encryptAESGCM(data: string): Promise<AESGCMOutput>;
-  public async encryptAESGCM(data: ArrayBuffer): Promise<AESGCMOutput>;
+  public async encryptAESGCM(
+    data: string,
+    key?: Buffer,
+    iv?: Buffer
+  ): Promise<AESGCMOutput>;
+  public async encryptAESGCM(
+    data: ArrayBuffer,
+    key?: Buffer,
+    iv?: Buffer
+  ): Promise<AESGCMOutput>;
   public async encryptAESGCM(
     data: string | ArrayBuffer,
     key?: Buffer,
diff --git a/src/services/CryptoService/CryptoServiceWeb.ts b/src/services/CryptoService/CryptoServiceWeb.ts
index 831e038..b11809e 100644
--- a/src/services/CryptoService/CryptoServiceWeb.ts
+++ b/src/services/CryptoService/CryptoServiceWeb.ts
@@ -39,8 +39,16 @@ const getBytes = (value: string | ArrayBuffer, encoding): ArrayBuffer => {
 };
 
 class CryptoServiceWeb implements ICryptoService {
-  public async encryptAESGCM(data: string): Promise<AESGCMOutput>;
-  public async encryptAESGCM(data: ArrayBuffer): Promise<AESGCMOutput>;
+  public async encryptAESGCM(
+    data: string,
+    key?: Buffer,
+    iv?: Buffer
+  ): Promise<AESGCMOutput>;
+  public async encryptAESGCM(
+    data: ArrayBuffer,
+    key?: Buffer,
+    iv?: Buffer
+  ): Promise<AESGCMOutput>;
   public async encryptAESGCM(
     data: string | ArrayBuffer,
     key?: Buffer | CryptoKey,
diff --git a/src/services/CryptoService/ICryptoService.ts b/src/services/CryptoService/ICryptoService.ts
index 0867a3b..d0d4dc9 100644
--- a/src/services/CryptoService/ICryptoService.ts
+++ b/src/services/CryptoService/ICryptoService.ts
@@ -11,7 +11,7 @@ export interface RSAKeys {
 
 export interface ICryptoService {
   encryptAESGCM: {
-    (data: string): Promise<AESGCMOutput>;
+    (data: string, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
     (data: ArrayBuffer, key?: Buffer, iv?: Buffer): Promise<AESGCMOutput>;
   };
   decryptAESGCM: {
-- 
GitLab