Configuration
The main steps needed to customize the project according to your own business logic are listed below; in addition the project contains some TODO
comment in order to highlight the necessary steps to customize the service.
Environment Variable
The following environment variables are expected by the service:
VERIFIABLE_CREDENTIAL_CONFIG
: path where to read the configuration mapping fileVERIFIABLE_CREDENTIAL_JWK
: JWK used to generate the JWTVERIFIABLE_CREDENTIAL_JWA
: JWA used to generrate the JWTFLOW_MANAGER_URL
: endpoint to flow manager service
Verifiable Credentials Schema
The service read a configuration JSON file with static information that will be filled with dynamic data provided by the input body in order to generate the verifiable credentials.
The following steps can be done in order to customize the verifiable credential schema generated by the service:
- change the configuration file with the static information of the verifiable credentials
- change the schema defined in
/src/utils/vcSchema.ts
- customize the logic of
generateVerifiableCredentialPayload
function inside/src/services/vcService.ts
file
By the default the /vc/default.json
file is used:
{
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential"
],
"issuer": "change-me"
}
Mapping
The service can handle different static JSON file.
All files will be saved in the same folder, defined in the VERIFIABLE_CREDENTIAL_CONFIG
environment variable.
With the VERIFIABLE_CREDENTIAL_CONFIG
environment variable can be defined the JSON file with the list of all the static files that can be used in order to generate the verifiable credentials.
By default, the default file will be always used for the verifiable credential generation, but it is possible to change this behavior change with the following steps:
- add a new element inside the configuration mapping file
- change
verifiableCredentialConfigurationSchema
schema inside/src/utils/schema.ts
file - change the mapping logic defined in the
getVcConfiguration
function inside/src/services/vcService.ts
file
By the default the /config/vcMapping.json
file is used:
{
"default": "/vc/default.json"
}
JWT
Once the verifiable credential is generated the microservice computes the JWT and returned it to as a response. In order to change the JWT generated you can change the following environment variables:
VERIFIABLE_CREDENTIAL_JWK
: JWK used to generate the JWTVERIFIABLE_CREDENTIAL_JWA
: JWA used to generrate the JWT
Kafka configuration
In order to enable Kafka usage, the following environment variables are required:
- MODE=
KAFKA
- KAFKA_CONFIG_FILE_PATH path to configuration file with kafka config
The configuration file has the following schema:
{
"type": "object",
"required": [
"clientId",
"brokers",
"authMechanism",
"username",
"password",
"consumerConfig",
"producerConfig",
],
"properties": {
"clientId": { "type": "string" },
"brokers": { "type": "string" },
"authMechanism": { "type": "string" },
"username": { "type": "string" },
"password": { "type": "string" },
"connectionTimeout": { "type": "number" },
"authenticationTimeout": { "type": "number" },
"connectionRetries": { "type": "number" },
"consumerConfig": {
"type": "object",
"required": [
"groupId",
"topic",
],
"properties": {
"topic": { "type": "string" },
"groupId": { "type": "string" },
"sessionTimeout": { "type": "number" },
"rebalanceTimeout": { "type": "number" },
"heartbeatInterval": { "type": "number" },
"allowAutoTopicCreation": { "type": "boolean" },
},
},
"producerConfig": {
"type": "object",
"required": [
"topic",
],
"properties": {
"topic": { "type": "string" },
"allowAutoTopicCreation": { "type": "boolean" },
},
},
},
}
Refer to KafkaJS documentation for more information about properties meaning.