+10
-6
cmd/goat/plc.go
+10
-6
cmd/goat/plc.go
···
11
11
12
12
"github.com/bluesky-social/indigo/atproto/identity"
13
13
"github.com/bluesky-social/indigo/atproto/syntax"
14
+
"github.com/bluesky-social/indigo/atproto/crypto"
14
15
"github.com/bluesky-social/indigo/util"
15
16
16
17
"github.com/did-method-plc/go-didplc"
···
359
360
}
360
361
361
362
for _, rotationKey := range cctx.StringSlice("rotation-key") {
362
-
if !strings.HasPrefix(rotationKey, "did:key:") {
363
-
return fmt.Errorf("rotation keys must be in did:key format")
363
+
if _, err := crypto.ParsePublicDIDKey(rotationKey); err != nil {
364
+
return err
364
365
}
365
366
op.RotationKeys = append(op.RotationKeys, rotationKey)
366
367
}
367
368
368
369
handle := cctx.String("handle")
369
370
if handle != "" {
370
-
// add at:// prefix if not already present
371
-
op.AlsoKnownAs = append(op.AlsoKnownAs, "at://"+strings.TrimPrefix(handle, "at://"))
371
+
parsedHandle, err := syntax.ParseHandle(strings.TrimPrefix(handle, "at://"))
372
+
if err != nil {
373
+
return err
374
+
}
375
+
op.AlsoKnownAs = append(op.AlsoKnownAs, "at://"+string(parsedHandle))
372
376
}
373
377
374
378
atprotoKey := cctx.String("atproto-key")
375
379
if atprotoKey != "" {
376
-
if !strings.HasPrefix(atprotoKey, "did:key:") {
377
-
return fmt.Errorf("atproto key must be in did:key format")
380
+
if _, err := crypto.ParsePublicDIDKey(atprotoKey); err != nil {
381
+
return err
378
382
}
379
383
op.VerificationMethods["atproto"] = atprotoKey
380
384
}