Skip to content

Commit

Permalink
feat(v3.1): introduce 3.1 concern
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoustachiste committed Jun 16, 2022
1 parent a9c2b85 commit 748ee8a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cert_schema/context_urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"BLOCKCERTS_ORG_V2_1_CONTEXT": "https://www.blockcerts.org/schema/2.1/context.json",
"BLOCKCERTS_V3_CONTEXT": "https://w3id.org/blockcerts/schema/3.0/context.json",
"BLOCKCERTS_V3_CANONICAL_CONTEXT": "https://w3id.org/blockcerts/v3",
"BLOCKCERTS_ORG_V3_CONTEXT": "https://www.blockcerts.org/schema/3.0/context.json"
"BLOCKCERTS_ORG_V3_CONTEXT": "https://www.blockcerts.org/schema/3.0/context.json",
"BLOCKCERTS_V3_1_CONTEXT": "https://w3id.org/blockcerts/schema/3.1/context.json",
"BLOCKCERTS_V3_1_CANONICAL_CONTEXT": "https://w3id.org/blockcerts/v3.1",
"BLOCKCERTS_ORG_V3_1_CONTEXT": "https://www.blockcerts.org/schema/3.1/context.json"
}
16 changes: 16 additions & 0 deletions cert_schema/context_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ def v3_all(self):
self.v3_blockcerts_org()
]

def v3_1(self):
return self.CONTEXT_URLS['BLOCKCERTS_V3_1_CONTEXT']

def v3_1_canonical(self):
return self.CONTEXT_URLS['BLOCKCERTS_V3_1_CANONICAL_CONTEXT']

def v3_1_blockcerts_org(self):
return self.CONTEXT_URLS['BLOCKCERTS_ORG_V3_1_CONTEXT']

def v3_all(self):
return [
self.v3(),
self.v3_canonical(),
self.v3_blockcerts_org()
]

def open_badge(self):
return self.CONTEXT_URLS['OPEN_BADGES_V2_CONTEXT']

Expand Down
13 changes: 10 additions & 3 deletions cert_schema/jsonld_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@
JSON_LD_CONTEXT_V3_0_BETA = os.path.join(BASE_DIR, '3.0-beta/context.json')

JSON_LD_CONTEXT_V3_0 = os.path.join(BASE_DIR, '3.0/context.json')
MERKLE_PROOF_2019_LD_CONTEXT = os.path.join(BASE_DIR, '3.0/merkleProof2019Context.json')
CHAINED_PROOF_2021_LD_CONTEXT = os.path.join(BASE_DIR, '3.0/chainedProof2021Context.json')
JSON_LD_CONTEXT_V3_1 = os.path.join(BASE_DIR, '3.1/context.json')
MERKLE_PROOF_2019_LD_CONTEXT = os.path.join(BASE_DIR, '3.1/merkleProof2019Context.json')
CHAINED_PROOF_2021_LD_CONTEXT = os.path.join(BASE_DIR, '3.1/chainedProof2021Context.json')

VERIFIABLE_CREDENTIAL_JSON_LD_CONTEXT_V1 = os.path.join(BASE_DIR, '3.0/credential.json')
ED25519_JSON_LD_CONTEXT_V1 = os.path.join(BASE_DIR, '3.0/ed25519Context.json')
ED25519_JSON_LD_CONTEXT_V1 = os.path.join(BASE_DIR, '3.1/ed25519Context.json')

PRELOADED_CONTEXTS = {}

Expand Down Expand Up @@ -133,6 +134,12 @@
PRELOADED_CONTEXTS[ContextUrlsInstance.v3_canonical()] = bc_context
PRELOADED_CONTEXTS[ContextUrlsInstance.v3_blockcerts_org()] = bc_context

with open(JSON_LD_CONTEXT_V3_1) as data_file:
bc_context = json.load(data_file)
PRELOADED_CONTEXTS[ContextUrlsInstance.v3_1()] = bc_context
PRELOADED_CONTEXTS[ContextUrlsInstance.v3_1_canonical()] = bc_context
PRELOADED_CONTEXTS[ContextUrlsInstance.v3_1_blockcerts_org()] = bc_context

def to_loader_response(data, url):
return {
'contextUrl': None,
Expand Down

0 comments on commit 748ee8a

Please sign in to comment.