Mint an agent's self-signed delegation request. Used when the agent's key is generated somewhere the human never sees — a CI runner, a hosted agent. The self-signature is proof of possession: the human countersigning a request knows the key on the other end is real, and is not tricked into delegating to a key nobody holds.
(agent: &Identity, agent_key: &KeyPair, software_agent: Option<&str>)
| 385 | /// countersigning a request knows the key on the other end is real, and is not |
| 386 | /// tricked into delegating to a key nobody holds. |
| 387 | pub fn mint_request(agent: &Identity, agent_key: &KeyPair, software_agent: Option<&str>) -> Value { |
| 388 | let mut doc = Map::new(); |
| 389 | doc.insert("@context".into(), json!(CONTEXT_URL)); |
| 390 | doc.insert("@type".into(), json!(TYPE_REQUEST)); |
| 391 | doc.insert("delegate".into(), json!(agent.id.to_did())); |
| 392 | doc.insert("delegateKey".into(), json!(agent.public_key.to_did_key())); |
| 393 | doc.insert("delegateName".into(), json!(agent.name)); |
| 394 | if let Some(sa) = software_agent { |
| 395 | doc.insert("softwareAgent".into(), json!(sa)); |
| 396 | } |
| 397 | doc.insert("requested".into(), json!(rfc3339(Utc::now()))); |
| 398 | |
| 399 | proof::attest_value(Value::Object(doc), agent, agent_key) |
| 400 | } |
| 401 | |
| 402 | /// Verify a delegation request's self-signature. |
| 403 | /// |