fcmpush 1.4.1 → 1.4.3

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: 8b7e2ec1bd92516fddfe4188ad164cc4f03e586d9de159fb52eb6f9318f99cb2
4
- data.tar.gz: d31f5a82b26960cb115930eb080a1c40516541292227c3f43e5397c6ceb39382
3
+ metadata.gz: 5955f70af9ad3b06fbd33190d218cd115919476a8f3bd85b0f97d3d13ab94757
4
+ data.tar.gz: 5f267e161537e51aaeb44428de5fe024556cf865b2fb3178a2b5286418250ef8
5
5
  SHA512:
6
- metadata.gz: 530207aada029ea8ef333957158eaa8c8ab147fdb6fe4a56cd707026ffe82f68eae6cee6701e3494be0bccbfb572fe61c481cc077bf2dd93c8da2f2b9ab453f3
7
- data.tar.gz: bf0f2c5b86ac0221f038ba303d373c591ca4dcf08a9c51183ff5061f4b2513e79b149ea47e0093db3642d7ae11cfba529b7d6f4a2796fa03dc1d73edaf72b305
6
+ metadata.gz: 9577b9638e6d3968377e648fb407f7ec5624bf4446c6dc04b1831e4da9d82022d78c7e96fd8bd0729fdb955366fa53fbf88e641b11a2da4ac2f7931bad14d3d5
7
+ data.tar.gz: b4a36fdfc16a8d9c85fc35373db504a1861c96b0f3cdbffd5feebcce7542d5d4bf969408f25854262317555e753ad2bedf0aa019012555364be6976869309b7f
data/fcmpush.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.required_ruby_version = '>= 2.6', '< 3.3'
25
+ spec.required_ruby_version = '>= 2.6', '< 3.4'
26
26
 
27
27
  spec.add_dependency 'google-apis-identitytoolkit_v3'
28
28
  spec.add_dependency 'net-http-persistent', '~> 4.0.1'
@@ -23,8 +23,22 @@ 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
+
29
+ if !configuration.proxy
30
+ # do nothing
31
+ elsif configuration.proxy == :ENV
32
+ @connection.proxy = :ENV
33
+ elsif configuration.proxy && configuration.proxy[:uri]
34
+ uri = URI(configuration.proxy[:uri])
35
+ # user name must not be a empty string, password can
36
+ if configuration.proxy[:user] && configuration.proxy[:user].strip != ''
37
+ uri.user = configuration.proxy[:user]
38
+ uri.password = configuration.proxy[:password] if configuration.proxy[:password]
39
+ end
40
+ @connection.proxy = uri
41
+ end
28
42
  end
29
43
 
30
44
  def v1_authorize
@@ -98,7 +112,10 @@ module Fcmpush
98
112
  uri = URI.join(TOPIC_DOMAIN, TOPIC_ENDPOINT_PREFIX + suffix)
99
113
  uri.query = URI.encode_www_form(query) unless query.empty?
100
114
 
101
- headers = legacy_authorized_header(headers)
115
+ headers = v1_authorized_header(headers)
116
+ # cf. https://takanamito.hateblo.jp/entry/2020/07/04/175045
117
+ # cf. https://github.com/miyataka/fcmpush/issues/40
118
+ headers['access_token_auth'] = 'true'
102
119
  post = Net::HTTP::Post.new(uri, headers)
103
120
  post.body = make_subscription_body(topic, *instance_ids)
104
121
 
@@ -119,7 +136,9 @@ module Fcmpush
119
136
  'Authorization' => "Bearer #{access_token}")
120
137
  end
121
138
 
139
+ # @deprecated TODO: remove this method next version
122
140
  def legacy_authorized_header(headers)
141
+ warn "[DEPRECATION] `legacy_authorized_header` is deprecated. Please use `v1_authorized_header` instead."
123
142
  headers.merge('Content-Type' => 'application/json',
124
143
  'Accept' => 'application/json',
125
144
  'Authorization' => "Bearer #{server_key}")
@@ -127,7 +146,7 @@ module Fcmpush
127
146
 
128
147
  def exception_handler(response)
129
148
  error = STATUS_TO_EXCEPTION_MAPPING[response.code]
130
- raise error.new("Receieved an error response #{response.code} #{error.to_s.split('::').last}: #{response.body}", response) if error
149
+ raise error.new("Received an error response #{response.code} #{error.to_s.split('::').last}: #{response.body}", response) if error
131
150
 
132
151
  response
133
152
  end
@@ -1,6 +1,6 @@
1
1
  module Fcmpush
2
2
  class Configuration
3
- attr_accessor :scope, :json_key_io, :server_key
3
+ attr_accessor :scope, :json_key_io, :server_key, :proxy
4
4
 
5
5
  def initialize
6
6
  @scope = ['https://www.googleapis.com/auth/firebase.messaging']
@@ -15,7 +15,17 @@ 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
23
+
24
+ # THIS IS EXPERIMENTAL
25
+ # NOT support `HTTPS_PROXY` environment variable. This feature not tested well on CI.
26
+ # cf. https://github.com/miyataka/fcmpush/pull/39#issuecomment-1722533622
27
+ # proxy
28
+ @proxy = :ENV
19
29
  end
20
30
  end
21
31
  end
@@ -1,3 +1,3 @@
1
1
  module Fcmpush
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.4.3'.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.1
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyataka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-02 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-apis-identitytoolkit_v3
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '2.6'
114
114
  - - "<"
115
115
  - !ruby/object:Gem::Version
116
- version: '3.3'
116
+ version: '3.4'
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="