@bedrock/vc-delivery 3.4.0 → 3.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/http.js +11 -4
- package/lib/openId.js +3 -3
- package/package.json +1 -1
package/lib/http.js
CHANGED
|
@@ -48,8 +48,15 @@ export async function addRoutes({app, service} = {}) {
|
|
|
48
48
|
const {localId, exchangeId: id} = req.params;
|
|
49
49
|
const {baseUri} = bedrock.config.server;
|
|
50
50
|
const exchangerId = `${baseUri}${routePrefix}/${localId}`;
|
|
51
|
-
//
|
|
52
|
-
|
|
51
|
+
// expose access to result via `req`; do not wait for it to settle here
|
|
52
|
+
const exchangePromise = exchanges.get({exchangerId, id}).catch(e => e);
|
|
53
|
+
req.getExchange = async () => {
|
|
54
|
+
const record = await exchangePromise;
|
|
55
|
+
if(record instanceof Error) {
|
|
56
|
+
throw record;
|
|
57
|
+
}
|
|
58
|
+
return record;
|
|
59
|
+
};
|
|
53
60
|
next();
|
|
54
61
|
});
|
|
55
62
|
|
|
@@ -141,7 +148,7 @@ export async function addRoutes({app, service} = {}) {
|
|
|
141
148
|
getConfigMiddleware,
|
|
142
149
|
middleware.authorizeServiceObjectRequest(),
|
|
143
150
|
asyncHandler(async (req, res) => {
|
|
144
|
-
const {exchange} = await req.
|
|
151
|
+
const {exchange} = await req.getExchange();
|
|
145
152
|
// do not return any oauth2 credentials
|
|
146
153
|
delete exchange.openId?.oauth2?.keyPair?.privateKeyJwk;
|
|
147
154
|
res.json({exchange});
|
|
@@ -157,7 +164,7 @@ export async function addRoutes({app, service} = {}) {
|
|
|
157
164
|
getConfigMiddleware,
|
|
158
165
|
asyncHandler(async (req, res) => {
|
|
159
166
|
const {config: exchanger} = req.serviceObject;
|
|
160
|
-
const {exchange} = await req.
|
|
167
|
+
const {exchange} = await req.getExchange();
|
|
161
168
|
|
|
162
169
|
// get any `verifiablePresentation` from the body...
|
|
163
170
|
let receivedPresentation = req?.body?.verifiablePresentation;
|
package/lib/openId.js
CHANGED
|
@@ -116,7 +116,7 @@ export async function createRoutes({
|
|
|
116
116
|
cors(),
|
|
117
117
|
getExchange,
|
|
118
118
|
asyncHandler(async (req, res) => {
|
|
119
|
-
const {exchange} = await req.
|
|
119
|
+
const {exchange} = await req.getExchange();
|
|
120
120
|
if(!exchange.openId) {
|
|
121
121
|
// FIXME: improve error
|
|
122
122
|
// unsupported protocol for the exchange
|
|
@@ -138,7 +138,7 @@ export async function createRoutes({
|
|
|
138
138
|
getConfigMiddleware,
|
|
139
139
|
getExchange,
|
|
140
140
|
asyncHandler(async (req, res) => {
|
|
141
|
-
const exchangeRecord = await req.
|
|
141
|
+
const exchangeRecord = await req.getExchange();
|
|
142
142
|
const {exchange} = exchangeRecord;
|
|
143
143
|
if(!exchange.openId) {
|
|
144
144
|
// FIXME: improve error
|
|
@@ -391,7 +391,7 @@ function _getAlgFromPrivateKey({privateKeyJwk}) {
|
|
|
391
391
|
|
|
392
392
|
async function _processCredentialRequests({req, res, isBatchRequest}) {
|
|
393
393
|
const {config: exchanger} = req.serviceObject;
|
|
394
|
-
const exchangeRecord = await req.
|
|
394
|
+
const exchangeRecord = await req.getExchange();
|
|
395
395
|
const {exchange} = exchangeRecord;
|
|
396
396
|
if(!exchange.openId) {
|
|
397
397
|
// FIXME: improve error
|