-
Notifications
You must be signed in to change notification settings - Fork 89
feat(wrapped-keys): add versioned key update support and client APIs #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ansonhkg
wants to merge
26
commits into
naga
Choose a base branch
from
feature/jss-141-add-update-function-for-wrapped-keys-naga
base: naga
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+369
−6
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
adea77a
feat(wrapped-keys): add versioned key update support and client APIs
Ansonhkg 3a644ec
chore(version): add changeset
Ansonhkg e381b1f
Update packages/wrapped-keys/src/lib/api/update-encrypted-key.ts
Ansonhkg 4ec70bd
Initial plan
Copilot f6a6538
Initial plan
Copilot b987f1d
Initial plan
Copilot 47ca9e9
Initial plan
Copilot 8a56af2
docs(wrapped-keys): add detailed JSDoc for UpdateEncryptedKeyResult
Copilot 04395fd
docs: add JSDoc for updatedAt and versions properties in StoredKeyMet…
Copilot 14ae7a8
Add detailed JSDoc documentation to WrappedKeyVersion interface
Copilot 3553f15
docs: add JSDoc for includeVersions property in GetEncryptedKeyDataPa…
Copilot a702d21
Merge pull request #1012 from LIT-Protocol/copilot/sub-pr-1007-yet-again
Ansonhkg e35409f
Merge pull request #1011 from LIT-Protocol/copilot/sub-pr-1007-anothe…
Ansonhkg a58e77e
Merge pull request #1010 from LIT-Protocol/copilot/sub-pr-1007-again
Ansonhkg 209229e
Merge pull request #1009 from LIT-Protocol/copilot/sub-pr-1007
Ansonhkg e58308c
doc: add wrapped keys doc
Ansonhkg 79fe914
Initial plan
Copilot fb3817e
Initial plan
Copilot a43b122
Update packages/wrapped-keys/src/lib/api/update-encrypted-key.ts
Ansonhkg 505e2cf
docs: add detailed JSDoc documentation to UpdateEncryptedKeyParams
Copilot 582bbc2
Add test for updateEncryptedKey with evmContractConditions
Copilot 7b18213
Use realistic EVM contract conditions in test helper
Copilot be45d0f
Remove unused address parameter from createEvmContractConditions
Copilot 49de446
Merge pull request #1013 from LIT-Protocol/copilot/sub-pr-1007-one-mo…
Ansonhkg 688284e
Merge pull request #1014 from LIT-Protocol/copilot/sub-pr-1007-please…
Ansonhkg 9714eed
Merge branch 'naga' into feature/jss-141-add-update-function-for-wrap…
Ansonhkg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@lit-protocol/wrapped-keys': minor | ||
| '@lit-protocol/e2e': minor | ||
| --- | ||
|
|
||
| Wrapped-keys now supports updating ciphertext/ACCs via a new PUT endpoint, returns version history when requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
docs/sdk/sdk-reference/wrapped-keys/functions/updateEncryptedKey.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| title: updateEncryptedKey | ||
| --- | ||
|
|
||
| # Function | ||
|
|
||
| > **updateEncryptedKey**(`params`) | ||
|
|
||
| Re-encrypts an existing wrapped key and appends the previous state to the `versions` array. | ||
|
|
||
| ## Parameters | ||
|
|
||
| <ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required> | ||
| Session signatures identifying the PKP that owns the wrapped key. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.litClient" type="LitClient" required> | ||
| Lit client instance used to talk to the wrapped-keys service. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.id" type="string" required> | ||
| Identifier of the wrapped key to update. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.ciphertext" type="string" required> | ||
| New base64-encrypted ciphertext to store. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.memo" type="string"> | ||
| Optional updated memo for the wrapped key. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.evmContractConditions" type="string"> | ||
| Optional updated ACCs for EVM contract conditions. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="params.userMaxPrice" type="bigint"> | ||
| Optional price ceiling for the Lit Action. | ||
| </ParamField> | ||
|
|
||
| ## Returns | ||
|
|
||
| <ResponseField name="result" type="UpdateEncryptedKeyResult"> | ||
| Returns `id`, `pkpAddress`, and `updatedAt` of the updated wrapped key. | ||
| </ResponseField> | ||
|
|
||
| ## Example | ||
|
|
||
| ```ts | ||
| const res = await wrappedKeysApi.updateEncryptedKey({ | ||
| pkpSessionSigs, | ||
| litClient, | ||
| id, | ||
| ciphertext: 'base64-new', | ||
| memo: 'rotated memo', | ||
| }); | ||
|
|
||
| const withHistory = await wrappedKeysApi.getEncryptedKey({ | ||
| pkpSessionSigs, | ||
| litClient, | ||
| id, | ||
| includeVersions: true, | ||
| }); | ||
| console.log(withHistory.versions); // [{ ciphertext: 'old', ... }] | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { updatePrivateKey } from '../service-client'; | ||
| import { UpdateEncryptedKeyParams, UpdateEncryptedKeyResult } from '../types'; | ||
| import { | ||
| getFirstSessionSig, | ||
| getLitNetworkFromClient, | ||
| getPkpAddressFromSessionSig, | ||
| } from './utils'; | ||
|
|
||
| /** | ||
| * Updates an existing wrapped key and appends the previous state to versions. | ||
| * | ||
| * @param { UpdateEncryptedKeyParams } params Parameters required to update the encrypted private key | ||
| * @returns { Promise<UpdateEncryptedKeyResult> } An object containing the id, pkpAddress, and updatedAt timestamp of the updated key | ||
| */ | ||
| export async function updateEncryptedKey( | ||
| params: UpdateEncryptedKeyParams | ||
| ): Promise<UpdateEncryptedKeyResult> { | ||
| const { | ||
| pkpSessionSigs, | ||
| litClient, | ||
| id, | ||
| ciphertext, | ||
| evmContractConditions, | ||
| memo, | ||
| } = params; | ||
|
|
||
| const sessionSig = getFirstSessionSig(pkpSessionSigs); | ||
| const pkpAddress = getPkpAddressFromSessionSig(sessionSig); | ||
| const litNetwork = getLitNetworkFromClient(litClient); | ||
|
|
||
| return updatePrivateKey({ | ||
| pkpAddress, | ||
| id, | ||
| sessionSig, | ||
| ciphertext, | ||
| evmContractConditions, | ||
| memo, | ||
| litNetwork, | ||
| }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.