@bedrock/vc-verifier 23.3.1 → 23.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,10 +99,10 @@ export async function createDocumentLoader({
99
99
  // use web loader if configured and instance config allows it (or it is
100
100
  // allowed by an allow list) and the url starts with `http` (and the core
101
101
  // config allows it, i.e., `webLoader` exists)
102
- const allowRemoteContexts = !config.verifyOptions?.documentLoader ||
102
+ const allowRemote = !config.verifyOptions?.documentLoader ||
103
103
  config.verifyOptions.documentLoader.allowRemoteContexts ||
104
104
  remoteUrlAllowList?.has(url);
105
- if(allowRemoteContexts &&
105
+ if(allowRemote &&
106
106
  url.startsWith('http') && e.name === 'NotFoundError' && webLoader) {
107
107
  return webLoader(url);
108
108
  }
package/lib/index.js CHANGED
@@ -6,9 +6,9 @@ import {
6
6
  addCborldRoutes, addContextRoutes
7
7
  } from '@bedrock/service-context-store';
8
8
  import {createService, schemas} from '@bedrock/service-core';
9
+ import {initializeServiceAgent, refreshZcaps} from '@bedrock/service-agent';
9
10
  import {addCaStoreRoutes as addMdlCaStoreRoutes} from './mdl.js';
10
11
  import {addRoutes} from './http.js';
11
- import {initializeServiceAgent} from '@bedrock/service-agent';
12
12
  import {verifyOptions} from '../schemas/bedrock-vc-verifier.js';
13
13
 
14
14
  // load config defaults
@@ -16,6 +16,9 @@ import './config.js';
16
16
 
17
17
  const serviceType = 'vc-verifier';
18
18
 
19
+ // export programmatic access to workflow service
20
+ export let verifierService;
21
+
19
22
  bedrock.events.on('bedrock.init', async () => {
20
23
  // add customizations to config validators...
21
24
  const createConfigBody = structuredClone(schemas.createConfigBody);
@@ -26,7 +29,7 @@ bedrock.events.on('bedrock.init', async () => {
26
29
  }
27
30
 
28
31
  // create `vc-verifier` service
29
- const service = await createService({
32
+ const service = verifierService = await createService({
30
33
  serviceType,
31
34
  routePrefix: '/verifiers',
32
35
  storageCost: {
@@ -47,7 +50,25 @@ bedrock.events.on('bedrock.init', async () => {
47
50
  }, {
48
51
  referenceId: 'keyAgreementKey',
49
52
  required: true
53
+ }, {
54
+ referenceId: 'refresh',
55
+ required: false
50
56
  }]
57
+ },
58
+ async refreshHandler({record, signal}) {
59
+ // for testing purposes only
60
+ if(service._disableRefreshHandler) {
61
+ return;
62
+ }
63
+ // refresh zcaps and update record w/results
64
+ const result = await refreshZcaps({
65
+ serviceType, config: record.config, signal
66
+ });
67
+ const config = result.config ?? record.config;
68
+ await service.configStorage.update({
69
+ config: {...config, sequence: config.sequence + 1},
70
+ refresh: result.refresh
71
+ });
51
72
  }
52
73
  });
53
74
 
package/lib/status.js CHANGED
@@ -108,8 +108,22 @@ export function createCheckStatus({config} = {}) {
108
108
  credential,
109
109
  documentLoader
110
110
  };
111
- return await handlers.checkStatus(options);
111
+ const result = await handlers.checkStatus(options);
112
+ if(result.error) {
113
+ throw result.error;
114
+ }
115
+ return result;
112
116
  } catch(error) {
117
+ if(!(error instanceof BedrockError)) {
118
+ // always expose cause message and name; expose cause details as
119
+ // BedrockError if error is marked public
120
+ const details = error.details?.public ? error.details : {};
121
+ error = new BedrockError(error.message, {
122
+ name: error.name || 'OperationError',
123
+ details: {...details, public: true},
124
+ cause: error
125
+ });
126
+ }
113
127
  return {verified: false, error};
114
128
  }
115
129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-verifier",
3
- "version": "23.3.1",
3
+ "version": "23.5.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock VC Verifier",
6
6
  "main": "./lib/index.js",
@@ -67,9 +67,9 @@
67
67
  "@bedrock/mongodb": "^11.0.0",
68
68
  "@bedrock/multikey-context": "^3.0.0",
69
69
  "@bedrock/security-context": "^9.0.0",
70
- "@bedrock/service-agent": "^10.0.0",
70
+ "@bedrock/service-agent": "^10.3.1",
71
71
  "@bedrock/service-context-store": "^13.1.0",
72
- "@bedrock/service-core": "^11.0.0",
72
+ "@bedrock/service-core": "^11.4.0",
73
73
  "@bedrock/validation": "^7.1.1",
74
74
  "@bedrock/vc-barcodes-context": "^1.0.0",
75
75
  "@bedrock/vc-revocation-list-context": "^5.0.0",