fcmpush 1.4.2 → 1.4.4

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
  SHA256:
3
- metadata.gz: 1d98bbee5a1f8daeb92bc80eb99e47900fbdb1dd1b02f94ccf336438acca4309
4
- data.tar.gz: e0c867579f0b8a9f36bdb1072eac2260c402ca1bb9a7651f991c039d453d6f90
3
+ metadata.gz: dbef0d4424feeec5ee1cf9b8a2cf1a09905bf38b6cdeee81258d54743cf482e3
4
+ data.tar.gz: 7e5b83733bf0a835a726d86eddb4c7620d57d0fc83b325b0ad5fa9c198a9152f
5
5
  SHA512:
6
- metadata.gz: 6955bdd01edff13812527e4c3b0e559d8fbf50d264ef27ac9f7bfb86cf9aa7b37e99ab05f6a7d3e4086c0a8ae13a91bd0198ac44d3ce4d2f3d1dcc6b38c56e64
7
- data.tar.gz: 0ad35b0fcf345715f4a6bc307a14f087961315803c0916e0032115cde3b8c3659fe18c108e22d822e2b4be9dbee41e6f9d1cd8a8804f76b370e6682881a2f4cf
6
+ metadata.gz: b00c885a01a3e27e3bb605debe64ad9a5e12bb2908baad3a8327c8d63dd9e2099dba3bc4e35e3804b0795b3f984a796c026ec3f2c22ee653508f3b6ca749f0b6
7
+ data.tar.gz: be3b0ae624b2d2dbbea1cfcd8ae42f44aa8cab254bc0ebbb1df8f65ccbefa3e5116e58cac67065064514a9a65b6e0d18f68732f9082a54e989710a6199b8b7b9
@@ -23,9 +23,12 @@ module Fcmpush
23
23
  access_token_response = v1_authorize
24
24
  @access_token = access_token_response['access_token']
25
25
  @access_token_expiry = Time.now.utc + access_token_response['expires_in']
26
- @server_key = configuration.server_key
26
+ # @server_key = configuration.server_key
27
27
  @connection = Net::HTTP::Persistent.new
28
28
 
29
+ @connection.open_timeout = configuration.open_timeout if configuration.open_timeout
30
+ @connection.read_timeout = configuration.read_timeout if configuration.read_timeout
31
+
29
32
  if !configuration.proxy
30
33
  # do nothing
31
34
  elsif configuration.proxy == :ENV
@@ -112,7 +115,10 @@ module Fcmpush
112
115
  uri = URI.join(TOPIC_DOMAIN, TOPIC_ENDPOINT_PREFIX + suffix)
113
116
  uri.query = URI.encode_www_form(query) unless query.empty?
114
117
 
115
- headers = legacy_authorized_header(headers)
118
+ headers = v1_authorized_header(headers)
119
+ # cf. https://takanamito.hateblo.jp/entry/2020/07/04/175045
120
+ # cf. https://github.com/miyataka/fcmpush/issues/40
121
+ headers['access_token_auth'] = 'true'
116
122
  post = Net::HTTP::Post.new(uri, headers)
117
123
  post.body = make_subscription_body(topic, *instance_ids)
118
124
 
@@ -133,7 +139,9 @@ module Fcmpush
133
139
  'Authorization' => "Bearer #{access_token}")
134
140
  end
135
141
 
142
+ # @deprecated TODO: remove this method next version
136
143
  def legacy_authorized_header(headers)
144
+ warn "[DEPRECATION] `legacy_authorized_header` is deprecated. Please use `v1_authorized_header` instead."
137
145
  headers.merge('Content-Type' => 'application/json',
138
146
  'Accept' => 'application/json',
139
147
  'Authorization' => "Bearer #{server_key}")
@@ -1,6 +1,6 @@
1
1
  module Fcmpush
2
2
  class Configuration
3
- attr_accessor :scope, :json_key_io, :server_key, :proxy
3
+ attr_accessor :scope, :json_key_io, :server_key, :proxy, :open_timeout, :read_timeout
4
4
 
5
5
  def initialize
6
6
  @scope = ['https://www.googleapis.com/auth/firebase.messaging']
@@ -15,13 +15,21 @@ module Fcmpush
15
15
  # ENV['GOOGLE_PRIVATE_KEY'] = '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n'
16
16
 
17
17
  # regacy auth
18
+ # @deprecated TODO: remove this next version
18
19
  @server_key = ENV['FCM_SERVER_KEY']
20
+ if @server_key
21
+ warn '[DEPRECATION] `FCM_SERVER_KEY` environment variable, also @server_key is deprecated. This attribute will be removed next version.'
22
+ end
19
23
 
20
24
  # THIS IS EXPERIMENTAL
21
25
  # NOT support `HTTPS_PROXY` environment variable. This feature not tested well on CI.
22
26
  # cf. https://github.com/miyataka/fcmpush/pull/39#issuecomment-1722533622
23
27
  # proxy
24
28
  @proxy = :ENV
29
+
30
+ # connection timeouts
31
+ @open_timeout = nil
32
+ @read_timeout = nil
25
33
  end
26
34
  end
27
35
  end
@@ -1,3 +1,3 @@
1
1
  module Fcmpush
2
- VERSION = '1.4.2'.freeze
2
+ VERSION = '1.4.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcmpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyataka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-27 00:00:00.000000000 Z
11
+ date: 2024-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-apis-identitytoolkit_v3