Skip to content

Commit

Permalink
Pass ListSource instance to writer and list manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Feb 18, 2024
1 parent b14fef9 commit 6170707
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 42 deletions.
15 changes: 7 additions & 8 deletions lib/CredentialStatusIssuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import assert from 'assert-plus';
import {CredentialStatusWriter} from './CredentialStatusWriter.js';
import {getIssuerAndSuite} from './helpers.js';
import {ListSource} from './ListSource.js';
import {logger} from './logger.js';
import {constants as rlConstants} from '@bedrock/vc-revocation-list-context';
import {constants as slConstants} from '@bedrock/vc-status-list-context';
Expand Down Expand Up @@ -55,25 +56,23 @@ export class CredentialStatusIssuer {
}
}

// FIXME: this process should setup writers for the N-many statuses ...
// for which the configuration should have zcaps/oauth privileges to
// connect to those status services and register VCs for status tracking
// and / or update status

// FIXME: this process should use the status list config to setup
// list sources (that use zcaps/oauth privileges create lists on demand)
// FIXME: the status service will need to issue and serve the SLC on
// demand -- and use cases may require redirection URLs for this
// FIXME: the status service will need access to its own other issuer
// instance for issuing SLCs
// FIXME: remove `issuer` and `suite` these will be handled by a status
// service instead

const {issuer, suite} = await getIssuerAndSuite({config, suiteName});
const listSource = new ListSource({
statusListConfig, documentLoader, edvClient, issuer, suite
});
writers.push(new CredentialStatusWriter({
statusListConfig,
documentLoader,
edvClient,
issuer,
suite
listSource
}));
}
}
Expand Down
19 changes: 5 additions & 14 deletions lib/CredentialStatusWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,15 @@ writer.finish():
5. Clear instance's LS.
*/
export class CredentialStatusWriter {
constructor({
statusListConfig, documentLoader, edvClient,
issuer, suite
} = {}) {
constructor({statusListConfig, documentLoader, edvClient, listSource} = {}) {
assert.object(statusListConfig, 'statusListConfig');
assert.func(documentLoader, 'documentLoader');
assert.object(edvClient, 'edvClient');
assert.string(issuer, 'issuer');
assert.object(suite, 'suite');
if(!issuer) {
throw new TypeError('"issuer" must be a non-empty string.');
}
assert.object(listSource, 'listSource');
this.statusListConfig = statusListConfig;
this.documentLoader = documentLoader;
this.edvClient = edvClient;
this.issuer = issuer;
this.suite = suite;
this.listSource = listSource;
this.listShard = null;
}

Expand Down Expand Up @@ -171,13 +163,12 @@ export class CredentialStatusWriter {
if(shardQueue.length === 0) {
// 2.1. Create a ListManager instance `listManager`.
// 2.2. Call listManager.getShard() and store result in the instance.
const {documentLoader, edvClient, issuer, suite} = this;
const {documentLoader, edvClient, listSource} = this;
const listManager = new ListManager({
statusListConfig,
documentLoader,
edvClient,
issuer,
suite
listSource
});
this.listShard = await listManager.getShard();
} else {
Expand Down
23 changes: 3 additions & 20 deletions lib/ListManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import assert from 'assert-plus';
import {Bitstring} from '@digitalbazaar/bitstring';
import {generateLocalId} from './helpers.js';
import {IndexAllocationCache} from './IndexAllocationCache.js';
import {ListSource} from './ListSource.js';

/* Notes: The following notes explain the scaling design for assigning
status list (SL) indexes to VCs in a parallel fashion. This design
Expand Down Expand Up @@ -200,34 +199,18 @@ Other notes:
least one IAD for every concurrently issuable VC.
*/
export class ListManager {
// FIXME: pass in ListSource API instance
constructor({
statusListConfig, documentLoader, edvClient,
issuer, suite
} = {}) {
constructor({statusListConfig, documentLoader, edvClient, listSource} = {}) {
assert.object(statusListConfig, 'statusListConfig');
assert.func(documentLoader, 'documentLoader');
assert.object(edvClient, 'edvClient');
assert.string(issuer, 'issuer');
assert.object(suite, 'suite');
if(!issuer) {
throw new TypeError('"issuer" must be a non-empty string.');
}
assert.object(listSource, 'listSource');
this.statusListConfig = statusListConfig;
this.documentLoader = documentLoader;
this.edvClient = edvClient;
this.listSource = listSource;
this.lmDoc = null;
this.activeCache = null;
this.conflicts = 0;

// FIXME: remove issuer/suite; part of ListSource/status list service
this.issuer = issuer;
this.suite = suite;
// FIXME: pass in list source instance
this.listSource = new ListSource({
statusListConfig, documentLoader, edvClient,
issuer, suite
});
}

async getShard() {
Expand Down

0 comments on commit 6170707

Please sign in to comment.