@bedrock/vc-delivery 4.2.0 → 4.3.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 +23 -4
- package/package.json +1 -1
- package/schemas/bedrock-vc-exchanger.js +8 -0
package/lib/openId.js
CHANGED
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
} from '@bedrock/validation';
|
|
9
9
|
import {importJWK, SignJWT} from 'jose';
|
|
10
10
|
import {
|
|
11
|
-
openIdAuthorizationResponseBody,
|
|
12
|
-
|
|
11
|
+
openIdAuthorizationResponseBody,
|
|
12
|
+
openIdBatchCredentialBody,
|
|
13
|
+
openIdCredentialBody,
|
|
14
|
+
openIdTokenBody,
|
|
13
15
|
presentationSubmission as presentationSubmissionSchema
|
|
14
16
|
} from '../schemas/bedrock-vc-exchanger.js';
|
|
15
17
|
import {verify, verifyDidProofJwt} from './verify.js';
|
|
@@ -235,7 +237,7 @@ export async function createRoutes({
|
|
|
235
237
|
|
|
236
238
|
{
|
|
237
239
|
"format": "ldp_vc",
|
|
238
|
-
"
|
|
240
|
+
"credential_definition": {
|
|
239
241
|
"@context": [
|
|
240
242
|
"https://www.w3.org/2018/credentials/v1",
|
|
241
243
|
"https://www.w3.org/2018/credentials/examples/v1"
|
|
@@ -289,7 +291,7 @@ export async function createRoutes({
|
|
|
289
291
|
{
|
|
290
292
|
credential_requests: [{
|
|
291
293
|
"format": "ldp_vc",
|
|
292
|
-
"
|
|
294
|
+
"credential_definition": {
|
|
293
295
|
"@context": [
|
|
294
296
|
"https://www.w3.org/2018/credentials/v1",
|
|
295
297
|
"https://www.w3.org/2018/credentials/examples/v1"
|
|
@@ -528,6 +530,11 @@ async function _processCredentialRequests({req, res, isBatchRequest}) {
|
|
|
528
530
|
}
|
|
529
531
|
credentialRequests = [req.body];
|
|
530
532
|
}
|
|
533
|
+
|
|
534
|
+
// before asserting, normalize credential requests to use `type` instead of
|
|
535
|
+
// `types`; this is to allow for OID4VCI draft 20 implementers that followed
|
|
536
|
+
// the non-normative examples
|
|
537
|
+
_normalizeCredentialDefinitionTypes({credentialRequests});
|
|
531
538
|
_assertCredentialRequests(
|
|
532
539
|
{credentialRequests, expectedCredentialRequests});
|
|
533
540
|
|
|
@@ -832,3 +839,15 @@ function _validate(validator, data) {
|
|
|
832
839
|
throw result.error;
|
|
833
840
|
}
|
|
834
841
|
}
|
|
842
|
+
|
|
843
|
+
function _normalizeCredentialDefinitionTypes({credentialRequests}) {
|
|
844
|
+
// normalize credential requests to use `type` instead of `types`
|
|
845
|
+
for(const cr of credentialRequests) {
|
|
846
|
+
if(cr?.credential_definition?.types) {
|
|
847
|
+
if(!cr?.credential_definition?.type) {
|
|
848
|
+
cr.credential_definition.type = cr.credential_definition.types;
|
|
849
|
+
}
|
|
850
|
+
delete cr.credential_definition.types;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
package/package.json
CHANGED