max_api_client 0.1.0 → 0.1.3

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: 90a56c712907fd53b66e127a84f712e96fc9d9172fae831fdcdc0f6dac9da0db
4
- data.tar.gz: 93042ed433e745dfc1a7eec5fac783f8bf71cd6a683d17c9e13125096b986230
3
+ metadata.gz: 9fde75c48daf67e3c6daac640e467b02b31601c5abef3e92ed3fd14f83509d28
4
+ data.tar.gz: 53f4dd194924f9853a98fcc60789bd7678320bedb73d7a0dbe35bd2bb1196817
5
5
  SHA512:
6
- metadata.gz: 70cf625de3554498841b7de213767e0bc31f87b3921569751d9ddaee7758e4796a6b060f100642e386900d76a2a0bf570f0d565ec308a46f5f96782aab3ebee2
7
- data.tar.gz: 8f7346ee0587d47ff1ee60314eb216f3d4cd3a63ff6f4b86cb0650a5313f244d120cb25ef0b494c1acabd8906fc186ca98582e2dd5805807fdd55f058f70b244
6
+ metadata.gz: 0bd30a89346e414d46dace23dfe18745a7e54ecec52024a3f48d7ba12e97b8e5df09eca5cad6be05e4ac0488c99b679f1671d85d132d09c7e9eb0b10197729cd
7
+ data.tar.gz: b9bedc2313023176b3b92e21c34c97e1d012f13afb1c8dfaa322c4e8c9125f61be75c33476b84e0dcd3ea6cf80a9c5ce197c6b809ff1a5d1d218df858f2af1e9
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.5
data/CHANGELOG.md CHANGED
@@ -1,7 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
- - Rewrote `README.md` with installation instructions, project status, TS vs Ruby comparison, and Max Bot API reference sections.
4
- - Filled gem metadata in `max_api_client.gemspec`.
3
+ ## [0.1.3] - 2026-07-16
4
+
5
+ - Switched the default API endpoint to `https://platform-api2.max.ru`.
6
+ - Added the Russian Trusted Root CA to the TLS trust store, with optional `ca_file` override.
7
+ - Added an explicit `verify_ssl: false` option for environments that must temporarily ignore certificate errors.
8
+ - Documented the new endpoint and TLS configuration options.
9
+ - Updated the TypeScript reference client link.
10
+
11
+ ## [0.1.2] - 2026-03-27
12
+
13
+ - Configured RubyGems trusted publishing through GitHub Actions.
14
+ - Added release tag validation and updated the Ruby CI matrix.
5
15
 
6
16
  ## [0.1.0] - 2026-02-12
7
17
 
data/README.md CHANGED
@@ -24,11 +24,84 @@ gem "max_api_client", git: "git@github.com:Ziaw/max_api_client.git"
24
24
  bundle install
