Skip to content

Commit cb871d4

Browse files
committed
update to use new issuer-registry-client
1 parent ed87284 commit cb871d4

File tree

10 files changed

+259
-117
lines changed

10 files changed

+259
-117
lines changed

README.md

Lines changed: 111 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,20 @@ The verification checks that the credential:
3434

3535
The verification will also tell us if any of the registries listed in the trusted registry list couldn't be loaded (say because of a network error), which is important because those missing registries might be the very registries that affirm the trustworthiness of the issuer of a given credential.
3636

37-
As of March 2025 issuers are trusted if they are listed in one of the Digital Credentials Issuer Registries:
37+
As of May 2025 we've published a list of known DCC registries:
3838

3939
```
40-
{
41-
name: 'DCC Pilot Registry',
42-
url: 'https://digitalcredentials.github.io/issuer-registry/registry.json'
43-
},
44-
{
45-
name: 'DCC Sandbox Registry',
46-
url: 'https://digitalcredentials.github.io/sandbox-registry/registry.json'
47-
},
48-
{
49-
name: 'DCC Community Registry',
50-
url: 'https://digitalcredentials.github.io/community-registry/registry.json'
51-
},
52-
{
53-
name: 'DCC Registry',
54-
url: 'https://digitalcredentials.github.io/dcc-registry/registry.json'
55-
}
40+
https://digitalcredentials.github.io/dcc-known-registries/known-did-registries.json
5641
```
5742

58-
The DCC is working on a new trust registry model that will extend the registry scope.
43+
that you would retrieve something like so:
44+
45+
```
46+
const response = await fetch("https://digitalcredentials.github.io/dcc-known-registries/known-did-registries.json");
47+
const knownRegistries = await response.json();
48+
```
49+
50+
and then pass that knownRegistries variable into the call to verifyCredential, as explained below.
5951

6052
## API
6153

@@ -72,7 +64,7 @@ This package exports two methods:
7264

7365
* credential - The W3C Verifiable Credential to be verified.
7466
* knownDidRegistries - a list of trusted registries.
75-
* reloadIssuerRegistry - A boolean (true/false) indication whether or not to refresh the cached copy of the registries.
67+
7668

7769
#### result
7870

