mailkick 1.0.1 → 1.1.1

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: e84a6786c23946b6e27a67a14d75c01da5cde231928d19c65edd2b591de9a153
4
- data.tar.gz: 1a944d065c7bf4c164db038aabe0073b3759e96a232ec22b29e86cf746ffc02f
3
+ metadata.gz: 2d27cea2a7290b64e0b7d59322124923e5c84069040d43df800269bd17069aec
4
+ data.tar.gz: 4a40900192322ef6e5f04940277713ce43d0c64c3a672ec29ec3a5dbd2269e80
5
5
  SHA512:
6
- metadata.gz: 3ed9f0315dc5c60ed5b2cc524fd13763566b6126bafceb665dbddcdc2a182f4408a370e267fdcc8ab97cbe616684c7ff5ab91b0fe717d39a65deac854cd3b958
7
- data.tar.gz: 82c2c1d7a1d0077eb60df59a9d672039b17750462a435afdef19125e26f3c122600a2a8f394c06a3119a64c773d4a6ef7a1f61dc5081dca587735eda80c4a9c3
6
+ metadata.gz: 39fc8af0c0b60f613834f05e9b02b8bbe795cb483ce62e4a99016d257ae0345ff7a97d024d5e4c9791b04f5074e51679b92175470e987e613152034aa8ee5128
7
+ data.tar.gz: b1f1ed3b224be6bfb74d87851e029a797783b7bf25d4d19c09a2b1867b3ce6a1803e19cabf7942ec9eedd1575c3aff6f6279386373fe8a6af807f659bb395817
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 1.1.1 (2023-01-30)
2
+
3
+ - Switched to JSON for serialization with non-default `secret_token`
4
+
5
+ ## 1.1.0 (2023-01-29)
6
+
7
+ - Improved secret token generation
8
+ - Switched to JSON for serialization with default `secret_token`
9
+
1
10
  ## 1.0.1 (2021-06-20)
2
11
 
3
12
  - Fixed error message when process out-opts not configured
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2021 Andrew Kane
1
+ Copyright (c) 2014-2023 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -5,8 +5,6 @@ Email subscriptions for Rails
5
5
  - Add one-click unsubscribe links to your emails
6
6
  - Fetch bounces and spam reports from your email service
7
7
 
