Skip to content

Commit

Permalink
add issuance with other dids
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Jan 12, 2024
1 parent 3f044c5 commit 318f5cf
Show file tree
Hide file tree
Showing 27 changed files with 998 additions and 88 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/continuous_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ jobs:
uses: appleboy/[email protected]
env:
AGENT_WALLET_KEY: ${{ secrets.AGENT_WALLET_KEY }}
CHEQD_TESTNET_COSMOS_PAYER_SEED: ${{ secrets.CHEQD_TESTNET_COSMOS_PAYER_SEED }}
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED: ${{ secrets.DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED }}
with:
host: dashboard.dev.animo.id
username: root
key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }}
envs: AGENT_WALLET_KEY
envs: AGENT_WALLET_KEY,DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED,CHEQD_TESTNET_COSMOS_PAYER_SEED
script: |
AGENT_WALLET_KEY=${AGENT_WALLET_KEY} docker stack deploy --compose-file openid4vc-playground/docker-compose.yml openid4vc-playground --with-registry-auth
AGENT_WALLET_KEY=${AGENT_WALLET_KEY} CHEQD_TESTNET_COSMOS_PAYER_SEED=${CHEQD_TESTNET_COSMOS_PAYER_SEED} DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED=${DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED} docker stack deploy --compose-file openid4vc-playground/docker-compose.yml openid4vc-playground --with-registry-auth
4 changes: 3 additions & 1 deletion agent/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
AGENT_HOST=http://localhost:3001
AGENT_WALLET_KEY=secret-wallet-key
AGENT_WALLET_KEY=secret-wallet-key
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED=2543786a945a27258087ccfe95ff62df
CHEQD_TESTNET_COSMOS_PAYER_SEED=robust across amount corn curve panther opera wish toe ring bleak empower wreck party abstract glad average muffin picnic jar squeeze annual long aunt
Binary file not shown.
Binary file not shown.
Binary file modified agent/dependencies/aries-framework-sd-jwt-vc-v0.4.2.tgz
Binary file not shown.
17 changes: 11 additions & 6 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "agent",
"dependencies": {
"@aries-framework/askar": "*",
"@aries-framework/core": "*",
"@aries-framework/node": "*",
"@aries-framework/openid4vc": "*",
"@aries-framework/sd-jwt-vc": "*",
"@aries-framework/askar": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-askar-v0.4.2.tgz",
"@aries-framework/cheqd": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-cheqd-v0.4.2.tgz",
"@aries-framework/core": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-core-v0.4.2.tgz",
"@aries-framework/indy-vdr": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-indy-vdr-v0.4.2.tgz",
"@aries-framework/node": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-node-v0.4.2.tgz",
"@aries-framework/openid4vc": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-openid4vc-v0.4.2.tgz",
"@aries-framework/sd-jwt-vc": "file:/Users/timo/Developer/openid4vc-playground/agent/dependencies/aries-framework-sd-jwt-vc-v0.4.2.tgz",
"@hyperledger/aries-askar-nodejs": "0.2.0-dev.5",
"@hyperledger/indy-vdr-nodejs": "0.2.0-dev.5",
"cors": "^2.8.5",
"express": "^4.18.2",
"zod": "^3.22.4"
Expand All @@ -25,6 +28,8 @@
"@aries-framework/node": "file:./dependencies/aries-framework-node-v0.4.2.tgz",
"@aries-framework/openid4vc": "file:./dependencies/aries-framework-openid4vc-v0.4.2.tgz",
"@aries-framework/askar": "file:./dependencies/aries-framework-askar-v0.4.2.tgz",
"@aries-framework/sd-jwt-vc": "file:./dependencies/aries-framework-sd-jwt-vc-v0.4.2.tgz"
"@aries-framework/sd-jwt-vc": "file:./dependencies/aries-framework-sd-jwt-vc-v0.4.2.tgz",
"@aries-framework/indy-vdr": "file:./dependencies/aries-framework-indy-vdr-v0.4.2.tgz",
"@aries-framework/cheqd": "file:./dependencies/aries-framework-cheqd-v0.4.2.tgz"
}
}
67 changes: 66 additions & 1 deletion agent/src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import {
Agent,
ConsoleLogger,
DidsModule,
JwkDidRegistrar,
JwkDidResolver,
KeyDidRegistrar,
KeyDidResolver,
LogLevel,
WebDidResolver,
joinUriParts,
} from "@aries-framework/core";
import { agentDependencies } from "@aries-framework/node";
import { SdJwtVcModule } from "@aries-framework/sd-jwt-vc";
import { AskarModule } from "@aries-framework/askar";
import {
CheqdModule,
CheqdDidRegistrar,
CheqdDidResolver,
} from "@aries-framework/cheqd";
import {
IndyVdrIndyDidRegistrar,
IndyVdrIndyDidResolver,
IndyVdrModule,
} from "@aries-framework/indy-vdr";
import { indyVdr } from "@hyperledger/indy-vdr-nodejs";
import { ariesAskar } from "@hyperledger/aries-askar-nodejs";
import {
OpenId4VcHolderModule,
OpenId4VcIssuerModule,
} from "@aries-framework/openid4vc";
import { AGENT_HOST, AGENT_WALLET_KEY } from "./constants";
import {
AGENT_HOST,
AGENT_WALLET_KEY,
CHEQD_TESTNET_COSMOS_PAYER_SEED,
} from "./constants";
import { Router } from "express";
import { credentialRequestToCredentialMapper } from "./issuer";

