An easy-to-host PDS on the ATProtocol, MacOS. Grandma-approved.

feat(common): add plc_directory_url to Config and DID error codes (MM-89)

authored by malpercio.dev and committed by

Tangled 5c7c90d7 e523544e

+18
+10
crates/common/src/config.rs
··· 38 38 pub admin_token: Option<String>, 39 39 // AES-256-GCM master key for encrypting signing key private keys at rest. 40 40 pub signing_key_master_key: Option<Sensitive<Zeroizing<[u8; 32]>>>, 41 + // URL of the PLC directory service (default: https://plc.directory) 42 + pub plc_directory_url: String, 41 43 } 42 44 43 45 /// Optional privacy/ToS links surfaced by `com.atproto.server.describeServer`. ··· 117 119 #[serde(default)] 118 120 pub(crate) telemetry: RawTelemetryConfig, 119 121 pub(crate) admin_token: Option<String>, 122 + pub(crate) plc_directory_url: Option<String>, 120 123 #[serde(skip)] 121 124 pub(crate) signing_key_master_key: Option<[u8; 32]>, 122 125 /// Sentinel field — only present to detect misconfiguration. ··· 235 238 if let Some(v) = env.get("EZPDS_ADMIN_TOKEN") { 236 239 raw.admin_token = Some(v.clone()); 237 240 } 241 + if let Some(v) = env.get("EZPDS_PLC_DIRECTORY_URL") { 242 + raw.plc_directory_url = Some(v.clone()); 243 + } 238 244 if let Some(v) = env.get("EZPDS_SIGNING_KEY_MASTER_KEY") { 239 245 raw.signing_key_master_key = Some(parse_hex_32("EZPDS_SIGNING_KEY_MASTER_KEY", v)?); 240 246 } ··· 291 297 )); 292 298 } 293 299 let invite_code_required = raw.invite_code_required.unwrap_or(true); 300 + let plc_directory_url = raw 301 + .plc_directory_url 302 + .unwrap_or_else(|| "https://plc.directory".to_string()); 294 303 295 304 let telemetry_defaults = TelemetryConfig::default(); 296 305 let otlp_endpoint = raw ··· 335 344 signing_key_master_key: raw 336 345 .signing_key_master_key 337 346 .map(|k| Sensitive(Zeroizing::new(k))), 347 + plc_directory_url, 338 348 }) 339 349 } 340 350
+8
crates/common/src/error.rs
··· 38 38 /// A claim code that has already been redeemed is presented again. 39 39 /// Clients should inform the user to obtain a different code. 40 40 ClaimCodeRedeemed, 41 + /// The DID has already been fully promoted to an active account. 42 + DidAlreadyExists, 43 + /// The external PLC directory returned a non-success response. 44 + PlcDirectoryError, 41 45 // TODO: add remaining codes from Appendix A as endpoints are implemented: 42 46 // 400: INVALID_DOCUMENT, INVALID_PROOF, INVALID_ENDPOINT, INVALID_CONFIRMATION 43 47 // 401: INVALID_CREDENTIALS ··· 69 73 ErrorCode::HandleTaken => 409, 70 74 ErrorCode::InvalidHandle => 400, 71 75 ErrorCode::ClaimCodeRedeemed => 409, 76 + ErrorCode::DidAlreadyExists => 409, 77 + ErrorCode::PlcDirectoryError => 502, 72 78 } 73 79 } 74 80 } ··· 220 226 (ErrorCode::HandleTaken, 409), 221 227 (ErrorCode::InvalidHandle, 400), 222 228 (ErrorCode::ClaimCodeRedeemed, 409), 229 + (ErrorCode::DidAlreadyExists, 409), 230 + (ErrorCode::PlcDirectoryError, 502), 223 231 ]; 224 232 for (code, expected) in cases { 225 233 assert_eq!(code.status_code(), expected, "wrong status for {code:?}");