8
- **Mailkick 1.0 was recently released** - see [how to upgrade](#upgrading)
9
-
10
8
  :postbox: Check out [Ahoy Email](https://github.com/ankane/ahoy_email) for analytics
11
9
 
12
10
  [![Build Status](https://github.com/ankane/mailkick/workflows/build/badge.svg?branch=master)](https://github.com/ankane/mailkick/actions)
@@ -16,7 +14,7 @@ Email subscriptions for Rails
16
14
  Add this line to your application’s Gemfile:
17
15
 
18
16
  ```ruby
19
- gem 'mailkick'
17
+ gem "mailkick"
20
18
  ```
21
19
 
22
20
  And run the generator. This creates a table to store subscriptions.
@@ -125,7 +123,7 @@ Will gladly accept pull requests for others.
125
123
  Add the gem
126
124
 
127
125
  ```ruby
128
- gem 'aws-sdk-sesv2'
126
+ gem "aws-sdk-sesv2"
129
127
  ```
130
128
 
131
129
  And [configure your AWS credentials](https://github.com/aws/aws-sdk-ruby#configuration). Requires `ses:ListSuppressedDestinations` permission.
@@ -137,7 +135,7 @@ If you started using Amazon SES [before November 25, 2019](https://docs.aws.amaz
137
135
  Add the gem
138
136
 
139
137
  ```ruby
140
- gem 'gibbon', '>= 2'
138
+ gem "gibbon", ">= 2"
141
139
  ```
142
140
 
143
141
  And set `ENV["MAILCHIMP_API_KEY"]` and `ENV["MAILCHIMP_LIST_ID"]`.
@@ -147,7 +145,7 @@ And set `ENV["MAILCHIMP_API_KEY"]` and `ENV["MAILCHIMP_LIST_ID"]`.
147
145
  Add the gem
148
146
 
149
147
  ```ruby
150
- gem 'mailgun-ruby'
148
+ gem "mailgun-ruby"
151
149
  ```
152
150
 
153
151
  And set `ENV["MAILGUN_API_KEY"]`.
@@ -157,7 +155,7 @@ And set `ENV["MAILGUN_API_KEY"]`.
157
155
  Add the gem
158
156
 
159
157
  ```ruby
160
- gem 'mandrill-api'
158
+ gem "mandrill-api"
161
159
  ```
162
160
 
163
161
  And set `ENV["MANDRILL_APIKEY"]`.
@@ -167,7 +165,7 @@ And set `ENV["MANDRILL_APIKEY"]`.
167
165
  Add the gem
168
166
 
169
167
  ```ruby
170
- gem 'postmark'
168
+ gem "postmark"
171
169
  ```
172
170
 
173
171
  And set `ENV["POSTMARK_API_KEY"]`.
@@ -177,7 +175,7 @@ And set `ENV["POSTMARK_API_KEY"]`.
177
175
  Add the gem
178
176
 
179
177
  ```ruby
180
- gem 'sendgrid-ruby'
178
+ gem "sendgrid-ruby"
181
179
  ```
182
180
 
183
181
  And set `ENV["SENDGRID_API_KEY"]`. The API key requires only the `Suppressions` permission.
@@ -5,7 +5,11 @@ module Mailkick
5
5
  initializer "mailkick" do |app|
6
6
  Mailkick.discover_services unless Mailkick.services.any?
7
7
 
8
- Mailkick.secret_token ||= begin
8
+ unless Mailkick.secret_token
9
+ Mailkick.secret_token = app.key_generator.generate_key("mailkick")
10
+ Mailkick.message_verifier = ActiveSupport::MessageVerifier.new(Mailkick.secret_token, serializer: JSON)
11
+
12
+ # TODO remove in 2.0
9
13
  creds =
10
14
  if app.respond_to?(:credentials) && app.credentials.secret_key_base
11
15
  app.credentials
@@ -15,7 +19,8 @@ module Mailkick
15
19
  app.config
16
20
  end
17
21
 
18
- creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
22
+ token = creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
23
+ Mailkick.message_verifier.rotate(token, serializer: Marshal)
19
24
  end
20
25
  end
21
26
  end
@@ -0,0 +1,15 @@
1
+ # need custom class due to
2
+ # https://github.com/rails/rails/issues/47185
3
+ module Mailkick
4
+ class Serializer
5
+ def self.dump(value)
6
+ JSON.dump(value)
7
+ end
8
+
9
+ def self.load(value)
10
+ JSON.load(value)
11
+ rescue JSON::ParserError
12
+ Marshal.load(value)
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.1"
3
3
  end
data/lib/mailkick.rb CHANGED
@@ -2,11 +2,13 @@
2
2
  require "active_support"
3
3
 
4
4
  # stdlib
5
+ require "json"
5
6
  require "set"
6
7
 
7
8
  # modules
8
9
  require "mailkick/legacy"
9
10
  require "mailkick/model"
11
+ require "mailkick/serializer"
10
12
  require "mailkick/service"
11
13
  require "mailkick/service/aws_ses"
12
14
  require "mailkick/service/mailchimp"
@@ -22,7 +24,9 @@ require "mailkick/version"
22
24
  require "mailkick/engine" if defined?(Rails)
23
25
 
24
26
  module Mailkick
25
- mattr_accessor :services, :secret_token, :mount, :process_opt_outs_method
27
+ mattr_accessor :services, :mount, :process_opt_outs_method
28
+ mattr_reader :secret_token
29
+ mattr_writer :message_verifier
26
30
  self.services = []
27
31
  self.mount = true
28
32
  self.process_opt_outs_method = ->(_) { raise "process_opt_outs_method not defined" }
@@ -37,8 +41,13 @@ module Mailkick
37
41
  end
38
42
  end
39
43
 
44
+ def self.secret_token=(token)
45
+ @@secret_token = token
46
+ @@message_verifier = nil
47
+ end
48
+
40
49
  def self.message_verifier
41
- @message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
50
+ @@message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token, serializer: Serializer)
42
51
  end
43
52
 
44
53
  def self.generate_token(subscriber, list)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-20 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -45,6 +45,7 @@ files:
45
45
  - lib/mailkick/engine.rb
46
46
  - lib/mailkick/legacy.rb
47
47
  - lib/mailkick/model.rb
48
+ - lib/mailkick/serializer.rb
48
49
  - lib/mailkick/service.rb
49
50
  - lib/mailkick/service/aws_ses.rb
50
51
  - lib/mailkick/service/mailchimp.rb
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.2.3
78
+ rubygems_version: 3.4.1
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Email subscriptions for Rails