payload-plugin-newsletter 0.1.1 → 0.3.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +39 -2
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/collections/NewsletterSettings.d.ts +4 -0
  5. package/dist/collections/NewsletterSettings.d.ts.map +1 -0
  6. package/dist/collections/Subscribers.d.ts.map +1 -1
  7. package/dist/endpoints/preferences.d.ts.map +1 -1
  8. package/dist/endpoints/subscribe.d.ts.map +1 -1
  9. package/dist/endpoints/unsubscribe.d.ts.map +1 -1
  10. package/dist/endpoints/verify-magic-link.d.ts.map +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/src/collections/NewsletterSettings.js +389 -0
  13. package/dist/src/collections/NewsletterSettings.js.map +1 -0
  14. package/dist/src/collections/Subscribers.js.map +1 -1
  15. package/dist/src/components/MagicLinkVerify.js +1 -1
  16. package/dist/src/components/MagicLinkVerify.js.map +1 -1
  17. package/dist/src/endpoints/preferences.js +16 -4
  18. package/dist/src/endpoints/preferences.js.map +1 -1
  19. package/dist/src/endpoints/subscribe.js +14 -3
  20. package/dist/src/endpoints/subscribe.js.map +1 -1
  21. package/dist/src/endpoints/unsubscribe.js +10 -2
  22. package/dist/src/endpoints/unsubscribe.js.map +1 -1
  23. package/dist/src/endpoints/verify-magic-link.js +13 -3
  24. package/dist/src/endpoints/verify-magic-link.js.map +1 -1
  25. package/dist/src/index.js +18 -12
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/templates/NewsletterTemplate.js.map +1 -1
  28. package/dist/src/templates/WelcomeTemplate.js.map +1 -1
  29. package/dist/src/types/index.js.map +1 -1
  30. package/dist/templates/NewsletterTemplate.d.ts.map +1 -1
  31. package/dist/templates/WelcomeTemplate.d.ts.map +1 -1
  32. package/dist/types/index.d.ts +5 -0
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/package.json +7 -3
  35. package/CLAUDE.md +0 -110
  36. package/dist/globals/EmailSettings.d.ts +0 -4
  37. package/dist/globals/EmailSettings.d.ts.map +0 -1
  38. package/dist/src/globals/EmailSettings.js +0 -252
  39. package/dist/src/globals/EmailSettings.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0] - 2025-06-15
9
+
10
+ ### Added
11
+ - Comprehensive security improvements to respect Payload access control
12
+ - Synthetic user pattern for subscriber self-service operations
13
+ - Admin verification for newsletter settings modifications
14
+ - Security documentation in README
15
+
16
+ ### Changed
17
+ - All API endpoints now properly implement `overrideAccess` and `user` parameters
18
+ - Preferences endpoint now ensures subscribers can only access their own data
19
+ - Unsubscribe endpoint validates ownership through tokens
20
+ - Magic link verification uses synthetic users for updates
21
+ - Newsletter settings modifications now require admin authentication
22
+
23
+ ### Security
24
+ - Implemented proper access control for all Payload Local API operations
25
+ - Added user context validation for authenticated endpoints
26
+ - Restricted settings access to admin users only
27
+ - Enhanced protection against unauthorized data access
28
+
29
+ ## [0.2.0] - 2025-06-15
30
+
31
+ ### Changed
32
+ - **BREAKING**: Changed newsletter settings from a global to a collection
33
+ - Allows multiple configurations (e.g., dev/staging/prod)
34
+ - Only one configuration can be active at a time
35
+ - Migrate existing settings by creating a new configuration in the collection
36
+ - Updated README to clarify the settings collection usage
37
+
38
+ ### Added
39
+ - Support for multiple email configurations
40
+ - Automatic deactivation of other configs when activating one
41
+ - Configuration name field for better organization
42
+
8
43
  ## [0.1.1] - 2025-06-15
9
44
 
10
45
  ### Fixed
@@ -38,6 +73,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
38
73
  - Domain restriction options
39
74
  - Input validation and sanitization
40
75
 
76
+ [0.3.0]: https://github.com/aniketpanjwani/payload-plugin-email-newsletter/releases/tag/v0.3.0
77
+ [0.2.0]: https://github.com/aniketpanjwani/payload-plugin-email-newsletter/releases/tag/v0.2.0
78
+ [0.1.1]: https://github.com/aniketpanjwani/payload-plugin-email-newsletter/releases/tag/v0.1.1
41
79
  [0.1.0]: https://github.com/aniketpanjwani/payload-plugin-email-newsletter/releases/tag/v0.1.0
42
80
 
43
81
  ---
package/README.md CHANGED
@@ -64,7 +64,7 @@ export default buildConfig({
64
64
 
65
65
  The plugin automatically adds:
66
66
  - A `subscribers` collection to manage your subscribers
67
- - A `newsletter-settings` global for email configuration
67
+ - A `newsletter-settings` collection for email configurations (supports multiple environments)
68
68
  - API endpoints for subscription and authentication
69
69
  - Newsletter scheduling fields to your articles (optional)
70
70
 
@@ -111,12 +111,32 @@ Subscribers can be managed through the Payload admin panel at `/admin/collection
111
111
 
112
112
  ### Email Settings
113
113
 
114
- After setup, configure email settings at `/admin/globals/newsletter-settings` in your admin panel. You can:
114
+ After setup, configure email settings at `/admin/collections/newsletter-settings` in your admin panel. You can:
115
+ - Create multiple configurations (e.g., for different environments or purposes)
116
+ - Set one configuration as active at a time
115
117
  - Switch between email providers
116
118
  - Update API keys and settings
117
119
  - Customize email templates
118
120
  - Set subscription preferences
119
121
 
122
+ **Note**: Only one configuration can be active at a time. The plugin will use the active configuration for sending emails.
123
+
124
+ ## Initial Setup
125
+
126
+ After installing the plugin, you'll need to:
127
+
128
+ 1. **Create an email configuration**:
129
+ - Go to `/admin/collections/newsletter-settings`
130
+ - Click "Create New"
131
+ - Give it a name (e.g., "Production" or "Development")
132
+ - Configure your email provider settings
133
+ - Set it as "Active"
134
+ - Save
135
+
136
+ 2. **Start collecting subscribers**:
137
+ - Subscribers will appear in `/admin/collections/subscribers`
138
+ - Use the provided React components or API endpoints
139
+
120
140
  ## Configuration Options
121
141
 
122
142
  ### Minimal Configuration
@@ -394,6 +414,23 @@ newsletterPlugin({
394
414
  - Check the email provider's dashboard for errors
395
415
  - Ensure from address is verified with your provider
396
416
 
417
+ ## Security
418
+
419
+ ### Access Control
420
+
421
+ Starting from v0.3.0, the plugin implements proper access control for all operations:
422
+
423
+ - **Subscriber data**: Users can only access and modify their own data via magic link authentication
424
+ - **Newsletter settings**: Only admin users can modify email provider settings and configurations
425
+ - **API endpoints**: All endpoints respect Payload's access control rules
426
+
427
+ ### Best Practices
428
+
429
+ - Always use environment variables for sensitive data (API keys, JWT secrets)
430
+ - Enable double opt-in for GDPR compliance
431
+ - Configure allowed domains to prevent spam subscriptions
432
+ - Set reasonable rate limits for subscriptions per IP
433
+
397
434
  ## Migration Guide
398
435
 
399
436
  Coming from another newsletter system? The plugin stores subscribers in a standard Payload collection, making it easy to import existing data: