Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
208b7fd
Add hardcoded keysets
GTC6244 Aug 20, 2025
2bd158b
feat(networks): Add the missing `keySetId` field to `mintWithMultiAut…
Ansonhkg Aug 21, 2025
c94e212
Add cargo lock
GTC6244 Aug 21, 2025
9b94223
chore(package.json): update @lit-protocol/contracts version to 0.5.0 …
Ansonhkg Aug 28, 2025
e1fdd87
fix(custom-auth):
Ansonhkg Sep 1, 2025
11178a5
chore(.gitignore): add missing entries for `lit-auth-artillery` and `…
Ansonhkg Sep 1, 2025
a19777b
refactor(custom-auth): clean up comments and formatting in custom aut…
Ansonhkg Sep 1, 2025
689e557
feat(rpc): implement RPC URL override functionality in various modules
Ansonhkg Sep 4, 2025
c922755
fix(auth-server): `initSystemContext` to override RPC URL
Ansonhkg Sep 4, 2025
18cc2c2
fix(private-rpc): withOverrides no longer monkey-patches methods nor …
Ansonhkg Sep 4, 2025
249d8ac
fix(e2e): rpc override test
Ansonhkg Sep 5, 2025
a19db40
fix(type): return type
Ansonhkg Sep 4, 2025
a49260e
fix(networks): add export functions
Ansonhkg Sep 4, 2025
279a481
fix: https://github.com/LIT-Protocol/js-sdk/pull/881#discussion_r2337…
Ansonhkg Sep 12, 2025
2bf0d96
https://github.com/LIT-Protocol/js-sdk/pull/881#discussion_r2337344946
Ansonhkg Sep 12, 2025
64a4b12
fix(accs): Custom EVM contract condition type failing on unified acce…
Ansonhkg Sep 12, 2025
7b54590
Merge pull request #881 from LIT-Protocol/feature/jss-85-bug-fix-cust…
Ansonhkg Sep 15, 2025
1b45ebf
Merge pull request #883 from LIT-Protocol/feature/jss-81-naga-bug-ove…
Ansonhkg Sep 16, 2025
e581b7b
Merge branch 'naga_add_hardcoded_keysets-3' into feature/jss-82-naga-…
Ansonhkg Sep 16, 2025
f4f5926
Merge pull request #884 from LIT-Protocol/feature/jss-82-naga-bug-som…
Ansonhkg Sep 16, 2025
5670ab2
Merge pull request #888 from LIT-Protocol/feature/jss-100-naga-bug-ac…
Ansonhkg Sep 18, 2025
83c4352
fix(wasm): update wasm-pack profile to retain optimization flags
Ansonhkg Sep 19, 2025
aec35a7
Merge branch 'naga' into naga_add_hardcoded_keysets-3
Ansonhkg Sep 22, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ lit-cache
lit-auth-local
artillery-state.json
artillery-pkp-tokens
lit-auth-artillery
lit-auth-artillery
alice-auth-manager-data
180 changes: 158 additions & 22 deletions e2e/src/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,29 @@ import {
} from './helper/tests';
import { init } from './init';

const RPC_OVERRIDE = process.env['LIT_YELLOWSTONE_PRIVATE_RPC_URL'];
if (RPC_OVERRIDE) {
console.log(
'🧪 E2E: Using RPC override (LIT_YELLOWSTONE_PRIVATE_RPC_URL):',
RPC_OVERRIDE
);
}

describe('all', () => {
// Singleton baby
let ctx: Awaited<ReturnType<typeof init>>;

// Auth contexts for testing
let alicePkpAuthContext: any;
let aliceCustomAuthContext: any;
let eveCustomAuthContext: any;

beforeAll(async () => {
try {
ctx = await init();

// Create PKP and custom auth contexts using helper functions
// alicePkpAuthContext = await createPkpAuthContext(ctx);
aliceCustomAuthContext = await createCustomAuthContext(ctx);
eveCustomAuthContext = await createCustomAuthContext(ctx);
} catch (e) {
console.error(e);
process.exit(1);
Expand Down Expand Up @@ -124,34 +132,51 @@ describe('all', () => {

describe('endpoints', () => {
it('pkpSign', () =>
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
createPkpSignTest(
ctx,
() => eveCustomAuthContext,
ctx.eveViemAccountPkp.pubkey
)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
createExecuteJsTest(
ctx,
() => eveCustomAuthContext,
ctx.eveViemAccountPkp.pubkey
)());
it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
createViewPKPsByAuthDataTest(ctx, ctx.eveCustomAuthData)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
createPkpEncryptDecryptTest(
ctx,
() => eveCustomAuthContext,
ctx.eveViemAccountPkp.ethAddress
)());
it('encryptDecryptFlow', () =>
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
it('pkpPermissionsManagerFlow', () =>
createPkpPermissionsManagerFlowTest(
createEncryptDecryptFlowTest(
ctx,
() => aliceCustomAuthContext
() => eveCustomAuthContext,
ctx.eveViemAccountPkp.pubkey
)());
});

describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => aliceCustomAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(ctx, () => aliceCustomAuthContext)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => aliceCustomAuthContext)());
});
// Disable for now because it requires a different flow
// it('pkpPermissionsManagerFlow', () =>
// createPkpPermissionsManagerFlowTest(
// ctx,
// () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey
// )());
});

// describe('integrations', () => {
// describe('pkp viem account', () => {
// it('sign message', () =>
// createViemSignMessageTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
// it('sign transaction', () =>
// createViemSignTransactionTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
// it('sign typed data', () =>
// createViemSignTypedDataTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
// });
// });
});

