-
Notifications
You must be signed in to change notification settings - Fork 28
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: Pass issuer to verifyJWS #41
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.
Looks good, suggesting a few changes.
src/did.ts
Outdated
const issuerResolution = await this.resolve(issuerUrl) | ||
const controllerProperty = issuerResolution.didDocument?.controller | ||
const controllers = extractControllers(controllerProperty) | ||
const signerIsController = controllers.some((controller) => controller === signerDid) |
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 not .includes
?
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.
Forgot about it :)
const signerDid = didResolutionResult.didDocument?.id | ||
if (options.issuer && options.issuer !== signerDid) { | ||
const issuerUrl = didWithTime(options.issuer, options.atTime) |
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.
Maybe break this and the timecheckEnabled
conditional into helper functions?
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.
TBH, I would like to accumulate a little more weirdness like this, and extract verifyJWS
into own verification service. It clearly does not belong here as a method of DID
object.
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.
Well, ideally most of this logic could move into the did-jwt package. Which btw should be renamed did-jose at some point: decentralized-identity/did-jwt#170
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.
Ideally, yeah.
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.
I really want to accumulate weirdness here nevertheless to guide the further changes.
Co-authored-by: Joel Thorstensson <oed@3box.io>
Signed-off-by: ukstv <sergey@ukstv.me>
@@ -249,7 +249,7 @@ export class DID { | |||
const issuerResolution = await this.resolve(issuerUrl) | |||
const controllerProperty = issuerResolution.didDocument?.controller | |||
const controllers = extractControllers(controllerProperty) | |||
const signerIsController = controllers.some((controller) => controller === signerDid) | |||
const signerIsController = signerDid ? controllers.includes(signerDid) : false |
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.
eh, ok I see why now 😆
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.
uhums :)
If
did-A
is the controller ofdid-B
a signature performed by A should be seen as valid if B is the issuer. We use the controller property in DID documents to allow for Safe and NFT DIDs.