Skip to content

Replace litConnectModal with Wagmi #797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: feat/naga-fix-bls-wasm-cleanup
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c235094
replace litConnectModal with wagmi
anshss Dec 28, 2024
94c091a
Merge branch 'master' into anshs
Ansonhkg Dec 30, 2024
429b95c
fix: linting errs
anshss Jan 2, 2025
c2e4e6d
refactor: litConnectModal as deafult
anshss Jan 2, 2025
456ad3b
chore: update version to `7.0.4`
Ansonhkg Jan 2, 2025
6711032
feat: wagmi as optional
anshss Jan 2, 2025
9fd958c
fmt
Ansonhkg Jan 2, 2025
1525da4
Merge pull request #753 from LIT-Protocol/v7.0.4-Publish
Ansonhkg Jan 2, 2025
412264b
fmt
Ansonhkg Jan 2, 2025
382d38d
Merge branch 'master' into anshs
Ansonhkg Jan 2, 2025
39af557
docs: improve package descriptions in READMEs
devin-ai-integration[bot] Jan 2, 2025
b3f6537
docs: update core package READMEs with improved descriptions and exam…
devin-ai-integration[bot] Jan 2, 2025
dd4a818
docs: update auth package READMEs with improved descriptions
devin-ai-integration[bot] Jan 2, 2025
14b4c41
docs: update PKP package READMEs with improved documentation
devin-ai-integration[bot] Jan 2, 2025
873aacf
docs: improve package descriptions and standardize README formatting
devin-ai-integration[bot] Jan 2, 2025
19054af
docs: improve root README.md organization and clarity
devin-ai-integration[bot] Jan 2, 2025
5884685
docs: fix formatting issues in README.md
devin-ai-integration[bot] Jan 2, 2025
7893a7c
doc: clean up devin's work
Ansonhkg Jan 2, 2025
763bd14
fmt
Ansonhkg Jan 2, 2025
fee3b14
doc: cleanup Devin's work
Ansonhkg Jan 2, 2025
862199b
fix logger test
susumutomita Jan 3, 2025
30f3217
fix wrapped keys test issue760
susumutomita Jan 4, 2025
9f0bcde
docs: address reviewer feedback on README
devin-ai-integration[bot] Jan 6, 2025
45efa33
chore: fix formatting
devin-ai-integration[bot] Jan 6, 2025
6cd6f07
Update packages/pkp-base/README.md
Ansonhkg Jan 6, 2025
90ee710
chore: apply prettier formatting
devin-ai-integration[bot] Jan 6, 2025
35137ce
feat: fix feedback devin missed
FedericoAmura Jan 6, 2025
0801de0
feat: fix feedback devin missed
FedericoAmura Jan 6, 2025
b1ed607
Merge pull request #761 from susumutomita/fix/wrapped-keys-test-issue760
Ansonhkg Jan 15, 2025
71a8f2d
Merge pull request #759 from susumutomita/bugfix/logger-tests-issue758
Ansonhkg Jan 15, 2025
6fb9791
Merge pull request #754 from LIT-Protocol/devin/1735845077-update-rea…
Ansonhkg Jan 15, 2025
e1fd8bd
Merge branch 'master' into anshs
Ansonhkg Jan 15, 2025
f1d068d
fix(ci): update Rust version to 1.83.0 for wasm compatibility
Ansonhkg Jan 15, 2025
d4e1a64
Merge pull request #766 from LIT-Protocol/feature/lit-4129-js-sdk-fix…
Ansonhkg Jan 15, 2025
309512b
Merge branch 'master' into anshs
Ansonhkg Jan 15, 2025
b0daa1a
Merge branch 'feat/naga-fix-bls-wasm-cleanup' into anshs
Ansonhkg Feb 11, 2025
92856c6
fix: add temp types export from constant
Ansonhkg Feb 11, 2025
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
277 changes: 158 additions & 119 deletions README.md
Original file line number Diff line number Diff line change
@@ -98,35 +98,45 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou

# Contributing and developing to this SDK

## Prerequisite
## Prerequisites