describe('EOA Native', () => {
Expand All @@ -161,3 +186,114 @@ describe('all', () => {
});
});
});

describe('rpc override', () => {
const TEST_RPC = process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL;
// const TEST_RPC = 'https://yellowstone-override.example';

// beforeAll(() => {
// process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = TEST_RPC;
// });

// afterAll(() => {
// process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = ORIGINAL_RPC;
// });

it('applies env rpc override to module and client', async () => {
const networks = await import('@lit-protocol/networks');

// choose module by NETWORK env (same way init.ts does)
const network = process.env.NETWORK || 'naga-dev';
const importNameMap: Record<string, string> = {
'naga-dev': 'nagaDev',
'naga-test': 'nagaTest',
'naga-local': 'nagaLocal',
'naga-staging': 'nagaStaging',
};
const importName = importNameMap[network];
const baseModule: any = (networks as any)[importName];

// apply override
const mod =
typeof baseModule.withOverrides === 'function'
? baseModule.withOverrides({ rpcUrl: TEST_RPC })
: baseModule;

// log for verification
// base vs effective (when override is supported)
const baseRpcUrl =
typeof baseModule.getRpcUrl === 'function'
? baseModule.getRpcUrl()
: 'n/a';
const effRpcUrl =
typeof mod.getRpcUrl === 'function' ? mod.getRpcUrl() : 'n/a';
// eslint-disable-next-line no-console
console.log('[rpc-override] TEST_RPC:', TEST_RPC);
// eslint-disable-next-line no-console
console.log(
'[rpc-override] module rpc (base → effective):',
baseRpcUrl,
'→',
effRpcUrl
);
try {
const baseChain =
typeof baseModule.getChainConfig === 'function'
? baseModule.getChainConfig()
: null;
const effChain =
typeof mod.getChainConfig === 'function' ? mod.getChainConfig() : null;
if (baseChain && effChain) {
// eslint-disable-next-line no-console
console.log(
'[rpc-override] module chain id/name (base → effective):',
`${baseChain.id}/${baseChain.name}`,
'→',
`${effChain.id}/${effChain.name}`
);
// eslint-disable-next-line no-console
console.log(
'[rpc-override] module rpcUrls.default.http (base → effective):',
baseChain.rpcUrls.default.http,
'→',
effChain.rpcUrls.default.http
);
// eslint-disable-next-line no-console
console.log(
'[rpc-override] module rpcUrls.public.http (base → effective):',
(baseChain.rpcUrls as any)['public']?.http,
'→',
(effChain.rpcUrls as any)['public']?.http
);
}
} catch {}

// module reflects override
expect(mod.getRpcUrl()).toBe(TEST_RPC);
const chain = mod.getChainConfig();
expect(chain.rpcUrls.default.http[0]).toBe(TEST_RPC);
expect((chain.rpcUrls as any)['public'].http[0]).toBe(TEST_RPC);

// client reflects override
const { createLitClient } = await import('@lit-protocol/lit-client');
const client = await createLitClient({ network: mod });
const cc = client.getChainConfig();

// eslint-disable-next-line no-console
console.log('[rpc-override] client rpcUrl:', cc.rpcUrl);
// eslint-disable-next-line no-console
console.log(
'[rpc-override] client viem rpcUrls.default:',
cc.viemConfig.rpcUrls.default.http
);
// eslint-disable-next-line no-console
console.log(
'[rpc-override] client viem rpcUrls.public:',
(cc.viemConfig.rpcUrls as any)['public']?.http
);

expect(cc.rpcUrl).toBe(TEST_RPC);
expect(cc.viemConfig.rpcUrls.default.http[0]).toBe(TEST_RPC);
expect((cc.viemConfig.rpcUrls as any)['public'].http[0]).toBe(TEST_RPC);
});
});
20 changes: 7 additions & 13 deletions e2e/src/helper/auth-contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ export const createCustomAuthContext = async (
ctx: Awaited<ReturnType<typeof init>>
) => {
console.log('🔁 Creating Custom Auth Context');

try {
// Set up custom auth method type and validation IPFS CID (from custom-auth-flow example)
const uniqueDappName = 'e2e-test-dapp';
const uniqueAuthMethodType = hexToBigInt(
keccak256(toBytes(uniqueDappName))
);
const uniqueUserId = `${uniqueDappName}-alice`;
const authMethodId = keccak256(toBytes(uniqueUserId));
const validationIpfsCid = 'QmYLeVmwJPVs7Uebk85YdVPivMyrvoeKR6X37kyVRZUXW4';

const customAuthContext = await ctx.authManager.createCustomAuthContext({
pkpPublicKey: ctx.aliceViemAccountPkp.publicKey,
pkpPublicKey: ctx.eveViemAccountPkp.pubkey,
authConfig: {
resources: [
['pkp-signing', '*'],
Expand All @@ -61,17 +55,17 @@ export const createCustomAuthContext = async (
},
litClient: ctx.litClient,
customAuthParams: {
litActionIpfsId: validationIpfsCid,
litActionIpfsId: ctx.eveValidationIpfsCid,
jsParams: {
pkpPublicKey: ctx.aliceViemAccountPkp.publicKey,
username: 'alice',
pkpPublicKey: ctx.eveViemAccountPkp.pubkey,
username: 'eve',
password: 'lit',
authMethodId: authMethodId,
authMethodId: ctx.eveCustomAuthData.authMethodId,
},
},
});

console.log('✅ Custom Auth Context created');
console.log('✅ Custom Auth Context created', customAuthContext);
return customAuthContext;
} catch (e) {
console.error('❌ Error creating Custom Auth Context', e);
Expand Down
5 changes: 3 additions & 2 deletions e2e/src/helper/tests/encrypt-decrypt-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { assert } from '../assertions';

export const createEncryptDecryptFlowTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
getAuthContext: () => any,
address?: string
) => {
return async () => {
const { createAccBuilder } = await import(
Expand All @@ -17,7 +18,7 @@ export const createEncryptDecryptFlowTest = (
if (authContext === ctx.aliceEoaAuthContext) {
aliceAddress = ctx.aliceViemAccount.address;
} else {
aliceAddress = ctx.aliceViemAccountPkp.ethAddress;
aliceAddress = address || ctx.aliceViemAccountPkp.ethAddress;
}

// Set up access control conditions requiring Bob's wallet ownership
Expand Down
5 changes: 3 additions & 2 deletions e2e/src/helper/tests/execute-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { assert } from '../assertions';

export const createExecuteJsTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
getAuthContext: () => any,
pubkey?: string
) => {
return async () => {
const litActionCode = `
Expand All @@ -29,7 +30,7 @@ export const createExecuteJsTest = (
message: 'Test message from e2e executeJs',
sigName: 'e2e-test-sig',
toSign: 'Test message from e2e executeJs',
publicKey: ctx.aliceViemAccountPkp.publicKey,
publicKey: pubkey || ctx.aliceViemAccountPkp.publicKey,
},
});

Expand Down
5 changes: 3 additions & 2 deletions e2e/src/helper/tests/pkp-encrypt-decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { assert } from '../assertions';

export const createPkpEncryptDecryptTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
getAuthContext: () => any,
address?: string
) => {
return async () => {
const { createAccBuilder } = await import(
Expand All @@ -19,7 +20,7 @@ export const createPkpEncryptDecryptTest = (
addressToUse = ctx.aliceViemAccount.address;
} else {
// PKP or Custom auth contexts
addressToUse = ctx.aliceViemAccountPkp.ethAddress;
addressToUse = address || ctx.aliceViemAccountPkp.ethAddress;
}

// Set up access control conditions requiring wallet ownership
Expand Down
5 changes: 3 additions & 2 deletions e2e/src/helper/tests/pkp-sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { assert } from '../assertions';

export const createPkpSignTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
getAuthContext: () => any,
pubkey?: string
) => {
return async () => {
const res = await ctx.litClient.chain.ethereum.pkpSign({
authContext: getAuthContext(),
pubKey: ctx.aliceViemAccountPkp.publicKey,
pubKey: pubkey || ctx.aliceViemAccountPkp.publicKey,
toSign: 'Hello, world!',
});

Expand Down
3 changes: 1 addition & 2 deletions e2e/src/helper/tests/view-pkps-by-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { init } from '../../init';
import { assert } from '../assertions';

export const createViewPKPsByAddressTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
ctx: Awaited<ReturnType<typeof init>>
) => {
return async () => {
const pkps = await ctx.litClient.viewPKPsByAddress({
Expand Down
12 changes: 6 additions & 6 deletions e2e/src/helper/tests/view-pkps-by-auth-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { assert } from '../assertions';

export const createViewPKPsByAuthDataTest = (
ctx: Awaited<ReturnType<typeof init>>,
getAuthContext: () => any
authData?: any
) => {
return async () => {
const { ViemAccountAuthenticator } = await import('@lit-protocol/auth');
const authData = await ViemAccountAuthenticator.authenticate(
ctx.aliceViemAccount
);
const _authData =
authData ||
(await ViemAccountAuthenticator.authenticate(ctx.aliceViemAccount));

const pkps = await ctx.litClient.viewPKPsByAuthData({
authData: {
authMethodType: authData.authMethodType,
authMethodId: authData.authMethodId,
authMethodType: _authData.authMethodType,
authMethodId: _authData.authMethodId,
},
pagination: {
limit: 10,
Expand Down
Loading
Loading