Path: blob/1.0-develop/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php
10262 views
<?php12namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;34use Lcobucci\JWT\ClaimsFormatter;5use Lcobucci\JWT\Token\RegisteredClaims;67final class TimestampDates implements ClaimsFormatter8{9/**10* The default time encoder for JWTs using this library is not supported correctly11* by Wings and will cause a flood of errors and panic conditions because the times12* cannot be parsed correctly. The default is time with microseconds, we just need13* to use the normal unix timestamp here.14*/15public function formatClaims(array $claims): array16{17foreach (RegisteredClaims::DATE_CLAIMS as $claim) {18if (!array_key_exists($claim, $claims)) {19continue;20}2122assert($claims[$claim] instanceof \DateTimeImmutable);23$claims[$claim] = $claims[$claim]->getTimestamp();24}2526return $claims;27}28}293031