-
Notifications
You must be signed in to change notification settings - Fork 9
fix: updated empty credential verifier check #110
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| import { VerificationFragment, Verifier, VerifierOptions } from '@tradetrust-tt/tt-verify'; | ||
| import { VerificationFragment, Verifier } from '@tradetrust-tt/tt-verify'; | ||
| import { SignedVerifiableCredential } from '@trustvc/w3c-vc'; | ||
| import { verifyW3CSignature } from '../../../../w3c'; | ||
|
|
||
| const type = 'DOCUMENT_STATUS'; | ||
| const name = 'W3CEmptyCredentialStatus'; | ||
|
|
||
| function isSignedVerifiableCredential(document: unknown): document is SignedVerifiableCredential { | ||
| return typeof document === 'object' && document !== null && 'proof' in document; | ||
| } | ||
|
|
||
| export const w3cEmptyCredentialStatus: Verifier<VerificationFragment> = { | ||
| skip: async () => { | ||
| return { | ||
|
|
@@ -28,10 +31,10 @@ export const w3cEmptyCredentialStatus: Verifier<VerificationFragment> = { | |
| ); | ||
| }, | ||
|
|
||
| verify: async (document: unknown, verifierOptions: VerifierOptions) => { | ||
| verify: async (document: unknown) => { | ||
| const doc = document as SignedVerifiableCredential; | ||
| const verificationResult = await verifyW3CSignature(doc, verifierOptions); | ||
| if (verificationResult.verified) { | ||
| const verificationResult = isSignedVerifiableCredential(doc); | ||
| if (verificationResult) { | ||
| return { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainKeep verify(document, verifierOptions) signature and tighten naming. Maintain the second parameter for backward compatibility and rename the boolean for clarity. - verify: async (document: unknown) => {
+ verify: async (document: unknown, _verifierOptions: VerifierOptions) => {
const doc = document as SignedVerifiableCredential;
- const verificationResult = isSignedVerifiableCredential(doc);
- if (verificationResult) {
+ const isSigned = isSignedVerifiableCredential(doc);
+ if (isSigned) {
return {
type,
name,
data: true,
status: 'VALID',
};
} else {
return {
type,
name,
data: false,
reason: {
- message: 'Document is not a valid SignedVerifiableCredential',
+ message: 'Document is not a valid SignedVerifiableCredential',
},
status: 'INVALID',
};
}
},Run to confirm signature parity across fragments: Also applies to: 50-55 🏁 Script executed: #!/bin/bash
# Verify other fragments still accept verifierOptions
rg -nP -C1 "verify:\s*async\s*\(\s*document:\s*unknown,\s*verifierOptions" src/verify
# Check this fragment’s usage and name occurrences
rg -n "W3CEmptyCredentialStatus|w3cEmptyCredentialStatus" -C2Length of output: 5130 Add missing
🤖 Prompt for AI Agents |
||
| type, | ||
| name, | ||
|
|
@@ -44,7 +47,7 @@ export const w3cEmptyCredentialStatus: Verifier<VerificationFragment> = { | |
| name, | ||
| data: false, | ||
| reason: { | ||
| message: verificationResult.error, | ||
| message: 'Document is not a valid SignedVerifiableCredential', | ||
| }, | ||
| status: 'INVALID', | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.