Skip to content

Commit

Permalink
[Release] 3.2.0 (#370)
Browse files Browse the repository at this point in the history
* init release

* feat: fix contracts-sdk (#359)

* use testThis in testThese to unify criteria and fix the pipeline that… (#360)

* use testThis in testThese to unify criteria and fix the pipeline that was missing some tests due to testThese finishing the process with code 0

* fmt

* remove problematic process.exit

* Add `K256` as alias of `ECDSA_CAIT_SITH` sig type

* add CI run on PRs targeting staging branches (#361)

* add comment pointing to repo (#362)

* Add `K256` as alias of `ECDSA_CAIT_SITH` sig type (#356)

* add comment pointing to repo

---------

Co-authored-by: Massimo Cairo <cairomassimo@gmail.com>

* prettied

* feature/lit-2511-js-sdk-review-remove-lit-siwe (#373)

* implement new interface to unify session authentication in client (#358)

* implement new interface to unify session authentication in client

* fix eth pkp wallet creation unit test

* update test to use global config

* add test group to CI

* change encryption test to also validate getting session sigs from cache

* remove process termination order included on testThese that was avoiding other tests to run

* Add `K256` as alias of `ECDSA_CAIT_SITH` sig type (#356)

* fix rpc constant used in testing

* add empty resourceAbilityRequests to test

* fix and clean test using new session cache interface to sign using PKPEthersWallet

* fix encryption test

* remove old test

* staging

* chore: update readme

* v?

* use throwError function

* remove unnnecessary sessionKeys as they are obtained from cache afterwards

* move authContext validation to function that validates the PKP auth context

* backwards compatibility to avoid a breaking change

* fmt

* fmt

* fix siwe import

---------

Co-authored-by: Massimo Cairo <cairomassimo@gmail.com>
Co-authored-by: Ansonhkg <ansonox@gmail.com>

* remove vanilla js builds (#372)

* Feature/lit 2494 js sdk get rid of lit third party libs (#371)

* remove 3rd party libs

* fix: revert back to fix react

* it works

* cherry picks 735438f 3b0422f

* readme

* resolve conflicts

---------

Signed-off-by: Anson <ansonox@gmail.com>

* fix: build issues

* chore: bump accs-schema version to 0.0.6

* update accs schemas version (#375)

* update accs schemas version

* 0.0.6 instead cus we pub the dist folder

---------

Co-authored-by: Ansonhkg <ansonox@gmail.com>

* fix: wrong error message

* Feature/lit 2491 js sdk make delegateeAddresses field optional (#376)

* chore: bump accs-schema version to 0.0.6

* fix: wrong error message

* feat: make delegatee Optional

* feat: add test

* fix: test case & add extra info on logs

* update: test case comment

* feature/lit-2544-js-sdk-remove-vanilla-js-from-readme

* Published version 3.2.0

---------

Signed-off-by: Anson <ansonox@gmail.com>
Co-authored-by: Federico Amura <federicoamura@gmail.com>
Co-authored-by: Massimo Cairo <cairomassimo@gmail.com>
Co-authored-by: Chris Cassano <1285652+glitch003@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 21, 2024
1 parent 91b3381 commit cb018a5
Show file tree
Hide file tree
Showing 232 changed files with 1,287 additions and 90,689 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- master
- staging/**
- feat/**
jobs:
master:
Expand Down Expand Up @@ -53,4 +54,4 @@ jobs:
run: yarn build
- name: Run End to End Tests
if: steps.build.outputs.exit_code == 0
run: yarn test:e2e:node --group=connection --group=lit-actions --group=pkp-auth-method --group=pkp-ethers --group=pkp-encryption-decryption
run: yarn test:e2e:node --group=connection --group=lit-actions --group=pkp-auth-method --group=pkp-ethers --group=pkp-encryption-decryption --group=pkp-session-sigs
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
/.vscode
/node_modules
/tmp
/packages/*/dist
/packages/lit-third-party-libs
/packages/*/dist
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [3.2.0] - 2024-02-20
- [staging/3.2.0](https://github.com/LIT-Protocol/js-sdk/pull/370)

# [3.1.3] - 2024-02-13

- [staging/2024-02-13](https://github.com/LIT-Protocol/js-sdk/pull/344)
Expand Down
86 changes: 31 additions & 55 deletions README.md

Large diffs are not rendered by default.

1,902 changes: 3 additions & 1,899 deletions apps/html/index.html

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions apps/nodejs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as encryption from '@lit-protocol/encryption';
import * as litAuthClient from '@lit-protocol/lit-auth-client';
import * as litNodeClient from '@lit-protocol/lit-node-client';
import * as litNodeClientNodejs from '@lit-protocol/lit-node-client-nodejs';
import * as litThirdPartyLibs from '@lit-protocol/lit-third-party-libs';
import * as logger from '@lit-protocol/logger';
import * as misc from '@lit-protocol/misc';
import * as miscBrowser from '@lit-protocol/misc-browser';
Expand Down Expand Up @@ -44,7 +43,6 @@ console.log("encryption:", hasItems(encryption));
console.log("litAuthClient:", hasItems(litAuthClient));
console.log("litNodeClient:", hasItems(litNodeClient));
console.log("litNodeClientNodejs:", hasItems(litNodeClientNodejs));
console.log("litThirdPartyLibs:", hasItems(litThirdPartyLibs));
console.log("logger:", hasItems(logger));
console.log("misc:", hasItems(misc));
console.log("miscBrowser:", hasItems(miscBrowser));
Expand Down
158 changes: 79 additions & 79 deletions apps/nodejs/manual-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as LitJsSdk from '@lit-protocol/lit-node-client';
// import { LitContracts } from '@lit-protocol/contracts-sdk';
import { ethers } from 'ethers';
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
import { SiweMessage } from 'lit-siwe';
import { SiweMessage } from 'siwe';
import { LIT_EVM_CHAINS } from '@lit-protocol/constants';


Expand Down Expand Up @@ -206,30 +206,30 @@ const runLogic = async (contract: LitContracts) => {
// };

const pkpSign = async (client, pkpPubkey, authSig) => {
// try and sign something
let sig = await client.pkpSign({
toSign: ethers.utils.arrayify(ethers.utils.keccak256([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])), // hello world in Uint8Array
pubKey: pkpPubkey,
authSig,
});
// try and sign something
let sig = await client.pkpSign({
toSign: ethers.utils.arrayify(ethers.utils.keccak256([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])), // hello world in Uint8Array
pubKey: pkpPubkey,
authSig,
});

// console.log("sig: ", sig);
// console.log("sig: ", sig);

const recoveredPk = ethers.utils.recoverPublicKey("0x" + sig.dataSigned, sig.signature);
const addr = ethers.utils.computeAddress('0x' + sig.publicKey);
const recoveredAddr = ethers.utils.computeAddress(recoveredPk);
const claimedAddr = ethers.utils.computeAddress(pkpPubkey);
const recoveredPk = ethers.utils.recoverPublicKey("0x" + sig.dataSigned, sig.signature);
const addr = ethers.utils.computeAddress('0x' + sig.publicKey);
const recoveredAddr = ethers.utils.computeAddress(recoveredPk);
const claimedAddr = ethers.utils.computeAddress(pkpPubkey);

const allGood = addr === recoveredAddr && addr === claimedAddr;
const allGood = addr === recoveredAddr && addr === claimedAddr;

console.log('all addresses match: ', allGood);
return allGood;
console.log('all addresses match: ', allGood);
return allGood;
}

const litActionSign = async(client, pkpPubkey, authSig) => {
console.log('testing sig with lit actions...');
// this code will be run on the node
const litActionCode = `
const litActionSign = async (client, pkpPubkey, authSig) => {
console.log('testing sig with lit actions...');
// this code will be run on the node
const litActionCode = `
const go = async () => {
// this requests a signature share from the Lit Node
// the signature share will be automatically returned in the HTTP response from the node
Expand All @@ -241,40 +241,40 @@ const litActionSign = async(client, pkpPubkey, authSig) => {
go();
`;

const signatures = await client.executeJs({
code: litActionCode,
authSig,
// all jsParams can be used anywhere in your litActionCode
jsParams: {
// this is the string "Hello World" for testing
toSign: ethers.utils.arrayify(ethers.utils.keccak256([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])),
publicKey: pkpPubkey,
sigName: "sig1",
},
});
// console.log("signatures: ", signatures);
const { sig1, sig2 } = signatures.signatures
const sigKeys = {
sig1: {
recovered: ethers.utils.computeAddress(ethers.utils.recoverPublicKey("0x" + sig1.dataSigned, sig1.signature)),
reported: ethers.utils.computeAddress('0x' + sig1.publicKey)
},
sig2: {
recovered: ethers.utils.computeAddress(ethers.utils.recoverPublicKey("0x" + sig2.dataSigned, sig2.signature)),
reported: ethers.utils.computeAddress('0x' + sig2.publicKey)
},
}
const signatures = await client.executeJs({
code: litActionCode,
authSig,
// all jsParams can be used anywhere in your litActionCode
jsParams: {
// this is the string "Hello World" for testing
toSign: ethers.utils.arrayify(ethers.utils.keccak256([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])),
publicKey: pkpPubkey,
sigName: "sig1",
},
});
// console.log("signatures: ", signatures);
const { sig1, sig2 } = signatures.signatures
const sigKeys = {
sig1: {
recovered: ethers.utils.computeAddress(ethers.utils.recoverPublicKey("0x" + sig1.dataSigned, sig1.signature)),
reported: ethers.utils.computeAddress('0x' + sig1.publicKey)
},
sig2: {
recovered: ethers.utils.computeAddress(ethers.utils.recoverPublicKey("0x" + sig2.dataSigned, sig2.signature)),
reported: ethers.utils.computeAddress('0x' + sig2.publicKey)
},
}

// console.log(`sigKeys: ${JSON.stringify(sigKeys, null, 2)}`)
// console.log(`sigKeys: ${JSON.stringify(sigKeys, null, 2)}`)

const pkpAddr = ethers.utils.computeAddress(pkpPubkey);
// console.log('pkpAddr:', pkpAddr)
const pkpAddr = ethers.utils.computeAddress(pkpPubkey);
// console.log('pkpAddr:', pkpAddr)


let allGood = sigKeys.sig1.recovered == sigKeys.sig1.reported && sigKeys.sig2.recovered == sigKeys.sig2.reported && sigKeys.sig1.recovered == sigKeys.sig2.recovered && sigKeys.sig1.recovered == pkpAddr;
console.log('all addresses match: ', allGood);
return allGood;
}
let allGood = sigKeys.sig1.recovered == sigKeys.sig1.reported && sigKeys.sig2.recovered == sigKeys.sig2.reported && sigKeys.sig1.recovered == sigKeys.sig2.recovered && sigKeys.sig1.recovered == pkpAddr;
console.log('all addresses match: ', allGood);
return allGood;
}

const mintPkpAndSign = async () => {
let client;
Expand Down Expand Up @@ -321,37 +321,37 @@ const mintPkpAndSign = async () => {

await client.connect();

const litContracts = new LitContracts({
privateKey: TEST_FUNDED_PRIVATE_KEY,
});
const pkpPubkey = await runLogic(litContracts);
console.log('pkpPubkey:', pkpPubkey);

const privateKey = TEST_FUNDED_PRIVATE_KEY;
const provider = new ethers.providers.JsonRpcProvider(
LIT_EVM_CHAINS['chronicleTestnet'].rpcUrls[0]
);
const wallet = new ethers.Wallet(privateKey, provider);
const authSig = await getAuthSig(wallet);

// console.log('Sleeping for 5 seconds so that the chronicle node replica can sync up');
// Sleep for 5 seconds
// await new Promise(resolve => setTimeout(resolve, 5000));


let startTime = Date.now();
let allGood = true;
const testCount = 1;
for(let i = 0; i < testCount; i++){
console.log(`testing ${i + 1} of ${testCount}`);
let result = await pkpSign(client, pkpPubkey, authSig);
if (!result) {
allGood = false;
}
const litContracts = new LitContracts({
privateKey: TEST_FUNDED_PRIVATE_KEY,
});
const pkpPubkey = await runLogic(litContracts);
console.log('pkpPubkey:', pkpPubkey);

const privateKey = TEST_FUNDED_PRIVATE_KEY;
const provider = new ethers.providers.JsonRpcProvider(
LIT_EVM_CHAINS['chronicleTestnet'].rpcUrls[0]
);
const wallet = new ethers.Wallet(privateKey, provider);
const authSig = await getAuthSig(wallet);

// console.log('Sleeping for 5 seconds so that the chronicle node replica can sync up');
// Sleep for 5 seconds
// await new Promise(resolve => setTimeout(resolve, 5000));


let startTime = Date.now();
let allGood = true;
const testCount = 1;
for (let i = 0; i < testCount; i++) {
console.log(`testing ${i + 1} of ${testCount}`);
let result = await pkpSign(client, pkpPubkey, authSig);
if (!result) {
allGood = false;
}
console.log(`it took ${(Date.now() - startTime) / 1000}s to run ${testCount} tests`)
console.log('all tests were good', allGood);
// await litActionSign(client, pkpPubkey, authSig);
}
console.log(`it took ${(Date.now() - startTime) / 1000}s to run ${testCount} tests`)
console.log('all tests were good', allGood);
// await litActionSign(client, pkpPubkey, authSig);
}

const getAuthSig = async (wallet) => {
Expand Down
76 changes: 1 addition & 75 deletions apps/react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as LitJsSdk_encryption from 'dist/packages/encryption';
import * as LitJsSdk_litAuthClient from 'dist/packages/lit-auth-client';
import * as LitJsSdk_litNodeClient from 'dist/packages/lit-node-client';
import * as LitJsSdk_litNodeClientNodejs from 'dist/packages/lit-node-client-nodejs';
import * as LitJsSdk_litThirdPartyLibs from 'dist/packages/lit-third-party-libs';
import * as LitJsSdk_logger from 'dist/packages/logger';
import * as LitJsSdk_misc from 'dist/packages/misc';
import * as LitJsSdk_miscBrowser from 'dist/packages/misc-browser';
Expand Down Expand Up @@ -44,7 +43,6 @@ declare global {
LitJsSdk_litAuthClient: any;
LitJsSdk_litNodeClient: any;
LitJsSdk_litNodeClientNodejs: any;
LitJsSdk_litThirdPartyLibs: any;
LitJsSdk_logger: any;
LitJsSdk_misc: any;
LitJsSdk_miscBrowser: any;
Expand Down Expand Up @@ -936,78 +934,6 @@ export function App() {



if(typeof LitJsSdk_litThirdPartyLibs === 'undefined') {
console.error("LitJsSdk_litThirdPartyLibs:", LitJsSdk_litThirdPartyLibs);
}else{
console.warn("LitJsSdk_litThirdPartyLibs:", LitJsSdk_litThirdPartyLibs);
window.LitJsSdk_litThirdPartyLibs = LitJsSdk_litThirdPartyLibs;
}
window.addEventListener('load', function() {

var root = document.getElementById('root');
var result = document.getElementById('result');
var entries = Object.entries(LitJsSdk_litThirdPartyLibs);
var lis = entries.map(([key, value]) => `
<li>
<div id="LitJsSdk_litThirdPartyLibs_${key}" class="key" onClick="(async (e) => {
var fn = LitJsSdk_litThirdPartyLibs['${key}'];
var fnType = typeof fn;
console.warn('[${key}] is type of [' + fnType + ']');
if ( fnType === 'string' ) return;
if( fnType === 'function' ){
try{
console.log('params:', globalThis.params);
var res;
try{
res = new fn(globalThis.params);
}catch{
res = await fn(globalThis.params);
}
window.output = res;
res = JSON.stringify(res, null, 2);
result.innerText = res;
console.log(res);
}catch(e){
console.error('Please set the [params] variable in the console then click again');
console.log(e);
}
return;
}
if( fnType === 'object' ){
var res = await fn;
window.output = res;
res = JSON.stringify(res, null, 2);
result.innerText = res;
console.log(res);
return;
}
})();">${key}</div>
<pre class="code">
<code>${(typeof value === 'function' ? value : JSON.stringify(value, null, 2))}</code>
</pre>
</li>`);
lis = lis.join(' ');
var template = `
<div class="cat">
<h1>LitJsSdk_litThirdPartyLibs has ${entries.length} functions</h1>
<ul>
${ lis }
</ul>
</div>
`;
root.insertAdjacentHTML('beforeend', template);
});





if(typeof LitJsSdk_logger === 'undefined') {
console.error("LitJsSdk_logger:", LitJsSdk_logger);
}else{
Expand Down Expand Up @@ -1879,7 +1805,7 @@ pre {
`,
}}
/>
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Wed, 14 Feb 2024 00:26:49 GMT
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Wed, 21 Feb 2024 00:16:38 GMT
<div id="root"></div>
<pre><code id="result"></code></pre>
</>
Expand Down
Loading

0 comments on commit cb018a5

Please sign in to comment.