line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Deep::JWT; |
2
|
2
|
|
|
2
|
|
29688
|
use 5.008005; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
51
|
|
5
|
2
|
|
|
2
|
|
899
|
use MIME::Base64 qw(decode_base64url); |
|
2
|
|
|
|
|
1083
|
|
|
2
|
|
|
|
|
125
|
|
6
|
2
|
|
|
2
|
|
616
|
use JSON qw(decode_json); |
|
2
|
|
|
|
|
9419
|
|
|
2
|
|
|
|
|
8
|
|
7
|
2
|
|
|
2
|
|
764
|
use Test::Deep (); |
|
2
|
|
|
|
|
8509
|
|
|
2
|
|
|
|
|
53
|
|
8
|
2
|
|
|
2
|
|
1539
|
use Test::Deep::Cmp; |
|
2
|
|
|
|
|
1506
|
|
|
2
|
|
|
|
|
11
|
|
9
|
2
|
|
|
2
|
|
101
|
use Exporter qw(import); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
661
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw(jwt); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub jwt { |
16
|
6
|
|
|
6
|
1
|
19593
|
my ($claims, $header) = @_; |
17
|
6
|
|
|
|
|
26
|
return __PACKAGE__->new($claims, $header); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init { |
21
|
6
|
|
|
6
|
0
|
28
|
my ($self, $claims, $header) = @_; |
22
|
6
|
|
|
|
|
57
|
$self->{claims} = $claims; |
23
|
6
|
|
|
|
|
12
|
$self->{header} = $header; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub descend { |
27
|
6
|
|
|
6
|
0
|
467
|
my ($self, $got) = @_; |
28
|
6
|
|
|
|
|
8
|
my ($header, $claims) = eval { |
29
|
6
|
|
|
|
|
19
|
my ($header, $claims, $sig) = split /\./, $got; |
30
|
|
|
|
|
|
|
return ( |
31
|
6
|
|
|
|
|
14
|
decode_json(decode_base64url($header)), |
32
|
|
|
|
|
|
|
decode_json(decode_base64url($claims)) |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
}; |
35
|
6
|
100
|
|
|
|
142
|
if (my $e = $@) { |
36
|
1
|
|
|
|
|
3
|
$self->{error} = $e; |
37
|
1
|
|
|
|
|
2
|
return 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
5
|
my $header_ok = 1; |
41
|
5
|
100
|
|
|
|
12
|
if ($self->{header}) { |
42
|
1
|
|
|
|
|
3
|
$header_ok = Test::Deep::wrap($self->{header})->descend($header); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
66
|
|
|
547
|
return Test::Deep::wrap($self->{claims})->descend($claims) && $header_ok; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub diagnostics { |
49
|
1
|
|
|
1
|
0
|
129
|
my ($self) = @_; |
50
|
1
|
50
|
|
|
|
5
|
return $self->{error} if $self->{error}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |