web-push 3.0.1 → 3.0.2

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: a688b354339ddf4f82d8febb54a2042bb432357dffd77a571c3c9212c107aa2f
4
- data.tar.gz: 01060b2687a57217cafb2cf96b3925c6e2e39102daf6f796277d06d767ae6a0e
3
+ metadata.gz: 6a90ad96aa12a10002ba31de9ac2b082abcce714bcb3e7b54e97d702cfd12af0
4
+ data.tar.gz: c04841ffa17ba33182087413b2b6a266ca08f0370510392df635dc040be6f34c
5
5
  SHA512:
6
- metadata.gz: 2386c18e4fef78c027b2a5dee6a1778dc82d43cf26dcf0468e83feb8ff972eca1b743c87d68612fffee8ea9feb05329bc4a06127599643de72d922b465aca776
7
- data.tar.gz: b023139054b433c36d32d5a91465e8d0082231a6c7c2e8f0ff79825599457c28b57e51ffcabdf21e7fb03ab5e63a28750c00fddfea74204c3f8da640fd9ffe38
6
+ metadata.gz: c6d24148fb7b252602028ba38200a3b8d156ece2f5b4fafefdaeae61e8c78718fb8e9d70f58dac356d96e7a455007f0a6d5d422062321fe600ee7783b08d6dde
7
+ data.tar.gz: 451223df83c431f13ed1da1abb3c074c03e57674180f37bd81abc5156309a8e5582380839bbcb5ba3ec23301ae0b7165083ffa15078b788714f09e6eeea92e6f
@@ -9,11 +9,11 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- os: [ubuntu-20.04, ubuntu-22.04]
13
- ruby-version: ['3.0', '3.1', '3.2']
12
+ os: [ubuntu-22.04, ubuntu-24.04]
13
+ ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4']
14
14
  runs-on: ${{ matrix.os }}
15
15
  steps:
16
- - uses: actions/checkout@v3
16
+ - uses: actions/checkout@v4
17
17
  - name: Set up Ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2016 Hiroyuki Sakuraba
2
- Copyright (c) 2022 Marco Colli, Pushpad (https://pushpad.xyz)
2
+ Copyright (c) 2022-2025 Marco Colli, Pushpad (https://pushpad.xyz)
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -55,10 +55,16 @@ navigator.serviceWorker.register('/service-worker.js')
55
55
 
56
56
  ### Subscribing to push notifications
57
57
 
58
- The VAPID public key you generated earlier is made available to the client as a `UInt8Array`. To do this, one way would be to expose the urlsafe-decoded bytes from Ruby to JavaScript when rendering the HTML template.
58
+ The VAPID public key that you generated earlier needs to be made available to JavaScript, which can be done in many ways, for example with a fetch request or when rendering the HTML template in Ruby:
59
59
 
60
- ```javascript
61
- window.vapidPublicKey = new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>);
60
+ ```erb
61
+ <script>
62
+ // Make the VAPID public key available to the client as a Uint8Array
63
+ window.vapidPublicKey = new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>)
64
+
65
+ // Or you can pass it as a string if you prefer
66
+ window.vapidPublicKey = "<%= ENV['VAPID_PUBLIC_KEY'].delete('=') %>"
67
+ </script>
62
68
  ```
63
69
 
64
70
  Your JavaScript code uses the `pushManager` interface to subscribe to push notifications, passing the VAPID public key to the subscription settings.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebPush
4
- VERSION = '3.0.1'.freeze
4
+ VERSION = '3.0.2'.freeze
5
5
  end
data/lib/web_push.rb CHANGED
@@ -56,10 +56,6 @@ module WebPush
56
56
  end
57
57
 
58
58
  def decode64(str)
59
- # For Ruby < 2.3, Base64.urlsafe_decode64 strict decodes and will raise errors if encoded value is not properly padded
60
- # Implementation: http://ruby-doc.org/stdlib-2.3.0/libdoc/base64/rdoc/Base64.html#method-i-urlsafe_decode64
61
- str = str.ljust((str.length + 3) & ~3, '=') if !str.end_with?('=') && str.length % 4 != 0
62
-
63
59
  Base64.urlsafe_decode64(str)
64
60
  end
65
61
 
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,12 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter '/spec/'
4
+ end
5
+
1
6
  require 'web_push'
2
7
  require 'webmock/rspec'
3
- require 'simplecov'
4
8
 
5
9
  WebMock.disable_net_connect!(allow_localhost: true)
6
- SimpleCov.start
7
10
 
8
11
  def vapid_options
9
12
  {
@@ -5,6 +5,18 @@ describe WebPush do
5
5
  expect(WebPush::VERSION).not_to be nil
6
6
  end
7
7
 
8
+ describe '.decode64' do
9
+ let(:a_padded_key) { "YWJjZGU=" }
10
+
11
+ it 'urlsafe decodes padded base64 string' do
12
+ expect(WebPush.decode64(a_padded_key)).to eq("abcde")
13
+ end
14
+
15
+ it 'urlsafe decodes unpadded base64 string' do
16
+ expect(WebPush.decode64(a_padded_key.delete("="))).to eq("abcde")
17
+ end
18
+ end
19
+
8
20
  shared_examples 'web push protocol standard error handling' do
9
21
  it 'raises InvalidSubscription if the API returns a 404 Error' do
10
22
  stub_request(:post, expected_endpoint)
data/web-push.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.required_ruby_version = '>= 3.0'
16
16
 
17
- spec.add_dependency 'jwt', '~> 2.0'
17
+ spec.add_dependency 'jwt', '~> 3.0'
18
18
  spec.add_dependency 'openssl', '~> 3.0'
19
19
 
20
20
  spec.add_development_dependency 'rspec', '~> 3.0'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zaru
8
8
  - collimarco
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-13 00:00:00.000000000 Z
12
+ date: 2025-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwt
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '2.0'
20
+ version: '3.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '2.0'
27
+ version: '3.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: openssl
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '3.0'
84
- description:
84
+ description:
85
85
  email:
86
86
  - support@pushpad.xyz
87
87
  executables: []
@@ -110,7 +110,7 @@ homepage: https://github.com/pushpad/web-push
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -125,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.3.1
129
- signing_key:
128
+ rubygems_version: 3.5.22
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: Web Push library for Ruby (RFC8030)
132
132
  test_files: []