friendship ended with social-app. php is my new best friend
at main 2.2 kB view raw
1<?php 2declare(strict_types=1); 3 4namespace Lcobucci\JWT; 5 6use DateTimeImmutable; 7use Lcobucci\JWT\Encoding\CannotEncodeContent; 8use Lcobucci\JWT\Signer\CannotSignPayload; 9use Lcobucci\JWT\Signer\Ecdsa\ConversionFailed; 10use Lcobucci\JWT\Signer\InvalidKeyProvided; 11use Lcobucci\JWT\Signer\Key; 12use Lcobucci\JWT\Token\RegisteredClaimGiven; 13 14/** @immutable */ 15interface Builder 16{ 17 /** 18 * Appends new items to audience 19 * 20 * @param non-empty-string ...$audiences 21 */ 22 public function permittedFor(string ...$audiences): Builder; 23 24 /** 25 * Configures the expiration time 26 */ 27 public function expiresAt(DateTimeImmutable $expiration): Builder; 28 29 /** 30 * Configures the token id 31 * 32 * @param non-empty-string $id 33 */ 34 public function identifiedBy(string $id): Builder; 35 36 /** 37 * Configures the time that the token was issued 38 */ 39 public function issuedAt(DateTimeImmutable $issuedAt): Builder; 40 41 /** 42 * Configures the issuer 43 * 44 * @param non-empty-string $issuer 45 */ 46 public function issuedBy(string $issuer): Builder; 47 48 /** 49 * Configures the time before which the token cannot be accepted 50 */ 51 public function canOnlyBeUsedAfter(DateTimeImmutable $notBefore): Builder; 52 53 /** 54 * Configures the subject 55 * 56 * @param non-empty-string $subject 57 */ 58 public function relatedTo(string $subject): Builder; 59 60 /** 61 * Configures a header item 62 * 63 * @param non-empty-string $name 64 */ 65 public function withHeader(string $name, mixed $value): Builder; 66 67 /** 68 * Configures a claim item 69 * 70 * @param non-empty-string $name 71 * 72 * @throws RegisteredClaimGiven When trying to set a registered claim. 73 */ 74 public function withClaim(string $name, mixed $value): Builder; 75 76 /** 77 * Returns a signed token to be used 78 * 79 * @throws CannotEncodeContent When data cannot be converted to JSON. 80 * @throws CannotSignPayload When payload signing fails. 81 * @throws InvalidKeyProvided When issue key is invalid/incompatible. 82 * @throws ConversionFailed When signature could not be converted. 83 */ 84 public function getToken(Signer $signer, Key $key): UnencryptedToken; 85}