-
Notifications
You must be signed in to change notification settings - Fork 20
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: oav3 did identity #154
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yehjxraymond
commented
Jan 27, 2021
Comment on lines
+44
to
+85
const data = getData(document); | ||
const merkleRoot = `0x${document.signature.merkleRoot}`; | ||
const signatureVerificationDeferred: Promise<SignatureVerificationFragment>[] = data.issuers.map(async (issuer) => { | ||
if (issuer.identityProof?.type === "DID") { | ||
const did = issuer.id; | ||
if (!did) throw new CodedError("id is missing in issuer", OpenAttestationDidCode.DID_MISSING, "DID_MISSING"); | ||
const key = issuer.identityProof?.key; | ||
if (!key) | ||
throw new CodedError( | ||
"Key is not present", | ||
OpenAttestationDidCode.MALFORMED_IDENTITY_PROOF, | ||
"MALFORMED_IDENTITY_PROOF" | ||
); | ||
const correspondingProof = document.proof.find((p) => p.verificationMethod.toLowerCase() === key.toLowerCase()); | ||
if (!correspondingProof) return { status: "INVALID", reason: "`id` is missing from issuer" }; | ||
|
||
const { verified } = await verifySignature({ | ||
merkleRoot, | ||
key, | ||
signature: correspondingProof.signature, | ||
did, | ||
}); | ||
return { did, status: verified ? "VALID" : "INVALID" }; | ||
} | ||
throw new CodedError( | ||
"Issuer is not using DID identityProof type", | ||
OpenAttestationDidCode.INVALID_ISSUERS, | ||
OpenAttestationDidCode[OpenAttestationDidCode.INVALID_ISSUERS] | ||
); | ||
}); | ||
const signatureVerifications = await Promise.all(signatureVerificationDeferred); | ||
const signedOnAll = | ||
signatureVerifications.some((i) => i.status === "VALID") && | ||
signatureVerifications.every((i) => i.status === "VALID"); | ||
|
||
return { | ||
name, | ||
type, | ||
data: signatureVerifications, | ||
status: signedOnAll ? "VALID" : "INVALID", | ||
}; | ||
}; |
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.
No changes to code here
Nebulis
approved these changes
Jan 27, 2021
yehjxraymond
added a commit
that referenced
this pull request
Feb 9, 2021
* chore: deleted previous v3 * feat: test fixture generation for dnsdid and did * fix: broken test * feat: documentIntegrity/hash working for v3 (#151) Co-authored-by: Raymond Yeh <ray@geek.sg> * feat: documentStatus/didSigned for v3 * fix: broken test * fix: lint & tests * fix: npm audit * chore: auto issue on generate script * feat: oav3 document store (#152) * chore: refactored verifier into skip, test & verify * feat: document store verification & generating revoked docs * chore: update comment Co-authored-by: Raymond Yeh <ray@geek.sg> * feat: verification for v3 with did identity proof (#154) Co-authored-by: Raymond Yeh <ray@geek.sg> * feat: oav3 dns did (#155) * feat: verification for dns-did * chore: refactored constraint checks * fix: lint * fix: test description Co-authored-by: Nebulis <nebounet@gmail.com> Co-authored-by: Raymond Yeh <ray@geek.sg> Co-authored-by: Nebulis <nebounet@gmail.com> * [WIP] feat: oav3 token registry (#153) * chore: refactored into test verify skip * chore: refactoring test [wip] * chore: refractor test * chores: empty-test-for-v3 * chore: removed unnecessary tests * chore: refractor-test-case * chore: added-v3-test * chore: added-v3-verify * test: added v3-verify-test * chore: fix-lint * chore: refactored code Co-authored-by: Raymond Yeh <ray@geek.sg> Co-authored-by: Chen Ren <siachenren@gmail.com> * feat: v3 dns txt (#156) * chore: refactored previous verifier * chore: refactored test * chore: rename test & added v3 tests * feat: verify for v3 documents * fix: lint * fix: token registry's test & oav3 integration test (#157) * chore: integration test for all OAv3 documents * chore: better var naming * fix: lint * chore: added getFailingFragments to tests * fix: reasons for dnsTxt moved out Co-authored-by: Raymond Yeh <ray@geek.sg> Co-authored-by: Raymond Yeh <ray@geek.sg> * chore: reference to generate script in readme * chore: using did-sign for v3 signing * chore: deleted unused code path * fix: better error message when document dont match * fix: uncommented document generation step Co-authored-by: Raymond Yeh <ray@geek.sg> Co-authored-by: Nebulis <nebounet@gmail.com> Co-authored-by: Chen Ren <siachenren@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.