Skip to content

Fix(auth): publicDid never persisted to wallet after DID creation in did.service.ts #114

Description

@Jashk120

Summary

In did.service.ts, the assignment that persists the created DID to the wallet entity is commented out:

// wallet.publicDid = didDocument.id
await this.em.flush()

The flush runs but publicDid is never set, so every wallet is saved with publicDid: null after DID creation.


Consequences

Duplicate DID guard never triggers
createDid() checks if (wallet.publicDid) at the top and throws if a DID already exists. Since publicDid is always null, the same wallet can create multiple DIDs on Hedera repeatedly.

Controller resolution always fails for OrgAdmin and Iss<!-- <!-- uer
Both roles require a controller wallet with a valid publicDid. Since no wallet ever has it set, the check:

if (!didControllerWallet || !didControllerWallet.publicDid)

always throws — meaning OrgAdmin and Issuer DID creation is permanently broken.

Test suite masks the bug
Tests mock publicDid as already set, so no test ever exercises the real assignment path. CI stays green.


Fix

  • Uncomment the assignment before the flush:
wallet.publicDid = didDocument.id
await this.em.flush()

A test verifying publicDid is set after createDid() completes should accompany the fix. -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions