Make activities pass JSON-LD validation

This commit is contained in:
silverpill 2023-02-19 23:20:25 +00:00
parent 50176b00cc
commit 2b5d4562aa
2 changed files with 26 additions and 5 deletions

View file

@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Fixed actor object JSON-LD validation errors.
- Fixed activity JSON-LD validation errors.
## [1.13.1] - 2023-02-09

View file

@ -1,8 +1,15 @@
use std::collections::HashMap;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use super::constants::{AP_CONTEXT, W3ID_DATA_INTEGRITY_CONTEXT};
use super::constants::{
AP_CONTEXT,
MITRA_CONTEXT,
W3ID_DATA_INTEGRITY_CONTEXT,
W3ID_SECURITY_CONTEXT,
};
use super::vocabulary::HASHTAG;
#[derive(Deserialize, Serialize)]
@ -101,11 +108,24 @@ pub struct Object {
pub url: Option<Value>,
}
pub type Context = [&'static str; 2];
pub type Context = (
&'static str,
&'static str,
&'static str,
HashMap<&'static str, &'static str>,
);
pub const fn build_default_context() -> Context {
[
pub fn build_default_context() -> Context {
(
AP_CONTEXT,
W3ID_SECURITY_CONTEXT,
W3ID_DATA_INTEGRITY_CONTEXT,
]
HashMap::from([
("proofValue", "sec:proofValue"),
("proofPurpose", "sec:proofPurpose"),
("verificationMethod", "sec:verificationMethod"),
("mitra", MITRA_CONTEXT),
("MitraJcsRsaSignature2022", "mitra:MitraJcsRsaSignature2022"),
]),
)
}