@@ -102,11 +94,33 @@ Four steps are checked, returning a result per step in a log like so:
10294
{
10395
"id": "registered_issuer",
10496
"valid": true/false,
105-
"foundInRegistries": [
106-
"DCC Sandbox Registry"
97+
"matchingIssuers": [
98+
{
99+
"issuer": {
100+
"federation_entity": {
101+
"organization_name": "DCC did:web test",
102+
"homepage_uri": "https://digitalcredentials.mit.edu",
103+
"location": "Cambridge, MA, USA"
104+
}
105+
},
106+
"registry": {
107+
"name": "DCC Sandbox Registry",
108+
"type": "dcc-legacy",
109+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
110+
}
111+
}
107112
],
108-
"registriesNotLoaded":[
109-
"DCC Issuer Registry"
113+
"uncheckedRegistries": [
114+
{
115+
"name": "DCC Community Registry",
116+
"type": "dcc-legacy",
117+
"url": "https://onldynoyrrrt.com/registry.json"
118+
},
119+
{
120+
"name": "DCC Pilot Registry",
121+
"type": "dcc-legacy",
122+
"url": "https://onldynoyrt.com/registry.json"
123+
}
110124
]
111125
}
112126
]
@@ -142,10 +156,23 @@ A conclusive verification might look like this example where all steps returned
142156
{
143157
"id": "registered_issuer",
144158
"valid": true,
145-
"foundInRegistries": [
146-
"DCC Sandbox Registry"
159+
"matchingIssuers": [
160+
{
161+
"issuer": {
162+
"federation_entity": {
163+
"organization_name": "DCC did:web test",
164+
"homepage_uri": "https://digitalcredentials.mit.edu",
165+
"location": "Cambridge, MA, USA"
166+
}
167+
},
168+
"registry": {
169+
"name": "DCC Sandbox Registry",
170+
"type": "dcc-legacy",
171+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
172+
}
173+
}
147174
],
148-
"registriesNotLoaded":[]
175+
"uncheckedRegistries": []
149176
}
150177
]
151178
}
@@ -173,10 +200,23 @@ And here is a slightly different verification result where we have still made co
173200
{
174201
"id": "registered_issuer",
175202
"valid": true,
176-
"foundInRegistries": [
177-
"DCC Sandbox Registry"
203+
"matchingIssuers": [
204+
{
205+
"issuer": {
206+
"federation_entity": {
207+
"organization_name": "DCC did:web test",
208+
"homepage_uri": "https://digitalcredentials.mit.edu",
209+
"location": "Cambridge, MA, USA"
210+
}
211+
},
212+
"registry": {
213+
"name": "DCC Sandbox Registry",
214+
"type": "dcc-legacy",
215+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
216+
}
217+
}
178218
],
179-
"registriesNotLoaded":[]
219+
"uncheckedRegistries": []
180220
}
181221
]
182222
}
@@ -225,12 +265,33 @@ A partially successful verification might look like this example, where we could
225265
{
226266
"id": "registered_issuer",
227267
"valid": false,
228-
"foundInRegistries": [],
229-
"registriesNotLoaded": [
268+
"matchingIssuers": [
230269
{
231-
"name": "DCC Sandbox Registry",
232-
"url": "https://onlynoyrt.com/registry.json"
270+
"issuer": {
271+
"federation_entity": {
272+
"organization_name": "DCC did:web test",
273+
"homepage_uri": "https://digitalcredentials.mit.edu",
274+
"location": "Cambridge, MA, USA"
275+
}
276+
},
277+
"registry": {
278+
"name": "DCC Sandbox Registry",
279+
"type": "dcc-legacy",
280+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
281+
}
233282
}
283+
],
284+
"uncheckedRegistries": [
285+
{
286+
"name": "DCC Community Registry",
287+
"type": "dcc-legacy",
288+
"url": "https://onldynoyrrrt.com/registry.json"
289+
},
290+
{
291+
"name": "DCC Pilot Registry",
292+
"type": "dcc-legacy",
293+
"url": "https://onldynoyrt.com/registry.json"
294+
}
234295
]
235296
}
236297
]
@@ -633,10 +694,23 @@ A successful signed VP result with two packaged VCs might look like so:
633694
{
634695
"id": "registered_issuer",
635696
"valid": true,
636-
"foundInRegistries": [
637-
"DCC Sandbox Registry"
638-
],
639-
"registriesNotLoaded": []
697+
"matchingIssuers": [
698+
{
699+
"issuer": {
700+
"federation_entity": {
701+
"organization_name": "DCC did:web test",
702+
"homepage_uri": "https://digitalcredentials.mit.edu",
703+
"location": "Cambridge, MA, USA"
704+
}
705+
},
706+
"registry": {
707+
"name": "DCC Sandbox Registry",
708+
"type": "dcc-legacy",
709+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
710+
}
711+
}
712+
],
713+
"uncheckedRegistries": []
640714
}
641715
],
642716
"credential": {vc omitted for brevity/clarity}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@digitalcredentials/verifier-core",
33
"description": "For verifying Verifiable Credentials in the browser, Node.js, and React Native.",
4-
"version": "1.0.0-beta.2",
4+
"version": "1.0.0-beta.3",
55
"scripts": {
66
"build-esm": "tsc -p tsconfig.esm.json",
77
"build-types": "tsc -p tsconfig.types.json",
@@ -16,7 +16,7 @@
1616
"test": "npm run lint && npm run test-node",
1717
"test-karma": "karma start karma.conf.cjs",
1818
"test-node-no-cov": "npm run build-test && mocha dist/test/*.spec.js && rimraf dist/test",
19-
"test-node": "npm run build-test && npx c8 --exclude 'dist/test/**' mocha dist/test/*.spec.js && rm -rf dist/test || true",
19+
"test-node": "npm run build-test && npx c8 --exclude 'dist/test/**' mocha --timeout 20000 dist/test/*.spec.js && rm -rf dist/test || true",
2020
"coveralls": "npm run test; npx c8 --exclude 'dist/test/**' report --reporter=text-lcov > ./coverage/lcov.info"
2121
},
2222
"type": "module",
@@ -29,7 +29,7 @@
2929
"@digitalcredentials/data-integrity": "^2.6.0",
3030
"@digitalcredentials/ed25519-signature-2020": "^7.0.0",
3131
"@digitalcredentials/eddsa-rdfc-2022-cryptosuite": "^1.3.0",
32-
"@digitalcredentials/issuer-registry-client": "file:../issuer-registry-client",
32+
"@digitalcredentials/issuer-registry-client": "^3.2.0-beta.2",
3333
"@digitalcredentials/jsonld-signatures": "^12.0.1",
3434
"@digitalcredentials/security-document-loader": "^7.0.0",
3535
"@digitalcredentials/vc": "^10.0.0",

