Skip to content

Commit

Permalink
update deps; remove unused code; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Sep 6, 2024
1 parent ece765d commit cf108a6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 82 deletions.
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@
"test": "NODE_OPTIONS=--experimental-vm-modules npx mocha --timeout 10000 -r dotenv/config dotenv_config_path=src/test-fixtures/.env.testing src/app.test.js "
},
"dependencies": {
"@digitalbazaar/did-io": "^2.0.0",
"@digitalbazaar/did-method-key": "^5.1.0",
"@digitalbazaar/ed25519-signature-2020": "^5.2.0",
"@digitalbazaar/ed25519-signature-2020": "^5.4.0",
"@digitalbazaar/ed25519-verification-key-2020": "^4.1.0",
"@digitalbazaar/vc": "^6.0.1",
"@digitalbazaar/vc": "^7.0.0",
"@digitalcredentials/security-document-loader": "^6.0.0",
"axios": "^1.4.0",
"cors": "^2.8.5",
"credentials-context": "^2.0.0",
"debug": "~2.6.9",
"did-context": "^3.1.1",
"dotenv": "^16.0.3",
"ed25519-signature-2020-context": "^1.1.0",
"express": "~4.16.1",
"jsonld-document-loader": "^2.0.0",
"morgan": "~1.9.1",
"winston": "^3.9.0"
},
Expand All @@ -38,7 +33,7 @@
"dcc"
],
"engines": {
"node": ">=16.0"
"node": ">=20.0"
},
"author": {
"name": "Digital Credentials Consortium",
Expand Down
1 change: 0 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import verifyAuthHeader from './verifyAuthHeader.js'
import { getConfig } from './config.js'
import testVC from './testVC.js';
import CoordinatorException from './CoordinatorException.js';
import { getSignedDIDAuth, verifyDIDAuth } from './didAuth.js';

async function callService(endpoint, body) {

Expand Down
17 changes: 6 additions & 11 deletions src/didAuth.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {signPresentation, createPresentation, verify} from '@digitalbazaar/vc';
import {signPresentation, createPresentation} from '@digitalbazaar/vc';
import {Ed25519VerificationKey2020} from '@digitalbazaar/ed25519-verification-key-2020';
import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020';
import { securityLoader } from './securityLoader.js';

import { securityLoader } from '@digitalcredentials/security-document-loader'

const documentLoader = securityLoader().build()

const signingKeyPairForTesting = await Ed25519VerificationKey2020.generate(
const key = await Ed25519VerificationKey2020.generate(
{
seed: new Uint8Array ([
217, 87, 166, 30, 75, 106, 132, 55,
Expand All @@ -16,18 +17,12 @@ const signingKeyPairForTesting = await Ed25519VerificationKey2020.generate(
controller: "did:key:z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP"
}
)
const suiteForSigning = new Ed25519Signature2020({key: signingKeyPairForTesting});
const suiteForVerification = new Ed25519Signature2020();
const suite = new Ed25519Signature2020({key});

export const getSignedDIDAuth = async (holder = 'did:ex:12345', challenge) => {
const presentation = createPresentation({holder});
return await signPresentation({
presentation, suite: suiteForSigning, challenge, documentLoader
presentation, suite, challenge, documentLoader
});
}

export const verifyDIDAuth = async (presentation, challenge) => {
const result = await verify({presentation, challenge, suite: suiteForVerification, documentLoader});
return result.verified
}

24 changes: 0 additions & 24 deletions src/generate.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/securityLoader.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/test-fixtures/nocks/directTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const signedVcWithId = {

const signedVp = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/ns/credentials/v2",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"type": [
Expand Down
2 changes: 1 addition & 1 deletion src/test-fixtures/nocks/vprTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ nock('http://localhost:4004', {"encodedQueryParams":true})
// that we generate as part of the test

nock('http://localhost:4004', {"encodedQueryParams":true})
.post('/exchange/34913bac-b4d7-4c98-a598-c259e8d2925e/199ea83d-3b8d-44f0-8509-d10ce02f5c7c', {"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"type":["VerifiablePresentation"],"holder":/.+/i,"proof":{"type":"Ed25519Signature2020","created":/.+/i,"verificationMethod":"did:key:z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP#z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP","proofPurpose":"authentication","challenge":"199ea83d-3b8d-44f0-8509-d10ce02f5c7c","proofValue":/.+/i}})
.post('/exchange/34913bac-b4d7-4c98-a598-c259e8d2925e/199ea83d-3b8d-44f0-8509-d10ce02f5c7c', {"@context":["https://www.w3.org/ns/credentials/v2","https://w3id.org/security/suites/ed25519-2020/v1"],"type":["VerifiablePresentation"],"holder":/.+/i,"proof":{"type":"Ed25519Signature2020","created":/.+/i,"verificationMethod":"did:key:z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP#z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP","proofPurpose":"authentication","challenge":"199ea83d-3b8d-44f0-8509-d10ce02f5c7c","proofValue":/.+/i}})
.reply(200, {"vc":{"@context":["https://www.w3.org/2018/credentials/v1","https://purl.imsglobal.org/spec/ob/v3p0/context.json","https://w3id.org/vc/status-list/2021/v1"],"id":"urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1","type":["VerifiableCredential","OpenBadgeCredential"],"issuer":{"id":"did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC","type":"Profile","name":"University of Wonderful","description":"The most wonderful university","url":"https://wonderful.edu/","image":{"id":"https://user-images.githubusercontent.com/947005/133544904-29d6139d-2e7b-4fe2-b6e9-7d1022bb6a45.png","type":"Image"}},"issuanceDate":"2020-01-01T00:00:00Z","name":"A Simply Wonderful Course","credentialSubject":{"type":"AchievementSubject","achievement":{"id":"http://wonderful.wonderful","type":"Achievement","criteria":{"narrative":"Completion of the Wonderful Course - well done you!"},"description":"Wonderful.","name":"Introduction to Wonderfullness"}}},"retrievalId":"someId","tenantName":"UN_PROTECTED_TEST","exchangeHost":"http://localhost:4005","transactionId":"199ea83d-3b8d-44f0-8509-d10ce02f5c7c","exchangeId":"34913bac-b4d7-4c98-a598-c259e8d2925e"}, [
'X-Powered-By',
'Express',
Expand Down

0 comments on commit cf108a6

Please sign in to comment.