vonage 7.32.0 → 7.33.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 +4 -4
- data/lib/vonage/account.rb +2 -0
- data/lib/vonage/basic_and_signature.rb +22 -0
- data/lib/vonage/config.rb +3 -0
- data/lib/vonage/conversions.rb +2 -0
- data/lib/vonage/signature.rb +24 -1
- data/lib/vonage/sms.rb +2 -0
- data/lib/vonage/verify.rb +2 -0
- data/lib/vonage/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5b786bdfd6a5142be34fe1400d4e1914b6d6d9ef4b7e15d10a56e88f9bb5250
|
|
4
|
+
data.tar.gz: 5768855f0b0d03e66222694234f257600fa65a4eaf07dc4c0b9ce36471b87807
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3596b7759e7dc20c08ea1a127d97519aff481011134db294ac81b01452700757055813b2905d32144ae1977d8daa1d7d391ef1378763360ca3443b117caf7e05
|
|
7
|
+
data.tar.gz: e4a089e502ded233cbfbc0c07a60ae5dffceae4e5c550556f377202b7a4cef3b1e42806c3901b81c1c9763a7dd884ae82e9e80e0ecb016e56d0e9bbaeadf7e3d
|
data/lib/vonage/account.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
module Vonage
|
|
4
|
+
class BasicAndSignature < AbstractAuthentication
|
|
5
|
+
def update(object, data)
|
|
6
|
+
if @config.authentication_preference == :signature
|
|
7
|
+
return unless object.is_a?(Hash)
|
|
8
|
+
|
|
9
|
+
object['api_key'] = T.must(@config).api_key
|
|
10
|
+
object['timestamp'] =Time.now.to_i.to_s
|
|
11
|
+
signature = Signature.new(@config).generate(object)
|
|
12
|
+
object[:sig] = signature
|
|
13
|
+
else
|
|
14
|
+
return unless object.is_a?(Net::HTTPRequest)
|
|
15
|
+
|
|
16
|
+
object.basic_auth(@config.api_key, @config.api_secret)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private_constant :Basic
|
|
22
|
+
end
|
data/lib/vonage/config.rb
CHANGED
|
@@ -109,6 +109,9 @@ module Vonage
|
|
|
109
109
|
sig { returns(T.nilable(String)) }
|
|
110
110
|
attr_accessor :app_version
|
|
111
111
|
|
|
112
|
+
sig { returns(T.nilable(Symbol)) }
|
|
113
|
+
attr_accessor :authentication_preference
|
|
114
|
+
|
|
112
115
|
# Returns the value of attribute http.
|
|
113
116
|
#
|
|
114
117
|
# @return [Vonage::HTTP::Options]
|
data/lib/vonage/conversions.rb
CHANGED
|
@@ -6,6 +6,8 @@ module Vonage
|
|
|
6
6
|
extend T::Sig
|
|
7
7
|
include Keys
|
|
8
8
|
|
|
9
|
+
self.authentication = BasicAndSignature
|
|
10
|
+
|
|
9
11
|
sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
|
|
10
12
|
def track_sms(params)
|
|
11
13
|
request('/conversions/sms', params: hyphenate(params), type: Post)
|
data/lib/vonage/signature.rb
CHANGED
|
@@ -10,6 +10,29 @@ module Vonage
|
|
|
10
10
|
@config = config
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
# Generate a request signature.
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# client = Vonage::Client.new
|
|
17
|
+
# client.config.signature_secret = 'secret'
|
|
18
|
+
# client.config.signature_method = 'sha512'
|
|
19
|
+
# params = {
|
|
20
|
+
# 'api_key' => 'abc123',
|
|
21
|
+
# 'to' => '447900000000',
|
|
22
|
+
# 'from' => '447900000001',
|
|
23
|
+
# 'text' => 'Hello World',
|
|
24
|
+
# 'timestamp' => '1385047698'
|
|
25
|
+
# }
|
|
26
|
+
#
|
|
27
|
+
# sig = client.signature.generate(params)
|
|
28
|
+
#
|
|
29
|
+
# @param [Hash] params
|
|
30
|
+
#
|
|
31
|
+
# @see https://developer.nexmo.com/concepts/guides/signing-messages
|
|
32
|
+
def generate(params, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
|
|
33
|
+
digest(params, signature_secret, signature_method)
|
|
34
|
+
end
|
|
35
|
+
|
|
13
36
|
# Check webhook request signature.
|
|
14
37
|
#
|
|
15
38
|
# @example
|
|
@@ -38,7 +61,7 @@ module Vonage
|
|
|
38
61
|
private
|
|
39
62
|
|
|
40
63
|
def digest(params, signature_secret, signature_method)
|
|
41
|
-
digest_string = params.sort.map { |k, v| "&#{k}=#{v.tr('&=', '_')}" }.join
|
|
64
|
+
digest_string = params.sort.map { |k, v| "&#{k}=#{v.to_s.tr('&=', '_')}" }.join
|
|
42
65
|
|
|
43
66
|
case signature_method
|
|
44
67
|
when 'md5', 'sha1', 'sha256', 'sha512'
|
data/lib/vonage/sms.rb
CHANGED
data/lib/vonage/verify.rb
CHANGED
data/lib/vonage/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vonage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.33.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vonage
|
|
@@ -137,6 +137,7 @@ files:
|
|
|
137
137
|
- lib/vonage/applications/list_response.rb
|
|
138
138
|
- lib/vonage/authentication_error.rb
|
|
139
139
|
- lib/vonage/basic.rb
|
|
140
|
+
- lib/vonage/basic_and_signature.rb
|
|
140
141
|
- lib/vonage/bearer_token.rb
|
|
141
142
|
- lib/vonage/client.rb
|
|
142
143
|
- lib/vonage/client_error.rb
|