From f69bc6a3c9878bbe21df18674426d9622f3034fa Mon Sep 17 00:00:00 2001 From: eum602 Date: Tue, 25 Jun 2024 22:17:34 -0500 Subject: [PATCH] Fix: Re define identifiers for the main controller set as default verification method Signed-off-by: eum602 --- lib/lac1/lac1resolverUtils.js | 7 ++++++- test/lac1/lac1Resolver.js | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/lac1/lac1resolverUtils.js b/lib/lac1/lac1resolverUtils.js index 8ba5db8..dabfcfe 100644 --- a/lib/lac1/lac1resolverUtils.js +++ b/lib/lac1/lac1resolverUtils.js @@ -157,8 +157,13 @@ export function wrapDidDocument( mode ) { const now = BigNumber.from(Math.floor(new Date().getTime() / 1000)); + const valueInHex = caip10ControllerFormat.split(":")[2]; + const defaultIdVerificationMethod = processVerificationMethodIdForAttribute( + did, + valueInHex + ); const defaultVerificationMethod = { - id: `${did}#controller`, + id: `${did}#${defaultIdVerificationMethod}`, type: "EcdsaSecp256k1RecoveryMethod2020", controller: `${did}`, blockchainAccountId: caip10ControllerFormat, diff --git a/test/lac1/lac1Resolver.js b/test/lac1/lac1Resolver.js index 82e33c9..d2cdcf2 100644 --- a/test/lac1/lac1Resolver.js +++ b/test/lac1/lac1Resolver.js @@ -6,6 +6,7 @@ import { getLac1didTestParams, newLac1Did as newDid, } from "../testInitializer.js"; +import { processVerificationMethodIdForAttribute } from "../../lib/lac1/lac1resolverUtils.js"; const expect = chai.expect; chai.use(chaiAsPromised); @@ -45,9 +46,13 @@ describe("Lac1 DIDResolver", async () => { const document = await resolver.lac1(did.id); const d = document.verificationMethod[0]; expect(d["controller"]).to.eq(did.id); - expect(d["id"]).to.eq(`${did.id}#controller`); - expect(d["type"]).to.eq("EcdsaSecp256k1RecoveryMethod2020"); const currentController = await did.getController(); + const defaultIdVerificationMethod = processVerificationMethodIdForAttribute( + did.id, + currentController + ); + expect(d["id"]).to.eq(`${did.id}#${defaultIdVerificationMethod}`); + expect(d["type"]).to.eq("EcdsaSecp256k1RecoveryMethod2020"); const retrievedHexchainId = did.chainId.length % 2 == 0 ? did.chainId : "0" + did.chainId; const retrievedIntchainId = parseInt(retrievedHexchainId, 16);