twilio-ruby 4.8.3.edge → 4.9.0.edge

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: 43ba74041c6b5df506291f3cd3be97841c4dba52
4
- data.tar.gz: 58945caad468f6be4eac62741b7790cb64d60510
3
+ metadata.gz: 3df7f4447f76cf5658ab7eecf38d45adffd783e6
4
+ data.tar.gz: 1d9ed7dc9443d66e611b169d3a02bde26c6d0108
5
5
  SHA512:
6
- metadata.gz: 3a29ca5d1c2b2b2f2686d6cf0a1e596ccdf82d5e3eeba52784d14425f26338601ed55e3ae1a64e29f7c015347eee890d6b65e75aff26e58093e3b0fd9291e490
7
- data.tar.gz: b4ab6292b6018c2f182338ec6c2a3cb709f53b7853d435b1736017c1320e579deaae12d432fdb45ab8e686aa4735b163ee1fe9102bd1ff08b871e09f799dded0
6
+ metadata.gz: 327717db3f366626c47f3df545cb3263ee387325acff399d881e3e7956948e04638246c2f31a65173040f4bab3adb9e8eda3371643262a3373180fcabc8f2217
7
+ data.tar.gz: 50c4747eb0c2a2d6008e14ac8552577a256405c854ec5b0b5315a285b506f6c95f2615f86f88f93ab440721ab25fbaff94af2cd3adf55823826b9a9d6b46f3de
data/CHANGES.md CHANGED
@@ -1,6 +1,13 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 4.9.0.edge
5
+ -------------
6
+
7
+ Release December 8, 2015
8
+
9
+ - Make nbf optional
10
+
4
11
  Version 4.4.0
5
12
  -------------
6
13
 
@@ -1,12 +1,20 @@
1
1
  module Twilio
2
2
  module Util
3
3
  class AccessToken
4
- def initialize(account_sid, signing_key_id, secret, ttl=3600, identity=nil)
4
+ attr_accessor :account_sid,
5
+ :signing_key_id,
6
+ :secret,
7
+ :ttl,
8
+ :identity,
9
+ :nbf
10
+
11
+ def initialize(account_sid, signing_key_id, secret, ttl=3600, identity=nil, nbf=nil)
5
12
  @account_sid = account_sid
6
13
  @signing_key_sid = signing_key_id
7
14
  @secret = secret
8
15
  @ttl = ttl
9
16
  @identity = identity
17
+ @nbf = nbf
10
18
  @grants = []
11
19
  end
12
20
 
@@ -32,10 +40,11 @@ module Twilio
32
40
  'jti' => "#{@signing_key_sid}-#{now}",
33
41
  'iss' => @signing_key_sid,
34
42
  'sub' => @account_sid,
35
- 'nbf' => now,
36
43
  'exp' => now + @ttl,
37
44
  'grants' => grants
38
45
  }
46
+ payload['nbf'] = @nbf unless @nbf.nil?
47
+
39
48
  JWT.encode payload, @secret, algorithm, headers
40
49
  end
41
50
 
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '4.8.3.edge'
2
+ VERSION = '4.9.0.edge'
3
3
  end
@@ -10,15 +10,37 @@ describe Twilio::Util::AccessToken do
10
10
 
11
11
  expect(payload['iss']).to eq('SK123')
12
12
  expect(payload['sub']).to eq('AC123')
13
- expect(payload['nbf']).not_to be_nil
14
13
  expect(payload['exp']).not_to be_nil
15
- expect(payload['nbf'] + 3600).to eq(payload['exp'])
14
+ expect(payload['exp']).to be >= Time.now.to_i
16
15
  expect(payload['jti']).not_to be_nil
17
- expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
16
+ expect(payload['jti']).to start_with payload['iss']
18
17
  expect(payload['grants']).not_to be_nil
19
18
  expect(payload['grants'].count).to eq(0)
20
19
  end
21
20
 
21
+ it 'should generate a nbf' do
22
+ now = Time.now.to_i
23
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
24
+ scat.identity = 'abc'
25
+ scat.nbf = now
26
+
27
+ token = scat.to_s
28
+ expect(token).not_to be_nil
29
+ payload, header = JWT.decode token, 'secret'
30
+
31
+ expect(payload['iss']).to eq('SK123')
32
+ expect(payload['sub']).to eq('AC123')
33
+ expect(payload['nbf']).not_to be_nil
34
+ expect(payload['nbf']).to eq(now)
35
+ expect(payload['exp']).not_to be_nil
36
+ expect(payload['exp']).to be >= Time.now.to_i
37
+ expect(payload['jti']).not_to be_nil
38
+ expect(payload['jti']).to start_with payload['iss']
39
+ expect(payload['grants']).not_to be_nil
40
+ expect(payload['grants'].count).to eq(1)
41
+ expect(payload['grants']['identity']).to eq('abc')
42
+ end
43
+
22
44
  it 'should be able to add conversation grant' do
