@trustvc/w3c-cli
TypeScript icon, indicating that this package has built-in type declarations

1.2.15 • Public • Published

TrustVC W3C CLI

w3c-cli is a command-line interface tool designed to demonstrate how to interact with Verifiable Credentials (VCs) and Decentralized Identifiers (DIDs) using functions from the following repositories:

This CLI provides a quick and straightforward way for users to:

  • Create key pairs
  • Generate well-known DIDs
  • Generate a signed Credential Status
  • Sign and verify VCs via the command line.

Table of Contents

Installation

  1. Install CLI:

[!NOTE] Remember to install the cli globally

npm install -g @trustvc/w3c-cli
  1. Run the CLI commands as needed:
w3c-cli <command>

How It Works

  • Generating Key Pairs: The CLI utilizes the generateKeyPair function from the w3c-issuer repository to generate key pairs, These key pairs are essential for creating DIDs and signing VCs.

  • 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 as a unique identifier in decentralized systems.

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

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

  • Generating a Signed Credential Status: The CLI creates a Bitstring StatusList from the w3c-credential-status repository and uses the createCredentialStatusPayload function to generate the pre-signed VC. It is then signed with the signCredential function from the w3c-vc repository, returning a signed Credential Status VC, which users can self-host.

  • Updating a Signed Credential Status: The CLI updates a signed Credential Status VC by downloading the hosted Credential Status VC. It then validates and parses the Bitstring StatusList, iteratively updating the StatusList, and signing the updated Credential Status using the signCredential function from the w3c-vc repository. Finally, it returns an updated signed Credential Status VC, which users can self-host.

Commands

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

w3c-cli key-pair

This command generates a DID key pair, importing functions from the w3c-issuer repository. The generated key pairs are used to create DIDs and sign VCs.

w3c-cli did

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

w3c-cli sign

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

w3c-cli 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.

w3c-cli credential-status create

This command creates a signed Credential Status VC using the Bitstring StatusList.

w3c-cli credential-status update

This command updates any existing Credential Status VC and resign the Credential Status after it has been updated.

Directory Structure

Each command file is located in the src/commands directory and imports relevant functions from the w3c-issuer, w3c-vc and w3c-credential-status repositories.

├── src
│   └── commands
│       ├── credentialStatus
│       |   ├── create.ts
│       |   └── update.ts
│       ├── credential-status.ts
│       ├── did.ts
│       ├── key-pair.ts
│       ├── sign.ts
│       └── verify.ts
├── package.json
└── README.md

/@trustvc/w3c-cli/

    Package Sidebar

    Install

    npm i @trustvc/w3c-cli

    Weekly Downloads

    175

    Version

    1.2.15

    License

    Apache-2.0

    Unpacked Size

    36.4 kB

    Total Files

    13

    Last publish

    Collaborators

    • imda.trustvc
    • nghaninn