nexmo-jwt 0.1.0 → 0.1.1

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: 8810bf15b38858eab28165f9fe3e206cac5f3ed14bbe775b8f1086c440cd48aa
4
- data.tar.gz: a2edfdeba6628732c4e4c9fbdc8ececdb4b0b0029e5c2dfcd9a577ab8bc64922
3
+ metadata.gz: c834d7bc1f7ab9d28961cd0527c7201cbf3cf798fd53ed8cf128a9786ea8cdde
4
+ data.tar.gz: cbf42defdddb80441ef33b3649c4822a9c2f89d2e2fdf34063a8d8978586e9b5
5
5
  SHA512:
6
- metadata.gz: 0cd2beaf48a5a9ea952e67decb88381f096133be034570004151220bf7a642f2cb69618cbb7aa4e8315868b381c06baf17f1ab3e216c5a2cd907175b3f362a0d
7
- data.tar.gz: 348c52c22c21ea98c379128e1062b6ce55a3c6c3b031cf9a34afd88147ba7d14ce4e5da86362faea083629f0c05ebea64602f243ea077fcf05c1d525818acdfb
6
+ metadata.gz: 31fdcd5160ba78ad55eb8db15cf5d42defca71b57db8e5d69738638bce6539f4dad122a5371e5372da385f548da6e5eda290c82a51406d187bbdb5c476f0495c
7
+ data.tar.gz: d131d09509e39d43b40fa897b2327e2d9c52dd800277372f06c20653a88c86394be7ee51f280efb1447adf2b2d2d0b72a4fa0acab2c91b5ed3a40af68880ef81
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nexmo JWT Generator for Ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/nexmo-jwt.svg)](https://badge.fury.io/rb/nexmo-jwt) [![Build Status](https://api.travis-ci.org/Nexmo/nexmo-jwt-ruby.svg?branch=master)](https://travis-ci.org/Nexmo/nexmo-jwt-ruby) [![Coverage Status](https://coveralls.io/repos/github/Nexmo/nexmo-jwt-ruby/badge.svg?branch=coveralls)](https://coveralls.io/github/Nexmo/nexmo-jwt-ruby?branch=master)[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
3
+ [![Gem Version](https://badge.fury.io/rb/nexmo-jwt.svg)](https://badge.fury.io/rb/nexmo-jwt)![Coverage Status](https://github.com/nexmo/nexmo-jwt-ruby/workflows/CI/badge.svg)[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
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
 
@@ -77,4 +77,4 @@ Nexmo API reference: https://developer.nexmo.com/api
77
77
  This library is released under the [MIT License][license]
78
78
 
79
79
  [signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library
80
- [license]: LICENSE.txt
80
+ [license]: LICENSE.txt
@@ -18,7 +18,7 @@ module Nexmo
18
18
  hash = {
19
19
  iat: iat,
20
20
  jti: generator.jti,
21
- exp: generator.exp + generator.ttl,
21
+ exp: generator.exp || iat + generator.ttl,
22
22
  sub: generator.subject,
23
23
  application_id: generator.application_id,
24
24
  typ: typ
@@ -42,12 +42,14 @@ module Nexmo
42
42
  attr_accessor :application_id, :private_key, :jti, :nbf, :ttl, :exp, :alg, :paths, :subject, :jwt
43
43
 
44
44
  def initialize(params = {})
45
+ Nexmo::JWTBuilder.validate_parameters_not_conflicting(params)
46
+
45
47
  @application_id = set_application_id(params.fetch(:application_id))
46
48
  @private_key = set_private_key(params.fetch(:private_key))
47
49
  @jti = params.fetch(:jti, SecureRandom.uuid)
48
50
  @nbf = params.fetch(:nbf, nil)
49
51
  @ttl = params.fetch(:ttl, 900)
50
- @exp = params.fetch(:exp, 0)
52
+ @exp = params.fetch(:exp, nil)
51
53
  @alg = params.fetch(:alg, 'RS256')
52
54
  @paths = params.fetch(:paths, nil)
53
55
  @subject = params.fetch(:subject, 'Subject')
@@ -56,6 +58,12 @@ module Nexmo
56
58
  after_initialize!(self)
57
59
  end
58
60
 
61
+ def self.validate_parameters_not_conflicting(params)
62
+ if params[:ttl] && params[:exp]
63
+ raise ArgumentError, "Expected either 'ttl' or 'exp' parameter, preference is to set 'ttl' parameter"
64
+ end
65
+ end
66
+
59
67
  def after_initialize!(builder)
60
68
  validate_not_before(builder.nbf) if builder.nbf
61
69
  validate_time_to_live(builder.ttl)
@@ -1,5 +1,5 @@
1
1
  module Nexmo
2
2
  class JWT
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  'source_code_uri' => 'https://github.com/Nexmo/nexmo-jwt-ruby',
20
20
  'bug_tracker_uri' => 'https://github.com/Nexmo/nexmo-jwt-ruby/issues',
21
21
  'changelog_uri' => 'https://github.com/Nexmo/nexmo-jwt-ruby/blob/master/CHANGES.md',
22
- 'documentation_uri' => 'https://www.rubydoc.info/github/nexmo/nexmo-jwt'
22
+ 'documentation_uri' => 'https://rubydoc.info/github/Nexmo/nexmo-jwt-ruby'
23
23
  }
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexmo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-16 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -46,7 +46,7 @@ metadata:
46
46
  source_code_uri: https://github.com/Nexmo/nexmo-jwt-ruby
47
47
  bug_tracker_uri: https://github.com/Nexmo/nexmo-jwt-ruby/issues
48
48
  changelog_uri: https://github.com/Nexmo/nexmo-jwt-ruby/blob/master/CHANGES.md
49
- documentation_uri: https://www.rubydoc.info/github/nexmo/nexmo-jwt
49
+ documentation_uri: https://rubydoc.info/github/Nexmo/nexmo-jwt-ruby
50
50
  post_install_message:
51
51
  rdoc_options: []
52
52
  require_paths: