jwtToken

suspend fun jwtToken(clientAccountId: String, signers: List<KeyPair> = emptyList(), homeDomain: String? = null, clientDomain: String? = null, clientDomainAccountKeyPair: KeyPair? = null, clientDomainSigningDelegate: Sep45ClientDomainSigningDelegate? = null, signatureExpirationLedger: Long? = null): Sep45AuthToken

Performs complete SEP-45 authentication flow.

This is the high-level API that handles the entire challenge-response flow:

  1. Validates input parameters

  2. Requests challenge from server

  3. Validates network passphrase (if provided in response)

  4. Decodes and validates authorization entries

  5. Signs entries with provided keypairs

  6. Submits signed entries to server

  7. Returns parsed JWT authentication token

Return

Sep45AuthToken containing JWT token and parsed claims

Parameters

clientAccountId

Contract account (C...) to authenticate

signers

List of keypairs to sign the client authorization entry. For contracts that implement __check_auth with signature verification, provide the keypairs with sufficient weight to meet the contract's authentication requirements. Can be empty for contracts whose __check_auth does not require signatures.

homeDomain

Optional home domain for the challenge request. If not provided, defaults to the server home domain from stellar.toml.

clientDomain

Optional client domain for verification

clientDomainAccountKeyPair

Optional keypair for local client domain signing

clientDomainSigningDelegate

Optional delegate for remote client domain signing

signatureExpirationLedger

Optional expiration ledger for signatures. If null and signers are provided, automatically set to current ledger + 10 (approximately 50-60 seconds).

Throws

If challenge request fails

If challenge validation fails

If token submission fails

If client domain signing parameters are misconfigured

If clientAccountId is not a contract address