Skip to content

Commit 85c7eb9

Browse files
pablof7zclaude
andcommitted
fix(blossom): handle UTF-8 characters in filenames during upload auth
Replace btoa() with TextEncoder approach to properly encode Unicode characters in filenames (spaces, international characters, emojis). The btoa() function only supports Latin1 encoding and would fail when the auth event content contained non-ASCII characters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 83dc10c commit 85c7eb9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

blossom/src/utils/auth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ export async function createAuthEvent(
8484
*/
8585
export function addAuthHeaders(headers: Record<string, string>, authEvent: NDKEvent): Record<string, string> {
8686
// Serialize and base64 encode the event according to BUD-01
87+
// Use TextEncoder to properly handle UTF-8 characters (e.g., Unicode in filenames)
8788
const serializedEvent = JSON.stringify(authEvent.rawEvent());
88-
const encodedEvent = btoa(serializedEvent);
89+
const encoder = new TextEncoder();
90+
const uint8Array = encoder.encode(serializedEvent);
91+
const binaryString = String.fromCharCode(...uint8Array);
92+
const encodedEvent = btoa(binaryString);
8993

9094
return {
9195
...headers,

0 commit comments

Comments
 (0)