Skip to content

About

Quarkus extension: did:plc and did:web resolution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

quarkus-did

Resolve DID documents from Quarkus: did:plc, did:web and did:key built in, more through a DidMethod SPI. Resolution only: what a document means (AT Protocol handles, PDS endpoints, keys for a given purpose) is the caller's business. Every fetch goes through quarkus-safe-fetch.

Minimum supported Quarkus: 3.40 (LTS). Status: experimental, version 0.1.

<dependency>
  <groupId>org.sitenetsoft.quarkus</groupId>
  <artifactId>quarkus-did</artifactId>
  <version>0.1.0-SNAPSHOT</version>
</dependency>

Usage

@Inject DidResolver resolver;               // blocking; never on the event loop
@Inject ReactiveDidResolver reactive;       // Mutiny

DidDocument doc = resolver.resolve("did:plc:ewvi7nxzyoun6zhxrhs64oiz");
String key = doc.verificationMethod("#atproto").orElseThrow().publicKeyMultibase();
URI pds = doc.service("#atproto_pds").flatMap(Service::endpointUri).orElseThrow();

verificationMethod(..) and service(..) accept #x, x or <did>#x and match entries stored with relative or absolute ids. Properties the record does not type (@context, assertionMethod, …) are kept in extra() and written back when the document is serialised.

The returned document's id always equals the requested DID. Failures are DidException subclasses:

Exception When
DidNotFound did:plc 404; did:web 404 or 410
DidDeactivated did:plc 410 (tombstone)
InvalidDidDocument unparseable, larger than max-document-size, or id is another DID
DidResolutionFailed malformed DID, method not enabled, network failure, other statuses

Methods

  • did:plc: GET {quarkus.did.plc.url}/{did}.
  • did:web: did:web:example.com → https://example.com/.well-known/did.json; did:web:example.com:user:alice → https://example.com/user/alice/did.json; a port is percent-encoded (did:web:example.com%3A8443). Test-only behaviour: when quarkus.safe-fetch.https-only=false the scheme is http, so tests can point a did:web DID at a loopback server (did:web:127.0.0.1%3A<port>). Leave https-only on in production.
  • did:key: built locally from the multikey (one Multikey verification method <did>#<multibase>), no network.

Add a method by declaring a CDI bean that implements DidMethod (method() returns the name, resolve(did) a Uni<DidDocument>). Application methods are always enabled and win over a built-in of the same name. The resolver checks DID syntax, the document id and caching for you.

Configuration

Property Default Purpose
quarkus.did.plc.url https://plc.directory PLC directory base URL
quarkus.did.cache-ttl 5m How long resolved documents are cached; 0 disables (keep under 10 minutes for AT Protocol OAuth)
quarkus.did.methods plc,web,key Built-in methods to enable
quarkus.did.max-document-size 256K Larger documents are rejected

Fetches also obey quarkus.safe-fetch.* (timeout, https-only, private addresses). In tests against loopback servers set quarkus.safe-fetch.https-only=false and quarkus.safe-fetch.allow-private-addresses=true.

Dev UI

The card has a resolver box: enter a DID and see its document or the resolution error, plus the enabled methods.

Building

Depends on multikey-java and quarkus-safe-fetch (install them first). Then JAVA_HOME=/path/to/jdk21 mvn -T 8 install.

About

Quarkus extension: did:plc and did:web resolution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages