Skip to content

fix(did): add did:web resolution to document endpoint#227

Merged
AbirAbbas merged 2 commits intomainfrom
fix/did-document-endpoint-web-resolution
Mar 5, 2026
Merged

fix(did): add did:web resolution to document endpoint#227
AbirAbbas merged 2 commits intomainfrom
fix/did-document-endpoint-web-resolution

Conversation

@AbirAbbas
Copy link
Contributor

Summary

  • The /api/v1/did/document/:did endpoint only resolved did:key identities via the in-memory registry, returning "DID not found" for valid did:web identifiers
  • Adds did:web resolution (via didWebService) before falling back to did:key, matching the pattern already used by the /api/v1/did/resolve/:did handler and the server's serveDIDDocument method
  • Handles deactivated/revoked DIDs with proper 410 Gone response

Test plan

  • Existing TestGetDIDDocumentHandler passes (did:key path unchanged)
  • Manual: curl http://localhost:8080/api/v1/did/document/did:web:localhost%3A8080:agents:<agent-id> returns W3C DID Document
  • Manual: Verify revoked did:web returns 410 Gone

🤖 Generated with Claude Code

The GetDIDDocument handler only resolved did:key identities via the
in-memory registry. did:web lookups returned "DID not found" even when
the agent had a valid did:web document stored in the database.

Add did:web resolution (via didWebService) before falling back to
did:key, matching the pattern already used by the ResolveDID handler
and the server's serveDIDDocument method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AbirAbbas AbirAbbas requested a review from a team as a code owner March 5, 2026 15:04
Gin URL-decodes path parameters, turning did:web:localhost%3A8080:agents:foo
into did:web:localhost:8080:agents:foo. The database stores the canonical
form with %3A, so lookups failed with "DID not found".

Add normalizeDIDWeb() helper that detects decoded port separators and
re-encodes them. Applied to both ResolveDID and GetDIDDocument handlers.

Manually verified against running control plane:
- /api/v1/did/document/did:web:... → 200 with W3C DID Document
- /api/v1/did/resolve/did:web:... → 200 with DID resolution result
- did:key paths unchanged (no regression)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AbirAbbas AbirAbbas merged commit cdf4e8b into main Mar 5, 2026
17 checks passed
@AbirAbbas AbirAbbas deleted the fix/did-document-endpoint-web-resolution branch March 5, 2026 16:04
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.

1 participant