Selkie--Widget--PasswordStrength

NAME

Selkie::Widget::PasswordStrength - Live password-strength meter bound to a TextInput

SYNOPSIS

use Selkie::Widget::TextInput;
use Selkie::Widget::PasswordStrength;
use Selkie::Sizing;

my $pw = Selkie::Widget::TextInput.new(
    sizing      => Sizing.fixed(1),
    placeholder => 'Enter password...',
    mask-char   => '*',
);

my $meter = Selkie::Widget::PasswordStrength.new(
    sizing => Sizing.fixed(1),
    input  => $pw,
);

$vbox.add($pw);
$vbox.add($meter);

DESCRIPTION

Non-focusable widget that subscribes to a TextInput's on-change Supply and renders a five-level strength meter in response.

Scoring is a simple length-plus-character-class heuristic — long enough for "password1" to look weak and "Correct Horse Battery Staple Example!" to look strong, without pulling in a dictionary or an external dependency. For serious analysis use zxcvbn; this is meant to give users directional feedback while they type.

Levels

  • weak (score < 20) — password-weak theme slot

  • fair (score < 40) — password-fair theme slot

  • good (score < 60) — password-good theme slot

  • strong (score < 80) — password-strong theme slot

  • very strong (score >= 80) — password-very-strong theme slot

An empty password uses password-empty. The unfilled part of the bar uses text-dim.

Score formula

score = min(100, length * (1 + 0.5 * (classes-1)) * class-bonus)

Where classes is the count of used character classes (lowercase / uppercase / digits / symbols) and class-bonus rewards mixed-class passwords.

ATTRIBUTES

  • input — the TextInput to watch. Required.

  • show-label — include the "weak"/"fair"/etc. label beside the bar. Default True.

method new

method new(
    *%args
) returns Selkie::Widget::PasswordStrength

Constructor. Defaults focusable to False (the meter is purely display). Required: :input — the TextInput to subscribe to. Optional: :show-label (default True) toggles the textual level beside the bar.

method score

method score() returns UInt

The most recent computed score, 0..100.

method label

method label() returns Str

The most recent level label ('', 'weak', ..., 'very strong').

sub score-password

sub score-password(
    Str $text
) returns UInt

Score a password 0..100 using a simple length + character-class heuristic. Intentionally simple and external-dependency-free. Not a substitute for zxcvbn; good enough to tell users directionally whether their choice is terrible, okay, or solid.

Selkie v0.10.0

High-level TUI framework built on Notcurses

Authors

  • Matt Doughty

License

Artistic-2.0

Dependencies

Notcurses::Native:ver<0.4.0+>:auth<zef:apogee>

Test Dependencies

Provides

  • Selkie
  • Selkie::App
  • Selkie::App::Internal::Dispatch
  • Selkie::App::Internal::ErrorLog
  • Selkie::App::Internal::FocusTree
  • Selkie::App::Internal::HitTest
  • Selkie::App::Internal::IdleBudget
  • Selkie::App::Internal::OverlayTree
  • Selkie::App::Internal::RenderLoop
  • Selkie::App::Internal::ScreenModalLifecycle
  • Selkie::App::Internal::Terminal
  • Selkie::App::Internal::TerminalSequences
  • Selkie::Container
  • Selkie::EffectiveBounds
  • Selkie::Event
  • Selkie::Layout::Allocate
  • Selkie::Layout::HBox
  • Selkie::Layout::Split
  • Selkie::Layout::VBox
  • Selkie::Plot::Palette
  • Selkie::Plot::Scaler
  • Selkie::Plot::Ticks
  • Selkie::ScreenManager
  • Selkie::Sizing
  • Selkie::Store
  • Selkie::Style
  • Selkie::Test::Focus
  • Selkie::Test::Keys
  • Selkie::Test::Snapshot
  • Selkie::Test::Snapshot::Harness
  • Selkie::Test::Store
  • Selkie::Test::Supply
  • Selkie::Test::Tree
  • Selkie::Theme
  • Selkie::Trace
  • Selkie::Tree
  • Selkie::Widget
  • Selkie::Widget::Axis
  • Selkie::Widget::BarChart
  • Selkie::Widget::Border
  • Selkie::Widget::Button
  • Selkie::Widget::CardList
  • Selkie::Widget::Checkbox
  • Selkie::Widget::CommandPalette
  • Selkie::Widget::ConfirmModal
  • Selkie::Widget::FileBrowser
  • Selkie::Widget::FocusableByDefault
  • Selkie::Widget::Heatmap
  • Selkie::Widget::HelpOverlay
  • Selkie::Widget::Histogram
  • Selkie::Widget::Image
  • Selkie::Widget::Legend
  • Selkie::Widget::LineChart
  • Selkie::Widget::ListView
  • Selkie::Widget::Modal
  • Selkie::Widget::MultiLineInput
  • Selkie::Widget::PasswordStrength
  • Selkie::Widget::Plot
  • Selkie::Widget::ProgressBar
  • Selkie::Widget::RadioGroup
  • Selkie::Widget::RichText
  • Selkie::Widget::RichText::Span
  • Selkie::Widget::ScatterPlot
  • Selkie::Widget::ScrollView
  • Selkie::Widget::Select
  • Selkie::Widget::Sparkline
  • Selkie::Widget::Spinner
  • Selkie::Widget::TabBar
  • Selkie::Widget::Table
  • Selkie::Widget::Text
  • Selkie::Widget::TextInput
  • Selkie::Widget::TextInput::HighlightSpan
  • Selkie::Widget::TextStream
  • Selkie::Widget::Toast
  • Selkie::Widget::ViewportedCardList

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.