Compact JSON-LD signed incoming activities

This commit is contained in:
Puck Meerburg
2022-01-22 13:48:27 +00:00
committed by Claire
parent 20a4b8081f
commit 63da32468c
4 changed files with 67 additions and 50 deletions

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
module JsonLdHelper
include ContextHelper
def equals_or_includes?(haystack, needle)
haystack.is_a?(Array) ? haystack.include?(needle) : haystack == needle
end
@@ -69,6 +71,12 @@ module JsonLdHelper
graph.dump(:normalize)
end
def compact(json)
compacted = JSON::LD::API.compact(json.without('signature'), full_context, documentLoader: method(:load_jsonld_context))
compacted['signature'] = json['signature']
compacted
end
def fetch_resource(uri, id, on_behalf_of = nil)
unless id
json = fetch_resource_without_id_validation(uri, on_behalf_of)