line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Deep::JWT; |
2
|
2
|
|
|
2
|
|
39581
|
use 5.008005; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
79
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
915
|
use MIME::Base64 qw(decode_base64url); |
|
2
|
|
|
|
|
1201
|
|
|
2
|
|
|
|
|
122
|
|
6
|
2
|
|
|
2
|
|
624
|
use JSON qw(decode_json); |
|
2
|
|
|
|
|
9783
|
|
|
2
|
|
|
|
|
9
|
|
7
|
2
|
|
|
2
|
|
749
|
use Test::Deep (); |
|
2
|
|
|
|
|
6841
|
|
|
2
|
|
|
|
|
47
|
|
8
|
2
|
|
|
2
|
|
1192
|
use Test::Deep::Cmp; |
|
2
|
|
|
|
|
1149
|
|
|
2
|
|
|
|
|
9
|
|
9
|
2
|
|
|
2
|
|
81
|
use Exporter qw(import); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
480
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw(jwt); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub jwt { |
16
|
6
|
|
|
6
|
1
|
20281
|
my ($claims, $header) = @_; |
17
|
6
|
|
|
|
|
28
|
return __PACKAGE__->new($claims, $header); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init { |
21
|
6
|
|
|
6
|
0
|
27
|
my ($self, $claims, $header) = @_; |
22
|
6
|
|
|
|
|
58
|
$self->{claims} = $claims; |
23
|
6
|
|
|
|
|
14
|
$self->{header} = $header; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub descend { |
27
|
6
|
|
|
6
|
0
|
456
|
my ($self, $got) = @_; |
28
|
6
|
|
|
|
|
6
|
my ($header, $claims) = eval { |
29
|
6
|
|
|
|
|
20
|
my ($header, $claims, $sig) = split /\./, $got; |
30
|
|
|
|
|
|
|
return ( |
31
|
6
|
|
|
|
|
16
|
decode_json(decode_base64url($header)), |
32
|
|
|
|
|
|
|
decode_json(decode_base64url($claims)) |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
}; |
35
|
6
|
100
|
|
|
|
126
|
if (my $e = $@) { |
36
|
1
|
|
|
|
|
3
|
$self->{error} = $e; |
37
|
1
|
|
|
|
|
2
|
return 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
6
|
my $header_ok = 1; |
41
|
5
|
100
|
|
|
|
11
|
if ($self->{header}) { |
42
|
1
|
|
|
|
|
3
|
$header_ok = Test::Deep::wrap($self->{header})->descend($header); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
66
|
|
|
542
|
return Test::Deep::wrap($self->{claims})->descend($claims) && $header_ok; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub diagnostics { |
49
|
1
|
|
|
1
|
0
|
131
|
my ($self) = @_; |
50
|
1
|
50
|
|
|
|
4
|
return $self->{error} if $self->{error}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |