Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/access-control-conditions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule provides functionalities for formatting and canonicalizing data,
```
yarn add @lit-protocol/access-control-conditions
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/access-control-conditions-vanilla/access-control-conditions.js"></script>
<script>
console.log(LitJsSdk_accessControlConditions);
</script>
```
9 changes: 0 additions & 9 deletions packages/auth-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ This submodule provides functionalities from various modules within the Lit SDK,
yarn add @lit-protocol/auth-browser
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/auth-browser-vanilla/auth-browser.js"></script>
<script>
console.log(LitJsSdk_authBrowser);
</script>
```

## Generate an authSig with long expiration

```
Expand Down
15 changes: 9 additions & 6 deletions packages/auth-browser/src/lib/chains/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { toUtf8Bytes } from '@ethersproject/strings';

// import WalletConnectProvider from '@walletconnect/ethereum-provider';
import { verifyMessage } from '@ethersproject/wallet';
import { EthereumProvider } from '@walletconnect/ethereum-provider';
import {
EthereumProvider,
default as WalletConnectProvider,
} from '@walletconnect/ethereum-provider';
import { ethers } from 'ethers';
import { getAddress } from 'ethers/lib/utils';
import { SiweMessage } from 'siwe';
Expand Down Expand Up @@ -128,6 +131,8 @@ export type WALLET_ERROR_VALUES =

/** ---------- Local Helpers ---------- */

let litWCProvider: WalletConnectProvider | undefined;