23
45
  scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
24
46
  scat.add_grant(Twilio::Util::AccessToken::ConversationsGrant.new)
@@ -29,11 +51,10 @@ describe Twilio::Util::AccessToken do
29
51
 
30
52
  expect(payload['iss']).to eq('SK123')
31
53
  expect(payload['sub']).to eq('AC123')
32
- expect(payload['nbf']).not_to be_nil
33
54
  expect(payload['exp']).not_to be_nil
34
- expect(payload['nbf'] + 3600).to eq(payload['exp'])
55
+ expect(payload['exp']).to be >= Time.now.to_i
35
56
  expect(payload['jti']).not_to be_nil
36
- expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
57
+ expect(payload['jti']).to start_with payload['iss']
37
58
  expect(payload['grants']).not_to be_nil
38
59
  expect(payload['grants'].count).to eq(1)
39
60
  expect(payload['grants']['rtc']).not_to be_nil
@@ -49,11 +70,10 @@ describe Twilio::Util::AccessToken do
49
70
 
50
71
  expect(payload['iss']).to eq('SK123')
51
72
  expect(payload['sub']).to eq('AC123')
52
- expect(payload['nbf']).not_to be_nil
53
73
  expect(payload['exp']).not_to be_nil
54
- expect(payload['nbf'] + 3600).to eq(payload['exp'])
74
+ expect(payload['exp']).to be >= Time.now.to_i
55
75
  expect(payload['jti']).not_to be_nil
56
- expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
76
+ expect(payload['jti']).to start_with payload['iss']
57
77
  expect(payload['grants']).not_to be_nil
58
78
  expect(payload['grants'].count).to eq(1)
59
79
  expect(payload['grants']['ip_messaging']).not_to be_nil
@@ -70,11 +90,10 @@ describe Twilio::Util::AccessToken do
70
90
 
71
91
  expect(payload['iss']).to eq('SK123')
72
92
  expect(payload['sub']).to eq('AC123')
73
- expect(payload['nbf']).not_to be_nil
74
93
  expect(payload['exp']).not_to be_nil
75
- expect(payload['nbf'] + 3600).to eq(payload['exp'])
94
+ expect(payload['exp']).to be >= Time.now.to_i
76
95
  expect(payload['jti']).not_to be_nil
77
- expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
96
+ expect(payload['jti']).to start_with payload['iss']
78
97
  expect(payload['grants']).not_to be_nil
79
98
  expect(payload['grants'].count).to eq(2)
80
99
  expect(payload['grants']['rtc']).not_to be_nil
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.3.edge
4
+ version: 4.9.0.edge
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.3.0
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
26
  version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.1.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jwt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  description: A simple library for communicating with the Twilio REST API, building
@@ -76,8 +76,8 @@ extra_rdoc_files:
76
76
  - README.md
77
77
  - LICENSE.md
78
78
  files:
79
- - .gitignore
80
- - .travis.yml
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
81
  - AUTHORS.md
82
82
  - CHANGES.md
83
83
  - Gemfile
@@ -291,27 +291,27 @@ licenses:
291
291
  metadata: {}
292
292
  post_install_message:
293
293
  rdoc_options:
294
- - --line-numbers
295
- - --inline-source
296
- - --title
294
+ - "--line-numbers"
295
+ - "--inline-source"
296
+ - "--title"
297
297
  - twilio-ruby
298
- - --main
298
+ - "--main"
299
299
  - README.md
300
300
  require_paths:
301
301
  - lib
302
302
  required_ruby_version: !ruby/object:Gem::Requirement
303
303
  requirements:
304
- - - '>='
304
+ - - ">="
305
305
  - !ruby/object:Gem::Version
306
306
  version: 1.9.3
307
307
  required_rubygems_version: !ruby/object:Gem::Requirement
308
308
  requirements:
309
- - - '>'
309
+ - - ">"
310
310
  - !ruby/object:Gem::Version
311
311
  version: 1.3.1
312
312
  requirements: []
313
313
  rubyforge_project:
314
- rubygems_version: 2.0.14
314
+ rubygems_version: 2.4.8
315
315
  signing_key:
316
316
  specification_version: 4
317
317
  summary: A simple library for communicating with the Twilio REST API, building TwiML,