mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-22 07:16:03 +00:00
Four hand-rolled base64url implementations existed: Base64URLCoding in the Nostr folder, private duplicates in NostrEmbeddedBitChat and CashuTokenDecoder, and an inline chain in VerificationService. Padding handling differed per call site, which is exactly the drift #642 warns about. Move Base64URLCoding into BitFoundation (the shared-components package), make it public, and route all call sites through it. The unified decode keeps CashuTokenDecoder's padding normalization - strip any '=' then re-pad - because external wallets emit both padded and unpadded forms; it accepts a superset of what the old Nostr-side decode accepted and returns identical results for every input the old decoder handled. Encoding is byte-for-byte identical to all three prior copies. Adds unit tests covering alphabet substitution, padded/unpadded forms, every padding length, and malformed-input rejection. Fixes #642