web-push 3.0.1 → 3.1.0

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: e3bdb2158142d9ffd8c7f50671b7613afd5f19021a16b9416aae42b8c05e8403
4
+ data.tar.gz: 81d443e347403d3a22a8d8c91998bec7280b2015930a9303bbc9143014304748
5
5
  SHA512:
6
- metadata.gz: 2386c18e4fef78c027b2a5dee6a1778dc82d43cf26dcf0468e83feb8ff972eca1b743c87d68612fffee8ea9feb05329bc4a06127599643de72d922b465aca776
7
- data.tar.gz: b023139054b433c36d32d5a91465e8d0082231a6c7c2e8f0ff79825599457c28b57e51ffcabdf21e7fb03ab5e63a28750c00fddfea74204c3f8da640fd9ffe38
6
+ metadata.gz: 3b2d34d5da7ecb7705abc060be5f4578eb2cfe5cd9d4fd62f7b13ecb4d2473c0009e174d3553850cc7abe68d4900741d1d9eee6f92846222a5adaef9bb9ba1f4
7
+ data.tar.gz: d14f4adfe100b421638daa9e3b47d4221d39f8f35cade077f28e7d82f105ee84532facb813aa7165c9c86085c9a3c7c58dbafa917ec3ba4da9d5ee5b78d90875
@@ -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@v6
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
@@ -5,7 +5,8 @@
5
5
 
6
6
  This gem makes it possible to send push messages to web browsers from Ruby backends using the [Web Push Protocol](https://datatracker.ietf.org/doc/html/rfc8030). It supports [Message Encryption for Web Push](https://datatracker.ietf.org/doc/html/rfc8291) and [VAPID](https://datatracker.ietf.org/doc/html/rfc8292).
7
7
 
8
- **Note**: This is an open source gem for Web Push. If you want to send web push notifications from Ruby using Pushpad, you need to use another gem ([pushpad gem](https://github.com/pushpad/pushpad-ruby)).
8
+ > [!NOTE]
9
+ > This is an open source gem for Web Push maintained by Pushpad. If you want to send web push notifications from Ruby using Pushpad (the cloud service), use the [pushpad gem](https://github.com/pushpad/pushpad-ruby).
9
10
 
10
11
  ## Installation
11
12
 
@@ -55,10 +56,16 @@ navigator.serviceWorker.register('/service-worker.js')
55
56
 
56
57
  ### Subscribing to push notifications
57
58
 
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.
59
+ 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
60
 
60
- ```javascript
61
- window.vapidPublicKey = new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>);
61
+ ```erb
62
+ <script>
63
+ // Make the VAPID public key available to the client as a Uint8Array
64
+ window.vapidPublicKey = new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>)
65
+
66
+ // Or you can pass it as a string if you prefer
67
+ window.vapidPublicKey = "<%= ENV['VAPID_PUBLIC_KEY'].delete('=') %>"
68
+ </script>
62
69
  ```
63
70
 
64
71
  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.1.0'.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,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.required_ruby_version = '>= 3.0'
16
16
 
17
- spec.add_dependency 'jwt', '~> 2.0'
18
- spec.add_dependency 'openssl', '~> 3.0'
17
+ spec.add_dependency 'jwt', '~> 3.0'
18
+ spec.add_dependency 'openssl', '>= 3.0'
19
19
 
20
20
  spec.add_development_dependency 'rspec', '~> 3.0'
21
21
  spec.add_development_dependency 'simplecov', '~> 0.0'
metadata CHANGED
@@ -1,15 +1,14 @@
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zaru
8
8
  - collimarco
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-11-13 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: jwt
@@ -17,26 +16,26 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '2.0'
19
+ version: '3.0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: '2.0'
26
+ version: '3.0'
28
27
  - !ruby/object:Gem::Dependency
29
28
  name: openssl
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
- - - "~>"
31
+ - - ">="
33
32
  - !ruby/object:Gem::Version
34
33
  version: '3.0'
35
34
  type: :runtime
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
- - - "~>"
38
+ - - ">="
40
39
  - !ruby/object:Gem::Version
41
40
  version: '3.0'
42
41
  - !ruby/object:Gem::Dependency
@@ -81,7 +80,6 @@ dependencies:
81
80
  - - "~>"
82
81
  - !ruby/object:Gem::Version
83
82
  version: '3.0'
84
- description:
85
83
  email:
86
84
  - support@pushpad.xyz
87
85
  executables: []
@@ -110,7 +108,6 @@ homepage: https://github.com/pushpad/web-push
110
108
  licenses:
111
109
  - MIT
112
110
  metadata: {}
113
- post_install_message:
114
111
  rdoc_options: []
115
112
  require_paths:
116
113
  - lib
@@ -125,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
122
  - !ruby/object:Gem::Version
126
123
  version: '0'
127
124
  requirements: []
128
- rubygems_version: 3.0.3.1
129
- signing_key:
125
+ rubygems_version: 3.6.9
130
126
  specification_version: 4
131
127
  summary: Web Push library for Ruby (RFC8030)
132
128
  test_files: []