Problem
encodeBase64 is used to construct LNbits Basic Auth credentials and deliberately bridges UTF-8 bytes to the Web Platform btoa API. It currently has no focused regression tests for Unicode handling or Base64 padding.
Scope
Add src/core/utils/base64.test.ts covering:
- empty input;
- ordinary ASCII credentials;
- one-byte and two-byte padding cases;
- non-ASCII/UTF-8 credentials;
- deterministic output matching known Base64 vectors.
Non-goals
- Do not replace the implementation or introduce Node-only globals such as
Buffer in production code.
- Do not add LNbits integration or network tests.
- Keep production changes out of scope unless a test exposes a confirmed defect.
Acceptance criteria
- Expected values are independent known vectors rather than values generated by calling the function under test.
- Tests exercise the browser-safe UTF-8 path.
- Existing tests, lint, and type checking continue to pass.
Verification
bun test src/core/utils/base64.test.ts
bun lint
bun typecheck
Problem
encodeBase64is used to construct LNbits Basic Auth credentials and deliberately bridges UTF-8 bytes to the Web PlatformbtoaAPI. It currently has no focused regression tests for Unicode handling or Base64 padding.Scope
Add
src/core/utils/base64.test.tscovering:Non-goals
Bufferin production code.Acceptance criteria
Verification
bun test src/core/utils/base64.test.ts bun lint bun typecheck