Skip to content

Commit

Permalink
VDX-308: || or ?? as option separator
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Nov 15, 2023
1 parent 52e40fc commit 81a005a
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 49 deletions.
6 changes: 3 additions & 3 deletions packages/agent/conf/demos/dbc/oid4vci_metadata/dbc.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/conf/demos/dbc/oid4vci_options/dbc.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/agent/conf/demos/fmdm/oid4vci_metadata/fmdm.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/conf/demos/fmdm/oid4vci_options/fmdm.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/agent/conf/demos/pf3/oid4vci_metadata/pf3.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/conf/demos/pf3/oid4vci_options/pf3.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/agent/conf/demos/triall/oid4vci_metadata/triall.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
15 changes: 7 additions & 8 deletions packages/agent/src/utils/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,22 @@ export function loadJsonFiles<T>({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
Expand Down

0 comments on commit 81a005a

Please sign in to comment.