/**
*
* Convert chain hex id to chain name
Expand Down Expand Up @@ -386,8 +391,7 @@ export const connectWeb3 = async ({
};

if (isBrowser()) {
// @ts-ignore
globalThis.litWCProvider = wcProvider;
litWCProvider = wcProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double checked that this variable is not used in other modules as it's now locally scoped instead of global

}
}

Expand Down Expand Up @@ -440,10 +444,9 @@ export const disconnectWeb3 = (): void => {
}

// @ts-ignore
if (isBrowser() && globalThis.litWCProvider) {
if (isBrowser() && litWCProvider) {
try {
// @ts-ignore
globalThis.litWCProvider.disconnect();
litWCProvider.disconnect();
} catch (err) {
log(
'Attempted to disconnect global WalletConnectProvider for lit-connect-modal',
Expand Down
9 changes: 0 additions & 9 deletions packages/auth-helpers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule manages permissions and capabilities related to accessing specifi
```
yarn add @lit-protocol/auth-helpers
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/auth-helpers-vanilla/auth-helpers.js"></script>
<script>
console.log(LitJsSdk_authHelpers);
</script>
```
9 changes: 0 additions & 9 deletions packages/constants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule exports various modules, constants, interfaces, errors, utilities
```
yarn add @lit-protocol/constants
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/constants-vanilla/constants.js"></script>
<script>
console.log(LitJsSdk_constants);
</script>
```
16 changes: 1 addition & 15 deletions packages/contracts-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,8 @@ Demo: https://demo-contracts-sdk-react.vercel.app/

# Installation

```js
yarn add @lit-protocol/contracts-sdk
```

# Vanilla JS (UMD)

```html
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/contracts-sdk-vanilla/contracts-sdk.js"></script>
<script>
(async () => {
const { LitContracts } = LitJsSdk_contractsSdk;

const litContracts = new LitContracts();
await litContracts.connect();
})();
</script>
yarn add @lit-protocol/contracts-sdk
```

# Quick Start
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
logWithRequestId,
mostCommonString,
sendRequest,
setMiscLitConfig,
} from '@lit-protocol/misc';
import {
AuthSig,
Expand Down Expand Up @@ -197,8 +198,8 @@ export class LitCore {
// -- set bootstrapUrls to match the network litNetwork unless it's set to custom
this.setCustomBootstrapUrls();

// -- set global variables
globalThis.litConfig = this.config;
// -- set misc global variables
setMiscLitConfig(this.config);
bootstrapLogManager('core');

// -- configure local storage if not present
Expand Down Expand Up @@ -387,7 +388,7 @@ export class LitCore {

this._stopListeningForNewEpoch();
// this._stopNetworkPolling();
if (globalThis.litConfig) delete globalThis.litConfig;
setMiscLitConfig(undefined);
}

// _stopNetworkPolling() {
Expand Down Expand Up @@ -532,9 +533,6 @@ export class LitCore {
// this._scheduleNetworkSync();
this._listenForNewEpoch();

// FIXME: don't create global singleton; multiple instances of `core` should not all write to global
// @ts-expect-error typeof globalThis is not defined. We're going to get rid of the global soon.
globalThis.litNodeClient = this;
this.ready = true;

log(`🔥 lit is ready. "litNodeClient" variable is ready to use globally.`);
Expand Down
9 changes: 0 additions & 9 deletions packages/crypto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ The crypto.ts file in the Lit SDK handles cryptographic operations, including th
```
yarn add @lit-protocol/crypto
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/crypto-vanilla/crypto.js"></script>
<script>
console.log(LitJsSdk_crypto);
</script>
```
9 changes: 0 additions & 9 deletions packages/encryption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule provides encryption and decryption of contents (string, file, etc
```
yarn add @lit-protocol/encryption
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/encryption-vanilla/encryption.js"></script>
<script>
console.log(LitJsSdk_encryption);
</script>
```
14 changes: 0 additions & 14 deletions packages/lit-node-client-nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import 'cross-fetch/dist/node-polyfill.js';

import * as _LitNodeClientNodeJs from './lib/lit-node-client-nodejs';
// ==================== Environment ====================

declare global {
// This `declare global` hackery _must_ use var to work.
// eslint-disable-next-line no-var, @typescript-eslint/no-explicit-any
var LitNodeClientNodeJs: any;
}

const LitNodeClientNodeJs = _LitNodeClientNodeJs.LitNodeClientNodeJs;
if (!globalThis.LitNodeClientNodeJs) {
globalThis.LitNodeClientNodeJs = LitNodeClientNodeJs;
}

// ==================== Exports ====================
export * from './lib/lit-node-client-nodejs';

Expand Down
9 changes: 0 additions & 9 deletions packages/lit-node-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This module is the main module of this monorepo. It sets a default authenticatio
```
yarn add @lit-protocol/lit-node-client
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/lit-node-client-vanilla/lit-node-client.js"></script>
<script>
const authSig = LitJsSdk_litNodeClient.checkAndSignAuthMessage({chain: 'ethereum'});
</script>
```
14 changes: 0 additions & 14 deletions packages/lit-node-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
import * as _LitNodeClient from './lib/lit-node-client';

declare global {
// This `var` is necessary for global hackery
// eslint-disable-next-line no-var, @typescript-eslint/no-explicit-any
var LitNodeClient: any;
}

const LitNodeClient = _LitNodeClient.LitNodeClient;
if (!globalThis.LitNodeClient) {
globalThis.LitNodeClient = LitNodeClient;
}

// ==================== Exports ====================

export * from './lib/lit-node-client';

export {
Expand Down
9 changes: 0 additions & 9 deletions packages/misc-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule includes functions for interaction with local storage (get, set,
```
yarn add @lit-protocol/misc-browser
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/misc-browser-vanilla/misc-browser.js"></script>
<script>
console.log(LitJsSdk_miscBrowser);
</script>
```
9 changes: 0 additions & 9 deletions packages/misc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ This submodule contains various utility functions for error handling, logging, t
```
yarn add @lit-protocol/misc
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/misc-vanilla/misc.js"></script>
<script>
console.log(LitJsSdk_misc);
</script>
```
25 changes: 16 additions & 9 deletions packages/misc/src/lib/misc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LitNodeClientConfig } from '@lit-protocol/types';
import { Contract } from '@ethersproject/contracts';
import { JsonRpcProvider } from '@ethersproject/providers';
import Ajv, { JSONSchemaType } from 'ajv';
Expand Down Expand Up @@ -31,6 +32,13 @@ import {
const logBuffer: any[][] = [];
const ajv = new Ajv();

// Module scoped variable to store the LitNodeClientConfig passed to LitCore
let litConfig: LitNodeClientConfig | undefined;

export const setMiscLitConfig = (config: LitNodeClientConfig | undefined) => {
litConfig = config;
};

/**
*
* Print error message based on Error interface
Expand Down Expand Up @@ -95,7 +103,6 @@ export const findMostCommonResponse = (responses: object[]): object => {
};

declare global {
var litConfig: any;
var wasmExport: any;
var wasmECDSA: any;
var logger: any;
Expand Down Expand Up @@ -148,13 +155,13 @@ export const log = (...args: any): void => {
}

// check if config is loaded yet
if (!globalThis?.litConfig) {
if (!litConfig) {
// config isn't loaded yet, push into buffer
logBuffer.push(args);
return;
}

if (globalThis?.litConfig?.debug !== true) {
if (litConfig?.debug !== true) {
return;
}
// config is loaded, and debug is true
Expand All @@ -176,13 +183,13 @@ export const logWithRequestId = (id: string, ...args: any) => {
}

// check if config is loaded yet
if (!globalThis?.litConfig) {
if (!litConfig) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a note to reevaluate this module of scoping of the LitConfig instance for the logger refactor task: https://linear.app/litprotocol/issue/LIT-3921/migrate-to-interfacing-with-logger-through-module-over-global-object

// config isn't loaded yet, push into buffer
logBuffer.push(args);
return;
}

if (globalThis?.litConfig?.debug !== true) {
if (litConfig?.debug !== true) {
return;
}
// config is loaded, and debug is true
Expand All @@ -206,13 +213,13 @@ export const logErrorWithRequestId = (id: string, ...args: any) => {
}

// check if config is loaded yet
if (!globalThis?.litConfig) {
if (!litConfig) {
// config isn't loaded yet, push into buffer
logBuffer.push(args);
return;
}

if (globalThis?.litConfig?.debug !== true) {
if (litConfig?.debug !== true) {
return;
}
// config is loaded, and debug is true
Expand All @@ -236,13 +243,13 @@ export const logError = (...args: any) => {
}

// check if config is loaded yet
if (!globalThis?.litConfig) {
if (!litConfig) {
// config isn't loaded yet, push into buffer
logBuffer.push(args);
return;
}

if (globalThis?.litConfig?.debug !== true) {
if (litConfig?.debug !== true) {
return;
}
// config is loaded, and debug is true
Expand Down
9 changes: 0 additions & 9 deletions packages/nacl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ re-export of https://www.npmjs.com/package/nacl
```
yarn add @lit-protocol/nacl
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/nacl-vanilla/nacl.js"></script>
<script>
console.log(LitJsSdk_nacl);
</script>
```
9 changes: 0 additions & 9 deletions packages/pkp-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,3 @@ This submodule defines a PKPBase class, providing shared wallet functionality fo
```
yarn add @lit-protocol/pkp-base
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/pkp-base-vanilla/pkp-base.js"></script>
<script>
console.log(LitJsSdk_pkpBase);
</script>
```
9 changes: 0 additions & 9 deletions packages/uint8arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,3 @@ Here are the two main functions:
```
yarn add @lit-protocol/uint8array
```

### Vanilla JS (UMD)

```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/uint8array-vanilla/uint8array.js"></script>
<script>
console.log(LitJsSdk_uint8array);
</script>
```
Loading
Loading