src/Verify.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const ed25519Suite = new Ed25519Signature2020();
3434
// add both suites - the vc lib will use whichever is appropriate
3535
const suite = [ed25519Suite, eddsaSuite]
3636

37-
export async function verifyPresentation({ presentation, challenge = 'meaningless', unsignedPresentation = false, knownDIDRegistries, reloadIssuerRegistry = true }:
37+
export async function verifyPresentation({ presentation, challenge = 'meaningless', unsignedPresentation = false, knownDIDRegistries }:
3838
{
3939
presentation: VerifiablePresentation,
4040
challenge?: string | null,
@@ -59,7 +59,7 @@ export async function verifyPresentation({ presentation, challenge = 'meaningles
5959
});
6060

6161
const transformedCredentialResults = await Promise.all(result.credentialResults.map(async (credentialResult: any) => {
62-
return transformResponse(credentialResult, credentialResult.credential, knownDIDRegistries, reloadIssuerRegistry)
62+
return transformResponse(credentialResult, credentialResult.credential, knownDIDRegistries)
6363
}));
6464

6565
// take what we need from the presentation part of the result
@@ -79,7 +79,7 @@ export async function verifyPresentation({ presentation, challenge = 'meaningles
7979
}
8080

8181

82-
export async function verifyCredential({ credential, knownDIDRegistries, reloadIssuerRegistry = true }: { credential: Credential, knownDIDRegistries: object, reloadIssuerRegistry: boolean }): Promise<VerificationResponse> {
82+
export async function verifyCredential({ credential, knownDIDRegistries}: { credential: Credential, knownDIDRegistries: object}): Promise<VerificationResponse> {
8383
try {
8484
// null unless credential has a status
8585
const statusChecker = getCredentialStatusChecker(credential)
@@ -92,14 +92,14 @@ export async function verifyCredential({ credential, knownDIDRegistries, reloadI
9292
verifyMatchingIssuers: false
9393
});
9494

95-
const adjustedResponse = await transformResponse(verificationResponse, credential, knownDIDRegistries, reloadIssuerRegistry)
95+
const adjustedResponse = await transformResponse(verificationResponse, credential, knownDIDRegistries)
9696
return adjustedResponse;
9797
} catch (error) {
9898
return { errors: [{ message: 'Could not verify credential.', name: UNKNOWN_ERROR, stackTrace: error }] }
9999
}
100100
}
101101

102-
async function transformResponse(verificationResponse: any, credential: Credential, knownDIDRegistries: object, reloadIssuerRegistry: boolean): Promise<VerificationResponse> {
102+
async function transformResponse(verificationResponse: any, credential: Credential, knownDIDRegistries: object): Promise<VerificationResponse> {
103103

104104
const fatalCredentialError = handleAnyFatalCredentialErrors(credential)
105105

@@ -115,7 +115,7 @@ async function transformResponse(verificationResponse: any, credential: Credenti
115115
}
116116

117117
const { issuer } = credential
118-
await addTrustedIssuersToVerificationResponse({ verificationResponse, knownDIDRegistries, reloadIssuerRegistry, issuer })
118+
await addTrustedIssuersToVerificationResponse({ verificationResponse, knownDIDRegistries, issuer })
119119

120120
// remove things we don't need from the result or that are duplicated elsewhere
121121
delete verificationResponse.results

src/issuerRegistries.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {RegistryClient, LoadResult} from '@digitalcredentials/issuer-registry-client';
1+
import {RegistryClient, LookupResult} from '@digitalcredentials/issuer-registry-client';
22
import { VerificationResponse, RegistryListResult } from './types/result.js';
33
import { REGISTERED_ISSUER_STEP_ID } from './constants/verificationSteps.js';
4-
const registries = new RegistryClient()
5-
const registryNotYetLoaded = true;
4+
const registryClient = new RegistryClient()
65

76
/**
87
* Checks to see if a VC's issuer appears in any of the known DID registries.
@@ -11,44 +10,31 @@ const registryNotYetLoaded = true;
1110
* which the issuer appears and a list of registries that couldn't be loaded
1211
*/
1312

14-
export async function getTrustedRegistryListForIssuer({ issuer, knownDIDRegistries, reloadIssuerRegistry = false }: {
13+
export async function getTrustedRegistryListForIssuer({ issuer, knownDIDRegistries}: {
1514
issuer: string | any,
16-
knownDIDRegistries: object,
17-
reloadIssuerRegistry: boolean | null
18-
}): Promise<RegistryListResult> {
19-
20-
let registryLoadResult:LoadResult[] = []
21-
// eslint-disable-next-line no-use-before-define
22-
if (reloadIssuerRegistry || registryNotYetLoaded) {
23-
registryLoadResult = await registries.load({ config: knownDIDRegistries })
24-
}
25-
const registriesNotLoaded : Array<{name: string, url: string}> = registryLoadResult.filter((registry:LoadResult)=>!registry.loaded).map(entry=>{return {name:entry.name, url:entry.url}})
26-
const issuerDid = typeof issuer === 'string' ? issuer : issuer.id;
27-
const issuerInfo = registries.didEntry(issuerDid);
28-
// See if the issuer DID appears in any of the known registries
29-
// If yes, assemble a list of registries in which it appears
30-
const foundInRegistries = issuerInfo?.inRegistries
31-
? Array.from(issuerInfo.inRegistries).map(r => r.name)
32-
: []
15+
knownDIDRegistries: object
16+
}): Promise<LookupResult> {
3317

34-
return {foundInRegistries, registriesNotLoaded}
18+
const issuerDid = typeof issuer === 'string' ? issuer : issuer.id;
19+
await registryClient.use({ registries: knownDIDRegistries })
20+
const results = await registryClient.lookupIssuersFor(issuerDid);
21+
return results
3522

3623
}
3724

38-
export async function addTrustedIssuersToVerificationResponse( {issuer, knownDIDRegistries, reloadIssuerRegistry = false, verificationResponse} :{
25+
export async function addTrustedIssuersToVerificationResponse( {issuer, knownDIDRegistries, verificationResponse} :{
3926
issuer: string | any,
40-
reloadIssuerRegistry: boolean | null,
4127
knownDIDRegistries: object,
4228
verificationResponse: VerificationResponse
4329
}) : Promise<void>
4430
{
45-
const {foundInRegistries,registriesNotLoaded} = await getTrustedRegistryListForIssuer( {issuer, knownDIDRegistries, reloadIssuerRegistry});
31+
const {matchingIssuers,uncheckedRegistries} = await getTrustedRegistryListForIssuer( {issuer, knownDIDRegistries});
4632

4733
const registryStep = {
4834
"id": REGISTERED_ISSUER_STEP_ID,
49-
"valid": !!foundInRegistries.length,
50-
foundInRegistries,
51-
registriesNotLoaded
35+
"valid": !!matchingIssuers.length,
36+
matchingIssuers,
37+
uncheckedRegistries
5238
};
5339

5440
(verificationResponse.log ??= []).push(registryStep)

src/test-fixtures/expectedResults.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,23 @@ const expectedResult = {
1919
{
2020
"id": "registered_issuer",
2121
"valid": true,
22-
"foundInRegistries": [
23-
"DCC Sandbox Registry"
22+
"matchingIssuers": [
23+
{
24+
"issuer": {
25+
"federation_entity": {
26+
"organization_name": "Public Test Issuer",
27+
"homepage_uri": "https://dcconsortium.org",
28+
"location": "Everywhere"
29+
}
30+
},
31+
"registry": {
32+
"name": "DCC Sandbox Registry",
33+
"type": "dcc-legacy",
34+
"url": "https://digitalcredentials.github.io/sandbox-registry/registry.json"
35+
}
36+
}
2437
],
25-
"registriesNotLoaded": []
38+
"uncheckedRegistries": []
2639
}
2740
]
2841
}

0 commit comments

Comments
 (0)