Skip to content

⭐️ LIT-4211 - V8 auth and lit client refactor #800

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

Draft
wants to merge 71 commits into
base: feat/naga-fix-bls-wasm-cleanup
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
163e083
feat(networks): LIT-4101 - Define initial package structure/stubs for…
MaximusHaximus Feb 10, 2025
23958f6
feat(auth): LIT-4211 - Add initial `auth` package
MaximusHaximus Feb 10, 2025
ab96720
feat(auth): LIT-4211 - Add initial `auth` package
MaximusHaximus Feb 11, 2025
829efbd
chore(lit-auth-client): LIT-4211 - eslint --fix and resolve tslint er…
MaximusHaximus Feb 11, 2025
c943535
feat(auth): LIT-4211 - Migrate `lit-auth-client` providers and relaye…
MaximusHaximus Feb 11, 2025
4932528
feat(auth): LIT-4211 - Define @lit-protocol/auth package
MaximusHaximus Feb 13, 2025
5c8dd30
feat(auth): LIT-4211 - Collapse `lit-node-client-nodejs` and `lit-nod…
MaximusHaximus Feb 13, 2025
a3e92d5
feat(auth): LIT-4211 - Initial stub for `lit-client` package structure
MaximusHaximus Feb 13, 2025
2610173
Merge remote-tracking branch 'origin/feat/naga-fix-bls-wasm-cleanup' …
FedericoAmura Feb 26, 2025
527e07a
feat: replace logger package and log in misc with pino
FedericoAmura Feb 26, 2025
cfc3c34
feat: remove misc package with a lot of zod schemas, helper functions…
FedericoAmura Mar 3, 2025
c99d1f0
feat: changes in lit node client to remove misc, missed in previous c…
FedericoAmura Mar 4, 2025
21b33f8
feat: logger fixes
FedericoAmura Mar 6, 2025
3d2dc98
fix: remove unused stuff and type fixes
FedericoAmura Mar 6, 2025
4e2d35c
fix: localStorage.spec.ts
FedericoAmura Mar 6, 2025
fc17d03
fix: assemble-most-common-response when property types differ
FedericoAmura Mar 6, 2025
a2ca33e
feat: replace uint8arrays pkg with Buffer
FedericoAmura Mar 6, 2025
2eec105
feat: replace nacl pkg with noble curves
FedericoAmura Mar 6, 2025
a6fd6b9
feat: remove IEither pattern
FedericoAmura Mar 6, 2025
f1cc256
fix: linting
FedericoAmura Mar 6, 2025
a45c133
fix: run unit test for all packages
FedericoAmura Mar 7, 2025
bc87787
feat: unify localstorage usage in misc-browser
FedericoAmura Mar 7, 2025
fc73d7f
feat: lit errors
FedericoAmura Mar 7, 2025
e9cf2db
feat: remove full erc20 abi
FedericoAmura Mar 7, 2025
e4d66c9
feat: remove encryption package
FedericoAmura Mar 7, 2025
a36466b
feat: errors in relay
FedericoAmura Mar 7, 2025
9a7a6bc
feat(local-dev): add gen:context command
Ansonhkg Mar 12, 2025
235535d
feat(ai): add context for AI and human 🧍‍♂️🤝🤖
Ansonhkg Mar 12, 2025
b4e9f05
feat(WIP->network&LitChainClient): copy/paste from https://github.com…
Ansonhkg Mar 12, 2025
81d3d95
feat(local-develop): update context
Ansonhkg Mar 12, 2025
d078e74
feat(networks): add shared directory
Ansonhkg Mar 12, 2025
2d136a8
feat(package.json): add bs58, elysia, and wagmi
Ansonhkg Mar 12, 2025
a8a3b82
chore: update yarn.lock
Ansonhkg Mar 12, 2025
c53ac9a
fix(networks/schemas): fix import paths
Ansonhkg Mar 12, 2025
68740c8
chore: remove unused `LIT_CONTRACT_NAME`
Ansonhkg Mar 12, 2025
2dd5ea2
fmt
Ansonhkg Mar 12, 2025
af1800d
chore: remove unused `callWithSeparatedSteps`, though this is a usefu…
Ansonhkg Mar 12, 2025
401b30d
fix(networks/LitChainClient): export util apis
Ansonhkg Mar 12, 2025
f50fca9
fmt
Ansonhkg Mar 12, 2025
50b9857
feat: abstract pino sdk logger singleton in previous logger package
FedericoAmura Mar 12, 2025
2b63d1e
feat: replace all javascript private properties with typescript priva…
FedericoAmura Mar 12, 2025
eb930e8
fix: remove removed tests references
FedericoAmura Mar 12, 2025
2c703e8
fix(linter): pkp, pricing and staking directories
Ansonhkg Mar 12, 2025
7e9628f
fix(linter): permissions directory
Ansonhkg Mar 12, 2025
27d1e9e
feat: missing logger migrations
FedericoAmura Mar 13, 2025
cc83252
feat: make event listener use an action repository so action definiti…
FedericoAmura Mar 13, 2025
0abe5c1
fix(linter): fixed imports for permissions directory
Ansonhkg Mar 13, 2025
1c13933
fix(linter): fix vNaga imports for higher level apis
Ansonhkg Mar 13, 2025
405a43d
feat(.gitignore): add `.cursor/rules` to ignore list, we can manually…
Ansonhkg Mar 13, 2025
694425c
fix(linter): vNaga imports for higher level apis
Ansonhkg Mar 13, 2025
5ef1e6a
fix(createLitContracts): 😡 hacky types to fix ts7056 but it works
Ansonhkg Mar 13, 2025
2016736
fix: remove module level loggers that were not updated if sdk logger …
FedericoAmura Mar 13, 2025
14a0ede
feat: add custom actions doc for event listener state machines
FedericoAmura Mar 14, 2025
5652cad
feat(test): ⭐️ remove `Bun` specific imports, so that the tests can b…
Ansonhkg Mar 14, 2025
bcf22fa
chore(test): remove bun imports
Ansonhkg Mar 14, 2025
46b3954
feat(package.json): add `pino-pretty` dep
Ansonhkg Mar 17, 2025
51e0ee9
feat(wip/networks): add `vDatil` code but need to fix linter and impo…
Ansonhkg Mar 17, 2025
d38c96f
fix(vNaga): fmt
Ansonhkg Mar 17, 2025
0bfd471
fix(networks): fix NetworkContext to be an interface (without realmId…
Ansonhkg Mar 17, 2025
851ab40
fmt
Ansonhkg Apr 3, 2025
b3205cb
fix(test): import paths
Ansonhkg Apr 3, 2025
f731a67
fix(.ts): import paths
Ansonhkg Apr 3, 2025
a08db3e
fmt
Ansonhkg Apr 3, 2025
edb6ab7
fmt
Ansonhkg Apr 3, 2025
aaf8c5f
Merge pull request #807 from LIT-Protocol/feat/lit-chain-manager-and-…
Ansonhkg Apr 3, 2025
9b63fd8
Merge branch 'LIT-4211-auth-refactor' into feature/lit-4238-clean-unn…
Ansonhkg Apr 3, 2025
a3041a5
chore: update yarn.lock
Ansonhkg Apr 3, 2025
f1d03ce
Merge pull request #802 from LIT-Protocol/feature/lit-4238-clean-unne…
Ansonhkg Apr 3, 2025
5407b80
fix(build): datil network module
Ansonhkg Apr 18, 2025
3918cb2
fmt
Ansonhkg Apr 18, 2025
f57c683
Merge pull request #822 from LIT-Protocol/feature/lit-4373-js-sdk-nag…
Ansonhkg Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 35 additions & 0 deletions .ctx/generate-local-network-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generating Local Network Context for Lit Protocol

The Lit network contexts, which include smart contract addresses and ABIs, typically come from the `@lit-protocol/contracts` package (a separate repository at https://github.com/LIT-Protocol/lit-contracts/). However, these contexts are designed for established networks.

## Local Network Setup

For local development (running Lit nodes on your machine), you need to generate a `networkContext.json` file in the `lit-assets` directory. This is typically done by running the deploy script after starting your local Anvil chain.

## Version Compatibility Changes

In version 7 or earlier, you could simply copy and paste the `networkContext.json` file, and it would work when setting the network to `custom` when running with Tinny (E2E test suite).

However, in version 8, we've optimised by removing redundant and unused ABIs from the JSON file and enforced strongly typed ABIs. This optimization introduced an additional conversion layer that extracts only the necessary ABI methods, which must be run manually for local network contexts.

## Generating Custom Context

To generate the proper context:

1. Locate the `getCustomContext` file in the network-specific folder (in this case, `vNaga/naga-develop` folder)
2. Use the `generateSignaturesFromContext` helper function from the `@lit-protocol/contracts` repository

Here's an example of how to use this function:

```ts
import { generateSignaturesFromContext } from '@lit-protocol/contracts/custom-network-signatures';

