Phase B: identifier+key on the wire, JCS envelope signing (FRX/0.5), registry binding
This commit is contained in:
+5
-3
@@ -22,6 +22,7 @@ pub struct Envelope {
|
||||
#[serde(rename = "type")]
|
||||
pub msg_type: String,
|
||||
pub from: String,
|
||||
pub key: String,
|
||||
pub ts: u64,
|
||||
pub nonce: String,
|
||||
pub body: Value,
|
||||
@@ -29,10 +30,11 @@ pub struct Envelope {
|
||||
}
|
||||
|
||||
impl Envelope {
|
||||
pub fn new(key: &Keypair, msg_type: &str, body: Value) -> Self {
|
||||
pub fn new(key: &Keypair, identifier: &str, msg_type: &str, body: Value) -> Self {
|
||||
let mut envelope = Self {
|
||||
msg_type: msg_type.to_string(),
|
||||
from: key.public_hex(),
|
||||
from: identifier.to_string(),
|
||||
key: key.public_hex(),
|
||||
ts: now_ts(),
|
||||
nonce: random_nonce(),
|
||||
body,
|
||||
@@ -183,7 +185,7 @@ mod tests {
|
||||
#[test]
|
||||
fn envelope_rejects_wrong_type() {
|
||||
let key = Keypair::generate();
|
||||
let envelope = Envelope::new(&key, TYPE_RESPONSE, json!({}));
|
||||
let envelope = Envelope::new(&key, "bob.example", TYPE_RESPONSE, json!({}));
|
||||
assert!(require_type(&envelope, TYPE_QUERY).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user