Skip to content

Commit 55b20f1

Browse files
committed
blossom: refactor BlossomClient::build_auth_header
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 263463e commit 55b20f1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

crates/nostr-blossom/src/client.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use base64::Engine;
77
use nostr::hashes::sha256::Hash as Sha256Hash;
88
use nostr::hashes::Hash;
99
use nostr::signer::NostrSigner;
10-
use nostr::{Event, EventBuilder, PublicKey, Timestamp};
10+
use nostr::{Event, EventBuilder, JsonUtil, PublicKey, Timestamp};
1111
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE, RANGE};
1212
#[cfg(not(target_arch = "wasm32"))]
1313
use reqwest::redirect::Policy;
@@ -340,10 +340,9 @@ impl BlossomClient {
340340
let auth_event: Event = EventBuilder::blossom_auth(authz.clone())
341341
.sign(signer)
342342
.await?;
343-
// TODO: use directly event.as_json
344-
let auth_bytes = serde_json::to_vec(&auth_event).unwrap();
345-
let encoded_auth = general_purpose::STANDARD.encode(auth_bytes);
346-
Ok(HeaderValue::from_str(&format!("Nostr {}", encoded_auth))?)
343+
let encoded_auth: String = general_purpose::STANDARD.encode(auth_event.as_json());
344+
let value: String = format!("Nostr {}", encoded_auth);
345+
Ok(HeaderValue::try_from(value)?)
347346
}
348347
}
349348

0 commit comments

Comments
 (0)