@bedrock/vc-delivery 6.3.1 → 6.4.1
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/oid4/http.js +15 -0
- package/lib/oid4/oid4vci.js +5 -4
- package/lib/vcapi.js +13 -1
- package/package.json +1 -1
package/lib/oid4/http.js
CHANGED
|
@@ -60,6 +60,7 @@ export async function createRoutes({
|
|
|
60
60
|
batchCredential: `${openIdRoute}/batch_credential`,
|
|
61
61
|
credential: `${openIdRoute}/credential`,
|
|
62
62
|
credentialOffer: `${openIdRoute}/credential-offer`,
|
|
63
|
+
nonce: `${openIdRoute}/nonce`,
|
|
63
64
|
token: `${openIdRoute}/token`,
|
|
64
65
|
jwks: `${openIdRoute}/jwks`,
|
|
65
66
|
// OID4VP routes
|
|
@@ -264,6 +265,20 @@ export async function createRoutes({
|
|
|
264
265
|
res.json(result);
|
|
265
266
|
}));
|
|
266
267
|
|
|
268
|
+
// a credential delivery server endpoint
|
|
269
|
+
// serves a nonce to be used in OID4VCI proofs (if required)
|
|
270
|
+
app.options(routes.nonce, cors());
|
|
271
|
+
app.post(
|
|
272
|
+
routes.nonce,
|
|
273
|
+
cors(),
|
|
274
|
+
getExchange,
|
|
275
|
+
asyncHandler(async (req, res) => {
|
|
276
|
+
// serve exchange ID as nonce
|
|
277
|
+
const exchangeRecord = await req.getExchange();
|
|
278
|
+
const {exchange} = exchangeRecord;
|
|
279
|
+
res.json({c_nonce: exchange.id});
|
|
280
|
+
}));
|
|
281
|
+
|
|
267
282
|
// a batch credential delivery server endpoint
|
|
268
283
|
// receives N credential requests and returns N VCs
|
|
269
284
|
app.options(routes.batchCredential, cors());
|
package/lib/oid4/oid4vci.js
CHANGED
|
@@ -36,14 +36,15 @@ export async function getCredentialIssuerConfig({req}) {
|
|
|
36
36
|
|
|
37
37
|
const exchangeId = `${workflow.id}/exchanges/${exchange.id}`;
|
|
38
38
|
return {
|
|
39
|
+
batch_credential_endpoint: `${exchangeId}/openid/batch_credential`,
|
|
40
|
+
credential_configurations_supported,
|
|
41
|
+
credential_endpoint: `${exchangeId}/openid/credential`,
|
|
39
42
|
credential_issuer: exchangeId,
|
|
40
43
|
issuer: exchangeId,
|
|
41
44
|
jwks_uri: `${exchangeId}/openid/jwks`,
|
|
42
|
-
token_endpoint: `${exchangeId}/openid/token`,
|
|
43
|
-
credential_endpoint: `${exchangeId}/openid/credential`,
|
|
44
|
-
batch_credential_endpoint: `${exchangeId}/openid/batch_credential`,
|
|
45
45
|
'pre-authorized_grant_anonymous_access_supported': true,
|
|
46
|
-
|
|
46
|
+
nonce_endpoint: `${exchangeId}/openid/nonce`,
|
|
47
|
+
token_endpoint: `${exchangeId}/openid/token`
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
|
package/lib/vcapi.js
CHANGED
|
@@ -223,9 +223,20 @@ export async function processExchange({req, res, workflow, exchangeRecord}) {
|
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
// FIXME: remove this once the other FIXME below is implemented
|
|
227
|
+
// and provides support for issuance in non-last step
|
|
228
|
+
if(step.issueRequests?.length > 0) {
|
|
229
|
+
throw new BedrockError(
|
|
230
|
+
'Invalid step detected; continuing exchanges currently must ' +
|
|
231
|
+
'only issue in the final step.', {
|
|
232
|
+
name: 'DataError',
|
|
233
|
+
details: {httpStatusCode: 500, public: true}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
226
237
|
// update the exchange to go to the next step, then loop to send
|
|
227
238
|
// next VPR
|
|
228
|
-
|
|
239
|
+
exchange.step = step.nextStep;
|
|
229
240
|
// ensure exchange state is active
|
|
230
241
|
if(exchange.state === 'pending') {
|
|
231
242
|
exchange.state = 'active';
|
|
@@ -249,6 +260,7 @@ export async function processExchange({req, res, workflow, exchangeRecord}) {
|
|
|
249
260
|
details: {httpStatusCode: 500, public: true}
|
|
250
261
|
});
|
|
251
262
|
}
|
|
263
|
+
currentStep = step.nextStep;
|
|
252
264
|
}
|
|
253
265
|
|
|
254
266
|
// mark exchange complete
|