Skip to content
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

Merged
merged 3 commits into from
Jul 12, 2021
Merged

feat: Pass issuer to verifyJWS #41

merged 3 commits into from
Jul 12, 2021

Conversation

ukstv
Copy link
Contributor

@ukstv ukstv commented Jul 12, 2021

If did-A is the controller of did-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.

@ukstv ukstv requested a review from oed July 12, 2021 11:47
Copy link
Member

@oed oed left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not .includes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about it :)

src/did.ts Outdated Show resolved Hide resolved
Comment on lines +246 to +248
const signerDid = didResolutionResult.didDocument?.id
if (options.issuer && options.issuer !== signerDid) {
const issuerUrl = didWithTime(options.issuer, options.atTime)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yeah.

Copy link
Contributor Author

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.

ukstv and others added 2 commits July 12, 2021 15:11
Co-authored-by: Joel Thorstensson <oed@3box.io>
@@ -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
Copy link
Member

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 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhums :)

@ukstv ukstv merged commit ce1f488 into master Jul 12, 2021
@ukstv ukstv deleted the su/issuer branch November 24, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants