@bedrock/vc-delivery 7.17.0 → 7.17.2
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/ExchangeProcessor.js +2 -1
- package/lib/issue.js +1 -0
- package/lib/oid4/http.js +7 -0
- package/lib/verify.js +28 -11
- package/package.json +1 -1
package/lib/ExchangeProcessor.js
CHANGED
|
@@ -258,7 +258,7 @@ export class ExchangeProcessor {
|
|
|
258
258
|
|
|
259
259
|
// 5. Set the verification results in
|
|
260
260
|
// `exchange.variables.results[exchange.step]`.
|
|
261
|
-
const {verificationMethod} = verifyResult;
|
|
261
|
+
const {verificationMethod, publicKeyJwk} = verifyResult;
|
|
262
262
|
exchange.variables.results[exchange.step] = {
|
|
263
263
|
...exchange.variables.results[exchange.step],
|
|
264
264
|
// common use case of DID Authentication; provide `did` for ease
|
|
@@ -266,6 +266,7 @@ export class ExchangeProcessor {
|
|
|
266
266
|
// receives `did` not verification method nor VP
|
|
267
267
|
did: verificationMethod?.controller || null,
|
|
268
268
|
verificationMethod,
|
|
269
|
+
publicKeyJwk,
|
|
269
270
|
verifiablePresentation,
|
|
270
271
|
verifyPresentationResults: buildVerifyPresentationResults({verifyResult})
|
|
271
272
|
};
|
package/lib/issue.js
CHANGED
package/lib/oid4/http.js
CHANGED
|
@@ -439,6 +439,13 @@ function _normalizeCredentials({verifiablePresentation}) {
|
|
|
439
439
|
vc.id?.startsWith('data:application/jwt,')) {
|
|
440
440
|
return vc.id.slice('data:application/jwt,'.length);
|
|
441
441
|
}
|
|
442
|
+
// parse any mdoc mDL into its non-VC format (includes base64 => base64url)
|
|
443
|
+
if(vc.type === 'EnvelopedVerifiableCredential' &&
|
|
444
|
+
vc.id?.startsWith('data:application/mdl;base64,')) {
|
|
445
|
+
const buffer = Buffer.from(
|
|
446
|
+
vc.id.slice('data:application/mdl;base64,'.length), 'base64');
|
|
447
|
+
return buffer.toString('base64url');
|
|
448
|
+
}
|
|
442
449
|
return vc;
|
|
443
450
|
});
|
|
444
451
|
}
|
package/lib/verify.js
CHANGED
|
@@ -142,7 +142,10 @@ export async function verify({
|
|
|
142
142
|
return {
|
|
143
143
|
verified,
|
|
144
144
|
challengeUses,
|
|
145
|
+
// return original VM result and w/both common key formats
|
|
145
146
|
verificationMethod,
|
|
147
|
+
multikey: await _toMultikey({vm: verificationMethod}),
|
|
148
|
+
publicKeyJwk: await _toJwk(verificationMethod),
|
|
146
149
|
credentialResults,
|
|
147
150
|
presentationResult
|
|
148
151
|
};
|
|
@@ -161,12 +164,11 @@ export async function verifyCredentialRequestProof({
|
|
|
161
164
|
if(diVp) {
|
|
162
165
|
const result = await verifyDidProofDiVp({workflow, exchange, diVp});
|
|
163
166
|
verifyResults.di_vp = verifyResults.di_vp ?? [];
|
|
164
|
-
// return results w/both common key formats
|
|
165
167
|
verifyResults.di_vp.push({
|
|
166
168
|
did: result.did,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}),
|
|
169
|
+
// return original VM result and w/both common key formats
|
|
170
|
+
verificationMethod: result.verifyResult.verificationMethod,
|
|
171
|
+
multikey: await _toMultikey({vm: result.verifyResult.verificationMethod}),
|
|
170
172
|
publicKeyJwk: await _toJwk(result.verifyResult.verificationMethod)
|
|
171
173
|
});
|
|
172
174
|
dids.push(result.did);
|
|
@@ -175,12 +177,14 @@ export async function verifyCredentialRequestProof({
|
|
|
175
177
|
if(jwt) {
|
|
176
178
|
const result = await verifyDidProofJwt({workflow, exchange, jwt});
|
|
177
179
|
verifyResults.jwt = verifyResults.jwt ?? [];
|
|
178
|
-
|
|
180
|
+
const multikey = await _toMultikey({
|
|
181
|
+
jwk: result.verifyResult.jwk, controller: result.did
|
|
182
|
+
});
|
|
179
183
|
verifyResults.jwt.push({
|
|
180
184
|
did: result.did,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
// return original VM result and w/both common key formats
|
|
186
|
+
verificationMethod: multikey,
|
|
187
|
+
multikey,
|
|
184
188
|
publicKeyJwk: result.verifyResult.jwk
|
|
185
189
|
});
|
|
186
190
|
dids.push(result.did);
|
|
@@ -366,7 +370,14 @@ function _getJwkAlgFromMultibase(mb) {
|
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
|
|
373
|
+
// tries to convert to JWK and returns undefined if it cannot
|
|
369
374
|
async function _toJwk(vm) {
|
|
375
|
+
if(vm?.type === 'JsonWebKey') {
|
|
376
|
+
return vm.publicKeyJwk;
|
|
377
|
+
}
|
|
378
|
+
if(!vm?.publicKeyMultibase) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
370
381
|
let jwk;
|
|
371
382
|
const alg = _getJwkAlgFromMultibase(vm.publicKeyMultibase);
|
|
372
383
|
if(alg === 'EdDSA') {
|
|
@@ -381,17 +392,23 @@ async function _toJwk(vm) {
|
|
|
381
392
|
return jwk;
|
|
382
393
|
}
|
|
383
394
|
|
|
395
|
+
// tries to convert to multikey and returns undefined if it cannot
|
|
384
396
|
async function _toMultikey({vm, jwk, controller}) {
|
|
397
|
+
if(vm?.type === 'JsonWebKey') {
|
|
398
|
+
jwk = vm.publicKeyJwk;
|
|
399
|
+
}
|
|
400
|
+
|
|
385
401
|
let keyPair;
|
|
386
402
|
if(jwk) {
|
|
387
|
-
if(jwk.alg === 'EdDSA') {
|
|
403
|
+
if(jwk.crv === 'Ed25519' || jwk.alg === 'EdDSA') {
|
|
388
404
|
keyPair = await Ed25519Multikey.fromJwk({jwk, controller});
|
|
389
405
|
}
|
|
390
|
-
if(jwk.alg
|
|
406
|
+
if(jwk.crv?.startsWith('P-') || jwk.alg?.startsWith('ES')) {
|
|
391
407
|
keyPair = await EcdsaMultikey.fromJwk({jwk, controller});
|
|
392
408
|
}
|
|
393
|
-
} else if(vm) {
|
|
409
|
+
} else if(vm?.publicKeyMultibase) {
|
|
394
410
|
if(vm.type === 'Multikey') {
|
|
411
|
+
// return VM as-is
|
|
395
412
|
return vm;
|
|
396
413
|
}
|
|
397
414
|
const alg = _getJwkAlgFromMultibase(vm.publicKeyMultibase);
|