glupbit/auth

JWT HS512 authentication for Upbit Exchange API.

Generates signed tokens with access_key, nonce, and optional query_hash / query_hash_alg claims using the gose JOSE library.

Types

Upbit API Access Key.

pub opaque type AccessKey

Bundled access + secret key pair.

pub opaque type Credentials

Upbit API Secret Key.

pub opaque type SecretKey

Values

pub fn access_key(key: String) -> AccessKey

Wrap a raw string as an AccessKey.

pub fn credentials(ak: AccessKey, sk: SecretKey) -> Credentials

Bundle an access key and secret key into Credentials.

pub fn credentials_from_env() -> Result(Credentials, String)

Load credentials from UPBIT_OPEN_API_ACCESS_KEY and UPBIT_OPEN_API_SECRET_KEY environment variables.

pub fn generate_token(
  creds: Credentials,
) -> Result(String, types.ApiError)

Generate a JWT for requests without parameters.

pub fn generate_token_with_body(
  creds: Credentials,
  body_params params: List(#(String, String)),
) -> Result(String, types.ApiError)

Generate a JWT for POST requests with a JSON body. Body params are converted to key=value&... format before hashing.

pub fn generate_token_with_query(
  creds: Credentials,
  query_string query_string: String,
) -> Result(String, types.ApiError)

Generate a JWT for GET/DELETE requests with query parameters. The raw query_string is SHA-512 hashed and included as query_hash.

pub fn secret_key(key: String) -> SecretKey

Wrap a raw string as a SecretKey.

pub fn sha512_hex(input: String) -> String

Compute the lowercase-hex SHA-512 digest of a string.

Search Document