Skip to main content

Module encoding

Module encoding 

Source
Expand description

base64url without padding, decoded strictly.

The permissive decoders accept several spellings of the same bytes, which matters here: these strings are compared, stored and fed to a MAC, and a server picks how they are spelled. So unknown characters are an error, padding is an error, a length that cannot come from whole bytes is an error, and the unused low bits of the final character must be zero. This is fromBase64Url in the app’s src/crypto/bytes.ts, rule for rule.

Functions§

be64
Eight bytes, big-endian: the additional data’s length, in a MAC input.
from_b64u
base64url to bytes, refusing anything non-canonical.
from_hex
Lowercase hex back to bytes, or None if it is not exactly that.
to_b64
Bytes to standard, padded base64, as a file’s content goes to the API.
to_b64u
Bytes to base64url, unpadded.
to_hex
Lowercase hex, for a webhook signature.