@nuwa-ai/identity-kit- Express middleware
- Rooch DID resolution (
did:rooch:*)
nuwa-kit/typescript/examples/did-check.
What You Build
- Public endpoints:
/health,/info - Protected endpoint:
/whoami - Middleware that verifies
Authorization: DIDAuthV1 ...
1) Install
2) Bootstrap Identity Environment
Your backend only needs DID resolution to verify signatures. You do not need a service private key for verification-only endpoints.3) Add DIDAuth Middleware
4) Protect Routes
Request Format
Backend expects this header:DIDAuth.v1.createSignature() + DIDAuth.v1.toAuthorizationHeader(), or with nuwa-id CLI (nuwa-id curl / nuwa-id auth-header).
Configuration
| Variable | Description | Default |
|---|---|---|
ROOCH_NETWORK | Rooch network (e.g. main, test, dev, local) | main |
ROOCH_NODE_URL | Custom Rooch RPC URL | auto-detected by network |
PORT | HTTP port | 3004 |
DEBUG | Enable debug logs | false |
Local Validation
Run the complete example:nuwa-id) to:
GET http://localhost:3004/whoami
Production Notes
- Keep middleware strict: fail closed on missing or invalid auth headers.
- Log caller DID and key id for auditing.
- If you front with API Gateway/Proxy, preserve the original
Authorizationheader. - For public internet deployments, add rate limiting before DIDAuth verification.
verifyAuthHeader()uses an in-memory nonce store by default. In multi-instance deployments, pass a sharednonceStore(for example Redis-backed) to keep replay protection consistent across replicas.

