@bedrock/vc-delivery 4.1.1 → 4.2.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/openId.js +56 -1
- package/package.json +1 -1
package/lib/openId.js
CHANGED
|
@@ -63,7 +63,11 @@ export async function createRoutes({
|
|
|
63
63
|
const routes = {
|
|
64
64
|
// OID4VCI routes
|
|
65
65
|
asMetadata: `/.well-known/oauth-authorization-server${exchangeRoute}`,
|
|
66
|
+
asMetadataDraftBug:
|
|
67
|
+
`${exchangeRoute}/.well-known/oauth-authorization-server`,
|
|
66
68
|
ciMetadata: `/.well-known/openid-credential-issuer${exchangeRoute}`,
|
|
69
|
+
ciMetadataDraftBug:
|
|
70
|
+
`${exchangeRoute}/.well-known/openid-credential-issuer`,
|
|
67
71
|
batchCredential: `${openIdRoute}/batch_credential`,
|
|
68
72
|
credential: `${openIdRoute}/credential`,
|
|
69
73
|
token: `${openIdRoute}/token`,
|
|
@@ -357,6 +361,57 @@ export async function createRoutes({
|
|
|
357
361
|
{req, presentation, presentationSubmission});
|
|
358
362
|
res.json(result);
|
|
359
363
|
}));
|
|
364
|
+
|
|
365
|
+
/* Note: The following routes are served only because of an OID4VCI draft bug
|
|
366
|
+
that tells clients to generate `/.well-known` paths in an erroneous way and
|
|
367
|
+
some implementers have complied. */
|
|
368
|
+
|
|
369
|
+
// an authorization server meta data endpoint
|
|
370
|
+
// serves `.well-known` oauth2 AS config for each exchange; each config is
|
|
371
|
+
// based on the exchanger used to create the exchange
|
|
372
|
+
app.get(
|
|
373
|
+
routes.asMetadataDraftBug,
|
|
374
|
+
cors(),
|
|
375
|
+
getConfigMiddleware,
|
|
376
|
+
asyncHandler(async (req, res) => {
|
|
377
|
+
// generate well-known oauth2 issuer config
|
|
378
|
+
const {config: exchanger} = req.serviceObject;
|
|
379
|
+
const exchangeId = `${exchanger.id}/exchanges/${req.params.exchangeId}`;
|
|
380
|
+
// note that technically, we should not need to serve any credential
|
|
381
|
+
// issuer metadata, but we do for backwards compatibility purposes as
|
|
382
|
+
// previous versions of OID4VCI required it
|
|
383
|
+
const oauth2Config = {
|
|
384
|
+
issuer: exchangeId,
|
|
385
|
+
jwks_uri: `${exchangeId}/openid/jwks`,
|
|
386
|
+
token_endpoint: `${exchangeId}/openid/token`,
|
|
387
|
+
credential_endpoint: `${exchangeId}/openid/credential`,
|
|
388
|
+
batch_credential_endpoint: `${exchangeId}/openid/batch_credential`
|
|
389
|
+
// FIXME: add `credentials_supported`
|
|
390
|
+
};
|
|
391
|
+
res.json(oauth2Config);
|
|
392
|
+
}));
|
|
393
|
+
|
|
394
|
+
// a credential issuer meta data endpoint
|
|
395
|
+
// serves `.well-known` oauth2 AS / CI config for each exchange; each config
|
|
396
|
+
// is based on the exchanger used to create the exchange
|
|
397
|
+
app.get(
|
|
398
|
+
routes.ciMetadataDraftBug,
|
|
399
|
+
cors(),
|
|
400
|
+
getConfigMiddleware,
|
|
401
|
+
asyncHandler(async (req, res) => {
|
|
402
|
+
// generate well-known oauth2 issuer config
|
|
403
|
+
const {config: exchanger} = req.serviceObject;
|
|
404
|
+
const exchangeId = `${exchanger.id}/exchanges/${req.params.exchangeId}`;
|
|
405
|
+
const oauth2Config = {
|
|
406
|
+
issuer: exchangeId,
|
|
407
|
+
jwks_uri: `${exchangeId}/openid/jwks`,
|
|
408
|
+
token_endpoint: `${exchangeId}/openid/token`,
|
|
409
|
+
credential_endpoint: `${exchangeId}/openid/credential`,
|
|
410
|
+
batch_credential_endpoint: `${exchangeId}/openid/batch_credential`
|
|
411
|
+
// FIXME: add `credentials_supported`
|
|
412
|
+
};
|
|
413
|
+
res.json(oauth2Config);
|
|
414
|
+
}));
|
|
360
415
|
}
|
|
361
416
|
|
|
362
417
|
async function _createExchangeAccessToken({exchanger, exchangeRecord}) {
|
|
@@ -621,7 +676,7 @@ async function _getAuthorizationRequest({req}) {
|
|
|
621
676
|
}
|
|
622
677
|
if(client_id_scheme) {
|
|
623
678
|
authorizationRequest.client_id_scheme = client_id_scheme;
|
|
624
|
-
} else if(authorizationRequest.client_id_scheme ===
|
|
679
|
+
} else if(authorizationRequest.client_id_scheme === undefined) {
|
|
625
680
|
authorizationRequest.client_id_scheme = 'redirect_uri';
|
|
626
681
|
}
|
|
627
682
|
if(client_metadata) {
|