authy 2.7.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -11
- data/README.md +39 -195
- data/authy.gemspec +0 -2
- data/examples/Gemfile +6 -0
- data/examples/README.md +48 -0
- data/examples/demo.rb +23 -19
- data/lib/authy.rb +0 -2
- data/lib/authy/api.rb +64 -58
- data/lib/authy/onetouch.rb +1 -1
- data/lib/authy/phone_verification.rb +5 -2
- data/lib/authy/url_helpers.rb +0 -4
- data/lib/authy/version.rb +1 -1
- data/spec/authy/api_spec.rb +384 -91
- data/spec/authy/onetouch_spec.rb +86 -30
- data/spec/authy/phone_verification_spec.rb +185 -54
- data/spec/authy/url_helpers_spec.rb +0 -12
- data/spec/spec_helper.rb +1 -2
- data/verify-legacy-v1.md +35 -0
- metadata +8 -11
- data/.travis.yml +0 -12
- data/Gemfile.lock +0 -118
- data/examples/pv-check.rb +0 -9
- data/examples/pv.rb +0 -12
- data/lib/authy/core_ext.rb +0 -26
- data/lib/authy/phone_intelligence.rb +0 -23
- data/spec/authy/phone_intelligence_spec.rb +0 -94
@@ -5,18 +5,6 @@ describe "Authy::URL" do
|
|
5
5
|
include Authy::URL
|
6
6
|
end
|
7
7
|
|
8
|
-
describe "escape_for_url" do
|
9
|
-
it "should user URI escape" do
|
10
|
-
expect(URI).to receive :escape
|
11
|
-
Dummy.escape_for_url("that")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should use Regexp" do
|
15
|
-
expect(Regexp).to receive(:new).with("[^#{URI::PATTERN::UNRESERVED}]").and_return(/a/)
|
16
|
-
Dummy.escape_for_url("that")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
8
|
describe "to_param" do
|
21
9
|
it "should user HTTP::Message.escape" do
|
22
10
|
expect(HTTP::Message).to receive(:escape).exactly(2).times.and_return "basic string"
|
data/spec/spec_helper.rb
CHANGED
@@ -11,8 +11,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.before(:suite) do
|
14
|
-
Authy.
|
15
|
-
Authy.api_key = 'bf12974d70818a08199d17d5e2bae630'
|
14
|
+
Authy.api_key = 'valid_api_key'
|
16
15
|
end
|
17
16
|
|
18
17
|
def generate_email
|
data/verify-legacy-v1.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Phone Verification V1
|
2
|
+
|
3
|
+
[Version 2 of the Verify API is now available!](https://www.twilio.com/docs/verify/api) V2 has an improved developer experience and new features. Some of the features of the V2 API include:
|
4
|
+
|
5
|
+
* Twilio helper libraries in JavaScript, Java, C#, Python, Ruby, and PHP
|
6
|
+
* PSD2 Secure Customer Authentication Support
|
7
|
+
* Improved Visibility and Insights
|
8
|
+
|
9
|
+
You are currently viewing Version 1. V1 of the API will be maintained for the time being, but any new features and development will be on Version 2. We strongly encourage you to do any new development with API V2. Check out the migration guide or the API Reference for more information.
|
10
|
+
|
11
|
+
### API Reference
|
12
|
+
|
13
|
+
API Reference is available at https://www.twilio.com/docs/verify/api/v1
|
14
|
+
|
15
|
+
### Starting a phone verification
|
16
|
+
|
17
|
+
`Authy::PhoneVerification.start` takes a country code, phone number and a method (sms or call) to deliver the code.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
response = Authy::PhoneVerification.start(via: "sms", country_code: 1, phone_number: "111-111-1111")
|
21
|
+
if response.ok?
|
22
|
+
# verification was started
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
### Checking a phone verification
|
27
|
+
|
28
|
+
`Authy::PhoneVerification.check` takes a country code, phone number and a verification code.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
response = Authy::PhoneVerification.check(verification_code: "1234", country_code: 1, phone_number: "111-111-1111")
|
32
|
+
if response.ok?
|
33
|
+
# verification was successful
|
34
|
+
end
|
35
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Authy Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -131,26 +131,24 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- ".document"
|
134
|
+
- ".github/workflows/build.yml"
|
134
135
|
- ".gitignore"
|
135
136
|
- ".rspec"
|
136
|
-
-
|
137
|
+
- CHANGELOG.md
|
137
138
|
- Gemfile
|
138
|
-
- Gemfile.lock
|
139
139
|
- LICENSE.txt
|
140
140
|
- README.md
|
141
141
|
- Rakefile
|
142
142
|
- authy.gemspec
|
143
143
|
- bin/authy-api-console
|
144
|
+
- examples/Gemfile
|
145
|
+
- examples/README.md
|
144
146
|
- examples/demo.rb
|
145
|
-
- examples/pv-check.rb
|
146
|
-
- examples/pv.rb
|
147
147
|
- lib/authy.rb
|
148
148
|
- lib/authy/api.rb
|
149
149
|
- lib/authy/config.rb
|
150
|
-
- lib/authy/core_ext.rb
|
151
150
|
- lib/authy/models/user.rb
|
152
151
|
- lib/authy/onetouch.rb
|
153
|
-
- lib/authy/phone_intelligence.rb
|
154
152
|
- lib/authy/phone_verification.rb
|
155
153
|
- lib/authy/response.rb
|
156
154
|
- lib/authy/url_helpers.rb
|
@@ -158,11 +156,11 @@ files:
|
|
158
156
|
- spec/authy/api_spec.rb
|
159
157
|
- spec/authy/config_spec.rb
|
160
158
|
- spec/authy/onetouch_spec.rb
|
161
|
-
- spec/authy/phone_intelligence_spec.rb
|
162
159
|
- spec/authy/phone_verification_spec.rb
|
163
160
|
- spec/authy/response_spec.rb
|
164
161
|
- spec/authy/url_helpers_spec.rb
|
165
162
|
- spec/spec_helper.rb
|
163
|
+
- verify-legacy-v1.md
|
166
164
|
homepage: https://github.com/authy/authy-ruby
|
167
165
|
licenses:
|
168
166
|
- MIT
|
@@ -182,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
180
|
- !ruby/object:Gem::Version
|
183
181
|
version: '0'
|
184
182
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.1.2
|
186
184
|
signing_key:
|
187
185
|
specification_version: 4
|
188
186
|
summary: Ruby library to access Authy services
|
@@ -190,7 +188,6 @@ test_files:
|
|
190
188
|
- spec/authy/api_spec.rb
|
191
189
|
- spec/authy/config_spec.rb
|
192
190
|
- spec/authy/onetouch_spec.rb
|
193
|
-
- spec/authy/phone_intelligence_spec.rb
|
194
191
|
- spec/authy/phone_verification_spec.rb
|
195
192
|
- spec/authy/response_spec.rb
|
196
193
|
- spec/authy/url_helpers_spec.rb
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.4.0)
|
5
|
-
ast (2.3.0)
|
6
|
-
axiom-types (0.1.1)
|
7
|
-
descendants_tracker (~> 0.0.4)
|
8
|
-
ice_nine (~> 0.11.0)
|
9
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
10
|
-
builder (3.2.3)
|
11
|
-
codeclimate-engine-rb (0.4.1)
|
12
|
-
virtus (~> 1.0)
|
13
|
-
coderay (1.1.2)
|
14
|
-
coercible (1.0.0)
|
15
|
-
descendants_tracker (~> 0.0.1)
|
16
|
-
descendants_tracker (0.0.4)
|
17
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
18
|
-
diff-lcs (1.3)
|
19
|
-
docile (1.1.5)
|
20
|
-
equalizer (0.0.11)
|
21
|
-
faraday (0.9.2)
|
22
|
-
multipart-post (>= 1.2, < 3)
|
23
|
-
git (1.3.0)
|
24
|
-
github_api (0.16.0)
|
25
|
-
addressable (~> 2.4.0)
|
26
|
-
descendants_tracker (~> 0.0.4)
|
27
|
-
faraday (~> 0.8, < 0.10)
|
28
|
-
hashie (>= 3.4)
|
29
|
-
mime-types (>= 1.16, < 3.0)
|
30
|
-
oauth2 (~> 1.0)
|
31
|
-
hashie (3.5.7)
|
32
|
-
highline (1.7.10)
|
33
|
-
httpclient (2.8.3)
|
34
|
-
ice_nine (0.11.2)
|
35
|
-
jeweler (2.3.7)
|
36
|
-
builder
|
37
|
-
bundler (>= 1)
|
38
|
-
git (>= 1.2.5)
|
39
|
-
github_api (~> 0.16.0)
|
40
|
-
highline (>= 1.6.15)
|
41
|
-
nokogiri (>= 1.5.10)
|
42
|
-
psych (~> 2.2)
|
43
|
-
rake
|
44
|
-
rdoc
|
45
|
-
semver2
|
46
|
-
json (2.1.0)
|
47
|
-
jwt (1.5.6)
|
48
|
-
method_source (0.9.0)
|
49
|
-
mime-types (2.99.3)
|
50
|
-
mini_portile2 (2.3.0)
|
51
|
-
multi_json (1.12.2)
|
52
|
-
multi_xml (0.6.0)
|
53
|
-
multipart-post (2.0.0)
|
54
|
-
nokogiri (1.8.2)
|
55
|
-
mini_portile2 (~> 2.3.0)
|
56
|
-
oauth2 (1.4.0)
|
57
|
-
faraday (>= 0.8, < 0.13)
|
58
|
-
jwt (~> 1.0)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
multi_xml (~> 0.5)
|
61
|
-
rack (>= 1.2, < 3)
|
62
|
-
parser (2.4.0.2)
|
63
|
-
ast (~> 2.3)
|
64
|
-
pry (0.11.3)
|
65
|
-
coderay (~> 1.1.0)
|
66
|
-
method_source (~> 0.9.0)
|
67
|
-
psych (2.2.4)
|
68
|
-
rack (2.0.3)
|
69
|
-
rainbow (2.2.2)
|
70
|
-
rake
|
71
|
-
rake (12.3.0)
|
72
|
-
rdoc (6.0.0)
|
73
|
-
reek (4.7.3)
|
74
|
-
codeclimate-engine-rb (~> 0.4.0)
|
75
|
-
parser (>= 2.4.0.0, < 2.5)
|
76
|
-
rainbow (~> 2.0)
|
77
|
-
rspec (3.7.0)
|
78
|
-
rspec-core (~> 3.7.0)
|
79
|
-
rspec-expectations (~> 3.7.0)
|
80
|
-
rspec-mocks (~> 3.7.0)
|
81
|
-
rspec-core (3.7.0)
|
82
|
-
rspec-support (~> 3.7.0)
|
83
|
-
rspec-expectations (3.7.0)
|
84
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
-
rspec-support (~> 3.7.0)
|
86
|
-
rspec-mocks (3.7.0)
|
87
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
-
rspec-support (~> 3.7.0)
|
89
|
-
rspec-support (3.7.0)
|
90
|
-
semver2 (3.4.2)
|
91
|
-
simplecov (0.15.1)
|
92
|
-
docile (~> 1.1.0)
|
93
|
-
json (>= 1.8, < 3)
|
94
|
-
simplecov-html (~> 0.10.0)
|
95
|
-
simplecov-html (0.10.2)
|
96
|
-
thread_safe (0.3.6)
|
97
|
-
virtus (1.0.5)
|
98
|
-
axiom-types (~> 0.1)
|
99
|
-
coercible (~> 1.0)
|
100
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
101
|
-
equalizer (~> 0.0, >= 0.0.9)
|
102
|
-
yard (0.9.12)
|
103
|
-
|
104
|
-
PLATFORMS
|
105
|
-
ruby
|
106
|
-
|
107
|
-
DEPENDENCIES
|
108
|
-
httpclient (>= 2.5.3.3)
|
109
|
-
jeweler
|
110
|
-
pry
|
111
|
-
rdoc
|
112
|
-
reek
|
113
|
-
rspec
|
114
|
-
simplecov
|
115
|
-
yard (~> 0.9.11)
|
116
|
-
|
117
|
-
BUNDLED WITH
|
118
|
-
1.16.1
|
data/examples/pv-check.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'authy' # gem install authy
|
2
|
-
|
3
|
-
Authy.api_url = "https://api.authy.com"
|
4
|
-
Authy.api_key = "[YOUR_API_KEY]"
|
5
|
-
|
6
|
-
response = Authy::PhoneVerification.check(verification_code: "1234", country_code: [YOUR_COUNTRY_CODE], phone_number: "[YOUR_PHONE_NUMBER]")
|
7
|
-
if response.ok?
|
8
|
-
# verification was started
|
9
|
-
end
|
data/examples/pv.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'authy' # gem install authy
|
2
|
-
|
3
|
-
Authy.api_url = "https://api.authy.com"
|
4
|
-
Authy.api_key = "[YOUR_API_KEY]"
|
5
|
-
|
6
|
-
# Custom Code example
|
7
|
-
# response = Authy::PhoneVerification.start(via: "sms", country_code: 1, phone_number: "[YOUR_NUMBER]", custom_code: "1234")
|
8
|
-
|
9
|
-
response = Authy::PhoneVerification.start(via: "sms", country_code: [YOUR_COUNTRY_CODE], phone_number: "[YOUR_PHONE_NUMBER]")
|
10
|
-
if response.ok?
|
11
|
-
# verification was started
|
12
|
-
end
|
data/lib/authy/core_ext.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def self.try_convert(value)
|
3
|
-
return value if value.instance_of?(Hash)
|
4
|
-
return nil if !value.respond_to?(:to_hash)
|
5
|
-
converted = value.to_hash
|
6
|
-
return converted if converted.instance_of?(Hash)
|
7
|
-
|
8
|
-
cname = value.class.name
|
9
|
-
raise TypeError, "can't convert %s to %s (%s#%s gives %s)" %
|
10
|
-
[cname, Hash.name, cname, :to_hash, converted.class.name]
|
11
|
-
end unless Hash.respond_to?(:try_convert)
|
12
|
-
end
|
13
|
-
|
14
|
-
class Array
|
15
|
-
def self.try_convert(value)
|
16
|
-
return value if value.instance_of?(Array)
|
17
|
-
return nil if !value.respond_to?(:to_ary)
|
18
|
-
converted = value.to_ary
|
19
|
-
return converted if converted.instance_of?(Array)
|
20
|
-
|
21
|
-
cname = value.class.name
|
22
|
-
raise TypeError, "can't convert %s to %s (%s#%s gives %s)" %
|
23
|
-
[cname, Array.name, cname, :to_ary, converted.class.name]
|
24
|
-
end unless Array.respond_to?(:try_convert)
|
25
|
-
end
|
26
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Authy
|
2
|
-
class PhoneIntelligence < Authy::API
|
3
|
-
|
4
|
-
# @deprecated
|
5
|
-
def self.verification_start(params)
|
6
|
-
warn "[DEPRECATION] `PhoneIntelligence.verification_start` is deprecated. Please use `PhoneVerification.start` instead."
|
7
|
-
Authy::PhoneVerification.start(params)
|
8
|
-
end
|
9
|
-
|
10
|
-
# @deprecated
|
11
|
-
def self.verification_check(params)
|
12
|
-
warn "[DEPRECATION] `PhoneIntelligence.verification_check` is deprecated. Please use `PhoneVerification.check` instead."
|
13
|
-
Authy::PhoneVerification.check(params)
|
14
|
-
end
|
15
|
-
|
16
|
-
# options:
|
17
|
-
# :country_code Numeric calling country code of the country.
|
18
|
-
# :phone_number The persons phone number.
|
19
|
-
def self.info(params)
|
20
|
-
get_request("protected/json/phones/info", params)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Authy::PhoneIntelligence" do
|
4
|
-
describe "Sending the verification code" do
|
5
|
-
|
6
|
-
it "should send the code via SMS" do
|
7
|
-
pending("API is not returning expected response in this case. The test phone number is invalid.")
|
8
|
-
response = Authy::PhoneIntelligence.verification_start(
|
9
|
-
via: "sms",
|
10
|
-
country_code: "1",
|
11
|
-
phone_number: "111-111-1111"
|
12
|
-
)
|
13
|
-
|
14
|
-
expect(response).to be_kind_of(Authy::Response)
|
15
|
-
expect(response).to be_ok
|
16
|
-
expect(response.message).to eq "Text message sent to +1 111-111-1111."
|
17
|
-
end
|
18
|
-
|
19
|
-
# it "should send the code via CALL" do
|
20
|
-
# response = Authy::PhoneIntelligence.verification_start(
|
21
|
-
# via: "call",
|
22
|
-
# country_code: "1",
|
23
|
-
# phone_number: "111-111-1111"
|
24
|
-
# )
|
25
|
-
|
26
|
-
# response.should be_kind_of(Authy::Response)
|
27
|
-
# response.success.should be_truthy
|
28
|
-
# response.message.should == "Text message sent to +1 111-111-1111."
|
29
|
-
# end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "validate the fields required" do
|
33
|
-
it "should return an error. Country code is required" do
|
34
|
-
response = Authy::PhoneIntelligence.verification_start(
|
35
|
-
via: "sms",
|
36
|
-
phone_number: "111-111-1111"
|
37
|
-
)
|
38
|
-
|
39
|
-
expect(response).to_not be_ok
|
40
|
-
expect(response.errors['message']).to match(/country_code - Parameter is required/)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return an error. Cellphone is invalid" do
|
44
|
-
response = Authy::PhoneIntelligence.verification_start(
|
45
|
-
via: "sms",
|
46
|
-
country_code: "1",
|
47
|
-
phone_number: "123"
|
48
|
-
)
|
49
|
-
|
50
|
-
expect(response).to_not be_ok
|
51
|
-
expect(response.errors['message']).to match(/Phone number is invalid/)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "Check the verification code" do
|
56
|
-
it "should return success true if code is correct" do
|
57
|
-
pending("API is not returning expected response in this case. The test phone number is invalid.")
|
58
|
-
|
59
|
-
response = Authy::PhoneIntelligence.verification_check(
|
60
|
-
country_code: "1",
|
61
|
-
phone_number: "111-111-1111",
|
62
|
-
verification_code: "0000"
|
63
|
-
)
|
64
|
-
|
65
|
-
expect(response).to be_ok
|
66
|
-
expect(response.message).to eq "Verification code is correct."
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return an error if code is incorrect" do
|
70
|
-
pending("API is not returning expected response in this case. The test phone number is invalid.")
|
71
|
-
|
72
|
-
response = Authy::PhoneIntelligence.verification_check(
|
73
|
-
country_code: "1",
|
74
|
-
phone_number: "111-111-1111",
|
75
|
-
verification_code: "1234"
|
76
|
-
)
|
77
|
-
|
78
|
-
expect(response).to_not be_ok
|
79
|
-
expect(response.message).to eq 'Verification code is incorrect.'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "Requesting phone number information" do
|
84
|
-
it "should return the phone information" do
|
85
|
-
response = Authy::PhoneIntelligence.info(
|
86
|
-
country_code: '1',
|
87
|
-
phone_number: '7754615609'
|
88
|
-
)
|
89
|
-
|
90
|
-
expect(response).to be_ok
|
91
|
-
expect(response.message).to match(/Phone number information as of/)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|