Skip to content
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

feat: add reset command #170

Merged
merged 1 commit into from
Jan 25, 2024
Merged

feat: add reset command #170

merged 1 commit into from
Jan 25, 2024

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Jan 24, 2024

Adds a reset command so you can reset you agent and login again to gain access to spaces. Retains agent DID.

I called this reset and not logout because we can't guarantee the agent retains any delegations that are not associated with the currently logged in account(s).

$ w3 whoami
did:key:z6MkiK3h93N8kE6jmAgTWd33QmuyDcsMnaAeQrGjp9iixT2B

$ w3 space ls
  did:key:z6MkoEBnTj96thGj7H7c1DrdNHF4AiA9VPDRVqTmp4teYd6B 
  did:key:z6MketbAFtbeqDeVHxSzSSDH2PfMTquQ3vzZCcPFweXBGe3R 
  did:key:z6MkgVNAd3rDAtvYwp5NscNteZjqW496dERwkMWiDKcZ13xa 
  did:key:z6MkjCoKJcunQgzihb4tXBYDd9xunhpGNoC14HEypgAe5cNW 
  did:key:z6MkfUw42NQV6Gs8ZLr4sujwRFZGQ789LVuRfkgRxFnTkRBz 
* did:key:z6MkwDuRThQcyWjqNsK54yKAmzfsiH6BTkASyiucThMtHt1T Test

$ w3 reset   
⁂ Agent reset.

$ w3 whoami
did:key:z6MkiK3h93N8kE6jmAgTWd33QmuyDcsMnaAeQrGjp9iixT2B

$ w3 space ls

$ w3 login alan.shaw@protocol.ai
⁂ Agent was authorized by did:mailto:protocol.ai:alan.shaw

$ w3 space ls                   
  did:key:z6MkoEBnTj96thGj7H7c1DrdNHF4AiA9VPDRVqTmp4teYd6B 
  did:key:z6MketbAFtbeqDeVHxSzSSDH2PfMTquQ3vzZCcPFweXBGe3R 
  did:key:z6MkgVNAd3rDAtvYwp5NscNteZjqW496dERwkMWiDKcZ13xa 
* did:key:z6MkwDuRThQcyWjqNsK54yKAmzfsiH6BTkASyiucThMtHt1T Test
  did:key:z6MkmyzUC328sSpm8Mncq9aUZuXLsBtARMXhZnEqfWcq11sw Claimer
  did:key:z6MkjCoKJcunQgzihb4tXBYDd9xunhpGNoC14HEypgAe5cNW 
  did:key:z6MkfUw42NQV6Gs8ZLr4sujwRFZGQ789LVuRfkgRxFnTkRBz 

...and look I gained access to a space I didn't have before!

@alanshaw
Copy link
Member Author

Perhaps this should be available in the client?

if (exportData) {
let data = AgentData.fromExport(exportData)
// do not reset the principal
data = await AgentData.create({ principal: data.principal, meta: data.meta })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I read the code and didn't see how it would not just re-import the same proofs fromExport. This (imho) makes it more obvious what's going on. just a idea

Suggested change
data = await AgentData.create({ principal: data.principal, meta: data.meta })
data = await AgentData.create({ principal: data.principal, meta: data.meta, delegations: undefined })

@alanshaw alanshaw merged commit 8eea385 into main Jan 25, 2024
1 check passed
@alanshaw alanshaw deleted the feat/reset branch January 25, 2024 12:15
vasco-santos pushed a commit that referenced this pull request Jan 25, 2024
🤖 I have created a release *beep* *boop*
---


##
[7.5.0](v7.4.0...v7.5.0)
(2024-01-25)


### Features

* add reset command
([#170](#170))
([8eea385](8eea385))


### Bug Fixes

* use remove from client
([#167](#167))
([96966ba](96966ba))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants