| 1 | package SignalWire::Security::SessionManager; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use JSON (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Digest::SHA qw(hmac_sha256_hex); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use MIME::Base64 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | has 'token_expiry_secs' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | default => sub { 900 }, # 15 minutes | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 40 | ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | has 'secret_key' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 418 | ▶ | default => sub { _random_hex(32) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | has '_debug_mode' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 21 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 424 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 40 | ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 427 | ▶ | sub _random_hex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_hex: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 427 | my ($len) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 27 | # Use /dev/urandom for cryptographically secure random bytes. | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # Die on failure rather than falling back to weak randomness. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 427 | ▶ | if (open my $fh, '<:raw', '/dev/urandom') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 427 | my $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 427 | my $read = read($fh, $bytes, $len); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 427 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 427 | ▶ | if (defined $read && $read == $len) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $read and $read == $len
MC/DC0%0/2
defined $read and $read == $len
defined $read
$read == $len
Truth table33%1/3
A and B
A= defined $readB= $read == $len
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 427 | return unpack('H*', $bytes); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | die "FATAL: Cannot generate secure random bytes - /dev/urandom unavailable. " | |||||||||||||||||||||||||||||||||||||||||
| 38 | . "This is required for session security.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub _random_urlsafe { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random_urlsafe: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | my ($len) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | my $bytes = ''; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | for (1 .. $len) { | |||||||||||||||||||||||||||||||||||||||||
| 45 | 16 | $bytes .= chr(int(rand(256))); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | return MIME::Base64::encode_base64url($bytes, ''); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | sub create_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_session: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | my ($self, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | $call_id //= _random_urlsafe(16); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$call_id //= _random_urlsafe(16)
MC/DC0%0/2
$call_id //= _random_urlsafe(16)
$call_id
_random_urlsafe(16)
Truth table66%2/3
A //= B
A= $call_idB= _random_urlsafe(16)
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | return $call_id; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | sub generate_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | my ($self, $function_name, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | my $expiry = int(time()) + $self->token_expiry_secs; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 9 | my $nonce = _random_hex(8); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 9 | my $message = "$call_id:$function_name:$expiry:$nonce"; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 9 | my $signature = hmac_sha256_hex($message, $self->secret_key); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | my $token = "$call_id.$function_name.$expiry.$nonce.$signature"; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | return MIME::Base64::encode_base64url($token, ''); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | # Alias | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | sub create_tool_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_tool_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my ($self, $function_name, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | return $self->generate_token($function_name, $call_id); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 29 | ▶ | sub _timing_safe_compare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timing_safe_compare: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 29 | my ($a, $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | # Compare HMAC of both values for constant-time comparison | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 29 | my $key = 'timing-safe-token-comparison'; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 29 | my $hmac_a = hmac_sha256_hex($a, $key); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 29 | my $hmac_b = hmac_sha256_hex($b, $key); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 29 | return $hmac_a eq $hmac_b; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 15 | ▶ | sub validate_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_token: called CC=13 SCAR=26.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 15 | my ($self, $call_id, $function_name, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 15 | ▶ | return 0 unless $call_id && $function_name && $token; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$call_id and $function_name and $token
$call_id and $function_name
MC/DC66%2/3
$call_id and $function_name and $token
$call_id
$function_name
$token
Truth table75%3/4
A and B and C
A= $call_idB= $function_nameC= $token
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | my $decoded; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 90 | 12 | $decoded = MIME::Base64::decode_base64url($token); | |||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 12 | ▶ | return 0 if $@ || !$decoded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not $decoded
MC/DC0%0/2
$@ or not $decoded
$@
not $decoded
Truth table33%1/3
A or not(B)
A= $@B= not $decoded
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 12 | my @parts = split(/\./, $decoded); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 12 | ▶ | return 0 unless @parts == 5; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | my ($token_call_id, $token_function, $token_expiry, $token_nonce, $token_signature) = @parts; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | # Verify function matches | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | return 0 unless _timing_safe_compare($token_function, $function_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | # Check expiry | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 9 | my $expiry = eval { int($token_expiry) }; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 9 | ▶ | return 0 if $@ || !defined $expiry; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not defined $expiry
MC/DC0%0/2
$@ or not defined $expiry
$@
not defined $expiry
Truth table33%1/3
A or not(B)
A= $@B= not defined $expiry
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 9 | ▶ | return 0 if $expiry < time(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # Recreate and verify signature | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | my $message = "$token_call_id:$token_function:$token_expiry:$token_nonce"; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | my $expected_signature = hmac_sha256_hex($message, $self->secret_key); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | ▶ | return 0 unless _timing_safe_compare($token_signature, $expected_signature); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # Verify call_id | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | ▶ | return 0 unless _timing_safe_compare($token_call_id, $call_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # Alias with different parameter order for backward compat | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | sub validate_tool_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_tool_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | my ($self, $function_name, $token, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | return $self->validate_token($call_id, $function_name, $token); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Legacy methods - no-ops for API compat (mirroring Python's | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # stateless SessionManager.activate_session/end_session/etc. which | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # accept the args, validate they're present, and return success). | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | sub activate_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
activate_session: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | my ($self, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | sub end_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_session: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | my ($self, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | ▶ | sub get_session_metadata { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_session_metadata: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | my ($self, $call_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | ▶ | sub set_session_metadata { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_session_metadata: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | my ($self, $call_id, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | sub debug_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_token: called CC=13 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | ▶ | return { error => 'debug mode not enabled' } unless $self->_debug_mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my $decoded; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | eval { $decoded = MIME::Base64::decode_base64url($token) }; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ▶ | if ($@ || !$decoded) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not $decoded
MC/DC0%0/2
$@ or not $decoded
$@
not $decoded
Truth table33%1/3
A or not(B)
A= $@B= not $decoded
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | valid_format => JSON::false, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ // "decode failed"
MC/DC0%0/1
$@ // "decode failed"
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | error => $@ // 'decode failed', | ||||||||||||||||||||||||||||||||||||||||||
| 157 | token_length => defined $token ? length($token) : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my @parts = split(/\./, $decoded); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | ▶ | if (@parts != 5) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | valid_format => JSON::false, | |||||||||||||||||||||||||||||||||||||||||
| 165 | parts_count => scalar @parts, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | token_length => length($token), | ||||||||||||||||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | my ($tc, $tf, $te, $tn, $ts) = @parts; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | my $current = int(time()); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my $expiry = eval { int($te) }; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ▶ | my $expired = defined $expiry ? ($expiry < $current ? 1 : 0) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | valid_format => JSON::true, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
defined $expiry and not $expired
MC/DC0%0/2
defined $expiry and not $expired
defined $expiry
not $expired
Truth table33%1/3
A and not(B)
A= defined $expiryB= not $expired
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | components => { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | call_id => (length($tc) > 8 ? substr($tc, 0, 8) . '...' : $tc), | ||||||||||||||||||||||||||||||||||||||||||
| 179 | function => $tf, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | expiry => $te, | ||||||||||||||||||||||||||||||||||||||||||
| 181 | nonce => $tn, | ||||||||||||||||||||||||||||||||||||||||||
| 182 | signature => (length($ts) > 8 ? substr($ts, 0, 8) . '...' : $ts), | ||||||||||||||||||||||||||||||||||||||||||
| 183 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | status => { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | current_time => $current, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | is_expired => $expired, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | expires_in_seconds => (defined $expiry && !$expired ? $expiry - $current : 0), | ||||||||||||||||||||||||||||||||||||||||||
| 188 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||