Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update jwt to 2.1.0
Fixes #435

I've also removed the references to `rails 5.2.0.beta2`, since a final
version has been out for a while.

On `lib/rpush/daemon/apnsp8/token.rb` I just did some styling
adjustments suggested by Rubocop (haven't really changed anything, but
was consulting the class to confirm if anything had to be changed).
  • Loading branch information
jsantos committed Jul 11, 2018
1 parent e52d3bc commit 6242960
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Appraisals
Expand Up @@ -38,10 +38,10 @@ appraise "rails-5.1" do
end

appraise "rails-5.2" do
gem "activesupport", ">= 5.2.0.beta2"
gem "activesupport", ">= 5.2.0"

group :development do
gem "rails", ">= 5.2.0.beta2"
gem "rails", ">= 5.2.0"
end
end

Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
rpush (3.2.0)
rpush (3.2.2)
activesupport
ansi
jwt (~> 1.5.6)
jwt (~> 2.1.0)
multi_json (~> 1.0)
net-http-persistent
net-http2 (~> 0.14)
Expand Down Expand Up @@ -58,7 +58,7 @@ GEM
i18n (1.0.0)
concurrent-ruby (~> 1.0)
json (2.1.0)
jwt (1.5.6)
jwt (2.1.0)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -77,9 +77,9 @@ GEM
mysql2 (0.5.1)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
net-http2 (0.17.0)
net-http2 (0.18.0)
http-2 (= 0.9.0)
nokogiri (1.8.2)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
parser (2.5.1.0)
Expand Down
18 changes: 14 additions & 4 deletions lib/rpush/daemon/apnsp8/token.rb
Expand Up @@ -3,7 +3,6 @@ module Daemon
module Apnsp8
TOKEN_TTL = 30 * 60
class Token

def initialize(app)
@app = app
end
Expand All @@ -15,13 +14,24 @@ def token
new_token
end
end

private

def new_token
@cached_token_at = Time.now
ec_key = OpenSSL::PKey::EC.new(@app.apn_key)
@cached_token = JWT.encode({iss: @app.team_id, iat: Time.now.to_i}, ec_key, 'ES256', {alg: 'ES256', kid: @app.apn_key_id})
@cached_token = JWT.encode(
{
iss: @app.team_id,
iat: Time.now.to_i
},
ec_key,
'ES256',
{
alg: 'ES256',
kid: @app.apn_key_id
}
)
end

def expired_token?
Expand All @@ -30,4 +40,4 @@ def expired_token?
end
end
end
end
end
2 changes: 1 addition & 1 deletion rpush.gemspec
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'multi_json', '~> 1.0'
s.add_runtime_dependency 'net-http-persistent'
s.add_runtime_dependency 'net-http2', '~> 0.14'
s.add_runtime_dependency 'jwt', '~> 1.5.6'
s.add_runtime_dependency 'jwt', '~> 2.1.0'
s.add_runtime_dependency 'activesupport'
s.add_runtime_dependency 'thor', ['>= 0.18.1', '< 2.0']
s.add_runtime_dependency 'railties'
Expand Down

0 comments on commit 6242960

Please sign in to comment.