25
25
  ```
26
26
 
27
+ ## Адрес API и сертификат Минцифры
28
+
29
+ По умолчанию клиент использует актуальный адрес `https://platform-api2.max.ru`.
30
+ В gem включён корневой сертификат `Russian Trusted Root CA`, поэтому TLS-цепочка
31
+ MAX проверяется вместе с обычным системным хранилищем доверенных сертификатов.
32
+ По умолчанию проверка TLS включена.
33
+
34
+ Актуальные сертификаты и инструкции по их системной установке опубликованы
35
+ на Госуслугах: <https://www.gosuslugi.ru/crt>.
36
+
37
+ Обычное подключение не требует дополнительных настроек:
38
+
39
+ ```ruby
40
+ api = MaxApiClient::Api.new(
41
+ token: ENV.fetch("MAX_BOT_TOKEN")
42
+ )
43
+ ```
44
+
45
+ Доступные параметры подключения:
46
+
47
+ - `base_url` — адрес MAX API, по умолчанию `https://platform-api2.max.ru`;
48
+ - `ca_file` — путь к дополнительному доверенному CA-файлу;
49
+ - `verify_ssl` — проверять сертификат сервера, по умолчанию `true`;
50
+ - `open_timeout` — таймаут установления соединения;
51
+ - `read_timeout` — таймаут чтения ответа.
52
+
53
+ Эти параметры поддерживают как `MaxApiClient::Api`, так и
54
+ `MaxApiClient::Client`.
55
+
56
+ ### Подключение собственного сертификата
57
+
58
+ Передайте путь к актуальному сертификату Минцифры в формате PEM:
59
+
60
+ ```ruby
61
+ api = MaxApiClient::Api.new(
62
+ token: ENV.fetch("MAX_BOT_TOKEN"),
63
+ ca_file: "/etc/ssl/certs/russian_trusted_root_ca.pem"
64
+ )
65
+ ```
66
+
67
+ Чтобы использовать только системное хранилище сертификатов, передайте
68
+ `ca_file: nil`.
69
+
70
+ ### Игнорирование неверного сертификата
71
+
72
+ Если окружение временно не может проверить сертификат, отключите проверку
73
+ параметром `verify_ssl: false`:
74
+
75
+ ```ruby
76
+ api = MaxApiClient::Api.new(
77
+ token: ENV.fetch("MAX_BOT_TOKEN"),
78
+ verify_ssl: false
79
+ )
80
+ ```
81
+
82
+ `verify_ssl: false` принимает любой серверный сертификат и делает соединение
83
+ уязвимым для перехвата. Используйте эту настройку только как временный обходной
84
+ вариант. Для постоянной настройки передайте актуальный сертификат через
85
+ `ca_file` или установите его в системное хранилище.
86
+
87
+ Полный пример настройки:
88
+
89
+ ```ruby
90
+ api = MaxApiClient::Api.new(
91
+ token: ENV.fetch("MAX_BOT_TOKEN"),
92
+ base_url: "https://platform-api2.max.ru",
93
+ ca_file: MaxApiClient::Client::DEFAULT_CA_FILE,
94
+ verify_ssl: true,
95
+ open_timeout: 10,
96
+ read_timeout: 30
97
+ )
98
+ ```
99
+
27
100
  ## Справочник API
28
101
 
29
102
  ### Методы бота
30
103
 
31
- Методы Ruby, доступные через `MaxApiClient::Api`:
104
+ Методы доступные через `MaxApiClient::Api`, порт официального клиента <https://github.com/max-messenger/max-bot-api-client-ts>, названия сохранены, poller собственный:
32
105
 
33
106
  - `get_my_info`
34
107
  - `edit_my_info(**extra)`
@@ -0,0 +1,33 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFwjCCA6qgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwcDELMAkGA1UEBhMCUlUx
3
+ PzA9BgNVBAoMNlRoZSBNaW5pc3RyeSBvZiBEaWdpdGFsIERldmVsb3BtZW50IGFu
4
+ ZCBDb21tdW5pY2F0aW9uczEgMB4GA1UEAwwXUnVzc2lhbiBUcnVzdGVkIFJvb3Qg
5
+ Q0EwHhcNMjIwMzAxMjEwNDE1WhcNMzIwMjI3MjEwNDE1WjBwMQswCQYDVQQGEwJS
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DAGAQH/AgEEMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
22
+ AAOCAgEAALIY1wkilt/urfEVM5vKzr6utOeDWCUczmWX/RX4ljpRdgF+5fAIS4vH
23
+ tmXkqpSCOVeWUrJV9QvZn6L227ZwuE15cWi8DCDal3Ue90WgAJJZMfTshN4OI8cq
24
+ W9E4EG9wglbEtMnObHlms8F3CHmrw3k6KmUkWGoa+/ENmcVl68u/cMRl1JbW2bM+
25
+ /3A+SAg2c6iPDlehczKx2oa95QW0SkPPWGuNA/CE8CpyANIhu9XFrj3RQ3EqeRcS
26
+ AQQod1RNuHpfETLU/A2gMmvn/w/sx7TB3W5BPs6rprOA37tutPq9u6FTZOcG1Oqj
27
+ C/B7yTqgI7rbyvox7DEXoX7rIiEqyNNUguTk/u3SZ4VXE2kmxdmSh3TQvybfbnXV
28
+ 4JbCZVaqiZraqc7oZMnRoWrXRG3ztbnbes/9qhRGI7PqXqeKJBztxRTEVj8ONs1d
29
+ WN5szTwaPIvhkhO3CO5ErU2rVdUr89wKpNXbBODFKRtgxUT70YpmJ46VVaqdAhOZ
30
+ D9EUUn4YaeLaS8AjSF/h7UkjOibNc4qVDiPP+rkehFWM66PVnP1Msh93tc+taIfC
31
+ EYVMxjh8zNbFuoc7fzvvrFILLe7ifvEIUqSVIC/AzplM/Jxw7buXFeGP1qVCBEHq
32
+ 391d/9RAfaZ12zkwFsl+IKwE/OZxW8AHa9i1p4GO0YSNuczzEm4=
33
+ -----END CERTIFICATE-----
@@ -7,13 +7,15 @@ module MaxApiClient
7
7
 
