line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pass::OTP::URI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Pass::OTP::URI - Parse otpauth:// URI |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Pass::OTP::URI qw(parse); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $uri = "otpauth://totp/ACME:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME&digits=6"; |
14
|
|
|
|
|
|
|
my %options = parse($uri); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
1203
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
19
|
1
|
|
|
1
|
|
39
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
22
|
|
20
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
303
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require Exporter; |
23
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
24
|
|
|
|
|
|
|
our @EXPORT_OK = qw(parse); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 FUNCTIONS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 4 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item parse($uri) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub parse { |
35
|
2
|
|
|
2
|
1
|
1176
|
my ($uri) = @_; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
5
|
my %options = ( |
38
|
|
|
|
|
|
|
base32 => 1, |
39
|
|
|
|
|
|
|
); |
40
|
2
|
|
|
|
|
29
|
($options{type}, $options{label}, my $params) = $uri =~ m#^otpauth://([th]otp)/((?:[^:?]+(?::|%3A))?[^:?]+)\?(.*)#; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
9
|
foreach my $param (split(/&/, $params)) { |
43
|
4
|
|
|
|
|
7
|
my ($option, $value) = split(/=/, $param); |
44
|
4
|
|
|
|
|
12
|
$options{$option} = $value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
15
|
return (%options); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Copyright (C) 2020 Jan Baier |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
63
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
64
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
See L for more information. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |