authy 2.5.0.pre → 2.6.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
  SHA1:
3
- metadata.gz: 5848053b422cea54e69e26d534fdf5b040e6fc99
4
- data.tar.gz: a50794e2a7ac0e82e3039743688ac8965af94259
3
+ metadata.gz: 50f02ebdae5f8d72a5f3199ae44feae6ff4a5c83
4
+ data.tar.gz: abb373f80d53746ac1c0d500823dbc4986ec53c8
5
5
  SHA512:
6
- metadata.gz: 2732e0a2bb42b00878dd4ac3a1e7df58507bcc3f6ecfe8182cf1f24ee801306d7c07060e7d5887f4ed2099339be88eeeb425dcc6b2fa7282c2340da94da9f976
7
- data.tar.gz: 95273c144d7d607b876fa4dc63376798149e5fc736bb31b468053b1160371dde33653b9e15f4288926427d3cb69a874e89fc49c9a1d2a9cbfba51897105744e6
6
+ metadata.gz: 268299200179efd6c7ba165202dcffe54b3376f3e105de6ddf84e75140367dea212ca3f06394c447898f44904682d6b1367e38f0336b65f2514b03fb0d9ddf73
7
+ data.tar.gz: cee6a3a6df933fa48b16ff3b9f58b035257a633ae6ac9b4fbcc8265305a1ca5b650231cdbd02d9e15238ce23491a469b28a4e2f9e9fcc2e6b792665f66e305c6
data/.gitignore CHANGED
@@ -54,5 +54,4 @@ examples/db
54
54
  .ruby-version
55
55
  .ruby-gemset
56
56
  .rvmrc
57
- Gemfile.lock
58
57
 
