Skip to content

Commit

Permalink
Renmae getEcdsaKeyType to getEcdsaKeyTypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JSAssassin committed Oct 19, 2023
1 parent dd6891c commit f18f8b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SUPPORTED_ECDSA_KEY_TYPES = new Map([
['z82L', 'P-384']
]);

export function getEcdsaKeyType({credential, presentation} = {}) {
export function getEcdsaKeyTypes({credential, presentation} = {}) {
let vc = presentation ? presentation.verifiableCredential : credential;
vc = Array.isArray(vc) ? vc : [vc];
const ecdsaKeyTypes = [];
Expand Down
6 changes: 3 additions & 3 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {checkStatus} from './status.js';
import cors from 'cors';
import {createDocumentLoader} from './documentLoader.js';
import {createSuites} from './suites.js';
import {getEcdsaKeyType} from './helpers.js';
import {getEcdsaKeyTypes} from './helpers.js';
import {serializeError} from 'serialize-error';
import {createValidateMiddleware as validate} from '@bedrock/validation';

Expand Down Expand Up @@ -86,7 +86,7 @@ export async function addRoutes({app, service} = {}) {

const {checks} = options;
_validateChecks({checks});
const ecdsaKeyTypes = getEcdsaKeyType({credential});
const ecdsaKeyTypes = getEcdsaKeyTypes({credential});
const suite = createSuites({ecdsaKeyTypes});
const result = await vc.verifyCredential({
credential,
Expand Down Expand Up @@ -191,7 +191,7 @@ export async function addRoutes({app, service} = {}) {
}
({uses: challengeUses} = result);
}
const ecdsaKeyTypes = getEcdsaKeyType({
const ecdsaKeyTypes = getEcdsaKeyTypes({
presentation: verifiablePresentation
});
const suite = createSuites({ecdsaKeyTypes});
Expand Down
10 changes: 5 additions & 5 deletions test/mocha/20-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {documentLoader as brDocLoader} from '@bedrock/jsonld-document-loader';
import {CapabilityAgent} from '@digitalbazaar/webkms-client';
import {createRequire} from 'node:module';
import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020';
import {getEcdsaKeyType} from '@bedrock/vc-verifier/lib/helpers.js';
import {getEcdsaKeyTypes} from '@bedrock/vc-verifier/lib/helpers.js';
import {httpClient} from '@digitalbazaar/http-client';
import {klona} from 'klona';

Expand Down Expand Up @@ -126,8 +126,8 @@ describe('verify APIs', () => {
const {type, cryptosuite} = mockCredential.proof;
if(cryptosuite) {
if(cryptosuite === 'ecdsa-2019') {
const keyType = getEcdsaKeyType({credential: mockCredential})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyType}`;
const keyTypes = getEcdsaKeyTypes({credential: mockCredential})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyTypes[0]}`;
} else {
description = `${type} - ${cryptosuite}`;
}
Expand Down Expand Up @@ -396,8 +396,8 @@ describe('verify APIs', () => {
const {type, cryptosuite} = mockCredential.proof;
if(cryptosuite) {
if(cryptosuite === 'ecdsa-2019') {
const keyType = getEcdsaKeyType({credential: mockCredential})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyType}`;
const keyTypes = getEcdsaKeyTypes({credential: mockCredential})[0];
description = `${type} - ${cryptosuite}, keytype: ${keyTypes[0]}`;
} else {
description = `${type} - ${cryptosuite}`;
}
Expand Down

0 comments on commit f18f8b4

Please sign in to comment.