use serde_json::{Value, json};
pub fn passport_context() -> Value {
json!({
"@context": [
"https://www.w3.org/ns/did/v1",
"https://ref.gs1.org/standards/digital-link/context/",
{
"dpp": "https://schema.odal-node.io/dpp#",
"gs1": "https://ref.gs1.org/voc/",
"schema": "https://schema.org/",
"gtin": "gs1:gtin",
"sector": "dpp:sector",
"passportId": "dpp:passportId",
"status": "dpp:status",
"sectorData": "dpp:sectorData",
"complianceResult": "dpp:complianceResult",
"createdAt": "schema:dateCreated",
"updatedAt": "schema:dateModified",
"jws": "dpp:jws"
}
]
})
}
pub fn frame_passport(passport: Value) -> Value {
match passport {
Value::Object(passport_map) => {
let mut framed = passport_context();
if let Value::Object(ref mut ctx_map) = framed {
ctx_map.extend(passport_map);
}
framed
}
other => other,
}
}
pub fn strip_context(framed: Value) -> Value {
match framed {
Value::Object(mut map) => {
map.remove("@context");
Value::Object(map)
}
other => other,
}
}