Skip to content

fix: validate credentialStatus format only at sign, not verify - #106

Merged
rongquan1 merged 1 commit into
mainfrom
fix/decouple-credentialstatus-from-checkcredential
Jul 29, 2026
Merged

fix: validate credentialStatus format only at sign, not verify#106
rongquan1 merged 1 commit into
mainfrom
fix/decouple-credentialstatus-from-checkcredential

Conversation

@rongquan1

@rongquan1 rongquan1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved credential verification by routing credential status validation through the dedicated status verifier.
    • Prevented status-related errors from being incorrectly reported as overall credential or signature integrity failures.

_checkCredential ran assertCredentialStatuses in both 'sign' and 'verify' modes.
Since 2.4.0's assertTransferableRecords strictly requires an integer chainId (via
assertIntegerChainId), a malformed tokenNetwork.chainId now throws during verify —
and _checkCredential(mode: 'verify') is reached by isSignedDocument() and the
DataIntegrity verifiers. That made a credential-status field problem masquerade as
"document is not signed" / a signature-integrity failure.

Gate the credentialStatus field-format validation to 'sign' mode. At verify the
status is the concern of the dedicated status verifier (verifyCredentialStatus), so
a malformed chainId now surfaces as a DOCUMENT_STATUS problem instead of a signature
one. Sign-time validation is unchanged (still rejects a bad chainId at creation).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d29f22e8-3f9a-43be-9b71-9afeb21837fe

📥 Commits

Reviewing files that changed from the base of the PR and between 4721297 and cb3ccc8.

📒 Files selected for processing (1)
  • packages/w3c-vc/src/lib/helper/index.ts

📝 Walkthrough

Walkthrough

_checkCredential now validates credentialStatus formatting only during signing. Verify-mode status failures are left to the dedicated credential-status verifier.

Changes

Credential status validation

Layer / File(s) Summary
Sign-mode credential status validation
packages/w3c-vc/src/lib/helper/index.ts
_checkCredential invokes assertCredentialStatuses only when mode === 'sign'; verify mode no longer performs this formatting check here.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: manishdex25

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided, so required Summary, Changes, Issues, and Releases sections are missing. Add the template sections with a brief summary, change list, related issues, and release/ETA details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change to credentialStatus validation during sign, not verify.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/decouple-credentialstatus-from-checkcredential

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@rongquan1
rongquan1 requested a review from manishdex25 July 29, 2026 07:18
@rongquan1
rongquan1 merged commit ade0b3e into main Jul 29, 2026
19 checks passed
@rongquan1
rongquan1 deleted the fix/decouple-credentialstatus-from-checkcredential branch July 29, 2026 08:56
nghaninn pushed a commit that referenced this pull request Jul 29, 2026
## [2.4.1](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-vc@2.4.0...@trustvc/w3c-vc@2.4.1) (2026-07-29)

### Bug Fixes

* validate credentialStatus format only at sign, not verify ([#106](#106)) ([ade0b3e](ade0b3e))
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Jul 29, 2026
## [2.4.1](https://github.com/TrustVC/w3c/compare/@trustvc/w3c@2.4.0...@trustvc/w3c@2.4.1) (2026-07-29)

### Bug Fixes

* validate credentialStatus format only at sign, not verify ([#106](#106)) ([ade0b3e](ade0b3e))
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants