nexmo 7.1.2 → 7.2.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: 964a347a61a516b4161b0110412b262ff82614b5c48cddb0d85ee6b9878854ee
4
- data.tar.gz: 50edc921ee4c8a8e4f7172d5c1d8ec3efa195d04d9923efcd98c2f4f6623d145
3
+ metadata.gz: ad124eb0e0e93884dc48ed8257b977c2cc365b19668326751d0fa9c0dd843696
4
+ data.tar.gz: a7e1dae46b7e4c9d86b49fa51f6e74679ec1df56d55961e81e1a8d12b1831f29
5
5
  SHA512:
6
- metadata.gz: 0b35dad79758fb59d4ef8662b6684afd655965ca402832c19b652c7985a4234ad3d815dbbbe190ccfda001901067918e3518fce6d3aa31c9f3ed88e09e8bfacb
7
- data.tar.gz: 91b1f197f77d8cfd7fcabc3d35d69e6b9adbad8d1dd30c0f0e7f8d376bc7dc521dd519ab0184c79ec1d02fb879afaaf0c8c606fc6a13692c03ba8804e31d0f92
6
+ metadata.gz: 4de53e3319290efe704e16603a09aa79af15cc47aaf75f539e1e442b040d6e86f7427e6a412702c0557cd1d43c1ee8b31b38e71646ac615766277ed63caa590c
7
+ data.tar.gz: 57c846af9f53f5537a6aeda3d588e36c6ef41c273f18640fe2214e37428ecd8d5ba7cfe91b619fc5035c43b0847a9507d97b9b036aa3fc1d6bb6b67bf975601f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nexmo Client Library for Ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![Build Status](https://api.travis-ci.org/Nexmo/nexmo-ruby.svg?branch=master)](https://travis-ci.org/Nexmo/nexmo-ruby) [![Coverage Status](https://coveralls.io/repos/github/Nexmo/nexmo-ruby/badge.svg?branch=coveralls)](https://coveralls.io/github/Nexmo/nexmo-ruby?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![Coverage Status](https://github.com/nexmo/nexmo-ruby/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Nexmo/nexmo-ruby/badge.svg?branch=coveralls)](https://coveralls.io/github/Nexmo/nexmo-ruby?branch=master)
4
4
 
5
5
  <img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />
6
6
 
@@ -112,18 +112,19 @@ the token option. For example:
112
112
  ```ruby
113
113
  claims = {
114
114
  application_id: application_id,
115
+ private_key: 'path/to/private.key',
115
116
  nbf: 1483315200,
116
- exp: 1514764800,
117
- iat: 1483228800
117
+ ttl: 800
118
118
  }
119
119
 
120
- private_key = File.read('path/to/private.key')
121
-
122
- token = Nexmo::JWT.generate(claims, private_key)
120
+ token = Nexmo::JWT.generate(claims)
123
121
 
124
122
  client = Nexmo::Client.new(token: token)
125
123
  ````
126
124
 
125
+ Documentation for the Nexmo Ruby JWT generator gem can be found at
126
+ [https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby](https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby).
127
+ The documentation outlines all the possible parameters you can use to customize and build a token with.
127
128
 
128
129
  ## Webhook signatures
129
130
 
@@ -1,13 +1,11 @@
1
- # typed: strict
1
+ # typed: false
2
2
  # frozen_string_literal: true
3
3
  require 'securerandom'
4
4
  require 'openssl'
5
- require 'jwt'
5
+ require 'nexmo-jwt'
6
6
 
7
7
  module Nexmo
8
- module JWT
9
- extend T::Sig
10
-
8
+ class JWT
11
9
  # Generate an encoded JSON Web Token.
12
10
  #
13
11
  # By default the Nexmo Ruby SDK generates a short lived JWT per request.
@@ -16,12 +14,14 @@ module Nexmo
16
14
  # directly call {Nexmo::JWT.generate} to generate a token, and set the token
17
15
  # attribute on the client object.
18
16
  #
17
+ # Documentation for the Nexmo Ruby JWT generator gem can be found at
18
+ # https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby
19
+ #
19
20
  # @example
20
21
  # claims = {
21
22
  # application_id: application_id,
22
- # nbf: 1483315200,
23
- # exp: 1514764800,
24
- # iat: 1483228800
23
+ # ttl: 800,
24
+ # subject: 'My_Subject'
25
25
  # }
26
26
  #
27
27
  # private_key = File.read('path/to/private.key')
@@ -33,15 +33,11 @@ module Nexmo
33
33
  #
34
34
  # @return [String]
35
35
  #
36
- sig { params(payload: T::Hash[T.any(Symbol, String), T.any(String, Integer)], private_key: T.any(OpenSSL::PKey::RSA, String)).returns(String) }
37
- def self.generate(payload, private_key)
38
- payload[:iat] = iat = Time.now.to_i unless payload.key?(:iat) || payload.key?('iat')
39
- payload[:exp] = T.must(iat) + 60 unless payload.key?(:exp) || payload.key?('exp')
40
- payload[:jti] = SecureRandom.uuid unless payload.key?(:jti) || payload.key?('jti')
41
-
42
- private_key = OpenSSL::PKey::RSA.new(private_key) unless private_key.respond_to?(:sign)
36
+ def self.generate(payload, private_key = nil)
37
+ raise "Expecting 'private_key' in either the payload or as a separate parameter" if !payload[:private_key] && !private_key
43
38
 
44
- ::JWT.encode(payload, private_key, 'RS256')
39
+ payload[:private_key] = private_key if private_key && !payload[:private_key]
40
+ @token = Nexmo::JWTBuilder.new(payload).jwt.generate
45
41
  end
46
42
  end
47
43
  end
@@ -10,9 +10,25 @@ module Nexmo
10
10
  hash.transform_keys { |k| k.to_s.tr('_', '-') }
11
11
  end
12
12
 
13
- sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T::Hash[String, T.untyped]) }
13
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T::Hash[T.untyped, T.untyped]) }
14
14
  def camelcase(hash)
15
- hash.transform_keys { |k| k.to_s.gsub(/_(\w)/) { $1.upcase } }
15
+ exceptions = [
16
+ 'dr_call_back_url',
17
+ 'mo_http_url',
18
+ 'mo_smpp_sys_type',
19
+ 'mo_call_back_url',
20
+ 'voice_callback_type',
21
+ 'voice_callback_value',
22
+ 'voice_status_callback',
23
+ 'messages_callback_value',
24
+ 'messages_callback_type'
25
+ ]
26
+ hash.transform_keys do |k|
27
+ if exceptions.include?(k.to_s)
28
+ next k.to_s.gsub(/_(\w)/) { $1.upcase.to_s }
29
+ end
30
+ k
31
+ end
16
32
  end
17
33
 
18
34
  ATTRIBUTE_KEYS = T.let(Hash.new { |h, k| h[k] = k.split(PATTERN).join('_').downcase.to_sym }, T::Hash[T.untyped, T.untyped])
@@ -1,8 +1,10 @@
1
- # typed: true
1
+ # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Nexmo
5
5
  class Redact < Namespace
6
+ extend T::Sig
7
+
6
8
  self.authentication = Basic
7
9
 
8
10
  self.request_body = JSON
@@ -27,6 +29,7 @@ module Nexmo
27
29
  #
28
30
  # @see https://developer.nexmo.com/api/redact#redact-message
29
31
  #
32
+ sig { params(params: T::Hash[Symbol, T.untyped]).returns(Nexmo::Response) }
30
33
  def transaction(params)
31
34
  request('/v1/redact/transaction', params: params, type: Post)
32
35
  end
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Nexmo
4
- VERSION = '7.1.2'
4
+ VERSION = '7.2.0'
5
5
  end
@@ -12,9 +12,10 @@ Gem::Specification.new do |s|
12
12
  s.summary = 'This is the Ruby client library for Nexmo\'s API. To use it you\'ll need a Nexmo account. Sign up for free at https://www.nexmo.com'
13
13
  s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md nexmo.gemspec)
14
14
  s.required_ruby_version = '>= 2.5.0'
15
- s.add_dependency('jwt', '~> 2')
15
+ s.add_dependency('nexmo-jwt', '~> 0.1.1')
16
16
  s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
17
17
  s.add_dependency('sorbet-runtime', '~> 0.5')
18
+ s.add_development_dependency('timecop', '~> 0.9')
18
19
  s.require_path = 'lib'
19
20
  s.metadata = {
20
21
  'homepage' => 'https://github.com/Nexmo/nexmo-ruby',
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.2
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexmo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jwt
14
+ name: nexmo-jwt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: 0.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2'
26
+ version: 0.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.5'
61
+ - !ruby/object:Gem::Dependency
62
+ name: timecop
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.9'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.9'
61
75
  description: Nexmo Client Library for Ruby
62
76
  email:
63
77
  - devrel@nexmo.com