mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-20 01:04:15 +00:00
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package pds
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"atcr.io/pkg/atproto/did"
|
|
)
|
|
|
|
// Type aliases for backward compatibility - code using pds.DIDDocument etc. still works
|
|
type DIDDocument = did.DIDDocument
|
|
type VerificationMethod = did.VerificationMethod
|
|
type Service = did.Service
|
|
|
|
// GenerateDIDFromURL creates a did:web identifier from a public URL
|
|
// Delegates to shared package
|
|
var GenerateDIDFromURL = did.GenerateDIDFromURL
|
|
|
|
// GenerateDIDDocument creates a DID document for the hold's did:web identity
|
|
func (p *HoldPDS) GenerateDIDDocument(publicURL string) (*DIDDocument, error) {
|
|
pubKey, err := p.signingKey.PublicKey()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to get public key: %w", err)
|
|
}
|
|
|
|
services := did.DefaultHoldServices(publicURL)
|
|
return did.GenerateDIDDocument(publicURL, pubKey, services)
|
|
}
|
|
|
|
// MarshalDIDDocument converts a DID document to JSON using the stored public URL
|
|
func (p *HoldPDS) MarshalDIDDocument() ([]byte, error) {
|
|
doc, err := p.GenerateDIDDocument(p.PublicURL)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return did.MarshalDIDDocument(doc)
|
|
}
|