@@ -0,0 +1,122 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ abstract_type (0.0.7)
5
+ adamantium (0.2.0)
6
+ ice_nine (~> 0.11.0)
7
+ memoizable (~> 0.4.0)
8
+ addressable (2.3.8)
9
+ ast (2.1.0)
10
+ builder (3.2.2)
11
+ coderay (1.1.0)
12
+ concord (0.1.5)
13
+ adamantium (~> 0.2.0)
14
+ equalizer (~> 0.0.9)
15
+ descendants_tracker (0.0.4)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ diff-lcs (1.2.5)
18
+ docile (1.1.5)
19
+ equalizer (0.0.11)
20
+ faraday (0.9.2)
21
+ multipart-post (>= 1.2, < 3)
22
+ git (1.2.9.1)
23
+ github_api (0.12.4)
24
+ addressable (~> 2.3)
25
+ descendants_tracker (~> 0.0.4)
26
+ faraday (~> 0.8, < 0.10)
27
+ hashie (>= 3.4)
28
+ multi_json (>= 1.7.5, < 2.0)
29
+ nokogiri (~> 1.6.6)
30
+ oauth2
31
+ hashie (3.4.3)
32
+ highline (1.7.8)
33
+ httpclient (2.7.0.1)
34
+ ice_nine (0.11.1)
35
+ jeweler (2.0.1)
36
+ builder
37
+ bundler (>= 1.0)
38
+ git (>= 1.2.5)
39
+ github_api
40
+ highline (>= 1.6.15)
41
+ nokogiri (>= 1.5.10)
42
+ rake
43
+ rdoc
44
+ json (1.8.3)
45
+ jwt (1.5.2)
46
+ memoizable (0.4.2)
47
+ thread_safe (~> 0.3, >= 0.3.1)
48
+ method_source (0.8.2)
49
+ mini_portile (0.6.2)
50
+ multi_json (1.11.2)
51
+ multi_xml (0.5.5)
52
+ multipart-post (2.0.0)
53
+ nokogiri (1.6.6.2)
54
+ mini_portile (~> 0.6.0)
55
+ oauth2 (1.0.0)
56
+ faraday (>= 0.8, < 0.10)
57
+ jwt (~> 1.0)
58
+ multi_json (~> 1.3)
59
+ multi_xml (~> 0.5)
60
+ rack (~> 1.2)
61
+ parser (2.2.3.0)
62
+ ast (>= 1.1, < 3.0)
63
+ private_attr (1.1.0)
64
+ procto (0.0.2)
65
+ pry (0.10.3)
66
+ coderay (~> 1.1.0)
67
+ method_source (~> 0.8.1)
68
+ slop (~> 3.4)
69
+ rack (1.6.4)
70
+ rainbow (2.0.0)
71
+ rake (10.4.2)
72
+ rdoc (4.2.0)
73
+ reek (3.6.0)
74
+ parser (~> 2.2, >= 2.2.2.5)
75
+ private_attr (~> 1.1)
76
+ rainbow (~> 2.0)
77
+ unparser (~> 0.2.2)
78
+ rspec (3.3.0)
79
+ rspec-core (~> 3.3.0)
80
+ rspec-expectations (~> 3.3.0)
81
+ rspec-mocks (~> 3.3.0)
82
+ rspec-core (3.3.2)
83
+ rspec-support (~> 3.3.0)
84
+ rspec-expectations (3.3.1)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.3.0)
87
+ rspec-mocks (3.3.2)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.3.0)
90
+ rspec-support (3.3.0)
91
+ simplecov (0.10.0)
92
+ docile (~> 1.1.0)
93
+ json (~> 1.8)
94
+ simplecov-html (~> 0.10.0)
95
+ simplecov-html (0.10.0)
96
+ slop (3.6.0)
97
+ thread_safe (0.3.5)
98
+ unparser (0.2.4)
99
+ abstract_type (~> 0.0.7)
100
+ adamantium (~> 0.2.0)
101
+ concord (~> 0.1.5)
102
+ diff-lcs (~> 1.2.5)
103
+ equalizer (~> 0.0.9)
104
+ parser (~> 2.2.2)
105
+ procto (~> 0.0.2)
106
+ yard (0.8.7.6)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ httpclient (>= 2.5.3.3)
113
+ jeweler
114
+ pry
115
+ rdoc
116
+ reek
117
+ rspec
118
+ simplecov
119
+ yard
120
+
121
+ BUNDLED WITH
122
+ 1.10.6
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2014 Authy Inc
1
+ Copyright (c) 2012-2016 Authy Inc
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -134,7 +134,32 @@ This call will be ignored if the user is using the Authy Mobile App. If you ensu
134
134
  end
