forked from
atscan.net/plcbundle
A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory
1package plc
2
3import "time"
4
5// PLCOperation represents a single operation from the PLC directory
6type PLCOperation struct {
7 DID string `json:"did"`
8 Operation map[string]interface{} `json:"operation"`
9 CID string `json:"cid"`
10 Nullified interface{} `json:"nullified,omitempty"`
11 CreatedAt time.Time `json:"createdAt"`
12
13 // RawJSON stores the original JSON bytes for exact reproduction
14 RawJSON []byte `json:"-"`
15}
16
17// IsNullified checks if this operation has been nullified
18func (op *PLCOperation) IsNullified() bool {
19 if op.Nullified == nil {
20 return false
21 }
22
23 switch v := op.Nullified.(type) {
24 case bool:
25 return v
26 case string:
27 return v != ""
28 default:
29 return false
30 }
31}
32
33// GetNullifyingCID returns the CID that nullified this operation
34func (op *PLCOperation) GetNullifyingCID() string {
35 if s, ok := op.Nullified.(string); ok {
36 return s
37 }
38 return ""
39}
40
41// DIDDocument represents a DID document from PLC
42type DIDDocument struct {
43 Context []string `json:"@context"`
44 ID string `json:"id"`
45 AlsoKnownAs []string `json:"alsoKnownAs"`
46 VerificationMethod []VerificationMethod `json:"verificationMethod"`
47 Service []Service `json:"service"`
48}
49
50// VerificationMethod represents a verification method in a DID document
51type VerificationMethod struct {
52 ID string `json:"id"`
53 Type string `json:"type"`
54 Controller string `json:"controller"`
55 PublicKeyMultibase string `json:"publicKeyMultibase"`
56}
57
58// Service represents a service endpoint in a DID document
59type Service struct {
60 ID string `json:"id"`
61 Type string `json:"type"`
62 ServiceEndpoint string `json:"serviceEndpoint"`
63}
64
65// ExportOptions contains options for exporting PLC operations
66type ExportOptions struct {
67 Count int // Number of operations to fetch
68 After string // ISO 8601 datetime string to start after
69}
70
71// DIDHistoryEntry represents a single operation in DID history
72type DIDHistoryEntry struct {
73 Operation PLCOperation `json:"operation"`
74 PLCBundle string `json:"plc_bundle,omitempty"`
75}
76
77// DIDHistory represents the full history of a DID
78type DIDHistory struct {
79 DID string `json:"did"`
80 Current *PLCOperation `json:"current"`
81 Operations []DIDHistoryEntry `json:"operations"`
82}
83
84// EndpointInfo contains extracted endpoint information from an operation
85type EndpointInfo struct {
86 Type string // "pds", "labeler", etc.
87 Endpoint string
88}