Skip to content

Fix DID verification method ID encoding and add controller#48

Merged
bajtos merged 1 commit into
mainfrom
claude/did-fragment-encoding-0j2sm9
Jul 24, 2026
Merged

Fix DID verification method ID encoding and add controller#48
bajtos merged 1 commit into
mainfrom
claude/did-fragment-encoding-0j2sm9

Conversation

@bajtos

@bajtos bajtos commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixed the DID document generation to correctly encode verification method IDs and set the controller field.

Key Changes

  • Fixed fragment encoding: Changed doc.Fragment("#key-0") to doc.Fragment("key-0") to prevent double-encoding of the # character. The Fragment() method automatically prepends #, so passing #key-0 resulted in #%23key-0 in the serialized output.
  • Set verification method controller: Added vm.Controller = doc.ID to properly associate the verification method with the DID document.
  • Added test coverage: Created comprehensive test (TestDIDDocument) that validates:
    • DID document generation succeeds
    • Document ID matches the service DID
    • Verification method ID is correctly formatted as did:web:example.com#key-0
    • Verification method ID does not contain percent-encoded characters
    • Verification method controller is set to the document ID

Implementation Details

The fix ensures that DID documents conform to the W3C DID specification by properly formatting the verification method ID and establishing the correct controller relationship.

https://claude.ai/code/session_01YAjDX5F44mcX8ojb1ENjY

References

doc.Fragment() expects a bare fragment name and prepends the "#" itself,
so passing "#key-0" produced a double-hash fragment that the DID-URL
serializer percent-encoded as "#%23key-0" (e.g.
did:web:hilt.staging.fil.one#%23key-0). Pass "key-0" instead.

Also set the verification method's Controller to the document's DID,
which was previously left unset and serialized as "controller": null.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YAjDX5F44mcX8ojb1ENjYt
Copilot AI review requested due to automatic review settings July 23, 2026 17:45

Copilot AI 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.

Pull request overview

This PR fixes DID document generation in identity to ensure verification method IDs serialize correctly (avoiding a double-encoded #) and to correctly set the verification method controller to the document DID.

Changes:

  • Fix verification method fragment handling by passing a bare fragment name to doc.Fragment(...) to avoid # being percent-encoded.
  • Set vm.Controller = doc.ID so the verification method is properly associated with the DID document.
  • Add a test validating DID document ID, verification method ID formatting, lack of %23, and controller correctness.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
identity/identity.go Corrects fragment handling for verification method IDs and sets verification method controller to the document DID.
identity/identity_test.go Adds coverage to validate DID document JSON output for correct id, verificationMethod[].id, and verificationMethod[].controller.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bajtos
bajtos requested review from alanshaw and frrist July 23, 2026 18:29
@bajtos
bajtos merged commit 7fc3b2c into main Jul 24, 2026
8 checks passed
bajtos added a commit to fil-forge/hilt that referenced this pull request Jul 24, 2026
## Summary

Bumps `github.com/fil-forge/libforge` from
`v0.0.0-20260713100115-a3aa293b990c` (2026-07-13) to
`v0.0.0-20260724113901-7fc3b2cec1ef` (2026-07-24, latest commit on the
default branch).

Performed via:

```
go get github.com/fil-forge/libforge@<latest-commit>
go mod tidy
```

Only `go.mod` and `go.sum` change — no other dependency versions were
affected.

## Changelog

libforge commits brought in, from `a3aa293` (the previously-pinned "fix:
make bucket optional") up to the new pin:

- **Fix DID verification method ID encoding and add controller**
([#48](fil-forge/libforge#48), `7fc3b2c` /
`f06be16`) — `doc.Fragment()` prepends `#` itself, so passing `"#key-0"`
double-encoded to `#%23key-0` in serialized DID documents (e.g.
`did:web:hilt.staging.fil.one#%23key-0`); now passes `"key-0"`. Also
sets the verification method's `Controller` to the document DID, which
previously serialized as `null`.
- **Add `/ucan/revoke` command**
([#47](fil-forge/libforge#47), `aba2bd2`) — new
bound command for UCAN revocation.
- **Add space to `/blob/remove`, `/blob/abort`, and `/blob/reject`**
(`aac837a`) — `/blob/abort` now carries a required `Cause` (the
`/space/blob/add` task link); adds `/blob/reject` (upload service →
storage node) so a parked blob has two mutually exclusive exits
(`/blob/accept` to commit, `/blob/reject` to unwind).

## Verification

The standard loop from `AGENTS.md` passes with the new version selected:

- `go build ./...` — ok
- `go vet ./...` — ok
- `go test ./...` — all packages pass (memory backends;
testcontainer-backed tests skip without Docker, as documented)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

5 participants