-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add init script for initialising issuance dids, schemas and credentia…
…l definitions (#73) * Add init script for initialising issuance dids, schemas and credential definitions * Cache created logger
- Loading branch information
1 parent
2ab8070
commit 8df6698
Showing
20 changed files
with
1,295 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
INBOUND_TRANSPORT="[{\"transport\": \"http\", \"port\": 5002}, {\"transport\": \"ws\", \"port\": 5003}]" | ||
OUTBOUND_TRANSPORT="http,ws" | ||
ADMIN_PORT=3000 | ||
IPFS_ORIGIN=http://ipfs:5001 | ||
POSTGRES_PORT=5432 | ||
POSTGRES_USERNAME=postgres | ||
POSTGRES_PASSWORD=postgres | ||
LABEL=vertiable-cloudagent |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'reflect-metadata' | ||
|
||
import dotenv from 'dotenv' | ||
import envalid from 'envalid' | ||
import { pino } from 'pino' | ||
|
||
import { PartialEnv, envConfig } from './env.js' | ||
import { type ILogger } from './logger.js' | ||
import { CredentialSchema } from './models/credentialSchema.js' | ||
import VeritableCloudagent from './models/veritableCloudagent.js' | ||
|
||
type InitConfigKeys = | ||
| 'CLOUDAGENT_ADMIN_ORIGIN' | ||
| 'LOG_LEVEL' | ||
| 'ISSUANCE_DID_POLICY' | ||
| 'ISSUANCE_SCHEMA_POLICY' | ||
| 'ISSUANCE_CRED_DEF_POLICY' | ||
|
||
class InitEnv implements PartialEnv<InitConfigKeys> { | ||
private values: Pick<envalid.CleanedEnv<typeof envConfig>, InitConfigKeys> | ||
|
||
constructor() { | ||
if (process.env.NODE_ENV === 'test') { | ||
dotenv.config({ path: 'test/test.env' }) | ||
} else { | ||
dotenv.config() | ||
} | ||
|
||
this.values = envalid.cleanEnv(process.env, { | ||
CLOUDAGENT_ADMIN_ORIGIN: envConfig.CLOUDAGENT_ADMIN_ORIGIN, | ||
LOG_LEVEL: envConfig.LOG_LEVEL, | ||
ISSUANCE_DID_POLICY: envConfig.ISSUANCE_DID_POLICY, | ||
ISSUANCE_SCHEMA_POLICY: envConfig.ISSUANCE_SCHEMA_POLICY, | ||
ISSUANCE_CRED_DEF_POLICY: envConfig.ISSUANCE_CRED_DEF_POLICY, | ||
}) | ||
} | ||
|
||
get<K extends InitConfigKeys>(key: K) { | ||
return this.values[key] | ||
} | ||
} | ||
const env = new InitEnv() | ||
|
||
const logger: ILogger = pino( | ||
{ | ||
name: 'veritable-ui-init', | ||
timestamp: true, | ||
level: env.get('LOG_LEVEL'), | ||
}, | ||
process.stdout | ||
) | ||
const cloudagent = new VeritableCloudagent(env, logger) | ||
const init = new CredentialSchema(env, logger, cloudagent) | ||
const details = await init.assertIssuanceRecords() | ||
logger.info(details, 'Asserted credential issuance records with: %o', details) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.