vonage-jwt 0.1.3 → 0.2.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: 4e64f9df01478c092cf5f950c5fb61d56227a558cba788a693cffad050ed5a66
4
- data.tar.gz: f72bd42ca910f5f6df52781eeb3d8d1ca658c261833bbe5ab68b3ef8f2571014
3
+ metadata.gz: 9d851f2a2dde78ab6552912fe891a5e97e847ebb2cfef9b65da52dd8d55a0ba5
4
+ data.tar.gz: e5f7e809b64741b1dfa3d4fa97a23aa6d73499648b31ae85cc1263a462fd29a2
5
5
  SHA512:
6
- metadata.gz: e0fb624c08c1c06db4def2a97b50a10add0392f89f6279de7c5b70c987881f510720202b6b84a3d9365a61b32f43fb3783ed30aa95a31a5adc7d1bf08dcf5444
7
- data.tar.gz: faa02b4e295b2a850191a956dbbe526c7feb498e3a51cd4ada6d9d66823036846e418092b06bf020e8cb7474bfa1f886a4fa47b30e2e746276ce49f62a9b6c43
6
+ metadata.gz: 74374a375bbf6c8aed98406fa6db1d053cc1f0388135b3ec2982318719839542d42c03935f0063728d7ce99b1130d53f9781d7ebe67561ec4fd75d2330b4302c
7
+ data.tar.gz: 1898208b67a593335db77d085aff7c9cd187ccf2ab1026e5f6cf9c7aad3e3074fa9d9ddb2a34cf73b2fecdaf81f6bfac396bb78cc4527ee71a555f34cd9bcbd2
data/README.md CHANGED
@@ -27,9 +27,11 @@ Alternatively you can clone the repository:
27
27
 
28
28
  ## Usage
29
29
 
30
+ ### Generating a JWT
31
+
30
32
  By default the Vonage JWT generator creates a short lived JWT (15 minutes) per request.
31
33
  To generate a long lived JWT for multiple requests, specify a longer value in the `exp`
32
- parameter during initialization.
34
+ parameter during initialization.
33
35
 
34
36
  Example with no custom configuration:
35
37
 
@@ -51,10 +53,10 @@ Example providing custom configuration options:
51
53
  "/messages": {
52
54
  "methods": ["POST", "GET"],
53
55
  "filters": {
54
- "from": "447977271009"
55
- }
56
- }
57
- }
56
+ "from": "447977271009"
57
+ }
58
+ }
59
+ }
58
60
  }
59
61
  },
60
62
  subject: 'My_Custom_Subject'
@@ -62,6 +64,28 @@ Example providing custom configuration options:
62
64
  @token = @builder.jwt.generate
63
65
  ```
64
66
 
67
+ ### Decoding a JWT
68
+
69
+ You can decode a JWT like so:
70
+
71
+ ```ruby
72
+ Vonage::JWT.decode(token, nil, false)
73
+ ```
74
+
75
+ where `token` is the JWT that you want to decode. The `Vonage::JWT::decode` method is essentially just a wrapper around the `ruby-jwt` library method of the same name, and usage is identical to what is [documented for that library](https://github.com/jwt/ruby-jwt#algorithms-and-usage).
76
+
77
+ ### Verifying a Signature
78
+
79
+ For JWTs that are signed, you can verify a JWT signature like so:
80
+
81
+ ```ruby
82
+ Vonage::JWT.verify_signature(token, signature_secret, algorithm)
83
+ ```
84
+
85
+ where `token` is the signed JWT, `signature_secret` is the secret or key required by whichever algorithm was used to sign the JWT, and `algorithm` is a string indicating the algorithm that was used to sign the JWT (e.g. `'HS256'`, `'RS256'`, etc)
86
+
87
+ The method will return `true` if the signature is verified and `false` if it is not.
88
+
65
89
  ## Documentation
66
90
 
67
91
  Vonage Ruby JWT documentation: https://www.rubydoc.info/github/Vonage/vonage-jwt
@@ -29,5 +29,18 @@ module Vonage
29
29
  hash.merge!(generator.additional_claims) if !generator.additional_claims.empty?
30
30
  hash
31
31
  end
32
+
33
+ def self.decode(token, secret = nil, verify = true, opts = {}, &block)
34
+ ::JWT.decode(token, secret, verify, opts, &block)
35
+ end
36
+
37
+ def self.verify_signature(token, signature_secret, algorithm)
38
+ begin
39
+ decode(token, signature_secret, true, {algorithm: algorithm})
40
+ return true
41
+ rescue ::JWT::VerificationError
42
+ return false
43
+ end
44
+ end
32
45
  end
33
46
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vonage
4
4
  class JWT
5
- VERSION = '0.1.3'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
data/vonage-jwt.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.summary = 'This is the Ruby client library to generate Vonage JSON Web Tokens (JWTs).'
15
15
  s.files = Dir.glob('lib/**/*.rb') + %w[LICENSE.txt README.md vonage-jwt.gemspec]
16
16
  s.required_ruby_version = '>= 2.5.0'
17
- s.add_dependency('jwt', '~> 2')
17
+ s.add_dependency('jwt', '>= 2.0', '< 4.0')
18
18
  s.require_path = 'lib'
19
19
  s.metadata = {
20
20
  'homepage' => 'https://github.com/Vonage/vonage-jwt-ruby',
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2025-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: '2.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '2'
32
+ version: '4.0'
27
33
  description: Vonage JWT Generator for Ruby
28
34
  email:
29
35
  - devrel@vonage.com
@@ -47,7 +53,7 @@ metadata:
47
53
  bug_tracker_uri: https://github.com/Vonage/vonage-jwt-ruby/issues
48
54
  changelog_uri: https://github.com/Vonage/vonage-jwt-ruby/blob/main/CHANGES.md
49
55
  documentation_uri: https://rubydoc.info/github/Vonage/vonage-jwt-ruby
50
- post_install_message:
56
+ post_install_message:
51
57
  rdoc_options: []
52
58
  require_paths:
53
59
  - lib
@@ -62,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
68
  - !ruby/object:Gem::Version
63
69
  version: '0'
64
70
  requirements: []
65
- rubygems_version: 3.2.3
66
- signing_key:
71
+ rubygems_version: 3.5.3
72
+ signing_key:
67
73
  specification_version: 4
68
74
  summary: This is the Ruby client library to generate Vonage JSON Web Tokens (JWTs).
69
75
  test_files: []