@bedrock/vc-delivery 3.2.0 → 3.4.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/issue.js CHANGED
@@ -15,8 +15,7 @@ export async function issue({exchanger, exchange} = {}) {
15
15
  // run jsonata compiler; only `jsonata` template type is supported and this
16
16
  // was validated when the exchanger was created
17
17
  const credentials = await Promise.all(credentialTemplates.map(
18
- ({template: t}) => jsonata(t).evaluate(variables)));
19
-
18
+ ({template: t}) => jsonata(t).evaluate(variables, variables)));
20
19
  // issue all VCs
21
20
  const vcs = await _issue({exchanger, credentials});
22
21
  verifiableCredential.push(...vcs);
package/lib/openId.js CHANGED
@@ -51,6 +51,7 @@ export async function createRoutes({
51
51
  const openIdRoute = `${exchangeRoute}/openid`;
52
52
  const routes = {
53
53
  asMetadata: `/.well-known/oauth-authorization-server${exchangeRoute}`,
54
+ ciMetadata: `/.well-known/openid-credential-issuer${exchangeRoute}`,
54
55
  batchCredential: `${openIdRoute}/batch_credential`,
55
56
  credential: `${openIdRoute}/credential`,
56
57
  token: `${openIdRoute}/token`,
@@ -60,13 +61,38 @@ export async function createRoutes({
60
61
  // urlencoded body parser (extended=true for rich JSON-like representation)
61
62
  const urlencoded = bodyParser.urlencoded({extended: true});
62
63
 
63
- // an authorization server endpoint
64
+ // an authorization server meta data endpoint
64
65
  // serves `.well-known` oauth2 AS config for each exchange; each config is
65
66
  // based on the exchanger used to create the exchange
66
67
  app.get(
67
68
  routes.asMetadata,
68
69
  cors(),
69
70
  getConfigMiddleware,
71
+ asyncHandler(async (req, res) => {
72
+ // generate well-known oauth2 issuer config
73
+ const {config: exchanger} = req.serviceObject;
74
+ const exchangeId = `${exchanger.id}/exchanges/${req.params.exchangeId}`;
75
+ // note that technically, we should not need to serve any credential
76
+ // issuer metadata, but we do for backwards compatibility purposes as
77
+ // previous versions of OID4VCI required it
78
+ const oauth2Config = {
79
+ issuer: exchangeId,
80
+ jwks_uri: `${exchangeId}/openid/jwks`,
81
+ token_endpoint: `${exchangeId}/openid/token`,
82
+ credential_endpoint: `${exchangeId}/openid/credential`,
83
+ batch_credential_endpoint: `${exchangeId}/openid/batch_credential`
84
+ // FIXME: add `credentials_supported`
85
+ };
86
+ res.json(oauth2Config);
87
+ }));
88
+
89
+ // a credential issuer meta data endpoint
90
+ // serves `.well-known` oauth2 AS / CI config for each exchange; each config
91
+ // is based on the exchanger used to create the exchange
92
+ app.get(
93
+ routes.ciMetadata,
94
+ cors(),
95
+ getConfigMiddleware,
70
96
  asyncHandler(async (req, res) => {
71
97
  // generate well-known oauth2 issuer config
72
98
  const {config: exchanger} = req.serviceObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-delivery",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock Verifiable Credential Delivery",
6
6
  "main": "./lib/index.js",