This directory contains example implementations of DID Web VH resolvers using different frameworks:
- Elysia Resolver - A resolver built with the Elysia framework (Bun)
- Express Resolver - A resolver built with Express (Node.js)
Both examples demonstrate functioning DID resolution with proper Ed25519 cryptographic verification.
- Bun - Fast JavaScript runtime and package manager
- Node.js (for Express example)
The Elysia resolver demonstrates a resolver with a custom Ed25519 verifier that extends the AbstractCrypto class:
bun examples/elysia-resolver.tsThis will start the resolver on port 3010.
The Express resolver demonstrates a resolver with an HSM Ed25519 implementation:
bun examples/express-resolver.tsThis will start the resolver on port 8000.
You can test both resolvers by making HTTP requests to the resolution endpoints:
# Elysia resolver
curl "http://localhost:3010/resolve/did:web:example.com"
# Express resolver
curl "http://localhost:8000/resolve/did:web:example.com"You can pass various query parameters for version control:
# Version number
curl "http://localhost:3010/resolve/did:web:example.com?versionNumber=1"
# Version ID
curl "http://localhost:3010/resolve/did:web:example.com?versionId=abc123"
# Version time
curl "http://localhost:3010/resolve/did:web:example.com?versionTime=2023-12-01T00:00:00Z"
# Verification method
curl "http://localhost:3010/resolve/did:web:example.com?verificationMethod=key-1"The Elysia resolver uses an ElysiaVerifier class that:
- Extends the
AbstractCryptoclass - Implements the
Verifierinterface for verification - Uses Ed25519 for cryptographic operations via
@stablelib/ed25519 - Demonstrates proper verification of Ed25519 signatures
The Express resolver uses an HSMSigner class that:
- Implements both
SignerandVerifierinterfaces directly - Simulates an HSM (Hardware Security Module) for secure Ed25519 key operations
- Provides a production-ready example of Ed25519 verification
Both examples follow a similar structure:
- Ed25519 Verifier Implementation: Proper cryptographic verification using the Ed25519 algorithm
- DID Resolution: Endpoints for resolving DIDs using the
didwebvh-tslibrary - File Handling: Logic for retrieving resources associated with DIDs
- Error Handling: Proper error reporting for various scenarios
These examples demonstrate proper Ed25519 cryptographic verification but should be reviewed for your specific security requirements before use in production:
- Key management should be handled securely (HSM, key vaults, etc.)
- Input validation should be robust
- Error handling should not leak sensitive information
- Rate limiting may be needed in production deployments
See the project's main license file for details.