@rensblitz/customer-instant-feedback-app 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rens Blitz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # Customer Instant Feedback App
2
+
3
+ A React component library for collecting user feedback directly within your application.
4
+
5
+ ## Features
6
+
7
+ - Capture screenshots with feedback
8
+ - Annotate specific elements
9
+ - Categorize feedback (Bug, UX, Content, Other)
10
+ - Configurable security modes (Open, Public Insert, Authenticated Only)
11
+ - Client-side rate limiting
12
+ - Input validation
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @rensblitz/customer-instant-feedback-app
18
+ ```
19
+
20
+ Or with yarn:
21
+
22
+ ```bash
23
+ yarn add @rensblitz/customer-instant-feedback-app
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Wrap your application with `FeedbackProvider`:
29
+
30
+ ```tsx
31
+ import { FeedbackProvider } from '@rensblitz/customer-instant-feedback-app';
32
+ import '@rensblitz/customer-instant-feedback-app/style.css';
33
+ import { createClient } from '@supabase/supabase-js';
34
+
35
+ const supabase = createClient('YOUR_URL', 'YOUR_ANON_KEY');
36
+
37
+ function App() {
38
+ return (
39
+ <FeedbackProvider
40
+ supabaseClient={supabase}
41
+ securityMode="public-insert" // Recommended for production
42
+ rateLimitSeconds={30}
43
+ validation={{
44
+ maxCommentLength: 2000,
45
+ maxNameLength: 100,
46
+ maxScreenshotSize: 500000, // 500KB
47
+ }}
48
+ >
49
+ <YourApp />
50
+ </FeedbackProvider>
51
+ );
52
+ }
53
+ ```
54
+
55
+ ## Security Configuration
56
+
57
+ The `FeedbackProvider` accepts a `securityMode` prop to control access levels.
58
+
59
+ ### Modes
60
+
61
+ | Mode | Description | Use Case |
62
+ | :--- | :--- | :--- |
63
+ | `open` (Default) | Full public access (read/write/update/delete). | Development / Internal Testing |
64
+ | `public-insert` | Anyone can submit feedback. Only authenticated users can read/manage. | Production (Recommended) |
65
+ | `authenticated-only` | Only authenticated users can submit or read feedback. | Internal Tools / Protected Apps |
66
+ | `custom` | You manage RLS policies entirely yourself. | Advanced Requirements |
67
+
68
+ ### Rate Limiting
69
+
70
+ Client-side rate limiting is available via `rateLimitSeconds`.
71
+
72
+ ```tsx
73
+ <FeedbackProvider rateLimitSeconds={60} ... />
74
+ ```
75
+
76
+ ### Validation
77
+
78
+ Input validation can be configured via `validation` prop.
79
+
80
+ ```tsx
81
+ <FeedbackProvider
82
+ validation={{
83
+ maxCommentLength: 500,
84
+ maxNameLength: 50,
85
+ allowScreenshots: true,
86
+ maxScreenshotSize: 1024 * 1024 // 1MB
87
+ }}
88
+ ...
89
+ />
90
+ ```
91
+
92
+ ## Migrations
93
+
94
+ We provide SQL templates for each security mode in the `migrations/` folder.
95
+
96
+ ### 1. Open Mode (`migrations/feedback_items_open.sql`)
97
+
98
+ Best for local development where auth is not set up.
99
+
100
+ ```sql
101
+ create policy "Allow public access to feedback items"
102
+ on public.feedback_items for all
103
+ using (true) with check (true);
104
+ ```
105
+
106
+ ### 2. Public Insert (`migrations/feedback_items_public_insert.sql`)
107
+
108
+ Allows anonymous users to submit feedback, but protects data from being read or modified publicly.
109
+
110
+ ```sql
111
+ create policy "Anyone can submit feedback"
112
+ on public.feedback_items for insert to public
113
+ with check (true);
114
+
115
+ create policy "Authenticated users can read feedback"
116
+ on public.feedback_items for select to authenticated
117
+ using (true);
118
+ ```
119
+
120
+ ### 3. Authenticated Only (`migrations/feedback_items_authenticated.sql`)
121
+
122
+ Strict mode requiring authentication for all operations.
123
+
124
+ ```sql
125
+ create policy "Authenticated users can manage feedback"
126
+ on public.feedback_items for all to authenticated
127
+ using (true) with check (true);
128
+ ```
129
+
130
+ ## TypeScript Types
131
+
132
+ ```typescript
133
+ type SecurityMode = 'open' | 'public-insert' | 'authenticated-only' | 'custom';
134
+
135
+ interface ValidationConfig {
136
+ maxCommentLength?: number;
137
+ maxNameLength?: number;
138
+ allowScreenshots?: boolean;
139
+ maxScreenshotSize?: number;
140
+ }
141
+
142
+ interface FeedbackProviderProps {
143
+ children: React.ReactNode;
144
+ enabled?: boolean;
145
+ supabaseClient?: SupabaseClient;
146
+ securityMode?: SecurityMode;
147
+ rateLimitSeconds?: number;
148
+ validation?: ValidationConfig;
149
+ }
150
+ ```
151
+
152
+ ## Security Best Practices
153
+
154
+ 1. **Always enable RLS** on your Supabase tables.
155
+ 2. Use `public-insert` or stricter in production.
156
+ 3. Combine client-side rate limiting with server-side protection (e.g., Supabase Edge Functions or API Gateway) for robust defense.
157
+ 4. Sanitize inputs on the server/database side as well if possible (though Supabase handles SQL injection automatically).
158
+
159
+ ## Development
160
+
161
+ ### Building the Package
162
+
163
+ ```bash
164
+ npm run build
165
+ ```
166
+
167
+ This will compile TypeScript and bundle the library for distribution.
168
+
169
+ ### Publishing to npm
170
+
171
+ The package is configured for publishing to npm with the following setup:
172
+ - ESM and CommonJS builds for compatibility
173
+ - TypeScript declarations included
174
+ - CSS styles exported separately
175
+ - Migrations included for easy Supabase setup
176
+
177
+ ## License
178
+
179
+ MIT © Rens Blitz