https://github.com/or13/did-jwk
did:jwk sdk & cli
https://github.com/or13/did-jwk
cli did jose
Last synced: 7 months ago
JSON representation
did:jwk sdk & cli
- Host: GitHub
- URL: https://github.com/or13/did-jwk
- Owner: OR13
- License: mit
- Created: 2022-09-06T14:37:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T15:18:32.000Z (almost 3 years ago)
- Last Synced: 2025-03-12T05:32:11.902Z (7 months ago)
- Topics: cli, did, jose
- Language: JavaScript
- Homepage: https://github.com/OR13/did-jwk
- Size: 156 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# did-jwk
- [method spec](https://github.com/quartzjer/did-jwk)
```bash
npm i @or13/did-jwk --save# install cli globally
npm i -g @or13/did-jwk
```## Use
### CLI
### Generate Key
```
did-jwk generate-key EdDSA
```### Generate For Purpose
```
did-jwk generate-for authenticity
did-jwk generate-for privacy
```### Sign & Verify
```
did-jwk generate-for authenticity > k0.json
echo '{"message": "hello"}' > m0.json
did-jwk sign ./k0.json ./m0.json > m0.signed.json
did-jwk verify ./m0.signed.json --decode
```### Encrypt & Decrypt
```
did-jwk generate-for privacy > k1.json
echo '{"message": "hello"}' > m0.json
did-jwk create ./k1.json > recipient_id.json
did-jwk encrypt `cat ./recipient_id.json | jq '.id'` ./m0.json > m0.encrypted.json
did-jwk decrypt ./k1.json ./m0.encrypted.json --decode
```## Development
```bash
npm i
npm t# to test the cli.
npm i -g .
```### CLI
### Generate Key
Create a private key
```
npm run did-jwk generate-key EdDSA --silent > ./src/cli-examples/key.json
```### Generate Key For Operation
Create a private key
```
npm run did-jwk generate-for authenticity --silent > ./src/cli-examples/key.authenticity.json
npm run did-jwk generate-for privacy --silent > ./src/cli-examples/key.privacy.json
```### Create DID
Create a DID.
```
npm run did-jwk create ./src/cli-examples/key.json --silent > ./src/cli-examples/id.json
npm run did-jwk create ./src/cli-examples/key.privacy.json --silent > ./src/cli-examples/id.encrypt.json
```### Resolve DID
Resolve a DID
```
npm run did-jwk resolve `cat ./src/cli-examples/id.json | jq '.id'` --silent > ./src/cli-examples/resolution.json
```### Dereference DID
Dereference a DID.
```
npm run did-jwk dereference `cat ./src/cli-examples/id.json | jq '.id'`#0 --silent > ./src/cli-examples/dereference.json
```### Sign
Sign as a DID
```
npm run did-jwk sign ./src/cli-examples/key.json ./src/cli-examples/message.json --silent > ./src/cli-examples/message.signed.json
```### Verify
Verify with a DID
```
npm run did-jwk verify ./src/cli-examples/message.signed.json --silent > ./src/cli-examples/message.verified.json
```Verify and decode
```
npm run did-jwk verify ./src/cli-examples/message.signed.json -- --decode
```### Encrypt to a DID
Encrypt to a DID
```
npm run did-jwk encrypt `cat ./src/cli-examples/id.encrypt.json | jq '.id'` ./src/cli-examples/message.json --silent > ./src/cli-examples/message.encrypted.json
```### Encrypt with a Private Key
Decrypt with a private key
```
npm run did-jwk decrypt ./src/cli-examples/key.privacy.json ./src/cli-examples/message.encrypted.json --silent > ./src/cli-examples/message.decrypted.json
```Decrypt and decode as text
```
npm run did-jwk decrypt ./src/cli-examples/key.privacy.json ./src/cli-examples/message.encrypted.json -- --decode
```