Skip to content

Commit

Permalink
Switch to DIF did web resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
brianorwhatever authored and ottonomy committed Jan 31, 2024
1 parent e4ddecf commit 81480ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 9 additions & 4 deletions common/documentLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as DidJwk from '@digitalbazaar/did-method-jwk';
import * as DidKey from '@digitalbazaar/did-method-key';
import * as DidWeb from '@interop/did-web-resolver';
import {
CONTEXT as CRED_CONTEXT,
CONTEXT_URL as CRED_CONTEXT_URL
Expand Down Expand Up @@ -31,18 +30,21 @@ import {
} from '@digitalbazaar/vdl-context';
import {CachedResolver} from '@digitalbazaar/did-io';
import {CryptoLD} from 'crypto-ld';
import {getResolver as didWebResolver} from 'web-did-resolver';
import {Ed25519VerificationKey2020}
from '@digitalbazaar/ed25519-verification-key-2020';
import {JsonLdDocumentLoader} from 'jsonld-document-loader';
import {parse} from 'did-resolver';
import X25519KeyAgreement2020Context from 'x25519-key-agreement-2020-context';
import {X25519KeyAgreementKey2020}
from '@digitalbazaar/x25519-key-agreement-key-2020';

const cryptoLd = new CryptoLD();
cryptoLd.use(Ed25519VerificationKey2020);
cryptoLd.use(X25519KeyAgreementKey2020);

const didWebDriver = DidWeb.driver({cryptoLd});
const didWebDriver = options => {
return didWebResolver(options).web;
};
const didKeyDriver = DidKey.driver();
didKeyDriver.use({
name: 'Ed25519',
Expand All @@ -57,7 +59,10 @@ didJwkDriver.use({
});

export const didResolver = new CachedResolver();
didResolver.use(didWebDriver);
didResolver.use({method: 'web', get: async opt => {
const parsedDID = parse(opt.did);
return didWebDriver()(opt.did, parsedDID);
}});
didResolver.use(didKeyDriver);
didResolver.use(didJwkDriver);

Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@digitalbazaar/vdl-aamva-context": "^1.0.0",
"@digitalbazaar/vdl-context": "^1.0.0",
"@digitalbazaar/x25519-key-agreement-key-2020": "^3.0.1",
"@interop/did-web-resolver": "^3.0.1",
"base64url": "^3.0.1",
"bnid": "^3.0.0",
"cors": "^2.8.5",
Expand All @@ -50,6 +49,7 @@
"crypto-ld": "^7.0.0",
"did-context": "^3.1.1",
"did-jwt-vc": "^3.2.14",
"did-resolver": "^4.1.0",
"dotenv": "^16.0.1",
"ed25519-signature-2020-context": "^1.1.0",
"express": "^4.17.1",
Expand All @@ -66,6 +66,7 @@
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"vue-json-pretty": "^2.2.4",
"web-did-resolver": "^2.0.27",
"x25519-key-agreement-2020-context": "^1.0.0"
},
"devDependencies": {
Expand All @@ -91,14 +92,5 @@
"tailwindcss": "^3.3.3",
"vite": "^4.4.5",
"vue": "^3.3.4"
},
"overrides": {
"@interop/did-web-resolver": {
"@digitalcredentials/http-client": {
"ky-universal": {
"ky": "0.25.1"
}
}
}
}
}

0 comments on commit 81480ce

Please sign in to comment.