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
| Key | Location | Default | Purpose |
|---|---|---|---|
:method_value | config | "public/auth" | RPC method override |
:nonce | opts | to_string(timestamp) | Explicit nonce |
:request_id | opts | System.unique_integer([:positive]) | RPC id |
:timestamp_ms_override | config | (unset) | Test-only — freezes the clock |
:nonce_override | config | (unset) | Test-only — freezes the nonce |