Skip to main content

aph_core/
aph_config.rs

1//! APH configuration constants — version pins, default TTLs, JCS profile.
2
3/// APH protocol version pin. Bump only with coordinated rollout.
4pub const APH_VERSION: &str = "0.1";
5
6/// W3C VC 2.0 context URL.
7pub const W3C_VC_CONTEXT_V2: &str = "https://www.w3.org/ns/credentials/v2";
8
9/// APH context URL (resolves to the published `aph` repo's `v1` JSON-LD context).
10pub const APH_CONTEXT_V1: &str = "https://w3id.org/aph/v1";
11
12/// Default mandate TTL: 24 hours. Per-channel adapter may override.
13pub const DEFAULT_MANDATE_TTL_SECONDS: u64 = 24 * 60 * 60;
14
15/// Maximum body preview lines included in `communication.preview` field.
16pub const MAX_PREVIEW_LINES: usize = 5;
17
18/// Maximum body size in bytes that a Verifier MUST accept without truncation
19/// requirement. Larger bodies still notarize but Verifiers MAY decline preview.
20pub const MAX_BODY_PREVIEW_BYTES: usize = 8 * 1024;
21
22/// Signature algorithm identifier — ES256 (p256 ECDSA over SHA-256).
23pub const ALG_ES256: &str = "ES256";
24
25/// Signature algorithm identifier — EdDSA (Ed25519).
26pub const ALG_EDDSA: &str = "EdDSA";
27
28/// JSON-LD `type` discriminator for an APH credential.
29pub const APH_CREDENTIAL_TYPE: &str = "AgentSendAuthorizationCredential";
30
31/// `cryptosuite` identifier for Data Integrity Proof, JCS-canonicalized EdDSA.
32pub const APH_DI_CRYPTOSUITE: &str = "eddsa-jcs-2022";
33
34#[cfg(test)]
35mod tests {
36  #[test]
37  fn version_is_0_1() {
38    // aphVersion is emitted into every envelope and verifiers MUST reject
39    // unsupported versions, so bumping this constant is a wire-breaking
40    // change that should never happen by accident.
41    std::assert_eq!(super::APH_VERSION, "0.1");
42  }
43
44  #[test]
45  fn contexts_are_https_urls() {
46    // JSON-LD context URIs are compared literally by verifiers and must be
47    // https — an http or relative URI would both fail those comparisons
48    // and invite an insecure fetch by a resolving processor.
49    std::assert!(super::W3C_VC_CONTEXT_V2.starts_with("https://"));
50    std::assert!(super::APH_CONTEXT_V1.starts_with("https://"));
51  }
52}