Skip to content

fead(did web): Use Credo's core DID document construction methods - #593

Open
rmlearney-digicatapult wants to merge 7 commits into
mainfrom
feat/diddoc-core-helpers
Open

rmlearney-digicatapult wants to merge 7 commits into
mainfrom
feat/diddoc-core-helpers

Conversation

@rmlearney-digicatapult

@rmlearney-digicatapult rmlearney-digicatapult commented Sep 18, 2026

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

Linked tickets

High level description

Replace hand-written document construction and validation with native Credo helpers

Detailed description

Credo exports multiple helper methods and validators for DID Document construction.

Swapped existing validation, key construction, document assembly using JsonTransformer and TypedArrayEncoder etc. for these methods.

Added simple did:web input parsing regression test.

Describe alternatives you've considered

Operational impact

Additional context

Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
Signed-off-by: rmlearney-digicatapult <robert.learney@digicatapult.org.uk>
@rmlearney-digicatapult
rmlearney-digicatapult requested a review from a team as a code owner September 18, 2026 13:20
Copilot AI balanced review requested due to automatic review settings September 18, 2026 13:20
@rmlearney-digicatapult rmlearney-digicatapult added the v:patch Change requires a semver patch version change label Sep 18, 2026

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.

🟡 Changes recommended

The new builder path omits document validation, allowing malformed service endpoints.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Replaces custom DID:web document construction with Credo-native parsing, key, service, and builder APIs.

Changes:

  • Builds DID documents using Credo helpers.
  • Adds DID method validation and regression coverage.
File summaries
File Description
tests/unit/didWebGenerator.test.ts Tests rejection of non-web DIDs.
src/utils/didWebGenerator.ts Refactors DID:web generation to Credo APIs.
Review details

Suppressed comments (1)

tests/unit/didWebGenerator.test.ts:77

  • The added test passes a syntactically valid did:key, so it only covers the wrong-method branch. Add a malformed input case to protect the new parseDid error wrapping and its Invalid DID identifier message.
      await didWebDocGenerator.generateDidWebDocument('did:key:z6Mkexample', 'http://localhost%3A5002')
  • Files reviewed: 3/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/didWebGenerator.ts

try {
await didWebDocGenerator.generateDidWebDocument('did:key:z6Mkexample', 'http://localhost%3A5002')
} catch (error) {

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.

[MINOR] There's no test for the new parsedDid.did !== didId guard — e.g. a did:web identifier with an extra path or query segment. Worth adding alongside the two new tests here since it's the other half of the validation this PR introduces.

Comment thread src/utils/didWebGenerator.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v:patch Change requires a semver patch version change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants