two_captcha 1.8.0 → 1.9.0

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: c6657c4e05fd2c0a00072c9070954b73b1a5573ab9a6896301b2836098aeea66
4
- data.tar.gz: ea035f063342b484e83272b2a75838fa4ce1b4b02b2c25a3a49e53b666ecb0d4
3
+ metadata.gz: b9ebd0f5784ffc3348f29f9abcd82e31f6298d6dc959557c204b41aeb19aae31
4
+ data.tar.gz: 4e5f0abecd976ea5cd4385bfffda6469a3dd8ba2b79f32bf81299488b9b39571
5
5
  SHA512:
6
- metadata.gz: ab1e833fbf80a57058f7e78a4b6399473fd56606247c34081212cbd9205ba7f9d6ab6a091a415a9db48d7b55ffe736ec2267c48a76adfa02764d3a4373c5d6f5
7
- data.tar.gz: 525b2cd2321e4e2ac9f35ec56a5f05c3ebc0d95ab7d0564e7c31d0c0a38f9a656e6fb7536224452174d3be10c33d5922d2b4d099e76ee78a678f22a1dfb5d6b1
6
+ metadata.gz: 349f83ce8ce70a30289fac68c9b171bd6e256b189435d5a6802179551ef3e536baf342d9d02e541ffe9c469ca0c3ca86b6ac9f3ab5d96a57a4b4116727d78bee
7
+ data.tar.gz: acfc725708ace49701cacf0dd465db438d3a3749b76d3c85f7691b828f201728094eeb6ec43db424e654e2a364118586c18655a65d0f24378d112b55fe66d51f
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  TwoCaptcha is a Ruby API for 2Captcha - [2Captcha.com](http://2captcha.com/?from=1025109)
4
4
 
5
- > We suggest you to also check the recommended CAPTCHA provider DeathByCaptcha.
6
- > The gem for this provider is available at https://github.com/infosimples/deathbycaptcha.
7
-
8
5
  ## Installation
9
6
 
10
7
  Add this line to your application's Gemfile:
@@ -128,6 +125,21 @@ captcha.text
128
125
  "P0_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXNza2V5IjoiNnpWV..."
129
126
  ```
130
127
 
128
+ #### Amazon WAF
129
+
130
+ ```ruby
131
+ captcha = client.decode_amazon_waf!(
132
+ sitekey: 'xyz',
133
+ pageurl: 'http://example.com/example=1',
134
+ iv: 'A1A1A1A1A1A1A1A1',
135
+ context: 'ABcd...',
136
+ challenge_script: 'http://example.com/challenge.js',
137
+ )
138
+
139
+ puts captcha.text
140
+ {"captcha_voucher":"eyJ0...","existing_token":"f2ae6..."}
141
+ ```
142
+
131
143
  *Parameters:*
132
144
 
133
145
  - `website_key`: the site key for the hCatpcha.
@@ -98,7 +98,7 @@ module TwoCaptcha
98
98
  #
99
99
  # @param [Hash] options Options hash.
100
100
  # @option options [String] :googlekey The open key of the site in which recaptcha is installed.
101
- # @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
101
+ # @option options [String] :pageurl The URL of the page where the recaptcha is present.
102
102
  #
103
103
  # @return [TwoCaptcha::Captcha] The solution of the given captcha.
104
104
  #
@@ -138,7 +138,7 @@ module TwoCaptcha
138
138
  #
139
139
  # @param [Hash] options Options hash.
140
140
  # @option options [String] :googlekey The open key of the site in which recaptcha is installed.
141
- # @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
141
+ # @option options [String] :pageurl The URL of the page where the recaptcha is present.
142
142
  # @option options [String] :action The action paramenter present on the page that uses recaptcha.
143
143
  # @option options [String] :min_score The minimum score necessary to pass the challenge.
144
144
  #
@@ -183,7 +183,7 @@ module TwoCaptcha
183
183
  #
184
184
  # @param [Hash] options Options hash.
185
185
  # @option options [String] :sitekey The key of the site in which hCaptcha is installed.
186
- # @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
186
+ # @option options [String] :pageurl The URL of the page where the hCaptcha is present.
187
187
  #
188
188
  # @return [TwoCaptcha::Captcha] The solution of the given captcha.
189
189
  #
@@ -205,6 +205,49 @@ module TwoCaptcha
205
205
  decoded_captcha
206
206
  end
207
207
 
208
+ # Solve Amazon WAF.
209
+ #
210
+ # @param [Hash] options Options hash. Check docs for the method decode_amazon_waf!.
211
+ #
212
+ # @return [TwoCaptcha::Captcha] The solution of the given captcha.
213
+ #
214
+ def decode_amazon_waf(options = {})
215
+ decode_amazon_waf!(opt)
216
+ rescue TwoCaptcha::Error => ex
217
+ TwoCaptcha::Captcha.new
218
+ end
219
+
220
+ #
221
+ # Solve Amazon WAF.
222
+ #
223
+ # @param [Hash] options Options hash.
224
+ # @option options [String] :sitekey The key of the site in which Amazon WAF is installed.
225
+ # @option options [String] :pageurl The URL of the page where the Amazon WAF is present.
226
+ # @option options [String] :iv The value of the `iv` parameter found on the page.
227
+ # @option options [String] :context The value of the `context` parameter found on the page.
228
+ # @option options [String] :challenge_script The source URL of challenge.js script on the page.
229
+ # @option options [String] :captcha_script The source URL of captcha.js script on the page
230
+ #
231
+ # @return [TwoCaptcha::Captcha] The solution of the given captcha.
232
+ #
233
+ def decode_amazon_waf!(options = {})
234
+ started_at = Time.now
235
+
236
+ fail(TwoCaptcha::ArgumentError) if options[:sitekey].empty? || options[:pageurl].empty? || options[:iv].empty? || options[:context].empty?
237
+
238
+ upload_options = { method: 'amazon_waf' }.merge(options)
239
+ decoded_captcha = upload(upload_options)
240
+
241
+ # pool untill the answer is ready
242
+ while decoded_captcha.text.to_s.empty?
243
+ sleep([polling, 10].max) # sleep at least 10 seconds
244
+ decoded_captcha = captcha(decoded_captcha.id)
245
+ fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
246
+ end
247
+
248
+ decoded_captcha
249
+ end
250
+
208
251
  # Upload a captcha to 2Captcha.
209
252
  #
210
253
  # This method will not return the solution. It helps on separating concerns.
@@ -1,4 +1,4 @@
1
1
  module TwoCaptcha
2
- VERSION = '1.8.0'
2
+ VERSION = '1.9.0'
3
3
  USER_AGENT = "TwoCaptcha/Ruby v#{VERSION}"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: two_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Barbolo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-07 00:00:00.000000000 Z
12
+ date: 2024-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.1.4
106
+ rubygems_version: 3.3.26
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Ruby API for 2Captcha (Captcha Solver as a Service)