Skip to content

Commit

Permalink
fixed DID resoultion
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwas1 committed Jan 8, 2025
1 parent 16b26d9 commit 82705f2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/did/services/did.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,15 +840,20 @@ export class DidService {

async resolveDid(appDetail, did: string) {
Logger.log('resolveDid() method: starts....', 'DidService');

const didInfo = await this.didRepositiory.findOne({
did,
});
let resolvedDid;
if (didInfo !== null && didInfo.registrationStatus !== 'COMPLETED') {
const hypersignDid = new HypersignDID();
const resolvedDIDDocFromBc = await hypersignDid.resolve({ did });
if (
(!resolvedDIDDocFromBc ||
Object.keys(resolvedDIDDocFromBc.didDocument).length == 0) &&
didInfo
) {
// didInfo !== null && didInfo.registrationStatus !== 'COMPLETED') {
const { edvId, kmsId } = appDetail;
Logger.log('resolveDid() method: initialising edv service', 'DidService');

const mnemonic = await getAppMenemonic(kmsId);
const didSplitedArray = did.split(':'); // Todo Remove this worst way of doing it
const namespace = didSplitedArray[2];
Expand All @@ -873,23 +878,19 @@ export class DidService {
'resolveDid() method: before calling hypersignDid.generate',
'DidService',
);
console.log(methodSpecificId);
console.log(publicKeyMultibase);

resolvedDid = await hypersignDid.generate({
methodSpecificId,
publicKeyMultibase,
});

const tempResolvedDid = {
didDocument: resolvedDid,
didDocumentMetadata: {},
didDocumentMetadata: null,
name: didInfo.name,
};
resolvedDid = tempResolvedDid;
} else {
const hypersignDid = new HypersignDID();
resolvedDid = await hypersignDid.resolve({ did });
resolvedDid = resolvedDIDDocFromBc;
resolvedDid['name'] = didInfo?.name;
}
return resolvedDid;
Expand Down

0 comments on commit 82705f2

Please sign in to comment.