diff --git a/.env.example b/.env.example index f8e6cab..d3085f6 100644 --- a/.env.example +++ b/.env.example @@ -16,7 +16,7 @@ TENANT_SEED_RANDOMTESTING=generate TENANT_SEED_DEFAULT=generate # see the README for an explanation of logging -LOG_ALL_FILE=logs/all.log +ALL_LOG_FILE=logs/all.log ERROR_LOG_FILE=logs/error.log CONSOLE_LOG_LEVEL=silly # default is silly, i.e. log everything - see the README for allowed levels LOG_LEVEL=silly # default is silly \ No newline at end of file diff --git a/README.md b/README.md index 2f629e0..4649b5b 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,10 @@ There is a sample .env file provided called .env.example to help you get started | `PORT` | http port on which to run the express app | 4006 | no | | `ENABLE_HTTPS_FOR_DEV` | runs the dev server over https - ONLY FOR DEV - typically to allow CORS calls from a browser | false | no | | `TENANT_SEED_{TENANT_NAME}` | see [tenants](#tenants) section for instructions | no | no | -|`TENANT_DIDMETHOD_{TENANT_NAME}` | did method (`key` or `web`) to use for signing on this tenant | `key` | no | +|`TENANT_DID_METHOD_{TENANT_NAME}` | did method (`key` or `web`) to use for signing on this tenant | `key` | no | | `TENANT_DID_URL_{TENANT_NAME}` | url to use for did:web | | no | | `ERROR_LOG_FILE` | log file for all errors - see [Logging](#logging) | no | no | -| `LOG_ALL_FILE` | log file for everything - see [Logging](#logging) | no | no | +| `ALL_LOG_FILE` | log file for everything - see [Logging](#logging) | no | no | | `CONSOLE_LOG_LEVEL` | console log level - see [Logging](#logging) | silly | no | | `LOG_LEVEL` | log level for application - see [Logging](#logging) | silly | no | @@ -89,7 +89,7 @@ There is a sample .env file provided called .env.example to help you get started You might want to allow more than one signing key ([DID](https://www.w3.org/TR/did-core/)) to be used with the issuer. For example, you might want to sign university/college degree diplomas with a key ([DID](https://www.w3.org/TR/did-core/)) that is only used by the registrar, but then also allow certificates for individual courses to be signed by by different keys ([DIDs](https://www.w3.org/TR/did-core/)) that are owned by the faculty or department that teaches the course. -We're calling these differents signing authorities 'tenants' (or 'instances'). You can set up as many tenants as you like by including a `TENANT_SEED_{TENANT_NAME}={seed}` environment variable for every 'tenant'. (NOTE: if you are using a did:web key, you must additinally specify `TENANT_DIDMETHOD_{TENANT_NAME}=web` and `TENANT_DID_URL_{TENANT_NAME}={the url for your did:web}`) for each did:web tenant. Read more in the [did:web generator section](#didweb-generator). +We're calling these differents signing authorities 'tenants' (or 'instances'). You can set up as many tenants as you like by including a `TENANT_SEED_{TENANT_NAME}={seed}` environment variable for every 'tenant'. (NOTE: if you are using a did:web key, you must additinally specify `TENANT_DID_METHOD_{TENANT_NAME}=web` and `TENANT_DID_URL_{TENANT_NAME}={the url for your did:web}`) for each did:web tenant. Read more in the [did:web generator section](#didweb-generator). NOTE: the `seed` is explained below in the [Signing key section](#signing-key). @@ -307,7 +307,7 @@ and save that in a file called did.json at the url where you'll host the documen ```https://raw.githubusercontent.com/jchartrand/didWebTest/main/.well-known/did.json``` -You must also set `TENANT_DIDMETHOD_{TENANT_NAME}=web` and set `TENANT_DID_URL_{TENANT_NAME}` to the url where your `.well-known/did.json` did-document is hosted, which for this example would be: +You must also set `TENANT_DID_METHOD_{TENANT_NAME}=web` and set `TENANT_DID_URL_{TENANT_NAME}` to the url where your `.well-known/did.json` did-document is hosted, which for this example would be: ```https://raw.githubusercontent.com/jchartrand/didWebTest/main``` @@ -329,7 +329,7 @@ The issuer is by default set up to use the did:key implemenation of a [DID](http The did:web implementation is preferable for production becuase it allows you to rotate (change) your signing keys whithout having to update every document that points at the old keys. -To use it set `TENANT_DIDMETHOD_{TENANT_NAME}=web` and set `TENANT_DID_URL_{TENANT_NAME}` to the url where your `.well-known/did.json` did-document is hosted. +To use it set `TENANT_DID_METHOD_{TENANT_NAME}=web` and set `TENANT_DID_URL_{TENANT_NAME}` to the url where your `.well-known/did.json` did-document is hosted. ## Usage @@ -544,7 +544,7 @@ There are also two log files that can be enabled: Enable each log by setting an env variable for each, indicating the path to the appropriate file, like this example: ``` -LOG_ALL_FILE=logs/all.log +ALL_LOG_FILE=logs/all.log ERROR_LOG_FILE=logs/error.log ``` diff --git a/src/app.test.js b/src/app.test.js index a6bcc8f..97bed94 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -152,13 +152,13 @@ describe('api', () => { resetConfig() process.env[`TENANT_SEED_${tenantName}`] = 'z1AeiPT496wWmo9BG2QYXeTusgFSZPNG3T9wNeTtjrQ3rCB' - process.env[`TENANT_DIDMETHOD_${tenantName}`] = 'web' + process.env[`TENANT_DID_METHOD_${tenantName}`] = 'web' process.env[`TENANT_DID_URL_${tenantName}`] = 'https://example.com' }) after(() => { delete process.env[`TENANT_SEED_${tenantName}`] - delete process.env[`TENANT_DIDMETHOD_${tenantName}`] + delete process.env[`TENANT_DID_METHOD_${tenantName}`] delete process.env[`TENANT_DID_URL_${tenantName}`] }) diff --git a/src/config.js b/src/config.js index 178b905..d0efc41 100644 --- a/src/config.js +++ b/src/config.js @@ -39,8 +39,8 @@ async function parseTenantSeeds() { DID_SEEDS[tenantName] = { didSeed: await decodeSeed(value), didMethod: - process.env[`TENANT_DIDMETHOD_${tenant}`] && - process.env[`TENANT_DIDMETHOD_${tenant}`].toLowerCase() === 'web' + process.env[`TENANT_DID_METHOD_${tenant}`] && + process.env[`TENANT_DID_METHOD_${tenant}`].toLowerCase() === 'web' ? 'web' : 'key', didUrl: process.env[`TENANT_DID_URL_${tenant}`] @@ -56,7 +56,7 @@ function parseConfig() { env.CONSOLE_LOG_LEVEL?.toLocaleLowerCase() || defaultConsoleLogLevel, logLevel: env.LOG_LEVEL?.toLocaleLowerCase() || defaultLogLevel, errorLogFile: env.ERROR_LOG_FILE, - logAllFile: env.LOG_ALL_FILE, + allLogFile: env.ALL_LOG_FILE, port: env.PORT ? parseInt(env.PORT) : defaultPort }) return config diff --git a/src/config.test.js b/src/config.test.js index 4f2d880..1d6d805 100644 --- a/src/config.test.js +++ b/src/config.test.js @@ -11,7 +11,7 @@ describe('Config', () => { beforeEach(async () => { resetConfig() delete process.env[`TENANT_SEED_${tenantName}`] - delete process.env[`TENANT_DIDMETHOD_${tenantName}`] + delete process.env[`TENANT_DID_METHOD_${tenantName}`] }) afterEach(async () => {}) @@ -27,7 +27,7 @@ describe('Config', () => { it('uses DID:key when requested', async () => { process.env[`TENANT_SEED_${tenantName}`] = 'z1AeiPT496wWmo9BG2QYXeTusgFSZPNG3T9wNeTtjrQ3rCB' - process.env[`TENANT_DIDMETHOD_${tenantName}`] = 'key' + process.env[`TENANT_DID_METHOD_${tenantName}`] = 'key' const seed = await getTenantSeed('configtest') expect(seed.didMethod).to.eql('key') }) @@ -35,7 +35,7 @@ describe('Config', () => { it('uses DID:web when requested', async () => { process.env[`TENANT_SEED_${tenantName}`] = 'z1AeiPT496wWmo9BG2QYXeTusgFSZPNG3T9wNeTtjrQ3rCB' - process.env[`TENANT_DIDMETHOD_${tenantName}`] = 'web' + process.env[`TENANT_DID_METHOD_${tenantName}`] = 'web' const seed = await getTenantSeed('configtest') expect(seed.didMethod).to.eql('web') }) diff --git a/src/test-fixtures/.env.testing b/src/test-fixtures/.env.testing index 8f9e72a..6326975 100644 --- a/src/test-fixtures/.env.testing +++ b/src/test-fixtures/.env.testing @@ -1,7 +1,7 @@ PORT=4007 ENABLE_HTTPS_FOR_DEV=false -LOG_ALL_FILE=logs/all.log +ALL_LOG_FILE=logs/all.log ERROR_LOG_FILE=logs/error.log CONSOLE_LOG_LEVEL=silly # default is silly, i.e. log everything - see the README for allowed levels LOG_LEVEL=silly # default is silly diff --git a/src/test-fixtures/vc.js b/src/test-fixtures/vc.js index f153fb6..ebe9aaa 100644 --- a/src/test-fixtures/vc.js +++ b/src/test-fixtures/vc.js @@ -2,7 +2,6 @@ const unsignedVC = { '@context': [ 'https://www.w3.org/2018/credentials/v1', 'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json', - 'https://w3id.org/vc/status-list/2021/v1', 'https://w3id.org/security/suites/ed25519-2020/v1' ], id: 'urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1', @@ -45,7 +44,7 @@ const unsignedVC = { // "credentialStatus": const credentialStatus = { id: 'https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4#16', - type: 'StatusList2021Entry', + type: 'BitstringStatusListEntry', statusPurpose: 'revocation', statusListIndex: 16, statusListCredential: @@ -70,13 +69,11 @@ const getUnsignedVCWithStatus = () => { } const ed25519_2020suiteContext = 'https://w3id.org/security/suites/ed25519-2020/v1' -const statusListContext = 'https://w3id.org/vc/status-list/2021/v1' export { getUnsignedVC, getUnsignedVCWithoutSuiteContext, getCredentialStatus, getUnsignedVCWithStatus, - ed25519_2020suiteContext, - statusListContext + ed25519_2020suiteContext } diff --git a/src/utils/logger.js b/src/utils/logger.js index edeba99..9b2b96a 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -1,7 +1,7 @@ import winston from 'winston' import { getConfig } from '../config.js' -const { errorLogFile, logAllFile, logLevel, consoleLogLevel } = getConfig() +const { errorLogFile, allLogFile, logLevel, consoleLogLevel } = getConfig() /* These are the default npm logging levels that Winston uses, but we include them explicitly @@ -59,10 +59,10 @@ if (errorLogFile) { ) } -if (logAllFile) { +if (allLogFile) { transports.push( new winston.transports.File({ - filename: logAllFile + filename: allLogFile }) ) }