Skip to content

Commit

Permalink
fix: Add the env variable for switching logs from LitProtocol [DEV-36…
Browse files Browse the repository at this point in the history
…93] (#423)

Add logs severity switching for LitProtocol

Co-authored-by: Tasos Derisiotis <[email protected]>
  • Loading branch information
Andrew Nikitin and Eengineer1 authored Apr 3, 2024
1 parent e97fb00 commit 129c5e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ $ veramo config check -f <path/to/>agent.yml
Your Veramo configuration seems fine. An agent can be created and the 'agent.execute()' method can be called on it.
```

### 5. Environment setup

1. `LIT_PROTOCOL_DEBUG` - Set this to `true` to enable debug logging for the LIT protocol. By default it is set to `false`.

## 📖 Documentation

[Tutorials, advanced configuration, and architecture for cheqd's Veramo plugin](https://docs.cheqd.io/identity/guides/sdk/veramo-sdk-for-cheqd) can be found on our [Identity Docs site](https://docs.cheqd.io/identity/).
Expand Down
5 changes: 3 additions & 2 deletions src/dkg-threshold/lit-protocol/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { JsonSaveEncryptionKeyRequest } from '@lit-protocol/types-v2';
import { randomBytes } from '../../utils/helpers.js';
import { isBrowser, isNode } from '../../utils/env.js';
import { v4 } from 'uuid';
import { LitProtocolDebugEnabled } from '../../utils/constants.js';

export type EncryptionResultV2 = {
encryptedString: Blob;
Expand Down Expand Up @@ -96,8 +97,8 @@ export class LitProtocolV2 {

// set client as per environment
this.client = (function (that: LitProtocolV2) {
if (isNode) return new LitNodeClientNodeJs({ litNetwork: that.litNetwork });
if (isBrowser) return new LitNodeClient({ litNetwork: that.litNetwork });
if (isNode) return new LitNodeClientNodeJs({ litNetwork: that.litNetwork, debug: LitProtocolDebugEnabled });
if (isBrowser) return new LitNodeClient({ litNetwork: that.litNetwork, debug: LitProtocolDebugEnabled });
throw new Error('[did-provider-cheqd]: lit-protocol: Unsupported runtime environment');
})(this);
}
Expand Down
5 changes: 3 additions & 2 deletions src/dkg-threshold/lit-protocol/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { generateSymmetricKey, randomBytes } from '../../utils/helpers.js';
import { isBrowser, isNode } from '../../utils/env.js';
import { v4 } from 'uuid';
import { fromString } from 'uint8arrays';
import { LitProtocolDebugEnabled } from '../../utils/constants.js';

export type ThresholdEncryptionResult = {
encryptedString: Uint8Array;
Expand Down Expand Up @@ -99,8 +100,8 @@ export class LitProtocol {

// set client as per environment
this.client = (function (that: LitProtocol) {
if (isNode) return new LitNodeClientNodeJs({ litNetwork: that.litNetwork });
if (isBrowser) return new LitNodeClient({ litNetwork: that.litNetwork });
if (isNode) return new LitNodeClientNodeJs({ litNetwork: that.litNetwork, debug: LitProtocolDebugEnabled });
if (isBrowser) return new LitNodeClient({ litNetwork: that.litNetwork, debug: LitProtocolDebugEnabled });
throw new Error('[did-provider-cheqd]: lit-protocol: Unsupported runtime environment');
})(this);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LitProtocolDebugEnabled = process.env.LIT_PROTOCOL_DEBUG === 'true';

0 comments on commit 129c5e1

Please sign in to comment.