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 w3 name get-key command #2107

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
10 changes: 8 additions & 2 deletions packages/w3/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1 align="center">⁂<br/>web3.storage</h1>
<p align="center">The CLI for web3.storage</p>

## Getting started
## Getting started

Install the CLI from npm
Install the CLI from npm

```console
$ npm install -g @web3-storage/w3
Expand Down Expand Up @@ -99,6 +99,12 @@ Working with name records simply updates the Web3.Storage cache of data.

Resolve the current IPNS record revision for the passed name.

### `w3 name get-key <keyId>`

**❗️Experimental** this command may not work, may change, and may be removed.

Retrieve the signing key associated with the passed name.

### `w3 name rm <keyId>`

**❗️Experimental** this command may not work, may change, and may be removed.
Expand Down
5 changes: 5 additions & 0 deletions packages/w3/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ cli.command('name resolve <keyId>')
.example('name resolve k51qzi5uqu5dlcuzv5xhg1zqn48gobcvn2mx13uoig7zfj8rz6zvqdxsugka9z')
.action(Name.resolve)

cli.command('name get-key <keyId>')
.describe('Retrieve the signing key associated with the passed name.')
.example('name get k51qzi5uqu5dlcuzv5xhg1zqn48gobcvn2mx13uoig7zfj8rz6zvqdxsugka9z')
.action(Name.getKey)

cli.command('name rm <keyId>')
.describe('Remove an IPNS name managed by this utility. Note: this does NOT unpublish the IPNS name, it simply removes the IPNS name and signing key from local config.')
.example('name rm k51qzi5uqu5dlcuzv5xhg1zqn48gobcvn2mx13uoig7zfj8rz6zvqdxsugka9z')
Expand Down
12 changes: 12 additions & 0 deletions packages/w3/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ export async function resolve (keyId) {
console.log(revision.value)
}

/**
* Retrieve the signing key associated with the given key.
* @param {string} keyId
*/
export function getKey (keyId) {
const signingKey = config.get(`name.${keyId}`)
if (!signingKey) {
throw new Error('missing signing key for the provided <keyId>')
}
console.log(signingKey)
}

/**
* @param {string} keyId
*/
Expand Down