Skip to content

feat: add obligation records context and related types - #104

Merged
rongquan1 merged 10 commits into
mainfrom
feature/eboe-v2
Jul 29, 2026
Merged

feat: add obligation records context and related types#104
rongquan1 merged 10 commits into
mainfrom
feature/eboe-v2

Conversation

@manishdex25

@manishdex25 manishdex25 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
  • 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.

Summary

What is the background of this pull request?

Changes

  • What are the changes made in this pull request?
  • Change this and that, etc...

Issues

What are the related issues or stories?

Releases

Channels: latest
ETA: Any target release date

Summary by CodeRabbit

  • New Features
    • Added JSON-LD contexts for bills of exchange and obligation records.
    • Added obligation-records credential status support, including obligation registry details.
    • Introduced stricter chainId validation (integer or numeric-string) for these credential statuses.
  • Documentation
    • Updated context catalog with new URLs and added sample resources.
  • Bug Fixes
    • Improved credential-status validation/routing when obligation registry details are present.
  • Tests & Chores
    • Expanded validation test coverage for chainId edge cases and updated context asset staging.

- 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.
@manishdex25
manishdex25 requested a review from rongquan1 July 21, 2026 18:19
@coderabbitai

coderabbitai Bot commented Jul 21, 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: 4133f5d4-e6ba-4be9-998a-d3e03d577195

📥 Commits

Reviewing files that changed from the base of the PR and between bae9c6c and 615d557.

📒 Files selected for processing (3)
  • packages/w3c-context/README.md
  • packages/w3c-credential-status/src/lib/utils.test.ts
  • packages/w3c-vc/src/lib/helper/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/w3c-vc/src/lib/helper/index.ts
  • packages/w3c-credential-status/src/lib/utils.test.ts
  • packages/w3c-context/README.md

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Obligation Records support

Layer / File(s) Summary
Context definition and loader registration
packages/w3c-context/src/context/*, packages/w3c-context/src/lib/index.ts, packages/w3c-context/samples/*, packages/w3c-context/README.md, scripts/copy-files.sh
Protected Obligation Records and bill-of-exchange contexts are defined, registered for loading, documented, sampled, and added to the staged context files.
Credential status typing and validation
packages/w3c-credential-status/src/lib/types.ts, packages/w3c-credential-status/src/lib/utils.ts, packages/w3c-credential-status/src/lib/utils.test.ts, packages/w3c-vc/src/lib/helper/index.ts, packages/w3c-vc/src/lib/helper/index.test.ts
Obligation Records status typing, integer chainId validation, status-specific validation, dispatch logic, and tests are added.

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
Loading

Suggested labels: released on @alpha``

Suggested reviewers: rongquan1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template headings are present, but the required Summary, Changes, Issues, and Releases details are mostly missing. Fill in each template section with concrete background, detailed changes, related issues, and release channel/ETA information.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding obligation records support and related types/contexts.
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 feature/eboe-v2

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 064b5dd and 8ff7401.

📒 Files selected for processing (5)
  • packages/w3c-context/src/context/obligation-records-context.json
  • packages/w3c-context/src/lib/index.ts
  • packages/w3c-credential-status/src/lib/types.ts
  • packages/w3c-credential-status/src/lib/utils.ts
  • packages/w3c-vc/src/lib/helper/index.ts

Comment thread packages/w3c-credential-status/src/lib/utils.ts Outdated
Comment thread packages/w3c-vc/src/lib/helper/index.ts Outdated
@manishdex25
manishdex25 changed the base branch from beta to main July 29, 2026 04:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Reject any present tokenId in sign mode.

assertObligationRecords(..., 'sign') currently allows tokenId: '', 0, false, or null because the check is truthiness-based. Check property presence instead, and apply the same correction to assertTransferableRecords for 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 win

Cover the full chainId matrix for obligation records.

The obligation test does not verify numeric strings, fractional values, non-numeric strings, NaN, or Infinity, unlike the Transferable Records tests. Reuse the same parameterized cases so regressions in assertObligationRecords are 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff7401 and bae9c6c.

📒 Files selected for processing (8)
  • packages/w3c-context/README.md
  • packages/w3c-context/samples/obligation-credential-subject.sample.json
  • packages/w3c-context/src/context/bill-of-exchange.json
  • packages/w3c-credential-status/src/lib/utils.test.ts
  • packages/w3c-credential-status/src/lib/utils.ts
  • packages/w3c-vc/src/lib/helper/index.test.ts
  • packages/w3c-vc/src/lib/helper/index.ts
  • scripts/copy-files.sh

Comment thread packages/w3c-context/README.md
@sonarqubecloud

Copy link
Copy Markdown

@rongquan1
rongquan1 merged commit 8f3e73a into main Jul 29, 2026
19 checks passed
@rongquan1
rongquan1 deleted the feature/eboe-v2 branch July 29, 2026 06:12
nghaninn pushed a commit that referenced this pull request Jul 29, 2026
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Jul 29, 2026
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Jul 29, 2026
# [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))
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Jul 29, 2026
# [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))
@tradetrustimda

Copy link
Copy Markdown

🎉 This PR is included in version 2.4.0 🎉

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