Expand All @@ -30,6 +51,50 @@ export const agent = new Agent({
},
},
modules: {
cheqd: new CheqdModule({
networks: [
{
network: "testnet",
cosmosPayerSeed: CHEQD_TESTNET_COSMOS_PAYER_SEED,
},
],
}),
indyVdr: new IndyVdrModule({
indyVdr,
networks: [
{
genesisTransactions: `{"reqSignature":{},"txn":{"data":{"data":{"alias":"OpsNode","blskey":"4i39oJqm7fVX33gnYEbFdGurMtwYQJgDEYfXdYykpbJMWogByocaXxKbuXdrg3k9LP33Tamq64gUwnm4oA7FkxqJ5h4WfKH6qyVLvmBu5HgeV8Rm1GJ33mKX6LWPbm1XE9TfzpQXJegKyxHQN9ABquyBVAsfC6NSM4J5t1QGraJBfZi","blskey_pop":"Qq3CzhSfugsCJotxSCRAnPjmNDJidDz7Ra8e4xvLTEzQ5w3ppGray9KynbGPH8T7XnUTU1ioZadTbjXaRY26xd4hQ3DxAyR4GqBymBn3UBomLRJHmj7ukcdJf9WE6tu1Fp1EhxmyaMqHv13KkDrDfCthgd2JjAWvSgMGWwAAzXEow5","client_ip":"13.58.197.208","client_port":"9702","node_ip":"3.135.134.42","node_port":"9701","services":["VALIDATOR"]},"dest":"EVwxHoKXUy2rnRzVdVKnJGWFviamxMwLvUso7KMjjQNH"},"metadata":{"from":"Pms5AZzgPWHSj6nNmJDfmo"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"77ad6682f320be9969f70a37d712344afed8e3fba8d43fa5602c81b578d26088"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"cynjanode","blskey":"32DLSweyJRxVMcVKGjUeNkVF1fwyFfRcFqGU9x7qL2ox2STpF6VxZkbxoLkGMPnt3gywRaY6jAjqgC8XMkf3webMJ4SEViPtBKZJjCCFTf4tGXfEsMwinummaPja85GgTALf7DddCNyCojmkXWHpgjrLx3626Z2MiNxVbaMapG2taFX","blskey_pop":"RQRU8GVYSYZeu9dfH6myhzZ2qfxeVpCL3bTzgto1bRbx3QCt3mFFQQBVbgrqui2JpXhcWXxoDzp1WyYbSZwYqYQbRmvK7PPG82VAvVagv1n83Qa3cdyGwCevZdEzxuETiiXBRWSPfb4JibAXPKkLZHyQHWCEHcAEVeXtx7FRS1wjTd","client_ip":"3.17.103.221","client_port":"9702","node_ip":"3.17.215.226","node_port":"9701","services":["VALIDATOR"]},"dest":"iTq944JTtwHnst7rucfsRA4m26x9i6zCKKohETBCiWu"},"metadata":{"from":"QC174PGaL4zA9YHYqofPH2"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"ce7361e44ec10a275899ece1574f6e38f2f3c7530c179fa07a2924e55775759b"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"GlobaliD","blskey":"4Behdr1KJfLTAPNospghtL7iWdCHca6MZDxAtzYNXq35QCUr4aqpLu6p4Sgu9wNbTACB3DbwmVgE2L7hX6UsasuvZautqUpf4nC5viFpH7X6mHyqLreBJTBH52tSwifQhRjuFAySbbfyRK3wb6R2Emxun9GY7MFNuy792LXYg4C6sRJ","blskey_pop":"RKYDRy8oTxKnyAV3HocapavH2jkw3PVe54JcEekxXz813DFbEy87N3i3BNqwHB7MH93qhtTRb7EZMaEiYhm92uaLKyubUMo5Rqjve2jbEdYEYVRmgNJWpxFKCmUBa5JwBWYuGunLMZZUTU3qjbdDXkJ9UNMQxDULCPU5gzLTy1B5kb","client_ip":"13.56.175.126","client_port":"9702","node_ip":"50.18.84.131","node_port":"9701","services":["VALIDATOR"]},"dest":"2ErWxamsNGBfhkFnwYgs4UW4aApct1kHUvu7jbkA1xX4"},"metadata":{"from":"4H8us7B1paLW9teANv8nam"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"0c3b33b77e0419d6883be35d14b389c3936712c38a469ac5320a3cae68be1293"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"IdRamp","blskey":"LoYzqUMPDZEfRshwGSzkgATxcM5FAS1LYx896zHnMfXP7duDsCQ6CBG2akBkZzgH3tBMvnjhs2z7PFc2gFeaKUF9fKDHhtbVqPofxH3ebcRfA959qU9mgvmkUwMUgwd21puRU6BebUwBiYxMxcE5ChReBnAkdAv19gVorm3prBMk94","blskey_pop":"R1DjpsG7UxgwstuF7WDUL17a9Qq64vCozwJZ88bTrSDPwC1cdRn3WmhqJw5LpEhFQJosDSVVT6tS8dAZrrssRv2YsELbfGEJ7ZGjhNjZHwhqg4qeustZ7PZZE3Vr1ALSHY4Aa6KpNzGodxu1XymYZWXAFokPAs3Kho8mKcJwLCHn3h","client_ip":"207.126.128.12","client_port":"9702","node_ip":"207.126.129.12","node_port":"9701","services":["VALIDATOR"]},"dest":"5Zj5Aec6Kt9ki1runrXu87wZ522mnm3zwmaoHLUcHLx9"},"metadata":{"from":"AFLDFPoJuDQUHqnfmg8U7i"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"c9df105558333ac8016610d9da5aad1e9a5dd50b9d9cc5684e94f439fa10f836"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"idlab-node01","blskey":"2fjJVi33U1tCTjW77cJaf1NLz7EzWkVNzR9BEQpVVK64MJpRKNUzt6k7Td2U8yqU5hGyAFH5N7ZymSB55TnpC3rJYLVTcGXZeXpmrQx3mwnXNyfTDnxfTpdQ1KMoFeZoDPZ8acfaH8GWeW2jL1qREE52tetBf4tXTeshmWzGkEN7r4y","blskey_pop":"RSjiM6dYUmN2rv2ca7dUCmEKrivq12rhxhXUKHdmSwUxbCmcijsgoERjYG7MqxhKLjSAJ5715K23fVEc6uK1kTenKmYCcCts8MLMAQG8Upb22nfgHJ3py8RwRoACeAjFF3myAMNRJJPhUdv96drJdwkGRv7f6JjvoB5KWVQYTNgheP","client_ip":"205.159.92.17","client_port":"9702","node_ip":"205.159.92.16","node_port":"9701","services":["VALIDATOR"]},"dest":"8czYgwmLDazVrBHuo53Tyx7Tw8ZhvnoC2BfhQGir4r8F"},"metadata":{"from":"PN8wFxLKjdkwyxoEEXwyz2"},"type":"0"},"txnMetadata":{"seqNo":5,"txnId":"9237eca7d2a203f6e1779f63064d2f22cf28e1bcd4e6fe5d791b15e82969acdc"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"lorica-identity-node1","blskey":"wUh24sVCQ8PHDgSb343g2eLxjD5vwxsrETfuV2sbwMNnYon9nhbaK5jcWTekvXtyiwxHxuiCCoZwKS97MQEAeC2oLbbMeKjYm212QwSnm7aKLEqTStXht35VqZvZLT7Q3mPQRYLjMGixdn4ocNHrBTMwPUQYycEqwaHWgE1ncDueXY","blskey_pop":"R2sMwF7UW6AaD4ALa1uB1YVPuP6JsdJ7LsUoViM9oySFqFt34C1x1tdHDysS9wwruzaaEFui6xNPqJ8eu3UBqcFKkoWhdsMqCALwe63ytxPwvtLtCffJLhHAcgrPC7DorXYdqhdG2cevdqc5oqFEAaKoFDBf12p5SsbbM4PYWCmVCb","client_ip":"35.225.220.151","client_port":"9702","node_ip":"35.224.26.110","node_port":"9701","services":["VALIDATOR"]},"dest":"k74ZsZuUaJEcB8RRxMwkCwdE5g1r9yzA3nx41qvYqYf"},"metadata":{"from":"Ex6hzsJFYzNJ7kzbfncNeU"},"type":"0"},"txnMetadata":{"seqNo":6,"txnId":"6880673ce4ae4a2352f103d2a6ae20469dd070f2027283a1da5e62a64a59d688"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"cysecure-itn","blskey":"GdCvMLkkBYevRFi93b6qaj9G2u1W6Vnbg8QhRD1chhrWR8vRE8x9x7KXVeUBPFf6yW5qq2JCfA2frc8SGni2RwjtTagezfwAwnorLhVJqS5ZxTi4pgcw6smebnt4zWVhTkh6ugDHEypHwNQBcw5WhBZcEJKgNbyVLnHok9ob6cfr3u","blskey_pop":"RbH9mY7M5p3UB3oj4sT1skYwMkxjoUnja8eTYfcm83VcNbxC9zR9pCiRhk4q1dJT3wkDBPGNKnk2p83vaJYLcgMuJtzoWoJAWAxjb3Mcq8Agf6cgQpBuzBq2uCzFPuQCAhDS4Kv9iwA6FsRnfvoeFTs1hhgSJVxQzDWMVTVAD9uCqu","client_ip":"35.169.19.171","client_port":"9702","node_ip":"54.225.56.21","node_port":"9701","services":["VALIDATOR"]},"dest":"4ETBDmHzx8iDQB6Xygmo9nNXtMgq9f6hxGArNhQ6Hh3u"},"metadata":{"from":"uSXXXEdBicPHMMhr3ddNF"},"type":"0"},"txnMetadata":{"seqNo":7,"txnId":"3c21718b07806b2f193b35953dda5b68b288efd551dce4467ce890703d5ba549"},"ver":"1"}`,
indyNamespace: "indicio:testnet",
isProduction: false,
connectOnStartup: true,
transactionAuthorAgreement: {
acceptanceMechanism: "for_session",
version: "1.0",
},
},
],
}),
dids: new DidsModule({
resolvers: [
new KeyDidResolver(),
new JwkDidResolver(),
new IndyVdrIndyDidResolver(),
new WebDidResolver(),
new CheqdDidResolver(),
],
registrars: [
new KeyDidRegistrar(),
new JwkDidRegistrar(),
new IndyVdrIndyDidRegistrar(),
new CheqdDidRegistrar(),
],
}),
sdJwtVc: new SdJwtVcModule(),
askar: new AskarModule({
ariesAskar,
Expand Down
6 changes: 6 additions & 0 deletions agent/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export const AGENT_HOST = process.env.AGENT_HOST ?? "http://localhost:3001";
export const AGENT_WALLET_KEY =
process.env.AGENT_WALLET_KEY ?? "openid4vc-playground";

export const DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED =
process.env.DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED;

export const CHEQD_TESTNET_COSMOS_PAYER_SEED =
process.env.CHEQD_TESTNET_COSMOS_PAYER_SEED;
23 changes: 23 additions & 0 deletions agent/src/did/cheqd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { agent } from "../agent";
import { CheqdDidCreateOptions } from "@aries-framework/cheqd";

export async function createDidCheqd() {
const didResult = await agent.dids.create<CheqdDidCreateOptions>({
method: "cheqd",
options: {
network: "testnet",
methodSpecificIdAlgo: "base58btc",
},
secret: {
// FIXME: verificationMethod should be optional in AFJ for cheqd
verificationMethod: {
id: "key-1",
type: "Ed25519VerificationKey2020",
},
},
});

if (didResult.didState.state === "failed") {
throw new Error("cheqd DID creation failed. " + didResult.didState.reason);
}
}
7 changes: 7 additions & 0 deletions agent/src/did/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from "./util";
export * from "./web";
export * from "./jwk";
export * from "./key";
export * from "./cheqd";
export * from "./indy";
export * from "./setup";
26 changes: 26 additions & 0 deletions agent/src/did/indy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { KeyType, TypedArrayEncoder } from "@aries-framework/core";
import { indyDidFromPublicKeyBase58 } from "@aries-framework/core/build/utils";
import { agent } from "../agent";

export async function importIndyDid(
namespaceIdentifier: string,
privateKey: string
) {
const key = await agent.wallet.createKey({
keyType: KeyType.Ed25519,
privateKey: TypedArrayEncoder.fromString(privateKey),
});

const indyDid = `did:indy:${namespaceIdentifier}:${indyDidFromPublicKeyBase58(
key.publicKeyBase58
)}`;

console.log({
indyDid,
publicKeyBase58: key.publicKeyBase58,
});
await agent.dids.import({
did: indyDid,
overwrite: true,
});
}
11 changes: 11 additions & 0 deletions agent/src/did/jwk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { KeyType, JwkDidCreateOptions } from "@aries-framework/core";
import { agent } from "../agent";

export async function createDidJwk() {
await agent.dids.create<JwkDidCreateOptions>({
method: "jwk",
options: {
keyType: KeyType.Ed25519,
},
});
}
11 changes: 11 additions & 0 deletions agent/src/did/key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { KeyType, KeyDidCreateOptions } from "@aries-framework/core";
import { agent } from "../agent";

export async function createDidKey() {
await agent.dids.create<KeyDidCreateOptions>({
method: "key",
options: {
keyType: KeyType.Ed25519,
},
});
}
50 changes: 50 additions & 0 deletions agent/src/did/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
CHEQD_TESTNET_COSMOS_PAYER_SEED,
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED,
} from "../constants";
import { createDidCheqd } from "./cheqd";
import { importIndyDid } from "./indy";
import { createDidJwk } from "./jwk";
import { createDidKey } from "./key";
import { getDidForMethod, hasDidForMethod } from "./util";
import { createDidWeb } from "./web";

const availableDids: string[] = [];

export async function setupAllDids() {
if (!(await hasDidForMethod("key"))) {
await createDidKey();
}
availableDids.push(await getDidForMethod("key"));

if (!(await hasDidForMethod("jwk"))) {
await createDidJwk();
}
availableDids.push(await getDidForMethod("jwk"));

if (!(await hasDidForMethod("web"))) {
await createDidWeb();
}
availableDids.push(await getDidForMethod("web"));

if (CHEQD_TESTNET_COSMOS_PAYER_SEED) {
if (!(await hasDidForMethod("cheqd"))) {
await createDidCheqd();
}
availableDids.push(await getDidForMethod("cheqd"));
}

if (DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED) {
if (!(await hasDidForMethod("indy"))) {
await importIndyDid(
"indicio:testnet",
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED
);
}
availableDids.push(await getDidForMethod("indy"));
}
}

export function getAvailableDids() {
return availableDids;
}
17 changes: 17 additions & 0 deletions agent/src/did/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { agent } from "../agent";

export async function hasDidForMethod(method: string) {
const [createdDid] = await agent.dids.getCreatedDids({ method });

return createdDid !== undefined;
}

export async function getDidForMethod(method: string) {
const [createdDid] = await agent.dids.getCreatedDids({ method });

if (!createdDid) {
throw new Error(`did for method ${method} does not exist`);
}

return createdDid.did;
}
32 changes: 12 additions & 20 deletions agent/src/did.ts → agent/src/did/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@ import {
DidDocumentBuilder,
getEd25519VerificationKey2018,
getJsonWebKey2020,
getJwkFromJson,
getJwkFromKey,
} from "@aries-framework/core";
import { agent } from "./agent";
import { AGENT_HOST } from "./constants";
import { agent } from "../agent";
import { AGENT_HOST } from "../constants";

const cleanHost = encodeURIComponent(
AGENT_HOST.replace("https://", "").replace("http://", "")
);

const did = `did:web:${cleanHost}`;
const didWeb = `did:web:${cleanHost}`;

export async function createDidWeb() {
const ed25519KeyId = `${did}#ed25519`;
const ed25519KeyId = `${didWeb}#ed25519`;
const ed25519Key = await agent.wallet.createKey({
keyType: KeyType.Ed25519,
});

const p256KeyId = `${did}#p256`;
const p256KeyId = `${didWeb}#p256`;
const p256Key = await agent.wallet.createKey({
keyType: KeyType.P256,
});

const didDocument = new DidDocumentBuilder(did)
const didDocument = new DidDocumentBuilder(didWeb)
.addVerificationMethod(
getEd25519VerificationKey2018({
key: ed25519Key,
controller: did,
controller: didWeb,
id: ed25519KeyId,
})
)
.addVerificationMethod(
getJsonWebKey2020({
key: p256Key,
did,
did: didWeb,
verificationMethodId: p256KeyId,
})
)
Expand All @@ -46,22 +44,16 @@ export async function createDidWeb() {
.build();

await agent.dids.import({
did,
did: didWeb,
didDocument,
});
}

export async function hasDidWeb() {
const [createdDid] = await agent.dids.getCreatedDids({ did });

return createdDid !== undefined;
}

export async function getDidWeb() {
const [createdDid] = await agent.dids.getCreatedDids({ did });
export async function getWebDidDocument() {
const [createdDid] = await agent.dids.getCreatedDids({ did: didWeb });

if (!createdDid || !createdDid.didDocument) {
throw new Error("did does not exist");
throw new Error(`did does not exist`);
}

return createdDid.didDocument;
Expand Down
Loading

0 comments on commit 318f5cf

Please sign in to comment.