Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

lastChunkHandling: strict-no-padding option? #62

Open

Description

@mary-ext

Would be useful for deterministic or multibase-adjacent usage where there is clear separation between base64 (which omits padding) and base64pad (which does include padding).

Right now the only way to mitigate this is to manually check if there's a padding and throw if that's the case, but I wonder if this is better handled as an option in lastChunkHandling instead?

https://github.com/mary-ext/atcute/blob/bde458b1ad33b9d0ede8975383301b7faa4194cd/packages/utilities/multibase/lib/bases/base64.ts#L15-L21

It seems weird to me that omitPadding was added in the encode side yet no equivalent option in the decode side.

Activity

  1. bakkot commented on Jan 7, 2025

    @bakkot
    Member

    It seems weird to me that omitPadding was added in the encode side yet no equivalent option in the decode side.

    No one had a use case for it. The relatively rare places which care about canonical encodings generally also enforce presence of padding, in my experience. Also, it's easier to check for padding when decoding than to generate it when encoding.

  2. mary-ext commented on Jan 7, 2025

    @mary-ext
    Author

    Hrmmm, unfortunate, there is a few more things I'm noticing that hampers the use in IPLD/DASL/AT Protocol context (without tacking on additional code, as mentioned above.)

    I'm wondering if I should just file them as separate issues, or mention it in here for now as the overarching issue is the same (determinism requirement)

    • base64 should...
      • not contain paddings (this issue)
      • not contain whitespaces
      • should throw if chunk only contains one character (Uint8Array.fromBase64('A') should throw instead of returning an empty uint8, it doesn't seem like lastChunkHandling: strict handles this?)
    • base16 should...
      • only contain lowercase letters (uppercase would be base16upper)
  3. bakkot commented on Jan 7, 2025

    @bakkot
    Member

    This proposal is no longer making changes except for bugfixes. You're welcome to mention use cases here, but they'd have to be done in a follow-up. That said, these were all discussed and we explicitly decided they weren't worth adding API complexity for, given that they're all straightforward to do in userland.

    Uint8Array.fromBase64('A') should throw

    Except this one. That should be an error in anything except stop-before-partial. If you're seeing otherwise, that's a bug in whatever implementation you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions