From b74190b22474986c20149b3a4a527a684f4ee3ce Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Tue, 3 Jan 2023 21:10:38 -0500 Subject: render publickeypem in actor endpoints --- views/actor.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'views') diff --git a/views/actor.go b/views/actor.go index a91044a..48aaa0b 100644 --- a/views/actor.go +++ b/views/actor.go @@ -7,7 +7,7 @@ import ( "github.com/go-fed/activity/streams" ) -func RenderActor(name, domain string) (map[string]interface{}, error) { +func RenderActor(name, domain, pem string) (map[string]interface{}, error) { inbox, err := urls.UrlInbox(name, domain) if err != nil { return nil, err @@ -29,6 +29,11 @@ func RenderActor(name, domain string) (map[string]interface{}, error) { return nil, err } + actorUrlKey, err := urls.UrlProfileKey(name, domain) + if err != nil { + return nil, err + } + followingUrl, err := urls.UrlFollowing(name, domain) if err != nil { return nil, err @@ -70,5 +75,23 @@ func RenderActor(name, domain string) (map[string]interface{}, error) { followingProp.SetIRI(followingUrl) p.SetActivityStreamsFollowing(followingProp) + pemProp := streams.NewW3IDSecurityV1PublicKeyPemProperty() + pemProp.Set(pem) + + ownerProp := streams.NewW3IDSecurityV1OwnerProperty() + ownerProp.Set(actorUrl) + + pubkeyId := streams.NewJSONLDIdProperty() + pubkeyId.Set(actorUrlKey) + + pubKey := streams.NewW3IDSecurityV1PublicKey() + pubKey.SetW3IDSecurityV1PublicKeyPem(pemProp) + pubKey.SetW3IDSecurityV1Owner(ownerProp) + pubKey.SetJSONLDId(pubkeyId) + + pubKeyProp := streams.NewW3IDSecurityV1PublicKeyProperty() + pubKeyProp.AppendW3IDSecurityV1PublicKey(pubKey) + p.SetW3IDSecurityV1PublicKey(pubKeyProp) + return streams.Serialize(p) } -- cgit v1.2.3