App-locket
view release on metacpan or search on metacpan
lib/App/locket.pm view on Meta::CPAN
package App::locket;
BEGIN {
$App::locket::VERSION = '0.0022';
}
# ABSTRACT: Copy secrets from a YAML/JSON cipherstore into the clipboard (pbcopy, xsel, xclip)
use strict;
use warnings;
BEGIN {
# Safe path
$ENV{ PATH } = '/bin:/usr/bin';
}
use Term::ReadKey;
END {
ReadMode 0;
}
use File::HomeDir;
use Path::Class;
use JSON; my $JSON = JSON->new->pretty;
use YAML::XS();
use File::Temp;
use Term::EditorEdit;
use Try::Tiny;
use String::Util qw/ trim /;
my $usage;
BEGIN {
$usage = <<_END_;
Usage: locket [options] setup|edit|<query>
--copy Copy value to clipboard using pbcopy, xsel, or xclip
--delay <delay> Keep value in clipboard for <delay> seconds
If value is still in the clipboard at the end of
<delay> then it will be automatically wiped from
the clipboard
--unsafe Turn the safety off. This will disable prompting
before emitting any sensitive information in
plaintext. There will be no opportunity to
abort (via CTRL-C)
--cfg <file> Use <file> for configuration
setup Setup a new or edit an existing user configuration
file (~/.locket/cfg)
edit Edit the cipherstore
The configuration must have an "edit" value, e.g.:
/usr/bin/vim -n ~/.locket.gpg
/<query> Search the cipherstore for <query> and emit the
resulting secret
The configuration must have a "read" value to
tell it how to read the cipherstore. Only piped
commands are supported today, and they should
be something like:
</usr/local/bin/gpg -q --no-tty -d ~/.locket.gpg'
If the found key in the cipherstore is of the format
"<username>@<site>" then the username will be emitted
first before the secret (which is assumed to be a password/passphrase)
Example YAML cipherstore:
%YAML 1.1
---
# A GMail identity
alice\@gmail: p455w0rd
# Some frequently used credit card information
cc4123: |
4123412341234123
01/23
123
_END_
}
use Getopt::Usaginator $usage;
use Digest::SHA qw/ sha1_hex sha512_hex /;
use List::MoreUtils qw/ :all /;
( run in 1.899 second using v1.01-cache-2.11-cpan-39bf76dae61 )