CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-base64url

For encoding to/from base64urls implementing RFC 4648 base64url standard

89

1.28x
Overview
Eval results
Files

task.mdevals/scenario-7/

URL-safe Payload Decoder

Build a small module that decodes URL-safe base64 payloads into readable text for HTTP and CLI inputs.

Capabilities

Decode message payloads

  • Decodes SGVsbG8sIHdvcmxkIQ into Hello, world! @test

Support non-UTF-8 output

  • When given Y2Fm6Q and encoding latin1, returns café instead of UTF-8 fallback @test

Reject invalid tokens

  • Passing a token containing non-base64url characters such as !!bad!! results in a thrown error @test

Implementation

@generates

API

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;

Dependencies { .dependencies }

base64url { .dependency }

Provides base64url decoding utilities for translating URL-safe payloads into text.

Install with Tessl CLI

npx tessl i tessl/npm-base64url

tile.json