From 5cb18d50a08739a5df2cc9719f7fde0a9ed864db Mon Sep 17 00:00:00 2001 From: sander Date: Wed, 15 Nov 2023 10:59:54 +0100 Subject: [PATCH 1/3] VDX-308: env var support in agent configs --- .../conf/demos/dbc/oid4vci_metadata/dbc.json | 6 +-- .../conf/demos/dbc/oid4vci_options/dbc.json | 2 +- .../oid4vci_metadata/energyshr.json | 6 +-- .../energy-shr/oid4vci_options/energyshr.json | 2 +- .../demos/fmdm/oid4vci_metadata/fmdm.json | 6 +-- .../conf/demos/fmdm/oid4vci_options/fmdm.json | 2 +- .../oid4vci_metadata/knb_van_auckland.json | 6 +-- .../oid4vci_options/knb_van_auckland.json | 2 +- .../{babylon => bank}/dids/jwk-es256k.json | 0 .../oid4vci_metadata/knb_bank.json} | 6 +-- .../oid4vci_options}/knb_bank.json | 2 +- .../oid4vp_options/knb_bank.json} | 2 +- .../presentation_definitions/knb_bank.json | 0 .../templates/knb_bank/BankAccount.hbs | 0 .../knb/kvk/oid4vci_metadata/knb_kvk.json | 6 +-- .../knb/kvk/oid4vci_options/knb_kvk.json | 2 +- .../conf/demos/pf3/oid4vci_metadata/pf3.json | 6 +-- .../conf/demos/pf3/oid4vci_options/pf3.json | 2 +- .../oid4vci_metadata/sphereonGuest.json | 6 +-- .../oid4vci_options/sphereonGuest.json | 2 +- .../demos/triall/oid4vci_metadata/triall.json | 6 +-- .../demos/triall/oid4vci_options/triall.json | 2 +- .../banqup/oid4vci_metadata/banqup.json | 6 +-- .../banqup/oid4vci_options/banqup.json | 2 +- packages/agent/src/utils/generic.ts | 40 ++++++++++++++----- 25 files changed, 72 insertions(+), 50 deletions(-) rename packages/agent/conf/demos/knb/{babylon => bank}/dids/jwk-es256k.json (100%) rename packages/agent/conf/demos/knb/{babylon/oid4vci_metadata/knb_babylon.json => bank/oid4vci_metadata/knb_bank.json} (93%) rename packages/agent/conf/demos/knb/{babylon/oid4vp_options => bank/oid4vci_options}/knb_bank.json (56%) rename packages/agent/conf/demos/knb/{babylon/oid4vci_options/knb_van_auckland.json => bank/oid4vp_options/knb_bank.json} (56%) rename packages/agent/conf/demos/knb/{babylon => bank}/presentation_definitions/knb_bank.json (100%) rename packages/agent/conf/demos/knb/{babylon => bank}/templates/knb_bank/BankAccount.hbs (100%) diff --git a/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json b/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json index 163ce0e3..2c29f2aa 100644 --- a/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json +++ b/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json @@ -1,9 +1,9 @@ { - "correlationId": "https://ssi.dutchblockchaincoalition.org/agent", + "correlationId": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://ssi.dutchblockchaincoalition.org/agent", - "credential_endpoint": "https://ssi.dutchblockchaincoalition.org/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "Dutch Blockchain Coalition", diff --git a/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json b/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json index 852bd8c7..05e48148 100644 --- a/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json +++ b/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json @@ -1,6 +1,6 @@ { "definitionId": "dbc2023", - "correlationId": "https://ssi.dutchblockchaincoalition.org/agent", + "correlationId": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json index 2225060e..9a091515 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json @@ -1,9 +1,9 @@ { - "correlationId": "https://ssi.energyshr.test.sphereon.com/issuer", + "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://ssi.energyshr.test.sphereon.com/issuer", - "credential_endpoint": "https://ssi.energyshr.test.sphereon.com/issuer/credentials", + "credential_issuer": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "credential_endpoint": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer/credentials", "display": [ { "name": "EnergySHR", diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json index a94962b0..f6f93fa4 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json @@ -1,6 +1,6 @@ { "definitionId": "energySHR", - "correlationId": "https://ssi.energyshr.test.sphereon.com/issuer", + "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json index 15769e53..4d37883a 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json @@ -1,9 +1,9 @@ { - "correlationId": "https://ssi.future-mobility-alliance.org/issuer", + "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://ssi.future-mobility-alliance.org/issuer", - "credential_endpoint": "https://ssi.future-mobility-alliance.org/issuer/credentials", + "credential_issuer": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "credential_endpoint": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer/credentials", "display": [ { "name": "Future Mobility Alliance", diff --git a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json index 06577f8b..4d023cac 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json @@ -1,6 +1,6 @@ { "definitionId": "fmdm2023", - "correlationId": "https://ssi.future-mobility-alliance.org/issuer", + "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json index 66c1e1c1..93991a49 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json @@ -1,9 +1,9 @@ { - "correlationId": "https://notary.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://notary.demo.sphereon.com/agent", - "credential_endpoint": "https://notary.demo.sphereon.com/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "credential_endpoint": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", "display": [ { "name": "Van Auckland notaries", diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json index c7eb05c6..408514d1 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json @@ -1,6 +1,6 @@ { "definitionId": "knb-auckland", - "correlationId": "https://notary.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/babylon/dids/jwk-es256k.json b/packages/agent/conf/demos/knb/bank/dids/jwk-es256k.json similarity index 100% rename from packages/agent/conf/demos/knb/babylon/dids/jwk-es256k.json rename to packages/agent/conf/demos/knb/bank/dids/jwk-es256k.json diff --git a/packages/agent/conf/demos/knb/babylon/oid4vci_metadata/knb_babylon.json b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json similarity index 93% rename from packages/agent/conf/demos/knb/babylon/oid4vci_metadata/knb_babylon.json rename to packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json index e59c0a28..2f83ae89 100644 --- a/packages/agent/conf/demos/knb/babylon/oid4vci_metadata/knb_babylon.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json @@ -1,9 +1,9 @@ { - "correlationId": "https://bank.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://bank.demo.sphereon.com/agent", - "credential_endpoint": "https://bank.demo.sphereon.com/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "credential_endpoint": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", "display": [ { "name": "Babylon Bank", diff --git a/packages/agent/conf/demos/knb/babylon/oid4vp_options/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json similarity index 56% rename from packages/agent/conf/demos/knb/babylon/oid4vp_options/knb_bank.json rename to packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json index 06232a50..0f1f3c0a 100644 --- a/packages/agent/conf/demos/knb/babylon/oid4vp_options/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "https://bank.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/babylon/oid4vci_options/knb_van_auckland.json b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json similarity index 56% rename from packages/agent/conf/demos/knb/babylon/oid4vci_options/knb_van_auckland.json rename to packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json index 06232a50..0f1f3c0a 100644 --- a/packages/agent/conf/demos/knb/babylon/oid4vci_options/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "https://bank.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/babylon/presentation_definitions/knb_bank.json b/packages/agent/conf/demos/knb/bank/presentation_definitions/knb_bank.json similarity index 100% rename from packages/agent/conf/demos/knb/babylon/presentation_definitions/knb_bank.json rename to packages/agent/conf/demos/knb/bank/presentation_definitions/knb_bank.json diff --git a/packages/agent/conf/demos/knb/babylon/templates/knb_bank/BankAccount.hbs b/packages/agent/conf/demos/knb/bank/templates/knb_bank/BankAccount.hbs similarity index 100% rename from packages/agent/conf/demos/knb/babylon/templates/knb_bank/BankAccount.hbs rename to packages/agent/conf/demos/knb/bank/templates/knb_bank/BankAccount.hbs diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json index 0e90a906..ba835869 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json @@ -1,9 +1,9 @@ { - "correlationId": "https://kvk.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://kvk.demo.sphereon.com/agent", - "credential_endpoint": "https://kvk.demo.sphereon.com/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "credential_endpoint": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", "display": [ { "name": "Kamer van koophandel", diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json index 20e5c3c7..39012ab2 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json @@ -1,6 +1,6 @@ { "definitionId": "knb-kvk", - "correlationId": "https://kvk.demo.sphereon.com/agent", + "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json b/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json index 49eff990..ba8ecffa 100644 --- a/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json +++ b/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json @@ -1,9 +1,9 @@ { - "correlationId": "https://ssi.sphereon.com/pf3", + "correlationId": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://ssi.sphereon.com/pf3", - "credential_endpoint": "https://ssi.sphereon.com/pf3/credentials", + "credential_issuer": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "Sphereon", diff --git a/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json b/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json index 2c785a88..3d3aed6c 100644 --- a/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json +++ b/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json @@ -1,6 +1,6 @@ { "definitionId": "pf3", - "correlationId": "https://ssi.sphereon.com/pf3", + "correlationId": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json b/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json index 6e4c4ab9..66ed9df0 100644 --- a/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json +++ b/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json @@ -1,9 +1,9 @@ { - "correlationId": "http://internet.or.LAN.host:5000/sphereonGuest", + "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", "overwriteExisting": true, "metadata": { - "credential_issuer": "http://internet.or.LAN.host:5000/sphereonGuest", - "credential_endpoint": "http://internet.or.LAN.host:5000/sphereonGuest/credentials", + "credential_issuer": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", + "credential_endpoint": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }/credentials", "display": [ { "name": "Sphereon International", diff --git a/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json b/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json index 08d9b1a7..fc6cd4ae 100644 --- a/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json +++ b/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json @@ -1,6 +1,6 @@ { "definitionId": "sphereonGuest", - "correlationId": "http://internet.or.LAN.host:5000/sphereonGuest", + "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json b/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json index e7940363..7dcea2f6 100644 --- a/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json +++ b/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json @@ -1,9 +1,9 @@ { - "correlationId": "https://ssi.triall.io/issuer", + "correlationId": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://ssi.triall.io/issuer", - "credential_endpoint": "https://ssi.triall.io/issuer/credentials", + "credential_issuer": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "Triall", diff --git a/packages/agent/conf/demos/triall/oid4vci_options/triall.json b/packages/agent/conf/demos/triall/oid4vci_options/triall.json index b8ce071b..e620ecc2 100644 --- a/packages/agent/conf/demos/triall/oid4vci_options/triall.json +++ b/packages/agent/conf/demos/triall/oid4vci_options/triall.json @@ -1,6 +1,6 @@ { "definitionId": "triall2023", - "correlationId": "https://ssi.triall.io/issuer", + "correlationId": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json b/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json index 2e44c185..5dc2f27b 100644 --- a/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json +++ b/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json @@ -1,9 +1,9 @@ { - "correlationId": "https://agent.banqup.demo.sphereon.com", + "correlationId": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "https://agent.banqup.demo.sphereon.com", - "credential_endpoint": "https://agent.banqup.demo.sphereon.com/credentials", + "credential_issuer": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "Banqup", diff --git a/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json b/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json index c45dfbe0..6664db92 100644 --- a/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json +++ b/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json @@ -1,6 +1,6 @@ { "definitionId": "banqup", - "correlationId": "https://agent.banqup.demo.sphereon.com", + "correlationId": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/src/utils/generic.ts b/packages/agent/src/utils/generic.ts index 6147920c..f6d70bd3 100644 --- a/packages/agent/src/utils/generic.ts +++ b/packages/agent/src/utils/generic.ts @@ -1,11 +1,10 @@ -import fs from "fs"; +import fs from 'fs' export function loadJsonFiles({path}: { path: string }): { names: string[], fileNames: string[], - asObject: Record + asObject: Record, asArray: T[] - } { const fileNames = fs.readdirSync(path).filter(file => file.match(/\.json$/)) const names: string[] = [] @@ -20,8 +19,12 @@ export function loadJsonFiles({path}: { path: string }): { names.push(name) files.push(fileName) const jsonFilePath = `${path}/${fileName}` + try { - const object = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8').toString()) as T + let content = fs.readFileSync(jsonFilePath, 'utf8').toString() + content = substituteEnvVars(content) + + const object = JSON.parse(content) as T asObject[name] = object asArray.push(object) } catch (e) { @@ -32,28 +35,47 @@ export function loadJsonFiles({path}: { path: string }): { } } }) + return {names, fileNames: files, asObject, asArray} } +function substituteEnvVars(content: string): string { + const envVarRegex = /\$\{([^}]+)}/g + return content.replace(envVarRegex, (_, vars) => { + const options = vars.split('|').map((opt: string) => opt.trim()) + for (const option of options) { + if (option.startsWith("'") && option.endsWith("'")) { + return option.slice(1, -1) + } + const envValue = process.env[option] + if (envValue !== undefined && envValue !== null && envValue.trim() !== '') { + return envValue + } + } + return '' + }) +} + + /** * The function builds a file path without missing or excess slashes * @param segments */ export function normalizeFilePath(...segments: (string | null | undefined)[]): string { - let result = ''; + let result = '' for (let i = 0; i < segments.length; i++) { - const segment = segments[i]; + const segment = segments[i] if (segment !== null && segment !== undefined && segment !== '') { if (i === 0) { // For the first non-null and non-empty segment, remove the trailing slash if it exists - result += segment.replace(/\/$/, ''); + result += segment.replace(/\/$/, '') } else { // For subsequent segments, ensure all slashes are present - result += `/${segment.replace(/^\//, '').replace(/\/$/, '')}`; + result += `/${segment.replace(/^\//, '').replace(/\/$/, '')}` } } } - return result; + return result } From 52e40fc88cc0f2c115a8065cf46e8ca0c0f309b6 Mon Sep 17 00:00:00 2001 From: sander Date: Wed, 15 Nov 2023 11:30:36 +0100 Subject: [PATCH 2/3] VDX-308: env var support in agent configs fix --- .../conf/demos/energy-shr/oid4vci_metadata/energyshr.json | 6 +++--- .../conf/demos/energy-shr/oid4vci_options/energyshr.json | 2 +- packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json | 6 +++--- packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json | 2 +- .../knb/auckland/oid4vci_metadata/knb_van_auckland.json | 6 +++--- .../knb/auckland/oid4vci_options/knb_van_auckland.json | 2 +- .../conf/demos/knb/bank/oid4vci_metadata/knb_bank.json | 6 +++--- .../agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json | 2 +- .../agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json | 2 +- .../agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json | 6 +++--- .../agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json index 9a091515..0eb0f7f6 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", - "credential_endpoint": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer/credentials", + "credential_issuer": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "EnergySHR", diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json index f6f93fa4..fbaf961c 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json @@ -1,6 +1,6 @@ { "definitionId": "energySHR", - "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json index 4d37883a..b9f0ac50 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", - "credential_endpoint": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer/credentials", + "credential_issuer": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", "display": [ { "name": "Future Mobility Alliance", diff --git a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json index 4d023cac..95495a32 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json @@ -1,6 +1,6 @@ { "definitionId": "fmdm2023", - "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/issuer", + "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json index 93991a49..44036516 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", - "credential_endpoint": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}/credentials", "display": [ { "name": "Van Auckland notaries", diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json index 408514d1..14b2b9e0 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json @@ -1,6 +1,6 @@ { "definitionId": "knb-auckland", - "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json index 2f83ae89..f9504391 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", - "credential_endpoint": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}/credentials", "display": [ { "name": "Babylon Bank", diff --git a/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json index 0f1f3c0a..22525f41 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json index 0f1f3c0a..22525f41 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json index ba835869..fab5c68d 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", - "credential_endpoint": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent/credentials", + "credential_issuer": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}/credentials", "display": [ { "name": "Kamer van koophandel", diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json index 39012ab2..9ba6b60a 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json @@ -1,6 +1,6 @@ { "definitionId": "knb-kvk", - "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | 'http://localhost:5000'}/agent", + "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" From 81a005a034a686162b29f86d8d4b52807291a9c8 Mon Sep 17 00:00:00 2001 From: sander Date: Wed, 15 Nov 2023 16:19:02 +0100 Subject: [PATCH 3/3] VDX-308: || or ?? as option separator --- .../conf/demos/dbc/oid4vci_metadata/dbc.json | 6 +++--- .../agent/conf/demos/dbc/oid4vci_options/dbc.json | 2 +- .../energy-shr/oid4vci_metadata/energyshr.json | 6 +++--- .../energy-shr/oid4vci_options/energyshr.json | 2 +- .../conf/demos/fmdm/oid4vci_metadata/fmdm.json | 6 +++--- .../conf/demos/fmdm/oid4vci_options/fmdm.json | 2 +- .../oid4vci_metadata/knb_van_auckland.json | 6 +++--- .../oid4vci_options/knb_van_auckland.json | 2 +- .../demos/knb/bank/oid4vci_metadata/knb_bank.json | 6 +++--- .../demos/knb/bank/oid4vci_options/knb_bank.json | 2 +- .../demos/knb/bank/oid4vp_options/knb_bank.json | 2 +- .../demos/knb/kvk/oid4vci_metadata/knb_kvk.json | 6 +++--- .../demos/knb/kvk/oid4vci_options/knb_kvk.json | 2 +- .../conf/demos/pf3/oid4vci_metadata/pf3.json | 6 +++--- .../agent/conf/demos/pf3/oid4vci_options/pf3.json | 2 +- .../oid4vci_metadata/sphereonGuest.json | 6 +++--- .../oid4vci_options/sphereonGuest.json | 2 +- .../demos/triall/oid4vci_metadata/triall.json | 6 +++--- .../conf/demos/triall/oid4vci_options/triall.json | 2 +- .../banqup/oid4vci_metadata/banqup.json | 6 +++--- .../banqup/oid4vci_options/banqup.json | 2 +- packages/agent/src/utils/generic.ts | 15 +++++++-------- 22 files changed, 48 insertions(+), 49 deletions(-) diff --git a/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json b/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json index 2c29f2aa..f4e3356a 100644 --- a/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json +++ b/packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_DBC ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_DBC ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_DBC ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "Dutch Blockchain Coalition", diff --git a/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json b/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json index 05e48148..8c7226d4 100644 --- a/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json +++ b/packages/agent/conf/demos/dbc/oid4vci_options/dbc.json @@ -1,6 +1,6 @@ { "definitionId": "dbc2023", - "correlationId": "${AGENT_ENDPOINT_DBC | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_DBC ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json index 0eb0f7f6..06e100b3 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_metadata/energyshr.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_ESHR ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_ESHR ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_ESHR ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "EnergySHR", diff --git a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json index fbaf961c..f1db7c57 100644 --- a/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json +++ b/packages/agent/conf/demos/energy-shr/oid4vci_options/energyshr.json @@ -1,6 +1,6 @@ { "definitionId": "energySHR", - "correlationId": "${AGENT_ENDPOINT_ESHR | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_ESHR ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json index b9f0ac50..869b46bf 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_FMDM ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_FMDM ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_FMDM ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "Future Mobility Alliance", diff --git a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json index 95495a32..ba115bea 100644 --- a/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json +++ b/packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json @@ -1,6 +1,6 @@ { "definitionId": "fmdm2023", - "correlationId": "${AGENT_ENDPOINT_FMDM | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_FMDM ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json index 44036516..ed5f7b61 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_metadata/knb_van_auckland.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_NOTARY ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_NOTARY ?? AGENT_ENDPOINT ?? http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_NOTARY ?? AGENT_ENDPOINT ?? http://localhost:5000'}/credentials", "display": [ { "name": "Van Auckland notaries", diff --git a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json index 14b2b9e0..67c48aed 100644 --- a/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json +++ b/packages/agent/conf/demos/knb/auckland/oid4vci_options/knb_van_auckland.json @@ -1,6 +1,6 @@ { "definitionId": "knb-auckland", - "correlationId": "${AGENT_ENDPOINT_NOTARY | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_NOTARY ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json index f9504391..58ab2516 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_metadata/knb_bank.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_BANK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_BANK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_BANK ?? AGENT_ENDPOINT ?? http://localhost:5000'}/credentials", "display": [ { "name": "Babylon Bank", diff --git a/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json index 22525f41..7ee87920 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vci_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_BANK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json index 22525f41..7ee87920 100644 --- a/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json +++ b/packages/agent/conf/demos/knb/bank/oid4vp_options/knb_bank.json @@ -1,6 +1,6 @@ { "definitionId": "knb-bank", - "correlationId": "${AGENT_ENDPOINT_BANK | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_BANK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json index fab5c68d..bc4f4cb6 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_metadata/knb_kvk.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_KVK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_KVK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_KVK ?? AGENT_ENDPOINT ?? http://localhost:5000'}/credentials", "display": [ { "name": "Kamer van koophandel", diff --git a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json index 9ba6b60a..5a5c0050 100644 --- a/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json +++ b/packages/agent/conf/demos/knb/kvk/oid4vci_options/knb_kvk.json @@ -1,6 +1,6 @@ { "definitionId": "knb-kvk", - "correlationId": "${AGENT_ENDPOINT_KVK | AGENT_ENDPOINT | http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_KVK ?? AGENT_ENDPOINT ?? http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json b/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json index ba8ecffa..7bff0229 100644 --- a/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json +++ b/packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_PF3 ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_PF3 ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_PF3 ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "Sphereon", diff --git a/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json b/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json index 3d3aed6c..0a6da9c1 100644 --- a/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json +++ b/packages/agent/conf/demos/pf3/oid4vci_options/pf3.json @@ -1,6 +1,6 @@ { "definitionId": "pf3", - "correlationId": "${AGENT_ENDPOINT_PF3 | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_PF3 ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json b/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json index 66ed9df0..18b95cd9 100644 --- a/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json +++ b/packages/agent/conf/demos/sphereonGuest/oid4vci_metadata/sphereonGuest.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", + "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST ?? AGENT_ENDPOINT ?? 'http://localhost:5000' }", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", - "credential_endpoint": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }/credentials", + "credential_issuer": "${AGENT_ENDPOINT_SPHEREONGUEST ?? AGENT_ENDPOINT ?? 'http://localhost:5000' }", + "credential_endpoint": "${AGENT_ENDPOINT_SPHEREONGUEST ?? AGENT_ENDPOINT ?? 'http://localhost:5000' }/credentials", "display": [ { "name": "Sphereon International", diff --git a/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json b/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json index fc6cd4ae..5cff49a5 100644 --- a/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json +++ b/packages/agent/conf/demos/sphereonGuest/oid4vci_options/sphereonGuest.json @@ -1,6 +1,6 @@ { "definitionId": "sphereonGuest", - "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST | AGENT_ENDPOINT | 'http://localhost:5000' }", + "correlationId": "${AGENT_ENDPOINT_SPHEREONGUEST ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json b/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json index 7dcea2f6..3a819f97 100644 --- a/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json +++ b/packages/agent/conf/demos/triall/oid4vci_metadata/triall.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_TRIALL ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_TRIALL ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_TRIALL ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "Triall", diff --git a/packages/agent/conf/demos/triall/oid4vci_options/triall.json b/packages/agent/conf/demos/triall/oid4vci_options/triall.json index e620ecc2..a1fed586 100644 --- a/packages/agent/conf/demos/triall/oid4vci_options/triall.json +++ b/packages/agent/conf/demos/triall/oid4vci_options/triall.json @@ -1,6 +1,6 @@ { "definitionId": "triall2023", - "correlationId": "${AGENT_ENDPOINT_TRIALL | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_TRIALL ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json b/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json index 5dc2f27b..037c7ca5 100644 --- a/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json +++ b/packages/agent/conf/demos/unified-post/banqup/oid4vci_metadata/banqup.json @@ -1,9 +1,9 @@ { - "correlationId": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_BANQUP ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "overwriteExisting": true, "metadata": { - "credential_issuer": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", - "credential_endpoint": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}/credentials", + "credential_issuer": "${AGENT_ENDPOINT_BANQUP ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", + "credential_endpoint": "${AGENT_ENDPOINT_BANQUP ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}/credentials", "display": [ { "name": "Banqup", diff --git a/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json b/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json index 6664db92..eaa3d64d 100644 --- a/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json +++ b/packages/agent/conf/demos/unified-post/banqup/oid4vci_options/banqup.json @@ -1,6 +1,6 @@ { "definitionId": "banqup", - "correlationId": "${AGENT_ENDPOINT_BANQUP | AGENT_ENDPOINT | 'http://localhost:5000'}", + "correlationId": "${AGENT_ENDPOINT_BANQUP ?? AGENT_ENDPOINT ?? 'http://localhost:5000'}", "issuerOpts": { "didOpts": { "checkLinkedDomains": "if_present" diff --git a/packages/agent/src/utils/generic.ts b/packages/agent/src/utils/generic.ts index f6d70bd3..6fab983f 100644 --- a/packages/agent/src/utils/generic.ts +++ b/packages/agent/src/utils/generic.ts @@ -40,23 +40,22 @@ export function loadJsonFiles({path}: { path: string }): { } function substituteEnvVars(content: string): string { - const envVarRegex = /\$\{([^}]+)}/g + const envVarRegex = /\$\{([^}]+)}/g; return content.replace(envVarRegex, (_, vars) => { - const options = vars.split('|').map((opt: string) => opt.trim()) + const options = vars.split(/(?:\|\|)|(?:\?\?)/).map((opt: string) => opt.trim()).filter(Boolean); for (const option of options) { if (option.startsWith("'") && option.endsWith("'")) { - return option.slice(1, -1) + return option.slice(1, -1); } - const envValue = process.env[option] + const envValue = process.env[option]; if (envValue !== undefined && envValue !== null && envValue.trim() !== '') { - return envValue + return envValue; } } - return '' - }) + return ''; + }); } - /** * The function builds a file path without missing or excess slashes * @param segments