-my %ATTRS = (
- device => 0,
- slot => 1,
- timeout => 10,
- pre_challenge => undef,
- post_challenge => undef,
- ykchalresp => sub { $ENV{YKCHALRESP} || 'ykchalresp' },
- ykinfo => sub { $ENV{YKINFO} || 'ykinfo' },
-);
-while (my ($subname, $default) = each %ATTRS) {
- no strict 'refs'; ## no critic (ProhibitNoStrict)
- *{$subname} = sub {
- my $self = shift;
- $self->{$subname} = shift if @_;
- $self->{$subname} //= (ref $default eq 'CODE') ? $default->($self) : $default;
- };
-}
-
-my %INFO = (
- serial => undef,
- version => undef,
- touch_level => undef,
- vendor_id => undef,
- product_id => undef,
-);
-while (my ($subname, $default) = each %INFO) {
- no strict 'refs'; ## no critic (ProhibitNoStrict)
- *{$subname} = sub {
- my $self = shift;
- $self->{$subname} = shift if @_;
- defined $self->{$subname} or $self->_set_yubikey_info;
- $self->{$subname} // $default;
- };
-}
+has device => 0;
+has slot => 1;
+has timeout => 10;
+has pre_challenge => undef;
+has post_challenge => undef;
+has ykchalresp => sub { $ENV{YKCHALRESP} || 'ykchalresp' };
+has ykinfo => sub { $ENV{YKINFO} || 'ykinfo' };