Skip to content

Commit e19a9ed

Browse files
committed
Use acceptedCryptosuites internally.
1 parent 75cb544 commit e19a9ed

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

lib/exchanges/chapiDirect.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2023-2026 Digital Bazaar, Inc. All rights reserved.
33
*/
44
import * as presentations from '../presentations.js';
55
import {Exchange} from './Exchange.js';
@@ -42,19 +42,19 @@ export class ChapiDirectExchange extends Exchange {
4242

4343
// sign presentation if `signOptions` is given
4444
if(signOptions) {
45-
// get `acceptedProofTypes`, `domain`, and `challenge` from VPR
45+
// get `acceptedCryptosuites`, `domain`, and `challenge` from VPR
4646
const vpr = this._event.credentialRequestOptions?.web
4747
.VerifiablePresentation;
4848
const {
4949
// FIXME: Throw error if challenge not provided
5050
challenge = 'c0ae1c8e-c7e7-469f-b252-86e6a0e7387e',
5151
domain,
52-
acceptedProofTypes
52+
acceptedCryptosuites
5353
} = getDIDAuthenticationOptions({vpr});
5454
const {profileId} = signOptions;
5555
verifiablePresentation = await presentations.sign({
5656
challenge, domain, presentation: verifiablePresentation,
57-
profileId, acceptedProofTypes
57+
profileId, acceptedCryptosuites
5858
});
5959
}
6060
this._finish({verifiablePresentation});

lib/exchanges/oid4vci.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2023-2026 Digital Bazaar, Inc. All rights reserved.
33
*/
44
import * as presentations from '../presentations.js';
55
import {
@@ -63,16 +63,16 @@ export class OID4VCIExchange extends Exchange {
6363

6464
const {authorizationRequest, vpr} = this._oid4vp;
6565

66-
// get `acceptedProofTypes`, `domain`, and `challenge` from VPR
66+
// get `acceptedCryptosuites`, `domain`, and `challenge` from VPR
6767
const {
6868
// FIXME: Throw error if challenge not provided
6969
challenge = 'c0ae1c8e-c7e7-469f-b252-86e6a0e7387e',
7070
domain,
71-
acceptedProofTypes
71+
acceptedCryptosuites
7272
} = getDIDAuthenticationOptions({vpr});
7373
verifiablePresentation = await presentations.sign({
7474
challenge, domain, presentation: verifiablePresentation,
75-
profileId, acceptedProofTypes
75+
profileId, acceptedCryptosuites
7676
});
7777
// send OID4VP authorization response
7878
const {
@@ -85,9 +85,9 @@ export class OID4VCIExchange extends Exchange {
8585
// result successful, fall through to finish with OID4VCI...
8686
} else {
8787
// FIXME: profile signer needs to be selected based on
88-
// `acceptedProofTypes`, so this needs to be passed into
88+
// `acceptedCryptosuites`, so this needs to be passed into
8989
// `getProfileSigner`; until then, the signer `type` should be checked
90-
// against `acceptedProofTypes` and rejected if there's no match
90+
// against `acceptedCryptosuites` and rejected if there's no match
9191
const {
9292
invocationSigner: signer
9393
} = await profileManager.getProfileSigner({profileId});

lib/exchanges/oid4vp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2023-2026 Digital Bazaar, Inc. All rights reserved.
33
*/
44
import * as presentations from '../presentations.js';
55
import {Exchange} from './Exchange.js';
@@ -58,17 +58,17 @@ export class OID4VPExchange extends Exchange {
5858

5959
// sign presentation if `signOptions` is given
6060
if(signOptions) {
61-
// get `acceptedProofTypes`, `domain`, and `challenge` from VPR
61+
// get `acceptedCryptosuites`, `domain`, and `challenge` from VPR
6262
const {profileId} = signOptions;
6363
const {
6464
// FIXME: Throw error if challenge not provided
6565
challenge = 'c0ae1c8e-c7e7-469f-b252-86e6a0e7387e',
6666
domain,
67-
acceptedProofTypes
67+
acceptedCryptosuites
6868
} = getDIDAuthenticationOptions({vpr: verifiablePresentationRequest});
6969
verifiablePresentation = await presentations.sign({
7070
challenge, domain, presentation: verifiablePresentation,
71-
profileId, acceptedProofTypes
71+
profileId, acceptedCryptosuites
7272
});
7373
}
7474
}

lib/exchanges/vcapi.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2023-2026 Digital Bazaar, Inc. All rights reserved.
33
*/
44
import * as presentations from '../presentations.js';
55
import {Exchange} from './Exchange.js';
@@ -64,17 +64,17 @@ export class VcapiExchange extends Exchange {
6464

6565
// sign presentation if `signOptions` is given
6666
if(signOptions) {
67-
// get `acceptedProofTypes`, `domain`, and `challenge` from VPR
67+
// get `acceptedCryptosuites`, `domain`, and `challenge` from VPR
6868
const {profileId} = signOptions;
6969
const {
7070
// FIXME: Throw error if challenge not provided
7171
challenge = 'c0ae1c8e-c7e7-469f-b252-86e6a0e7387e',
7272
domain,
73-
acceptedProofTypes
73+
acceptedCryptosuites
7474
} = getDIDAuthenticationOptions({vpr: this._vpr});
7575
verifiablePresentation = await presentations.sign({
7676
challenge, domain, presentation: verifiablePresentation,
77-
profileId, acceptedProofTypes
77+
profileId, acceptedCryptosuites
7878
});
7979
}
8080
}

lib/presentations.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ export async function sign({
129129
({name}) => ({cryptosuite: name}));
130130
}
131131

132-
// FIXME: profile signer needs to be selected based on `acceptedProofTypes`,
132+
// FIXME: profile signer needs to be selected based on `acceptedCryptosuites`,
133133
// so this needs to be passed into `getProfileSigner`; until then, the
134-
// signer `type` should be checked against `acceptedProofTypes` and rejected
135-
// if there's no match
134+
// signer `type` should be checked against `acceptedCryptosuites` and
135+
// rejected if there's no match
136136
const {
137137
invocationSigner: signer
138138
} = await profileManager.getProfileSigner({profileId});
139139

140-
// pick a suite from the accepted proof types, initialized to a special
140+
// pick a suite from the accepted cryptosuites, initialized to a special
141141
// backwards compatibility case (or `undefined` if it does not apply)
142142
let suite = _handleLegacyDraftCryptosuites({presentation});
143143
if(!suite && Array.isArray(acceptedCryptosuites) &&
@@ -246,6 +246,11 @@ async function _deriveCredentials({
246246
return;
247247
}
248248

249+
// normalize `acceptedCryptosuites` to `[{cryptosuite}, ...]` to handle
250+
// backwards-compatibility where an array of strings was used
251+
acceptedCryptosuites = acceptedCryptosuites.map(
252+
ac => typeof ac === 'object' ? ac : ({cryptosuite: ac}));
253+
249254
// convert `vprQuery.credentialQuery.example` to JSON pointers, modulo
250255
// `@context` field (the `@context` field is assumed to already have been
251256
// matched during prior processing); any VCDM mandatory pointers will be
@@ -271,7 +276,8 @@ async function _deriveCredentials({
271276
// otherwise generate a derived VC for each SD proof that is both understood
272277
// by the wallet and in `credentialQuery.acceptedCryptosuites`, setting
273278
// match.derived[<cryptosuite>] = derived VC
274-
const acceptedCryptosuiteSet = new Set(acceptedCryptosuites);
279+
const acceptedCryptosuiteSet = new Set(acceptedCryptosuites
280+
.map(ac => ac?.cryptosuite));
275281
for(const match of matches) {
276282
const {record: {content: verifiableCredential}} = match;
277283
match.derived = [];
@@ -308,7 +314,7 @@ async function _deriveCredentials({
308314
// in some way would be useful; need to signal to UIs selective disclosure
309315
// (data minimization) and unlinkability likelihood -- also unlinkability for
310316
// verifiers vs. for regulators and similar for well-known VC types vs. via
311-
// proof types
317+
// proof types (cryptosuites)
312318
}
313319

314320
async function _getLocalMatches({vprQuery, credentialStore}) {
@@ -588,7 +594,7 @@ function _pruneShallowPointers(pointers) {
588594

589595
function _checkSignerCryptosuite({acceptedCryptosuites, signer}) {
590596
const supported = SUPPORTED_CRYPTOSUITES.get(signer.type);
591-
const accepted = new Set(acceptedCryptosuites.map(ac => ac.cryptosuite));
597+
const accepted = new Set(acceptedCryptosuites.map(ac => ac?.cryptosuite));
592598
if(accepted.intersection(supported).size === 0) {
593599
const names = [...accepted].join(', ');
594600
throw new Error(

0 commit comments

Comments
 (0)