tangled
alpha
login
or
join now
atscan.net
/
plcbundle-go
1
fork
atom
[DEPRECATED] Go implementation of plcbundle
1
fork
atom
overview
issues
pulls
pipelines
did resolver optimalizations
tree.fail
4 months ago
645a6779
fe3bd8b2
+27
-16
2 changed files
expand all
collapse all
unified
split
bundle
did_index.go
plc
resolver.go
+1
-1
bundle/did_index.go
···
97
97
shardDir: shardDir,
98
98
configPath: configPath,
99
99
shardCache: make(map[uint8]*mmapShard),
100
100
-
maxCache: 10, // Keep 20 hot shards in memory (~120 MB)
100
100
+
maxCache: 25, // Keep 20 hot shards in memory (~120 MB)
101
101
evictionThreshold: 25,
102
102
config: config,
103
103
logger: logger,
+26
-15
plc/resolver.go
···
76
76
77
77
// Initialize state on first operation
78
78
if state == nil {
79
79
-
state = &DIDState{DID: did}
79
79
+
state = &DIDState{
80
80
+
DID: did,
81
81
+
RotationKeys: []string{},
82
82
+
VerificationMethods: make(map[string]string),
83
83
+
AlsoKnownAs: []string{},
84
84
+
Services: make(map[string]ServiceDefinition),
85
85
+
}
80
86
}
81
87
82
88
// Apply operation to state
···
132
138
133
139
// Handle legacy handle format
134
140
if handle, ok := opData["handle"].(string); ok {
141
141
+
// Only set if alsoKnownAs is empty
135
142
if len(state.AlsoKnownAs) == 0 {
136
143
state.AlsoKnownAs = []string{"at://" + handle}
137
144
}
···
166
173
167
174
// StateToDIDDocument converts internal PLC state to W3C DID document format
168
175
func StateToDIDDocument(state *DIDState) *DIDDocument {
169
169
-
// Detect key types to determine correct @context
170
170
-
contexts := []string{"https://www.w3.org/ns/did/v1"}
176
176
+
// Base contexts - ALWAYS include multikey (matches PLC directory behavior)
177
177
+
contexts := []string{
178
178
+
"https://www.w3.org/ns/did/v1",
179
179
+
"https://w3id.org/security/multikey/v1", // ← Always include this
180
180
+
}
171
181
172
172
-
hasMultikey := false
173
182
hasSecp256k1 := false
174
183
hasP256 := false
175
184
176
176
-
// Check verification method key types
185
185
+
// Check verification method key types for additional contexts
177
186
for _, didKey := range state.VerificationMethods {
178
187
keyType := detectKeyType(didKey)
179
188
switch keyType {
···
181
190
hasSecp256k1 = true
182
191
case "p256":
183
192
hasP256 = true
184
184
-
default:
185
185
-
hasMultikey = true
186
193
}
187
194
}
188
195
189
189
-
// Add appropriate context URLs
190
190
-
if hasMultikey || hasSecp256k1 || hasP256 {
191
191
-
contexts = append(contexts, "https://w3id.org/security/multikey/v1")
192
192
-
}
196
196
+
// Add suite-specific contexts only if those key types are present
193
197
if hasSecp256k1 {
194
198
contexts = append(contexts, "https://w3id.org/security/suites/secp256k1-2019/v1")
195
199
}
···
198
202
}
199
203
200
204
doc := &DIDDocument{
201
201
-
Context: contexts,
202
202
-
ID: state.DID,
203
203
-
AlsoKnownAs: state.AlsoKnownAs,
205
205
+
Context: contexts,
206
206
+
ID: state.DID,
207
207
+
AlsoKnownAs: []string{}, // ← Empty slice
208
208
+
VerificationMethod: []VerificationMethod{}, // ← Empty slice
209
209
+
Service: []Service{}, // ← Empty slice
210
210
+
}
211
211
+
212
212
+
// Copy alsoKnownAs if present
213
213
+
if len(state.AlsoKnownAs) > 0 {
214
214
+
doc.AlsoKnownAs = state.AlsoKnownAs
204
215
}
205
216
206
217
// Convert services
···
212
223
})
213
224
}
214
225
215
215
-
// Keep verification methods with full DID (they're correct):
226
226
+
// Keep verification methods with full DID
216
227
for id, didKey := range state.VerificationMethods {
217
228
doc.VerificationMethod = append(doc.VerificationMethod, VerificationMethod{
218
229
ID: state.DID + "#" + id,