2021-01-23 20:09:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;
|
|
|
|
|
|
|
|
use Lcobucci\JWT\ClaimsFormatter;
|
|
|
|
use Lcobucci\JWT\Token\RegisteredClaims;
|
|
|
|
|
|
|
|
final class TimestampDates implements ClaimsFormatter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The default time encoder for JWTs using this library is not supported correctly
|
|
|
|
* by Wings and will cause a flood of errors and panic conditions because the times
|
|
|
|
* cannot be parsed correctly. The default is time with microseconds, we just need
|
|
|
|
* to use the normal unix timestamp here.
|
|
|
|
*/
|
|
|
|
public function formatClaims(array $claims): array
|
|
|
|
{
|
|
|
|
foreach (RegisteredClaims::DATE_CLAIMS as $claim) {
|
2021-01-23 20:33:34 +00:00
|
|
|
if (!array_key_exists($claim, $claims)) {
|
2021-01-23 20:09:16 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-29 17:53:59 +00:00
|
|
|
assert($claims[$claim] instanceof \DateTimeImmutable);
|
2021-01-23 20:09:16 +00:00
|
|
|
$claims[$claim] = $claims[$claim]->getTimestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $claims;
|
|
|
|
}
|
|
|
|
}
|