amazon_auth 0.7.0 → 0.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: 2616112a7c77ce7a370145836360fc55df643716450e6222d95affa6c1b942ec
4
- data.tar.gz: e96f0dad4d371aeaf0c6bd7dc325cd252fea806e992c322aceef88e01e5c7cc4
3
+ metadata.gz: 6ba25f9aeee6baa2987b8788859f81dd11f8d3b8c81d6320bef15fa7b0df47ea
4
+ data.tar.gz: 0b5443a962d8527a6d58083430dc923f80327a3efc655c9701b3b9b97004cb32
5
5
  SHA512:
6
- metadata.gz: a18f9d6ce597e2c12a96bdf6748bc8eda365533f8d5daebd968282a58dfb330cf12adfc7c057b529b1b5e20a05a9c61e9a41ba5cf8c0922b27db921f656f0f4a
7
- data.tar.gz: 99b3832589d28b9e4eebf5bf4fc3fe590ecc5b57ec6031a5b5e4854d472add8d700b1abf118d10d9dfb441454d1ce2152c6d95220726b474e446f200b7d8b1db
6
+ metadata.gz: 2063595a48860cb43818b7e0be372039989fc9250ffae50276bc36d9ddd75844ec582cf65898ec0ec16cc9eb23e8990d416b2e619b509b554d51de2a99499e1a
7
+ data.tar.gz: d000ea349dbfe3e0127930a11d1f2aa35c0d9f71ec045b508771264cdfb19eee558bfd6d27babbcd684dd0289f7c68920d79adedf3e6829f61d0a1733e584b72
data/README.md CHANGED
@@ -70,6 +70,8 @@ envchain amazon rails console
70
70
  In console, you can move around pages using Capybara DSL
71
71
 
72
72
  ```ruby
73
+ require 'amazon_auth'
74
+
73
75
  # Without credentials in .env
74
76
  client = AmazonAuth::Client.new(login: 'your_amazon_email', password: 'your_amazon_password')
75
77
 
@@ -80,7 +82,7 @@ client = AmazonAuth::Client.new
80
82
  client.sign_in
81
83
 
82
84
  # Continue to the page for Kindle
83
- link = client.links_for('#navFooter a').find{|link| link =~ %r{/gp/digital/fiona/manage/} }
85
+ link = client.links_for('#navFooter a').find{|link| link =~ %r{/hz/mycd/myx} }
84
86
  client.session.visit link
85
87
  ```
86
88
 
@@ -94,14 +96,16 @@ e.g. `AMAZON_DOMAIN=amazon.co.jp` for Japanese site
94
96
 
95
97
  Using [capybara-sessionkeeper gem](https://github.com/kyamaguchi/capybara-sessionkeeper)
96
98
 
97
- ```
99
+ ```ruby
98
100
  client = AmazonAuth::Client.new(keep_cookie: true, debug: true)
101
+ client.sign_in
99
102
  ```
100
103
 
101
104
  You can change Capyabra.save_path when it isn't set
102
105
 
103
- ```
106
+ ```ruby
104
107
  client = AmazonAuth::Client.new(keep_cookie: true, save_path: 'tmp/cookies', debug: true)
108
+ client.sign_in
105
109
  ```
106
110
 
107
111
  ### Logging
@@ -122,7 +126,7 @@ client = AmazonAuth::Client.new(debug: true)
122
126
 
123
127
  In console,
124
128
 
125
- ```
129
+ ```ruby
126
130
  client = AmazonAuth::Client.new(driver: :firefox)
127
131
  ```
128
132
 
data/amazon_auth.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/kyamaguchi/amazon_auth"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.start_with?('.') }
17
17
  spec.bindir = "exe"
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
@@ -7,7 +7,7 @@ module AmazonAuth
7
7
 
8
8
  def encode(str)
9
9
  raise "Empty string" if str.to_s.size == 0
10
- Base64.strict_encode64("#{salt}#{str}")
10
+ ::Base64.strict_encode64("#{salt}#{str}")
11
11
  end
12
12
 
13
13
  def salt
@@ -16,7 +16,7 @@ module AmazonAuth
16
16
 
17
17
  def self.decode(code)
18
18
  raise "Empty string" if code.to_s.size == 0
19
- Base64.strict_decode64(code).gsub(/\A#{salt}/, '')
19
+ ::Base64.strict_decode64(code).gsub(/\A#{salt}/, '')
20
20
  end
21
21
 
22
22
  def self.salt
@@ -57,7 +57,12 @@ module AmazonAuth
57
57
 
58
58
  debug "Begin submit_signin_form"
59
59
  unless session.has_selector?('#signInSubmit')
60
- if session.has_selector?('input#continue') && session.has_selector?('input#ap_email')
60
+ if session.has_selector?('#continue input.a-button-input') && session.has_selector?('input#ap_email_login')
61
+ log "Found a form which asks only email (v2)"
62
+ session.fill_in 'ap_email_login', with: login
63
+ session.first('#continue input.a-button-input').click
64
+ # Maybe the following form is deprecated
65
+ elsif session.has_selector?('input#continue') && session.has_selector?('input#ap_email')
61
66
  log "Found a form which asks only email"
62
67
  session.fill_in 'ap_email', with: login
63
68
  session.first('input#continue').click
@@ -1,3 +1,3 @@
1
1
  module AmazonAuth
2
- VERSION = "0.7.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/lib/amazon_auth.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'dotenv'
2
2
  Dotenv.load
3
+ require 'base64'
3
4
  require "active_support/all"
4
5
  require "capybara"
5
6
  require "capybara/sessionkeeper"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuho Yamaguchi
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-07-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: capybara
@@ -158,9 +157,6 @@ executables:
158
157
  extensions: []
159
158
  extra_rdoc_files: []
160
159
  files:
161
- - ".circleci/config.yml"
162
- - ".gitignore"
163
- - ".rspec"
164
160
  - Gemfile
165
161
  - LICENSE.txt
166
162
  - README.md
@@ -181,7 +177,6 @@ homepage: https://github.com/kyamaguchi/amazon_auth
181
177
  licenses:
182
178
  - MIT
183
179
  metadata: {}
184
- post_install_message:
185
180
  rdoc_options: []
186
181
  require_paths:
187
182
  - lib
@@ -196,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
191
  - !ruby/object:Gem::Version
197
192
  version: '0'
198
193
  requirements: []
199
- rubygems_version: 3.1.6
200
- signing_key:
194
+ rubygems_version: 3.6.7
201
195
  specification_version: 4
202
196
  summary: Login amazon.
203
197
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,21 +0,0 @@
1
- version: 2.1
2
-
3
- jobs:
4
- test:
5
- parameters:
6
- ruby-version:
7
- type: string
8
- docker:
9
- - image: cimg/ruby:<< parameters.ruby-version >>-browsers
10
- steps:
11
- - checkout
12
- - run: bundle install
13
- - run: bundle exec rspec
14
-
15
- workflows:
16
- all-tests:
17
- jobs:
18
- - test:
19
- matrix:
20
- parameters:
21
- ruby-version: ["2.7.5", "3.0.3"]
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /.env
11
- /.env.development
12
- /.byebug_history
13
- /.ruby-version
14
- /.rspec_status
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color