signer_rejection.rs (1761B)
1 //! Output-only bounded diagnostics; no raw signer response is retained. 2 use radroots_signing::issuance::{RejectedArtifact, RejectionReason}; 3 use wasm_bindgen::prelude::*; 4 5 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 6 #[wasm_bindgen] 7 pub enum SignerRejectionReason { 8 TooLarge, 9 InvalidArtifact, 10 InvalidSignature, 11 BindingMismatch, 12 Unsupported, 13 } 14 #[derive(Clone, Debug)] 15 #[wasm_bindgen] 16 pub struct SignerFingerprint { 17 #[wasm_bindgen(readonly, getter_with_clone)] 18 pub sha256: Vec<u8>, 19 #[wasm_bindgen(readonly, getter_with_clone)] 20 pub covered_bytes: String, 21 #[wasm_bindgen(readonly, getter_with_clone)] 22 pub total_bytes: String, 23 } 24 #[derive(Clone, Debug)] 25 #[wasm_bindgen] 26 pub struct SignerRejection { 27 #[wasm_bindgen(readonly)] 28 pub reason: SignerRejectionReason, 29 #[wasm_bindgen(readonly, getter_with_clone)] 30 pub fingerprint: Option<SignerFingerprint>, 31 } 32 impl From<RejectedArtifact> for SignerRejection { 33 fn from(value: RejectedArtifact) -> Self { 34 Self { 35 reason: match value.reason() { 36 RejectionReason::TooLarge => SignerRejectionReason::TooLarge, 37 RejectionReason::InvalidArtifact => SignerRejectionReason::InvalidArtifact, 38 RejectionReason::InvalidSignature => SignerRejectionReason::InvalidSignature, 39 RejectionReason::BindingMismatch => SignerRejectionReason::BindingMismatch, 40 _ => SignerRejectionReason::Unsupported, 41 }, 42 fingerprint: value.fingerprint().map(|v| SignerFingerprint { 43 sha256: v.sha256().to_vec(), 44 covered_bytes: v.covered_bytes().to_string(), 45 total_bytes: v.total_bytes().to_string(), 46 }), 47 } 48 } 49 }