feat: add delegation ls and delegation revoke commands with local cleanup#368
Open
Pranav-1100 wants to merge 4 commits intostoracha:mainfrom
Open
feat: add delegation ls and delegation revoke commands with local cleanup#368Pranav-1100 wants to merge 4 commits intostoracha:mainfrom
Pranav-1100 wants to merge 4 commits intostoracha:mainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR brings the remaining delegation management commands from the JS client over to Guppy so we can manage and revoke the permission slips we give out right from the terminal. Resolves #367.
Here is a breakdown of what was added:
guppy delegation ls
A local command that queries the agent store to list all permission slips given away by this agent. It filters out received proofs and internal session proofs so you only see what you've actually delegated to others.
guppy delegation revoke :
A network command that invokes the ucan/revoke capability to permanently blacklist a specific UCAN CID on the Storacha servers.
Core SDK Fix (RemoveDelegation):
While building revoke, I noticed the Go client lacked the JS client's ability to delete a specific delegation locally. I added RemoveDelegation(cid) to the agentstore.Store interface (along with memory/fs implementations and tests). Now, when a delegation is successfully revoked on the network, it is properly deleted from the user's local config file, preventing ghost delegations from cluttering up delegation ls.
Fix for delegation create:
I updated guppy delegation create to automatically save the newly created delegation to the local agent datastore via c.AddProofs(). Before this, it wasn't saving locally, which meant delegation ls couldn't actually index or find them.
Verification with Output
$ guppy delegation create did:key:z6Mkk... did:key:z6Mk4... -c "space/info" bafy..... $ guppy delegation ls Delegations created by this agent: CID: bafy..... Audience: did:key:z6Mk4..... Capabilities: - space/info (with: did:key:z6Mk4.....) Total: 1 delegation(s)$ guppy delegation revoke bafy...... Revoking delegation bafy..... Success! Delegation has been revoked. $ guppy delegation ls No external delegations created by this agent found.