NATS server setup
The repository ships a minimalnats-server.conf:
nats-server.conf
The
no_tls: true setting is suitable for local development and private networks. In production, configure TLS termination at a load balancer or enable TLS directly in nats-server.conf.Docker Compose
Run a NATS server alongside the platform services:docker-compose.yml
.env
Authentication types
The auth type is controlled byNATS_AUTH_TYPE. The same value applies to every microservice unless overridden by NOTIFICATION_NATS_AUTH_TYPE for the notification service.
- nkey (default)
- creds
- usernamePassword
- none
Each service authenticates with its own NKey seed. This is the recommended method for production deployments.The
.env
getNatsOptions helper in libs/common/src/nats.config.ts encodes each seed with TextEncoder and passes it to nkeyAuthenticator.Reconnection behavior
The platform configures automatic reconnection via theNATSReconnects enum (defined in libs/enum/src/enum.ts). The getNatsOptions function applies:
| Option | Source |
|---|---|
maxReconnectAttempts | NATSReconnects.maxReconnectAttempts |
reconnectTimeWait | NATSReconnects.reconnectTimeWait |
Service-to-subject mapping
Each microservice registers on NATS as a queue group using its service name constant fromCommonConstants. The API Gateway acts as the sole publisher; services consume from their respective subjects.
| Service constant | NATS queue name |
|---|---|
API_GATEWAY_SERVICE | api-gateway |
USER_SERVICE | user |
ORGANIZATION_SERVICE | organization |
AGENT_SERVICE | agent-service |
AGENT_PROVISIONING | agent-provisioning |
ISSUANCE_SERVICE | issuance |
VERIFICATION_SERVICE | verification |
CONNECTION_SERVICE | connection |
SCHEMA_SERVICE | schema |
CREDENTIAL_DEFINITION_SERVICE | credential-definition |
ECOSYSTEM_SERVICE | ecosystem |
UTILITY_SERVICE | utilitites |
GEO_LOCATION_SERVICE | geo-location |
NOTIFICATION_SERVICE | notification |
OIDC4VC_ISSUANCE_SERVICE | oid4vc-issuance |
OIDC4VC_VERIFICATION_SERVICE | oid4vc-verification |
X509_SERVICE | x509-service |
JetStream configuration
JetStream provides durable, at-least-once delivery for event streams. Configure the stream names and consumer behavior with the following variables.Name of the JetStream stream that carries aggregate domain events. Default:
aggregate.Name of the JetStream stream for DID creation notifications. Default:
did-notify.Name of the durable pull consumer attached to the streams above. Default:
hub-pull-consumer.How long (in nanoseconds) JetStream waits for an acknowledgement before redelivering a message. Default:
10_000.Maximum number of delivery attempts before a message is considered dead-lettered. Default:
4.Example JetStream environment block
.env
Notification service override
The notification service can use a different NATS auth type than the rest of the platform. This is useful when the notification pathway connects to a separate NATS cluster..env
ENABLE_NATS_NOTIFICATION=false (the default), the NATS notification pathway is disabled regardless of NOTIFICATION_NATS_AUTH_TYPE.
How the API Gateway connects
The API Gateway bootstrap inapps/api-gateway/src/main.ts connects to NATS as a microservice transport:
apps/api-gateway/src/main.ts
getNatsOptions selects the authenticator based on NATS_AUTH_TYPE and assembles the server list from NATS_URL. Multiple NATS URLs (for clustering) are supported as comma-separated values.