1.1.0 • Published 9 months ago

@nghaninn/w3c-cli v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

w3c-cli

w3c-cli is a command-line interface tool designed to demonstrate how to interact with verifiable credentials and DIDs (Decentralized Identifiers) using functions from the w3c-issuer and w3c-vc repositories. This CLI serves as a quick and straightforward way for users to generate well-known DIDs, create DID key pairs, and sign and verify verifiable credentials via the command line.

Table of Contents

Installation

  1. Clone the repository:
git clone <repository-url>
cd w3c-cli
  1. Install dependencies:
npm install
  1. Run the CLI commands as needed:
npm run dev <command>

How It Works

  • Generating Well-Known DID: The CLI uses the issueDID function from the w3c-issuerrepository to generate a well-known DID. This allows users to self-host their DID, serving as a unique identifier in decentralized systems.

  • Generating DID Key Pairs: The CLI utilizes the generateKeyPair function from the w3c-issuer repository to generate DID key pairs. These key pairs are essential for both creating and signing DIDs, as well as for signing Verifiable Credentials (VCs).

  • Signing Verifiable Credentials: Using the signCredential function from the w3c-vc repository, the CLI digitally signs a Verifiable Credential, ensuring that the credential is tamper-evident and can be trusted by external verifiers.

  • Verifying Verifiable Credentials:: The verifyCredential function from the w3c-vc repository verifies the authenticity of a signed Verifiable Credential by checking the cryptographic proof, ensuring that the credential has not been altered and confirming the validity of the issuer’s signature.

Commands

The CLI provides several commands to help users interact with DIDs and Verifiable Credentials:

npm run dev did

This command generates a well-known DID using functionality from the w3c-issuer repository, allowing users to self-host their own DID.

npm run dev generate

This command generates a DID key pair, importing functions from the w3c-issuer repository. The key pairs are used for creating and signing DIDs, as well as for signing verifiable credentials.

npm run dev sign

The sign command allows you to digitally sign a Verifiable Credential. It leverages the w3c-vc repository to create cryptographic proofs for the credentials, ensuring that the data remains tamper-evident and can be verified by any trusted party.

npm run dev verify

This command verifies the authenticity of a signed Verifiable Credential using the cryptographic proofs generated by the w3c-vc repository. It ensures that the credential has not been altered and confirms the validity of the issuer’s signature.

Directory Structure

Each command file (did.ts, generate.ts, sign.ts, verify.ts) is located in the src/commands directory and imports relevant functions from the w3c-issuer and w3c-vc repositories.

├── src
│   └── commands
│       ├── did.ts
│       ├── generate.ts
│       ├── sign.ts
│       └── verify.ts
├── package.json
└── README.md