@bedrock/vc-delivery 7.7.2 → 7.9.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.
- package/lib/helpers.js +35 -0
- package/lib/index.js +17 -3
- package/lib/oid4/oid4vp.js +6 -1
- package/lib/vcapi.js +6 -1
- package/package.json +3 -3
package/lib/helpers.js
CHANGED
|
@@ -56,6 +56,41 @@ export function buildPresentationFromResults({
|
|
|
56
56
|
return vp;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
export function buildVerifyPresentationResults({verifyResult}) {
|
|
60
|
+
/*if(verifyResult.results) {
|
|
61
|
+
// VCALM-compliant result already available, use it or a minimized version
|
|
62
|
+
// of it to avoid hitting exchange storage capacity limits
|
|
63
|
+
}*/
|
|
64
|
+
|
|
65
|
+
// backwards-compatibility: construct VCALM-compliant result
|
|
66
|
+
return {
|
|
67
|
+
verified: verifyResult.verified,
|
|
68
|
+
results: {
|
|
69
|
+
presentation: {
|
|
70
|
+
verified: verifyResult.presentationResult?.verified,
|
|
71
|
+
proof: verifyResult.presentationResult?.results?.map(r => ({
|
|
72
|
+
verified: r.verified,
|
|
73
|
+
input: r.proof
|
|
74
|
+
})),
|
|
75
|
+
},
|
|
76
|
+
credentials: verifyResult.credentialResults?.map(r => ({
|
|
77
|
+
verified: r.verified,
|
|
78
|
+
results: {
|
|
79
|
+
proof: r.results?.map(r => ({
|
|
80
|
+
verified: r.verified,
|
|
81
|
+
input: r.proof
|
|
82
|
+
})),
|
|
83
|
+
credentialStatus: r.statusResult?.results?.map(r => ({
|
|
84
|
+
verified: r.verified,
|
|
85
|
+
input: r.credentialStatus,
|
|
86
|
+
value: r.status
|
|
87
|
+
}))
|
|
88
|
+
}
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
59
94
|
export function emitExchangeUpdated({workflow, exchange, step}) {
|
|
60
95
|
if(!step?.callback?.url) {
|
|
61
96
|
// no-op when there is no callback to notify
|
package/lib/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
5
|
import * as workflowSchemas from '../schemas/bedrock-vc-workflow.js';
|
|
6
6
|
import {createService, schemas} from '@bedrock/service-core';
|
|
7
|
+
import {initializeServiceAgent, refreshZcaps} from '@bedrock/service-agent';
|
|
7
8
|
import {
|
|
8
9
|
MAX_ISSUER_INSTANCES, MAX_OID4VP_CLIENT_PROFILES
|
|
9
10
|
} from './constants.js';
|
|
10
11
|
import {addRoutes} from './http.js';
|
|
11
|
-
import {initializeServiceAgent} from '@bedrock/service-agent';
|
|
12
12
|
import {parseLocalId} from './helpers.js';
|
|
13
13
|
import '@bedrock/express';
|
|
14
14
|
|
|
@@ -44,9 +44,9 @@ async function _initService({serviceType, routePrefix}) {
|
|
|
44
44
|
schema.properties.issuerInstances = issuerInstances;
|
|
45
45
|
// allow zcaps by custom reference ID
|
|
46
46
|
schema.properties.zcaps = structuredClone(schemas.zcaps);
|
|
47
|
-
// max of
|
|
47
|
+
// max of 4 basic zcaps + max issuer instances + max OID4VP client profiles
|
|
48
48
|
schema.properties.zcaps.maxProperties =
|
|
49
|
-
|
|
49
|
+
4 + MAX_ISSUER_INSTANCES + MAX_OID4VP_CLIENT_PROFILES;
|
|
50
50
|
schema.properties.zcaps.additionalProperties = schemas.delegatedZcap;
|
|
51
51
|
// note: credential templates are not required; if any other properties
|
|
52
52
|
// become required, add them here
|
|
@@ -87,8 +87,22 @@ async function _initService({serviceType, routePrefix}) {
|
|
|
87
87
|
}, {
|
|
88
88
|
referenceId: 'verifyPresentation',
|
|
89
89
|
required: false
|
|
90
|
+
}, {
|
|
91
|
+
referenceId: 'refresh',
|
|
92
|
+
required: false
|
|
90
93
|
}]
|
|
91
94
|
},
|
|
95
|
+
async refreshHandler({record, signal}) {
|
|
96
|
+
// refresh zcaps and update record w/results
|
|
97
|
+
const result = await refreshZcaps({
|
|
98
|
+
serviceType, config: record.config, signal
|
|
99
|
+
});
|
|
100
|
+
const config = result.config ?? record.config;
|
|
101
|
+
await service.configStorage.update({
|
|
102
|
+
config: {...config, sequence: config.sequence + 1},
|
|
103
|
+
refresh: result.refresh
|
|
104
|
+
});
|
|
105
|
+
},
|
|
92
106
|
async usageAggregator({meter, signal} = {}) {
|
|
93
107
|
return usageAggregator({meter, signal, service});
|
|
94
108
|
}
|
package/lib/oid4/oid4vp.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
5
|
import * as exchanges from '../exchanges.js';
|
|
6
6
|
import {
|
|
7
|
-
buildPresentationFromResults,
|
|
7
|
+
buildPresentationFromResults,
|
|
8
|
+
buildVerifyPresentationResults,
|
|
9
|
+
emitExchangeUpdated,
|
|
8
10
|
evaluateExchangeStep
|
|
9
11
|
} from '../helpers.js';
|
|
10
12
|
import {getClientBaseUrl, getClientProfile} from './clientProfiles.js';
|
|
@@ -264,6 +266,9 @@ export async function processAuthorizationResponse({req, clientProfileId}) {
|
|
|
264
266
|
presentation,
|
|
265
267
|
verifyResult
|
|
266
268
|
}),
|
|
269
|
+
verifyPresentationResults: buildVerifyPresentationResults({
|
|
270
|
+
verifyResult
|
|
271
|
+
}),
|
|
267
272
|
openId: {
|
|
268
273
|
clientProfileId,
|
|
269
274
|
authorizationRequest,
|
package/lib/vcapi.js
CHANGED
|
@@ -5,7 +5,9 @@ import * as bedrock from '@bedrock/core';
|
|
|
5
5
|
import * as exchanges from './exchanges.js';
|
|
6
6
|
import {createChallenge as _createChallenge, verify} from './verify.js';
|
|
7
7
|
import {
|
|
8
|
-
buildPresentationFromResults,
|
|
8
|
+
buildPresentationFromResults,
|
|
9
|
+
buildVerifyPresentationResults,
|
|
10
|
+
emitExchangeUpdated,
|
|
9
11
|
evaluateExchangeStep,
|
|
10
12
|
generateRandom, validateVerifiablePresentation
|
|
11
13
|
} from './helpers.js';
|
|
@@ -245,6 +247,9 @@ export async function processExchange({req, res, workflow, exchangeRecord}) {
|
|
|
245
247
|
verifiablePresentation: buildPresentationFromResults({
|
|
246
248
|
presentation: receivedPresentation,
|
|
247
249
|
verifyResult
|
|
250
|
+
}),
|
|
251
|
+
verifyPresentationResults: buildVerifyPresentationResults({
|
|
252
|
+
verifyResult
|
|
248
253
|
})
|
|
249
254
|
};
|
|
250
255
|
exchange.variables.results[currentStep] = result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrock/vc-delivery",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bedrock Verifiable Credential Delivery",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@bedrock/https-agent": "^4.1.0",
|
|
60
60
|
"@bedrock/mongodb": "^11.0.0",
|
|
61
61
|
"@bedrock/oauth2-verifier": "^2.3.1",
|
|
62
|
-
"@bedrock/service-agent": "^10.
|
|
63
|
-
"@bedrock/service-core": "^11.
|
|
62
|
+
"@bedrock/service-agent": "^10.3.1",
|
|
63
|
+
"@bedrock/service-core": "^11.4.0",
|
|
64
64
|
"@bedrock/validation": "^7.1.1"
|
|
65
65
|
},
|
|
66
66
|
"directories": {
|