- node (v19.x or above)
- rust (v1.70.00 or above)
- [wasm-pack](https://github.com/rustwasm/wasm-pack)
Before you begin, ensure you have the following installed:

## Recommended
- Node.js v19.0.0 or later
- Rust v1.70.0 or later
- [wasm-pack](https://github.com/rustwasm/wasm-pack) for WebAssembly compilation

- NX Console: https://nx.dev/core-features/integrate-with-editors
## Development Tools

Recommended for better development experience:

- [NX Console](https://nx.dev/core-features/integrate-with-editors) - Visual Studio Code extension for NX workspace management

# Quick Start

The following commands will help you start developing with this repository.
To start developing with this repository:

First, install the dependencies via yarn:
1. Install dependencies:

```
yarn
```

2. Build the packages:

```
yarn build:dev
```

## Building

You can build the project with the following commands:
Build the project using one of these commands:

```
// for local development - It stripped away operations that don't matter for local dev
// For local development (optimized, excludes production-only operations)
yarn build:dev
// you should never need to use yarn build unless you want to test or publish it
// For testing and publishing (full build with all operations)
yarn build
```

@@ -148,22 +158,6 @@ yarn test:local

`nx generate @nx/js:library`

## Create a new react demo app using the Lit JS SDK

```sh
yarn tools --create --react contracts-sdk --demo
```

## Deleting a package or app

```
// delete an app from ./app/<app-name>
yarn delete:app <app-name>
// delete a package from ./packages/<package-name>
yarn delete:package <package-name>
```

## Building

```sh
@@ -210,170 +204,216 @@ Having done this setup, this is what the development cycle looks like moving for
2. Rebuild specific package
3. Rebuild client application.

### Building changes to Rust source
### Building Rust Components

If changes are made to `packages/wasm` see [here](./packages/wasm/README.md) for info on building from source.
For changes to WebAssembly components in `packages/wasm`, refer to the [WebAssembly build guide](./packages/wasm/README.md).

## Publishing
## Publishing New Versions

You must have at least nodejs v18 to do this.
Prerequisites:

1. Install the latest packages with `yarn install`
- Node.js v18.0.0 or later

2. Run `yarn bump` to bump the version
Publishing steps:

3. Build all the packages with `yarn build`
1. Create a release PR:

4. Run the unit tests with `yarn test:unit` & e2e node tests `yarn test:local` locally & ensure that they pass
- Create a new branch from master with format `vX.X.X-Publish`
- Add changelog as PR description
- Add "Release" label to the PR
- Reference example: https://github.com/LIT-Protocol/js-sdk/pull/753

5. Update the docs with `yarn gen:docs --push`
2. After PR approval, proceed with publishing:
- Update dependencies: `yarn install`
- Increment version: `yarn bump`
- Build packages: `yarn build`
- Run tests:
- Unit tests: `yarn test:unit`
- E2E tests: `yarn test:local`
- Generate documentation: `yarn gen:docs --push`
- Publish packages: `yarn publish:packages`
- Commit with message: "Published version X.X.X"

6. Finally, publish with `yarn publish:packages`
## Testing Guide

7. Commit these changes "Published version X.X.X"
### Available Test Commands

## Testing
| Command | Description |
| ----------------- | ------------------------------------ |
| `yarn test:unit` | Run unit tests for all packages |
| `yarn test:local` | Run E2E tests in Node.js environment |

### Quick Start on E2E Testing
### Running Tests

The following will serve the react testing app and launch the cypress e2e testing after
1. Unit Tests:

```sh
yarn test:local
```
```sh
yarn test:unit
```

### Unit Tests
2. End-to-End Tests:

```sh
yarn test:unit
```
```sh
yarn test:local
```

## Testing with a Local Lit Node
Optional Environment Variables:

First, deploy your Lit Node Contracts, since the correct addresses will be pulled from the `../lit-assets/blockchain/contracts/deployed-lit-node-contracts-temp.json` file.
- NETWORK=<network_name> (datil, datil-test, datil-dev, etc.)
- DEBUG=true/false

Set these two env vars:
Optional Flags:

```sh
export LIT_JS_SDK_LOCAL_NODE_DEV="true"
export LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY="putAFundedPrivateKeyOnChronicleHere"
```
- --filter=<test-name>

Run:
See more in `local-tests/README.md`

```sh
yarn update:contracts-sdk --fetch
yarn update:contracts-sdk --gen
yarn build:packages
```
## Local Development with Lit Node

### Setup Local Environment

1. Deploy Lit Node Contracts (addresses will be read from `../lit-assets/blockchain/contracts/deployed-lit-node-contracts-temp.json`)

To run manual tests:
2. Configure environment variables:

```sh
yarn nx run nodejs:serve
# Enable local node development
export LIT_JS_SDK_LOCAL_NODE_DEV="true"

# Set funded wallet for Chronicle testnet
export LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY="your-funded-private-key"
```

## ENV Vars
## Environment Variables

| Variable | Description | Usage |
| -------------------------------------- | --------------------------- | ------------------------------------------------------------ |
| `LIT_JS_SDK_GITHUB_ACCESS_TOKEN` | GitHub access token | Required for accessing contract ABIs from private repository |
| `LIT_JS_SDK_LOCAL_NODE_DEV` | Local node development flag | Set to `true` to use a local Lit node |
| `LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY` | Funded wallet private key | Required for Chronicle Testnet transactions |

- LIT_JS_SDK_GITHUB_ACCESS_TOKEN - a github access token to get the contract ABIs from a private repo
- LIT_JS_SDK_LOCAL_NODE_DEV - set to true to use a local node
- LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY - set to a funded wallet on Chronicle Testnet
# Error Handling Guide

# Error Handling
## Overview

This SDK uses custom error classes derived from [@openagenda/verror](https://github.com/OpenAgenda/verror) to handle errors between packages and to the SDK consumers.
Normal error handling is also supported as VError extends the native Error class, but using VError allows for better error composition and information propagation.
You can check their documentation for the extra fields that are added to the error object and methods on how to handle them in a safe way.
The SDK implements a robust error handling system using [@openagenda/verror](https://github.com/OpenAgenda/verror). This system provides:

## Example
- Detailed error information with cause tracking
- Error composition and chaining
- Additional context through metadata
- Compatibility with native JavaScript Error handling

## Using Error Handling

### Basic Example

```ts
import { VError } from '@openagenda/verror';
import { LitNodeClientBadConfigError } from '@lit-protocol/constants';

try {
// Simulate an error condition
const someNativeError = new Error('some native error');

// Throw a Lit-specific error with context
throw new LitNodeClientBadConfigError(
{
cause: someNativeError,
info: {
foo: 'bar',
},
meta: {
baz: 'qux',
},
info: { foo: 'bar' },
meta: { baz: 'qux' },
},
'some useful message'
);
} catch (e) {
// Access error details
console.log(e.name); // LitNodeClientBadConfigError
console.log(e.message); // some useful message: some native error
console.log(e.info); // { foo: 'bar' }
console.log(e.baz); // qux
// VError.cause(e) is someNativeError
// VError.info(e) is { foo: 'bar' }
// VError.meta(e) is { baz: 'qux', code: 'lit_node_client_bad_config_error', kind: 'Config' }
// Verror.fullStack(e) is the full stack trace composed of the error chain including the causes

// Additional error information
// - VError.cause(e): Original error (someNativeError)
// - VError.info(e): Additional context ({ foo: 'bar' })
// - VError.meta(e): Metadata ({ baz: 'qux', code: 'lit_node_client_bad_config_error', kind: 'Config' })
// - VError.fullStack(e): Complete error chain stack trace
}
```

## Creating a new error

In file `packages/constants/src/lib/errors.ts` you can find the list of errors that are currently supported and add new ones if needed.

To create and use a new error, you need to:

1. Add the error information to the `LIT_ERROR` object in `packages/constants/src/lib/errors.ts`
2. Export the error from the `errors.ts` file at the end of the file
3. Import the error where you need it
4. Throw the error in your code adding all the information a user might need to know about the error such as the cause, the info, etc.
## Creating Custom Errors

To add new error types:

1. Locate `packages/constants/src/lib/errors.ts`
2. Add your error definition to the `LIT_ERROR` object
3. Export the new error class
4. Import and use in your code with relevant context:
```ts
throw new YourCustomError(
{
cause: originalError,
info: {
/* context */
},
meta: {
/* metadata */
},
},
'Error message'
);
```

# Dockerfile

...coming soon

## Other Commands

### Interactive graph dependencies using NX
# Core Systems and Services

```
yarn graph
```
The Lit Protocol SDK provides the following core systems:

![](https://i.ibb.co/2dLyMTW/Screenshot-2022-11-15-at-15-18-46.png)
- Cryptographic key management (PKP - Programmable Key Pair)
- Blockchain wallet interactions (Ethereum, Solana, Cosmos)
- Decentralized authentication and authorization
- Distributed computing and signing
- Smart contract management
- Access control and encryption services

# FAQs & Common Errors
# Main Functions and Classes

<details>
<summary>(React) Failed to parse source map from</summary>
Key components available across packages:

In your React package.json, add `GENERATE_SOURCEMAP=false` to your start script
- `PKPEthersWallet`: Ethereum wallet management for PKP
- `LitNodeClient`: Network interaction client
- `executeJs()`: Decentralized JavaScript execution
- `signMessageWithEncryptedKey()`: Cryptographic signing
- `generatePrivateKey()`: Key generation utilities
- `TinnyEnvironment`: Testing environment setup

eg.
# Troubleshooting Guide

```
"scripts": {
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
```
## Common Issues and Solutions

### Crypto API Error

</details>
**Problem:** "Reference Error: crypto is not defined"

<details>
<summary>Reference Error: crypto is not defined</summary>
**Solution:**
Add the following polyfill for environments without native crypto:

```js
import crypto, { createHash } from 'crypto';

// Add crypto to global scope
Object.defineProperty(globalThis, 'crypto', {
value: {
// Implement getRandomValues
getRandomValues: (arr: any) => crypto.randomBytes(arr.length),

// Implement subtle crypto
subtle: {
digest: (algorithm: string, data: Uint8Array) => {
return new Promise((resolve, reject) =>
return new Promise((resolve) =>
resolve(
createHash(algorithm.toLowerCase().replace('-', ''))
.update(data)
@@ -386,10 +426,9 @@ Object.defineProperty(globalThis, 'crypto', {
});
```

</details>
<details>
<summary>error Command failed with exit code 13.</summary>
### Unexpected Error on Node

Make sure your node version is above v18.0.0
**Problem:** Exit code 13

</details>
**Solution:**
Make sure your node version is above v18.0.0
2 changes: 1 addition & 1 deletion local-tests/tests/testRelayer.ts
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ export const testRelayer = async (devEnv: TinnyEnvironment) => {
litNodeClient: devEnv.litNodeClient,
});

const pkps = await ethWalletProvider.fetchPKPsThroughRelayer(
const pkps = await ethWalletProvider.fetchPKPs(
alice.authMethod
);

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@
"@openagenda/verror": "^3.1.4",
"@simplewebauthn/browser": "^7.2.0",
"@simplewebauthn/typescript-types": "^7.0.0",
"@tanstack/react-query": "^5.62.11",
"@wagmi/core": "^2.16.3",
"@walletconnect/ethereum-provider": "2.9.2",
"@walletconnect/jsonrpc-utils": "1.0.8",
"@walletconnect/types": "2.9.2",
@@ -65,12 +67,15 @@
"micromodal": "^0.4.10",
"multiformats": "^9.7.1",
"pako": "^2.1.0",
"react": "^19.0.0",
"siwe": "^2.3.2",
"siwe-recap": "0.0.2-alpha.0",
"tslib": "^2.7.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"uint8arrays": "^4.0.3"
"uint8arrays": "^4.0.3",
"viem": "^2.21.57",
"wagmi": "^2.14.6"
},
"devDependencies": {
"@nx/devkit": "17.3.0",
38 changes: 34 additions & 4 deletions packages/access-control-conditions/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
# Quick Start
# Access Control Conditions

This submodule provides functionalities for formatting and canonicalizing data, validating and creating digital signatures, and hashing various types of conditions and identifiers in a deterministic way to ensure data integrity and security within the LIT protocol.
A comprehensive toolkit for managing access control conditions within the Lit Protocol ecosystem. This package provides functionalities for formatting, validating, and securing access control rules.

### node.js / browser
## Installation

```
```bash
yarn add @lit-protocol/access-control-conditions
```

## Quick Start

```typescript
import {
validateAccessControlConditions,
hashAccessControlConditions,
} from '@lit-protocol/access-control-conditions';

// Validate conditions
const isValid = await validateAccessControlConditions(conditions);

// Hash conditions for verification
const hash = await hashAccessControlConditions(conditions);
```

## Key Features

- Data formatting and canonicalization
- Digital signature validation and creation
- Deterministic condition hashing
- Access control rule validation
- Secure identifier management

## Core Operations

- Condition Validation: Verify access control rules
- Hash Generation: Create deterministic hashes
- Signature Management: Handle digital signatures
- Data Canonicalization: Ensure consistent formats
40 changes: 32 additions & 8 deletions packages/auth-browser/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
# Quick Start
# Auth Browser

This submodule provides functionalities from various modules within the Lit SDK, enabling users to authenticate in the browser and connect to different blockchain networks (Ethereum, Cosmos, and Solana) with convenience, while also providing a function to disconnect from the Ethereum network.
Browser-specific authentication utilities for the Lit Protocol, enabling seamless connection to various blockchain networks including Ethereum, Cosmos, and Solana.

### node.js / browser
## Installation

```
```bash
yarn add @lit-protocol/auth-browser
```

## Generate an authSig with long expiration
## Quick Start

```typescript
import { checkAndSignAuthMessage } from '@lit-protocol/auth-browser';

// Generate an authSig with long expiration
const expiration = new Date(
Date.now() + 1000 * 60 * 60 * 24 * 30
).toISOString();
const authSig = await checkAndSignAuthMessage({
chain: 'ethereum',
expiration: expiration,
});
```
const expiration = new Date(Date.now() + 1000 * 60 * 60 * 99999).toISOString();

const authSig = LitJsSdk_authBrowser.checkAndSignAuthMessage({chain: 'ethereum', expiration: expiration});
## Key Features

```
- Multi-chain authentication support
- Ethereum
- Cosmos
- Solana
- Convenient network connection management
- Automatic signature generation
- Flexible expiration handling
- Network disconnection utilities

## Authentication Methods

- Standard Authentication: Quick connect with default settings
- Custom Expiration: Control signature validity period
- Multi-Chain Support: Connect to different networks
- Network Management: Connect and disconnect as needed
6 changes: 5 additions & 1 deletion packages/auth-browser/package.json
Original file line number Diff line number Diff line change
@@ -26,7 +26,11 @@
"tweetnacl-util": "^0.13.3",
"util": "^0.12.4",
"web-vitals": "^3.0.4",
"@lit-protocol/contracts": "^0.0.74"
"@lit-protocol/contracts": "^0.0.74",
"wagmi": "^2.14.6",
"viem": "^2.0.0",
"@tanstack/react-query": "^5.0.0",
"react": "^18.0.0"
},
"tags": [
"browser"
190 changes: 161 additions & 29 deletions packages/auth-browser/src/lib/chains/eth.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import { Buffer as BufferPolyfill } from 'buffer';
import depd from 'depd';

import { hexlify } from '@ethersproject/bytes';
import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers';
import { toUtf8Bytes } from '@ethersproject/strings';

// import WalletConnectProvider from '@walletconnect/ethereum-provider';
import { verifyMessage } from '@ethersproject/wallet';
import { injected, walletConnect } from '@wagmi/connectors';
import {
connect as wagmiConnect,
disconnect as wagmiDisconnect,
getWalletClient,
Config,
} from '@wagmi/core';
import {
EthereumProvider,
default as WalletConnectProvider,
} from '@walletconnect/ethereum-provider';
import depd from 'depd';
import { ethers } from 'ethers';
import { getAddress } from 'ethers/lib/utils';
import { SiweMessage } from 'siwe';

// @ts-ignore: If importing 'nacl' directly, the built files will use .default instead
import * as nacl from 'tweetnacl';
import * as naclUtil from 'tweetnacl-util';
import { http } from 'viem';
import { createConfig } from 'wagmi';

// @ts-ignore: If importing 'nacl' directly, the built files will use .default instead
import {
EITHER_TYPE,
ELeft,
@@ -33,6 +37,7 @@ import {
UnsupportedChainException,
WrongNetworkException,
WrongParamFormat,
LITEVMChain,
} from '@lit-protocol/constants';
import {
isBrowser,
@@ -42,7 +47,7 @@ import {
validateSessionSig,
} from '@lit-protocol/misc';
import { getStorageItem } from '@lit-protocol/misc-browser';
import { AuthCallbackParams, AuthSig } from '@lit-protocol/types';
import { AuthSig, AuthCallbackParams, AuthProvider } from '@lit-protocol/types';

import LitConnectModal from '../connect-modal/modal';

@@ -52,6 +57,9 @@ if (globalThis && typeof globalThis.Buffer === 'undefined') {
globalThis.Buffer = BufferPolyfill;
}

type RPCUrls = Record<string, string>;
let litWCProvider: WalletConnectProvider | undefined;

/** ---------- Local Interfaces ---------- */
interface ConnectWeb3 {
chainId: number;
@@ -63,8 +71,6 @@ interface ConnectWeb3Result {
account: string | any;
}

type RPCUrls = Record<string, string>;

interface signAndSaveAuthParams {
web3: Web3Provider;
account: string;
@@ -73,6 +79,7 @@ interface signAndSaveAuthParams {
expiration: string;
uri?: string;
nonce: string;
provider: AuthProvider;
}

interface IABI {
@@ -103,6 +110,7 @@ interface SignMessageParams {
body: string;
web3: Web3Provider;
account: string;
provider: AuthProvider;
}

interface SignedMessage {
@@ -120,8 +128,7 @@ export type WALLET_ERROR_VALUES =

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

let litWCProvider: WalletConnectProvider | undefined;

let wagmiConfig: Config;
/**
*
* Convert chain hex id to chain name
@@ -280,6 +287,52 @@ export const getMustResign = (authSig: AuthSig, resources: any): boolean => {
return mustResign;
};

const getWagmiProvider = async (
chainId: number,
walletConnectProjectId?: string
) => {
const chain = Object.values(LIT_CHAINS).find((c) => c.chainId === chainId);
if (!chain) {
throw new Error(`Chain ID ${chainId} not supported`);
}

const litChainToWagmiChain = (litChain: LITEVMChain) => ({
id: litChain.chainId,
name: litChain.name,
network: litChain.name.toLowerCase(),
nativeCurrency: {
name: litChain.name,
symbol: litChain.symbol,
decimals: litChain.decimals,
},
rpcUrls: {
default: { http: litChain.rpcUrls },
public: { http: litChain.rpcUrls },
},
});

const litChain = litChainToWagmiChain(chain);

const config = createConfig({
chains: [litChain],
transports: {
[litChain.id]: http(litChain.rpcUrls.default.http[0]),
},
connectors: [
injected(),
...(walletConnectProjectId
? [
walletConnect({
projectId: walletConnectProjectId,
}),
]
: []),
],
});

return config;
};

/**
*
* Get RPC Urls in the correct format
@@ -311,13 +364,64 @@ export const getRPCUrls = (): RPCUrls => {

/**
* @browserOnly
* Connect to web 3
* Connect to web 3 using wagmi as provider
*
* @param { connectWeb3WithWagmi }
*
* @return { Promise<ConnectWeb3Result> } web3, account
*/
export const connectWeb3WithWagmi = async ({
chainId = 1,
walletConnectProjectId,
}: ConnectWeb3): Promise<ConnectWeb3Result> => {
// -- check if it's nodejs
if (isNode()) {
log('connectWeb3 is not supported in nodejs.');
return { web3: null, account: null };
}

log('getting provider via wagmi');

const config = await getWagmiProvider(chainId, walletConnectProjectId);
wagmiConfig = config;

const result = await wagmiConnect(config, {
connector: config.connectors[0],
chainId,
});

log('got provider');
if (!result) {
throw new Error('Failed to connect wallet');
}

const walletClient = await getWalletClient(config);

if (!walletClient) {
throw new Error('No wallet client found');
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - Create Web3Provider from wallet client
const web3 = new Web3Provider(walletClient);

log('listing accounts');
const accounts = await web3.listAccounts();
log('accounts', accounts);
const account = ethers.utils.getAddress(accounts[0]);

return { web3, account };
};

/**
* @browserOnly
* Connect to web 3 using lit connect modal as provider
*
* @param { ConnectWeb3 }
* @param { connectWeb3WithLitConnectModal }
*
* @return { Promise<ConnectWeb3Result> } web3, account
*/
export const connectWeb3 = async ({
export const connectWeb3WithLitConnectModal = async ({
chainId = 1,
walletConnectProjectId,
}: ConnectWeb3): Promise<ConnectWeb3Result> => {
@@ -393,21 +497,20 @@ export const connectWeb3 = async ({
*
* @return { void }
*/
export const disconnectWeb3 = (): void => {
export const disconnectWeb3 = async (): Promise<void> => {
if (isNode()) {
log('disconnectWeb3 is not supported in nodejs.');
return;
}

// @ts-ignore
if (isBrowser() && litWCProvider) {
if (isBrowser()) {
try {
litWCProvider.disconnect();
if (litWCProvider) {
litWCProvider.disconnect();
} else {
await wagmiDisconnect(wagmiConfig);
}
} catch (err) {
log(
'Attempted to disconnect global WalletConnectProvider for lit-connect-modal',
err
);
log('Error disconnecting wallet:', err);
}
}

@@ -435,6 +538,7 @@ export const checkAndSignEVMAuthMessage = async ({
uri,
walletConnectProjectId,
nonce,
provider = AuthProvider.Wagmi,
}: AuthCallbackParams): Promise<AuthSig> => {
// -- check if it's nodejs
if (isNode()) {
@@ -469,10 +573,24 @@ export const checkAndSignEVMAuthMessage = async ({
const selectedChain = LIT_CHAINS[chain];
const expirationString = expiration ?? getDefaultExpiration();

const { web3, account } = await connectWeb3({
chainId: selectedChain.chainId,
walletConnectProjectId,
});
let web3: Web3Provider | undefined;
let account: string | undefined;

if (provider === AuthProvider.Wagmi) {
({ web3, account } = await connectWeb3WithWagmi({
chainId: selectedChain.chainId,
walletConnectProjectId,
}));
} else {
throw new Error('Invalid provider');
}

if (!web3) {
throw new Error('Web3Provider is undefined');
}
if (!account) {
throw new Error('Account is undefined');
}

log(`got web3 and account: ${account}`);

@@ -508,7 +626,7 @@ export const checkAndSignEVMAuthMessage = async ({

// -- 4. case: (current chain id is NOT equal to selected chain) AND is set to switch chain
if (currentChainIdOrError.result !== selectedChainId && switchChain) {
const provider = web3.provider as any;
const provider = web3?.provider as any;

// -- (case) if able to switch chain id
try {
@@ -573,6 +691,7 @@ export const checkAndSignEVMAuthMessage = async ({
expiration: expirationString,
uri,
nonce,
provider,
});

authSigOrError = {
@@ -619,6 +738,7 @@ export const checkAndSignEVMAuthMessage = async ({
expiration: expirationString,
uri,
nonce,
provider,
});
log('7. authSig:', authSig);

@@ -635,6 +755,7 @@ export const checkAndSignEVMAuthMessage = async ({
expiration: expirationString,
uri,
nonce,
provider,
});
}
log('8. mustResign:', mustResign);
@@ -659,6 +780,7 @@ export const checkAndSignEVMAuthMessage = async ({
expiration: expirationString,
uri,
nonce,
provider,
});
}

@@ -677,6 +799,7 @@ const _signAndGetAuth = async ({
expiration,
uri,
nonce,
provider,
}: signAndSaveAuthParams): Promise<AuthSig> => {
await signAndSaveAuthMessage({
web3,
@@ -686,6 +809,7 @@ const _signAndGetAuth = async ({
expiration,
uri,
nonce,
provider,
});

const authSigOrError = getStorageItem(LOCAL_STORAGE_KEYS.AUTH_SIGNATURE);
@@ -725,6 +849,7 @@ export const signAndSaveAuthMessage = async ({
expiration,
uri,
nonce,
provider,
}: signAndSaveAuthParams): Promise<AuthSig> => {
// check if it's nodejs
if (isNode()) {
@@ -765,6 +890,7 @@ export const signAndSaveAuthMessage = async ({
body,
web3,
account: formattedAccount,
provider,
});

// -- 3. prepare auth message
@@ -810,6 +936,7 @@ export const signMessage = async ({
body,
web3,
account,
provider,
}: SignMessageParams): Promise<SignedMessage> => {
// check if it's nodejs
if (isNode()) {
@@ -823,7 +950,12 @@ export const signMessage = async ({
// -- validate
if (!web3 || !account) {
log(`web3: ${web3} OR ${account} not found. Connecting web3..`);
const res = await connectWeb3({ chainId: 1 });
let res;
if (provider === AuthProvider.Wagmi) {
res = await connectWeb3WithWagmi({ chainId: 1 });
} else {
res = await connectWeb3WithLitConnectModal({ chainId: 1 });
}
web3 = res.web3;
account = res.account;
}
40 changes: 36 additions & 4 deletions packages/auth-helpers/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
# Quick Start
# Auth Helpers

This submodule manages permissions and capabilities related to accessing specific resources on the blockchain. It utilizes features from the 'siwe' and 'siwe-recap' libraries to verify and handle data, allowing users to encode and decode session capabilities, add proofs and attenuations (specific resource permissions), and verify whether certain capabilities for a resource are supported. It also provides the ability to add capabilities to 'siwe' messages and provides methods specifically tailored to the LIT protocol, enabling adding and verifying capabilities for specific LIT resources.
Advanced authentication utilities for managing blockchain resource permissions and capabilities within the Lit Protocol ecosystem. Built on top of SIWE (Sign-In with Ethereum) and SIWE-RECAP for robust authentication flows.

### node.js / browser
## Installation

```
```bash
yarn add @lit-protocol/auth-helpers
```

## Quick Start

```typescript
import {
encodeSessionCapabilities,
verifyCapabilities,
} from '@lit-protocol/auth-helpers';

// Encode session capabilities
const encoded = await encodeSessionCapabilities(capabilities);

// Verify resource capabilities
const isValid = await verifyCapabilities(resource, capabilities);
```

## Key Features

- Session capability management
- SIWE integration and extensions
- Resource permission handling
- Proof and attestation support
- Custom capability verification
- Lit Protocol-specific methods

## Core Functionality

- Capability Encoding/Decoding: Manage session permissions
- Resource Verification: Check access rights
- SIWE Message Enhancement: Add capability information
- Permission Management: Handle resource access
- Proof System: Manage attestations and verifications
3 changes: 3 additions & 0 deletions packages/constants/src/index.ts
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@ export * from './lib/errors';
// ----------- Utils -----------
export * from './lib/utils/utils';

// ----------- Types -----------
export * from './lib/constants/types';

// ----------- ABIs -----------
import * as ABI_ERC20 from './lib/abis/ERC20.json';

32 changes: 29 additions & 3 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
# core
# Core

This library was generated with [Nx](https://nx.dev).
This package provides foundational utilities and interfaces that power the core functionalities of the Lit Protocol SDK. It includes essential data structures, business logic, and shared configurations that other packages build upon.

## Installation

```bash
yarn add @lit-protocol/core
```

## Quick Start

```typescript
import { LitCore } from '@lit-protocol/core';

// Initialize core functionality
const litCore = new LitCore();

// Use core utilities
await litCore.connect();
```

## Key Features

- Core data structures and interfaces
- Shared configurations and constants
- Base classes for Lit Protocol functionality
- Essential utility functions
- Type definitions for core components

## Building

Run `nx build core` to build the library.

## Running unit tests
## Testing

Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
40 changes: 36 additions & 4 deletions packages/crypto/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
# Quick Start
# Crypto

The crypto.ts file in the Lit SDK handles cryptographic operations, including the generation, import, encryption and decryption of keys, as well as management of cryptographic shares using BLS and ECDSA schemes.
A comprehensive cryptographic toolkit for the Lit Protocol SDK that handles secure key operations, encryption/decryption, and advanced cryptographic schemes.

### node.js / browser
## Installation

```
```bash
yarn add @lit-protocol/crypto
```

## Quick Start

```typescript
import { generateSessionKeyPair, encrypt } from '@lit-protocol/crypto';

// Generate a new key pair
const keyPair = await generateSessionKeyPair();

// Encrypt data with public key and identity param
const encryptedData = await encrypt(
keyPair.slice(2),
new Uint8Array([1, 2, 3]),
new Uint8Array([4, 5, 6])
);
```

## Key Features

- Private key generation and management
- BLS and ECDSA cryptographic schemes
- Secure key import/export
- Data encryption and decryption
- Cryptographic share management
- Signature generation and verification

## Supported Operations

- Key Generation: Create secure cryptographic keys
- Encryption/Decryption: Protect sensitive data
- Share Management: Handle distributed key shares
- Signature Operations: Generate and verify cryptographic signatures
29 changes: 14 additions & 15 deletions packages/lit-auth-client/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# lit-auth-client
# Lit Auth Client

`lit-auth-client` makes it easy to manage PKP authentication with Lit Protocol. This library offers convenient classes for social logins, Ethereum wallet sign-ins, and minting and fetching of PKPs linked to auth methods.
A comprehensive authentication client for managing PKP (Programmable Key Pair) authentication with Lit Protocol. This package simplifies the integration of various authentication methods including social logins and Ethereum wallet sign-ins.

## 📜 API Reference

Check out the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/lit_auth_client_src.html).

## 📦 Installation

Get started by installing the package:
## Installation

```bash
yarn add @lit-protocol/lit-auth-client
```

## 🙌 Contributing
## Quick Start

This library was generated with [Nx](https://nx.dev).
See the lit-pkp-auth-demo [here](https://github.com/LIT-Protocol/lit-pkp-auth-demo/blob/8f9e301e82e655b28fe9ab767ad3778bfe74701d/src/utils/lit.ts#L75-L85)

### Building
## Key Features

Run `nx build lit-auth-client` to build the library.
- Social login integration
- Ethereum wallet authentication
- PKP minting and management
- Auth method linking
- Secure token handling
- Multiple provider support

### Running unit tests
## Documentation

Run `nx test lit-auth-client` to execute the unit tests via [Jest](https://jestjs.io).
For detailed API documentation, visit the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/lit_auth_client_src.html).
4 changes: 1 addition & 3 deletions packages/lit-node-client-nodejs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Getting Started

This `LitNodeClientNodeJs` is created solely to run on Node.js.

The usual `checkAndSignAuthMessage` is not included in this package, so you need to add it manually to the constructor if you decide to use it on a browser, or with any custom auth callback.
This package provides a Node.js-specific implementation of the Lit Protocol client, enabling server-side applications to interact with the Lit network. It offers optimized Node.js performance while maintaining all core Lit Protocol functionality, excluding browser-specific authentication which can be manually added if needed.

```js
import * as LitJsSdkNodeJs from '@lit-protocol/lit-node-client-nodejs';
31 changes: 27 additions & 4 deletions packages/lit-node-client/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# Quick Start
# Lit Node Client

This module is the main module of this monorepo. It sets a default authentication callback using the `checkAndSignAuthMessage` function from the auth-browser submodule, which is designed to work in both browser and Node.js environments, facilitating interaction with Lit nodes.
This module is the main interface for interacting with the Lit Protocol network. It provides a robust client implementation that handles network communication, authentication, and node interactions in both browser and Node.js environments.

### node.js / browser
## Installation

```
```bash
yarn add @lit-protocol/lit-node-client
```

## Quick Start

```typescript
import { LitNodeClient } from '@lit-protocol/lit-node-client';

// Initialize the client
const client = new LitNodeClient({
litNetwork: 'datil',
});

// Connect to the network
await client.connect();
```

## Key Features

- Seamless authentication with Lit nodes
- Default authentication callback using `checkAndSignAuthMessage`
- Cross-platform support (browser and Node.js)
- Network connection management
- Secure node communication
- Automatic request handling and retries
2 changes: 1 addition & 1 deletion packages/logger/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# logger

This library was generated with [Nx](https://nx.dev).
This package provides a centralized logging utility for the Lit Protocol SDK, offering structured logging capabilities across all packages. It enables consistent log formatting, level-based filtering, and standardized error reporting throughout the Lit Protocol ecosystem.

## Building

1 change: 1 addition & 0 deletions packages/logger/src/lib/logger.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { version, LOG_LEVEL, LOG_LEVEL_VALUES } from '@lit-protocol/constants';
import { hashMessage } from 'ethers/lib/utils';
export { LOG_LEVEL };

export { LOG_LEVEL };
export enum LogLevel {
OFF = -1,
ERROR = 0,
2 changes: 1 addition & 1 deletion packages/nacl/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quick Start

re-export of https://www.npmjs.com/package/nacl
This package provides essential cryptographic operations for the Lit Protocol by re-exporting TweetNaCl.js (https://www.npmjs.com/package/nacl). It offers a lightweight implementation of the NaCl (pronounced "salt") cryptography library, enabling secure encryption, decryption, and digital signatures across the Lit Protocol ecosystem.

### node.js / browser

55 changes: 38 additions & 17 deletions packages/pkp-base/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
# Quick Start
# PKP Base

This submodule defines a PKPBase class, providing shared wallet functionality for PKP signers, responsible for managing public key compression, initializing and connecting to the LIT node, running LIT actions, and offering debug functions for logging and error handling.
A foundational package providing shared wallet functionality for PKP (Programmable Key Pair) signers in the Lit Protocol ecosystem. This package manages public key operations, LIT node connections, and action execution.

| Method/Property | Description |
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `compressPubKey(pubKey: string)` | Compresses a provided public key |
| `setUncompressPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the uncompressed public key and its buffer representation |
| `setCompressedPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the compressed public key and its buffer representation |
| `setLitAction(prop: PKPBaseProp)` | Sets the Lit action to be executed by the LitNode client |
| `setLitActionJsParams<CustomType extends T = T>(params: CustomType)` | Sets the value of the `litActionJsParams` property to the given params object |
| `createAndSetSessionSigs(sessionParams: GetSessionSigsProps)` | Creates and sets the session sigs and their expiration |
| `init()` | Initializes the PKPBase instance by connecting to the LIT node |
| `runLitAction(toSign: Uint8Array, sigName: string)` | Runs the specified Lit action with the given parameters |
| `ensureLitNodeClientReady()` | Ensures that the LitNode client is ready for use |
| `log(...args: any[])` | Logs the provided arguments to the console, but only if debugging is enabled |
## Installation

### node.js / browser

```
```bash
yarn add @lit-protocol/pkp-base
```

## Quick Start

```typescript
import { PKPBase } from '@lit-protocol/pkp-base';

// Initialize PKP Base
const pkpBase = new PKPBase({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
});

// Connect to LIT node
await pkpBase.init();

// Run LIT action
const signature = await pkpBase.runLitAction(dataToSign, 'sign');
```

## Key Features

- Public key compression and management
- LIT node connection handling
- Session signature management
- LIT action execution
- Debug logging capabilities

## Core Methods

| Method | Description |
| ---------------- | ---------------------------------- |
| `init()` | Initialize and connect to LIT node |
| `runLitAction()` | Execute LIT actions |
| `runSign()` | Signs a message |
48 changes: 44 additions & 4 deletions packages/pkp-cosmos/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
# PKPCosmos
# PKP Cosmos

The `PKPCosmosWallet` class is a specialized wallet for the Cosmos blockchain, based on the `DirectSecp256k1HdWallet` class from the `@cosmjs/proto-signing` library. This class implements the `OfflineDirectSigner` and `PKPClientHelpers` interfaces. The wallet can generate its own Bech32 address (address), manage account data (`getAccounts`), and sign transactions (`signDirect`) with the private key using a LIT node client. It can also create a SigningStargateClient instance (`getClient`), prepare transaction data (formSendTx), and sign a transaction following the SigningStargateClient.sign method (`sign`). The class supports the customization of the Cosmos RPC URL (`rpc`) and the Bech32 address prefix (`addressPrefix`).
A specialized wallet implementation for the Cosmos blockchain ecosystem using Lit Protocol's PKP (Programmable Key Pair) technology. Built on top of `@cosmjs/proto-signing`, this package enables secure transaction signing and account management through Lit nodes.

# Getting Started
## Installation

```
```bash
yarn add @lit-protocol/pkp-cosmos
```

## Quick Start

```typescript
import { PKPCosmosWallet } from '@lit-protocol/pkp-cosmos';

// Initialize wallet
const wallet = new PKPCosmosWallet({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
addressPrefix: 'cosmos',
});

// Get wallet address
const address = await wallet.getAddress();

// Sign transaction
const signedTx = await wallet.signDirect(address, {
bodyBytes: tx.bodyBytes,
authInfoBytes: tx.authInfoBytes,
chainId: chainId,
});
```

## Key Features

- Bech32 address generation
- Account data management
- Transaction signing via LIT nodes
- SigningStargateClient integration
- Customizable RPC endpoints
- Flexible address prefix support

## Core Functionality

- Address Generation: Create Cosmos blockchain addresses
- Transaction Management: Sign and prepare transactions
- Client Integration: Create SigningStargateClient instances
- Account Operations: Manage account data and balances
- Network Configuration: Customize RPC URLs and prefixes
52 changes: 44 additions & 8 deletions packages/pkp-ethers/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
# Getting started
# PKP Ethers

This module presents a modified version of `new ethers.Wallet()`, known as `PKPEthersWallet`. Unlike its counterpart, `PKPEthersWallet` does not store private keys nor does it support the creation of random wallets.
A specialized Ethereum wallet implementation using Lit Protocol's PKP (Programmable Key Pair) technology, built as an extension of ethers.js Wallet. This package provides secure transaction signing and account management through Lit nodes without storing private keys locally.

Despite these differences, it retains the ability to sign and send transactions, process JSON requests, retrieve balance and transaction count, among other functionalities, just like a standard ethers.js Wallet instance.
## Installation

API: https://docs.ethers.org/v4/api-wallet.html

```
```bash
yarn add @lit-protocol/pkp-ethers ethers
```

More info here:
https://github.com/LIT-Protocol/pkp-ethers/tree/master/packages/wallet
## Quick Start

```typescript
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';

// Initialize wallet
const wallet = new PKPEthersWallet({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
});

// Get wallet address
const address = await wallet.getAddress();

// Sign transaction
const signedTx = await wallet.signTransaction({
to: recipient,
value: ethers.utils.parseEther('0.1'),
});
```

## Key Features

- Secure transaction signing via LIT nodes
- Full ethers.js Wallet compatibility
- JSON-RPC request handling
- Balance and nonce management
- Gas estimation support
- Message signing capabilities

## Core Functionality

- Transaction Management: Sign and send transactions
- Account Operations: Get balances and transaction counts
- Message Signing: Sign messages and typed data
- Network Integration: Connect to any EVM network
- Gas Handling: Estimate and manage gas costs

For detailed API documentation, visit:
https://docs.ethers.org/v4/api-wallet.html
50 changes: 35 additions & 15 deletions packages/pkp-walletconnect/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
# pkp-walletconnect
# PKP WalletConnect

`pkp-walletconnect` wraps [`@walletconnect/web3wallet`](https://docs.walletconnect.com/2.0/web/web3wallet/wallet-usage) to provide base functionality needed to pair PKPs to dApps, approve and reject session proposals, and respond to session requests. This library is intended to be used with `pkp-client`.
A WalletConnect integration for Lit Protocol's PKP (Programmable Key Pair) system, enabling secure dApp connections and session management. This package wraps WalletConnect's Web3Wallet to provide seamless PKP integration with decentralized applications.

## 📜 API Reference

Check out the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/pkp_walletconnect_src.html).

## 📦 Installation

Get started by installing the package:
## Installation

```bash
yarn add @lit-protocol/pkp-walletconnect
```

## 🙌 Contributing
## Quick Start

```typescript
import { PKPWalletConnect } from '@lit-protocol/pkp-walletconnect';

// Initialize WalletConnect client
const client = new PKPWalletConnect();

// Handle session proposals
client.on('session_proposal', async (proposal) => {
const approved = await client.approveSession(proposal);
});

// Handle session requests
client.on('session_request', async (request) => {
const response = await client.respondToRequest(request);
});
```

This library was generated with [Nx](https://nx.dev).
## Key Features

### Building
- WalletConnect v2.0 integration
- dApp pairing management
- Session proposal handling
- Request/response management
- Multi-chain support
- Event handling system

Run `nx build pkp-walletconnect` to build the library.
## Core Functionality

### Running unit tests
- Session Management: Handle dApp connections
- Request Processing: Respond to session requests
- Pairing: Manage PKP-dApp pairings
- Event Handling: Subscribe to WalletConnect events
- Chain Configuration: Support multiple blockchains

Run `nx test pkp-walletconnect` to execute the unit tests via [Jest](https://jestjs.io).
For detailed API documentation, visit the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/pkp_walletconnect_src.html).
40 changes: 37 additions & 3 deletions packages/types/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
# Types

This submodule exports various interfaces & types related to Lit Protocol. eg. access control conditions, chain properties, JSON requests, auth statuses, wallet provider options, etc.
This package provides comprehensive TypeScript type definitions for the entire Lit Protocol ecosystem. It exports interfaces and types that ensure type safety and provide excellent IDE support across all Lit Protocol packages.

# Getting Started
## Installation

```
```bash
yarn add @lit-protocol/types
```

## Quick Start

```typescript
import {
AccessControlConditions,
ChainProperties,
AuthStatus,
WalletProvider,
} from '@lit-protocol/types';

// Use types in your code
const conditions: AccessControlConditions = {
// ... your conditions
};
```

## Available Types

- Access Control Conditions: Define access rules
- Chain Properties: Blockchain-specific configurations
- JSON Request/Response: Network communication types
- Authentication: Auth status and provider types
- Wallet Providers: Supported wallet options
- Node Configuration: Lit node setup types
- Protocol Interfaces: Core protocol definitions

## Benefits

- Full TypeScript support
- Enhanced code completion
- Compile-time type checking
- Better development experience
- Consistent type definitions across packages
10 changes: 10 additions & 0 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
@@ -59,6 +59,11 @@ export interface AuthSig {
algo?: string;
}

// FIXME: no enum
export enum AuthProvider {
Wagmi = 'wagmi',
}

export interface AuthCallbackParams extends LitActionSdkParams {
/**
* The serialized session key pair to sign. If not provided, a session key pair will be fetched from localStorge or generated.
@@ -101,6 +106,11 @@ export interface AuthCallbackParams extends LitActionSdkParams {
walletConnectProjectId?: string;

resourceAbilityRequests?: LitResourceAbilityRequest[];

/**
* The provider to use for the auth callback. Defaults to `litConnectModal`.
*/
provider?: AuthProvider;
}

/** ---------- Crypto ---------- */
4 changes: 2 additions & 2 deletions packages/wasm/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# WASM

Core lit utilities implemented in `Rust` and compiled to `WebAssembly` through `wasm-pack` implementations within this package wrap the compiled implementations from `rust` and provides functionality for converting the compiled artifact to a `base64` encoded string for binding to the generated bridge. the functionality contained within this package exposes the functinoality provided from the wasm utilities.
This package provides high-performance cryptographic operations for the Lit Protocol by implementing core utilities in Rust and compiling them to WebAssembly. It enables efficient cross-platform execution of critical cryptographic functions while maintaining security and performance. The package handles the compilation process through wasm-pack and provides JavaScript bindings for seamless integration.

For information on implementations see the [rust](./rust/README.md) directory.
For detailed implementation information, see the [rust](./rust/README.md) directory.

### Building

978 changes: 921 additions & 57 deletions yarn.lock

Large diffs are not rendered by default.