One Hat Cyber Team
Your IP:
216.73.216.102
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
home
/
fluxyjvi
/
www
/
assets
/
images
/
View File Name :
Token.tar
DataSet.php 0000644 00000001554 15107326404 0006611 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use function array_key_exists; final class DataSet { /** @var array<string, mixed> */ private array $data; private string $encoded; /** @param mixed[] $data */ public function __construct(array $data, string $encoded) { $this->data = $data; $this->encoded = $encoded; } /** * @param mixed|null $default * * @return mixed|null */ public function get(string $name, $default = null) { return $this->data[$name] ?? $default; } public function has(string $name): bool { return array_key_exists($name, $this->data); } /** @return mixed[] */ public function all(): array { return $this->data; } public function toString(): string { return $this->encoded; } } RegisteredClaimGiven.php 0000644 00000001063 15107326404 0011313 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use InvalidArgumentException; use Lcobucci\JWT\Exception; use function sprintf; final class RegisteredClaimGiven extends InvalidArgumentException implements Exception { private const DEFAULT_MESSAGE = 'Builder#withClaim() is meant to be used for non-registered claims, ' . 'check the documentation on how to set claim "%s"'; public static function forClaim(string $name): self { return new self(sprintf(self::DEFAULT_MESSAGE, $name)); } } Plain.php 0000644 00000004347 15107326404 0006332 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use DateTimeInterface; use Lcobucci\JWT\Token as TokenInterface; use function in_array; final class Plain implements TokenInterface { private DataSet $headers; private DataSet $claims; private Signature $signature; public function __construct( DataSet $headers, DataSet $claims, Signature $signature ) { $this->headers = $headers; $this->claims = $claims; $this->signature = $signature; } public function headers(): DataSet { return $this->headers; } public function claims(): DataSet { return $this->claims; } public function signature(): Signature { return $this->signature; } public function payload(): string { return $this->headers->toString() . '.' . $this->claims->toString(); } public function isPermittedFor(string $audience): bool { return in_array($audience, $this->claims->get(RegisteredClaims::AUDIENCE, []), true); } public function isIdentifiedBy(string $id): bool { return $this->claims->get(RegisteredClaims::ID) === $id; } public function isRelatedTo(string $subject): bool { return $this->claims->get(RegisteredClaims::SUBJECT) === $subject; } public function hasBeenIssuedBy(string ...$issuers): bool { return in_array($this->claims->get(RegisteredClaims::ISSUER), $issuers, true); } public function hasBeenIssuedBefore(DateTimeInterface $now): bool { return $now >= $this->claims->get(RegisteredClaims::ISSUED_AT); } public function isMinimumTimeBefore(DateTimeInterface $now): bool { return $now >= $this->claims->get(RegisteredClaims::NOT_BEFORE); } public function isExpired(DateTimeInterface $now): bool { if (! $this->claims->has(RegisteredClaims::EXPIRATION_TIME)) { return false; } return $now >= $this->claims->get(RegisteredClaims::EXPIRATION_TIME); } public function toString(): string { return $this->headers->toString() . '.' . $this->claims->toString() . '.' . $this->signature->toString(); } } RegisteredClaims.php 0000644 00000003533 15107326404 0010511 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; /** * Defines the list of claims that are registered in the IANA "JSON Web Token Claims" registry * * @see https://tools.ietf.org/html/rfc7519#section-4.1 */ interface RegisteredClaims { public const ALL = [ self::AUDIENCE, self::EXPIRATION_TIME, self::ID, self::ISSUED_AT, self::ISSUER, self::NOT_BEFORE, self::SUBJECT, ]; public const DATE_CLAIMS = [ self::ISSUED_AT, self::NOT_BEFORE, self::EXPIRATION_TIME, ]; /** * Identifies the recipients that the JWT is intended for * * @see https://tools.ietf.org/html/rfc7519#section-4.1.3 */ public const AUDIENCE = 'aud'; /** * Identifies the expiration time on or after which the JWT MUST NOT be accepted for processing * * @see https://tools.ietf.org/html/rfc7519#section-4.1.4 */ public const EXPIRATION_TIME = 'exp'; /** * Provides a unique identifier for the JWT * * @see https://tools.ietf.org/html/rfc7519#section-4.1.7 */ public const ID = 'jti'; /** * Identifies the time at which the JWT was issued * * @see https://tools.ietf.org/html/rfc7519#section-4.1.6 */ public const ISSUED_AT = 'iat'; /** * Identifies the principal that issued the JWT * * @see https://tools.ietf.org/html/rfc7519#section-4.1.1 */ public const ISSUER = 'iss'; /** * Identifies the time before which the JWT MUST NOT be accepted for processing * * https://tools.ietf.org/html/rfc7519#section-4.1.5 */ public const NOT_BEFORE = 'nbf'; /** * Identifies the principal that is the subject of the JWT. * * https://tools.ietf.org/html/rfc7519#section-4.1.2 */ public const SUBJECT = 'sub'; } Signature.php 0000644 00000001141 15107326404 0007215 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; final class Signature { private string $hash; private string $encoded; public function __construct(string $hash, string $encoded) { $this->hash = $hash; $this->encoded = $encoded; } public static function fromEmptyData(): self { return new self('', ''); } public function hash(): string { return $this->hash; } /** * Returns the encoded version of the signature */ public function toString(): string { return $this->encoded; } } Builder.php 0000644 00000007200 15107326404 0006644 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use DateTimeImmutable; use Lcobucci\JWT\Builder as BuilderInterface; use Lcobucci\JWT\ClaimsFormatter; use Lcobucci\JWT\Encoder; use Lcobucci\JWT\Encoding\CannotEncodeContent; use Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer\Key; use function array_diff; use function array_merge; use function in_array; final class Builder implements BuilderInterface { /** @var array<string, mixed> */ private array $headers = ['typ' => 'JWT', 'alg' => null]; /** @var array<string, mixed> */ private array $claims = []; private Encoder $encoder; private ClaimsFormatter $claimFormatter; public function __construct(Encoder $encoder, ClaimsFormatter $claimFormatter) { $this->encoder = $encoder; $this->claimFormatter = $claimFormatter; } public function permittedFor(string ...$audiences): BuilderInterface { $configured = $this->claims[RegisteredClaims::AUDIENCE] ?? []; $toAppend = array_diff($audiences, $configured); return $this->setClaim(RegisteredClaims::AUDIENCE, array_merge($configured, $toAppend)); } public function expiresAt(DateTimeImmutable $expiration): BuilderInterface { return $this->setClaim(RegisteredClaims::EXPIRATION_TIME, $expiration); } public function identifiedBy(string $id): BuilderInterface { return $this->setClaim(RegisteredClaims::ID, $id); } public function issuedAt(DateTimeImmutable $issuedAt): BuilderInterface { return $this->setClaim(RegisteredClaims::ISSUED_AT, $issuedAt); } public function issuedBy(string $issuer): BuilderInterface { return $this->setClaim(RegisteredClaims::ISSUER, $issuer); } public function canOnlyBeUsedAfter(DateTimeImmutable $notBefore): BuilderInterface { return $this->setClaim(RegisteredClaims::NOT_BEFORE, $notBefore); } public function relatedTo(string $subject): BuilderInterface { return $this->setClaim(RegisteredClaims::SUBJECT, $subject); } /** @inheritdoc */ public function withHeader(string $name, $value): BuilderInterface { $this->headers[$name] = $value; return $this; } /** @inheritdoc */ public function withClaim(string $name, $value): BuilderInterface { if (in_array($name, RegisteredClaims::ALL, true)) { throw RegisteredClaimGiven::forClaim($name); } return $this->setClaim($name, $value); } /** @param mixed $value */ private function setClaim(string $name, $value): BuilderInterface { $this->claims[$name] = $value; return $this; } /** * @param array<string, mixed> $items * * @throws CannotEncodeContent When data cannot be converted to JSON. */ private function encode(array $items): string { return $this->encoder->base64UrlEncode( $this->encoder->jsonEncode($items) ); } public function getToken(Signer $signer, Key $key): Plain { $headers = $this->headers; $headers['alg'] = $signer->algorithmId(); $encodedHeaders = $this->encode($headers); $encodedClaims = $this->encode($this->claimFormatter->formatClaims($this->claims)); $signature = $signer->sign($encodedHeaders . '.' . $encodedClaims, $key); $encodedSignature = $this->encoder->base64UrlEncode($signature); return new Plain( new DataSet($headers, $encodedHeaders), new DataSet($this->claims, $encodedClaims), new Signature($signature, $encodedSignature) ); } } InvalidTokenStructure.php 0000644 00000001177 15107326404 0011575 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use InvalidArgumentException; use Lcobucci\JWT\Exception; final class InvalidTokenStructure extends InvalidArgumentException implements Exception { public static function missingOrNotEnoughSeparators(): self { return new self('The JWT string must have two dots'); } public static function arrayExpected(string $part): self { return new self($part . ' must be an array'); } public static function dateIsNotParseable(string $value): self { return new self('Value is not in the allowed date format: ' . $value); } } Parser.php 0000644 00000010053 15107326404 0006512 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use DateTimeImmutable; use Lcobucci\JWT\Decoder; use Lcobucci\JWT\Parser as ParserInterface; use Lcobucci\JWT\Token as TokenInterface; use function array_key_exists; use function count; use function explode; use function is_array; use function is_numeric; use function number_format; final class Parser implements ParserInterface { private const MICROSECOND_PRECISION = 6; private Decoder $decoder; public function __construct(Decoder $decoder) { $this->decoder = $decoder; } public function parse(string $jwt): TokenInterface { [$encodedHeaders, $encodedClaims, $encodedSignature] = $this->splitJwt($jwt); $header = $this->parseHeader($encodedHeaders); return new Plain( new DataSet($header, $encodedHeaders), new DataSet($this->parseClaims($encodedClaims), $encodedClaims), $this->parseSignature($header, $encodedSignature) ); } /** * Splits the JWT string into an array * * @return string[] * * @throws InvalidTokenStructure When JWT doesn't have all parts. */ private function splitJwt(string $jwt): array { $data = explode('.', $jwt); if (count($data) !== 3) { throw InvalidTokenStructure::missingOrNotEnoughSeparators(); } return $data; } /** * Parses the header from a string * * @return mixed[] * * @throws UnsupportedHeaderFound When an invalid header is informed. * @throws InvalidTokenStructure When parsed content isn't an array. */ private function parseHeader(string $data): array { $header = $this->decoder->jsonDecode($this->decoder->base64UrlDecode($data)); if (! is_array($header)) { throw InvalidTokenStructure::arrayExpected('headers'); } if (array_key_exists('enc', $header)) { throw UnsupportedHeaderFound::encryption(); } if (! array_key_exists('typ', $header)) { $header['typ'] = 'JWT'; } return $header; } /** * Parses the claim set from a string * * @return mixed[] * * @throws InvalidTokenStructure When parsed content isn't an array or contains non-parseable dates. */ private function parseClaims(string $data): array { $claims = $this->decoder->jsonDecode($this->decoder->base64UrlDecode($data)); if (! is_array($claims)) { throw InvalidTokenStructure::arrayExpected('claims'); } if (array_key_exists(RegisteredClaims::AUDIENCE, $claims)) { $claims[RegisteredClaims::AUDIENCE] = (array) $claims[RegisteredClaims::AUDIENCE]; } foreach (RegisteredClaims::DATE_CLAIMS as $claim) { if (! array_key_exists($claim, $claims)) { continue; } $claims[$claim] = $this->convertDate($claims[$claim]); } return $claims; } /** * @param int|float|string $timestamp * * @throws InvalidTokenStructure */ private function convertDate($timestamp): DateTimeImmutable { if (! is_numeric($timestamp)) { throw InvalidTokenStructure::dateIsNotParseable($timestamp); } $normalizedTimestamp = number_format((float) $timestamp, self::MICROSECOND_PRECISION, '.', ''); $date = DateTimeImmutable::createFromFormat('U.u', $normalizedTimestamp); if ($date === false) { throw InvalidTokenStructure::dateIsNotParseable($normalizedTimestamp); } return $date; } /** * Returns the signature from given data * * @param mixed[] $header */ private function parseSignature(array $header, string $data): Signature { if ($data === '' || ! array_key_exists('alg', $header) || $header['alg'] === 'none') { return Signature::fromEmptyData(); } $hash = $this->decoder->base64UrlDecode($data); return new Signature($hash, $data); } } UnsupportedHeaderFound.php 0000644 00000000515 15107326404 0011715 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Token; use InvalidArgumentException; use Lcobucci\JWT\Exception; final class UnsupportedHeaderFound extends InvalidArgumentException implements Exception { public static function encryption(): self { return new self('Encryption is not supported yet'); } }