8
8
  # rubocop:disable Metrics/ParameterLists
9
9
  def initialize(token:, base_url: Client::DEFAULT_BASE_URL, adapter: nil, open_timeout: nil, read_timeout: nil,
10
- logger: nil)
10
+ ca_file: Client::DEFAULT_CA_FILE, verify_ssl: true, logger: nil)
11
11
  @client = Client.new(
12
12
  token:,
13
13
  base_url:,
14
14
  adapter:,
15
15
  open_timeout:,
16
16
  read_timeout:,
17
+ ca_file:,
18
+ verify_ssl:,
17
19
  logger:
18
20
  )
19
21
  @raw = RawApi.new(client)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaxApiClient
4
+ # Builds a TLS trust store from the system defaults and an optional CA file.
5
+ class CertificateStore
6
+ def self.configure(http, ca_file:, verify_ssl:)
7
+ http.use_ssl = true
8
+ http.verify_mode = verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
9
+ http.cert_store = build(ca_file:) if verify_ssl
10
+ end
11
+
12
+ def self.build(ca_file:)
13
+ OpenSSL::X509::Store.new.tap do |store|
14
+ store.set_default_paths
15
+ store.add_file(ca_file) if ca_file
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,7 +3,8 @@
3
3
  module MaxApiClient
4
4
  # HTTP transport client responsible for authenticated API requests.
5
5
  class Client
6
- DEFAULT_BASE_URL = "https://platform-api.max.ru"
6
+ DEFAULT_BASE_URL = "https://platform-api2.max.ru"
7
+ DEFAULT_CA_FILE = File.expand_path("../../certs/russian_trusted_root_ca.pem", __dir__)
7
8
  REQUEST_CLASSES = {
8
9
  get: Net::HTTP::Get,
9
10
  post: Net::HTTP::Post,
@@ -12,15 +13,18 @@ module MaxApiClient
12
13
  delete: Net::HTTP::Delete
13
14
  }.freeze
14
15
 
15
- attr_reader :token, :base_url
16
+ attr_reader :token, :base_url, :ca_file, :verify_ssl
16
17
 
17
18
  # rubocop:disable Metrics/ParameterLists
18
- def initialize(token:, base_url: DEFAULT_BASE_URL, adapter: nil, open_timeout: nil, read_timeout: nil, logger: nil)
19
+ def initialize(token:, base_url: DEFAULT_BASE_URL, adapter: nil, open_timeout: nil, read_timeout: nil,
20
+ ca_file: DEFAULT_CA_FILE, verify_ssl: true, logger: nil)
19
21
  @token = token
20
22
  @base_url = base_url
21
23
  @adapter = adapter
22
24
  @open_timeout = open_timeout
23
25
  @read_timeout = read_timeout
26
+ @ca_file = ca_file
27
+ @verify_ssl = verify_ssl
24
28
  @logger = logger || MaxApiClient.logger
25
29
  end
26
30
  # rubocop:enable Metrics/ParameterLists
@@ -122,10 +126,13 @@ module MaxApiClient
122
126
  end
123
127
 
124
128
  def configured_http(uri, open_timeout:, read_timeout:)
129
+ open_timeout ||= @open_timeout
130
+ read_timeout ||= @read_timeout
131
+
125
132
  Net::HTTP.new(uri.host, uri.port).tap do |http|
