Skip to content

Feature/credential selection#423

Closed
rmlearney-digicatapult wants to merge 67 commits into
mainfrom
feature/credential-selection
Closed

Feature/credential selection#423
rmlearney-digicatapult wants to merge 67 commits into
mainfrom
feature/credential-selection

Conversation

@rmlearney-digicatapult

@rmlearney-digicatapult rmlearney-digicatapult commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Pull Request

Checklist

  • Have you read Digital Catapult's Code of Conduct?
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

PR Type

Please delete options that are irrelevant.

  • Feature
  • Documentation Update

Linked tickets

High level description

Updated ProofController to accept credential selection when presenting a proof rather than trusting the agent to pick the one from the top of the list

Updated the ProofController with an endpoint to retrieve the proof content

Detailed description

AI-assisted PR.

New API Capability: The POST /proofs/{proofRecordId}/accept-request endpoint now accepts a simplified proofFormats object in the body. This allows callers to specify exactly which credentialId should satisfy each attribute or predicate in a proof request

New API Capability: The GET /proofs/{proofRecordId}/credentials endpoint allows retrieval of only those credentials which match the proof request from the agent, using native methods within credo-ts, simplifying the need to get all credentials and filter

New proposalMessage endpoint: added GET /proofs/:proofRecordId/content to retrieve the formatted proof content for a specific proofRecord

Hydration Logic: Implemented logic in the ProofController to "hydrate" these simplified selection requests into the complex protocol-specific formats required by Credo-TS (e.g. anoncreds proof structures)

Validation: Added strict validation to ensure requested credentials exist and match the proof requirements, returning 400 Bad Request for malformed requests and 404 Not Found for missing credentials

Type Safety: Refactored the ProofController and associated tests to remove any casts, significantly improving type safety and maintainability

Tests: Unit test coverage for all new functionality

Documentation:
Added comprehensive documentation in explicit-credential-selection.md detailing the new workflow and payload structures

Describe alternatives you've considered

No changes, allowing the agent to just automatically choose which credentials to use for proofs from the 'top of the pile'

Operational impacte

Allowing the verifying agent to select which fields they want to be proven

Allowing the proving agent to select which credentials to use for proof, selecting from multiple credentials and composing multiple credentials to generate proofs

Additional context

- Refactor ProofController.acceptRequest to support simplified proof formats
- Add hydration logic to convert simplified formats to full Credo-TS formats
- Add validation for simplified formats (400 Bad Request)
- Add error handling for missing credentials (404 Not Found)
- Export ProofFormats type in types.ts
- Update unit tests to verify new logic and remove any casts
- Add documentation for explicit credential selection
- Update README with link to new docs
- Update maker script to support credential selection
Copilot AI review requested due to automatic review settings December 11, 2025 14:16
@rmlearney-digicatapult
rmlearney-digicatapult requested a review from a team as a code owner December 11, 2025 14:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces explicit credential selection for proof requests, allowing API clients to specify which credentials should be used when responding to proof requests rather than relying on automatic selection. The implementation adds a simplified API format that gets hydrated into the complex Credo TS proof format, reducing client-side complexity.

Key Changes

  • New API capability: POST /v1/proofs/{proofRecordId}/accept-request now accepts optional simplified proofFormats with just credentialId and revealed fields
  • Hydration logic: Controller automatically enriches simplified format with full credential metadata from Credo TS wallet
  • Script enhancement: maker-accept-proof-from-oem.ts updated to support credential selection via CLI argument

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/controllers/v1/proofs/ProofController.ts Implements three-path logic (auto-select/hydrate/pass-through) with hydration loops for attributes and predicates, plus type guard for format detection
src/controllers/types.ts Adds SimpleProofFormats interface and exports ProofFormats type, extends AcceptProofRequestOptions with new proofFormats field
tests/unit/proof.test.ts Adds single happy-path test for simplified credential selection, validates hydration output structure
scripts/maker-accept-proof-from-oem.ts Adds --credential-id CLI parameter, constructs simplified proofFormats from proof request message
docs/explicit-credential-selection.md Comprehensive new documentation explaining the feature, API usage, three-path logic, and example scenario
README.md Minor formatting fixes (code blocks, links), adds reference to new documentation, fixes typo
docker-compose-integration-tests.yml Updates comments with NODE_EXTRA_CA_CERTS setup instructions, adds environment variable to test service
package.json, package-lock.json Version bump from 0.16.13 to 0.16.14

Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread scripts/maker-respond-proof-request.ts
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread docs/explicit-credential-selection.md
Comment thread README.md Outdated
Comment thread tests/unit/proof.test.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI commented Dec 11, 2025

Copy link
Copy Markdown

@rmlearney-digicatapult I've opened a new pull request, #424, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Fix TypeScript errors in ProofController hydration logic
- Downgrade sensitive credential logging to debug level
- Add extensive unit tests for ProofController edge cases and security checks
- Redact sensitive credential data from ProofController logs
- Remove temporary /credentials endpoint
- Improve type safety in redaction logic (remove any)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.

Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread docs/explicit-credential-selection.md Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread tests/unit/proof.test.ts Outdated
Comment thread src/controllers/v1/proofs/ProofController.ts Outdated
Comment thread package.json Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: David Blane <32327139+dblane-digicatapult@users.noreply.github.com>
rmlearney-digicatapult and others added 26 commits December 18, 2025 13:58
- Refactor ProofController to use strict types and helper methods
- Update ProofController tests to cover new logic and remove 'any' types
- Add tests for proof content simplification and includeContent
- Filter out redundant proof state change events in ProofEvents
- Add tests for webhook noise reduction
- Fix 500 error in ProofController by adding null check for availableAnonCreds
- Update e2e test to filter credentials by connectionId to avoid stale data
- Update e2e test to use correct credentialRecordId from nested structure
- Configure Bob agent to never auto-accept credentials to enable manual acceptance testing
…automation

- Update `register-schema.ts` to default to `makeAuthorisation.json`.
- Update `issue-credential.ts` to auto-lookup the latest credential definition.
- Update `maker-connect-to-oem.ts` to auto-lookup the latest holder credential.
- Update `oem-accept-connection.ts` to auto-accept pending connections.
- Update `maker-propose-proof-to-oem.ts` to disable auto-accept proof, enabling manual response flow.
- Add `maker-accept-credential.ts` for credential acceptance.
- Replace `maker-accept-proof-from-oem.ts` with `maker-respond-proof-request.ts` for robust proof handling.
@rmlearney-digicatapult
rmlearney-digicatapult marked this pull request as draft January 12, 2026 11:48
@rmlearney-digicatapult

Copy link
Copy Markdown
Contributor Author

PR superseded by split PR approach

@rmlearney-digicatapult
rmlearney-digicatapult deleted the feature/credential-selection branch January 12, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants