feat: add obligation records context and related types - #104
Conversation
- Introduced a new JSON context for obligation records. - Updated index.ts to include the new obligation records context. - Added ObligationRecordsCredentialStatus type to manage obligation records. - Implemented assertion function for ObligationRecordsCredentialStatus in utils.ts. - Enhanced credential status checking to accommodate obligation records.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds Obligation Records and bill-of-exchange JSON-LD contexts, registers them with the document loader, introduces related credential-status typing and validation, updates VC dispatch, and adds samples, documentation, tests, and copy-script entries. ChangesObligation Records support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CredentialStatus
participant _checkCredentialStatus
participant assertObligationRecords
participant assertTransferableRecords
CredentialStatus->>_checkCredentialStatus: provide TransferableRecords status
alt obligationRegistry is present
_checkCredentialStatus->>assertObligationRecords: validate Obligation Records status
else obligationRegistry is absent
_checkCredentialStatus->>assertTransferableRecords: validate transferable status
end
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/w3c-credential-status/src/lib/utils.ts`:
- Around line 180-182: Replace the Number(chainId) check in the
credential-status validator with explicit validation that rejects empty,
non-numeric, non-finite, and fractional values while accepting only actual
integers. Apply the same shared integer-validation helper to the existing
Transferable Records validator, preserving the current error context for
chainId.
In `@packages/w3c-vc/src/lib/helper/index.ts`:
- Around line 530-536: The validator dispatch must choose based on whether
obligationRegistry is present, not whether it is a string. Update the
conditional in the status-validation flow to route any object containing
obligationRegistry to assertObligationRecords, allowing that validator to reject
invalid types; otherwise use assertTransferableRecords. Add a regression test
covering numeric obligationRegistry with a valid tokenRegistry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 28faf9d8-4261-4f21-96a7-f40ce8982e6b
📒 Files selected for processing (5)
packages/w3c-context/src/context/obligation-records-context.jsonpackages/w3c-context/src/lib/index.tspackages/w3c-credential-status/src/lib/types.tspackages/w3c-credential-status/src/lib/utils.tspackages/w3c-vc/src/lib/helper/index.ts
…ct sample - Refactored the bill of exchange context to replace deprecated fields with new identifiers.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/w3c-credential-status/src/lib/utils.ts (1)
189-195: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winReject any present
tokenIdin sign mode.
assertObligationRecords(..., 'sign')currently allowstokenId: '',0,false, ornullbecause the check is truthiness-based. Check property presence instead, and apply the same correction toassertTransferableRecordsfor parity.Proposed fix
- if (tokenId && mode === 'sign') { + if (mode === 'sign' && Object.prototype.hasOwnProperty.call(credentialStatus, 'tokenId')) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/w3c-credential-status/src/lib/utils.ts` around lines 189 - 195, Update the sign-mode checks in assertObligationRecords and assertTransferableRecords to reject tokenId whenever the property is present, including empty, zero, false, or null values, rather than relying on truthiness. Preserve the existing verify-mode validation and error behavior for absent tokenId values.
🧹 Nitpick comments (1)
packages/w3c-credential-status/src/lib/utils.test.ts (1)
95-111: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the full chainId matrix for obligation records.
The obligation test does not verify numeric strings, fractional values, non-numeric strings,
NaN, orInfinity, unlike the Transferable Records tests. Reuse the same parameterized cases so regressions inassertObligationRecordsare detected.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/w3c-credential-status/src/lib/utils.test.ts` around lines 95 - 111, Expand the parameterized chainId coverage in the assertObligationRecords tests to match the existing Transferable Records matrix, including numeric strings, fractional values, non-numeric strings, NaN, and Infinity. Reuse the same valid and invalid cases while keeping the expected integer-validation error assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/w3c-context/README.md`:
- Around line 70-89: Add
https://trustvc.io/context/render-method-context-v2.json to the “Available
Context URLs” list in the TrustVC Business Contexts section, reflecting the file
deployed by scripts/copy-files.sh. If the context is intentionally internal,
explicitly document that instead of listing the URL.
---
Outside diff comments:
In `@packages/w3c-credential-status/src/lib/utils.ts`:
- Around line 189-195: Update the sign-mode checks in assertObligationRecords
and assertTransferableRecords to reject tokenId whenever the property is
present, including empty, zero, false, or null values, rather than relying on
truthiness. Preserve the existing verify-mode validation and error behavior for
absent tokenId values.
---
Nitpick comments:
In `@packages/w3c-credential-status/src/lib/utils.test.ts`:
- Around line 95-111: Expand the parameterized chainId coverage in the
assertObligationRecords tests to match the existing Transferable Records matrix,
including numeric strings, fractional values, non-numeric strings, NaN, and
Infinity. Reuse the same valid and invalid cases while keeping the expected
integer-validation error assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2c5f61cf-6d73-4f5b-a3a5-6da93d88a26f
📒 Files selected for processing (8)
packages/w3c-context/README.mdpackages/w3c-context/samples/obligation-credential-subject.sample.jsonpackages/w3c-context/src/context/bill-of-exchange.jsonpackages/w3c-credential-status/src/lib/utils.test.tspackages/w3c-credential-status/src/lib/utils.tspackages/w3c-vc/src/lib/helper/index.test.tspackages/w3c-vc/src/lib/helper/index.tsscripts/copy-files.sh
|
# [2.4.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-context@2.3.0...@trustvc/w3c-context@2.4.0) (2026-07-29) ### Features * add obligation records context and related types ([#104](#104)) ([8f3e73a](8f3e73a))
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.4.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-credential-status@2.3.0...@trustvc/w3c-credential-status@2.4.0) (2026-07-29) ### Features * add obligation records context and related types ([#104](#104)) ([8f3e73a](8f3e73a))
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.4.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-vc@2.3.0...@trustvc/w3c-vc@2.4.0) (2026-07-29) ### Features * add obligation records context and related types ([#104](#104)) ([8f3e73a](8f3e73a))
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.4.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c@2.3.0...@trustvc/w3c@2.4.0) (2026-07-29) ### Features * add obligation records context and related types ([#104](#104)) ([8f3e73a](8f3e73a))
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |



Summary
What is the background of this pull request?
Changes
Issues
What are the related issues or stories?
Releases
Channels: latest
ETA: Any target release date
Summary by CodeRabbit