-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Upgrade did-resolver to v3 #151
feat!: Upgrade did-resolver to v3 #151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the help maintaining this library!
The PR generally looks good, but I have some questions that I'd like to get answered before the merge.
src/xc20pEncryption.ts
Outdated
if (typeof key === 'string') { | ||
return didDoc.publicKey.find((pk) => pk.id === key) | ||
return didDocument.verificationMethod.find((pk) => pk.id === key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some resolvers may still be using the deprecated publicKey
member of the DIDDocument
.
I think the 2 arrays should be merged, to support these resolvers.
Perhaps something like this would do the trick:
return didDocument.verificationMethod.find((pk) => pk.id === key) | |
return ([ | |
...(didDocument.publicKey), | |
...(didDocument.verificationMethod) | |
].find((pk) => pk.id === key) |
I see that a similar approach is used in JWT.ts#resolveAuthenticator()
but that one has some extra checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I believe I did this elsewhere in the code.
src/VerifierAlgorithm.ts
Outdated
if (pk.publicKeyBase58) { | ||
return base58ToBytes(pk.publicKeyBase58) | ||
} else if (pk.publicKeyBase64) { | ||
} else if (isLegacyVerMethod(pk) && pk.publicKeyBase64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this extra check necessary?
Perhaps it can be simplified to something like:
} else if (isLegacyVerMethod(pk) && pk.publicKeyBase64) { | |
} else if ((<LegacyVerificationMethod>pk).publicKeyBase64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, ty
src/JWT.ts
Outdated
const authenticators: PublicKey[] = publicKeysToCheck.filter(({ type }) => | ||
types.find((supported) => supported === type) | ||
const authenticators: VerificationMethod[] = publicKeysToCheck.filter(({ type }) => | ||
types.indexOf(type) !== -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the filter for supported types removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually the same logic. This change is not needed, can change it back.
Pushed some edits to address your comments @mirceanis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for the contribution!
# [5.0.0](4.9.0...5.0.0) (2021-03-09) ### Features * upgrade did-resolver to v3 ([#151](#151)) ([e02f56b](e02f56b)) ### BREAKING CHANGES * The `Resolver` used during verification is expected to conform to the latest spec.
🎉 This PR is included in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Replaces #150
Fixes #144
Edit:
I think this would be seen as a breaking release so I flagged it as such.