Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php
10262 views
1
<?php
2
3
namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;
4
5
use Lcobucci\JWT\ClaimsFormatter;
6
use Lcobucci\JWT\Token\RegisteredClaims;
7
8
final class TimestampDates implements ClaimsFormatter
9
{
10
/**
11
* The default time encoder for JWTs using this library is not supported correctly
12
* by Wings and will cause a flood of errors and panic conditions because the times
13
* cannot be parsed correctly. The default is time with microseconds, we just need
14
* to use the normal unix timestamp here.
15
*/
16
public function formatClaims(array $claims): array
17
{
18
foreach (RegisteredClaims::DATE_CLAIMS as $claim) {
19
if (!array_key_exists($claim, $claims)) {
20
continue;
21
}
22
23
assert($claims[$claim] instanceof \DateTimeImmutable);
24
$claims[$claim] = $claims[$claim]->getTimestamp();
25
}
26
27
return $claims;
28
}
29
}
30
31