Closed radleylewis closed 5 months ago
I want to provide an update on this bug. Specifically, I have identified the variation in the behaviour between using the memory stores and the persistent databases (sqlite, postgres etc).
The issue pertains to the DIDStore
. When the MemoryDIDStore
saves an identifier, it is not concerned with any relations (i.e. keys, services) and so simply applies the save in importDID
as follows:
async importDID(args: IIdentifier) {
const identifier = { ...args }
for (const key of identifier.keys) {
if (key.privateKeyHex) {
delete key.privateKeyHex
}
}
this.identifiers[args.did] = identifier // this line here
return true
}
However, when dealing with the persistent datastores, if the key itself has not first been imported using agent.keyManagerImport
then the operation will fail. So any call to didManagerAddKey
needs to be preempted with keyManagerImport
.
Its arguable that this is not a bug, however, it isn't at all intuitive and I was stuck on this for a fair while. I am happy to raise a PR with a fix, however the typing in the didStore doesn't allow for easy patching.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bug severity 4
Describe the bug When adding a key, using the
didManagerAddKey
method, the Identifier is being successfully transmitted to the network but is not stored faithfully in the local store (i.e. the resolved DIDDoc from the network includes the X25519 key being added, however, the local store usingdidManagerGet
resolves a DIDDoc that does not included the added key).To Reproduce Steps to reproduce the behaviour: I have create a repository here which isolates the relevant logical calls and configures a minimal veramo agent to demonstrate the issue. There are instructions included in the README.
Observed behaviour When using a db connection to
sqlite
orpostgres
the local DIDDoc does not include the added key (despite it having been transmitted successfully to the network and available on the network resolvable DIDDoc). When using theMemoryDidStore
andMemoryKeyStore
(as opposed to the keystores with the persistent db connection), the correct DIDDoc is returned (i.e. the local DIDDoc includes the addedX25519
key).Expected behaviour The local DIDDoc should reflect the updated changes (added key) when using the persistent database connections (sqlite, postgres).
Details Expected Local DIDDoc (includes two keys: secp256k1, x25519 just added):
Actual Output (missing x25519 key):
Additional context Repo to reproduce
Versions (please complete the following information):
5.6.0
N/A
21.4.0