This project provides a set of utilities for handling verifiable credentials, including creating, signing, verifying, and managing cryptographic keys. The utilities are designed to work with Bun, a fast JavaScript runtime.
-
Key Generation: Generate RSA key pairs and automatically update the
.env
file with the generated keys. - Credential Creation: Create verifiable credentials in compliance with W3C standards.
- Signing and Verification: Sign credentials and verify their authenticity using RSA signatures.
- Command-Line Interface (CLI): A CLI tool for key generation and other utilities.
To install the dependencies, use Bun:
bun install
To build the project, use the following command:
bun run build
This will generate the JavaScript files and TypeScript declaration files in the dist
directory.
You can generate RSA keys and update the .env
file using the CLI:
bunx verifiable-credentials-utils keygen
Use the createCoinCredential
function to create a new verifiable credential:
import { createCoinCredential } from './create';
const credential = createCoinCredential({
type: 'Coin',
amount: 100,
holder: 'https://example.com/holder',
});
To sign a credential, use the signCredential
function:
import { signCredential } from './sign';
import { VerifiableCredential } from './schemas';
const signedCredential = signCredential<VerifiableCredential>(credential);
To verify the authenticity of a signed credential:
import { verifyCredential } from './verify';
const isValid = verifyCredential(signedCredential);
-
src/: Contains the TypeScript source files.
- cli.ts: The entry point for the CLI.
- constants.ts: Common constants used throughout the project.
- create.ts: Logic for creating verifiable credentials.
-
keygen.ts: Key generation logic and
.env
management. - schemas.ts: Zod schemas for data validation.
- sign.ts: Functions for signing credentials.
- verify.ts: Functions for verifying credentials.
- utils.ts: Utility functions.
- build: Build the project using Bun.
- version: Bump the version before committing and pushing.
- prepublishOnly: Ensure the project is built before publishing.
- pre-commit: Runs the build script before committing changes.
- pre-push: Bumps the version before pushing to the remote repository.
This project is licensed under the MIT License.