stellar-sdk 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16f2babbd6e3fd516c62f8ff0fb2fe264e335dae7bb051721a3f4fefb5195f4d
4
- data.tar.gz: dd0d6b370c14ca38ae09a7bcfcfaccfc1214af2115308c9f2574f84f133a85a4
3
+ metadata.gz: 3829133758963683cfff3f2132c55d8bf53540bd731d9cb2e619d2ae36012112
4
+ data.tar.gz: d2ec22a621018102dc93c9cb6e89dbaa5029ef29ec4d1b85f5b6cf6a8b1a8ccb
5
5
  SHA512:
6
- metadata.gz: 5b4ce731f7be3b66a5d1cd0f8a03ebb8ba5ffbcb7c55b0fdc9a45189edd95f2d288a3047d603e222e06f69e7079c418c27bc0b82c3bcd0f25f182573630cba67
7
- data.tar.gz: c74630a8193bc6bfd3bd2ce730491c0de96f4b7b49b9b1523d02b191f9c2358cfe1c6ca7e286db28ded3680c6e8d110c003249928f86682cec6da3e4fc91b35d
6
+ metadata.gz: 53958e7a613b1a8cfa6b7a36a505c3820337b5a696bc16bfe7b7d3da9060fee01b0dd1afd61f4c48cb2eeee8c6a9b8b3b71d75b39afc1681b985a2a266af6231
7
+ data.tar.gz: b235706bc0f6d4b92298a43dae775d9b7210028c1306171ffd65212478addc929f760e0f6421e795c77d2e58570e6aa81d7665f5d93005695e1c4271e6e074f2
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [0.29.0](https://www.github.com/astroband/ruby-stellar-sdk/compare/v0.28.0...v0.29.0) (2021-09-07)
9
+
10
+ ### Added
11
+ * support for client domain in SEP-10
12
+ ### Deprecated
13
+ * `Stellar::Client` class is marked as deprecated in favour of new `stellar-horizon` gem
14
+
8
15
  ## [0.28.0](https://www.github.com/astroband/ruby-stellar-sdk/compare/v0.27.0...v0.28.0) (2021-07-17)
9
16
 
10
17
  ### Changed
@@ -44,6 +44,8 @@ module Stellar
44
44
 
45
45
  # @option options [String] :horizon The Horizon server URL.
46
46
  def initialize(options)
47
+ ActiveSupport::Deprecation.warn("`Stellar::Horizon` is deprecated and will be removed from `stellar-sdk` next relase. Use `stellar-horizon` gem for requesting Horizon API")
48
+
47
49
  @options = options
48
50
  @horizon = Hyperclient.new(options[:horizon]) { |client|
49
51
  client.faraday_block = lambda do |conn|
data/lib/stellar/sep10.rb CHANGED
@@ -64,6 +64,20 @@ module Stellar
64
64
  )
65
65
  end
66
66
 
67
+ if options[:client_domain].present?
68
+ if options[:client_domain_account].blank?
69
+ raise "`client_domain_account` is required, if `client_domain` is provided"
70
+ end
71
+
72
+ tb.add_operation(
73
+ Stellar::Operation.manage_data(
74
+ name: "client_domain",
75
+ value: options[:client_domain],
76
+ source_account: options[:client_domain_account]
77
+ )
78
+ )
79
+ end
80
+
67
81
  tb.build.to_envelope(server).to_xdr(:base64)
68
82
  end
69
83
 
@@ -125,16 +139,14 @@ module Stellar
125
139
 
126
140
  rest_ops.each do |op|
127
141
  body = op.body
142
+ op_params = body.value
128
143
 
129
144
  if body.arm != :manage_data_op
130
145
  raise InvalidSep10ChallengeError, "The transaction has operations that are not of type 'manageData'"
131
- elsif op.source_account != server.muxed_account
146
+ elsif op.source_account != server.muxed_account && op_params.data_name != "client_domain"
132
147
  raise InvalidSep10ChallengeError, "The transaction has operations that are unrecognized"
133
- else
134
- op_params = body.value
135
- if op_params.data_name == "web_auth_domain" && options.key?(:auth_domain) && op_params.data_value != options[:auth_domain]
136
- raise InvalidSep10ChallengeError, "The transaction has 'manageData' operation with 'web_auth_domain' key and invalid value"
137
- end
148
+ elsif op_params.data_name == "web_auth_domain" && options.key?(:auth_domain) && op_params.data_value != options[:auth_domain]
149
+ raise InvalidSep10ChallengeError, "The transaction has 'manageData' operation with 'web_auth_domain' key and invalid value"
138
150
  end
139
151
  end
140
152
 
@@ -210,6 +222,9 @@ module Stellar
210
222
  client_signers = signers.select { |s| s =~ /G[A-Z0-9]{55}/ && s != server.address }.to_set
211
223
  raise InvalidSep10ChallengeError, "at least one regular signer must be provided" if client_signers.empty?
212
224
 
225
+ client_domain_account_address = extract_client_domain_account(te.tx)
226
+ client_signers.add(client_domain_account_address) if client_domain_account_address.present?
227
+
213
228
  # verify all signatures in one pass
214
229
  client_signers.add(server.address)
215
230
  signers_found = verify_tx_signatures(tx_envelope: te, signers: client_signers)
@@ -229,6 +244,10 @@ module Stellar
229
244
  raise InvalidSep10ChallengeError, "Transaction has unrecognized signatures."
230
245
  end
231
246
 
247
+ if client_domain_account_address.present? && !signers_found.include?(client_domain_account_address)
248
+ raise InvalidSep10ChallengeError, "Transaction not signed by client domain account."
249
+ end
250
+
232
251
  signers_found
233
252
  end
234
253
 
@@ -249,7 +268,7 @@ module Stellar
249
268
  to_keypair = Stellar::DSL.method(:KeyPair)
250
269
  keys_by_hint = signers.map(&to_keypair).index_by(&:signature_hint)
251
270
 
252
- tx_envelope.signatures.each.with_object(Set.new) do |sig, result|
271
+ signatures.each_with_object(Set.new) do |sig, result|
253
272
  key = keys_by_hint.delete(sig.hint)
254
273
  result.add(key.address) if key&.verify(sig.signature, tx_hash)
255
274
  end
@@ -272,5 +291,16 @@ module Stellar
272
291
  keypair.verify(sig.signature, tx_hash)
273
292
  end
274
293
  end
294
+
295
+ def self.extract_client_domain_account(transaction)
296
+ client_domain_account_op =
297
+ transaction
298
+ .operations
299
+ .find { |op| op.body.value.data_name == "client_domain" }
300
+
301
+ return if client_domain_account_op.blank?
302
+
303
+ Util::StrKey.encode_muxed_account(client_domain_account_op.source_account)
304
+ end
275
305
  end
276
306
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  - Sergey Nebolsin
9
9
  - Timur Ramazanov
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-07-20 00:00:00.000000000 Z
13
+ date: 2021-09-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: stellar-base
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.28.0
21
+ version: 0.29.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.28.0
28
+ version: 0.29.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: activesupport
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -148,8 +148,8 @@ dependencies:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
150
  version: '3.9'
151
- description:
152
- email:
151
+ description:
152
+ email:
153
153
  executables: []
154
154
  extensions: []
155
155
  extra_rdoc_files:
@@ -173,12 +173,12 @@ licenses:
173
173
  - Apache-2.0
174
174
  metadata:
175
175
  bug_tracker_uri: https://github.com/astroband/ruby-stellar-sdk/issues
176
- changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.28.0/sdk/CHANGELOG.md
177
- documentation_uri: https://rubydoc.info/gems/stellar-sdk/0.28.0/
176
+ changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.29.0/sdk/CHANGELOG.md
177
+ documentation_uri: https://rubydoc.info/gems/stellar-sdk/0.29.0/
178
178
  github_repo: ssh://github.com/astroband/ruby-stellar-sdk
179
179
  homepage_uri: https://github.com/astroband/ruby-stellar-sdk/tree/main/sdk
180
- source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.28.0/sdk
181
- post_install_message:
180
+ source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.29.0/sdk
181
+ post_install_message:
182
182
  rdoc_options: []
183
183
  require_paths:
184
184
  - lib
@@ -193,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.2.22
197
- signing_key:
196
+ rubygems_version: 3.1.4
197
+ signing_key:
198
198
  specification_version: 4
199
199
  summary: Stellar client library
200
200
  test_files: []