RFC 9530 SHA-256/SHA-512 digest generation, HTTP header integration, negotiation, verification, and audit
moon add HaQiLyner/moon_digest_fields@0.2.0let body = @base64.str2bytes("{\"hello\": \"world\"}\n")
let response = @digest.apply_digest_header(
{ headers: [{ name: "Content-Type", value: "application/json" }], body },
@digest.Content,
)
let result = @digest.verify_http_message(response, @digest.Content)
println(result.verification.decision.to_string()) // verifiedmoon update
moon test --target js
moon run cmd/main --target js
moon run examples/bench --target jspub(all) struct AuditEntry {
record_id : String
target : IntegrityTarget
field_value : String?
body : Bytes
} derive(Eq, Debug)pub(all) struct AuditFinding {
record_id : String
target : IntegrityTarget
decision : VerificationDecision
algorithm : String
code : String
} derive(Eq, Debug)pub(all) struct AuditReport {
findings : Array[AuditFinding]
verified : Int
mismatch : Int
invalid : Int
missing : Int
blocked : Int
too_large : Int
} derive(Eq, Debug)pub(all) struct HttpIntegrityResult {
field_name : String
combined_value : String
occurrences : Int
verification : Verification
} derive(Eq, Debug)pub(all) struct Verification {
target : IntegrityTarget
decision : VerificationDecision
algorithm : String
code : String
checked : Int
ignored : Int
} derive(Eq, Debug)fn apply_digest_header(message : HttpMessage, target : IntegrityTarget, algorithms? : Array[String]) -> HttpMessage raise DigestFieldErrorfn digest_field_for(input : Bytes, algorithms : Array[String]) -> DigestField raise DigestFieldErrorfn negotiate_digest_algorithm(preferences : PreferenceField, supported : Array[String]) -> NegotiationResultfn negotiate_http_digest(headers : Array[HttpHeader], target : IntegrityTarget, supported? : Array[String]) -> NegotiationResult raise DigestFieldErrorfn verify_digest(target : IntegrityTarget, field : DigestField, body : Bytes, policy : VerificationPolicy) -> Verificationfn verify_digest_field(target : IntegrityTarget, field_value : String, body : Bytes, policy : VerificationPolicy) -> Verificationfn verify_http_message(message : HttpMessage, target : IntegrityTarget, policy? : VerificationPolicy) -> HttpIntegrityResultInstall
Download zipRFC 9530 SHA-256/SHA-512 digest generation, HTTP header integration, negotiation, verification, and audit