From 7914ace74e8421e54fc6174d08d16b94930dd71a Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:09:27 +0100 Subject: [PATCH 1/7] chore(scripts): remove `auto-fix-deps` scripts --- nx.json | 7 +------ package.json | 5 ++--- packages/networks/project.json | 6 ------ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/nx.json b/nx.json index efc0a6520..ba8050d50 100644 --- a/nx.json +++ b/nx.json @@ -13,14 +13,9 @@ }, "targetDefaults": { "build": { - "dependsOn": ["auto-fix-deps", "^build"], + "dependsOn": ["^build"], "cache": true }, - "auto-fix-deps": { - "cache": true, - "inputs": ["{projectRoot}/src/**/*", "{projectRoot}/package.json"], - "outputs": ["{projectRoot}/package.json"] - }, "check-deps": { "executor": "nx:run-commands", "options": { diff --git a/package.json b/package.json index ae85b044b..e2917a1a3 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "scripts": { "reset": "bun unlink-all && rimraf dist node_modules doc tmp yarn-error.log yarn.lock package-lock.json bun.lockb learn-debug.log tmp .nx lit-auth-storage pkp-tokens lit-auth-local ./e2e/dist ./e2e/node_modules", "go": "bun run build && bun link-all", - "build": "bun unlink-all && bun scripts/auto-fix-deps.mjs && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier", - "build:affected": "bun scripts/auto-fix-deps.mjs && nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions", - "auto-fix-deps": "bun scripts/auto-fix-deps.mjs", + "build": "bun unlink-all && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier", + "build:affected": " nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions", "check-deps": "npx nx run-many --target=check-deps --exclude=wrapped-keys,wrapped-keys-lit-actions", "validate": "npm run check-deps && npm run build", "test:local": "node ./local-tests/build.mjs && dotenvx run --env-file=.env -- node ./local-tests/build/test.mjs", diff --git a/packages/networks/project.json b/packages/networks/project.json index 7204542e7..4cdbc19a7 100644 --- a/packages/networks/project.json +++ b/packages/networks/project.json @@ -21,12 +21,6 @@ "command": "depcheck" } }, - "auto-fix-deps": { - "executor": "nx:run-commands", - "options": { - "command": "echo 'Dependencies auto-fixed by global script'" - } - }, "lint": { "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], From 06e202ec4fbb25f6a04b451b5741f91a01f47762 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:10:15 +0100 Subject: [PATCH 2/7] chore(package): remove `gen:readme` script and associated file --- package.json | 1 - tools/scripts/gen-readme.mjs | 153 ----------------------------------- 2 files changed, 154 deletions(-) delete mode 100644 tools/scripts/gen-readme.mjs diff --git a/package.json b/package.json index e2917a1a3..56526ba8a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "publish:tinny": "cd ./local-tests && npm publish", "gen:local-network-context": "bun run packages/networks/src/networks/vNaga/envs/naga-local/scripts/00-generate-abi-signatures.ts", "gen:docs": "node ./tools/scripts/gen-doc.mjs", - "gen:readme": "node ./tools/scripts/gen-readme.mjs", "prettier": "npx nx format:write --all", "format:check": "npx nx format:check --all", "link-all": "for dir in packages/*/; do echo \"Linking in $dir\"; (cd \"$dir\" && bun link) || { echo \"ERROR: Failed to link in $dir\"; exit 1; }; done", diff --git a/tools/scripts/gen-readme.mjs b/tools/scripts/gen-readme.mjs deleted file mode 100644 index 240e8d1dd..000000000 --- a/tools/scripts/gen-readme.mjs +++ /dev/null @@ -1,153 +0,0 @@ -// #Usage: node tools/scripts/gen-readme.mjs - -// Read the file and replace between -// and with the package.json content -import { readFileSync, writeFileSync } from 'fs'; -import { join } from 'path'; -import { exit } from 'process'; -import { greenLog, listDirsRecursive, redLog } from './utils.mjs'; - -const TAG = process.env.TAG ? `/${process.env.TAG}` : ''; - -const readmePath = join('README.md'); -const readme = readFileSync(readmePath, 'utf8'); - -const badge = (lib, text) => { - let color = 'orange'; - - if (text === 'universal') { - color = '8A6496'; - } - if (text === 'bundled') { - color = '17224B'; - } - if (text === 'browser') { - color = 'E98869'; - } - - if (text === 'nodejs') { - color = '2E8B57'; - } - - return `![${lib}](https://img.shields.io/badge/-${text}-${color} "${lib}")`; -}; - -const getSize = (lib) => { - return `![](https://img.shields.io/bundlephobia/min/${lib})`; -}; - -const getNpm = (lib) => { - // return `npm`; - // return ``; - return ``; -}; - -const libs = (await listDirsRecursive('packages', false)).map((lib) => - lib.replace('packages/', '') -); - -// create rows to array -let universals = []; -let browsers = []; -let bundled = []; -let nodejs = []; - -libs.map((lib) => { - const pkg = JSON.parse(readFileSync(`packages/${lib}/package.json`, 'utf8')); - const { name, description, version, tags } = pkg; - - const _packagePath = 'https://github.com/LIT-Protocol/js-sdk/tree/master/'; - const _package = `[${name}](${_packagePath}packages/${lib})`; - - let _tag; - - try { - _tag = badge(lib, tags[0]); - } catch (e) { - redLog(`${name}/package.json doesn't have "tags" property`); - } - // const _size = getSize(name); - const _download = `${getNpm(name)}`; - - const content = `| ${_package} | ${_tag} | ${_download}`; - - if (tags[0] === 'universal') { - universals.push(content); - } - if (tags[0] === 'browser') { - browsers.push(content); - } - if (tags[0] === 'bundled') { - bundled.push(content); - } - if (tags[0] === 'nodejs') { - nodejs.push(content); - } -}); - -let rows = [...bundled, ...universals, ...browsers, ...nodejs]; -let mainModules = [ - '@lit-protocol/lit-node-client', - '@lit-protocol/lit-node-client-nodejs', -]; -let mainRows = []; -let otherRows = []; - -// separate the rows into main and others -rows.forEach((row) => { - const name = row.split('|')[1].trim(); - if (mainModules.some((module) => name.includes(module))) { - mainRows.push(row); - } else { - otherRows.push(row); - } -}); - -// sort main rows to have @lit-protocol/lit-node-client at the top -mainRows = mainRows.sort((a, b) => { - const aName = a.split('|')[1].trim(); - const bName = b.split('|')[1].trim(); - if (aName.includes('@lit-protocol/lit-node-client')) { - return -1; - } - if (bName.includes('@lit-protocol/lit-node-client')) { - return 1; - } - return 0; -}); - -const tables = { - headers: ['Package', 'Category', 'Download'], - mainRows: mainRows, - otherRows: otherRows, -}; - -// make table to github markdown -const table = (headers, rows) => { - const header = headers.join(' | '); - const divider = headers.map(() => '---').join(' | '); - const body = rows.join('\n'); - return ` -${header} -${divider} -${body} -`; -}; - -let mainContent = table(tables.headers, tables.mainRows); -let otherContent = - "If you're a tech-savvy user and wish to utilize only specific submodules that our main module relies upon, you can find individual packages listed below. This way, you can import only the necessary packages that cater to your specific use case::\n\n" + - table(tables.headers, tables.otherRows); - -// use regex to replace the content between the comments and -const newReadme = readme.replace( - /[\s\S]*/m, - `\n${mainContent}\n\n${otherContent}\n` -); - -// console.log(newReadme); - -writeFileSync(readmePath, newReadme, 'utf8'); -greenLog('šŸŽ‰ New README.md Generated!', true); - -exit(); From 42fed1945f222f07483cce0f7fe2f264fb88d177 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:14:38 +0100 Subject: [PATCH 3/7] chore(yarn): remove .yarnrc.yml configuration file --- .yarnrc.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .yarnrc.yml diff --git a/.yarnrc.yml b/.yarnrc.yml deleted file mode 100644 index 3186f3f07..000000000 --- a/.yarnrc.yml +++ /dev/null @@ -1 +0,0 @@ -nodeLinker: node-modules From e2dfe1fe59ca48a61603c4d0d412ffe16347e9c8 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:15:50 +0100 Subject: [PATCH 4/7] chore(examples): remove unused example files for EOA native auth flow and release verification --- examples/src/eoa-native-auth-flow.ts | 28 ---- examples/src/release-verification-example.ts | 144 ------------------- 2 files changed, 172 deletions(-) delete mode 100644 examples/src/eoa-native-auth-flow.ts delete mode 100644 examples/src/release-verification-example.ts diff --git a/examples/src/eoa-native-auth-flow.ts b/examples/src/eoa-native-auth-flow.ts deleted file mode 100644 index 271505bd8..000000000 --- a/examples/src/eoa-native-auth-flow.ts +++ /dev/null @@ -1,28 +0,0 @@ -export const eoaNativeAuthFlow = async () => { - const { init } = await import('./init'); - - const { myAccount, litClient, authManager } = await init(); - - // 1. Get the authenticator - const { ViemAccountAuthenticator } = await import('@lit-protocol/auth'); - - const authDataViemAcconut = await ViemAccountAuthenticator.authenticate( - myAccount - ); - - const authSig = JSON.parse(authDataViemAcconut.accessToken); - - console.log('āœ… authSig:', authSig); - - // 2. Authenticate the account - const authData = await ViemAccountAuthenticator.authenticate(myAccount); - console.log('āœ… authData:', authData); - - // 3a. Mint a PKP using your account. This is then owned by the account - // ā—ļø You will need to manually add permissions to the PKP before it can be used. - const mintedPkpWithEoa = await litClient.mintWithEoa({ - account: myAccount, - }); - - console.log('āœ… mintedPkpWithEoa:', mintedPkpWithEoa); -}; diff --git a/examples/src/release-verification-example.ts b/examples/src/release-verification-example.ts deleted file mode 100644 index 058a51402..000000000 --- a/examples/src/release-verification-example.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Release Verification Example - * - * This example demonstrates how to use the new release verification feature - * in the Lit Protocol SDK. This feature ensures that Lit nodes are running - * verified releases that are registered on-chain. - * - * The release verification process: - * 1. Extracts the release ID from the node attestation - * 2. Verifies the release ID format and subnet ID - * 3. Queries the on-chain release register contract through the network module - * 4. Verifies the release is active and matches the expected environment - * - * Architecture: - * - orchestrateHandshake() receives the network module and release config - * - Network module (naga-dev.module.ts) provides the release verification function - * - Crypto package performs only cryptographic verification and calls the provided function - * - * Usage: bun run examples/src/release-verification-example.ts - */ - -import { createLitClient } from '@lit-protocol/lit-client'; -import { ReleaseVerificationConfig } from '@lit-protocol/crypto'; - -async function main() { - console.log('šŸ” Starting Release Verification Example...\n'); - - try { - // Define release verification configuration - // This would typically come from your application's config - const releaseVerificationConfig: ReleaseVerificationConfig = { - // RPC URL for the blockchain where the release register contract is deployed - rpcUrl: 'https://chain-rpc.litprotocol.com/http', - - // Address of the release register contract - // This address would be provided by the Lit Protocol team - releaseRegisterContractAddress: - '0x1234567890123456789012345678901234567890', - - // Subnet ID that nodes should be running on - subnetId: 'test', // or 'prod' for production - - // Environment: 0 = test, 1 = prod - environment: 0, - }; - - console.log('šŸ”§ Release verification config:', releaseVerificationConfig); - - // Import the network configuration - const { nagaDev } = await import('@lit-protocol/networks'); - - // Initialize Lit client with release verification enabled - console.log('šŸ“± Initializing Lit client...'); - const litClient = await createLitClient({ - network: nagaDev, - - // Note: Release verification is now handled at the network module level - // The naga-dev module provides the verifyReleaseId function - // This gets called during handshake when attestation is enabled - }); - - console.log('āœ… Lit client initialized successfully!'); - - // The release verification happens automatically during the handshake process - // when attestation checking is enabled and release verification config is provided - // The flow is: - // 1. orchestrateHandshake receives releaseVerificationConfig and networkModule - // 2. checkSevSnpAttestation calls networkModule.getVerifyReleaseId() - // 3. Network module handles contract interaction and verification - - console.log( - 'šŸ” Release verification is integrated into the network module' - ); - console.log( - 'šŸ’” Contract verification is handled by the chain-aware network layer' - ); - - console.log('āœ… Example completed successfully!'); - } catch (error) { - console.error('āŒ Error:', error); - - if (error instanceof Error) { - console.error('Error details:', { - name: error.name, - message: error.message, - }); - } - - process.exit(1); - } -} - -// Additional example: Manual release verification using network module -async function manualReleaseVerificationExample() { - console.log('\nšŸ”¬ Manual Release Verification Example...\n'); - - // Example of manually calling the release verification function from the network module - const { nagaDev } = await import('@lit-protocol/networks'); - - // Get the release verification function from the network module - const verifyReleaseId = nagaDev.getVerifyReleaseId(); - - // Mock attestation data (in reality this comes from nodes) - const mockAttestation = { - noonce: 'base64-encoded-challenge', - data: { - RELEASE_ID: Buffer.from( - 'test-subnet-release-id-64-chars-long-unique-identifier-123', - 'utf8' - ).toString('base64'), - EXTERNAL_ADDR: Buffer.from('192.168.1.1:7470', 'utf8').toString('base64'), - }, - signatures: ['base64-signature'], - report: 'base64-report', - }; - - const releaseConfig: ReleaseVerificationConfig = { - rpcUrl: 'https://chain-rpc.litprotocol.com/http', - releaseRegisterContractAddress: - '0x1234567890123456789012345678901234567890', - subnetId: 'test', - environment: 0, - }; - - try { - // This would verify the release ID against the on-chain contract - await verifyReleaseId(mockAttestation as any, releaseConfig); - - console.log('āœ… Manual release verification passed!'); - } catch (error) { - console.log( - 'āŒ Manual release verification failed (expected with mock data):', - (error as Error).message - ); - } -} - -// Run the examples -main() - .then(() => manualReleaseVerificationExample()) - .catch((error) => { - console.error('āŒ Unexpected error:', error); - process.exit(1); - }); From c9fc0ad7b0ba8be4074e4a8991c458ab1cc14c16 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:16:07 +0100 Subject: [PATCH 5/7] chore(env): remove obsolete .env.ci file containing environment variables --- .env.ci | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .env.ci diff --git a/.env.ci b/.env.ci deleted file mode 100644 index b1e7e0b84..000000000 --- a/.env.ci +++ /dev/null @@ -1,19 +0,0 @@ -#Tinny ENV Vars -MAX_ATTEMTPS=1 -NETWORK=custom -DEBUG=true -WAIT_FOR_KEY_INTERVAL=3000 -TIME_TO_RELEASE_KEY=10000 -RUN_IN_BAND=true -RUN_IN_BAND_INTERVAL=5000 -NO_SETUP=false -USE_SHIVA=true -NETWORK_CONFIG=./networkContext.json -TEST_TIMEOUT=45000 - -#Shiva Client ENV Vars -STOP_TESTNET=false -TESTNET_MANAGER_URL=http://127.0.0.1:8000 -USE_LIT_BINARIES=true -LIT_NODE_BINARY_PATH=/usr/bin/lit_node -LIT_ACTION_BINARY_PATH=/usr/bin/lit_actions From d4e7375578488b992f7f11e216976b9f8f5d46ec Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:20:06 +0100 Subject: [PATCH 6/7] chore(lerna): remove unused lerna.json configuration file --- lerna.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lerna.json diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 1eba48fc7..000000000 --- a/lerna.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "useNx": true, - "useWorkspaces": true, - "version": "8.0.0-alpha.4" -} From c668c02ebb901df03c570808a2eafd4a53e5abee Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 21 Aug 2025 13:49:58 +0100 Subject: [PATCH 7/7] chore(package): remove unused `go` script and clean up documentation generation script --- package.json | 4 -- tools/scripts/gen-doc.mjs | 121 -------------------------------------- 2 files changed, 125 deletions(-) delete mode 100644 tools/scripts/gen-doc.mjs diff --git a/package.json b/package.json index 56526ba8a..8870077c2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "license": "MIT", "scripts": { "reset": "bun unlink-all && rimraf dist node_modules doc tmp yarn-error.log yarn.lock package-lock.json bun.lockb learn-debug.log tmp .nx lit-auth-storage pkp-tokens lit-auth-local ./e2e/dist ./e2e/node_modules", - "go": "bun run build && bun link-all", "build": "bun unlink-all && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier", "build:affected": " nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions", "check-deps": "npx nx run-many --target=check-deps --exclude=wrapped-keys,wrapped-keys-lit-actions", @@ -13,10 +12,7 @@ "test:unit": "npx nx run-many --target=test", "test:unit:watch": "npx nx run-many --target=test --watch", "show:affected": "npx nx show projects --affected --uncommitted", - "build:tinny": "node ./local-tests/build.mjs", - "publish:tinny": "cd ./local-tests && npm publish", "gen:local-network-context": "bun run packages/networks/src/networks/vNaga/envs/naga-local/scripts/00-generate-abi-signatures.ts", - "gen:docs": "node ./tools/scripts/gen-doc.mjs", "prettier": "npx nx format:write --all", "format:check": "npx nx format:check --all", "link-all": "for dir in packages/*/; do echo \"Linking in $dir\"; (cd \"$dir\" && bun link) || { echo \"ERROR: Failed to link in $dir\"; exit 1; }; done", diff --git a/tools/scripts/gen-doc.mjs b/tools/scripts/gen-doc.mjs deleted file mode 100644 index e136bd422..000000000 --- a/tools/scripts/gen-doc.mjs +++ /dev/null @@ -1,121 +0,0 @@ -// #Usage: node tools/scripts/gen-doc.mjs - -import { exit } from 'process'; -import { - greenLog, - listDirsRecursive, - readJsonFile, - runCommand, - writeJsonFile, - getArgs, - redLog, - createDirs, -} from './utils.mjs'; -import * as liveServer from 'live-server'; -import inquirer from 'inquirer'; - -const VERCEL_PROJECT = { - V5: 'prj_Xq6tl0JfFOmWlCLlMkh0B5rzFHoK', - V6: 'prj_Ed96nvLrMCQgjVN252BmnHD1kRy4', - V7: 'prj_87TpDb44hK5zKtny2fjcLcyND73Q', -}; - -const args = getArgs(); - -const FLAG = args[0]; -const VERCEL_ORG_ID = 'team_BYVnuWp5MA5ra1UCzHa2XsCD'; - -if (!FLAG) { - console.log('\n----- Available flags -----'); - console.log('1. --preview to open the docs in browser'); - console.log('2. --push to build & push the docs to vercel'); - console.log('\n'); -} - -async function selectProject() { - const { project } = await inquirer.prompt([ - { - type: 'list', - name: 'project', - message: 'Select the Vercel project to push to:', - choices: [ - { name: 'V5', value: VERCEL_PROJECT.V5 }, - { name: 'V6', value: VERCEL_PROJECT.V6 }, - { name: 'V7', value: VERCEL_PROJECT.V7 }, - ], - }, - ]); - return project; -} - -const TARGET = 'typedoc.json'; - -const jsonFile = await readJsonFile(TARGET); - -const dirs = (await listDirsRecursive('packages', false)).map( - (dir) => `./${dir}/src/index.ts` -); - -const onlyInterestedIn = [ - // './packages/access-control-conditions/src/index.ts', - // './packages/access-control-conditions-schemas/src/index.ts', - // './packages/auth/src/index.ts', - // './packages/auth-helpers/src/index.ts', - // './packages/auth-services/src/index.ts', - // './packages/constants/src/index.ts', - // './packages/crypto/src/index.ts', - './packages/lit-client/src/index.ts', - // './packages/logger/src/index.ts', - // './packages/networks/src/index.ts', - // './packages/schemas/src/index.ts', - // './packages/types/src/index.ts', - // './packages/wasm/src/index.ts', - // './packages/wrapped-keys/src/index.ts', - // './packages/wrapped-keys-lit-actions/src/index.ts', -]; - -// jsonFile.entryPoints = dirs; -jsonFile.entryPoints = onlyInterestedIn; - -await writeJsonFile(TARGET, jsonFile); - -greenLog(`${TARGET} has been updated.`); - -greenLog(`generating typedoc...`); -await runCommand(`yarn typedoc --options ${TARGET}`); - -if (FLAG === '--preview') { - // await runCommand(`open ./docs/index.html`); - liveServer.default.start({ - port: 56965, // Set the server port. Defaults to 8080. - host: '0.0.0.0', // Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP. - root: './doc', // Set root directory that's being served. Defaults to cwd. - open: false, // When false, it won't load your browser by default. - ignore: 'scss,my/templates', // comma-separated string for paths to ignore - file: 'index.html', // When set, serve this file (server root relative) for every 404 (useful for single-page applications) - wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec. - // mount: [['/components', './node_modules']], // Mount a directory to a route. - logLevel: 2, // 0 = errors only, 1 = some, 2 = lots - // middleware: [function(req, res, next) { next(); }] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack - }); -} else if (FLAG === '--push') { - const projectId = await selectProject(); // Prompt user to select a project - - createDirs('doc/.vercel'); - writeJsonFile('doc/.vercel/project.json', { - projectId: projectId, - orgId: VERCEL_ORG_ID, - }); - - redLog( - `If this is your first time running, you might have to run 'cd doc && vercel' to setup manually.` - ); - greenLog( - 'Trying to push to Vercel, takes about a minute. If not, there must be an error.' - ); - const link = await runCommand(`cd doc && vercel --prod`); - console.log('Deployed:', link); - exit(); -} else { - exit(); -}