0
0
Fork 0

Compact JSON-LD signed incoming activities (#17426)

Co-authored-by: Puck Meerburg <puck@puck.moe>
This commit is contained in:
Claire 2022-02-03 14:07:29 +01:00 committed by GitHub
parent d0d15bf49c
commit d1ecc323e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 49 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)