1. Go to this page and download the library: Download k2gl/token-status-list library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k2gl / token-status-list example snippets
use K2gl\Dsse\PublicKey;
use K2gl\TokenStatusList\StatusListResolver;
use K2gl\TokenStatusList\StatusReference;
$resolver = new StatusListResolver(
httpClient: $psr18Client,
requestFactory: $psr17RequestFactory,
key: PublicKey::fromPem($issuerPublicKeyPem),
cache: $psr16Cache, // optional
);
// $payload is the verified Referenced Token's claims — e.g. VerifiedSdJwtVc::status()
$reference = StatusReference::fromClaim($payload->status);
$status = $resolver->check($reference);
$status->isValid(); // 0x00
$status->isInvalid(); // 0x01 — revoked
$status->isSuspended(); // 0x02
$status->value; // the raw value, for application-specific statuses
use K2gl\TokenStatusList\KeyResolver;
final class IssuerKeys implements KeyResolver
{
public function resolve(stdClass $header, stdClass $payload): Verifier
{
return $this->jwks->find($header->kid ?? null) ?? throw new TokenStatusListException('Unknown kid.');
}
}
use K2gl\Dsse\EcdsaP256Signer;
use K2gl\TokenStatusList\Status;
use K2gl\TokenStatusList\StatusList;
use K2gl\TokenStatusList\StatusListTokenIssuer;
$list = StatusList::create(size: 100_000, bits: 1);
$list->set(42, Status::invalid());
$issuer = new StatusListTokenIssuer(EcdsaP256Signer::fromPem($privateKeyPem, keyId: '12'));
$compact = $issuer->issue(
uri: 'https://example.com/statuslists/1',
statusList: $list,
expiresAt: time() + 7 * 86400,
ttl: 43200,
);
// serve $compact as application/statuslist+jwt at that URI
use K2gl\TokenStatusList\StatusReference;
$claims['status'] = (new StatusReference('https://example.com/statuslists/1', index: 42))->toClaim();
// {"status_list": {"idx": 42, "uri": "https://example.com/statuslists/1"}}
use K2gl\TokenStatusList\StatusListTokenVerifier;
$verifier = new StatusListTokenVerifier(
allowedAlgorithms: ['ES256'], // default: ES256/384/512, EdDSA, RS256/384/512
clockLeewaySeconds: 60,
);
$token = $verifier->verify($compact, $issuerKey, expectedUri: $reference->uri);
$token->status($reference); // Status
$token->statusList(); // StatusList — get(), count(), bits()
$token->freshUntil(time()); // when to fetch again, from ttl and exp
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.