For encoding to/from base64urls implementing RFC 4648 base64url standard
89
Build a small module that decodes URL-safe base64 payloads into readable text for HTTP and CLI inputs.
SGVsbG8sIHdvcmxkIQ into Hello, world! @testY2Fm6Q and encoding latin1, returns café instead of UTF-8 fallback @test!!bad!! results in a thrown error @test@generates
export interface DecodeOptions {
/**
* Character encoding to use when converting bytes to text. Defaults to "utf8".
*/
encoding?: BufferEncoding;
}
/**
* Converts a base64url-encoded token into decoded text.
*
* @param token Base64url-encoded content with "-" and "_" alphabet, padding optional.
* @param options Optional configuration for decoding.
* @returns Decoded text using the requested encoding.
* @throws Error when the token is empty, not a string, or not valid base64url data.
*/
export function decodeMessage(token: string, options?: DecodeOptions): string;Provides base64url decoding utilities for translating URL-safe payloads into text.
Install with Tessl CLI
npx tessl i tessl/npm-base64url