Skip to main content

build_auth_token

Function build_auth_token 

Source
pub fn build_auth_token(
    deadline_unix_secs: i64,
    account_index: i64,
    api_key_index: u8,
    sk: &PrivateKey,
    k: Scalar,
) -> Result<String, AuthTokenError>
Expand description

Build a Lighter auth token using the system clock as the now reference.

Validates the deadline against LIGHTER_AUTH_TOKEN_MAX_TTL. See build_auth_token_at for an injectable-now variant suitable for tests.

ยงErrors

Returns AuthTokenError::DeadlineNotInFuture if deadline_unix_secs <= now, AuthTokenError::TtlTooLarge if it exceeds the venue cap, or AuthTokenError::ClockBeforeEpoch if the system clock predates the UNIX epoch.