amazon_auth 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -17
- data/amazon_auth.gemspec +1 -1
- data/exe/convert_amazon_credentials +20 -0
- data/lib/amazon_auth/client.rb +2 -2
- data/lib/amazon_auth/converter.rb +14 -2
- data/lib/amazon_auth/version.rb +1 -1
- metadata +8 -8
- data/.env.sample +0 -3
- data/bin/convert_login +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0422990dab48ee78bad2f81fc141227209f9e77c
|
4
|
+
data.tar.gz: eef8ccc48f157f0e069b2634e05ce181b29ac4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bc1f3eb5a564a99b20559461b0960795364b8295b0df22d9fde0bdb2bb547a69c345f6102347fe97bdf253971bc1c4d14a9143c1ea01475af894c098b86ada
|
7
|
+
data.tar.gz: eb081e28d47bb7f51ecfd0301f9ddcc2ea3e7fd5b42952397eb185e9e24f944991e961ecb1cc66f5705a8c7e2236e376bbde2756a1fb330ec2cb31b9081c808a
|
data/README.md
CHANGED
@@ -26,31 +26,26 @@ This may not work with newer versions of Firefox.
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
```
|
30
|
-
cp .env.sample .env
|
31
|
-
vi .env
|
32
|
-
```
|
33
|
-
|
34
29
|
### Set Amazon credentials on your local machine
|
35
30
|
|
36
|
-
[Quick] You can set
|
31
|
+
[Quick] You can set login and password in console.
|
37
32
|
|
38
33
|
[Recommended] Or you can convert them to protect them against shoulder surfing.
|
39
|
-
Run
|
40
|
-
(`AMAZON_USERNAME_CODE`
|
41
|
-
|
42
|
-
You can change the salt with `AMAZON_CODE_SALT` if you like.
|
34
|
+
Run `convert_amazon_credentials` and paste the output to _env_.
|
35
|
+
(`AMAZON_USERNAME_CODE` , `AMAZON_PASSWORD_CODE` and `AMAZON_CODE_SALT`)
|
43
36
|
|
44
37
|
### Run
|
45
38
|
|
46
|
-
|
47
|
-
bin/console
|
48
|
-
```
|
49
|
-
|
50
|
-
You can move around pages using Capybara DSL
|
39
|
+
In console, you can move around pages using Capybara DSL
|
51
40
|
|
52
41
|
```ruby
|
42
|
+
# Without credentials in .env
|
43
|
+
client = AmazonAuth::Client.new(login: 'your_amazon_email', password: 'your_amazon_password')
|
44
|
+
|
45
|
+
# With credentials in .env
|
53
46
|
client = AmazonAuth::Client.new
|
47
|
+
|
48
|
+
# Sign in
|
54
49
|
page = client.sign_in
|
55
50
|
|
56
51
|
# Continue to the page for Kindle
|
@@ -64,9 +59,18 @@ page.driver.quit
|
|
64
59
|
|
65
60
|
Some features come from https://github.com/kyamaguchi/kindle
|
66
61
|
|
67
|
-
|
62
|
+
```
|
63
|
+
git clone https://github.com/kyamaguchi/amazon_auth.git
|
64
|
+
cd amazon_auth
|
65
|
+
bundle
|
68
66
|
|
69
|
-
|
67
|
+
./exe/convert_amazon_credentials
|
68
|
+
vi .env
|
69
|
+
|
70
|
+
rspec
|
71
|
+
|
72
|
+
./bin/console
|
73
|
+
```
|
70
74
|
|
71
75
|
## Contributing
|
72
76
|
|
data/amazon_auth.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'capybara'
|
23
|
-
spec.add_runtime_dependency 'selenium-webdriver'
|
23
|
+
spec.add_runtime_dependency 'selenium-webdriver', '~> 3.2.0'
|
24
24
|
spec.add_runtime_dependency 'highline'
|
25
25
|
spec.add_runtime_dependency 'dotenv'
|
26
26
|
spec.add_runtime_dependency 'activesupport'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative "../lib/amazon_auth"
|
4
|
+
require 'highline/import'
|
5
|
+
|
6
|
+
result = []
|
7
|
+
|
8
|
+
login = ask("Enter your #{AmazonInfo.domain} username: ") { |q| q.echo = true }
|
9
|
+
passwd = ask("Enter your #{AmazonInfo.domain} password: ") { |q| q.echo = "*" }
|
10
|
+
salt = ask("Enter your salt: ") { |q| q.default = AmazonAuth::Converter.default_salt ; q.echo = true }
|
11
|
+
|
12
|
+
raise "Empty login or password" if login.to_s.size == 0 || passwd.to_s.size == 0
|
13
|
+
|
14
|
+
converter = AmazonAuth::Converter.new(salt)
|
15
|
+
|
16
|
+
puts "Put the following lines in .env"
|
17
|
+
puts
|
18
|
+
puts "AMAZON_USERNAME_CODE=#{converter.encode(login)}"
|
19
|
+
puts "AMAZON_PASSWORD_CODE=#{converter.encode(passwd)}"
|
20
|
+
puts "AMAZON_CODE_SALT=#{salt}"
|
data/lib/amazon_auth/client.rb
CHANGED
@@ -8,14 +8,14 @@ module AmazonAuth
|
|
8
8
|
if (amazon_username_code = ENV['AMAZON_USERNAME_CODE']).present?
|
9
9
|
Converter.decode(amazon_username_code)
|
10
10
|
else
|
11
|
-
|
11
|
+
raise('AMAZON_USERNAME_CODE is required.')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
@password = options.fetch(:password) do
|
15
15
|
if (amazon_password_code = ENV['AMAZON_PASSWORD_CODE']).present?
|
16
16
|
Converter.decode(amazon_password_code)
|
17
17
|
else
|
18
|
-
|
18
|
+
raise('AMAZON_PASSWORD_CODE is required.')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,18 +1,30 @@
|
|
1
1
|
module AmazonAuth
|
2
2
|
class Converter
|
3
3
|
|
4
|
-
def
|
4
|
+
def initialize(salt)
|
5
|
+
@salt = salt
|
6
|
+
end
|
7
|
+
|
8
|
+
def encode(str)
|
5
9
|
raise "Empty string" if str.to_s.size == 0
|
6
10
|
Base64.strict_encode64("#{salt}#{str}")
|
7
11
|
end
|
8
12
|
|
13
|
+
def salt
|
14
|
+
@salt || self.class.salt
|
15
|
+
end
|
16
|
+
|
9
17
|
def self.decode(code)
|
10
18
|
raise "Empty string" if code.to_s.size == 0
|
11
19
|
Base64.strict_decode64(code).gsub(/\A#{salt}/, '')
|
12
20
|
end
|
13
21
|
|
14
22
|
def self.salt
|
15
|
-
ENV['AMAZON_CODE_SALT'] ||
|
23
|
+
ENV['AMAZON_CODE_SALT'].presence || raise('salt is missing')
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.default_salt
|
27
|
+
"iloveamazon"
|
16
28
|
end
|
17
29
|
end
|
18
30
|
end
|
data/lib/amazon_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuho Yamaguchi
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: selenium-webdriver
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: highline
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,11 +125,11 @@ dependencies:
|
|
125
125
|
description: Login amazon.
|
126
126
|
email:
|
127
127
|
- kzh.yap@gmail.com
|
128
|
-
executables:
|
128
|
+
executables:
|
129
|
+
- convert_amazon_credentials
|
129
130
|
extensions: []
|
130
131
|
extra_rdoc_files: []
|
131
132
|
files:
|
132
|
-
- ".env.sample"
|
133
133
|
- ".gitignore"
|
134
134
|
- ".rspec"
|
135
135
|
- ".travis.yml"
|
@@ -139,8 +139,8 @@ files:
|
|
139
139
|
- Rakefile
|
140
140
|
- amazon_auth.gemspec
|
141
141
|
- bin/console
|
142
|
-
- bin/convert_login
|
143
142
|
- bin/setup
|
143
|
+
- exe/convert_amazon_credentials
|
144
144
|
- lib/amazon_auth.rb
|
145
145
|
- lib/amazon_auth/amazon_info.rb
|
146
146
|
- lib/amazon_auth/client.rb
|
data/.env.sample
DELETED
data/bin/convert_login
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative "../lib/amazon_auth"
|
4
|
-
require 'highline/import'
|
5
|
-
|
6
|
-
result = []
|
7
|
-
|
8
|
-
login = if amazon_username = ENV['AMAZON_USERNAME']
|
9
|
-
amazon_username
|
10
|
-
else
|
11
|
-
ask("Enter your #{AmazonInfo.domain} username: ") { |q| q.echo = true } unless login = ARGV[0]
|
12
|
-
end
|
13
|
-
passwd = ENV['AMAZON_PASSWORD'] || ask("Enter your #{AmazonInfo.domain} password: ") { |q| q.echo = "*" }
|
14
|
-
|
15
|
-
raise "Empty login or password" if login.to_s.size == 0 || passwd.to_s.size == 0
|
16
|
-
|
17
|
-
puts "Put the following lines in .env (Remove AMAZON_USERNAME and AMAZON_PASSWORD if you have)"
|
18
|
-
puts
|
19
|
-
puts "AMAZON_USERNAME_CODE=#{AmazonAuth::Converter.encode(login)}"
|
20
|
-
puts "AMAZON_PASSWORD_CODE=#{AmazonAuth::Converter.encode(passwd)}"
|