Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use integrity::json_ld::ig_common_context_link;

#[cfg(feature = "jsonld")]
let context_urn = ig_common_context_link();
// Returns: "urn:cid:bafkr4ibtc72t26blsnipjniwpoawtopufixoe7bbloqk7ko65cizgnhgnq"
// Returns: "urn:cid:bafkr4ic7ydwk3rtoltyzx4zn3vvu3r7hpzxtmbzmnksotx7k5nbnwclf6m"
```

These contexts are embedded at compile time and used by the JSON-LD processor to:
Expand Down
20 changes: 1 addition & 19 deletions ffi/src/ffi/lineage_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::{collections::HashMap, ffi::c_char};

use serde_json::Value;

use crate::{
ffi::{
blob_store::IgBlobStoreHandle,
error::{map_anyhow, run_ffi, FfiError, IgStatus},
runtime::IgRuntimeHandle,
util::{as_ref, cstr_to_string, optional_cstr_to_string, write_c_string},
util::{as_ref, cstr_to_string, write_c_string},
},
lineage::models::{
manifest::{self, Manifest},
Expand All @@ -29,7 +27,6 @@ pub extern "C" fn ig_lineage_manifest_generate(
runtime: *const IgRuntimeHandle,
include_context: bool,
statements_json: *const c_char,
attributes_json_or_null: *const c_char,
blobs_json: *const c_char,
out_manifest_json: *mut *mut c_char,
err_out: *mut *mut c_char,
Expand All @@ -47,24 +44,9 @@ pub extern "C" fn ig_lineage_manifest_generate(
)
})?;

let attributes = match optional_cstr_to_string(attributes_json_or_null)? {
Some(attributes_json) => {
let value = serde_json::from_str::<HashMap<String, Value>>(&attributes_json)
.map_err(|e| {
FfiError::new(
IgStatus::JsonError,
format!("failed to parse attributes json: {e}"),
)
})?;
Some(value)
}
None => None,
};

let manifest = map_anyhow(runtime.block_on(manifest::generate_manifest(
include_context,
statements,
attributes,
blobs,
)))?;
let manifest_json = map_anyhow(serde_json::to_string(&manifest).map_err(Into::into))?;
Expand Down
6 changes: 4 additions & 2 deletions ffi/src/ffi/lineage_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
DidStatementEqtyVCompCustomV1, DidStatementEqtyVCompDockerV1,
DidStatementEqtyVCompIntelTdxV0, DidStatementRegular,
},
extract_statement_id, extract_statement_type, AssociationStatement,
extract_statement_id, extract_statement_type, AssociationStatement, AssociationType,
ComputationStatement, DataStatement, DsseStatement, EntityStatement,
GovernanceStatement, MetadataStatement, SigstoreBundleStatement, Statement,
StatementTrait, StorageStatement, VcStatement,
Expand Down Expand Up @@ -87,7 +87,8 @@ fn decode_hex_arr<const N: usize>(value: String, field_name: &str) -> Result<[u8
#[serde(rename_all = "camelCase")]
struct AssociationCreateRequest {
subject: String,
association: String,
association: Vec<String>,
r#type: AssociationType,
registered_by: String,
timestamp: Option<String>,
}
Expand Down Expand Up @@ -277,6 +278,7 @@ pub extern "C" fn ig_lineage_statement_create_association(
let statement = map_anyhow(runtime.block_on(AssociationStatement::create(
request.subject,
request.association,
request.r#type,
request.registered_by,
request.timestamp,
)))?;
Expand Down
5 changes: 3 additions & 2 deletions ffi/src/ffi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ fn ffi_lineage_statement_create_and_utils_smoke() {

let request = serde_json::json!({
"subject": "bafkr4ibthuzk3zug7ghmx63yjqaiu6rx4hhfdv3453j5bodskgw57bx2ya",
"association": "baga6yaq6echz7kjzuhzubnsq2mqkw5oxpkrio5nwb4fibzkwaqke3hqbc25g4",
"association": ["baga6yaq6echz7kjzuhzubnsq2mqkw5oxpkrio5nwb4fibzkwaqke3hqbc25g4"],
"registeredBy": "did:key:z6Mkw2PvzC9DHXiYQHMDRwyxCCV9n4EDc6vqqp1uyi9nrwsP",
"timestamp": "2025-01-01T00:00:00Z"
"timestamp": "2025-01-01T00:00:00Z",
"type": "includes"
});
let request_c = cstring(&request.to_string());

Expand Down
1 change: 1 addition & 0 deletions integrity-blob/src/blob_store/local_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::blob_store::{calc_and_validate_cid, BlobStore};
/// Local filesystem blob storage
///
/// Stores blobs as files in a directory, with CIDs as filenames.
#[derive(Clone)]
pub struct LocalFs {
path: PathBuf,
}
Expand Down
2 changes: 1 addition & 1 deletion integrity-jsonld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const MULTICODEC_RDFC_1_0: u64 = 0xb403;
/// # Returns
/// URN string in format `urn:cid:{cid}` for the IG common context.
pub fn ig_common_context_link() -> String {
let cid: &'static str = "bafkr4ibtc72t26blsnipjniwpoawtopufixoe7bbloqk7ko65cizgnhgnq";
let cid: &'static str = "bafkr4ic7ydwk3rtoltyzx4zn3vvu3r7hpzxtmbzmnksotx7k5nbnwclf6m";

format!("urn:cid:{cid}").trim_end().to_owned()
}
Expand Down
10 changes: 10 additions & 0 deletions integrity-jsonld/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ fn build_static_contexts() -> Result<ContextMap> {
// (non-trivial bit is generating the string in include_str since it's a macro)
let urn_cid_links: ContextMap = [
// latest
(
"urn:cid:bafkr4ic7ydwk3rtoltyzx4zn3vvu3r7hpzxtmbzmnksotx7k5nbnwclf6m".to_owned(),
{
let json = include_str!(
"../../static_contexts/cid/bafkr4ic7ydwk3rtoltyzx4zn3vvu3r7hpzxtmbzmnksotx7k5nbnwclf6m"
);
validate_json_string(json)?;
json
},
),
(
"urn:cid:bafkr4ibtc72t26blsnipjniwpoawtopufixoe7bbloqk7ko65cizgnhgnq".to_owned(),
{
Expand Down
22 changes: 0 additions & 22 deletions integrity-lineage-models/src/models/graph.rs

This file was deleted.

17 changes: 0 additions & 17 deletions integrity-lineage-models/src/models/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,17 @@ pub struct Manifest {
/// Optional anchor records proving statement publication
#[serde(skip_serializing_if = "Option::is_none")]
pub anchors: Option<Vec<Anchor>>,
/// Optional custom attributes for the manifest
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<HashMap<String, Value>>,
}

/// Generates a version 3 manifest from statements and blobs.
///
/// # Arguments
/// * `include_context` - Whether to embed JSON-LD contexts
/// * `statements` - Statements to include in the manifest
/// * `attributes` - Optional custom attributes
/// * `blobs` - Binary blobs referenced by statements
pub async fn generate_manifest(
include_context: bool,
statements: Vec<Statement>,
attributes: Option<HashMap<String, Value>>,
blobs: HashMap<String, String>,
) -> Result<Manifest> {
let contexts = if include_context {
Expand All @@ -74,7 +69,6 @@ pub async fn generate_manifest(
statements,
blobs,
contexts,
attributes,
anchors: None,
})
}
Expand All @@ -101,16 +95,6 @@ pub async fn merge_async(a: Manifest, b: Manifest) -> Result<Manifest> {
let mut blobs = a.blobs;
blobs.extend(b.blobs);

let attributes = match (a.attributes, b.attributes) {
(None, None) => None,
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(Some(mut a), Some(b)) => {
a.extend(b);
Some(a)
}
};

let anchors = match (a.anchors, b.anchors) {
(None, None) => None,
(Some(a), None) => Some(a),
Expand All @@ -127,7 +111,6 @@ pub async fn merge_async(a: Manifest, b: Manifest) -> Result<Manifest> {
statements,
blobs,
anchors,
attributes,
};

Ok(manifest)
Expand Down
2 changes: 0 additions & 2 deletions integrity-lineage-models/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// DSSE envelope models for lineage data
pub mod dsse;
/// Graph structure for organizing related statements
pub mod graph;
/// Manifest models for packaging statements and metadata
pub mod manifest;
/// Statement types for different lineage events
Expand Down
Loading