XU XUv0.16.0

#crypto/jwt

import: #crypto/jwt

counts: 10 functions, 0 methods, 0 types, 1 constants, 0 method sets

XU-CT-USE: fixed-shape-only HS256 tag equality uses crypto/subtle; asymmetric JWS algorithms remain variable-time. Compact JWS (JWT, RFC 7515 / RFC 7519) signing and verification HS256 (HMAC-SHA256) ES256 (ECDSA P-256 SHA-256, raw 64-byte R||S) RS256 (RSA PKCS#1 v1.5 SHA-256) EdDSA (Ed25519) Explicit algorithm verification prevents `alg: "none"` or algorithm confusion.

const MIN_HMAC_KEY_BYTES

XuAPI
pub const MIN_HMAC_KEY_BYTES = 32

Purpose

Constant MIN_HMAC_KEY_BYTES, defining protocol or algorithm parameters.

validate_claims_time

XuAPI
pub fn validate_claims_time(claims_json &string, now_sec int, leeway_sec int) int

Purpose

validate_claims_time enforces RFC 7519 exp and nbf claims when present. Throws on failure; handle the error or propagate it to the caller.

Parameters

claims_json &string
claims_json (read-only borrow; caller keeps the original; type &string)
now_sec int
now_sec (int)
leeway_sec int
leeway_sec (int)

Returns

int — a value of this type

sign_es256

XuAPI
pub fn sign_es256(private_key &string, team_id string, key_id string, iat_sec int) string

Purpose

sign_es256 builds an APNs provider JWT. private_key is the 32-byte P-256 scalar. Throws on failure; handle the error or propagate it to the caller.

Parameters

private_key &string
private_key (read-only borrow; caller keeps the original; type &string)
team_id string
team_id (string)
key_id string
key_id (string)
iat_sec int
iat_sec (int)

Returns

string — result string

sign_es256_claims

XuAPI
pub fn sign_es256_claims(private_key &string, key_id string, claims_json string) string

Purpose

Sign es256 claims. Throws on failure; handle the error or propagate it to the caller.

Parameters

private_key &string
private_key (read-only borrow; caller keeps the original; type &string)
key_id string
key_id (string)
claims_json string
claims_json (string)

Returns

string — result string

verify_es256

XuAPI
pub fn verify_es256(token string, public_key &string) string

Purpose

Verify es256. Throws on failure; handle the error or propagate it to the caller.

Parameters

token string
token (string)
public_key &string
public_key (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

sign_hs256

XuAPI
pub fn sign_hs256(secret &string, claims_json string) string

Purpose

Sign hs256. Throws on failure; handle the error or propagate it to the caller.

Parameters

secret &string
secret (read-only borrow; caller keeps the original; type &string)
claims_json string
claims_json (string)

Returns

string — result string

verify_hs256

XuAPI
pub fn verify_hs256(token string, secret &string) string

Purpose

Verify hs256. Throws on failure; handle the error or propagate it to the caller.

Parameters

token string
token (string)
secret &string
secret (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

sign_rs256

XuAPI
pub fn sign_rs256(private_key &rsa.PrivateKey, key_id string, claims_json string) string

Purpose

Sign rs256. Throws on failure; handle the error or propagate it to the caller.

Parameters

private_key &rsa.PrivateKey
private_key (read-only borrow; caller keeps the original; type &rsa.PrivateKey)
key_id string
key_id (string)
claims_json string
claims_json (string)

Returns

string — result string

verify_rs256

XuAPI
pub fn verify_rs256(token string, public_key &rsa.PublicKey) string

Purpose

Verify rs256. Throws on failure; handle the error or propagate it to the caller.

Parameters

token string
token (string)
public_key &rsa.PublicKey
public_key (read-only borrow; caller keeps the original; type &rsa.PublicKey)

Returns

string — result string

sign_eddsa

XuAPI
pub fn sign_eddsa(private_key &string, key_id string, claims_json string) string

Purpose

Sign eddsa. Throws on failure; handle the error or propagate it to the caller.

Parameters

private_key &string
private_key (read-only borrow; caller keeps the original; type &string)
key_id string
key_id (string)
claims_json string
claims_json (string)

Returns

string — result string

verify_eddsa

XuAPI
pub fn verify_eddsa(token string, public_key &string) string

Purpose

Verify eddsa. Throws on failure; handle the error or propagate it to the caller.

Parameters

token string
token (string)
public_key &string
public_key (read-only borrow; caller keeps the original; type &string)

Returns

string — result string