module

PrismatIQ

Constants

SENSITIVE_KEY_PATTERN = /[?&](?:password|passwd|pwd|secret|token|key|api[_-]?key|auth|credential|bearer|basic|jwt|oauth|api[_-]?secret|session[_-]?id|private[_-]?key|access[_-]?token|refresh[_-]?token|client[_-]?secret)\s*[=:][^&\s]*/i

Regex pattern to match sensitive key=value pairs in URLs, headers, or config. Matches: ?password=secret, &token=xyz, "secret: value", etc. The entire key+separator+value is replaced with [REDACTED].

Class methods

clear_caches
clear_theme_cache
extract_theme(source : String, options : ThemeOptions = ThemeOptions.new) : ThemeResult | Nil
find_closest(target : RGB, palette : Array(RGB)) : RGB | Nil
find_closest_in_palette(target : RGB, path : String, options : Options = Options.default) : RGB | Nil
fix_theme(theme_json : String, legacy_bg : String | Nil = nil, legacy_text : String | Nil = nil) : String | Nil
get_color(path : String) : RGB | Nil
get_color(io : IO) : RGB | Nil
get_color(img : CrImage::Image) : RGB | Nil
get_palette_channel(path : String, options : Options = Options.default) : Channel(Array(RGB))
get_palette_color_thief(pixels : Slice(UInt8), width : Int32, height : Int32, options : Options = Options.default) : Array(String)
get_palette_from_buffer(pixels : Slice(UInt8), width : Int32, height : Int32, options : Options, config : Config = Config.default) : Array(RGB)
get_palette_from_ico_v2(path : String, options : Options = Options.default, config : Config = Config.default) : Result(Array(RGB), Error)

Extract palette from ICO file with explicit Error type (v2 API)

get_palette_v2(path : String, options : Options = Options.default, config : Config = Config.default) : Result(Array(RGB), Error)
get_palette_v2(io : IO, options : Options = Options.default, config : Config = Config.default) : Result(Array(RGB), Error)
get_palette_v2(pixels : Slice(UInt8), width : Int32, height : Int32, options : Options = Options.default, config : Config = Config.default) : Result(Array(RGB), Error)
get_palette_v2(image : CrImage::Image, options : Options = Options.default, config : Config = Config.default) : Result(Array(RGB), Error)
get_palette_v2!(path : String, options : Options = Options.default, config : Config = Config.default) : Array(RGB)
get_palette_v2!(io : IO, options : Options = Options.default, config : Config = Config.default) : Array(RGB)
get_palette_v2!(pixels : Slice(UInt8), width : Int32, height : Int32, options : Options = Options.default, config : Config = Config.default) : Array(RGB)
get_palette_v2!(image : CrImage::Image, options : Options = Options.default, config : Config = Config.default) : Array(RGB)
get_palette_with_stats(pixels : Slice(UInt8), width : Int32, height : Int32, options : Options = Options.default, config : Config = Config.default) : Tuple(Array(PaletteEntry), Int32)
log_debug(message : String) : Nil

Logs a debug message with sensitive data sanitization. Routes through Config.default for unified debug control.

sanitize_message(message : String) : String

Sanitizes potentially sensitive data from debug messages before logging. Redacts passwords, tokens, API keys, and authentication credentials.

Uses a simple replacement strategy: find sensitive key=value patterns and replace them entirely with [REDACTED]. This is more robust than trying to preserve partial values since secrets should never appear in debug logs anyway.

Handles:

  • URL query parameters: ?password=secret&token=xyz
  • Header-like values: "Authorization: Bearer xyz"
  • Config values: api_key=secret

Nested types