This guide covers the did:web method integration for TrustWeave. The did:web plugin provides W3C-compliant DID resolution from HTTPS endpoints.
Overview
The did/plugins/web module provides a complete implementation of TrustWeave’s DidMethod interface using the W3C did:web specification. This integration enables you to:
Create and resolve DIDs from HTTPS endpoints
Host DID documents at standard web locations (/.well-known/did.json)
Support domain-based and path-based did:web identifiers
valkms=InMemoryKeyManagementService()valhttpClient=OkHttpClient()valmethod=WebDidMethod.create(kms,httpClient)// Create DID for a domainvaloptions=didCreationOptions{algorithm=KeyAlgorithm.ED25519purpose(KeyPurpose.AUTHENTICATION)purpose(KeyPurpose.ASSERTION)property("domain","example.com")property("hostingUrl","https://example.com")// Optional: publish immediately}valdocument=method.createDid(options)println("Created: ${document.id}")// did:web:example.com
// Create DID for did:web:example.com:user:alicevaloptions=didCreationOptions{property("domain","example.com")property("path","user:alice")property("hostingUrl","https://example.com")}valdocument=method.createDid(options)// Resolves from: https://example.com/user/alice/.well-known/did.json
Host it at the appropriate URL path (/.well-known/did.json)
Ensure HTTPS is enabled
Set proper Content-Type: application/json
Example: Publishing to AWS S3
1
2
3
4
5
6
7
8
9
10
11
// After creating the DID documentvaldocument=method.createDid(options)// Upload to S3 or your hosting servicevals3Client=AmazonS3Client.builder().build()valjson=Json.encodeToString(documentToJsonElement(document))s3Client.putObject("my-bucket",".well-known/did.json",json)
Integration with TrustWeave
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
importcom.trustweave.TrustWeaveimportcom.trustweave.webdid.WebDidMethodimportcom.trustweave.webdid.WebDidConfigvalTrustWeave=TrustWeave.create{kms=InMemoryKeyManagementService()didMethods{+WebDidMethod.create(kms!!,OkHttpClient(),WebDidConfig.default())}}// Use did:webvaldid=TrustWeave.dids.create("web"){property("domain","example.com")}valresolved=TrustWeave.dids.resolve(did.id)
Error Handling
Common errors and solutions:
Error
Cause
Solution
HTTP 404
Document not found at URL
Ensure document is hosted at correct path
HTTP 403
Access denied
Check server permissions
Invalid DID format
DID doesn’t match did:web format
Validate DID string format
HTTPS required
Non-HTTPS URL used
Use HTTPS for all document hosting
Document ID mismatch
Resolved document ID doesn’t match DID
Verify document content
Testing
For testing without actual web hosting, the method supports in-memory storage:
1
2
3
4
5
6
7
valmethod=WebDidMethod.create(kms,OkHttpClient())// Create DID (stored in memory)valdocument=method.createDid(options)// Resolve from memory (if not published to web)valresult=method.resolveDid(document.id)