await generateSignaturesFromContext({
jsonFilePath:
'/Users/anson/Projects/lit-assets/blockchain/contracts/networkContext.json', // in lit assets repo
networkName: 'naga-develop',
outputDir: './naga-develop-signatures',
useScriptDirectory: true,
callerPath: import.meta.url,
});
```
Empty file.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -77,4 +77,6 @@ local-tests/build
packages/wrapped-keys-lit-actions/src/generated

digest
generate-digest.ts
generate-digest.ts

.cursor/rules
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
"todo-tree.tree.scanMode": "workspace",
"conventionalCommits.scopes": [
"contracts-sdk",
"lit-node-client-nodejs",
"core",
"lit-node-client",
"core"
],
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2f7c47",
@@ -52,4 +52,4 @@
// ]
// }
// ]
}
}
59 changes: 29 additions & 30 deletions README.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -3,3 +3,22 @@ const crypto = require('crypto');
global.TextEncoder = require('util').TextEncoder;
global.TextDecoder = require('util').TextDecoder;
global.crypto = crypto;

if (!global.crypto.subtle) {
global.crypto.subtle = {
digest: async (algorithm, data) => {
const algo = algorithm.toLowerCase().replace('-', '');
const hash = crypto.createHash(algo);
hash.update(Buffer.from(data));
return hash.digest().buffer;
},
};
}

// If this is not included, you will get the following error when running it in Jest:
// (Error) Details: Request is not defined
// The problem is that Jest is running in a Node.js environment where the global Request API (part of the Fetch API) might not be available or properly configured. Bun, on the other hand, has this API built into its runtime by default, which is why it works.
const { default: fetch, Request, Response } = require('node-fetch');
global.fetch = fetch;
global.Request = Request;
global.Response = Response;
18 changes: 0 additions & 18 deletions local-tests/README.md
Original file line number Diff line number Diff line change
@@ -122,21 +122,3 @@ The `TinnyPerson` class encapsulates various functionalities to manage wallet op
| `createCapacityDelegationAuthSig(addresses)` | Mints a Capacity Credits NFT and creates an authentication signature for delegating capacity, which can be used to authorize other addresses to use the minted credits. |

##

# esbuild benchmark

```ts
// test-bundle-speed.ts
export const testBundleSpeed = async (devEnv: TinnyEnvironment) => {
const a = await import('@lit-protocol/lit-node-client');
const b = await import('@lit-protocol/contracts-sdk');
const c = await import('@lit-protocol/auth-helpers');
const d = await import('@lit-protocol/constants');
const e = await import('@lit-protocol/lit-auth-client');

console.log(a, b, c, d, e);
};
// ----------------
// Build time: 77ms
// ----------------
```
6 changes: 2 additions & 4 deletions local-tests/package.json
Original file line number Diff line number Diff line change
@@ -81,16 +81,14 @@
"synthetix-js": "^2.74.1",
"tslib": "^2.3.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"uint8arrays": "^4.0.3",
"@openagenda/verror": "^3.1.4",
"ipfs-unixfs-importer": "12.0.1",
"@solana/web3.js": "^1.95.3",
"bech32": "^2.0.0",
"pako": "^2.1.0",
"@lit-protocol/misc": "^7.0.0",
"@lit-protocol/lit-node-client": "^7.0.0",
"@lit-protocol/lit-auth-client": "^7.0.0",
"@lit-protocol/lit-node-client": "8.0.0-alpha.0",
"@lit-protocol/auth": "8.0.0-alpha.0",
"@lit-protocol/contracts": "^0.0.71"
}
}
Loading