Browse Source

Preload common JSON-LD contexts (#9412)

Fixes #9411
ThibG 1 week ago
parent
commit
f13d08314e
4 changed files with 59 additions and 0 deletions
  1. 1
    0
      Gemfile
  2. 5
    0
      Gemfile.lock
  3. 3
    0
      config/initializers/json_ld.rb
  4. 50
    0
      lib/json_ld/security.rb

+ 1
- 0
Gemfile View File

@@ -90,6 +90,7 @@ gem 'webpacker', '~> 3.5'
90 90
 gem 'webpush'
91 91
 
92 92
 gem 'json-ld', '~> 2.2'
93
+gem 'json-ld-preloaded', '~> 2.2'
93 94
 gem 'rdf-normalize', '~> 0.3'
94 95
 
95 96
 group :development, :test do

+ 5
- 0
Gemfile.lock View File

@@ -291,6 +291,10 @@ GEM
291 291
     json-ld (2.2.1)
292 292
       multi_json (~> 1.12)
293 293
       rdf (>= 2.2.8, < 4.0)
294
+    json-ld-preloaded (2.2.3)
295
+      json-ld (>= 2.2, < 4.0)
296
+      multi_json (~> 1.12)
297
+      rdf (>= 2.2, < 4.0)
294 298
     jsonapi-renderer (0.2.0)
295 299
     jwt (2.1.0)
296 300
     kaminari (1.1.1)
@@ -696,6 +700,7 @@ DEPENDENCIES
696 700
   idn-ruby
697 701
   iso-639
698 702
   json-ld (~> 2.2)
703
+  json-ld-preloaded (~> 2.2)
699 704
   kaminari (~> 1.1)
700 705
   letter_opener (~> 1.4)
701 706
   letter_opener_web (~> 1.3)

+ 3
- 0
config/initializers/json_ld.rb View File

@@ -0,0 +1,3 @@
1
+# frozen_string_literal: true
2
+
3
+require_relative '../../lib/json_ld/security'

+ 50
- 0
lib/json_ld/security.rb View File

@@ -0,0 +1,50 @@
1
+# -*- encoding: utf-8 -*-
2
+# frozen_string_literal: true
3
+# This file generated automatically from https://w3id.org/security/v1
4
+require 'json/ld'
5
+class JSON::LD::Context
6
+  add_preloaded("https://w3id.org/security/v1") do
7
+    new(processingMode: "json-ld-1.0", term_definitions: {
8
+      "CryptographicKey" => TermDefinition.new("CryptographicKey", id: "https://w3id.org/security#Key", simple: true),
9
+      "EcdsaKoblitzSignature2016" => TermDefinition.new("EcdsaKoblitzSignature2016", id: "https://w3id.org/security#EcdsaKoblitzSignature2016", simple: true),
10
+      "EncryptedMessage" => TermDefinition.new("EncryptedMessage", id: "https://w3id.org/security#EncryptedMessage", simple: true),
11
+      "GraphSignature2012" => TermDefinition.new("GraphSignature2012", id: "https://w3id.org/security#GraphSignature2012", simple: true),
12
+      "LinkedDataSignature2015" => TermDefinition.new("LinkedDataSignature2015", id: "https://w3id.org/security#LinkedDataSignature2015", simple: true),
13
+      "LinkedDataSignature2016" => TermDefinition.new("LinkedDataSignature2016", id: "https://w3id.org/security#LinkedDataSignature2016", simple: true),
14
+      "authenticationTag" => TermDefinition.new("authenticationTag", id: "https://w3id.org/security#authenticationTag", simple: true),
15
+      "canonicalizationAlgorithm" => TermDefinition.new("canonicalizationAlgorithm", id: "https://w3id.org/security#canonicalizationAlgorithm", simple: true),
16
+      "cipherAlgorithm" => TermDefinition.new("cipherAlgorithm", id: "https://w3id.org/security#cipherAlgorithm", simple: true),
17
+      "cipherData" => TermDefinition.new("cipherData", id: "https://w3id.org/security#cipherData", simple: true),
18
+      "cipherKey" => TermDefinition.new("cipherKey", id: "https://w3id.org/security#cipherKey", simple: true),
19
+      "created" => TermDefinition.new("created", id: "http://purl.org/dc/terms/created", type_mapping: "http://www.w3.org/2001/XMLSchema#dateTime"),
20
+      "creator" => TermDefinition.new("creator", id: "http://purl.org/dc/terms/creator", type_mapping: "@id"),
21
+      "dc" => TermDefinition.new("dc", id: "http://purl.org/dc/terms/", simple: true, prefix: true),
22
+      "digestAlgorithm" => TermDefinition.new("digestAlgorithm", id: "https://w3id.org/security#digestAlgorithm", simple: true),
23
+      "digestValue" => TermDefinition.new("digestValue", id: "https://w3id.org/security#digestValue", simple: true),
24
+      "domain" => TermDefinition.new("domain", id: "https://w3id.org/security#domain", simple: true),
25
+      "encryptionKey" => TermDefinition.new("encryptionKey", id: "https://w3id.org/security#encryptionKey", simple: true),
26
+      "expiration" => TermDefinition.new("expiration", id: "https://w3id.org/security#expiration", type_mapping: "http://www.w3.org/2001/XMLSchema#dateTime"),
27
+      "expires" => TermDefinition.new("expires", id: "https://w3id.org/security#expiration", type_mapping: "http://www.w3.org/2001/XMLSchema#dateTime"),
28
+      "id" => TermDefinition.new("id", id: "@id", simple: true),
29
+      "initializationVector" => TermDefinition.new("initializationVector", id: "https://w3id.org/security#initializationVector", simple: true),
30
+      "iterationCount" => TermDefinition.new("iterationCount", id: "https://w3id.org/security#iterationCount", simple: true),
31
+      "nonce" => TermDefinition.new("nonce", id: "https://w3id.org/security#nonce", simple: true),
32
+      "normalizationAlgorithm" => TermDefinition.new("normalizationAlgorithm", id: "https://w3id.org/security#normalizationAlgorithm", simple: true),
33
+      "owner" => TermDefinition.new("owner", id: "https://w3id.org/security#owner", type_mapping: "@id"),
34
+      "password" => TermDefinition.new("password", id: "https://w3id.org/security#password", simple: true),
35
+      "privateKey" => TermDefinition.new("privateKey", id: "https://w3id.org/security#privateKey", type_mapping: "@id"),
36
+      "privateKeyPem" => TermDefinition.new("privateKeyPem", id: "https://w3id.org/security#privateKeyPem", simple: true),
37
+      "publicKey" => TermDefinition.new("publicKey", id: "https://w3id.org/security#publicKey", type_mapping: "@id"),
38
+      "publicKeyPem" => TermDefinition.new("publicKeyPem", id: "https://w3id.org/security#publicKeyPem", simple: true),
39
+      "publicKeyService" => TermDefinition.new("publicKeyService", id: "https://w3id.org/security#publicKeyService", type_mapping: "@id"),
40
+      "revoked" => TermDefinition.new("revoked", id: "https://w3id.org/security#revoked", type_mapping: "http://www.w3.org/2001/XMLSchema#dateTime"),
41
+      "salt" => TermDefinition.new("salt", id: "https://w3id.org/security#salt", simple: true),
42
+      "sec" => TermDefinition.new("sec", id: "https://w3id.org/security#", simple: true, prefix: true),
43
+      "signature" => TermDefinition.new("signature", id: "https://w3id.org/security#signature", simple: true),
44
+      "signatureAlgorithm" => TermDefinition.new("signatureAlgorithm", id: "https://w3id.org/security#signingAlgorithm", simple: true),
45
+      "signatureValue" => TermDefinition.new("signatureValue", id: "https://w3id.org/security#signatureValue", simple: true),
46
+      "type" => TermDefinition.new("type", id: "@type", simple: true),
47
+      "xsd" => TermDefinition.new("xsd", id: "http://www.w3.org/2001/XMLSchema#", simple: true, prefix: true)
48
+    })
49
+  end
50
+end