135
135
  ```
136
136
 
137
- ### Contributing to authy
137
+ ## Phone Verification
138
+
139
+ ### Starting a phone verification
140
+
141
+ `Authy::PhoneVerification.start` takes a country code, phone number and a method (sms or call) to deliver the code.
142
+
143
+ ```ruby
144
+ response = Authy::PhoneVerification.start(via: "sms", country_code: 1, phone_number: "111-111-1111")
145
+ if response.ok?
146
+ # verification was started
147
+ end
148
+ ```
149
+
150
+ ### Checking a phone verification
151
+
152
+ `Authy::PhoneVerification.check` takes a country code, phone number and a verification code.
153
+
154
+ ```ruby
155
+ response = Authy::PhoneVerification.start(verification_code: "1234", country_code: 1, phone_number: "111-111-1111")
156
+ if response.ok?
157
+ # verification was successful
158
+ end
159
+ ```
160
+
161
+
162
+ ## Contributing to authy
138
163
 
139
164
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
140
165
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -147,5 +172,5 @@ This call will be ignored if the user is using the Authy Mobile App. If you ensu
147
172
  Copyright
148
173
  ==
149
174
 
150
- Copyright (c) 2012-2014 Authy Inc. See LICENSE.txt for
175
+ Copyright (c) 2012-2016 Authy Inc. See LICENSE.txt for
151
176
  further details.
@@ -12,4 +12,5 @@ require 'authy/models/user'
12
12
  require 'authy/config'
13
13
  require 'authy/api'
14
14
  require 'authy/phone_intelligence'
15
+ require 'authy/phone_verification'
15
16
  require 'authy/onetouch'
@@ -1,33 +1,39 @@
1
1
  module Authy
2
2
  class OneTouch < Authy::API
3
3
 
4
+ # Maximum String size for the parameters
5
+ MAX_STRING_SIZE = 200
6
+
4
7
  # options:
5
8
  # :id
6
9
  # :details Hash containing the approval request details
7
10
  # :hidden_details
8
11
  # :phone_number The persons phone number.
9
12
  def self.send_approval_request(params)
10
- user_id = params.delete(:id) || params.delete('id')
11
- message = (params.delete(:message) || params.delete('message')).to_s
12
- details = params.delete(:details) || params.delete('details')
13
- hidden_details = params.delete(:hidden_details) || params.delete('hidden_details')
14
- logos = params.delete(:logos) || params.delete('logos')
13
+ user_id = params.delete(:id) || params.delete('id')
14
+ message = (params.delete(:message) || params.delete('message')).to_s
15
+ details = params.delete(:details) || params.delete('details')
16
+ hidden_details = params.delete(:hidden_details) || params.delete('hidden_details')
17
+ logos = params.delete(:logos) || params.delete('logos')
18
+ seconds_to_expire = params.delete(:seconds_to_expire) || params.delete('seconds_to_expire')
15
19
 
16
- return invalid_response("Message cannot be blank") if message.empty?
17
- return invalid_response('User id is invalid') unless is_digit?(user_id)
20
+ return invalid_response("message cannot be blank") if message.empty?
21
+ return invalid_response('user id is invalid') unless is_digit?(user_id)
18
22
 
19
23
  begin
20
24
  self.clean_hash!(details)
21
25
  self.clean_hash!(hidden_details)
26
+ self.clean_logos!(logos)
22
27
  rescue => e
23
- return invalid_response("Invalid details or hidden details: #{e.message}")
28
+ return invalid_response("Invalid parameters: #{e.message}")
24
29
  end
25
30
 
26
31
  post_request("onetouch/json/users/#{user_id}/approval_requests", {
27
- message: message,
32
+ message: message[0, MAX_STRING_SIZE],
28
33
  details: details,
29
34
  hidden_details: hidden_details,
30
- logos: logos
35
+ logos: logos,
36
+ seconds_to_expire: seconds_to_expire
31
37
  })
32
38
  end
33
39
 
@@ -39,8 +45,27 @@ module Authy
39
45
 
40
46
  private
41
47
  def self.clean_hash!(test_hash)
48
+ return if test_hash.nil? # Allow nil hash
49
+
42
50
  raise "Hash expected. Got: #{test_hash.class}" unless test_hash.is_a? Hash
43
51
  test_hash = test_hash.map { |k, v| [k, v.to_s] }.to_h
44
52
  end
53
+
54
+ def self.clean_logos!(logos)
55
+ return if logos.nil? # Allow nil logos
56
+
57
+ raise "Array expected. Got #{logos.class}" unless logos.is_a? Array
58
+ logos = logos.map do |logo|
59
+ raise "Invalid logo format: #{logo}" unless logo.is_a? Hash
60
+ res = logo.delete(:res) || logo.delete('res')
61
+ url = logo.delete(:url) || logo.delete('url')
62
+
63
+ raise "Logo should include res and url" if res.nil? || url.nil?
64
+
65
+ # We ignore any additional parameter on the logos, and truncate
66
+ # string size to the maximum allowed.
67
+ { res: res[0, MAX_STRING_SIZE], url: url[0, MAS_STRING_SIZE] }
68
+ end
69
+ end
45
70
  end
46
71
  end
@@ -1,22 +1,16 @@
1
1
  module Authy
2
2
  class PhoneIntelligence < Authy::API
3
3
 
4
- # options:
5
- # :via (sms|call)
6
- # :country_code Numeric calling country code of the country.
7
- # :phone_number The persons phone number.
4
+ # @deprecated
8
5
  def self.verification_start(params)
9
- params[:via] = "sms" unless %w(sms, call).include?(params[:via])
10
-
11
- post_request("protected/json/phones/verification/start", params)
6
+ warn "[DEPRECATION] `PhoneIntelligence.verification_start` is deprecated. Please use `PhoneVerification.start` instead."
7
+ Authy::PhoneVerification.start(params)
12
8
  end
13
9
 
14
- # options:
15
- # :country_code Numeric calling country code of the country.
16
- # :phone_number The persons phone number.
17
- # :verification_code The verification code entered by the user.
10
+ # @deprecated
18
11
  def self.verification_check(params)
19
- get_request("protected/json/phones/verification/check", params)
12
+ warn "[DEPRECATION] `PhoneIntelligence.verification_check` is deprecated. Please use `PhoneVerification.check` instead."
13
+ Authy::PhoneVerification.check(params)
20
14
  end
21
15
 
22
16
  # options:
@@ -26,4 +20,4 @@ module Authy
26
20
  get_request("protected/json/phones/info", params)
27
21
  end
28
22
  end
29
- end
23
+ end
@@ -0,0 +1,22 @@
1
+ module Authy
2
+ class PhoneVerification < Authy::API
3
+ # options:
4
+ # :via (sms|call)
5
+ # :country_code Numeric calling country code of the country.
6
+ # :phone_number The persons phone number.
7
+ def self.start(params)
8
+ params[:via] = "sms" unless %w(sms, call).include?(params[:via])
9
+
10
+ post_request("protected/json/phones/verification/start", params)
11
+ end
12
+
13
+ # options:
14
+ # :country_code Numeric calling country code of the country.
15
+ # :phone_number The persons phone number.
16
+ # :verification_code The verification code entered by the user.
17
+ def self.check(params)
18
+ get_request("protected/json/phones/verification/check", params)
19
+ end
20
+
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Authy
2
- VERSION = "2.5.0.pre"
2
+ VERSION = "2.6.0"
3
3
  end
@@ -20,11 +20,39 @@ describe Authy::OneTouch do
20
20
  'Bank account' => '23527922',
21
21
  'Amount' => '10 BTC',
22
22
  },
23
+ hidden_details: {
24
+ 'IP Address' => '192.168.0.3'
25
+ },
26
+ seconds_to_expire: 150
27
+ )
28
+
29
+ expect(response).to be_kind_of(Authy::Response)
30
+ expect(response).to be_ok
31
+ end
32
+
33
+ it 'requires message as mandatory' do
34
+ response = Authy::OneTouch.send_approval_request(
35
+ id: @user.id,
36
+ details: {
37
+ 'Bank account' => '23527922',
38
+ 'Amount' => '10 BTC',
39
+ },
23
40
  hidden_details: {
24
41
  'IP Address' => '192.168.0.3'
25
42
  }
26
43
  )
27
44
 
45
+ expect(response).to be_kind_of(Authy::Response)
46
+ expect(response).to_not be_ok
47
+ expect(response.message).to eq 'message cannot be blank'
48
+ end
49
+
50
+ it 'does not require other fields as mandatory' do
51
+ response = Authy::OneTouch.send_approval_request(
52
+ id: @user.id,
53
+ message: 'Test message'
54
+ )
55
+
28
56
  expect(response).to be_kind_of(Authy::Response)
29
57
  expect(response).to be_ok
30
58
  end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Authy::PhoneVerification" do
4
+ describe "Sending the verification code" do
5
+
6
+ it "should send the code via SMS" do
7
+ response = Authy::PhoneVerification.start(
8
+ :via => "sms",
9
+ :country_code => "1",
10
+ :phone_number => "111-111-1111"
11
+ )
12
+
13
+ response.should be_kind_of(Authy::Response)
14
+ response.should be_ok
15
+ response.message.should == "Text message sent to +1 111-111-1111."
16
+ end
17
+
18
+ # it "should send the code via CALL" do
19
+ # response = Authy::PhoneVerification.start(
20
+ # :via => "call",
21
+ # :country_code => "1",
22
+ # :phone_number => "111-111-1111"
23
+ # )
24
+
25
+ # response.should be_kind_of(Authy::Response)
26
+ # response.success.should be_truthy
27
+ # response.message.should == "Text message sent to +1 111-111-1111."
28
+ # end
29
+ end
30
+
31
+ describe "validate the fields required" do
32
+ it "should return an error. Country code is required" do
33
+ response = Authy::PhoneVerification.start(
34
+ :via => "sms",
35
+ :phone_number => "111-111-1111"
36
+ )
37
+
38
+ response.should_not be_ok
39
+ response.errors['message'] =~ /Country code is mandatory/
40
+ end
41
+
42
+ it "should return an error. Cellphone is invalid" do
43
+ response = Authy::PhoneVerification.start(
44
+ :via => "sms",
45
+ :country_code => "1",
46
+ :phone_number => "123"
47
+ )
48
+
49
+ response.should_not be_ok
50
+ response.errors['message'] =~ /Phone number is invalid/
51
+ end
52
+ end
53
+
54
+ describe "Check the verification code" do
55
+ it "should return success true if code is correct" do
56
+ response = Authy::PhoneVerification.check(
57
+ :country_code => "1",
58
+ :phone_number => "111-111-1111",
59
+ :verification_code => "0000"
60
+ )
61
+
62
+ response.should be_ok
63
+ response.message.should == "Verification code is correct."
64
+ end
65
+
66
+ it "should return an error if code is incorrect" do
67
+ response = Authy::PhoneVerification.check(
68
+ :country_code => "1",
69
+ :phone_number => "111-111-1111",
70
+ :verification_code => "1234"
71
+ )
72
+
73
+ response.should_not be_ok
74
+ response.message.should == "Verification code is incorrect."
75
+ end
76
+ end
77
+ end
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: 2.5.0.pre
4
+ version: 2.6.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: 2015-06-09 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -134,10 +134,10 @@ files:
134
134
  - ".gitignore"
135
135
  - ".rspec"
136
136
  - Gemfile
137
+ - Gemfile.lock
137
138
  - LICENSE.txt
138
139
  - README.md
139
140
  - Rakefile
140
- - VERSION
141
141
  - authy.gemspec
142
142
  - bin/authy-api-console
143
143
  - examples/demo.rb
@@ -148,6 +148,7 @@ files:
148
148
  - lib/authy/models/user.rb
149
149
  - lib/authy/onetouch.rb
150
150
  - lib/authy/phone_intelligence.rb
151
+ - lib/authy/phone_verification.rb
151
152
  - lib/authy/response.rb
152
153
  - lib/authy/url_helpers.rb
153
154
  - lib/authy/version.rb
@@ -155,6 +156,7 @@ files:
155
156
  - spec/authy/config_spec.rb
156
157
  - spec/authy/onetouch_spec.rb
157
158
  - spec/authy/phone_intelligence_spec.rb
159
+ - spec/authy/phone_verification_spec.rb
158
160
  - spec/authy/response_spec.rb
159
161
  - spec/authy/url_helpers_spec.rb
160
162
  - spec/spec_helper.rb
@@ -173,9 +175,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
175
  version: '0'
174
176
  required_rubygems_version: !ruby/object:Gem::Requirement
175
177
  requirements:
176
- - - ">"
178
+ - - ">="
177
179
  - !ruby/object:Gem::Version
178
- version: 1.3.1
180
+ version: '0'
179
181
  requirements: []
180
182
  rubyforge_project: authy
181
183
  rubygems_version: 2.4.6
@@ -187,6 +189,7 @@ test_files:
187
189
  - spec/authy/config_spec.rb
188
190
  - spec/authy/onetouch_spec.rb
189
191
  - spec/authy/phone_intelligence_spec.rb
192
+ - spec/authy/phone_verification_spec.rb
190
193
  - spec/authy/response_spec.rb
191
194
  - spec/authy/url_helpers_spec.rb
192
195
  - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.5.0