Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 24 additions & 22 deletions decrypt-api-key-in-action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ This example shows how you can encrypt an api key on the client with specific de

Before running, there are two variables to configure within `index.ts`:

**Note: ts-node-esm requires NodeJS version 19**
**Note: ts-node-esm requires NodeJS version 20**

```js
const url = `<your http endpoint for api-key usage>`;
const key = '<your api key>';
const key = "<your api key>";
```

## Restricting your api key to only be used by a single Lit Action
Expand All @@ -16,35 +17,36 @@ Within the code you will see the below ACC condition:

```js
const accessControlConditions = [
{
contractAddress: '',
standardContractType: '',
chain,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: '0',
},
{
contractAddress: "",
standardContractType: "",
chain,
method: "eth_getBalance",
parameters: [":userAddress", "latest"],
returnValueTest: {
comparator: ">=",
value: "0",
},
},
];
```

You can change the above to the below to use the parameter: `:currentActionId` which will only allow a speific `IPFS ID` to decrypt the key which is explicitly asserted on in the condition `parameters`

```js
const accessControlConditions = [
{
contractAddress: '',
standardContractType: '',
chain,
method: 'eth_getBalance',
parameters: [':currentActionId', 'latest'],
returnValueTest: {
comparator: '==',
value: '<your ipfs id>',
},
{
contractAddress: "",
standardContractType: "",
chain,
method: "eth_getBalance",
parameters: [":currentActionId", "latest"],
returnValueTest: {
comparator: "==",
value: "<your ipfs id>",
},
},
];
```

For easy upload of your Lit Action source code you can use the explorer [here](https://explorer.litprotocol.com/create-action)
2 changes: 1 addition & 1 deletion decrypt-api-key-in-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"siwe": "^2.0.0"
},
"scripts": {
"start": "ts-node-esm src/index.ts"
"start": "node --loader ts-node/esm src/index.ts"
}
}