Conversation
f989484 to
8bb243e
Compare
|
I'm not sure I get what is going on here. We display the outdated DID format in the new format? I think I remember that the problem was that the old signature is just not valid over the new format. Have we solved this somehow? |
|
Hey @rflechtner, sorry that I didn't clarify, though I remember mentioning it to you, the old signature IS valid even for the new format, as the signature is essentially built the same way with the same data and they match . |
Yeah sorry man I can't seem to remember. So when I run the resulting object through the sdk or the did resolver, they would validate the signature correctly, regardless of whether it was originally part of the old or the new format? |
|
No worries, might have been some time ago 🙄 ...the resulting signatures match! |
rflechtner
left a comment
There was a problem hiding this comment.
Seems to do what it is supposed to do 👍
I had a hard time reviewing because it was not easy to understand what the original format looked like and what we'd have to do to translate. In-line comments and appropriate typing could help!
| @@ -50,9 +67,15 @@ export class MongoDbMContactsService implements ContactsService { | |||
| } | |||
| private convertToContact(contactDB: ContactDB): Contact { | |||
There was a problem hiding this comment.
can we adjust the typing so that it reflects the potential conversion from the old to the new format?
the easiest way to do this would probably be
| private convertToContact(contactDB: ContactDB): Contact { | |
| private convertToContact(contactDB: ContactDB & {signature?: string} ): Contact { |
There was a problem hiding this comment.
Yeah, I really wasn't sure how to deal with "shadow" properties, but it seems like this is a great way to deal with potential shadow properties
| return { | ||
| metaData, | ||
| did, | ||
| did: actualDid, |
There was a problem hiding this comment.
I guess
| did: actualDid, | |
| did: contactDB.signature && did ? {...did, signature: contactDB.signature} : did, |
would also do it?
There was a problem hiding this comment.
in fact when you add the optional {signature?: string} to the signature you could even make this more concise by adding signature to
const { metaData, did, publicIdentity } = contactDB
| .deleteOne({ | ||
| 'publicIdentity.address': contact.publicIdentity.address, | ||
| }) |
There was a problem hiding this comment.
can you add a comment describing why we need to delete the existing entry first?
There was a problem hiding this comment.
I.e. why an update just won't do the trick?
There was a problem hiding this comment.
Yes, sure, also for here: ran into issues with updating as this keeps the old properties as artifacts or something, it does not exactly replace the stored document, thus not removing the signature outer property.
fixes KILTProtocol/ticket#744
When Contact with deprecated format exists in DB we delete on update and respond SDK format.
How to test:
docker-compose up -d mongodb
start old democlient and old services
register Contact with DID in deprecated format
restart services with this PR included
visit http://localhost:3000/contacts
contact DID should be displayed in updated sdk format
Checklist: