CCXT.WS.Auth.JsonrpcLinebreak (ccxt_client v0.6.1)

Copy Markdown View Source

JSON-RPC Linebreak auth pattern — deribit.

Signs "{timestamp_ms}\n{nonce}\n" with HMAC-SHA256 hex and wraps the signature in a JSON-RPC 2.0 public/auth frame with grant_type: "client_signature".

handle_auth_response/2 extracts result.expires_in (seconds) and returns {:ok, %{ttl_ms: N}} so the adapter can schedule re-auth via CCXT.WS.Auth.Expiry.

Example Frame (deribit)

%{
  "jsonrpc" => "2.0",
  "id" => 1,
  "method" => "public/auth",
  "params" => %{
    "grant_type" => "client_signature",
    "client_id" => "api_key",
    "timestamp" => 1699999999999,
    "signature" => "hex_signature",
    "nonce" => "1699999999999",
    "data" => ""
  }
}

Config / opts

KeyLocationDefaultPurpose
:method_valueconfig"public/auth"RPC method override
:nonceoptsto_string(timestamp)Explicit nonce
:request_idoptsSystem.unique_integer([:positive])RPC id
:timestamp_ms_overrideconfig(unset)Test-only — freezes the clock
:nonce_overrideconfig(unset)Test-only — freezes the nonce