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-3/

URL-safe Payload Codec

Build a module that converts textual or binary payloads to and from URL-safe Base64 strings while honoring caller-specified character encodings and rejecting unsupported inputs.

Capabilities

Encode payloads with optional encoding

Encode strings or buffers into padding-free, URL-safe Base64 strings. Default to UTF-8 when no encoding is provided; honor a supplied encoding for string inputs.

  • Encoding "hello" with the default encoding returns "aGVsbG8" @test
  • Encoding the string "\xff\xff" using the "binary" encoding returns "__8" @test

Validate inputs before encoding

Reject inputs that are neither strings nor buffers.

  • Encoding a numeric input (e.g., 42) throws a TypeError @test

Decode payloads with optional encoding

Decode URL-safe Base64 strings back to text using the requested encoding, defaulting to UTF-8 when omitted.

  • Decoding "__8" using the "binary" encoding produces a string whose binary bytes equal 0xff, 0xff @test

Implementation

@generates

API

export function encodePayload(input: string | Buffer, encoding?: BufferEncoding): string;
export function decodePayload(encoded: string, encoding?: BufferEncoding): string;

Dependencies { .dependencies }

base64url { .dependency }

Provides URL-safe Base64 encoding/decoding utilities with optional encoding support.

Install with Tessl CLI

npx tessl i tessl/npm-base64url

tile.json