denoland/celldPublic

self-hosted, distributed Durable Objects

atob rejects valid Base64 without padding

DL

I ran into another issue while using PropelAuth's Cloudflare SDK on celld 0.4.1. `atob()` rejects Base64 strings when the trailing `=` padding is omitted, which causes JOSE to fail when decoding JWT signatures.

For now I'm patching the sdk, but apparently that padding is [optional for `atob()`](https://infra.spec.whatwg.org/#forgiving-base64-decode). Here is a minimal repro:

```js atob("YQ=="); // "a" atob("YQ"); // Should also return "a", but throws InvalidCharacterError ```

Here is a patch with a fix:

[0001-Implement-forgiving-Base64-decoding-for-atob.patch](https://github.com/user-attachments/files/32133749/0001-Implement-forgiving-Base64-decoding-for-atob.patch)

My industrious little bot found a few more edge cases, but I will submit separate issues for those to keep the patches focused.

  1. bartlomiejuclosedlast month on GitHub

  2. bartlomiejureferenced 9c2d299dd6ablast month on GitHub

  3. ryreferenced e519694581dclast month on GitHub

  4. ryreferenced 4250d366aceblast month on GitHub

  5. ryreferenced 3127cf8e307elast month on GitHub

  6. ryreferenced 12d5b6333fe5last month on GitHub