@vocoweb/kernel 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) 2025 VocoWeb
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,252 @@
1
+ # @vocoweb/kernel
2
+
3
+ [![npm version](https://badge.fury.io/js/%40vocoweb%Fkernel.svg)](https://www.npmjs.com/package/@vocoweb/kernel)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Production-ready authentication, payments, and compliance kernel for B2B SaaS applications.
7
+
8
+ ## Overview
9
+
10
+ `@vocoweb/kernel` is a proprietary governance kernel that automates the hardest parts of EU software compliance:
11
+
12
+ - **Authentication** - Secure Supabase auth wrapper with pre-built components
13
+ - **Payments & VAT** - Stripe integration with EU VAT validation (VIES)
14
+ - **Legal Compliance** - GDPR-compliant legal components and data export
15
+ - **GDPR Deletion** - Cascading deletion engine with external API cleanup
16
+ - **Accessibility** - WCAG 2.1 AA compliant components (EAA 2025 ready)
17
+ - **Data Residency** - Egress blocking for EU data compliance
18
+ - **Audit Logging** - Enterprise-grade shadow recording
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @vocoweb/kernel
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### Server-Side (API Routes)
29
+
30
+ ```typescript
31
+ import { auth, billing } from '@vocoweb/kernel';
32
+
33
+ // Protect API routes
34
+ export async function GET(request: Request) {
35
+ const user = await auth.requireUser(request);
36
+ return Response.json({ user });
37
+ }
38
+
39
+ // Create Stripe checkout with VAT validation
40
+ export async function POST(request: Request) {
41
+ const { priceId, vatNumber } = await request.json();
42
+ const user = await auth.requireUser(request);
43
+
44
+ const session = await billing.createCheckoutSession({
45
+ priceId,
46
+ userId: user.id,
47
+ vatNumber, // Optional: EU VAT number for reverse charge
48
+ successUrl: '/dashboard?checkout=success',
49
+ cancelUrl: '/pricing?checkout=cancelled',
50
+ });
51
+
52
+ return Response.json({ url: session.url });
53
+ }
54
+ ```
55
+
56
+ ### Client-Side (React Components)
57
+
58
+ ```tsx
59
+ import { VocoAuth, CookieConsent } from '@vocoweb/kernel/react';
60
+
61
+ export default function Layout({ children }: { children: React.ReactNode }) {
62
+ return (
63
+ <html>
64
+ <body>
65
+ <CookieConsent />
66
+ {children}
67
+ </body>
68
+ </html>
69
+ );
70
+ }
71
+
72
+ // Login page
73
+ export default function LoginPage() {
74
+ return <VocoAuth redirectUrl="/dashboard" />;
75
+ }
76
+ ```
77
+
78
+ ## Modules
79
+
80
+ ### Module A: Vault (Authentication)
81
+
82
+ Secure Supabase authentication with pre-built components.
83
+
84
+ ```typescript
85
+ import { auth } from '@vocoweb/kernel';
86
+
87
+ // Client-side
88
+ await auth.loginWithGoogle();
89
+ await auth.logout();
90
+
91
+ // Server-side
92
+ const user = await auth.requireUser(request);
93
+ const token = await auth.verifyToken(request);
94
+ ```
95
+
96
+ ### Module B: Register (Payments & Billing)
97
+
98
+ Stripe integration with EU VAT validation.
99
+
100
+ ```typescript
101
+ import { billing } from '@vocoweb/kernel';
102
+
103
+ // Create checkout with VAT validation
104
+ const session = await billing.createCheckoutSession({
105
+ priceId: 'price_...',
106
+ userId: user.id,
107
+ vatNumber: 'DE123456789', // Validates against VIES
108
+ });
109
+
110
+ // Validate VAT number
111
+ const isValid = await billing.validateVat('DE123456789');
112
+
113
+ // Get user invoices
114
+ const invoices = await billing.getInvoices(userId);
115
+ ```
116
+
117
+ ### Module C: Shield (Legal Compliance)
118
+
119
+ GDPR-compliant legal components.
120
+
121
+ ```tsx
122
+ import { PrivacyPolicy, TermsOfService } from '@vocoweb/kernel/react';
123
+
124
+ <PrivacyPolicy
125
+ companyName="Acme Inc"
126
+ email="privacy@acme.com"
127
+ updatedAt="2025-01-01"
128
+ />
129
+
130
+ <TermsOfService
131
+ companyName="Acme Inc"
132
+ email="legal@acme.com"
133
+ jurisdiction="Delaware, USA"
134
+ />
135
+ ```
136
+
137
+ ### Module 1: Erasure Engine (GDPR)
138
+
139
+ One-click user deletion with cascading cleanup.
140
+
141
+ ```typescript
142
+ import { privacy } from '@vocoweb/kernel';
143
+
144
+ // GDPR Article 17 - Right to be Forgotten
145
+ const result = await privacy.obliterate(userId);
146
+ // Deletes from: users, projects, websites, logs
147
+ // Anonymizes: invoices
148
+ // Calls: SendGrid, OpenAI APIs
149
+
150
+ // Export user data (GDPR request)
151
+ const data = await privacy.exportUserData(userId);
152
+ ```
153
+
154
+ ### Module 2: EAA Enforcer (Accessibility)
155
+
156
+ WCAG 2.1 AA compliant components.
157
+
158
+ ```tsx
159
+ import { VocoButton, VocoInput, VocoForm } from '@vocoweb/kernel/react';
160
+
161
+ <VocoButton aria-label="Submit form">Submit</VocoButton>
162
+ // Automatically validates ARIA labels and contrast
163
+
164
+ <VocoInput
165
+ label="Email"
166
+ type="email"
167
+ required
168
+ // Automatic label association and error handling
169
+ />
170
+ ```
171
+
172
+ ### Module 3: Sovereignty Shield (Data Residency)
173
+
174
+ Block data from leaving the EU region.
175
+
176
+ ```typescript
177
+ import { residency } from '@vocoweb/kernel';
178
+
179
+ // middleware.ts
180
+ export { middleware } from '@vocoweb/kernel/residency';
181
+
182
+ // All outgoing requests are validated
183
+ // Non-EU destinations are blocked
184
+ ```
185
+
186
+ ### Module 4: Audit Log (Enterprise)
187
+
188
+ Shadow recording for all database mutations.
189
+
190
+ ```tsx
191
+ import { VocoAuditLog } from '@vocoweb/kernel/react';
192
+
193
+ <VocoAuditLog
194
+ userId={user.id}
195
+ filters={{ action: 'UPDATE', table: 'projects' }}
196
+ />
197
+ ```
198
+
199
+ ## Environment Variables
200
+
201
+ ```bash
202
+ # Supabase (Required)
203
+ NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
204
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
205
+ SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
206
+
207
+ # Stripe (Required)
208
+ STRIPE_SECRET_KEY=sk_...
209
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_...
210
+ STRIPE_WEBHOOK_SECRET=whsec_...
211
+
212
+ # App Configuration
213
+ NEXT_PUBLIC_APP_URL=https://yourapp.com
214
+ NEXT_PUBLIC_APP_NAME=Your App
215
+ SUPPORT_EMAIL=support@yourapp.com
216
+ LEGAL_EMAIL=legal@yourapp.com
217
+
218
+ # Data Residency (Optional)
219
+ VOCO_DATA_RESIDENCY_ENABLED=true
220
+ VOCO_DATA_REGION=eu
221
+ VOCO_RESIDENCY_STRICT_MODE=true
222
+
223
+ # Accessibility (Optional)
224
+ VOCO_ENFORCE_CONTRAST=true
225
+ VOCO_ENFORCE_ARIA=true
226
+ VOCO_CONTRAST_RATIO=4.5
227
+ ```
228
+
229
+ ## Philosophy
230
+
231
+ The VocoWeb Kernel is built on the principle that **AI should not write auth, payments, or compliance code**.
232
+
233
+ These domains require:
234
+ - Deep security knowledge
235
+ - Legal compliance expertise
236
+ - Production hardening
237
+ - Continuous updates for regulations
238
+
239
+ By providing pre-built, tested, and compliant modules, we enable AI to focus on business logic while ensuring the critical infrastructure is secure and compliant.
240
+
241
+ ## License
242
+
243
+ MIT © VocoWeb
244
+
245
+ ## Support
246
+
247
+ - Email: legal@vocoweb.in
248
+ - Documentation: [GitHub Wiki](https://github.com/vocoweb/vocoweb-kernel/wiki)
249
+
250
+ ---
251
+
252
+ **Built with care by [VocoWeb](https://vocoweb.in)**