From e92d23b4e3e065fe7e0ce87b5045dd7199ff0c0c Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Wed, 4 Jan 2023 08:22:57 -0500 Subject: try to resolve publickey json --- registry/registry.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/registry/registry.go b/registry/registry.go index 20138e1..5b912b1 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -186,9 +186,23 @@ func (r *Registry) Inbox(name string, req *http.Request) error { if err != nil { return err } - var t vocab.ActivityStreamsPerson - streams.ToType(context.Background(), keyPageData) - pubKeyProp := t.GetW3IDSecurityV1PublicKey() + + var person vocab.ActivityStreamsPerson + + resolver, err := streams.NewJSONResolver(func(c context.Context, p vocab.ActivityStreamsPerson) error { + // Store the person in the enclosing scope, for later. + person = p + return nil + }, func(c context.Context, note vocab.ActivityStreamsNote) error { + // We can treat the type differently. + return nil + }) + + ctx := context.Background() + // Pass in a vocab.Type instead of map[string]interface{}. + err = resolver.Resolve(ctx, keyPageData) + + pubKeyProp := person.GetW3IDSecurityV1PublicKey() iter := pubKeyProp.At(0) pubKey := iter.Get() pemProp := pubKey.GetW3IDSecurityV1PublicKeyPem() -- cgit v1.2.3