App-OATH

 view release on metacpan or  search on metacpan

lib/App/OATH.pm  view on Meta::CPAN

package App::OATH;
our $VERSION = '1.20260324'; # VERSION

use strict;
use warnings;

use Convert::Base32;
use Digest::HMAC_SHA1 qw(hmac_sha1);
use English qw{ -no_match_vars };
use Fcntl ':flock';
use File::HomeDir qw{ my_home };
use JSON;
use POSIX;
use URL::Encode qw{ url_encode };
use Text::QRCode;
use Term::ANSIColor;

use App::OATH::Crypt;

if ( $OSNAME eq 'MSWin32' ) { # uncoverable statement
    require Term::ReadPassword::Win32; # uncoverable statement
} # uncoverable statement
else { # uncoverable statement
    require Term::ReadPassword; # uncoverable statement
} # uncoverable statement

sub new {
    my ( $class ) = @_;
    my $self = {
        'filename' => my_home() . '/.oath.json',
    };
    bless $self, $class;
    return $self;
}

sub usage {
    my ( $self ) = @_;
    print "usage: $0 --add string --file filename --help --init --list --newpass --raw --rawqr --search string \n\n";
    print "options:\n\n";
    print "--add string\n";
    print "    add a new password to the database, the format can be one of the following\n"; 
    print "        text: identifier:secret\n";
    print "        url:  otpauth://totp/alice\@google.com?secret=JBSWY3DPEHPK3PXP\n\n";
    print "--file filename\n";
    print "    filename for database, default ~/.oath.json\n\n";
    print "--help\n";
    print "    show this help\n\n";
    print "--init\n";
    print "    initialise the database, file must not exist\n\n";
    print "--list\n";
    print "    list keys in database\n\n";
    print "--newpass\n";
    print "    resave database with a new password\n\n";
    print "--raw\n";
    print "    show the raw oath code (useful for migration to another device)\n\n";
    print "--rawqr\n";
    print "    show the raw oath code as an importable qr code (useful for migration to another device)\n\n";
    print "--search string\n";
    print "    search database for keys matching string\n\n";
    exit 0;
}



( run in 1.094 second using v1.01-cache-2.11-cpan-39bf76dae61 )