UNPKG

@gleif-it/vlei-verifier-workflows

Version:

Workflows for vLEI users and vLEI credentials for the vLEI-verifier service

34 lines (33 loc) 1.14 kB
import { buildCredentials, } from './utils/handle-json-config.js'; import { RULES, SCHEMAS, witnessIds } from './constants.js'; export class WorkflowState { static instance; configJson; schemas = SCHEMAS; rules = RULES; clients = new Map(); aids = new Map(); oobis = new Map(); credentialsInfo = new Map(); registries = new Map(); credentials = new Map(); aidsInfo = new Map(); kargsAID = witnessIds.length > 0 ? { toad: witnessIds.length, wits: witnessIds } : {}; constructor(configJson) { this.configJson = configJson; this.credentialsInfo = buildCredentials(configJson); } static getInstance(configJson = null) { if (!WorkflowState.instance) { if (!configJson) throw 'WorkflowState.getInstance: no configJson was provided'; WorkflowState.instance = new WorkflowState(configJson); } return WorkflowState.instance; } static resetInstance() { if (WorkflowState.instance) { WorkflowState.instance = new WorkflowState(WorkflowState.instance.configJson); } } }