honeymaker 0.12.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc3033c53052a7498aff900daa5751df3c7fc335d141e44fb411ddcd644fbb60
4
- data.tar.gz: 783c314037519d4e404e6145b98d6107cced8c46f180f7aff7d6ee123b145691
3
+ metadata.gz: 6862c70498fbf141e4808db14c19d5bd63a5dc59d7877797048756252b1d2836
4
+ data.tar.gz: e593c15692fcf4fb4677349b269076314cfac14fbe09b65b1c05b7aada91894d
5
5
  SHA512:
6
- metadata.gz: f192d993e87591038536d8edf6e02546d2320d73840fa1c1610f826f3721805eb4fa8021dba486ed752c90d5db7c707fecf4552285f8534c95c98aac6cc65f21
7
- data.tar.gz: f54ef09c03a5c461700148ed7a58782ad654dad0af0c626d7093f524218e03a57fd49e09694f28dda606546baf612567415b821aa9f0b67c6268eea31c02e81e
6
+ metadata.gz: f1547ddeaa92b66ba371d21f5452d88dc5aec87895649d28dec3ea9d54b36cb76582084b923381aadcbc004a95ba17291951b717ad4a7601a4401966f72af760
7
+ data.tar.gz: 96ad193d8d2ca903ac26e261c7a493ce77f25f2e644e4e5e152d8d4a3f717b5ae5cb6bfa6d1f3f33d49656b3a5decd5ee98402ce85ea5d3c72f28819858a93c2
@@ -168,7 +168,8 @@ module Honeymaker
168
168
  with_rescue do
169
169
  payload = body.compact.merge(request: path, nonce: timestamp_ms.to_s)
170
170
  encoded_payload = Base64.strict_encode64(payload.to_json)
171
- signature = hmac_sha256(@api_secret, encoded_payload)
171
+ # HMAC-SHA384, not SHA256: https://developer.gemini.com/authentication/api-key
172
+ signature = OpenSSL::HMAC.hexdigest("sha384", @api_secret, encoded_payload)
172
173
 
173
174
  response = connection.post do |req|
174
175
  req.url path
@@ -87,6 +87,12 @@ module Honeymaker
87
87
  post_private("/0/private/BalanceEx", { nonce: nonce })
88
88
  end
89
89
 
90
+ # The key's own permission flags (query-funds, withdraw-funds, modify-trades, query-ledger, ...).
91
+ # Needs no permission itself, so it answers for any valid key.
92
+ def get_api_key_info
93
+ post_private("/0/private/GetApiKeyInfo", { nonce: nonce })
94
+ end
95
+
90
96
  def get_balances
91
97
  result = get_extended_balance
92
98
  return result if result.failure?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Honeymaker
4
- VERSION = "0.12.0"
4
+ VERSION = "0.12.2"
5
5
  end
@@ -72,6 +72,23 @@ class Honeymaker::Clients::GeminiTest < Minitest::Test
72
72
  assert result.success?
73
73
  end
74
74
 
75
+ # Gemini signs with HMAC-SHA384 of the base64 payload
76
+ # (https://developer.gemini.com/authentication/api-key); any other digest is rejected.
77
+ def test_private_requests_are_signed_with_hmac_sha384
78
+ request = Struct.new(:headers) { def url(_path) = nil }.new
79
+ connection = Object.new
80
+ connection.define_singleton_method(:post) do |&block|
81
+ block.call(request)
82
+ Struct.new(:body).new({})
83
+ end
84
+ @client.instance_variable_set(:@connection, connection)
85
+
86
+ @client.get_balances
87
+
88
+ payload = request.headers[:"X-GEMINI-PAYLOAD"]
89
+ assert_equal OpenSSL::HMAC.hexdigest("sha384", "test_secret", payload), request.headers[:"X-GEMINI-SIGNATURE"]
90
+ end
91
+
75
92
  private
76
93
 
77
94
  def stub_connection(method, body)
@@ -78,6 +78,14 @@ class Honeymaker::Clients::KrakenTest < Minitest::Test
78
78
  assert result.success?
79
79
  end
80
80
 
81
+ def test_get_api_key_info
82
+ stub_connection(:post, { "error" => [], "result" => { "apiKeyName" => "bot",
83
+ "permissions" => %w[query-funds query-ledger] } })
84
+ result = @client.get_api_key_info
85
+ assert result.success?
86
+ assert_equal %w[query-funds query-ledger], result.data["result"]["permissions"]
87
+ end
88
+
81
89
  def test_get_trades_history
82
90
  stub_connection(:post, { "error" => [], "result" => { "trades" => { "T1" => { "pair" => "XBTUSDT" } }, "count" => 1 } })
83
91
  result = @client.get_trades_history
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeymaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deltabadger