File tree Expand file tree Collapse file tree 4 files changed +38
-2
lines changed
transaction-manager/test/unit/utils Expand file tree Collapse file tree 4 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ export default class EthereumPrivateKeyCipherProvider
2020 /** Dictionary containing all the private keys indexed by address */
2121 private decryptionParametersDictionary : IDecryptionParametersDictionary ;
2222
23+ private isDecryptionOn = false ;
24+
2325 constructor ( decryptionParameters ?: EncryptionTypes . IDecryptionParameters ) {
2426 this . decryptionParametersDictionary = new Map < string , EncryptionTypes . IDecryptionParameters > ( ) ;
2527 if ( decryptionParameters ) {
@@ -42,9 +44,17 @@ export default class EthereumPrivateKeyCipherProvider
4244 * @returns true if decryption is available
4345 */
4446 public isDecryptionAvailable ( ) : boolean {
45- return this . decryptionParametersDictionary . size > 0 ;
47+ return this . decryptionParametersDictionary . size > 0 && this . isDecryptionOn ;
4648 }
4749
50+ /**
51+ * Switches on decryption
52+ *
53+ * @param option
54+ */
55+ public switchOnOffDecryption ( option : boolean ) : void {
56+ this . isDecryptionOn = option ;
57+ }
4858 /**
4959 * Encrypts data
5060 *
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider
6161 */
6262 private debug = false ;
6363
64+ /**
65+ * @property {boolean } isDecryptionOn - A boolean indicating if decryption is enabled.
66+ */
67+ private isDecryptionOn = false ;
68+
6469 /**
6570 * @constructor
6671 * @param {LitNodeClient|LitNodeClientNodeJs } litClient - An instance of a Lit Protocol client (either client-side or Node.js).
@@ -274,6 +279,15 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider
274279 return accessControlConditions ;
275280 }
276281
282+ /**
283+ * Switches on decryption
284+ *
285+ * @param option
286+ */
287+ public switchOnOffDecryption ( option : boolean ) : void {
288+ this . isDecryptionOn = option ;
289+ }
290+
277291 /**
278292 * @function isEncryptionAvailable
279293 * @description Checks if encryption is available.
@@ -324,7 +338,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider
324338 * @returns {boolean } A boolean indicating if decryption is available.
325339 */
326340 public isDecryptionAvailable ( ) : boolean {
327- return this . client !== null && this . sessionSigs !== null ;
341+ return this . client !== null && this . sessionSigs !== null && this . isDecryptionOn ;
328342 }
329343
330344 /**
Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ export const fakeDecryptionProvider: DecryptionProviderTypes.IDecryptionProvider
106106} ;
107107
108108export class FakeEpkCipherProvider implements CipherProviderTypes . ICipherProvider {
109+ switchOnOffDecryption ( option : boolean ) : void {
110+ throw new Error ( 'Method not implemented.' ) ;
111+ }
109112 isEncryptionAvailable ( ) : boolean {
110113 throw new Error ( 'Method not implemented.' ) ;
111114 }
@@ -174,6 +177,9 @@ export class FakeLitProtocolProvider implements CipherProviderTypes.ICipherProvi
174177 constructor ( ) {
175178 this . storedRawData = '' ;
176179 }
180+ switchOnOffDecryption ( option : boolean ) : void {
181+ throw new Error ( 'Method not implemented.' ) ;
182+ }
177183 isEncryptionAvailable ( ) : boolean {
178184 throw new Error ( 'Method not implemented.' ) ;
179185 }
Original file line number Diff line number Diff line change @@ -29,4 +29,10 @@ export interface ICipherProvider {
2929 * @returns A boolean indicating if decryption is available.
3030 */
3131 isDecryptionAvailable ( ) : boolean ;
32+
33+ /**
34+ * Switches on/off decryption.
35+ * @param option - A boolean indicating if decryption should be switched on/off.
36+ */
37+ switchOnOffDecryption ( option : boolean ) : void ;
3238}
You can’t perform that action at this time.
0 commit comments