From 3fc36d8ca412135a0664ac39b78003868ba54850 Mon Sep 17 00:00:00 2001 From: "Charles E. Lehner" Date: Thu, 12 May 2022 12:23:27 -0400 Subject: [PATCH] Add CACAO-ZCAP context --- contexts/cacao-zcap-v1.jsonld | 29 +++++++++++++++++++++++++++++ contexts/src/lib.rs | 2 ++ contexts/update.sh | 1 + src/jsonld.rs | 8 ++++++++ 4 files changed, 40 insertions(+) create mode 100644 contexts/cacao-zcap-v1.jsonld diff --git a/contexts/cacao-zcap-v1.jsonld b/contexts/cacao-zcap-v1.jsonld new file mode 100644 index 000000000..69e57dabf --- /dev/null +++ b/contexts/cacao-zcap-v1.jsonld @@ -0,0 +1,29 @@ +{ + "@context": { + "@protected": true, + "validFrom": { + "@id": "https://www.w3.org/2018/credentials#validFrom", + "@type": "http://www.w3.org/2001/XMLSchema#dateTime" + }, + "CacaoZcap2022": { + "@id": "https://demo.didkit.dev/2022/cacao-zcap/#CacaoZcap2022", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type", + "cacaoPayloadType": "https://demo.didkit.dev/2022/cacao-zcap/#cacaoPayloadType", + "cacaoZcapSubstatement": "https://demo.didkit.dev/2022/cacao-zcap/#cacaoZcapSubstatement", + "cacaoRequestId": "https://demo.didkit.dev/2022/cacao-zcap/#cacaoRequestId" + } + }, + "CacaoZcapProof2022": { + "@id": "https://demo.didkit.dev/2022/cacao-zcap/#CacaoZcapProof2022", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type", + "cacaoSignatureType": "https://demo.didkit.dev/2022/cacao-zcap/#cacaoSignatureType" + } + } + } +} diff --git a/contexts/src/lib.rs b/contexts/src/lib.rs index 37d2a7325..8e39ad503 100644 --- a/contexts/src/lib.rs +++ b/contexts/src/lib.rs @@ -55,6 +55,8 @@ pub const VDL_V1: &str = include_str!("../w3id-vdl-v1.jsonld"); pub const WALLET_V1: &str = include_str!("../w3id-wallet-v1.jsonld"); /// pub const ZCAP_V1: &str = include_str!("../w3id-zcap-v1.jsonld"); +/// +pub const CACAO_ZCAP_V1: &str = include_str!("../cacao-zcap-v1.jsonld"); pub const TZ_V2: &str = include_str!("../tz-2021-v2.jsonld"); pub const TZVM_V1: &str = include_str!("../tzvm-2021-v1.jsonld"); diff --git a/contexts/update.sh b/contexts/update.sh index 4ae529428..e13882f21 100755 --- a/contexts/update.sh +++ b/contexts/update.sh @@ -27,4 +27,5 @@ exec curl \ https://w3id.org/zcap/v1 -o w3id-zcap-v1.jsonld \ https://w3id.org/vc-revocation-list-2020/v1 -o w3id-vc-revocation-list-2020-v1.jsonld \ https://w3id.org/vc/status-list/2021/v1 -o w3id-vc-status-list-2021-v1.jsonld \ + https://demo.didkit.dev/2022/cacao-zcap/contexts/v1.json -o cacao-zcap-v1.jsonld \ -L diff --git a/src/jsonld.rs b/src/jsonld.rs index 0b002332e..5d75ca31d 100644 --- a/src/jsonld.rs +++ b/src/jsonld.rs @@ -147,6 +147,7 @@ pub const PRESENTATION_SUBMISSION_V1_CONTEXT: &str = pub const VDL_V1_CONTEXT: &str = "https://w3id.org/vdl/v1"; pub const WALLET_V1_CONTEXT: &str = "https://w3id.org/wallet/v1"; pub const ZCAP_V1_CONTEXT: &str = "https://w3id.org/zcap/v1"; +pub const CACAO_ZCAP_V1_CONTEXT: &str = "https://demo.didkit.dev/2022/cacao-zcap/contexts/v1.json"; lazy_static! { pub static ref CREDENTIALS_V1_CONTEXT_DOCUMENT: RemoteDocument = { @@ -317,6 +318,12 @@ lazy_static! { let iri = Iri::new(ZCAP_V1_CONTEXT).unwrap(); RemoteDocument::new(doc, iri) }; + pub static ref CACAO_ZCAP_V1_CONTEXT_DOCUMENT: RemoteDocument = { + let jsonld = ssi_contexts::CACAO_ZCAP_V1; + let doc = json::parse(jsonld).unwrap(); + let iri = Iri::new(CACAO_ZCAP_V1_CONTEXT).unwrap(); + RemoteDocument::new(doc, iri) + }; } pub struct StaticLoader; @@ -366,6 +373,7 @@ impl Loader for StaticLoader { VDL_V1_CONTEXT => Ok(VDL_V1_CONTEXT_DOCUMENT.clone()), WALLET_V1_CONTEXT => Ok(WALLET_V1_CONTEXT_DOCUMENT.clone()), ZCAP_V1_CONTEXT => Ok(ZCAP_V1_CONTEXT_DOCUMENT.clone()), + CACAO_ZCAP_V1_CONTEXT => Ok(CACAO_ZCAP_V1_CONTEXT_DOCUMENT.clone()), _ => { eprintln!("unknown context {}", url); Err(json_ld::ErrorCode::LoadingDocumentFailed.into())