feat(tokens): add offline client-token verification - #71
Merged
AdirAmsalem merged 2 commits intoSep 24, 2026
Merged
Conversation
Client tokens from client.tokens.create are EdDSA (Ed25519) JWTs signed
by the platform and verifiable against its public JWKS, but the SDK had
no way to verify them, so integrators round-tripped to the platform to
read values already signed into the token (service_tier, allowed
models/origins, expiry, owner ids).
- client.tokens.verify(token) / verify_client_token(token): verify the
signature against the platform JWKS (fetched once and cached), plus
exp (30s leeway), iss and aud. Returns VerifiedClientToken.
- client.tokens.decode(token) / decode_client_token(token): claims
without verification, no network. Returns ClientTokenClaims,
documented as untrusted.
- Result fields: user_id, organization_id, api_key_id (parent key, else
the token id), api_key_name, service_tier, pool ("free" for tier 0,
else "paid"), allowed_models, allowed_origins, constraints,
realtime_concurrent_session_limit, zero_data_retention, attribution,
expires_at, and the raw claims.
- New TokenVerifyError and TokenDecodeError.
- PyJWT + cryptography ship as the optional `verify` extra and are
imported lazily, so minting-only users pull no crypto dependency.
AdirAmsalem
force-pushed
the
conductor/decart-python-offline-client-token-verify
branch
from
September 24, 2026 13:36
4408273 to
4021a62
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4021a62. Configure here.
Convert the exp claim with datetime.fromtimestamp(..., tz=timezone.utc) instead of relying on pydantic's int-to-datetime coercion, which is not guaranteed to be timezone-aware across supported pydantic 2.x versions.
AdirAmsalem
deleted the
conductor/decart-python-offline-client-token-verify
branch
September 24, 2026 13:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Client tokens from
client.tokens.createare EdDSA JWTs verifiable offline against the platform JWKS, but the SDK had no way to verify them. This adds it.API
https://platform.decart.ai/api/auth/jwks(fetched once and cached via PyJWT'sPyJWKClient), plusexp(30s leeway),issandaud.jwks_url,issuer,audience,leewayare overridable.VerifiedClientToken;decodereturns its untrusted parentClientTokenClaims. Fields:user_id,organization_id,api_key_id(parent key, else token id),api_key_name,service_tier,pool("free"for tier 0, else"paid"),allowed_models,allowed_origins,constraints,realtime_concurrent_session_limit,zero_data_retention,attribution,expires_at, rawclaims.TokenVerifyError/TokenDecodeError.decart[verify](pyjwt[crypto]), imported lazily so minting-only users pull no crypto dependency.decodeneeds no extra.Note
Medium Risk
Introduces a security-sensitive JWT verification path backends may use for authorization; behavior is well-tested and optional, but incorrect adoption of
decodewithoutverifycould weaken trust assumptions.Overview
Adds offline verification and decoding for short-lived client JWTs minted via
client.tokens.create, so backends can trust signed claims (tier, models, origins, expiry) without calling the platform.New
verify_client_token/client.tokens.verifyvalidate EdDSA signatures against the platform JWKS (https://platform.decart.ai/api/auth/jwks, cached in-process), plusexp(30s leeway),iss, andaud.decode_client_token/client.tokens.decodeparse claims with no signature check (untrusted). Results are typed asVerifiedClientToken/ClientTokenClaimswith mapped fields includingpool("free"for tier 0). Failures raiseTokenVerifyError/TokenDecodeError.Verification is gated behind optional
decart[verify](pyjwt[crypto]), lazily imported so token creation stays lightweight. README documents the flow; a large test suite covers tampering, expiry, JWKS caching, and key rotation.Reviewed by Cursor Bugbot for commit b3ab053. Bugbot is set up for automated code reviews on this repo. Configure here.