Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LIT-Protocol/js-sdk into feat/lit…
Browse files Browse the repository at this point in the history
…-1815-pull-dynamic-node-urls
  • Loading branch information
Josh Long committed Nov 28, 2023
2 parents 2f110dd + 02976b7 commit 6bb27f7
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 69 deletions.
65 changes: 32 additions & 33 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/demo-encrypt-decrypt-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function App() {
const [data, setData] = useState<object | string>({
data: {
name: 'Lit Protocol',
description: 'Threadshold cryptography for the win!',
description: 'Threshold cryptography for the win!',
}
});
const [str, setStr] = useState('This test is working! Omg!');
Expand Down
2 changes: 1 addition & 1 deletion packages/access-control-conditions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/auth-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/auth-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/bls-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/contracts-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/contracts-sdk/src/abis/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export * from "./RateLimitNFT.sol/RateLimitNFT.ts";
export * from "./PKPHelper.sol/PKPHelper.ts";
export * from "./PKPPermissions.sol/PKPPermissions.ts";
export * from "./PKPNFTMetadata.sol/PKPNFTMetadata.ts";
export * from "./Allowlist.sol/Allowlist.ts";
export * from "./Allowlist.sol/Allowlist.ts";
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
45 changes: 44 additions & 1 deletion packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,50 @@ export class LitCore {
log('Error connecting to node. Detected "ERR" in keys', url, keys);
}

this.serverKeys[url] = keys;
if (!keys.latestBlockhash) {
log('Error getting latest blockhash from the node.');
}

if (this.config.checkNodeAttestation) {
// check attestation
if (!resp.attestation) {
console.error(
`Missing attestation in handshake response from ${url}`
);
throwError({
message: `Missing attestation in handshake response from ${url}`,
errorKind: LIT_ERROR.INVALID_NODE_ATTESTATION.kind,
errorCode: LIT_ERROR.INVALID_NODE_ATTESTATION.name,
});
} else {
// actually verify the attestation by checking the signature against AMD certs
log('Checking attestation against amd certs...');
const attestation = resp.attestation;

try {
checkSevSnpAttestation(attestation, challenge, url).then(() => {
log(`Lit Node Attestation verified for ${url}`);

// only set server keys if attestation is valid
// so that we don't use this node if it's not valid
this.serverKeys[url] = keys;
});
} catch (e) {
console.error(
`Lit Node Attestation failed verification for ${url}`
);
console.error(e);
throwError({
message: `Lit Node Attestation failed verification for ${url}`,
errorKind: LIT_ERROR.INVALID_NODE_ATTESTATION.kind,
errorCode: LIT_ERROR.INVALID_NODE_ATTESTATION.name,
});
}
}
} else {
// don't check attestation, just set server keys
this.serverKeys[url] = keys;
}
})
.catch((e: any) => {
log('Error connecting to node ', url, e);
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/ecdsa-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/encryption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/lit-auth-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
},
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/lit-node-client-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/lit-node-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/misc-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/misc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/nacl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/pkp-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
1 change: 1 addition & 0 deletions packages/pkp-base/src/lib/pkp-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { publicKeyConvert } from 'secp256k1';
import { toString as uint8arrayToString } from 'uint8arrays';
import { defaultLitnodeClientConfig } from '@lit-protocol/constants';

/**
* Compresses a given public key.
Expand Down
2 changes: 1 addition & 1 deletion packages/pkp-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/pkp-cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/pkp-ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/pkp-sui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/pkp-walletconnect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
],
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/sev-snp-utils-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
2 changes: 1 addition & 1 deletion packages/uint8arrays/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"version": "3.0.24",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
}
}
11 changes: 3 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"paths": {
"@lit-protocol/*": [
"packages/*/src"
]
"@lit-protocol/*": ["packages/*/src"]
}
},
"exclude": [
"node_modules",
"tmp"
]
}
"exclude": ["node_modules", "tmp"]
}

0 comments on commit 6bb27f7

Please sign in to comment.