mailkick 1.0.0 → 1.1.0

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: 2ff139814252a1c4ec153cc81f311dd5d8c1745a4970aaab8cb2164df4d4692d
4
- data.tar.gz: 1e4700dc2dbb96dcb09c4c79c00a837de387c8712db72c3bc13150ea94355da2
3
+ metadata.gz: 29547fd14ea942978a05dce4e217a19095b3e60b32d4f3d0da658603d02b2ef1
4
+ data.tar.gz: 5df27e5ebc7a4be7c60ea04251a78baaba22cf19d958a9043e0fdf30ec3760e2
5
5
  SHA512:
6
- metadata.gz: f28ec4a1bb1fa022ad4bd9a250a45650562db467a7c6d14f0150e5f9c8137cd766376a605c0304092ff7036d2efca22ae95e3d61e5693d40f616205b54aedb72
7
- data.tar.gz: 5eb0a1544b00da879c77c2919501c2b21f6c4916e7bc1b710ad271c33ba6cd9cd6607d5d8c06f64380ce825f11187ff841deb21c58cd9ee4a8af3536ff3f594b
6
+ metadata.gz: d656f3001137374753348508afe6a86a226039a9fba1873fad479d6f6b8f43ecf79f59e28fca498a505ab7b8467b44863fe8b6866f13c305530bc497976f5f49
7
+ data.tar.gz: 06b66e4eb5e9ba1705e8f62eaa3a953e8ff3fef54d65ca44ff6981313d36408e38533154258107cca82a8b02033772e311ee11be07e71dddb99a05be1bee2772
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
+ ## 1.1.0 (2023-01-29)
2
+
3
+ - Improved secret token generation
4
+
5
+ ## 1.0.1 (2021-06-20)
6
+
7
+ - Fixed error message when process out-opts not configured
8
+
1
9
  ## 1.0.0 (2021-06-03)
2
10
 
3
11
  - Switched from opt-outs to subscriptions
12
+ - Dropped support for Ruby < 2.6 and Rails < 5.2
4
13
 
5
14
  ## 0.4.3 (2020-11-01)
6
15
 
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.
@@ -97,7 +95,7 @@ Mailkick.process_opt_outs_method = lambda do |opt_outs|
97
95
  next unless subscriber
98
96
 
99
97
  subscriber.mailkick_subscriptions.each do |subscription|
100
- subscription.destroy if subscription.updated_at < opt_out[:time]
98
+ subscription.destroy if subscription.created_at < opt_out[:time]
101
99
  end
102
100
  end
103
101
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/mailkick.rb CHANGED
@@ -22,10 +22,12 @@ require "mailkick/version"
22
22
  require "mailkick/engine" if defined?(Rails)
23
23
 
24
24
  module Mailkick
25
- mattr_accessor :services, :secret_token, :mount, :process_opt_outs_method
25
+ mattr_accessor :services, :mount, :process_opt_outs_method
26
+ mattr_reader :secret_token
27
+ mattr_writer :message_verifier
26
28
  self.services = []
27
29
  self.mount = true
28
- self.process_opt_outs_method = -> { raise "process_opt_outs_method not defined" }
30
+ self.process_opt_outs_method = ->(_) { raise "process_opt_outs_method not defined" }
29
31
 
30
32
  def self.fetch_opt_outs
31
33
  services.each(&:fetch_opt_outs)
@@ -37,8 +39,15 @@ module Mailkick
37
39
  end
38
40
  end
39
41
 
42
+ def self.secret_token=(token)
43
+ @@secret_token = token
44
+ @@message_verifier = nil
45
+ end
46
+
47
+ # TODO use JSON serializer
48
+ # can't currently rotate serializer without rotating token or digest
40
49
  def self.message_verifier
41
- @message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
50
+ @@message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
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.0
4
+ version: 1.1.0
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-04 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
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.2.3
77
+ rubygems_version: 3.4.1
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Email subscriptions for Rails