Vidit Kulshrestha 9d621fcc1c Consolidate base64url helpers into a single BitFoundation utility
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
2026-07-27 09:32:58 +05:30
..