Skip to content

Commit

Permalink
[Merge Branch] Feature/lit 1498 js sdk merge e2e nodejs branch into v3 (
Browse files Browse the repository at this point in the history
#221) (#222)

* update ecdsa sdk

* refactor combiination entry point for new method signature

* update ecdsa-sdk from ecdsa wasm

* updates for new cait sith ecdsa-sdk

* fixes to key remapping

* update to crypto tests for ecdsa sdk

* update tests for sign recombination

* remove unused import

* Add new ECDSA signature types

* remove enum from types

* add enum for ecdsa key type.

* update enums

* remove static v value from test

* update ecdsa-sdk with new recid calculation

* fix update to ecdsa-sdk for recid fixes

* Integrate new BLS WASM

* Update crypto wrappers around BLS WASM

* Add return types to utility functions

* Use generics in IEither

* Use generics in IEither

* Refactor param validation, add coverage, use IEither to return error instead of throwing

* Fix map

* Fix crypto package logic + tests

* Update encryption helpers and integrate new BLS encryption to lit-node-client-nodejs package

* Remove jalapeno support and make serrano the default

* Build fixes + bug fixes

* Make demo app use TS

* Use better names, fixes

* Fix bug, make errors more verbose

* Update encryption logic in demo app

* Couple of important bug fixes + tidy up

* Demo using human-readable strings

* Update comments and JSDocs

* Fix bugs, update all e2e & manual tests, simplify encryptString to just arrayify utf-16 strings

* Update bls-sdk,crypto with verify_signature, implement demo-locked-express-app

* Add getSignedToken + verification to e2e tests

* Update manual_tests for signed JWT tests

* Cleanup

* Fix types

* Use cayenne as default

* Update to cayenne contracts

* fix tsc error

* rebuilt wasm module

* bump major to 3 -> 3.0.0

* add sig type

* fix test and sig combination logic

* update logic for removing postifxed polarity on signature

* upgrade signature combination for cait sith changes

* update test

* upgrade crypto and ecdsa lib for hd key signature and public key derivation

* add support for public key derivation

* update claim and signing tests

* add auth callback statement

* updates for new enums on nodes

* add hd key support

* update claim impls

* add rootkeys to handshake

* add mint claim callback

* update claim types  per node updates

* remove key id from signing request

* chore: update pkgs in lit auth example

* Revert "chore: update pkgs in lit auth example"

This reverts commit 83263dd.

* Merge pull request #194 from LIT-Protocol/feat/update-mint-relay

feat: support new mint and fetch endpoints

* merge of pr #194 fixes

* implement relay fetch call

* add telem endpoint

* fix build issues from merge

* fix types

* migrate hd pubkey method from lit-node-client to lit-core

* update claim endpoint

* updates for key claiming

* wip update contracts

* update manifest urls and add  access token headers on fetch

* move sig reformatting to client

* read auth method acc token from cfg

* update contract-client

* updates for cayenne

* update lit config for auth method pass through

* update sig recomb for new key type value

* update tests

* update contract addresses for cayenne

* add contract ignore statement

* update contract sdk bindings

* update contracts lookup for cayenne

* update claim types for explicit claim processing types.

* add check for expiration on auth sig generation

* update type comment

* fix import

* change network for demo

* update relay endpoints

* update relay url

* update relayer endpoint

* update import

* get rp id from origin domain

* remove check for webauthn from claim

* add logging of request id on http request failure

* update function name

* revery webauthn create options url change

* Published Version 2.2.54

* fmt

* update baseProvider claimKey

* type update

* [Master <> V3 Merge] Feature/lit 1322 js sdk merge in v3 to revamp branch (#209)

* Feature/lit 856 add sych support (#186)

* start stych refactor

* add basic token validation for otp authentication

* updates from testing

* remove stale types

* remove test data from test source

* type fixes

* typo

* fmt

* type updates

* initigrate both otp auth methods

* version 2.2.42

* fix provider options union

* fix base provider relay body

* Published Version 2.2.43

* Use setup-node GH action with yarn caching (#180)

* Use setup-node GH action with yarn caching

* Add step name

* fix url route formatting

* Published Version 2.2.44 --alpha

* add public goods network (#190)

* Feature/pkp sui (#185)

* feat: add pkp-sui

* feat: add pkp-sui test

* fix typo

* change to use bs58

* fix pkp-sui test

fix typo
Devnet is reset weekly, Testnet was reset on May 11

---------



* Publish version 2.2.45

* feat: add optimismGoerli

* Published version 2.2.46

* feat: add manual tests on optimismGoerli

* docs: update pkp-sui readme (#191)



* added waev chain (#192)

* Pass in statement from authCallbackParams to signSessionKey (#193)

* wip: support new mint endpoint

* wip: update lit-auth-client demo app

* wip: expand provider options, export stytch

* wip: local testing

* chore: remove logs, local relay

* misc: update copy in demo app

* fix: different type to represent data for registering auth methods

* fix: handle parsing err

* fix: set routes

* Fix/humanize acc (#196)

* updates from contract abi import

* update test

* feat: option to not build into react app

* Published version 2.2.49

* chore: update pkgs in lit auth example

* feat: support WC v2 for lit-connect-modal (#197)

* Revert to 3118e29

* Revert "chore: update pkgs in lit auth example"

This reverts commit 3118e29.

* Revert "feat: support WC v2 for lit-connect-modal (#197)"

This reverts commit a3b83cd.

* [V2/V3] [Feat] Update lit modal to support wallet connect (#198)

* feat: support wc v2 for lit-connect-modal

* chore: remove old file

* - moved lit-connect-model dependency

* Update esbuilder/lit-connect-modal/esbuild.js




* fix: minor changes required

---------





* Published version 2.2.50

* chore: update pkgs

* docs: update lit-connect-modal demo readme



* fix webauth options generation url endpoint

* Published Version 2.2.53

* feat: add handshake body checks on 'successful' handhshakes

* fix: remove throwing error

* [V2/V3] feat: add handshake body checks on 'successful' handhshakes (#207)

* feat: add handshake body checks on 'successful' handhshakes

* fix: remove throwing error

* fix: build issues

* revery webauthn create options url change

* Published Version 2.2.54

* explicit any types

---------












* add connect call to claimKeyId

* remove access list contract

* update contract addresses

* remove allow list

* remove access control conditions contract

* add WithAuthMethodSigning type

* update contract manifest

* update deployment addresses

* remove twillio otp auth provider

* remove duplicated package

* feat: ability to npm link and unlink packages

* feat: add scripts to either bun/npm link

* getSignatures works

* fix: publish version

* feat: ES2021 to make "replaceAll" work

* fix: add chore back to be able to publish

* fix: had to add "DOM" to use global "crypto"

* feat: add script to generate config

* feat: add flatten object

* fix: when lit action is used as pure serverless function

* fix: general worker api

* chore: add success exit

* enable nx cache

* remove nx cache

* Feat/manual claim test (#213)

* add manual claim test

* got past last error

* fixing stuff as i go

* remove manual overrides for relay url.  use cayenne which seems to work fine now

* test working but wrong derived pubkey

* more debugging

* fix tests

* remove local overrides

* Added lit action fixes

* it works

* use cayenne

* added 2 signatures

* built

* add check for sig properties before conversion

* update config

* update config

* feat: add UNKNOWN_SIGNATURE_ERROR

* updates for claim key comments and abstractions

* fix typescript errors with nodejs app

* Feature/easier local node testing (#215)

* fix typescript errors with nodejs app

* config and docs for testing against a local node

* local testing works

* restore cayenne contracts

* add env var docs

* cleanup

* feat: script to enable/disable nx build cache

* chore: update text

* feat: add bun test script

* chore: make test exit

* chore: bun test lit node client

* Update executeJs for claim processing from execution response

* chage claim test

* add new error type

* ref loop to map stmt

* add lit actions comment

* add claim combiner test

* update comments

* disallow webauthn authentication

* add explicit return type

* make cayenne use 3 nodes by default (#217)

* update key claim combiner and types

* Feature/fixes to manual test for local chronicle node (#218)

* added a sleep to the manual test so there's time for the minted PKP to propagate to the local chronicle replica

* debug: false

* first pass

* add address conversion

* update api docs for v3

* format account addr to eip-55

* add casing normalize to eth sign message check

* bump version to 3.0.1

* bump version 3.0.2

* feat: add e2e-nodejs tests

* feat: add the ability to test by group

* update project id

* update api docs

* feat: add test to LitNodeClientNodejs

* docs: update

* fix: access controls conditions tests

* add auth method scopes and pkp helper method

* add pkp helper methods

* feat: add contracts-sdk tests

* fix: min nodes

* chore: update contracts

* fix: add allowJs: true

* feat: add more tests

* wip

* fix: pkp sign recover works

* wip

* fix: use sha256 to check dataSigned

* Hash the toSign parameter before signing in tests (#220)

* wip: all new e2e tests passed so far, continue..

* feat: pkp sui works

* 🚀 all unit tests passed, next e2e nodejs

* update: github CI

* chore: change to use html instead of react for testing

* ci update

* chore: indentation

* fix: error message

* Empty-Commit

* fix: to use pkpSign & passed all pkp-ethers tests

* fix: pkp client works too

* 🚀 OK. All Good

* docs: update

* resolve comments

---------

Signed-off-by: Anson <ansonox@gmail.com>
Signed-off-by: sarah z <15064710+sarahzdev@users.noreply.github.com>
Co-authored-by: Josh Long <josh@litprotocol.com>
Co-authored-by: Howard Tam <howard.tam.95@gmail.com>
Co-authored-by: sarahzdev <sarah.hg.zhang@gmail.com>
Co-authored-by: sarah z <15064710+sarahzdev@users.noreply.github.com>
Co-authored-by: Howard <hwrdtm@users.noreply.github.com>
Co-authored-by: Chris Cassano <1285652+glitch003@users.noreply.github.com>
Co-authored-by: yhl125 <54613623+yhl125@users.noreply.github.com>
Co-authored-by: Yoonhyoung-Lee <54613623+Yoonhyoung-Lee@users.noreply.github.com>
Co-authored-by: Adarsh-Kumar28 <115020815+Adarsh-Kumar28@users.noreply.github.com>
  • Loading branch information
10 people authored Sep 25, 2023
1 parent f13d30b commit 04d2385
Show file tree
Hide file tree
Showing 387 changed files with 54,313 additions and 19,968 deletions.
108 changes: 64 additions & 44 deletions README.md

Large diffs are not rendered by default.

1,774 changes: 11 additions & 1,763 deletions apps/html/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ pre {
`,
}}
/>
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Tue, 19 Sep 2023 22:44:06 GMT
(REACT) THIS FILE IS AUTOMATICALLY GENERATED FROM tools/scripts/gen-react.mjs Mon, 25 Sep 2023 16:18:36 GMT
<div id="root"></div>
<pre><code id="result"></code></pre>
</>
Expand Down
2 changes: 1 addition & 1 deletion doc/assets/search.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1>Packages</h1>
<tbody><tr>
<td><a href="https://github.com/LIT-Protocol/js-sdk/tree/master/packages/lit-node-client-nodejs">@lit-protocol/lit-node-client-nodejs</a></td>
<td><img src="https://img.shields.io/badge/-nodejs-2E8B57" alt="lit-node-client-nodejs" title="lit-node-client-nodejs"></td>
<td>3.0.2</td>
<td>3.0.0</td>
<td><a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/lit-node-client-nodejs">npm</a><br/><a href="https://cdn.jsdelivr.net/npm/@lit-protocol/lit-node-client-nodejs-vanilla/lit-node-client-nodejs.min.js">Vanilla JS (UMD)</a></td>
</tr>
<tr>
Expand Down Expand Up @@ -309,7 +309,7 @@ <h1>Quick Start</h1>
<h2>Building</h2>
</a>
<p>You can build the project with the following command:</p>
<pre><code><span class="hl-0">yarn</span><span class="hl-1"> </span><span class="hl-0">build</span>
<pre><code><span class="hl-0">yarn</span><span class="hl-1"> </span><span class="hl-0">build</span><br/><br/><span class="hl-8">// for single package without dependencies</span><br/><span class="hl-0">yarn</span><span class="hl-1"> </span><span class="hl-0">nx</span><span class="hl-1"> </span><span class="hl-0">run</span><span class="hl-1"> </span><span class="hl-0">lit</span><span class="hl-1">-</span><span class="hl-0">node</span><span class="hl-1">-</span><span class="hl-0">client</span><span class="hl-1">-</span><span class="hl-9">nodejs</span><span class="hl-1">:</span><span class="hl-0">build</span><span class="hl-1"> --</span><span class="hl-10">with</span><span class="hl-1">-</span><span class="hl-0">deps</span><span class="hl-1">=</span><span class="hl-6">false</span>
</code></pre>

<a href="#running-test-apps" id="running-test-apps" style="color: inherit; text-decoration: none;">
Expand Down
26 changes: 26 additions & 0 deletions e2e-nodejs/00-setup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import LITCONFIG from '../lit.config.json' assert { type: 'json' };
import { fail } from '../tools/scripts/utils.mjs';

const client = new LitNodeClient({
litNetwork: LITCONFIG.TEST_ENV.litNetwork,
debug: process.env.DEBUG === 'true' ?? LITCONFIG.TEST_ENV.debug,
minNodeCount: LITCONFIG.TEST_ENV.minNodeCount,
});
await client.connect();

// ==================== Validation ====================
if (client.ready !== true) {
fail('client not ready');
}

if (LITCONFIG.CONTROLLER_AUTHSIG === undefined) {
fail('Controller authSig cannot be empty');
}

if (LITCONFIG.PKP_PUBKEY === undefined) {
fail('PKP pubkey cannot be empty');
}

// ==================== Success ====================
export { client };
30 changes: 30 additions & 0 deletions e2e-nodejs/group-connection/test-connection-cayenne.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { LitNodeClient } from '@lit-protocol/lit-node-client';

const LIT_NETWORK = 'cayenne';

export async function main() {
// ==================== Test Logic ====================
const client = new LitNodeClient({
litNetwork: LIT_NETWORK,
debug: process.env.DEBUG === 'true' ?? LITCONFIG.TEST_ENV.debug,

minNodeCount: LITCONFIG.TEST_ENV.minNodeCount,
});
await client.connect();

// ==================== Post-Validation ====================
if (!client.ready) {
return fail('client not ready');
}
if (client.config.litNetwork !== LIT_NETWORK) {
return fail(`client not connected to ${LIT_NETWORK}`);
}

// ==================== Success ====================
return success(`Connected to ${LIT_NETWORK}`);
}

await testThis({ name: path.basename(import.meta.url), fn: main });
23 changes: 23 additions & 0 deletions e2e-nodejs/group-contracts/test-contracts-mint-cost.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { LitContracts } from '@lit-protocol/contracts-sdk';

export async function main() {
// ==================== Setup ====================
const contractClient = new LitContracts();
await contractClient.connect();

// ==================== Test Logic ====================
const mintCost = await contractClient.pkpNftContract.read.mintCost();

// ==================== Post-Validation ====================
if (mintCost === undefined || mintCost === null) {
return fail('mintCost should not be empty');
}

// ==================== Success ====================
return success('ContractsSDK should read mintCost');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
40 changes: 40 additions & 0 deletions e2e-nodejs/group-contracts/test-contracts-with-pkp.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { LitContracts } from '@lit-protocol/contracts-sdk';
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';

export async function main() {
// ========== PKP WALLET SETUP ===========
const pkpWallet = new PKPEthersWallet({
pkpPubKey: LITCONFIG.PKP_PUBKEY,
controllerAuthSig: LITCONFIG.CONTROLLER_AUTHSIG,
rpc: LITCONFIG.CHRONICLE_RPC,
});

await pkpWallet.init();

if (pkpWallet._isSigner !== true) {
return fail('pkpWallet should be signer');
}

// ==================== LitContracts Setup ====================
const contractClient = new LitContracts({
signer: pkpWallet,
});

await contractClient.connect();

// ==================== Test Logic ====================
const mintCost = await contractClient.pkpNftContract.read.mintCost();

// ==================== Post-Validation ====================
if (mintCost === undefined || mintCost === null) {
return fail('mintCost should not be empty');
}

// ==================== Success ====================
return success('ContractsSDK should read mintCost with PKP');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
35 changes: 35 additions & 0 deletions e2e-nodejs/group-contracts/test-contracts-with-private-key.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { LitContracts } from '@lit-protocol/contracts-sdk';
import { ethers } from 'ethers';

export async function main() {
// ========== PKP WALLET SETUP ===========
const privateKey =
'0x4cc303e56f1ff14e762a33534d7fbaa8a76e52509fd96373f24045baae99cc38';
const provider = new ethers.providers.JsonRpcProvider(
LITCONFIG.CHRONICLE_RPC
);
const signer = new ethers.Wallet(privateKey, provider);

// ==================== LitContracts Setup ====================
const contractClient = new LitContracts({
signer,
});

await contractClient.connect();

// ==================== Test Logic ====================
const mintCost = await contractClient.pkpNftContract.read.mintCost();

// ==================== Post-Validation ====================
if (mintCost === undefined || mintCost === null) {
return fail('mintCost should not be empty');
}

// ==================== Success ====================
return success('ContractsSDK should read mintCost with private key');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
32 changes: 32 additions & 0 deletions e2e-nodejs/group-contracts/test-contracts-with-provider.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { LitContracts } from '@lit-protocol/contracts-sdk';
import { ethers } from 'ethers';

export async function main() {
// ========== PKP WALLET SETUP ===========
const provider = new ethers.providers.JsonRpcProvider(
LITCONFIG.CHRONICLE_RPC
);

// ==================== LitContracts Setup ====================
const contractClient = new LitContracts({
provider,
});

await contractClient.connect();

// ==================== Test Logic ====================
const mintCost = await contractClient.pkpNftContract.read.mintCost();

// ==================== Post-Validation ====================
if (mintCost === undefined || mintCost === null) {
return fail('mintCost should not be empty');
}

// ==================== Success ====================
return success('ContractsSDK should read mintCost with provider');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
49 changes: 49 additions & 0 deletions e2e-nodejs/group-lit-actions/test-lit-action-1-sig.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { client } from '../00-setup.mjs';
import { ethers } from 'ethers';

// NOTE: you need to hash data before you send it in.
// If you send something that isn't 32 bytes, the nodes will return an error.
const TO_SIGN = ethers.utils.arrayify(ethers.utils.keccak256([1, 2, 3, 4, 5]));

export async function main() {
// ==================== Test Logic ====================
const res = await client.executeJs({
authSig: LITCONFIG.CONTROLLER_AUTHSIG,
code: `(async () => {
const sigShare = await LitActions.signEcdsa({
toSign,
publicKey,
sigName: "sig",
});
})();`,
jsParams: {
toSign: TO_SIGN,
publicKey: LITCONFIG.PKP_PUBKEY,
},
});

// ==================== Post-Validation ====================
if (Object.keys(res.signatures).length <= 0) {
return fail(
`should have at least 1 signature but received ${
Object.keys(res.signatures).length
}`
);
}

['sig', 'r', 's', 'recid', 'signature', 'publicKey', 'dataSigned'].forEach(
(key) => {
if (!res.signatures.sig[key]) {
return fail(`sig.${key} is undefined, empty, or null`);
}
}
);

// ==================== Success ====================
return success('Lit Action should log sign x1 sig');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
70 changes: 70 additions & 0 deletions e2e-nodejs/group-lit-actions/test-lit-action-2-sigs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { client } from '../00-setup.mjs';
import { ethers } from 'ethers';

// NOTE: you need to hash data before you send it in.
// If you send something that isn't 32 bytes, the nodes will return an error.
const TO_SIGN = ethers.utils.arrayify(ethers.utils.keccak256([1, 2, 3, 4, 5]));

export async function main() {
// ==================== Test Logic ====================
const res = await client.executeJs({
authSig: LITCONFIG.CONTROLLER_AUTHSIG,
code: `(async () => {
console.log('hello world')
async function signMultipleSigs(numSigs, toSign, publicKey) {
const sigShares = [];
for(let i = 0; i < numSigs; i++) {
const sigShare = await LitActions.signEcdsa({
toSign,
publicKey,
sigName: "sig" + i,
});
sigShares.push(sigShare);
}
return sigShares;
}
const sigShares = await signMultipleSigs(numberOfSigs, toSign, publicKey);
})();`,
jsParams: {
numberOfSigs: 2,
toSign: TO_SIGN,
publicKey: LITCONFIG.PKP_PUBKEY,
sigName: 'fooSig',
},
});

// ==================== Post-Validation ====================
if (Object.keys(res.signatures).length !== 2) {
return fail(
`should have 2 signatures but received ${
Object.keys(res.signatures).length
}`
);
}

// Checking each sig in the signatures array
Object.entries(res.signatures).forEach(([key, sig]) => {
if (key !== 'sig0' && key !== 'sig1') {
return fail(`sig name ${key} is not expected`);
}

['r', 's', 'recid', 'signature', 'publicKey', 'dataSigned'].forEach(
(key) => {
if (!sig[key]) {
return fail(`sig.${key} is undefined, empty, or null`);
}
}
);
});

// ==================== Success ====================
return success('Lit Action should be able to sign data x2 sigs');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
54 changes: 54 additions & 0 deletions e2e-nodejs/group-lit-actions/test-lit-action-claim-key.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import path from 'path';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import LITCONFIG from '../../lit.config.json' assert { type: 'json' };
import { client } from '../00-setup.mjs';

export async function main() {
// ==================== Test Logic ====================
const res = await client.executeJs({
authSig: LITCONFIG.CONTROLLER_AUTHSIG,
code: `(async () => {
Lit.Actions.claimKey({keyId: "foo"});
})();`,
jsParams: {
// Nada!
},
});

// ==================== Post-Validation ====================
if (!res.success) {
return fail(`response should be success`);
}

if (Object.keys(res.signedData).length > 0) {
return fail(`signedData should be empty`);
}

if (Object.keys(res.decryptedData).length > 0) {
return fail(`decryptedData should be empty`);
}

// -- should have claimData
if (
res.claimData === undefined ||
res.claimData === null ||
Object.keys(res.claimData).length === 0
) {
return fail(`claimData should not be empty`);
}

if (res.claimData['foo'] === undefined) {
return fail(`claimData should have "foo" key`);
}

['signature', 'derivedKeyId'].forEach((key) => {
if (!res.claimData.foo[key]) {
return fail(`claimData.foo should have ${key}`);
}
});

// ==================== Success ====================
return success('Lit Action should return claim');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
Loading

0 comments on commit 04d2385

Please sign in to comment.