use warnings;
use strict;
-use Crypt::Misc 0.029 qw(decode_b64 encode_b32r);
+use Crypt::Misc 0.049 qw(decode_b64 encode_b32r);
use Devel::GlobalDestruction;
use Encode qw(encode);
use File::KDBX::Constants qw(:history :icon);
use File::KDBX::Error;
use File::KDBX::Util qw(:assert :class :coercion :erase :function :uri generate_uuid load_optional);
use Hash::Util::FieldHash;
-use List::Util qw(first sum0);
+use List::Util qw(any first sum0);
use Ref::Util qw(is_coderef is_hashref is_plain_hashref);
use Scalar::Util qw(blessed looks_like_number);
use Storable qw(dclone);
-use Time::Piece;
+use Time::Piece 1.33;
use boolean;
use namespace::clean;
my %PLACEHOLDERS;
my %STANDARD_STRINGS = map { $_ => 1 } qw(Title UserName Password URL Notes);
-=attr uuid
-
-128-bit UUID identifying the entry within the database.
-
-=attr icon_id
-
-Integer representing a default icon. See L<File::KDBX::Constants/":icon"> for valid values.
-
-=attr custom_icon_uuid
-
-128-bit UUID identifying a custom icon within the database.
-
=attr foreground_color
Text color represented as a string of the form C<#000000>.
TODO
-=attr tags
-
-Text string with arbitrary tags which can be used to build a taxonomy.
-
=attr auto_type_enabled
Whether or not the entry is eligible to be matched for auto-typing.
keystroke_sequence => '{USERNAME}{TAB}{PASSWORD}{ENTER}',
}
-Keystroke sequences can have </Placeholders>, most commonly C<{USERNAME}> and C<{PASSWORD}>.
-
-=attr previous_parent_group
-
-128-bit UUID identifying a group within the database.
+Keystroke sequences can have L</Placeholders>, most commonly C<{USERNAME}> and C<{PASSWORD}>.
=attr quality_check
There are methods available to provide more convenient access to binaries, including L</binary> and
L</binary_value>.
-=attr custom_data
-
-A set of key-value pairs used to store arbitrary data, usually used by software to keep track of state rather
-than by end users (who typically work with the strings and binaries).
-
=attr history
Array of historical entries. Historical entries are prior versions of the same entry so they all share the
same UUID with the current entry.
-=attr last_modification_time
-
-Date and time when the entry was last modified.
-
-=attr creation_time
-
-Date and time when the entry was created.
-
-=attr last_access_time
-
-Date and time when the entry was last accessed.
-
-=attr expiry_time
-
-Date and time when the entry expired or will expire.
-
-=attr expires
-
-Boolean value indicating whether or not an entry is expired.
-
-=attr usage_count
-
-The number of times an entry has been used, which typically means how many times the B<Password> string has
-been accessed.
-
-=attr location_changed
-
-Date and time when the entry was last moved to a different parent group.
-
=attr notes
Alias for the B<Notes> string value.
=method expand_string_value
- $string = $entry->expand_string_value;
+ $string = $entry->expand_string_value($string_key);
Same as L</string_value> but will substitute placeholders and resolve field references. Any placeholders that
do not expand to values are left as-is.
Some placeholders (notably field references) require the entry be connected to a database and will throw an
error if it is not.
+=method expand_notes
+
+Shortcut equivalent to C<< ->expand_string_value('Notes') >>.
+
+=method expand_password
+
+Shortcut equivalent to C<< ->expand_string_value('Password') >>.
+
+=method expand_title
+
+Shortcut equivalent to C<< ->expand_string_value('Title') >>.
+
+=method expand_url
+
+Shortcut equivalent to C<< ->expand_string_value('URL') >>.
+
+=method expand_username
+
+Shortcut equivalent to C<< ->expand_string_value('UserName') >>.
+
=cut
sub _expand_placeholder {
return $self->_expand_string($str);
}
-=attr expand_notes
-
-Shortcut equivalent to C<< ->expand_string_value('Notes') >>.
-
-=attr expand_password
-
-Shortcut equivalent to C<< ->expand_string_value('Password') >>.
-
-=attr expand_title
-
-Shortcut equivalent to C<< ->expand_string_value('Title') >>.
-
-=attr expand_url
-
-Shortcut equivalent to C<< ->expand_string_value('URL') >>.
-
-=attr expand_username
-
-Shortcut equivalent to C<< ->expand_string_value('UserName') >>.
-
=method other_strings
$other = $entry->other_strings;
$params{secret} = encode_b32r($params{secret}) if !$params{base32};
$params{base32} = 1;
- my $otp = eval {Pass::OTP::otp(%params, @_) };
+ my $otp = eval { Pass::OTP::otp(%params, @_) };
if (my $err = $@) {
throw 'Unable to generate HOTP', error => $err;
}
$params{secret} = encode_b32r($params{secret}) if !$params{base32};
$params{base32} = 1;
- my $otp = eval {Pass::OTP::otp(%params, @_) };
+ my $otp = eval { Pass::OTP::otp(%params, @_) };
if (my $err = $@) {
throw 'Unable to generate TOTP', error => $err;
}
my %params = (
type => 'hotp',
- issuer => $self->title || 'KDBX',
- account => $self->username || 'none',
+ issuer => $self->expand_title || 'KDBX',
+ account => $self->expand_username || 'none',
digits => 6,
counter => $self->string_value('HmacOtp-Counter') // 0,
$self->_otp_secret_params('Hmac'),
);
my %params = (
type => 'totp',
- issuer => $self->title || 'KDBX',
- account => $self->username || 'none',
+ issuer => $self->expand_title || 'KDBX',
+ account => $self->expand_username || 'none',
digits => $self->string_value('TimeOtp-Length') // 6,
algorithm => $algorithms{$self->string_value('TimeOtp-Algorithm') || ''} || 'sha1',
period => $self->string_value('TimeOtp-Period') // 30,
my $max_items = $args{max_items} // eval { $self->kdbx->history_max_items } // HISTORY_DEFAULT_MAX_ITEMS;
my $max_size = $args{max_size} // eval { $self->kdbx->history_max_size } // HISTORY_DEFAULT_MAX_SIZE;
- my $max_age = $args{max_age} // HISTORY_DEFAULT_MAX_AGE;
+ my $max_age = $args{max_age} // eval { $self->kdbx->maintenance_history_days } // HISTORY_DEFAULT_MAX_AGE;
# history is ordered oldest to newest
my $history = $self->history;
a UUID. An entry can also have an icon associated with it, and there are various timestamps. Take a look at
the attributes to see what's available.
-A B<File::KDBX::Entry> is a subclass of L<File::KDBX::Object>.
+A B<File::KDBX::Entry> is a subclass of L<File::KDBX::Object>. View its documentation to see other attributes
+and methods available on entries.
=head2 Placeholders
* ☑ C<{DT_UTC_MINUTE}> Minute Year component of the current UTC time
* ☑ C<{DT_UTC_SECOND}> - Second component of the current UTC time
-If the current date and time is <2012-07-25 17:05:34>, the "simple" form would be C<20120725170534>.
+If the current date and time is C<2012-07-25 17:05:34>, the "simple" form would be C<20120725170534>.
=head3 Special Key Placeholders
If the placeholder is expanded in the context of an entry, C<$entry> is the B<File::KDBX::Entry> object in
context. Otherwise it is C<undef>. An entry is in context if, for example, the placeholder is in an entry's
-strings or auto-complete key sequences.
+strings or auto-type key sequences.
$File::KDBX::PLACEHOLDERS{'MY_PLACEHOLDER:'} = sub {
my ($entry, $arg) = @_; # ^ Notice the colon here