A library for ATProtocol identities.

bug: inline attestation was not resolving keys in crates/atproto-attestation/src/bin/atproto-attestation-verify.rs

Changed files
+19 -6
crates
atproto-attestation
+19 -6
crates/atproto-attestation/src/bin/atproto-attestation-verify.rs
··· 47 48 use anyhow::{Context, Result, anyhow}; 49 use atproto_attestation::AnyInput; 50 - use atproto_identity::key::{KeyData, KeyResolver}; 51 use clap::Parser; 52 use serde_json::Value; 53 use std::{ ··· 115 attestation: Option<String>, 116 } 117 118 - struct FakeKeyResolver {} 119 120 #[async_trait::async_trait] 121 - impl KeyResolver for FakeKeyResolver { 122 - async fn resolve(&self, _subject: &str) -> Result<KeyData> { 123 - todo!() 124 } 125 } 126 ··· 175 identity_resolver, 176 }; 177 178 - let key_resolver = FakeKeyResolver {}; 179 180 atproto_attestation::verify_record( 181 AnyInput::Serialize(record.clone()),
··· 47 48 use anyhow::{Context, Result, anyhow}; 49 use atproto_attestation::AnyInput; 50 + use atproto_identity::key::{KeyData, KeyResolver, identify_key}; 51 use clap::Parser; 52 use serde_json::Value; 53 use std::{ ··· 115 attestation: Option<String>, 116 } 117 118 + /// A key resolver that supports `did:key:` identifiers directly. 119 + /// 120 + /// This resolver handles key references that are encoded as `did:key:` strings, 121 + /// parsing them to extract the cryptographic key data. For other DID methods, 122 + /// it returns an error since those would require fetching DID documents. 123 + struct DidKeyResolver {} 124 125 #[async_trait::async_trait] 126 + impl KeyResolver for DidKeyResolver { 127 + async fn resolve(&self, subject: &str) -> Result<KeyData> { 128 + if subject.starts_with("did:key:") { 129 + identify_key(subject) 130 + .map_err(|e| anyhow!("Failed to parse did:key '{}': {}", subject, e)) 131 + } else { 132 + Err(anyhow!( 133 + "Subject '{}' is not a did:key: identifier. Only did:key: subjects are supported by this resolver.", 134 + subject 135 + )) 136 + } 137 } 138 } 139 ··· 188 identity_resolver, 189 }; 190 191 + let key_resolver = DidKeyResolver {}; 192 193 atproto_attestation::verify_record( 194 AnyInput::Serialize(record.clone()),