Cliente JWT

Genera, firma y verifica JSON Web Tokens desde Delphi/C++Builder. Firmas HMAC, RSA y ECDSA, JWE cifrados al estilo PASETO, refresco automático y fácil integración con TsgcHTTP2Client / TsgcHTTPComponentClient.

TsgcHTTP_JWT_Client

Sign HS256/HS384/HS512, RS256/RS384/RS512, ES256/ES384, EdDSA tokens; decode incoming JWTs; auto-refresh near expiry; pair with the HTTP and HTTP/2 clients via Authentication.Token.JWT.

Clase del componente

TsgcHTTP_JWT_Client

Protocolo

RFC 7519 (JWT)

Plataformas

Windows, macOS, Linux, iOS, Android

Edición

Professional / Enterprise

Configura header + payload, firma y enlaza

Set Header.alg, Payload.iss / iat / exp, load the signing key, then attach the JWT client to your HTTP / HTTP/2 / WebSocket component as the bearer-token source.

uses
  sgcHTTP, sgcBase_Helpers;

var
  JWT: TsgcHTTP_JWT_Client;
begin
  JWT := TsgcHTTP_JWT_Client.Create(nil);
  JWT.JWTOptions.Header.alg := jwtES256;
  JWT.JWTOptions.Header.kid := 'apple-key-id';
  JWT.JWTOptions.Payload.iss := 'team-id';
  JWT.JWTOptions.Payload.iat := StrToInt64(GetDateTimeUnix(Now, False));
  JWT.JWTOptions.Algorithms.ES.PrivateKey.LoadFromFile('AuthKey_XXX.p8');
  JWT.JWTOptions.RefreshTokenAfter := 40 * 60; // auto-mint every 40 min

  ShowMessage(JWT.Token);
end;
// uses: sgcHTTP
TsgcHTTP_JWT_Client *JWT = new TsgcHTTP_JWT_Client(this);
JWT->JWTOptions->Header->alg = jwtES256;
JWT->JWTOptions->Header->kid = "apple-key-id";
JWT->JWTOptions->Payload->iss = "team-id";
JWT->JWTOptions->Algorithms->ES->PrivateKey->LoadFromFile("AuthKey_XXX.p8");

ShowMessage(JWT->Token);

Qué incluye

A typed JWT mint-and-verify component with HMAC, RSA, ECDSA and EdDSA signatures, automatic refresh and a clean handoff to the HTTP / HTTP/2 / WebSocket components.

Algoritmos

JWTOptions.Header.alg selects HS256/384/512, RS256/384/512, ES256/384/512, PS256/384/512 or EdDSA. Keys are loaded from PEM, P8 or in-memory streams.

Claims estándar

JWTOptions.Payload.iss, sub, aud, exp, nbf, iat, jti are typed properties matching RFC 7519 — plus a free-form CustomClaims for vendor extensions.

Refresco automático

RefreshTokenAfter tells the component to mint a new JWT after N seconds — useful for APNs ES256 tokens that Apple expects rotated within an hour.

Decodificar y verificar

Decode(token) parses an inbound JWT and verifies the signature against the configured keys; OnVerify fires with success/failure and the parsed payload.

Soporte JWE

Encrypted JWTs (JWE) per RFC 7516 are supported: AES-CBC, AES-GCM, RSA-OAEP and ECDH-ES key wrapping.

Listo para HTTP/2

Pair with TsgcHTTP2Client or TsgcHTTPComponentClient by setting Authentication.Token.JWT — every outbound request gets a fresh signed bearer token.

Especificaciones y referencias

Fuentes autorizadas de los estándares que implementa este componente.

Documentación y Demos

Enlace directo a la referencia del componente, descarga el proyecto demo listo para ejecutar y la prueba gratuita.

Ayuda en línea — TsgcHTTP_JWT_Client Referencia completa de propiedades, métodos y eventos de este componente.
Proyecto demo — Demos\20.HTTP_Protocol\05.JWT Proyecto de ejemplo listo para ejecutar. Se incluye en el paquete sgcWebSockets — descarga la prueba gratuita más abajo.
Documento técnico (PDF) Características, inicio rápido, ejemplos de código para Delphi y C++ Builder y referencias de fuentes primarias — solo este componente.
Manual de usuario (PDF) Manual completo que cubre todos los componentes de la biblioteca.

¿Listo para generar JWTs firmados?

Descarga la prueba gratuita y añade firma JWT a tus aplicaciones Delphi.