aegisvault 0.4.13

Convert otpauth-URI file to Encrypted Aegis JSON on stdout
Documentation
#!/usr/bin/perl
# Convert otpauth URIs into clear text Aegis vault format
# Copyright       : https://www.fsf.org/copyleft/gpl.html
# Author          : Dan Jacobson -- https://www.jidanni.org/
# Created On      : Wed Apr  8 08:59:06 2020
# Last Modified On: Thu Apr  9 21:19:27 2020
# Update Count    : 138
use strict;
use warnings FATAL => q(all);
use JSON;
use URI;
use URI::QueryParam;
use UUID 'uuid';
binmode STDOUT;
my %h = (
	db     => { version => 3 },
	header => {
		params => undef,
		slots  => undef
	},
	version => 1,
);
while (<>) {
	next unless /otpauth:.*/;
	my $u = URI->new($&);
	push @{ $h{db}->{entries} }, {
		icon => undef,
		info => {
			algorithm => "SHA1",
			period => 30,
			digits => 6,
			secret => $u->query_param('secret'),
		},
		name => ( $u->path_segments )[-1],
		issuer => ( $u->path_segments )[-1],
		type => $u->authority,
		uuid => uuid(),
		note => "",
		favorite => JSON::false,
		groups => undef,
	 };
}
for ( @{ $h{db}->{entries} } ) {
	$_->{info}->{digits} += 0;
	$_->{info}->{period} += 0;
}
my $json = JSON->new;
$json = $json->canonical(1);
print $json->pretty->encode( \%h );