1//! Types shared by every dev.site component: the CLI, the daemon, the control plane, and2//! native clients. No I/O lives here.34pub mod access_plan;5pub mod capability;6pub mod id;7pub mod wire;89pub use capability::{CapabilityClaims, CapabilityError, Permission, SignedCapability};10pub use id::{AccountId, IdParseError, ResourceId};11pub use wire::{ConnectRequest, ErrorCode, Request, Response};1213/// Domain-separated statement signed by a daemon when enrolling or registering14/// its endpoint identity with the control plane.15pub fn machine_endpoint_proof_message(endpoint: &[u8; 32]) -> Vec<u8> {16 let mut message = b"dev.site machine endpoint proof v1\0".to_vec();17 message.extend_from_slice(endpoint);18 message19}2021/// Canonical statement signed by a short-lived client endpoint when asking a22/// trusted machine to broker service access on its behalf.23pub fn service_grant_request_message(24 request_id: &str,25 service: &str,26 requester_endpoint: &[u8; 32],27 expires_at: u64,28) -> Vec<u8> {29 let mut message = b"dev.site service grant request v1\0".to_vec();30 push_field(&mut message, request_id.as_bytes());31 push_field(&mut message, service.as_bytes());32 push_field(&mut message, requester_endpoint);33 message.extend_from_slice(&expires_at.to_be_bytes());34 message35}3637/// Canonical statement signed by the enrolled broker endpoint when issuing an38/// endpoint-bound session for one resolved resource.39pub fn service_grant_issue_message(40 request_id: &str,41 resource_id: &str,42 requester_endpoint: &[u8; 32],43 expires_at: u64,44) -> Vec<u8> {45 let mut message = b"dev.site service grant issue v1\0".to_vec();46 push_field(&mut message, request_id.as_bytes());47 push_field(&mut message, resource_id.as_bytes());48 push_field(&mut message, requester_endpoint);49 message.extend_from_slice(&expires_at.to_be_bytes());50 message51}5253fn push_field(message: &mut Vec<u8>, field: &[u8]) {54 message.extend_from_slice(&(field.len() as u64).to_be_bytes());55 message.extend_from_slice(field);56}5758/// ALPN for the authorized bidirectional TCP stream protocol.59pub const ALPN: &[u8] = b"devsite/tcp/1";