126
- http.use_ssl = uri.scheme == "https"
127
- http.open_timeout = open_timeout || @open_timeout if open_timeout || @open_timeout
128
- http.read_timeout = read_timeout || @read_timeout if read_timeout || @read_timeout
133
+ CertificateStore.configure(http, ca_file:, verify_ssl:) if uri.scheme == "https"
134
+ http.open_timeout = open_timeout if open_timeout
135
+ http.read_timeout = read_timeout if read_timeout
129
136
  end
130
137
  end
131
138
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Root namespace for gem version information.
4
4
  module MaxApiClient
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.3"
6
6
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "json"
4
4
  require "net/http"
5
+ require "openssl"
5
6
  require "uri"
6
7
  require "securerandom"
7
8
 
8
9
  require_relative "max_api_client/version"
9
10
  require_relative "max_api_client/error"
11
+ require_relative "max_api_client/certificate_store"
10
12
  require_relative "max_api_client/client"
11
13
  require_relative "max_api_client/base_api"
12
14
  require_relative "max_api_client/raw_api"
@@ -17,9 +17,12 @@ module MaxApiClient
17
17
 
18
18
  class Client
19
19
  DEFAULT_BASE_URL: String
20
+ DEFAULT_CA_FILE: String
20
21
  attr_reader token: String
21
22
  attr_reader base_url: String
22
- def initialize: (token: String, ?base_url: String, ?adapter: untyped, ?open_timeout: Numeric?, ?read_timeout: Numeric?, ?logger: untyped) -> void
23
+ attr_reader ca_file: String?
24
+ attr_reader verify_ssl: bool
25
+ def initialize: (token: String, ?base_url: String, ?adapter: untyped, ?open_timeout: Numeric?, ?read_timeout: Numeric?, ?ca_file: String?, ?verify_ssl: bool, ?logger: untyped) -> void
23
26
  def call: (method: Symbol | String, ?path: String?, ?query: untyped, ?body: untyped, ?path_params: untyped, ?headers: untyped, ?url: String?, ?raw_body: untyped, ?parse_json: bool) -> Hash[Symbol, untyped]
24
27
  end
25
28
 
@@ -123,7 +126,7 @@ module MaxApiClient
123
126
  attr_reader raw: RawApi
124
127
  attr_reader upload: Upload
125
128
  attr_reader client: Client
126
- def initialize: (token: String, ?base_url: String, ?adapter: untyped, ?open_timeout: Numeric?, ?read_timeout: Numeric?, ?logger: untyped) -> void
129
+ def initialize: (token: String, ?base_url: String, ?adapter: untyped, ?open_timeout: Numeric?, ?read_timeout: Numeric?, ?ca_file: String?, ?verify_ssl: bool, ?logger: untyped) -> void
127
130
  def get_my_info: () -> untyped
128
131
  def edit_my_info: (untyped extra) -> untyped
129
132
  def set_my_commands: (Array[bot_command] commands) -> untyped
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: max_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Zimin
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-03-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Ruby client for Max Bot API.
13
13
  email:
@@ -17,15 +17,18 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - ".rubocop.yml"
20
+ - ".ruby-version"
20
21
  - CHANGELOG.md
21
22
  - CODE_OF_CONDUCT.md
22
23
  - LICENSE.txt
23
24
  - README.md
24
25
  - Rakefile
26
+ - certs/russian_trusted_root_ca.pem
25
27
  - lib/max_api_client.rb
26
28
  - lib/max_api_client/api.rb
27
29
  - lib/max_api_client/attachments.rb
28
30
  - lib/max_api_client/base_api.rb
31
+ - lib/max_api_client/certificate_store.rb
29
32
  - lib/max_api_client/client.rb
30
33
  - lib/max_api_client/error.rb
31
34
  - lib/max_api_client/polling.rb
@@ -55,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  requirements: []
58
- rubygems_version: 3.6.2
61
+ rubygems_version: 3.6.9
59
62
  specification_version: 4
60
63
  summary: Ruby client for Max Bot API
61
64
  test_files: []