pub fn render_offered(
app: &DidNostr,
owner: &DidNostr,
containers: &[ContainerGrant],
) -> OfferedGrantExpand description
Renders the offered grant for an application key app in owner’s
pod, one authorisation per container in manifest order.
The same function runs in the controller and in the client, so the combined hash the client checks is the one the controller stored.
§Examples
use stratum_node_core::{render_offered, ContainerGrant, DidNostr, Sha256Digest};
let app = DidNostr::from_hex(&"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5")?;
let owner = DidNostr::from_hex(&"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")?;
let grants: Vec<ContainerGrant> = serde_json::from_str(
r#"[{"path":"in/","modes":["Read"],"operations":["GET"]},
{"path":"out/","modes":["Read","Write"],"operations":["PUT"]}]"#,
)?;
let offered = render_offered(&app, &owner, &grants);
assert_eq!(offered.containers.len(), 2);
assert_eq!(
offered.turtle,
format!("{}\n{}", offered.containers[0].turtle, offered.containers[1].turtle),
);
assert_eq!(offered.sha256, Sha256Digest::of(offered.turtle.as_bytes()));