@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 +21 -0
- package/README.md +252 -0
- package/dist/index.d.mts +2670 -0
- package/dist/index.d.ts +2670 -0
- package/dist/index.js +5560 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5370 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react-CSDXc0m4.d.mts +446 -0
- package/dist/react-CSDXc0m4.d.ts +446 -0
- package/dist/react.d.mts +3 -0
- package/dist/react.d.ts +3 -0
- package/dist/react.js +1854 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +1845 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +89 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2670 @@
|
|
|
1
|
+
import { U as UserDataExport, C as ContrastResult, A as AriaValidationResult, K as KeyboardNavigationResult, a as ComplianceLevel, b as AccessibilityViolation, D as DataRegion, c as AuditRecorderConfig, d as AuditAction, e as AuditQueryFilters } from './react-CSDXc0m4.mjs';
|
|
2
|
+
export { f as AccessibilityAudit, g as AccessibilityProps, h as ApiError, i as ApiResponse, j as AuditExport, k as AuditLogEntry, l as AuditQueryResult, m as AuditRecord, n as AuthSession, B as ButtonProps, o as CookieConsent, p as CookieConsentChoice, q as CookieConsentProps, F as FormProps, I as InputProps, P as PaginatedResponse, r as PaginationParams, s as PrivacyPolicy, t as PrivacyPolicyProps, R as RequestDestination, T as TermsOfService, u as TermsOfServiceProps, v as TriggerConfig, w as UserId, V as VocoAuditLog, x as VocoAuditLogProps, y as VocoAuth, z as VocoButton, E as VocoForm, G as VocoInput } from './react-CSDXc0m4.mjs';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import * as _supabase_auth_js from '@supabase/auth-js';
|
|
6
|
+
import { Session, User, SupabaseClient } from '@supabase/supabase-js';
|
|
7
|
+
import * as Stripe from 'stripe';
|
|
8
|
+
import Stripe__default from 'stripe';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import 'react';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom error classes for @vocoweb/kernel
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Base VocoWeb error
|
|
17
|
+
*/
|
|
18
|
+
declare class VocoError extends Error {
|
|
19
|
+
code: string;
|
|
20
|
+
statusCode: number;
|
|
21
|
+
details?: Record<string, unknown> | undefined;
|
|
22
|
+
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown> | undefined);
|
|
23
|
+
toJSON(): {
|
|
24
|
+
name: string;
|
|
25
|
+
message: string;
|
|
26
|
+
code: string;
|
|
27
|
+
statusCode: number;
|
|
28
|
+
details: Record<string, unknown> | undefined;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Authentication errors
|
|
33
|
+
*/
|
|
34
|
+
declare class VocoAuthError extends VocoError {
|
|
35
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
36
|
+
static invalidCredentials(): VocoAuthError;
|
|
37
|
+
static sessionExpired(): VocoAuthError;
|
|
38
|
+
static unauthorized(message?: string): VocoAuthError;
|
|
39
|
+
static forbidden(message?: string): VocoAuthError;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Payment errors
|
|
43
|
+
*/
|
|
44
|
+
declare class VocoBillingError extends VocoError {
|
|
45
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
46
|
+
static invalidVatNumber(vatNumber: string): VocoBillingError;
|
|
47
|
+
static vatValidationFailed(vatNumber: string, reason: string): VocoBillingError;
|
|
48
|
+
static paymentRequired(message?: string): VocoBillingError;
|
|
49
|
+
static checkoutFailed(reason: string): VocoBillingError;
|
|
50
|
+
static subscriptionNotFound(): VocoBillingError;
|
|
51
|
+
static invoiceNotFound(invoiceId: string): VocoBillingError;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Configuration errors
|
|
55
|
+
*/
|
|
56
|
+
declare class VocoConfigError extends VocoError {
|
|
57
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
58
|
+
static missingEnvVar(varName: string): VocoConfigError;
|
|
59
|
+
static invalidConfig(message: string): VocoConfigError;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Compliance errors
|
|
63
|
+
*/
|
|
64
|
+
declare class VocoComplianceError extends VocoError {
|
|
65
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
66
|
+
static deletionFailed(userId: string, reason: string): VocoComplianceError;
|
|
67
|
+
static deletionInProgress(userId: string): VocoComplianceError;
|
|
68
|
+
static invalidEntityType(entityType: string): VocoComplianceError;
|
|
69
|
+
static anonymizationFailed(table: string, reason: string): VocoComplianceError;
|
|
70
|
+
static externalApiFailed(service: string, reason: string): VocoComplianceError;
|
|
71
|
+
static dataExportFailed(userId: string, reason: string): VocoComplianceError;
|
|
72
|
+
static egressBlocked(destination: string, reason: string): VocoComplianceError;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Accessibility errors
|
|
76
|
+
*/
|
|
77
|
+
declare class VocoAccessibilityError extends VocoError {
|
|
78
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
79
|
+
static missingAriaLabel(component: string, prop: string): VocoAccessibilityError;
|
|
80
|
+
static contrastRatioFailed(fg: string, bg: string, ratio: number): VocoAccessibilityError;
|
|
81
|
+
static keyboardNavigationMissing(component: string): VocoAccessibilityError;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validation errors using Zod
|
|
85
|
+
*/
|
|
86
|
+
declare class VocoValidationError extends VocoError {
|
|
87
|
+
field: string;
|
|
88
|
+
constructor(message: string, field: string, details?: Record<string, unknown>);
|
|
89
|
+
static fromZod(error: {
|
|
90
|
+
fieldErrors: Record<string, string[]>;
|
|
91
|
+
}): VocoValidationError;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Network errors
|
|
95
|
+
*/
|
|
96
|
+
declare class VocoNetworkError extends VocoError {
|
|
97
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
98
|
+
static fetchFailed(url: string, status?: number): VocoNetworkError;
|
|
99
|
+
static timeout(operation: string, timeoutMs: number): VocoNetworkError;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Type guard for VocoWeb errors
|
|
103
|
+
*/
|
|
104
|
+
declare function isVocoError(error: unknown): error is VocoError;
|
|
105
|
+
/**
|
|
106
|
+
* Get a user-friendly error message
|
|
107
|
+
*/
|
|
108
|
+
declare function getErrorMessage(error: unknown): string;
|
|
109
|
+
/**
|
|
110
|
+
* Format error for API responses
|
|
111
|
+
*/
|
|
112
|
+
declare function formatApiError(error: unknown): {
|
|
113
|
+
name: string;
|
|
114
|
+
message: string;
|
|
115
|
+
code: string;
|
|
116
|
+
statusCode: number;
|
|
117
|
+
details: Record<string, unknown> | undefined;
|
|
118
|
+
} | {
|
|
119
|
+
name: string;
|
|
120
|
+
message: string;
|
|
121
|
+
code: string;
|
|
122
|
+
statusCode: number;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Shared utility functions for @vocoweb/kernel
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Merge Tailwind CSS classes with proper precedence
|
|
131
|
+
*/
|
|
132
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
133
|
+
/**
|
|
134
|
+
* Format currency for display
|
|
135
|
+
*/
|
|
136
|
+
declare function formatCurrency(amount: number, currency?: string, locale?: string): string;
|
|
137
|
+
/**
|
|
138
|
+
* Format date for display
|
|
139
|
+
*/
|
|
140
|
+
declare function formatDate(date: Date | string, locale?: string, options?: Intl.DateTimeFormatOptions): string;
|
|
141
|
+
/**
|
|
142
|
+
* Format relative time (e.g., "2 hours ago")
|
|
143
|
+
*/
|
|
144
|
+
declare function formatRelativeTime(date: Date | string, locale?: string): string;
|
|
145
|
+
/**
|
|
146
|
+
* Generate a random ID
|
|
147
|
+
*/
|
|
148
|
+
declare function generateId(prefix?: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Deep clone an object
|
|
151
|
+
*/
|
|
152
|
+
declare function deepClone<T>(obj: T): T;
|
|
153
|
+
/**
|
|
154
|
+
* Safe JSON parse with fallback
|
|
155
|
+
*/
|
|
156
|
+
declare function safeJsonParse<T>(str: string, fallback: T): T;
|
|
157
|
+
/**
|
|
158
|
+
* Debounce a function
|
|
159
|
+
*/
|
|
160
|
+
declare function debounce<T extends (...args: unknown[]) => unknown>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Throttle a function
|
|
163
|
+
*/
|
|
164
|
+
declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limit: number): (...args: Parameters<T>) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Sleep for a specified duration
|
|
167
|
+
*/
|
|
168
|
+
declare function sleep(ms: number): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Retry a function with exponential backoff
|
|
171
|
+
*/
|
|
172
|
+
declare function retry<T>(fn: () => Promise<T>, options?: {
|
|
173
|
+
maxAttempts?: number;
|
|
174
|
+
initialDelay?: number;
|
|
175
|
+
maxDelay?: number;
|
|
176
|
+
backoffMultiplier?: number;
|
|
177
|
+
retryIf?: (error: unknown) => boolean;
|
|
178
|
+
}): Promise<T>;
|
|
179
|
+
/**
|
|
180
|
+
* Check if running in browser
|
|
181
|
+
*/
|
|
182
|
+
declare const isBrowser: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Check if running in server environment
|
|
185
|
+
*/
|
|
186
|
+
declare const isServer: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Get environment variable (server-side)
|
|
189
|
+
*/
|
|
190
|
+
declare function getEnv(key: string, fallback?: string): string;
|
|
191
|
+
/**
|
|
192
|
+
* Validate email format
|
|
193
|
+
*/
|
|
194
|
+
declare function isValidEmail(email: string): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Truncate text with ellipsis
|
|
197
|
+
*/
|
|
198
|
+
declare function truncate(str: string, maxLength: number): string;
|
|
199
|
+
/**
|
|
200
|
+
* Capitalize first letter
|
|
201
|
+
*/
|
|
202
|
+
declare function capitalize(str: string): string;
|
|
203
|
+
/**
|
|
204
|
+
* Convert camelCase to kebab-case
|
|
205
|
+
*/
|
|
206
|
+
declare function camelToKebab(str: string): string;
|
|
207
|
+
/**
|
|
208
|
+
* Convert kebab-case to camelCase
|
|
209
|
+
*/
|
|
210
|
+
declare function kebabToCamel(str: string): string;
|
|
211
|
+
/**
|
|
212
|
+
* Get initials from name
|
|
213
|
+
*/
|
|
214
|
+
declare function getInitials(name: string, maxLength?: number): string;
|
|
215
|
+
/**
|
|
216
|
+
* Pluralize a word
|
|
217
|
+
*/
|
|
218
|
+
declare function pluralize(count: number, singular: string, plural?: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* Format a list of items
|
|
221
|
+
*/
|
|
222
|
+
declare function formatList(items: string[], locale?: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* Clamp a number between min and max
|
|
225
|
+
*/
|
|
226
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
227
|
+
/**
|
|
228
|
+
* Round to a specified number of decimal places
|
|
229
|
+
*/
|
|
230
|
+
declare function roundTo(value: number, decimals: number): number;
|
|
231
|
+
/**
|
|
232
|
+
* Check if a value is defined (not null or undefined)
|
|
233
|
+
*/
|
|
234
|
+
declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
235
|
+
/**
|
|
236
|
+
* Filter out null and undefined values from an array
|
|
237
|
+
*/
|
|
238
|
+
declare function filterDefined<T>(array: Array<T | null | undefined>): T[];
|
|
239
|
+
/**
|
|
240
|
+
* Create a promise that resolves after a timeout or rejects if the timeout is exceeded
|
|
241
|
+
*/
|
|
242
|
+
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutError?: Error): Promise<T>;
|
|
243
|
+
/**
|
|
244
|
+
* Batch array items into chunks of specified size
|
|
245
|
+
*/
|
|
246
|
+
declare function chunk<T>(array: T[], size: number): T[][];
|
|
247
|
+
/**
|
|
248
|
+
* Group array items by a key function
|
|
249
|
+
*/
|
|
250
|
+
declare function groupBy<T, K extends string | number>(array: T[], keyFn: (item: T) => K): Record<K, T[]>;
|
|
251
|
+
/**
|
|
252
|
+
* Create a promise that can be resolved externally
|
|
253
|
+
*/
|
|
254
|
+
declare function createDeferred<T>(): {
|
|
255
|
+
promise: Promise<T>;
|
|
256
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
257
|
+
reject: (reason?: unknown) => void;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Environment configuration for @vocoweb/kernel
|
|
262
|
+
* Validates all required environment variables at startup
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Supabase configuration schema
|
|
267
|
+
*/
|
|
268
|
+
declare const SupabaseConfigSchema: z.ZodObject<{
|
|
269
|
+
url: z.ZodString;
|
|
270
|
+
anonKey: z.ZodString;
|
|
271
|
+
serviceRoleKey: z.ZodString;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
url: string;
|
|
274
|
+
anonKey: string;
|
|
275
|
+
serviceRoleKey: string;
|
|
276
|
+
}, {
|
|
277
|
+
url: string;
|
|
278
|
+
anonKey: string;
|
|
279
|
+
serviceRoleKey: string;
|
|
280
|
+
}>;
|
|
281
|
+
/**
|
|
282
|
+
* Stripe configuration schema
|
|
283
|
+
*/
|
|
284
|
+
declare const StripeConfigSchema: z.ZodObject<{
|
|
285
|
+
secretKey: z.ZodString;
|
|
286
|
+
publishableKey: z.ZodString;
|
|
287
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
secretKey: string;
|
|
290
|
+
publishableKey: string;
|
|
291
|
+
webhookSecret?: string | undefined;
|
|
292
|
+
}, {
|
|
293
|
+
secretKey: string;
|
|
294
|
+
publishableKey: string;
|
|
295
|
+
webhookSecret?: string | undefined;
|
|
296
|
+
}>;
|
|
297
|
+
/**
|
|
298
|
+
* App configuration schema
|
|
299
|
+
*/
|
|
300
|
+
declare const AppConfigSchema: z.ZodObject<{
|
|
301
|
+
url: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
302
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
303
|
+
supportEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
304
|
+
legalEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
305
|
+
}, "strip", z.ZodTypeAny, {
|
|
306
|
+
url: string;
|
|
307
|
+
name: string;
|
|
308
|
+
supportEmail: string;
|
|
309
|
+
legalEmail: string;
|
|
310
|
+
}, {
|
|
311
|
+
url?: string | undefined;
|
|
312
|
+
name?: string | undefined;
|
|
313
|
+
supportEmail?: string | undefined;
|
|
314
|
+
legalEmail?: string | undefined;
|
|
315
|
+
}>;
|
|
316
|
+
/**
|
|
317
|
+
* Data residency configuration schema
|
|
318
|
+
*/
|
|
319
|
+
declare const ResidencyConfigSchema: z.ZodObject<{
|
|
320
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
321
|
+
region: z.ZodDefault<z.ZodOptional<z.ZodEnum<["eu", "us", "apac", "global"]>>>;
|
|
322
|
+
strictMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
323
|
+
}, "strip", z.ZodTypeAny, {
|
|
324
|
+
enabled: boolean;
|
|
325
|
+
region: "eu" | "us" | "apac" | "global";
|
|
326
|
+
strictMode: boolean;
|
|
327
|
+
}, {
|
|
328
|
+
enabled?: boolean | undefined;
|
|
329
|
+
region?: "eu" | "us" | "apac" | "global" | undefined;
|
|
330
|
+
strictMode?: boolean | undefined;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* Accessibility configuration schema
|
|
334
|
+
*/
|
|
335
|
+
declare const AccessibilityConfigSchema: z.ZodObject<{
|
|
336
|
+
enforceContrast: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
337
|
+
enforceAriaLabels: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
338
|
+
enforceKeyboardNav: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
339
|
+
contrastRatio: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
340
|
+
}, "strip", z.ZodTypeAny, {
|
|
341
|
+
enforceContrast: boolean;
|
|
342
|
+
enforceAriaLabels: boolean;
|
|
343
|
+
enforceKeyboardNav: boolean;
|
|
344
|
+
contrastRatio: number;
|
|
345
|
+
}, {
|
|
346
|
+
enforceContrast?: boolean | undefined;
|
|
347
|
+
enforceAriaLabels?: boolean | undefined;
|
|
348
|
+
enforceKeyboardNav?: boolean | undefined;
|
|
349
|
+
contrastRatio?: number | undefined;
|
|
350
|
+
}>;
|
|
351
|
+
/**
|
|
352
|
+
* Complete kernel configuration schema
|
|
353
|
+
*/
|
|
354
|
+
declare const KernelConfigSchema: z.ZodObject<{
|
|
355
|
+
supabase: z.ZodObject<{
|
|
356
|
+
url: z.ZodString;
|
|
357
|
+
anonKey: z.ZodString;
|
|
358
|
+
serviceRoleKey: z.ZodString;
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
url: string;
|
|
361
|
+
anonKey: string;
|
|
362
|
+
serviceRoleKey: string;
|
|
363
|
+
}, {
|
|
364
|
+
url: string;
|
|
365
|
+
anonKey: string;
|
|
366
|
+
serviceRoleKey: string;
|
|
367
|
+
}>;
|
|
368
|
+
stripe: z.ZodObject<{
|
|
369
|
+
secretKey: z.ZodString;
|
|
370
|
+
publishableKey: z.ZodString;
|
|
371
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
372
|
+
}, "strip", z.ZodTypeAny, {
|
|
373
|
+
secretKey: string;
|
|
374
|
+
publishableKey: string;
|
|
375
|
+
webhookSecret?: string | undefined;
|
|
376
|
+
}, {
|
|
377
|
+
secretKey: string;
|
|
378
|
+
publishableKey: string;
|
|
379
|
+
webhookSecret?: string | undefined;
|
|
380
|
+
}>;
|
|
381
|
+
app: z.ZodObject<{
|
|
382
|
+
url: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
383
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
384
|
+
supportEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
385
|
+
legalEmail: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
386
|
+
}, "strip", z.ZodTypeAny, {
|
|
387
|
+
url: string;
|
|
388
|
+
name: string;
|
|
389
|
+
supportEmail: string;
|
|
390
|
+
legalEmail: string;
|
|
391
|
+
}, {
|
|
392
|
+
url?: string | undefined;
|
|
393
|
+
name?: string | undefined;
|
|
394
|
+
supportEmail?: string | undefined;
|
|
395
|
+
legalEmail?: string | undefined;
|
|
396
|
+
}>;
|
|
397
|
+
residency: z.ZodObject<{
|
|
398
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
399
|
+
region: z.ZodDefault<z.ZodOptional<z.ZodEnum<["eu", "us", "apac", "global"]>>>;
|
|
400
|
+
strictMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
enabled: boolean;
|
|
403
|
+
region: "eu" | "us" | "apac" | "global";
|
|
404
|
+
strictMode: boolean;
|
|
405
|
+
}, {
|
|
406
|
+
enabled?: boolean | undefined;
|
|
407
|
+
region?: "eu" | "us" | "apac" | "global" | undefined;
|
|
408
|
+
strictMode?: boolean | undefined;
|
|
409
|
+
}>;
|
|
410
|
+
accessibility: z.ZodObject<{
|
|
411
|
+
enforceContrast: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
412
|
+
enforceAriaLabels: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
413
|
+
enforceKeyboardNav: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
414
|
+
contrastRatio: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
415
|
+
}, "strip", z.ZodTypeAny, {
|
|
416
|
+
enforceContrast: boolean;
|
|
417
|
+
enforceAriaLabels: boolean;
|
|
418
|
+
enforceKeyboardNav: boolean;
|
|
419
|
+
contrastRatio: number;
|
|
420
|
+
}, {
|
|
421
|
+
enforceContrast?: boolean | undefined;
|
|
422
|
+
enforceAriaLabels?: boolean | undefined;
|
|
423
|
+
enforceKeyboardNav?: boolean | undefined;
|
|
424
|
+
contrastRatio?: number | undefined;
|
|
425
|
+
}>;
|
|
426
|
+
}, "strip", z.ZodTypeAny, {
|
|
427
|
+
supabase: {
|
|
428
|
+
url: string;
|
|
429
|
+
anonKey: string;
|
|
430
|
+
serviceRoleKey: string;
|
|
431
|
+
};
|
|
432
|
+
stripe: {
|
|
433
|
+
secretKey: string;
|
|
434
|
+
publishableKey: string;
|
|
435
|
+
webhookSecret?: string | undefined;
|
|
436
|
+
};
|
|
437
|
+
app: {
|
|
438
|
+
url: string;
|
|
439
|
+
name: string;
|
|
440
|
+
supportEmail: string;
|
|
441
|
+
legalEmail: string;
|
|
442
|
+
};
|
|
443
|
+
residency: {
|
|
444
|
+
enabled: boolean;
|
|
445
|
+
region: "eu" | "us" | "apac" | "global";
|
|
446
|
+
strictMode: boolean;
|
|
447
|
+
};
|
|
448
|
+
accessibility: {
|
|
449
|
+
enforceContrast: boolean;
|
|
450
|
+
enforceAriaLabels: boolean;
|
|
451
|
+
enforceKeyboardNav: boolean;
|
|
452
|
+
contrastRatio: number;
|
|
453
|
+
};
|
|
454
|
+
}, {
|
|
455
|
+
supabase: {
|
|
456
|
+
url: string;
|
|
457
|
+
anonKey: string;
|
|
458
|
+
serviceRoleKey: string;
|
|
459
|
+
};
|
|
460
|
+
stripe: {
|
|
461
|
+
secretKey: string;
|
|
462
|
+
publishableKey: string;
|
|
463
|
+
webhookSecret?: string | undefined;
|
|
464
|
+
};
|
|
465
|
+
app: {
|
|
466
|
+
url?: string | undefined;
|
|
467
|
+
name?: string | undefined;
|
|
468
|
+
supportEmail?: string | undefined;
|
|
469
|
+
legalEmail?: string | undefined;
|
|
470
|
+
};
|
|
471
|
+
residency: {
|
|
472
|
+
enabled?: boolean | undefined;
|
|
473
|
+
region?: "eu" | "us" | "apac" | "global" | undefined;
|
|
474
|
+
strictMode?: boolean | undefined;
|
|
475
|
+
};
|
|
476
|
+
accessibility: {
|
|
477
|
+
enforceContrast?: boolean | undefined;
|
|
478
|
+
enforceAriaLabels?: boolean | undefined;
|
|
479
|
+
enforceKeyboardNav?: boolean | undefined;
|
|
480
|
+
contrastRatio?: number | undefined;
|
|
481
|
+
};
|
|
482
|
+
}>;
|
|
483
|
+
/**
|
|
484
|
+
* Parsed configuration types
|
|
485
|
+
*/
|
|
486
|
+
type SupabaseConfig = z.infer<typeof SupabaseConfigSchema>;
|
|
487
|
+
type StripeConfig = z.infer<typeof StripeConfigSchema>;
|
|
488
|
+
type AppConfig = z.infer<typeof AppConfigSchema>;
|
|
489
|
+
type ResidencyConfig = z.infer<typeof ResidencyConfigSchema>;
|
|
490
|
+
type AccessibilityConfig = z.infer<typeof AccessibilityConfigSchema>;
|
|
491
|
+
type KernelConfig = z.infer<typeof KernelConfigSchema>;
|
|
492
|
+
/**
|
|
493
|
+
* Validate and parse kernel configuration
|
|
494
|
+
*/
|
|
495
|
+
declare function validateConfig(config: Record<string, unknown>): KernelConfig;
|
|
496
|
+
/**
|
|
497
|
+
* Load configuration from environment variables
|
|
498
|
+
*/
|
|
499
|
+
declare function loadConfigFromEnv(): KernelConfig;
|
|
500
|
+
/**
|
|
501
|
+
* Get the kernel configuration (cached)
|
|
502
|
+
*/
|
|
503
|
+
declare function getConfig(): KernelConfig;
|
|
504
|
+
/**
|
|
505
|
+
* Reset cached configuration (useful for testing)
|
|
506
|
+
*/
|
|
507
|
+
declare function resetConfig(): void;
|
|
508
|
+
/**
|
|
509
|
+
* Set configuration manually (useful for testing or custom initialization)
|
|
510
|
+
*/
|
|
511
|
+
declare function setConfig(config: KernelConfig): void;
|
|
512
|
+
/**
|
|
513
|
+
* Get Supabase configuration
|
|
514
|
+
*/
|
|
515
|
+
declare function getSupabaseConfig(): SupabaseConfig;
|
|
516
|
+
/**
|
|
517
|
+
* Get Stripe configuration
|
|
518
|
+
*/
|
|
519
|
+
declare function getStripeConfig(): StripeConfig;
|
|
520
|
+
/**
|
|
521
|
+
* Get App configuration
|
|
522
|
+
*/
|
|
523
|
+
declare function getAppConfig(): AppConfig;
|
|
524
|
+
/**
|
|
525
|
+
* Get Data Residency configuration
|
|
526
|
+
*/
|
|
527
|
+
declare function getResidencyConfig(): ResidencyConfig;
|
|
528
|
+
/**
|
|
529
|
+
* Get Accessibility configuration
|
|
530
|
+
*/
|
|
531
|
+
declare function getAccessibilityConfig(): AccessibilityConfig;
|
|
532
|
+
/**
|
|
533
|
+
* Check if all required environment variables are set
|
|
534
|
+
*/
|
|
535
|
+
declare function checkRequiredEnvVars(): boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Environment-aware check: runs validation only in development or when explicitly enabled
|
|
538
|
+
*/
|
|
539
|
+
declare function validateEnvironment(skipProduction?: boolean): boolean;
|
|
540
|
+
/**
|
|
541
|
+
* Export a singleton instance for convenience
|
|
542
|
+
*/
|
|
543
|
+
declare const config: {
|
|
544
|
+
get: typeof getConfig;
|
|
545
|
+
supabase: typeof getSupabaseConfig;
|
|
546
|
+
stripe: typeof getStripeConfig;
|
|
547
|
+
app: typeof getAppConfig;
|
|
548
|
+
residency: typeof getResidencyConfig;
|
|
549
|
+
accessibility: typeof getAccessibilityConfig;
|
|
550
|
+
validate: typeof validateEnvironment;
|
|
551
|
+
check: typeof checkRequiredEnvVars;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Type definitions for the Auth module
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* OAuth provider types
|
|
560
|
+
*/
|
|
561
|
+
type OAuthProvider = 'google' | 'github' | 'azure' | 'bitbucket';
|
|
562
|
+
/**
|
|
563
|
+
* OAuth options
|
|
564
|
+
*/
|
|
565
|
+
interface OAuthOptions {
|
|
566
|
+
provider?: OAuthProvider;
|
|
567
|
+
redirectTo?: string;
|
|
568
|
+
scopes?: string;
|
|
569
|
+
queryParams?: Record<string, string>;
|
|
570
|
+
skipBrowserRedirect?: boolean;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Sign in with email/password options
|
|
574
|
+
*/
|
|
575
|
+
interface SignInWithPasswordOptions {
|
|
576
|
+
email: string;
|
|
577
|
+
password: string;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Sign up options
|
|
581
|
+
*/
|
|
582
|
+
interface SignUpOptions {
|
|
583
|
+
email: string;
|
|
584
|
+
password: string;
|
|
585
|
+
metadata?: Record<string, unknown>;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Reset password options
|
|
589
|
+
*/
|
|
590
|
+
interface ResetPasswordOptions {
|
|
591
|
+
email: string;
|
|
592
|
+
redirectTo?: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Update user options
|
|
596
|
+
*/
|
|
597
|
+
interface UpdateUserOptions {
|
|
598
|
+
email?: string;
|
|
599
|
+
password?: string;
|
|
600
|
+
metadata?: Record<string, unknown>;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Auth state change callback
|
|
604
|
+
*/
|
|
605
|
+
type AuthStateChangeCallback = (event: 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED', session: Session | null) => void;
|
|
606
|
+
/**
|
|
607
|
+
* Subscription handle for auth state changes
|
|
608
|
+
*/
|
|
609
|
+
interface AuthSubscription {
|
|
610
|
+
unsubscribe: () => void;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* User role types
|
|
614
|
+
*/
|
|
615
|
+
type UserRole = 'admin' | 'user' | 'guest' | 'premium';
|
|
616
|
+
/**
|
|
617
|
+
* Extended user with role
|
|
618
|
+
*/
|
|
619
|
+
interface UserWithRole extends User {
|
|
620
|
+
role?: UserRole;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Server-side request types
|
|
624
|
+
*/
|
|
625
|
+
interface AuthRequest {
|
|
626
|
+
headers: {
|
|
627
|
+
get(name: string): string | null;
|
|
628
|
+
};
|
|
629
|
+
cookies?: {
|
|
630
|
+
get(name: string): {
|
|
631
|
+
value: string;
|
|
632
|
+
} | undefined;
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Verified user from server-side auth
|
|
637
|
+
*/
|
|
638
|
+
interface VerifiedUser {
|
|
639
|
+
id: string;
|
|
640
|
+
email: string;
|
|
641
|
+
role?: UserRole;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Supabase client configuration
|
|
646
|
+
* Singleton pattern to prevent multiple instances
|
|
647
|
+
*/
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Client type enum
|
|
651
|
+
*/
|
|
652
|
+
declare enum ClientType {
|
|
653
|
+
Browser = "browser",
|
|
654
|
+
Server = "server",
|
|
655
|
+
ServiceRole = "service_role"
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Get the browser Supabase client (uses anon key)
|
|
659
|
+
* Only works in browser environment
|
|
660
|
+
*/
|
|
661
|
+
declare function getBrowserClient(): SupabaseClient;
|
|
662
|
+
/**
|
|
663
|
+
* Get the server Supabase client (uses anon key)
|
|
664
|
+
* For server-side operations with user context
|
|
665
|
+
*/
|
|
666
|
+
declare function getServerClient(): SupabaseClient;
|
|
667
|
+
/**
|
|
668
|
+
* Get the service role client (uses service role key)
|
|
669
|
+
* For admin operations - use with caution!
|
|
670
|
+
* Should only be used server-side for privileged operations.
|
|
671
|
+
*/
|
|
672
|
+
declare function getServiceRoleClient(): SupabaseClient;
|
|
673
|
+
/**
|
|
674
|
+
* Get a Supabase client based on type
|
|
675
|
+
*/
|
|
676
|
+
declare function getClient(type?: ClientType): SupabaseClient;
|
|
677
|
+
/**
|
|
678
|
+
* Reset all clients (useful for testing)
|
|
679
|
+
*/
|
|
680
|
+
declare function resetClients(): void;
|
|
681
|
+
/**
|
|
682
|
+
* Check if a specific client type is initialized
|
|
683
|
+
*/
|
|
684
|
+
declare function isClientInitialized(type: ClientType): boolean;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Client-side authentication functions
|
|
688
|
+
* These functions are meant to be used in the browser
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Sign in with OAuth provider (e.g., Google, GitHub)
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* await auth.loginWithGoogle({ redirectTo: '/dashboard' });
|
|
696
|
+
*/
|
|
697
|
+
declare function loginWithOAuth(options?: OAuthOptions): Promise<void>;
|
|
698
|
+
/**
|
|
699
|
+
* Sign in with Google OAuth (convenience function)
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* await auth.loginWithGoogle();
|
|
703
|
+
*/
|
|
704
|
+
declare function loginWithGoogle(redirectTo?: string): Promise<void>;
|
|
705
|
+
/**
|
|
706
|
+
* Sign in with GitHub OAuth
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* await auth.loginWithGitHub();
|
|
710
|
+
*/
|
|
711
|
+
declare function loginWithGitHub(redirectTo?: string): Promise<void>;
|
|
712
|
+
/**
|
|
713
|
+
* Sign in with email and password
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* await auth.signInWithPassword({ email: 'user@example.com', password: 'password123' });
|
|
717
|
+
*/
|
|
718
|
+
declare function signInWithPassword(options: SignInWithPasswordOptions): Promise<{
|
|
719
|
+
data: {
|
|
720
|
+
session: Session | null;
|
|
721
|
+
user: User | null;
|
|
722
|
+
};
|
|
723
|
+
}>;
|
|
724
|
+
/**
|
|
725
|
+
* Sign up a new user
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* await auth.signUp({
|
|
729
|
+
* email: 'user@example.com',
|
|
730
|
+
* password: 'password123',
|
|
731
|
+
* metadata: { name: 'John Doe' }
|
|
732
|
+
* });
|
|
733
|
+
*/
|
|
734
|
+
declare function signUp(options: SignUpOptions): Promise<{
|
|
735
|
+
data: {
|
|
736
|
+
session: Session | null;
|
|
737
|
+
user: User | null;
|
|
738
|
+
};
|
|
739
|
+
}>;
|
|
740
|
+
/**
|
|
741
|
+
* Sign out the current user
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* await auth.logout();
|
|
745
|
+
*/
|
|
746
|
+
declare function logout(): Promise<void>;
|
|
747
|
+
/**
|
|
748
|
+
* Get the current session
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* const session = await auth.getSession();
|
|
752
|
+
* if (session) {
|
|
753
|
+
* console.log('User is logged in:', session.user);
|
|
754
|
+
* }
|
|
755
|
+
*/
|
|
756
|
+
declare function getSession(): Promise<Session | null>;
|
|
757
|
+
/**
|
|
758
|
+
* Get the current user
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* const user = await auth.getUser();
|
|
762
|
+
* if (user) {
|
|
763
|
+
* console.log('User email:', user.email);
|
|
764
|
+
* }
|
|
765
|
+
*/
|
|
766
|
+
declare function getUser(): Promise<User | null>;
|
|
767
|
+
/**
|
|
768
|
+
* Refresh the current session
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* await auth.refreshSession();
|
|
772
|
+
*/
|
|
773
|
+
declare function refreshSession(): Promise<Session | null>;
|
|
774
|
+
/**
|
|
775
|
+
* Update the current user
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* await auth.updateUser({ metadata: { name: 'Jane Doe' } });
|
|
779
|
+
*/
|
|
780
|
+
declare function updateUser(options: UpdateUserOptions): Promise<User>;
|
|
781
|
+
/**
|
|
782
|
+
* Send a password reset email
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* await auth.resetPassword({ email: 'user@example.com' });
|
|
786
|
+
*/
|
|
787
|
+
declare function resetPassword(options: ResetPasswordOptions): Promise<void>;
|
|
788
|
+
/**
|
|
789
|
+
* Subscribe to auth state changes
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* const subscription = auth.onAuthStateChange((event, session) => {
|
|
793
|
+
* console.log('Auth event:', event, 'Session:', session);
|
|
794
|
+
* });
|
|
795
|
+
*
|
|
796
|
+
* // Later: unsubscribe
|
|
797
|
+
* subscription.unsubscribe();
|
|
798
|
+
*/
|
|
799
|
+
declare function onAuthStateChange(callback: AuthStateChangeCallback): AuthSubscription;
|
|
800
|
+
/**
|
|
801
|
+
* Get the access token for API requests
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* const token = await auth.getAccessToken();
|
|
805
|
+
* const response = await fetch('/api/protected', {
|
|
806
|
+
* headers: { Authorization: `Bearer ${token}` }
|
|
807
|
+
* });
|
|
808
|
+
*/
|
|
809
|
+
declare function getAccessToken(): Promise<string | null>;
|
|
810
|
+
/**
|
|
811
|
+
* Check if a user is currently authenticated
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* if (await auth.isAuthenticated()) {
|
|
815
|
+
* console.log('User is logged in');
|
|
816
|
+
* }
|
|
817
|
+
*/
|
|
818
|
+
declare function isAuthenticated(): Promise<boolean>;
|
|
819
|
+
/**
|
|
820
|
+
* Client authentication API
|
|
821
|
+
*/
|
|
822
|
+
declare const clientAuth: {
|
|
823
|
+
loginWithOAuth: typeof loginWithOAuth;
|
|
824
|
+
loginWithGoogle: typeof loginWithGoogle;
|
|
825
|
+
loginWithGitHub: typeof loginWithGitHub;
|
|
826
|
+
signInWithPassword: typeof signInWithPassword;
|
|
827
|
+
signUp: typeof signUp;
|
|
828
|
+
logout: typeof logout;
|
|
829
|
+
getSession: typeof getSession;
|
|
830
|
+
getUser: typeof getUser;
|
|
831
|
+
refreshSession: typeof refreshSession;
|
|
832
|
+
updateUser: typeof updateUser;
|
|
833
|
+
resetPassword: typeof resetPassword;
|
|
834
|
+
onAuthStateChange: typeof onAuthStateChange;
|
|
835
|
+
getAccessToken: typeof getAccessToken;
|
|
836
|
+
isAuthenticated: typeof isAuthenticated;
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Server-side authentication functions
|
|
841
|
+
* These functions are meant to be used in API routes, middleware, and server components
|
|
842
|
+
*/
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* JWT token payload
|
|
846
|
+
*/
|
|
847
|
+
interface JWTPayload {
|
|
848
|
+
sub: string;
|
|
849
|
+
email: string;
|
|
850
|
+
role?: UserRole;
|
|
851
|
+
exp: number;
|
|
852
|
+
iat: number;
|
|
853
|
+
aud: string;
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Decode and verify a JWT token
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* const payload = await auth.decodeToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...');
|
|
860
|
+
*/
|
|
861
|
+
declare function decodeToken(token: string): JWTPayload;
|
|
862
|
+
/**
|
|
863
|
+
* Verify a JWT token and return the user
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* const user = await auth.verifyToken(request);
|
|
867
|
+
*/
|
|
868
|
+
declare function verifyToken(request: AuthRequest): Promise<VerifiedUser>;
|
|
869
|
+
/**
|
|
870
|
+
* Verify a JWT token and return the session
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* const session = await auth.verifySession(request);
|
|
874
|
+
*/
|
|
875
|
+
declare function verifySession(request: AuthRequest): Promise<Session>;
|
|
876
|
+
/**
|
|
877
|
+
* Require an authenticated user for a protected route
|
|
878
|
+
* Throws 401 if user is not authenticated
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* export async function GET(request: Request) {
|
|
882
|
+
* const user = await auth.requireUser(request);
|
|
883
|
+
* return Response.json({ user });
|
|
884
|
+
* }
|
|
885
|
+
*/
|
|
886
|
+
declare function requireUser(request: AuthRequest): Promise<VerifiedUser>;
|
|
887
|
+
/**
|
|
888
|
+
* Require a specific role for a protected route
|
|
889
|
+
* Throws 403 if user doesn't have the required role
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* export async function DELETE(request: Request) {
|
|
893
|
+
* const user = await auth.requireRole(request, 'admin');
|
|
894
|
+
* return Response.json({ user });
|
|
895
|
+
* }
|
|
896
|
+
*/
|
|
897
|
+
declare function requireRole(request: AuthRequest, allowedRoles: UserRole[]): Promise<VerifiedUser>;
|
|
898
|
+
/**
|
|
899
|
+
* Check if a user has a specific role
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* if (await auth.hasRole(request, 'admin')) {
|
|
903
|
+
* // Show admin features
|
|
904
|
+
* }
|
|
905
|
+
*/
|
|
906
|
+
declare function hasRole(request: AuthRequest, role: UserRole): Promise<boolean>;
|
|
907
|
+
/**
|
|
908
|
+
* Get a user by ID (admin function)
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* const user = await auth.getUserById('user-id-here');
|
|
912
|
+
*/
|
|
913
|
+
declare function getUserById(userId: string): Promise<User | null>;
|
|
914
|
+
/**
|
|
915
|
+
* Update a user's role (admin function)
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* await auth.updateUserRole('user-id-here', 'admin');
|
|
919
|
+
*/
|
|
920
|
+
declare function updateUserRole(userId: string, role: UserRole): Promise<void>;
|
|
921
|
+
/**
|
|
922
|
+
* Delete a user (admin function)
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* await auth.deleteUser('user-id-here');
|
|
926
|
+
*/
|
|
927
|
+
declare function deleteUser(userId: string): Promise<void>;
|
|
928
|
+
/**
|
|
929
|
+
* Create a middleware-compatible auth function
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* // In Next.js middleware
|
|
933
|
+
* import { createMiddleware } from '@vocoweb/kernel/auth';
|
|
934
|
+
*
|
|
935
|
+
* export const middleware = createMiddleware({
|
|
936
|
+
* publicRoutes: ['/api/public', '/login'],
|
|
937
|
+
* });
|
|
938
|
+
*/
|
|
939
|
+
declare function createMiddleware(options?: {
|
|
940
|
+
publicRoutes?: string[];
|
|
941
|
+
apiPrefix?: string;
|
|
942
|
+
}): (request: Request) => Promise<Request | Response>;
|
|
943
|
+
/**
|
|
944
|
+
* Server authentication API
|
|
945
|
+
*/
|
|
946
|
+
declare const serverAuth: {
|
|
947
|
+
verifyToken: typeof verifyToken;
|
|
948
|
+
verifySession: typeof verifySession;
|
|
949
|
+
requireUser: typeof requireUser;
|
|
950
|
+
requireRole: typeof requireRole;
|
|
951
|
+
hasRole: typeof hasRole;
|
|
952
|
+
getUserById: typeof getUserById;
|
|
953
|
+
updateUserRole: typeof updateUserRole;
|
|
954
|
+
deleteUser: typeof deleteUser;
|
|
955
|
+
createMiddleware: typeof createMiddleware;
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Main authentication API
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* import { auth } from '@vocoweb/kernel';
|
|
963
|
+
*
|
|
964
|
+
* // Client-side
|
|
965
|
+
* await auth.loginWithGoogle();
|
|
966
|
+
* await auth.logout();
|
|
967
|
+
*
|
|
968
|
+
* // Server-side
|
|
969
|
+
* const user = await auth.requireUser(request);
|
|
970
|
+
*/
|
|
971
|
+
declare const auth: {
|
|
972
|
+
loginWithOAuth: typeof loginWithOAuth;
|
|
973
|
+
loginWithGoogle: typeof loginWithGoogle;
|
|
974
|
+
loginWithGitHub: typeof loginWithGitHub;
|
|
975
|
+
signInWithPassword: typeof signInWithPassword;
|
|
976
|
+
signUp: typeof signUp;
|
|
977
|
+
logout: typeof logout;
|
|
978
|
+
getSession: typeof getSession;
|
|
979
|
+
getUser: typeof getUser;
|
|
980
|
+
refreshSession: typeof refreshSession;
|
|
981
|
+
updateUser: typeof updateUser;
|
|
982
|
+
resetPassword: typeof resetPassword;
|
|
983
|
+
onAuthStateChange: typeof onAuthStateChange;
|
|
984
|
+
getAccessToken: typeof getAccessToken;
|
|
985
|
+
isAuthenticated: typeof isAuthenticated;
|
|
986
|
+
verifyToken: typeof verifyToken;
|
|
987
|
+
verifySession: typeof verifySession;
|
|
988
|
+
requireUser: typeof requireUser;
|
|
989
|
+
requireRole: typeof requireRole;
|
|
990
|
+
hasRole: typeof hasRole;
|
|
991
|
+
getUserById: typeof getUserById;
|
|
992
|
+
updateUserRole: typeof updateUserRole;
|
|
993
|
+
deleteUser: typeof deleteUser;
|
|
994
|
+
createMiddleware: typeof createMiddleware;
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* VocoAuthClient class for OOP usage
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* const client = new VocoAuthClient();
|
|
1002
|
+
* await client.loginWithGoogle();
|
|
1003
|
+
*/
|
|
1004
|
+
declare class VocoAuthClient {
|
|
1005
|
+
/**
|
|
1006
|
+
* Sign in with Google OAuth
|
|
1007
|
+
*/
|
|
1008
|
+
loginWithGoogle(redirectTo?: string): Promise<void>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Sign in with email and password
|
|
1011
|
+
*/
|
|
1012
|
+
signInWithPassword(options: SignInWithPasswordOptions): Promise<{
|
|
1013
|
+
data: {
|
|
1014
|
+
session: _supabase_auth_js.Session | null;
|
|
1015
|
+
user: _supabase_auth_js.User | null;
|
|
1016
|
+
};
|
|
1017
|
+
}>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Sign up a new user
|
|
1020
|
+
*/
|
|
1021
|
+
signUp(options: SignUpOptions): Promise<{
|
|
1022
|
+
data: {
|
|
1023
|
+
session: _supabase_auth_js.Session | null;
|
|
1024
|
+
user: _supabase_auth_js.User | null;
|
|
1025
|
+
};
|
|
1026
|
+
}>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Sign out the current user
|
|
1029
|
+
*/
|
|
1030
|
+
logout(): Promise<void>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Get the current session
|
|
1033
|
+
*/
|
|
1034
|
+
getSession(): Promise<_supabase_auth_js.Session | null>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Get the current user
|
|
1037
|
+
*/
|
|
1038
|
+
getUser(): Promise<_supabase_auth_js.User | null>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Subscribe to auth state changes
|
|
1041
|
+
*/
|
|
1042
|
+
onAuthStateChange(callback: AuthStateChangeCallback): AuthSubscription;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Type definitions for the Billing module
|
|
1047
|
+
*/
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Checkout session options
|
|
1051
|
+
*/
|
|
1052
|
+
interface CheckoutOptions {
|
|
1053
|
+
/**
|
|
1054
|
+
* Stripe Price ID
|
|
1055
|
+
*/
|
|
1056
|
+
priceId: string;
|
|
1057
|
+
/**
|
|
1058
|
+
* User ID for customer lookup/creation
|
|
1059
|
+
*/
|
|
1060
|
+
userId: string;
|
|
1061
|
+
/**
|
|
1062
|
+
* VAT number for EU reverse charge (optional)
|
|
1063
|
+
* Format: Country code + VAT number (e.g., "DE123456789")
|
|
1064
|
+
*/
|
|
1065
|
+
vatNumber?: string;
|
|
1066
|
+
/**
|
|
1067
|
+
* Customer email (optional - will use user's email if not provided)
|
|
1068
|
+
*/
|
|
1069
|
+
email?: string;
|
|
1070
|
+
/**
|
|
1071
|
+
* Customer name (optional)
|
|
1072
|
+
*/
|
|
1073
|
+
name?: string;
|
|
1074
|
+
/**
|
|
1075
|
+
* URL to redirect to on success
|
|
1076
|
+
*/
|
|
1077
|
+
successUrl?: string;
|
|
1078
|
+
/**
|
|
1079
|
+
* URL to redirect to on cancel
|
|
1080
|
+
*/
|
|
1081
|
+
cancelUrl?: string;
|
|
1082
|
+
/**
|
|
1083
|
+
* Metadata to attach to the session
|
|
1084
|
+
*/
|
|
1085
|
+
metadata?: Record<string, string>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Subscription quantity (default: 1)
|
|
1088
|
+
*/
|
|
1089
|
+
quantity?: number;
|
|
1090
|
+
/**
|
|
1091
|
+
* Trial period days (optional)
|
|
1092
|
+
*/
|
|
1093
|
+
trialPeriodDays?: number;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Checkout session result
|
|
1097
|
+
*/
|
|
1098
|
+
interface CheckoutResult {
|
|
1099
|
+
url: string;
|
|
1100
|
+
sessionId: string;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Webhook event types
|
|
1104
|
+
*/
|
|
1105
|
+
type WebhookEvent = Stripe__default.Event;
|
|
1106
|
+
/**
|
|
1107
|
+
* Invoice status
|
|
1108
|
+
*/
|
|
1109
|
+
type InvoiceStatus = 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
|
|
1110
|
+
/**
|
|
1111
|
+
* Invoice with metadata
|
|
1112
|
+
*/
|
|
1113
|
+
interface Invoice {
|
|
1114
|
+
id: string;
|
|
1115
|
+
number: string;
|
|
1116
|
+
amount: number;
|
|
1117
|
+
currency: string;
|
|
1118
|
+
status: InvoiceStatus;
|
|
1119
|
+
createdAt: Date;
|
|
1120
|
+
dueDate?: Date;
|
|
1121
|
+
paidAt?: Date;
|
|
1122
|
+
pdfUrl?: string;
|
|
1123
|
+
metadata?: Record<string, string>;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Subscription status
|
|
1127
|
+
*/
|
|
1128
|
+
type SubscriptionStatus = Stripe__default.Subscription.Status;
|
|
1129
|
+
/**
|
|
1130
|
+
* Subscription information
|
|
1131
|
+
*/
|
|
1132
|
+
interface Subscription {
|
|
1133
|
+
id: string;
|
|
1134
|
+
status: SubscriptionStatus;
|
|
1135
|
+
priceId: string;
|
|
1136
|
+
amount: number;
|
|
1137
|
+
currency: string;
|
|
1138
|
+
interval: 'month' | 'year';
|
|
1139
|
+
currentPeriodStart: Date;
|
|
1140
|
+
currentPeriodEnd: Date;
|
|
1141
|
+
cancelAtPeriodEnd: boolean;
|
|
1142
|
+
trialStart?: Date;
|
|
1143
|
+
trialEnd?: Date;
|
|
1144
|
+
metadata?: Record<string, string>;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Price information
|
|
1148
|
+
*/
|
|
1149
|
+
interface Price {
|
|
1150
|
+
id: string;
|
|
1151
|
+
productId: string;
|
|
1152
|
+
amount: number;
|
|
1153
|
+
currency: string;
|
|
1154
|
+
interval: 'month' | 'year' | 'one_time' | null;
|
|
1155
|
+
active: boolean;
|
|
1156
|
+
metadata?: Record<string, string>;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Product information
|
|
1160
|
+
*/
|
|
1161
|
+
interface Product {
|
|
1162
|
+
id: string;
|
|
1163
|
+
name: string;
|
|
1164
|
+
description?: string;
|
|
1165
|
+
active: boolean;
|
|
1166
|
+
metadata?: Record<string, string>;
|
|
1167
|
+
prices?: Price[];
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Customer information
|
|
1171
|
+
*/
|
|
1172
|
+
interface Customer {
|
|
1173
|
+
id: string;
|
|
1174
|
+
email?: string;
|
|
1175
|
+
name?: string;
|
|
1176
|
+
metadata?: Record<string, string>;
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Payment method types
|
|
1180
|
+
*/
|
|
1181
|
+
type PaymentMethodType = Stripe__default.PaymentMethod.Type;
|
|
1182
|
+
/**
|
|
1183
|
+
* EU VAT information
|
|
1184
|
+
*/
|
|
1185
|
+
interface VatInfo {
|
|
1186
|
+
country: string;
|
|
1187
|
+
vatNumber: string;
|
|
1188
|
+
valid: boolean;
|
|
1189
|
+
companyName?: string;
|
|
1190
|
+
address?: string;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Tax calculation result
|
|
1194
|
+
*/
|
|
1195
|
+
interface TaxCalculation {
|
|
1196
|
+
amount: number;
|
|
1197
|
+
currency: string;
|
|
1198
|
+
taxAmount: number;
|
|
1199
|
+
taxRate: number;
|
|
1200
|
+
reverseCharge: boolean;
|
|
1201
|
+
vatValid: boolean;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Customer portal session options
|
|
1205
|
+
*/
|
|
1206
|
+
interface PortalOptions {
|
|
1207
|
+
customerId: string;
|
|
1208
|
+
returnUrl: string;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Update subscription options
|
|
1212
|
+
*/
|
|
1213
|
+
interface UpdateSubscriptionOptions {
|
|
1214
|
+
subscriptionId: string;
|
|
1215
|
+
priceId?: string;
|
|
1216
|
+
quantity?: number;
|
|
1217
|
+
metadata?: Record<string, string>;
|
|
1218
|
+
cancelAtPeriodEnd?: boolean;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* VAT (Value Added Tax) validation and utilities
|
|
1223
|
+
* Uses the EU VIES (VAT Information Exchange System) API
|
|
1224
|
+
*/
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* EU country codes with VAT
|
|
1228
|
+
*/
|
|
1229
|
+
declare const EU_COUNTRY_CODES: readonly ["AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "EL", "ES", "FI", "FR", "HR", "HU", "IE", "IT", "LT", "LU", "LV", "MT", "NL", "PL", "PT", "RO", "SE", "SI", "SK"];
|
|
1230
|
+
/**
|
|
1231
|
+
* Extract country code and VAT number from a VAT number string
|
|
1232
|
+
*/
|
|
1233
|
+
declare function parseVatNumber(vatNumber: string): {
|
|
1234
|
+
countryCode: string;
|
|
1235
|
+
vatNumber: string;
|
|
1236
|
+
} | null;
|
|
1237
|
+
/**
|
|
1238
|
+
* Check if a country is in the EU
|
|
1239
|
+
*/
|
|
1240
|
+
declare function isEuCountry(countryCode: string): boolean;
|
|
1241
|
+
/**
|
|
1242
|
+
* Validate VAT number format
|
|
1243
|
+
*/
|
|
1244
|
+
declare function isValidVatFormat(vatNumber: string): boolean;
|
|
1245
|
+
/**
|
|
1246
|
+
* Validate VAT number using VIES API
|
|
1247
|
+
*
|
|
1248
|
+
* @example
|
|
1249
|
+
* const result = await validateVat('DE123456789');
|
|
1250
|
+
* if (result.valid) {
|
|
1251
|
+
* console.log('Company:', result.companyName);
|
|
1252
|
+
* }
|
|
1253
|
+
*/
|
|
1254
|
+
declare function validateVat(vatNumber: string): Promise<VatInfo>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Quick VAT format check (does not call VIES API)
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* if (isValidVatFormat('DE123456789')) {
|
|
1260
|
+
* // Format is valid, but not yet verified
|
|
1261
|
+
* }
|
|
1262
|
+
*/
|
|
1263
|
+
declare function quickVatCheck(vatNumber: string): boolean;
|
|
1264
|
+
/**
|
|
1265
|
+
* Check if reverse charge applies (B2B transaction within EU)
|
|
1266
|
+
*/
|
|
1267
|
+
declare function shouldApplyReverseCharge(buyerCountry: string, sellerCountry: string, buyerVatNumber: string): boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Calculate tax amount with reverse charge consideration
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* const tax = calculateTax({
|
|
1273
|
+
* amount: 10000, // $100.00 in cents
|
|
1274
|
+
* taxRate: 0.20, // 20% VAT
|
|
1275
|
+
* reverseCharge: true, // B2B with valid VAT
|
|
1276
|
+
* });
|
|
1277
|
+
* // tax.taxAmount = 0 (reverse charge)
|
|
1278
|
+
*/
|
|
1279
|
+
declare function calculateTax(options: {
|
|
1280
|
+
amount: number;
|
|
1281
|
+
taxRate: number;
|
|
1282
|
+
reverseCharge: boolean;
|
|
1283
|
+
}): {
|
|
1284
|
+
amount: number;
|
|
1285
|
+
taxAmount: number;
|
|
1286
|
+
taxRate: number;
|
|
1287
|
+
reverseCharge: boolean;
|
|
1288
|
+
};
|
|
1289
|
+
/**
|
|
1290
|
+
* Get standard VAT rate for a country
|
|
1291
|
+
* Note: These are standard rates and may not reflect reduced rates for specific goods
|
|
1292
|
+
*/
|
|
1293
|
+
declare function getStandardVatRate(countryCode: string): number;
|
|
1294
|
+
/**
|
|
1295
|
+
* Clear VAT validation cache (useful for testing)
|
|
1296
|
+
*/
|
|
1297
|
+
declare function clearVatCache(): void;
|
|
1298
|
+
/**
|
|
1299
|
+
* VAT validation API
|
|
1300
|
+
*/
|
|
1301
|
+
declare const vat: {
|
|
1302
|
+
validate: typeof validateVat;
|
|
1303
|
+
quickCheck: typeof quickVatCheck;
|
|
1304
|
+
parse: typeof parseVatNumber;
|
|
1305
|
+
isEuCountry: typeof isEuCountry;
|
|
1306
|
+
shouldApplyReverseCharge: typeof shouldApplyReverseCharge;
|
|
1307
|
+
calculateTax: typeof calculateTax;
|
|
1308
|
+
getStandardRate: typeof getStandardVatRate;
|
|
1309
|
+
clearCache: typeof clearVatCache;
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
declare const vat$1_EU_COUNTRY_CODES: typeof EU_COUNTRY_CODES;
|
|
1313
|
+
declare const vat$1_calculateTax: typeof calculateTax;
|
|
1314
|
+
declare const vat$1_clearVatCache: typeof clearVatCache;
|
|
1315
|
+
declare const vat$1_getStandardVatRate: typeof getStandardVatRate;
|
|
1316
|
+
declare const vat$1_isEuCountry: typeof isEuCountry;
|
|
1317
|
+
declare const vat$1_isValidVatFormat: typeof isValidVatFormat;
|
|
1318
|
+
declare const vat$1_parseVatNumber: typeof parseVatNumber;
|
|
1319
|
+
declare const vat$1_quickVatCheck: typeof quickVatCheck;
|
|
1320
|
+
declare const vat$1_shouldApplyReverseCharge: typeof shouldApplyReverseCharge;
|
|
1321
|
+
declare const vat$1_validateVat: typeof validateVat;
|
|
1322
|
+
declare const vat$1_vat: typeof vat;
|
|
1323
|
+
declare namespace vat$1 {
|
|
1324
|
+
export { vat$1_EU_COUNTRY_CODES as EU_COUNTRY_CODES, vat$1_calculateTax as calculateTax, vat$1_clearVatCache as clearVatCache, vat$1_getStandardVatRate as getStandardVatRate, vat$1_isEuCountry as isEuCountry, vat$1_isValidVatFormat as isValidVatFormat, vat$1_parseVatNumber as parseVatNumber, vat$1_quickVatCheck as quickVatCheck, vat$1_shouldApplyReverseCharge as shouldApplyReverseCharge, vat$1_validateVat as validateVat, vat$1_vat as vat };
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Stripe checkout session creation with VAT validation
|
|
1329
|
+
*/
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Create Stripe checkout session with VAT validation
|
|
1333
|
+
*
|
|
1334
|
+
* @example
|
|
1335
|
+
* const result = await createCheckoutSession({
|
|
1336
|
+
* priceId: 'price_...',
|
|
1337
|
+
* userId: 'user-123',
|
|
1338
|
+
* vatNumber: 'DE123456789',
|
|
1339
|
+
* email: 'customer@example.com',
|
|
1340
|
+
* });
|
|
1341
|
+
*/
|
|
1342
|
+
declare function createCheckoutSession(options: CheckoutOptions): Promise<CheckoutResult>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Create a customer portal session
|
|
1345
|
+
*
|
|
1346
|
+
* @example
|
|
1347
|
+
* const result = await createPortalSession({
|
|
1348
|
+
* customerId: 'cus_...',
|
|
1349
|
+
* returnUrl: 'https://app.example.com/settings',
|
|
1350
|
+
* });
|
|
1351
|
+
*/
|
|
1352
|
+
declare function createPortalSession(options: {
|
|
1353
|
+
customerId: string;
|
|
1354
|
+
returnUrl: string;
|
|
1355
|
+
}): Promise<{
|
|
1356
|
+
url: string;
|
|
1357
|
+
}>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Get checkout session by ID
|
|
1360
|
+
*
|
|
1361
|
+
* @example
|
|
1362
|
+
* const session = await getCheckoutSession('cs_test_...');
|
|
1363
|
+
*/
|
|
1364
|
+
declare function getCheckoutSession(sessionId: string): Promise<Stripe__default.Checkout.Session>;
|
|
1365
|
+
/**
|
|
1366
|
+
* List products with prices
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* const products = await listProducts({ active: true });
|
|
1370
|
+
*/
|
|
1371
|
+
declare function listProducts(options?: {
|
|
1372
|
+
active?: boolean;
|
|
1373
|
+
limit?: number;
|
|
1374
|
+
}): Promise<Array<{
|
|
1375
|
+
product: Stripe__default.Product;
|
|
1376
|
+
prices: Stripe__default.Price[];
|
|
1377
|
+
}>>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Get product by ID with prices
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* const product = await getProduct('prod_...');
|
|
1383
|
+
*/
|
|
1384
|
+
declare function getProduct(productId: string): Promise<{
|
|
1385
|
+
product: Stripe__default.Product;
|
|
1386
|
+
prices: Stripe__default.Price[];
|
|
1387
|
+
}>;
|
|
1388
|
+
/**
|
|
1389
|
+
* Checkout API
|
|
1390
|
+
*/
|
|
1391
|
+
declare const checkout: {
|
|
1392
|
+
createSession: typeof createCheckoutSession;
|
|
1393
|
+
getSession: typeof getCheckoutSession;
|
|
1394
|
+
createPortal: typeof createPortalSession;
|
|
1395
|
+
listProducts: typeof listProducts;
|
|
1396
|
+
getProduct: typeof getProduct;
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
declare const checkout$1_checkout: typeof checkout;
|
|
1400
|
+
declare const checkout$1_createCheckoutSession: typeof createCheckoutSession;
|
|
1401
|
+
declare const checkout$1_createPortalSession: typeof createPortalSession;
|
|
1402
|
+
declare const checkout$1_getCheckoutSession: typeof getCheckoutSession;
|
|
1403
|
+
declare const checkout$1_getProduct: typeof getProduct;
|
|
1404
|
+
declare const checkout$1_listProducts: typeof listProducts;
|
|
1405
|
+
declare namespace checkout$1 {
|
|
1406
|
+
export { checkout$1_checkout as checkout, checkout$1_createCheckoutSession as createCheckoutSession, checkout$1_createPortalSession as createPortalSession, checkout$1_getCheckoutSession as getCheckoutSession, checkout$1_getProduct as getProduct, checkout$1_listProducts as listProducts };
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Stripe webhook handler
|
|
1411
|
+
* Verifies webhook signatures and processes events
|
|
1412
|
+
*/
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* Webhook event handler type
|
|
1416
|
+
*/
|
|
1417
|
+
type WebhookEventHandler = (event: Stripe__default.Event) => void | Promise<void>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Parse and verify Stripe webhook
|
|
1420
|
+
*
|
|
1421
|
+
* @example
|
|
1422
|
+
* import { verifyWebhook } from '@vocoweb/kernel/billing';
|
|
1423
|
+
*
|
|
1424
|
+
* export async function POST(request: Request) {
|
|
1425
|
+
* const body = await request.text();
|
|
1426
|
+
* const signature = request.headers.get('stripe-signature') || '';
|
|
1427
|
+
*
|
|
1428
|
+
* try {
|
|
1429
|
+
* const event = verifyWebhook(body, signature);
|
|
1430
|
+
* // Process event...
|
|
1431
|
+
* } catch (error) {
|
|
1432
|
+
* return Response.json({ error: 'Invalid webhook' }, { status: 400 });
|
|
1433
|
+
* }
|
|
1434
|
+
* }
|
|
1435
|
+
*/
|
|
1436
|
+
declare function verifyWebhook(payload: string | Buffer, signature: string, secret?: string): Stripe__default.Event;
|
|
1437
|
+
/**
|
|
1438
|
+
* Register a handler for a specific webhook event type
|
|
1439
|
+
*
|
|
1440
|
+
* @example
|
|
1441
|
+
* onWebhookEvent('checkout.session.completed', async (event) => {
|
|
1442
|
+
* const session = event.data.object as Stripe.Checkout.Session;
|
|
1443
|
+
* console.log('Checkout completed:', session.id);
|
|
1444
|
+
* });
|
|
1445
|
+
*/
|
|
1446
|
+
declare function onWebhookEvent(eventType: string, handler: WebhookEventHandler): void;
|
|
1447
|
+
/**
|
|
1448
|
+
* Unregister all handlers for an event type
|
|
1449
|
+
*/
|
|
1450
|
+
declare function offWebhookEvent(eventType: string): void;
|
|
1451
|
+
/**
|
|
1452
|
+
* Process a webhook event by calling registered handlers
|
|
1453
|
+
*
|
|
1454
|
+
* @example
|
|
1455
|
+
* const event = verifyWebhook(body, signature);
|
|
1456
|
+
* await handleWebhook(event);
|
|
1457
|
+
*/
|
|
1458
|
+
declare function handleWebhook(event: Stripe__default.Event): Promise<void>;
|
|
1459
|
+
/**
|
|
1460
|
+
* Create a standardized webhook handler for Next.js API routes
|
|
1461
|
+
*
|
|
1462
|
+
* @example
|
|
1463
|
+
* export const POST = handleWebhookRequest({
|
|
1464
|
+
* onCheckoutCompleted: async (session) => {
|
|
1465
|
+
* // Handle successful checkout
|
|
1466
|
+
* },
|
|
1467
|
+
* onInvoicePaid: async (invoice) => {
|
|
1468
|
+
* // Handle paid invoice
|
|
1469
|
+
* },
|
|
1470
|
+
* });
|
|
1471
|
+
*/
|
|
1472
|
+
declare function handleWebhookRequest(config?: {
|
|
1473
|
+
onCheckoutCompleted?: (session: Stripe__default.Checkout.Session) => void | Promise<void>;
|
|
1474
|
+
onInvoicePaid?: (invoice: Stripe__default.Invoice) => void | Promise<void>;
|
|
1475
|
+
onInvoiceFailed?: (invoice: Stripe__default.Invoice) => void | Promise<void>;
|
|
1476
|
+
onSubscriptionCreated?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1477
|
+
onSubscriptionUpdated?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1478
|
+
onSubscriptionDeleted?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1479
|
+
onCustomerCreated?: (customer: Stripe__default.Customer) => void | Promise<void>;
|
|
1480
|
+
onEvent?: (event: Stripe__default.Event) => void | Promise<void>;
|
|
1481
|
+
}): (request: Request) => Promise<Response>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Middleware-style webhook handler for Express
|
|
1484
|
+
*
|
|
1485
|
+
* @example
|
|
1486
|
+
* app.post('/webhook', expressWebhookHandler({
|
|
1487
|
+
* onCheckoutCompleted: async (session) => {
|
|
1488
|
+
* // Handle checkout
|
|
1489
|
+
* },
|
|
1490
|
+
* }));
|
|
1491
|
+
*/
|
|
1492
|
+
declare function expressWebhookHandler(config?: {
|
|
1493
|
+
onCheckoutCompleted?: (session: Stripe__default.Checkout.Session) => void | Promise<void>;
|
|
1494
|
+
onInvoicePaid?: (invoice: Stripe__default.Invoice) => void | Promise<void>;
|
|
1495
|
+
onInvoiceFailed?: (invoice: Stripe__default.Invoice) => void | Promise<void>;
|
|
1496
|
+
onSubscriptionCreated?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1497
|
+
onSubscriptionUpdated?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1498
|
+
onSubscriptionDeleted?: (subscription: Stripe__default.Subscription) => void | Promise<void>;
|
|
1499
|
+
onCustomerCreated?: (customer: Stripe__default.Customer) => void | Promise<void>;
|
|
1500
|
+
onEvent?: (event: Stripe__default.Event) => void | Promise<void>;
|
|
1501
|
+
}): (req: {
|
|
1502
|
+
body?: string;
|
|
1503
|
+
headers: {
|
|
1504
|
+
"stripe-signature"?: string;
|
|
1505
|
+
};
|
|
1506
|
+
}, res: {
|
|
1507
|
+
status(code: number): {
|
|
1508
|
+
json(data: unknown): void;
|
|
1509
|
+
};
|
|
1510
|
+
json(data: unknown): void;
|
|
1511
|
+
}) => Promise<void>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Webhook API
|
|
1514
|
+
*/
|
|
1515
|
+
declare const webhook: {
|
|
1516
|
+
verify: typeof verifyWebhook;
|
|
1517
|
+
handle: typeof handleWebhook;
|
|
1518
|
+
on: typeof onWebhookEvent;
|
|
1519
|
+
off: typeof offWebhookEvent;
|
|
1520
|
+
createHandler: typeof handleWebhookRequest;
|
|
1521
|
+
expressHandler: typeof expressWebhookHandler;
|
|
1522
|
+
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Common Stripe webhook event types
|
|
1525
|
+
*/
|
|
1526
|
+
declare const WebhookEvents: {
|
|
1527
|
+
readonly CHECKOUT_COMPLETED: "checkout.session.completed";
|
|
1528
|
+
readonly CHECKOUT_EXPIRED: "checkout.session.expired";
|
|
1529
|
+
readonly INVOICE_CREATED: "invoice.created";
|
|
1530
|
+
readonly INVOICE_PAID: "invoice.paid";
|
|
1531
|
+
readonly INVOICE_PAYMENT_FAILED: "invoice.payment_failed";
|
|
1532
|
+
readonly INVOICE_SENT: "invoice.sent";
|
|
1533
|
+
readonly INVOICE_UPCOMING: "invoice.upcoming";
|
|
1534
|
+
readonly INVOICE_VOIDED: "invoice.voided";
|
|
1535
|
+
readonly INVOICE_MARKED_UNCOLLECTIBLE: "invoice.marked_uncollectible";
|
|
1536
|
+
readonly SUBSCRIPTION_CREATED: "customer.subscription.created";
|
|
1537
|
+
readonly SUBSCRIPTION_UPDATED: "customer.subscription.updated";
|
|
1538
|
+
readonly SUBSCRIPTION_DELETED: "customer.subscription.deleted";
|
|
1539
|
+
readonly SUBSCRIPTION_TRIAL_WILL_END: "customer.subscription.trial_will_end";
|
|
1540
|
+
readonly CUSTOMER_CREATED: "customer.created";
|
|
1541
|
+
readonly CUSTOMER_UPDATED: "customer.updated";
|
|
1542
|
+
readonly CUSTOMER_DELETED: "customer.deleted";
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
type webhook$1_WebhookEventHandler = WebhookEventHandler;
|
|
1546
|
+
declare const webhook$1_WebhookEvents: typeof WebhookEvents;
|
|
1547
|
+
declare const webhook$1_expressWebhookHandler: typeof expressWebhookHandler;
|
|
1548
|
+
declare const webhook$1_handleWebhook: typeof handleWebhook;
|
|
1549
|
+
declare const webhook$1_handleWebhookRequest: typeof handleWebhookRequest;
|
|
1550
|
+
declare const webhook$1_offWebhookEvent: typeof offWebhookEvent;
|
|
1551
|
+
declare const webhook$1_onWebhookEvent: typeof onWebhookEvent;
|
|
1552
|
+
declare const webhook$1_verifyWebhook: typeof verifyWebhook;
|
|
1553
|
+
declare const webhook$1_webhook: typeof webhook;
|
|
1554
|
+
declare namespace webhook$1 {
|
|
1555
|
+
export { type webhook$1_WebhookEventHandler as WebhookEventHandler, webhook$1_WebhookEvents as WebhookEvents, webhook$1_expressWebhookHandler as expressWebhookHandler, webhook$1_handleWebhook as handleWebhook, webhook$1_handleWebhookRequest as handleWebhookRequest, webhook$1_offWebhookEvent as offWebhookEvent, webhook$1_onWebhookEvent as onWebhookEvent, webhook$1_verifyWebhook as verifyWebhook, webhook$1_webhook as webhook };
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* Invoice management
|
|
1560
|
+
*/
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Get invoice by ID
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* const invoice = await getInvoice('in_...');
|
|
1567
|
+
*/
|
|
1568
|
+
declare function getInvoice(invoiceId: string): Promise<Invoice>;
|
|
1569
|
+
/**
|
|
1570
|
+
* List invoices for a customer
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* const invoices = await getInvoices('cus_...');
|
|
1574
|
+
*/
|
|
1575
|
+
declare function getInvoices(customerId: string, options?: {
|
|
1576
|
+
limit?: number;
|
|
1577
|
+
status?: Invoice['status'];
|
|
1578
|
+
}): Promise<{
|
|
1579
|
+
invoices: Invoice[];
|
|
1580
|
+
hasMore: boolean;
|
|
1581
|
+
}>;
|
|
1582
|
+
/**
|
|
1583
|
+
* List invoices for a user (by user_id metadata)
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* const invoices = await getUserInvoices('user-123');
|
|
1587
|
+
*/
|
|
1588
|
+
declare function getUserInvoices(userId: string, options?: {
|
|
1589
|
+
limit?: number;
|
|
1590
|
+
status?: Invoice['status'];
|
|
1591
|
+
}): Promise<{
|
|
1592
|
+
invoices: Invoice[];
|
|
1593
|
+
hasMore: boolean;
|
|
1594
|
+
}>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Get upcoming invoice for a subscription
|
|
1597
|
+
*
|
|
1598
|
+
* @example
|
|
1599
|
+
* const invoice = await getUpcomingInvoice('sub_...');
|
|
1600
|
+
*/
|
|
1601
|
+
declare function getUpcomingInvoice(subscriptionId: string): Promise<Invoice | null>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Create an invoice for a subscription immediately
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* const invoice = await createInvoice('sub_...');
|
|
1607
|
+
*/
|
|
1608
|
+
declare function createInvoice(subscriptionId: string): Promise<Invoice>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Pay an invoice (for automatic collection invoices)
|
|
1611
|
+
*
|
|
1612
|
+
* @example
|
|
1613
|
+
* const invoice = await payInvoice('in_...');
|
|
1614
|
+
*/
|
|
1615
|
+
declare function payInvoice(invoiceId: string): Promise<Invoice>;
|
|
1616
|
+
/**
|
|
1617
|
+
* Void an invoice
|
|
1618
|
+
*
|
|
1619
|
+
* @example
|
|
1620
|
+
* const invoice = await voidInvoice('in_...');
|
|
1621
|
+
*/
|
|
1622
|
+
declare function voidInvoice(invoiceId: string): Promise<Invoice>;
|
|
1623
|
+
/**
|
|
1624
|
+
* Send an invoice to the customer
|
|
1625
|
+
*
|
|
1626
|
+
* @example
|
|
1627
|
+
* await sendInvoice('in_...');
|
|
1628
|
+
*/
|
|
1629
|
+
declare function sendInvoice(invoiceId: string): Promise<void>;
|
|
1630
|
+
/**
|
|
1631
|
+
* Get invoice line items
|
|
1632
|
+
*
|
|
1633
|
+
* @example
|
|
1634
|
+
* const lines = await getInvoiceLines('in_...');
|
|
1635
|
+
*/
|
|
1636
|
+
declare function getInvoiceLines(invoiceId: string): Promise<Stripe__default.InvoiceLineItem[]>;
|
|
1637
|
+
/**
|
|
1638
|
+
* Invoices API
|
|
1639
|
+
*/
|
|
1640
|
+
declare const invoices: {
|
|
1641
|
+
get: typeof getInvoice;
|
|
1642
|
+
list: typeof getInvoices;
|
|
1643
|
+
getUser: typeof getUserInvoices;
|
|
1644
|
+
getUpcoming: typeof getUpcomingInvoice;
|
|
1645
|
+
create: typeof createInvoice;
|
|
1646
|
+
pay: typeof payInvoice;
|
|
1647
|
+
void: typeof voidInvoice;
|
|
1648
|
+
send: typeof sendInvoice;
|
|
1649
|
+
getLines: typeof getInvoiceLines;
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
declare const invoices$1_createInvoice: typeof createInvoice;
|
|
1653
|
+
declare const invoices$1_getInvoice: typeof getInvoice;
|
|
1654
|
+
declare const invoices$1_getInvoiceLines: typeof getInvoiceLines;
|
|
1655
|
+
declare const invoices$1_getInvoices: typeof getInvoices;
|
|
1656
|
+
declare const invoices$1_getUpcomingInvoice: typeof getUpcomingInvoice;
|
|
1657
|
+
declare const invoices$1_getUserInvoices: typeof getUserInvoices;
|
|
1658
|
+
declare const invoices$1_invoices: typeof invoices;
|
|
1659
|
+
declare const invoices$1_payInvoice: typeof payInvoice;
|
|
1660
|
+
declare const invoices$1_sendInvoice: typeof sendInvoice;
|
|
1661
|
+
declare const invoices$1_voidInvoice: typeof voidInvoice;
|
|
1662
|
+
declare namespace invoices$1 {
|
|
1663
|
+
export { invoices$1_createInvoice as createInvoice, invoices$1_getInvoice as getInvoice, invoices$1_getInvoiceLines as getInvoiceLines, invoices$1_getInvoices as getInvoices, invoices$1_getUpcomingInvoice as getUpcomingInvoice, invoices$1_getUserInvoices as getUserInvoices, invoices$1_invoices as invoices, invoices$1_payInvoice as payInvoice, invoices$1_sendInvoice as sendInvoice, invoices$1_voidInvoice as voidInvoice };
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
/**
|
|
1667
|
+
* Main billing API
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* import { billing } from '@vocoweb/kernel';
|
|
1671
|
+
*
|
|
1672
|
+
* // Create checkout with VAT validation
|
|
1673
|
+
* const session = await billing.createCheckoutSession({
|
|
1674
|
+
* priceId: 'price_...',
|
|
1675
|
+
* userId: 'user-123',
|
|
1676
|
+
* vatNumber: 'DE123456789',
|
|
1677
|
+
* });
|
|
1678
|
+
*
|
|
1679
|
+
* // Validate VAT number
|
|
1680
|
+
* const vat = await billing.validateVat('DE123456789');
|
|
1681
|
+
*
|
|
1682
|
+
* // Get user invoices
|
|
1683
|
+
* const { invoices } = await billing.getInvoices('user-123');
|
|
1684
|
+
*/
|
|
1685
|
+
declare const billing: {
|
|
1686
|
+
validateVat: typeof validateVat;
|
|
1687
|
+
quickVatCheck: typeof quickVatCheck;
|
|
1688
|
+
parseVatNumber: typeof parseVatNumber;
|
|
1689
|
+
isEuCountry: typeof isEuCountry;
|
|
1690
|
+
shouldApplyReverseCharge: typeof shouldApplyReverseCharge;
|
|
1691
|
+
calculateTax: typeof calculateTax;
|
|
1692
|
+
getStandardVatRate: typeof getStandardVatRate;
|
|
1693
|
+
createCheckoutSession: typeof createCheckoutSession;
|
|
1694
|
+
getCheckoutSession: typeof getCheckoutSession;
|
|
1695
|
+
createPortalSession: typeof createPortalSession;
|
|
1696
|
+
listProducts: typeof listProducts;
|
|
1697
|
+
getProduct: typeof getProduct;
|
|
1698
|
+
verifyWebhook: typeof verifyWebhook;
|
|
1699
|
+
handleWebhook: typeof handleWebhook;
|
|
1700
|
+
onWebhookEvent: typeof onWebhookEvent;
|
|
1701
|
+
offWebhookEvent: typeof offWebhookEvent;
|
|
1702
|
+
handleWebhookRequest: typeof handleWebhookRequest;
|
|
1703
|
+
expressWebhookHandler: typeof expressWebhookHandler;
|
|
1704
|
+
getInvoice: typeof getInvoice;
|
|
1705
|
+
getInvoices: typeof getInvoices;
|
|
1706
|
+
getUserInvoices: typeof getUserInvoices;
|
|
1707
|
+
getUpcomingInvoice: typeof getUpcomingInvoice;
|
|
1708
|
+
createInvoice: typeof createInvoice;
|
|
1709
|
+
payInvoice: typeof payInvoice;
|
|
1710
|
+
voidInvoice: typeof voidInvoice;
|
|
1711
|
+
sendInvoice: typeof sendInvoice;
|
|
1712
|
+
getInvoiceLines: typeof getInvoiceLines;
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* BillingClient class for OOP usage
|
|
1717
|
+
*/
|
|
1718
|
+
declare class BillingClient {
|
|
1719
|
+
/**
|
|
1720
|
+
* Create a checkout session
|
|
1721
|
+
*/
|
|
1722
|
+
createCheckoutSession(options: CheckoutOptions): Promise<CheckoutResult>;
|
|
1723
|
+
/**
|
|
1724
|
+
* Validate VAT number
|
|
1725
|
+
*/
|
|
1726
|
+
validateVat(vatNumber: string): Promise<VatInfo>;
|
|
1727
|
+
/**
|
|
1728
|
+
* Get invoices for a user
|
|
1729
|
+
*/
|
|
1730
|
+
getInvoices(userId: string): Promise<{
|
|
1731
|
+
invoices: Invoice[];
|
|
1732
|
+
hasMore: boolean;
|
|
1733
|
+
}>;
|
|
1734
|
+
/**
|
|
1735
|
+
* Verify webhook signature
|
|
1736
|
+
*/
|
|
1737
|
+
verifyWebhook(payload: string | Buffer, signature: string, secret?: string): Stripe.Stripe.Event;
|
|
1738
|
+
/**
|
|
1739
|
+
* Create customer portal session
|
|
1740
|
+
*/
|
|
1741
|
+
createPortalSession(options: PortalOptions): Promise<{
|
|
1742
|
+
url: string;
|
|
1743
|
+
}>;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* GDPR Data Export functionality
|
|
1748
|
+
* Allows users to request all their data as required by GDPR
|
|
1749
|
+
*/
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* Export all user data for GDPR compliance
|
|
1753
|
+
*
|
|
1754
|
+
* This function fetches all data associated with a user from:
|
|
1755
|
+
* - User profile
|
|
1756
|
+
* - Projects
|
|
1757
|
+
* - Websites
|
|
1758
|
+
* - Usage logs
|
|
1759
|
+
* - Subscriptions
|
|
1760
|
+
* - Invoices
|
|
1761
|
+
* - Audit logs
|
|
1762
|
+
*
|
|
1763
|
+
* @example
|
|
1764
|
+
* const exportData = await exportUserData('user-123');
|
|
1765
|
+
* // Returns all user data in structured format
|
|
1766
|
+
*/
|
|
1767
|
+
declare function exportUserData(userId: string): Promise<UserDataExport>;
|
|
1768
|
+
/**
|
|
1769
|
+
* Export user data as downloadable JSON string
|
|
1770
|
+
*
|
|
1771
|
+
* @example
|
|
1772
|
+
* const json = await exportUserDataAsJson('user-123');
|
|
1773
|
+
* // Send to user via email or download
|
|
1774
|
+
*/
|
|
1775
|
+
declare function exportUserDataAsJson(userId: string): Promise<string>;
|
|
1776
|
+
/**
|
|
1777
|
+
* Create a data export file name
|
|
1778
|
+
*
|
|
1779
|
+
* @example
|
|
1780
|
+
* const filename = createExportFilename('user-123');
|
|
1781
|
+
* // Returns: "user-data-export-user-123-20250208.json"
|
|
1782
|
+
*/
|
|
1783
|
+
declare function createExportFilename(userId: string): string;
|
|
1784
|
+
/**
|
|
1785
|
+
* Check if user has pending export requests
|
|
1786
|
+
*
|
|
1787
|
+
* @example
|
|
1788
|
+
* const hasPending = await hasPendingExports('user-123');
|
|
1789
|
+
*/
|
|
1790
|
+
declare function hasPendingExports(userId: string): Promise<boolean>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Request a data export (creates a pending export record)
|
|
1793
|
+
*
|
|
1794
|
+
* @example
|
|
1795
|
+
* const exportId = await requestDataExport('user-123');
|
|
1796
|
+
*/
|
|
1797
|
+
declare function requestDataExport(userId: string): Promise<string>;
|
|
1798
|
+
/**
|
|
1799
|
+
* Process pending data exports
|
|
1800
|
+
* This should be called by a background job or cron
|
|
1801
|
+
*
|
|
1802
|
+
* @example
|
|
1803
|
+
* await processPendingExports();
|
|
1804
|
+
*/
|
|
1805
|
+
declare function processPendingExports(limit?: number): Promise<number>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Get completed export for a user
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* const export = await getUserExport('user-123');
|
|
1811
|
+
*/
|
|
1812
|
+
declare function getUserExport(userId: string): Promise<UserDataExport | null>;
|
|
1813
|
+
/**
|
|
1814
|
+
* Data export API
|
|
1815
|
+
*/
|
|
1816
|
+
declare const dataExport: {
|
|
1817
|
+
export: typeof exportUserData;
|
|
1818
|
+
exportAsJson: typeof exportUserDataAsJson;
|
|
1819
|
+
createFilename: typeof createExportFilename;
|
|
1820
|
+
hasPending: typeof hasPendingExports;
|
|
1821
|
+
request: typeof requestDataExport;
|
|
1822
|
+
processPending: typeof processPendingExports;
|
|
1823
|
+
getUser: typeof getUserExport;
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* Module C: Shield (Legal Compliance)
|
|
1828
|
+
* GDPR-compliant legal components and data export
|
|
1829
|
+
*/
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Main legal compliance API
|
|
1833
|
+
*
|
|
1834
|
+
* @example
|
|
1835
|
+
* import { legal } from '@vocoweb/kernel';
|
|
1836
|
+
*
|
|
1837
|
+
* // Export user data for GDPR
|
|
1838
|
+
* const exportData = await legal.exportUserData('user-123');
|
|
1839
|
+
*
|
|
1840
|
+
* // Check for pending exports
|
|
1841
|
+
* const hasPending = await legal.hasPendingExports('user-123');
|
|
1842
|
+
*/
|
|
1843
|
+
declare const legal: {
|
|
1844
|
+
exportUserData: typeof exportUserData;
|
|
1845
|
+
exportUserDataAsJson: typeof exportUserDataAsJson;
|
|
1846
|
+
createExportFilename: typeof createExportFilename;
|
|
1847
|
+
hasPendingExports: typeof hasPendingExports;
|
|
1848
|
+
requestDataExport: typeof requestDataExport;
|
|
1849
|
+
processPendingExports: typeof processPendingExports;
|
|
1850
|
+
getUserExport: typeof getUserExport;
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* Privacy and GDPR type definitions
|
|
1855
|
+
*/
|
|
1856
|
+
/**
|
|
1857
|
+
* Action to perform on a dependency during deletion
|
|
1858
|
+
*/
|
|
1859
|
+
type DependencyAction = {
|
|
1860
|
+
table: string;
|
|
1861
|
+
foreign_key: string;
|
|
1862
|
+
action: 'delete' | 'anonymize' | 'retain';
|
|
1863
|
+
cascade?: boolean;
|
|
1864
|
+
keep_fields?: string[];
|
|
1865
|
+
};
|
|
1866
|
+
/**
|
|
1867
|
+
* External API call configuration
|
|
1868
|
+
*/
|
|
1869
|
+
type ExternalApiConfig = {
|
|
1870
|
+
service: 'supabase' | 'stripe' | 'sendgrid' | 'openai' | string;
|
|
1871
|
+
action: string;
|
|
1872
|
+
endpoint?: string;
|
|
1873
|
+
method?: string;
|
|
1874
|
+
required?: boolean;
|
|
1875
|
+
lookup_key?: string;
|
|
1876
|
+
lookup_table?: string;
|
|
1877
|
+
};
|
|
1878
|
+
/**
|
|
1879
|
+
* External API call result
|
|
1880
|
+
*/
|
|
1881
|
+
type ExternalApiCall = {
|
|
1882
|
+
service: string;
|
|
1883
|
+
action: string;
|
|
1884
|
+
status: 'pending' | 'completed' | 'failed';
|
|
1885
|
+
error?: string;
|
|
1886
|
+
timestamp: Date;
|
|
1887
|
+
};
|
|
1888
|
+
/**
|
|
1889
|
+
* Compliance map configuration for an entity type
|
|
1890
|
+
*/
|
|
1891
|
+
type ComplianceMapConfig = {
|
|
1892
|
+
table: string;
|
|
1893
|
+
primary_key: string;
|
|
1894
|
+
dependencies: DependencyAction[];
|
|
1895
|
+
external_apis?: ExternalApiConfig[];
|
|
1896
|
+
};
|
|
1897
|
+
/**
|
|
1898
|
+
* Full compliance map
|
|
1899
|
+
*/
|
|
1900
|
+
type ComplianceMap = {
|
|
1901
|
+
[entityType: string]: ComplianceMapConfig;
|
|
1902
|
+
};
|
|
1903
|
+
/**
|
|
1904
|
+
* Result of a deletion operation
|
|
1905
|
+
*/
|
|
1906
|
+
type DeletionResult = {
|
|
1907
|
+
success: boolean;
|
|
1908
|
+
userId: string;
|
|
1909
|
+
deletedTables: string[];
|
|
1910
|
+
anonymizedTables: string[];
|
|
1911
|
+
retainedTables: string[];
|
|
1912
|
+
externalApiCalls: ExternalApiCall[];
|
|
1913
|
+
errors: Array<{
|
|
1914
|
+
table: string;
|
|
1915
|
+
error: string;
|
|
1916
|
+
}>;
|
|
1917
|
+
completedAt: Date;
|
|
1918
|
+
};
|
|
1919
|
+
/**
|
|
1920
|
+
* Scheduled deletion
|
|
1921
|
+
*/
|
|
1922
|
+
type ScheduledDeletion = {
|
|
1923
|
+
id: string;
|
|
1924
|
+
userId: string;
|
|
1925
|
+
entityType: 'user' | 'project' | 'website';
|
|
1926
|
+
scheduledFor: Date;
|
|
1927
|
+
status: 'pending' | 'processing' | 'completed' | 'cancelled' | 'failed';
|
|
1928
|
+
createdAt: Date;
|
|
1929
|
+
cancelledAt?: Date;
|
|
1930
|
+
completedAt?: Date;
|
|
1931
|
+
error?: string;
|
|
1932
|
+
};
|
|
1933
|
+
/**
|
|
1934
|
+
* Data export record
|
|
1935
|
+
*/
|
|
1936
|
+
type DataExportRecord = {
|
|
1937
|
+
id: string;
|
|
1938
|
+
userId: string;
|
|
1939
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
1940
|
+
requestedAt: Date;
|
|
1941
|
+
completedAt?: Date;
|
|
1942
|
+
data?: any;
|
|
1943
|
+
error?: string;
|
|
1944
|
+
};
|
|
1945
|
+
/**
|
|
1946
|
+
* Deletion status details
|
|
1947
|
+
*/
|
|
1948
|
+
type DeletionStatusDetails = {
|
|
1949
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'not_found';
|
|
1950
|
+
tracker?: DeletionTracker;
|
|
1951
|
+
};
|
|
1952
|
+
/**
|
|
1953
|
+
* Deletion status tracker
|
|
1954
|
+
* Stores deletion progress for audit trail
|
|
1955
|
+
*/
|
|
1956
|
+
interface DeletionTracker {
|
|
1957
|
+
userId: string;
|
|
1958
|
+
startedAt: Date;
|
|
1959
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
1960
|
+
deletedTables: string[];
|
|
1961
|
+
anonymizedTables: string[];
|
|
1962
|
+
retainedTables: string[];
|
|
1963
|
+
externalApiCalls: ExternalApiCall[];
|
|
1964
|
+
errors: Array<{
|
|
1965
|
+
table: string;
|
|
1966
|
+
error: string;
|
|
1967
|
+
}>;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* GDPR Erasure Engine (Article 17 - Right to be Forgotten)
|
|
1972
|
+
* Cascading deletion with external API cleanup
|
|
1973
|
+
*/
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Perform cascading deletion based on compliance map
|
|
1977
|
+
*
|
|
1978
|
+
* This function:
|
|
1979
|
+
* 1. Reads the compliance-map.json configuration
|
|
1980
|
+
* 2. Executes cascading deletions in dependency order
|
|
1981
|
+
* 3. Calls external APIs for cleanup (Supabase, Stripe, SendGrid)
|
|
1982
|
+
* 4. Creates an audit trail of all actions
|
|
1983
|
+
*
|
|
1984
|
+
* @example
|
|
1985
|
+
* const result = await obliterateUserData('user-123');
|
|
1986
|
+
* // Returns: { deletedTables: [...], anonymizedTables: [...], ... }
|
|
1987
|
+
*/
|
|
1988
|
+
declare function obliterateUserData(userId: string, entityType?: 'user' | 'project' | 'website'): Promise<DeletionResult>;
|
|
1989
|
+
/**
|
|
1990
|
+
* Check deletion status for a user
|
|
1991
|
+
*/
|
|
1992
|
+
declare function checkDeletionStatus(userId: string): Promise<{
|
|
1993
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'not_found';
|
|
1994
|
+
tracker?: DeletionTracker;
|
|
1995
|
+
}>;
|
|
1996
|
+
/**
|
|
1997
|
+
* Schedule delayed deletion (30-day grace period)
|
|
1998
|
+
*
|
|
1999
|
+
* This creates a pending deletion that can be cancelled within 30 days
|
|
2000
|
+
*
|
|
2001
|
+
* @example
|
|
2002
|
+
* const deletionId = await scheduleDeletion('user-123');
|
|
2003
|
+
* // User can cancel within 30 days
|
|
2004
|
+
*/
|
|
2005
|
+
declare function scheduleDeletion(userId: string, entityType?: 'user' | 'project' | 'website', delayDays?: number): Promise<string>;
|
|
2006
|
+
/**
|
|
2007
|
+
* Cancel scheduled deletion
|
|
2008
|
+
*
|
|
2009
|
+
* @example
|
|
2010
|
+
* await cancelScheduledDeletion('deletion-id-123');
|
|
2011
|
+
*/
|
|
2012
|
+
declare function cancelScheduledDeletion(deletionId: string): Promise<void>;
|
|
2013
|
+
/**
|
|
2014
|
+
* Process scheduled deletions (should be called by cron job)
|
|
2015
|
+
*
|
|
2016
|
+
* @example
|
|
2017
|
+
* const processed = await processScheduledDeletions();
|
|
2018
|
+
*/
|
|
2019
|
+
declare function processScheduledDeletions(limit?: number): Promise<number>;
|
|
2020
|
+
/**
|
|
2021
|
+
* Export the obliterate module
|
|
2022
|
+
*/
|
|
2023
|
+
declare const obliterate: {
|
|
2024
|
+
userData: typeof obliterateUserData;
|
|
2025
|
+
checkStatus: typeof checkDeletionStatus;
|
|
2026
|
+
schedule: typeof scheduleDeletion;
|
|
2027
|
+
cancel: typeof cancelScheduledDeletion;
|
|
2028
|
+
processScheduled: typeof processScheduledDeletions;
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* Main privacy/GDPR API
|
|
2033
|
+
*
|
|
2034
|
+
* @example
|
|
2035
|
+
* import { privacy } from '@vocoweb/kernel';
|
|
2036
|
+
*
|
|
2037
|
+
* // GDPR deletion (right to be forgotten)
|
|
2038
|
+
* const result = await privacy.obliterate('user-123');
|
|
2039
|
+
*
|
|
2040
|
+
* // GDPR data export
|
|
2041
|
+
* const exportData = await privacy.exportUserData('user-123');
|
|
2042
|
+
*/
|
|
2043
|
+
declare const privacy: {
|
|
2044
|
+
obliterate: typeof obliterateUserData;
|
|
2045
|
+
exportUserData: typeof exportUserData;
|
|
2046
|
+
checkDeletionStatus: (userId: string) => Promise<{
|
|
2047
|
+
status: "pending" | "processing" | "completed" | "failed" | "not_found";
|
|
2048
|
+
tracker?: DeletionTracker;
|
|
2049
|
+
}>;
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* Accessibility validators for WCAG 2.1 AA compliance
|
|
2054
|
+
*/
|
|
2055
|
+
|
|
2056
|
+
/**
|
|
2057
|
+
* Check color contrast ratio against WCAG standards
|
|
2058
|
+
*
|
|
2059
|
+
* @param foreground - Foreground color (hex)
|
|
2060
|
+
* @param background - Background color (hex)
|
|
2061
|
+
* @returns Contrast result with WCAG AA/AAA compliance
|
|
2062
|
+
*
|
|
2063
|
+
* @example
|
|
2064
|
+
* const result = checkColorContrast('#ffffff', '#000000');
|
|
2065
|
+
* // Returns: { ratio: 21, aa: true, aaa: true, ... }
|
|
2066
|
+
*/
|
|
2067
|
+
declare function checkColorContrast(foreground: string, background: string): ContrastResult;
|
|
2068
|
+
/**
|
|
2069
|
+
* Validate ARIA attributes on an element
|
|
2070
|
+
*
|
|
2071
|
+
* @param ariaLabel - ARIA label value
|
|
2072
|
+
* @param ariaLabelledby - ARIA labelledby value
|
|
2073
|
+
* @param elementType - Type of element (button, input, etc.)
|
|
2074
|
+
* @returns Validation result with any issues found
|
|
2075
|
+
*
|
|
2076
|
+
* @example
|
|
2077
|
+
* const result = validateAriaLabel(undefined, undefined, 'button');
|
|
2078
|
+
* // Returns: { valid: false, issues: [{ severity: 'error', message: '...' }] }
|
|
2079
|
+
*/
|
|
2080
|
+
declare function validateAriaLabel(ariaLabel?: string, ariaLabelledby?: string, elementType?: string): AriaValidationResult;
|
|
2081
|
+
/**
|
|
2082
|
+
* Test keyboard navigation for a component
|
|
2083
|
+
*
|
|
2084
|
+
* @param element - DOM element to test
|
|
2085
|
+
* @returns Keyboard navigation result
|
|
2086
|
+
*
|
|
2087
|
+
* @example
|
|
2088
|
+
* const button = document.querySelector('button');
|
|
2089
|
+
* const result = testKeyboardNavigation(button);
|
|
2090
|
+
*/
|
|
2091
|
+
declare function testKeyboardNavigation(element: unknown): KeyboardNavigationResult;
|
|
2092
|
+
/**
|
|
2093
|
+
* Run comprehensive accessibility audit on a color scheme
|
|
2094
|
+
*
|
|
2095
|
+
* @param colors - Object with foreground and background colors
|
|
2096
|
+
* @param level - WCAG compliance level to test against
|
|
2097
|
+
* @returns Array of accessibility violations
|
|
2098
|
+
*
|
|
2099
|
+
* @example
|
|
2100
|
+
* const violations = auditColorScheme({
|
|
2101
|
+
* primary: '#ffffff',
|
|
2102
|
+
* background: '#000000'
|
|
2103
|
+
* }, 'AA');
|
|
2104
|
+
*/
|
|
2105
|
+
declare function auditColorScheme(colors: Record<string, {
|
|
2106
|
+
foreground?: string;
|
|
2107
|
+
background?: string;
|
|
2108
|
+
}>, level?: ComplianceLevel): AccessibilityViolation[];
|
|
2109
|
+
/**
|
|
2110
|
+
* Validate that all interactive elements have accessible names
|
|
2111
|
+
*
|
|
2112
|
+
* @param elements - Array of element descriptors
|
|
2113
|
+
* @returns Array of accessibility violations
|
|
2114
|
+
*/
|
|
2115
|
+
declare function validateInteractiveElements(elements: Array<{
|
|
2116
|
+
type: string;
|
|
2117
|
+
hasLabel?: boolean;
|
|
2118
|
+
hasAriaLabel?: string;
|
|
2119
|
+
id?: string;
|
|
2120
|
+
}>): AccessibilityViolation[];
|
|
2121
|
+
/**
|
|
2122
|
+
* Check if a focus indicator meets WCAG requirements
|
|
2123
|
+
*
|
|
2124
|
+
* @param element - CSS selector or element to check
|
|
2125
|
+
* @returns Whether the focus indicator is sufficient
|
|
2126
|
+
*/
|
|
2127
|
+
declare function validateFocusIndicator(element: unknown): boolean;
|
|
2128
|
+
/**
|
|
2129
|
+
* Get suggested color pairings for improved contrast
|
|
2130
|
+
*
|
|
2131
|
+
* @param color - Color to find pairings for
|
|
2132
|
+
* @param targetRatio - Target contrast ratio (default 4.5 for AA)
|
|
2133
|
+
* @returns Array of suggested colors with their contrast ratios
|
|
2134
|
+
*/
|
|
2135
|
+
declare function getSuggestedColorPairings(color: string, targetRatio?: number): Array<{
|
|
2136
|
+
color: string;
|
|
2137
|
+
ratio: number;
|
|
2138
|
+
}>;
|
|
2139
|
+
/**
|
|
2140
|
+
* Accessibility validators API
|
|
2141
|
+
*/
|
|
2142
|
+
declare const validators: {
|
|
2143
|
+
checkColorContrast: typeof checkColorContrast;
|
|
2144
|
+
validateAriaLabel: typeof validateAriaLabel;
|
|
2145
|
+
testKeyboardNavigation: typeof testKeyboardNavigation;
|
|
2146
|
+
auditColorScheme: typeof auditColorScheme;
|
|
2147
|
+
validateInteractiveElements: typeof validateInteractiveElements;
|
|
2148
|
+
validateFocusIndicator: typeof validateFocusIndicator;
|
|
2149
|
+
getSuggestedColorPairings: typeof getSuggestedColorPairings;
|
|
2150
|
+
};
|
|
2151
|
+
/**
|
|
2152
|
+
* Create a contrast error with suggestions
|
|
2153
|
+
*/
|
|
2154
|
+
declare function throwContrastError(fg: string, bg: string, ratio: number): never;
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* Module 2: EAA Enforcer (Accessibility)
|
|
2158
|
+
* WCAG 2.1 AA compliant components and validators
|
|
2159
|
+
*/
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* Main accessibility API
|
|
2163
|
+
*
|
|
2164
|
+
* @example
|
|
2165
|
+
* import { accessibility } from '@vocoweb/kernel';
|
|
2166
|
+
*
|
|
2167
|
+
* // Check color contrast
|
|
2168
|
+
* const result = accessibility.checkColorContrast('#ffffff', '#000000');
|
|
2169
|
+
*
|
|
2170
|
+
* // Validate ARIA labels
|
|
2171
|
+
* const validation = accessibility.validateAriaLabel(undefined, undefined, 'button');
|
|
2172
|
+
*/
|
|
2173
|
+
declare const accessibility: {
|
|
2174
|
+
checkColorContrast: typeof checkColorContrast;
|
|
2175
|
+
validateAriaLabel: typeof validateAriaLabel;
|
|
2176
|
+
testKeyboardNavigation: typeof testKeyboardNavigation;
|
|
2177
|
+
auditColorScheme: typeof auditColorScheme;
|
|
2178
|
+
validateFocusIndicator: typeof validateFocusIndicator;
|
|
2179
|
+
getSuggestedColorPairings: typeof getSuggestedColorPairings;
|
|
2180
|
+
validateInteractiveElements: typeof validateInteractiveElements;
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* Data Residency type definitions for GDPR compliance
|
|
2185
|
+
*/
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* IP geolocation result
|
|
2189
|
+
*/
|
|
2190
|
+
interface IpGeolocation {
|
|
2191
|
+
ip: string;
|
|
2192
|
+
country: string;
|
|
2193
|
+
region?: string;
|
|
2194
|
+
city?: string;
|
|
2195
|
+
isEu: boolean;
|
|
2196
|
+
latitude?: number;
|
|
2197
|
+
longitude?: number;
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Destination rule
|
|
2201
|
+
*/
|
|
2202
|
+
interface DestinationRule {
|
|
2203
|
+
pattern: string | RegExp;
|
|
2204
|
+
allowedRegions: DataRegion[];
|
|
2205
|
+
description?: string;
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Data residency configuration
|
|
2209
|
+
*/
|
|
2210
|
+
interface DataResidencyConfig {
|
|
2211
|
+
/**
|
|
2212
|
+
* Default region for data storage
|
|
2213
|
+
*/
|
|
2214
|
+
defaultRegion: DataRegion;
|
|
2215
|
+
/**
|
|
2216
|
+
* Allowed regions for data processing
|
|
2217
|
+
*/
|
|
2218
|
+
allowedRegions: DataRegion[];
|
|
2219
|
+
/**
|
|
2220
|
+
* Blocked destinations (patterns)
|
|
2221
|
+
*/
|
|
2222
|
+
blockedDestinations: string[];
|
|
2223
|
+
/**
|
|
2224
|
+
* Allowed destinations with region restrictions
|
|
2225
|
+
*/
|
|
2226
|
+
destinationRules: DestinationRule[];
|
|
2227
|
+
/**
|
|
2228
|
+
* Whether to block all non-EU egress
|
|
2229
|
+
*/
|
|
2230
|
+
blockNonEuEgress: boolean;
|
|
2231
|
+
/**
|
|
2232
|
+
* Supabase region (for detecting if requests stay within EU)
|
|
2233
|
+
*/
|
|
2234
|
+
supabaseRegion: string;
|
|
2235
|
+
/**
|
|
2236
|
+
* Custom headers to check for region
|
|
2237
|
+
*/
|
|
2238
|
+
regionHeaders?: string[];
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Request analysis result
|
|
2242
|
+
*/
|
|
2243
|
+
interface RequestAnalysis {
|
|
2244
|
+
url: string;
|
|
2245
|
+
method: string;
|
|
2246
|
+
destination: string;
|
|
2247
|
+
region: DataRegion;
|
|
2248
|
+
allowed: boolean;
|
|
2249
|
+
reason?: string;
|
|
2250
|
+
matchedRule?: DestinationRule;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Egress block event
|
|
2254
|
+
*/
|
|
2255
|
+
interface EgressBlockEvent {
|
|
2256
|
+
timestamp: Date;
|
|
2257
|
+
ip: string;
|
|
2258
|
+
url: string;
|
|
2259
|
+
method: string;
|
|
2260
|
+
region: DataRegion;
|
|
2261
|
+
reason: string;
|
|
2262
|
+
userId?: string;
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Middleware options
|
|
2266
|
+
*/
|
|
2267
|
+
interface MiddlewareOptions {
|
|
2268
|
+
/**
|
|
2269
|
+
* Custom configuration
|
|
2270
|
+
*/
|
|
2271
|
+
config?: Partial<DataResidencyConfig>;
|
|
2272
|
+
/**
|
|
2273
|
+
* Paths to exclude from checks
|
|
2274
|
+
*/
|
|
2275
|
+
excludePaths?: string[];
|
|
2276
|
+
/**
|
|
2277
|
+
* Handler for blocked requests
|
|
2278
|
+
*/
|
|
2279
|
+
onBlocked?: (event: EgressBlockEvent) => void | Promise<void>;
|
|
2280
|
+
/**
|
|
2281
|
+
* Whether to log allowed requests
|
|
2282
|
+
*/
|
|
2283
|
+
logAllowed?: boolean;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
/**
|
|
2287
|
+
* Region detection and IP geolocation
|
|
2288
|
+
*/
|
|
2289
|
+
|
|
2290
|
+
/**
|
|
2291
|
+
* Supabase EU regions
|
|
2292
|
+
*/
|
|
2293
|
+
declare const SUPABASE_EU_REGIONS: string[];
|
|
2294
|
+
/**
|
|
2295
|
+
* Detect region from IP address
|
|
2296
|
+
* Uses a free IP geolocation API or falls back to headers
|
|
2297
|
+
*
|
|
2298
|
+
* @param ip - IP address to detect
|
|
2299
|
+
* @param headers - Optional headers for region detection
|
|
2300
|
+
* @returns Detected region
|
|
2301
|
+
*/
|
|
2302
|
+
declare function detectRegion(ip: string, headers?: Record<string, string | undefined>): Promise<DataRegion>;
|
|
2303
|
+
/**
|
|
2304
|
+
* Detect region from request headers
|
|
2305
|
+
*/
|
|
2306
|
+
declare function detectRegionFromHeaders(headers?: Record<string, string | undefined>): DataRegion | null;
|
|
2307
|
+
/**
|
|
2308
|
+
* Get IP geolocation information
|
|
2309
|
+
*
|
|
2310
|
+
* @param ip - IP address to lookup
|
|
2311
|
+
* @returns Geolocation information
|
|
2312
|
+
*/
|
|
2313
|
+
declare function getIpGeolocation(ip: string): Promise<IpGeolocation>;
|
|
2314
|
+
/**
|
|
2315
|
+
* Check if an IP is private/local
|
|
2316
|
+
*/
|
|
2317
|
+
declare function isPrivateIp(ip: string): boolean;
|
|
2318
|
+
/**
|
|
2319
|
+
* Parse IP from headers (handles X-Forwarded-For, etc.)
|
|
2320
|
+
*/
|
|
2321
|
+
declare function parseIpFromHeaders(headers: Record<string, string | undefined>): string;
|
|
2322
|
+
/**
|
|
2323
|
+
* Detect if a URL points to an EU-hosted service
|
|
2324
|
+
*/
|
|
2325
|
+
declare function detectUrlRegion(url: string): DataRegion;
|
|
2326
|
+
/**
|
|
2327
|
+
* Region detection API
|
|
2328
|
+
*/
|
|
2329
|
+
declare const detector: {
|
|
2330
|
+
detectRegion: typeof detectRegion;
|
|
2331
|
+
detectRegionFromHeaders: typeof detectRegionFromHeaders;
|
|
2332
|
+
getIpGeolocation: typeof getIpGeolocation;
|
|
2333
|
+
isPrivateIp: typeof isPrivateIp;
|
|
2334
|
+
parseIpFromHeaders: typeof parseIpFromHeaders;
|
|
2335
|
+
detectUrlRegion: typeof detectUrlRegion;
|
|
2336
|
+
isEuCountry: typeof isEuCountry;
|
|
2337
|
+
};
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Destination whitelist management
|
|
2341
|
+
* Controls which external services and endpoints can be called
|
|
2342
|
+
*/
|
|
2343
|
+
|
|
2344
|
+
/**
|
|
2345
|
+
* Default allowed destinations for EU data residency
|
|
2346
|
+
*/
|
|
2347
|
+
declare const DEFAULT_ALLOWED_DESTINATIONS: DestinationRule[];
|
|
2348
|
+
/**
|
|
2349
|
+
* Default blocked destinations (high-risk)
|
|
2350
|
+
*/
|
|
2351
|
+
declare const DEFAULT_BLOCKED_DESTINATIONS: string[];
|
|
2352
|
+
/**
|
|
2353
|
+
* Check if a destination is allowed based on rules
|
|
2354
|
+
*
|
|
2355
|
+
* @param url - Destination URL
|
|
2356
|
+
* @param rules - Destination rules to check
|
|
2357
|
+
* @param currentRegion - Current data region
|
|
2358
|
+
* @returns Whether the destination is allowed
|
|
2359
|
+
*/
|
|
2360
|
+
declare function checkDestinationAgainstRules(url: string, rules: DestinationRule[], currentRegion?: string): {
|
|
2361
|
+
allowed: boolean;
|
|
2362
|
+
matchedRule?: DestinationRule;
|
|
2363
|
+
reason?: string;
|
|
2364
|
+
};
|
|
2365
|
+
/**
|
|
2366
|
+
* Create a custom whitelist configuration
|
|
2367
|
+
*/
|
|
2368
|
+
declare function createWhitelist(customRules: Partial<DestinationRule>[]): DestinationRule[];
|
|
2369
|
+
/**
|
|
2370
|
+
* Validate whitelist configuration
|
|
2371
|
+
*/
|
|
2372
|
+
declare function validateWhitelist(rules: DestinationRule[]): {
|
|
2373
|
+
valid: boolean;
|
|
2374
|
+
errors: string[];
|
|
2375
|
+
};
|
|
2376
|
+
/**
|
|
2377
|
+
* Add a destination to the whitelist
|
|
2378
|
+
*/
|
|
2379
|
+
declare function addToWhitelist(rules: DestinationRule[], newRule: DestinationRule): DestinationRule[];
|
|
2380
|
+
/**
|
|
2381
|
+
* Remove a destination from the whitelist
|
|
2382
|
+
*/
|
|
2383
|
+
declare function removeFromWhitelist(rules: DestinationRule[], pattern: string | RegExp): DestinationRule[];
|
|
2384
|
+
/**
|
|
2385
|
+
* Get whitelist statistics
|
|
2386
|
+
*/
|
|
2387
|
+
declare function getWhitelistStats(rules: DestinationRule[]): {
|
|
2388
|
+
total: number;
|
|
2389
|
+
byRegion: Record<string, number>;
|
|
2390
|
+
};
|
|
2391
|
+
/**
|
|
2392
|
+
* Whitelist management API
|
|
2393
|
+
*/
|
|
2394
|
+
declare const whitelist: {
|
|
2395
|
+
DEFAULT_ALLOWED_DESTINATIONS: DestinationRule[];
|
|
2396
|
+
DEFAULT_BLOCKED_DESTINATIONS: string[];
|
|
2397
|
+
checkDestinationAgainstRules: typeof checkDestinationAgainstRules;
|
|
2398
|
+
createWhitelist: typeof createWhitelist;
|
|
2399
|
+
validateWhitelist: typeof validateWhitelist;
|
|
2400
|
+
addToWhitelist: typeof addToWhitelist;
|
|
2401
|
+
removeFromWhitelist: typeof removeFromWhitelist;
|
|
2402
|
+
getWhitelistStats: typeof getWhitelistStats;
|
|
2403
|
+
};
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* Next.js middleware for data residency enforcement
|
|
2407
|
+
* Blocks outgoing requests to non-EU destinations
|
|
2408
|
+
*/
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Default configuration
|
|
2412
|
+
*/
|
|
2413
|
+
declare const DEFAULT_CONFIG: {
|
|
2414
|
+
defaultRegion: DataRegion;
|
|
2415
|
+
allowedRegions: DataRegion[];
|
|
2416
|
+
blockedDestinations: string[];
|
|
2417
|
+
destinationRules: typeof whitelist.DEFAULT_ALLOWED_DESTINATIONS;
|
|
2418
|
+
blockNonEuEgress: boolean;
|
|
2419
|
+
supabaseRegion: string;
|
|
2420
|
+
regionHeaders: string[];
|
|
2421
|
+
};
|
|
2422
|
+
/**
|
|
2423
|
+
* Create a Next.js middleware for data residency
|
|
2424
|
+
*
|
|
2425
|
+
* @example
|
|
2426
|
+
* // middleware.ts
|
|
2427
|
+
* import { createDataResidencyMiddleware } from '@vocoweb/kernel/residency';
|
|
2428
|
+
*
|
|
2429
|
+
* export default createDataResidencyMiddleware({
|
|
2430
|
+
* blockNonEuEgress: true,
|
|
2431
|
+
* onBlocked: async (event) => {
|
|
2432
|
+
* console.log('Blocked egress:', event);
|
|
2433
|
+
* }
|
|
2434
|
+
* });
|
|
2435
|
+
*/
|
|
2436
|
+
declare function createDataResidencyMiddleware(options?: MiddlewareOptions): (request: Request) => Promise<Response | undefined>;
|
|
2437
|
+
/**
|
|
2438
|
+
* Analyze a request to determine if it's allowed
|
|
2439
|
+
*/
|
|
2440
|
+
declare function analyzeRequest(request: Request, currentRegion: DataRegion, config: typeof DEFAULT_CONFIG): RequestAnalysis;
|
|
2441
|
+
/**
|
|
2442
|
+
* Validate a destination against the residency policy
|
|
2443
|
+
*
|
|
2444
|
+
* @example
|
|
2445
|
+
* const result = isDestinationAllowed('https://api.example.com', 'eu');
|
|
2446
|
+
* // Returns: { allowed: false, reason: '...' }
|
|
2447
|
+
*/
|
|
2448
|
+
declare function isDestinationAllowed(url: string, clientRegion?: DataRegion, config?: Partial<typeof DEFAULT_CONFIG>): Promise<{
|
|
2449
|
+
allowed: boolean;
|
|
2450
|
+
reason?: string;
|
|
2451
|
+
}>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Create a fetch wrapper that enforces data residency
|
|
2454
|
+
*
|
|
2455
|
+
* @example
|
|
2456
|
+
* const safeFetch = createSafeFetch({ blockNonEuEgress: true });
|
|
2457
|
+
* await safeFetch('https://api.example.com/data');
|
|
2458
|
+
*/
|
|
2459
|
+
declare function createSafeFetch(options?: MiddlewareOptions): (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
2460
|
+
/**
|
|
2461
|
+
* Middleware and utilities API
|
|
2462
|
+
*/
|
|
2463
|
+
declare const middleware: {
|
|
2464
|
+
create: typeof createDataResidencyMiddleware;
|
|
2465
|
+
analyzeRequest: typeof analyzeRequest;
|
|
2466
|
+
isDestinationAllowed: typeof isDestinationAllowed;
|
|
2467
|
+
createSafeFetch: typeof createSafeFetch;
|
|
2468
|
+
};
|
|
2469
|
+
|
|
2470
|
+
/**
|
|
2471
|
+
* Module 3: Sovereignty Shield (Data Residency)
|
|
2472
|
+
* Egress blocking for GDPR compliance
|
|
2473
|
+
*/
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* Main data residency API
|
|
2477
|
+
*
|
|
2478
|
+
* @example
|
|
2479
|
+
* import { residency } from '@vocoweb/kernel';
|
|
2480
|
+
*
|
|
2481
|
+
* // Check if a destination is allowed
|
|
2482
|
+
* const result = await residency.isDestinationAllowed('https://api.example.com', 'eu');
|
|
2483
|
+
*
|
|
2484
|
+
* // Create a middleware
|
|
2485
|
+
* const middleware = residency.createMiddleware({ blockNonEuEgress: true });
|
|
2486
|
+
*
|
|
2487
|
+
* // Create a safe fetch wrapper
|
|
2488
|
+
* const safeFetch = residency.createSafeFetch();
|
|
2489
|
+
*/
|
|
2490
|
+
declare const residency: {
|
|
2491
|
+
detectRegion: typeof detectRegion;
|
|
2492
|
+
detectUrlRegion: typeof detectUrlRegion;
|
|
2493
|
+
parseIpFromHeaders: typeof parseIpFromHeaders;
|
|
2494
|
+
isDestinationAllowed: typeof isDestinationAllowed;
|
|
2495
|
+
createMiddleware: typeof createDataResidencyMiddleware;
|
|
2496
|
+
createSafeFetch: typeof createSafeFetch;
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* Audit Log Recorder
|
|
2501
|
+
* Shadow recording for database mutations
|
|
2502
|
+
*/
|
|
2503
|
+
|
|
2504
|
+
/**
|
|
2505
|
+
* Configure audit recorder
|
|
2506
|
+
*
|
|
2507
|
+
* @example
|
|
2508
|
+
* configureRecorder({
|
|
2509
|
+
* excludeTables: ['temp_tables'],
|
|
2510
|
+
* batchSize: 200
|
|
2511
|
+
* });
|
|
2512
|
+
*/
|
|
2513
|
+
declare function configureRecorder(config: Partial<AuditRecorderConfig>): void;
|
|
2514
|
+
/**
|
|
2515
|
+
* Record a database mutation
|
|
2516
|
+
*
|
|
2517
|
+
* @param tableName - Table being modified
|
|
2518
|
+
* @param action - Type of action
|
|
2519
|
+
* @param recordId - ID of the record
|
|
2520
|
+
* @param oldValue - Old value (for UPDATE/DELETE)
|
|
2521
|
+
* @param newValue - New value (for INSERT/UPDATE)
|
|
2522
|
+
* @param userId - User making the change
|
|
2523
|
+
* @param metadata - Additional metadata
|
|
2524
|
+
*
|
|
2525
|
+
* @example
|
|
2526
|
+
* await recordMutation(
|
|
2527
|
+
* 'users',
|
|
2528
|
+
* 'UPDATE',
|
|
2529
|
+
* 'user-123',
|
|
2530
|
+
* { name: 'Old Name' },
|
|
2531
|
+
* { name: 'New Name' },
|
|
2532
|
+
* 'user-456'
|
|
2533
|
+
* );
|
|
2534
|
+
*/
|
|
2535
|
+
declare function recordMutation(tableName: string, action: AuditAction, recordId: string, oldValue: Record<string, unknown> | null, newValue: Record<string, unknown> | null, userId: string, metadata?: Record<string, unknown>): Promise<void>;
|
|
2536
|
+
/**
|
|
2537
|
+
* Flush pending records to database
|
|
2538
|
+
*/
|
|
2539
|
+
declare function flushRecords(): Promise<void>;
|
|
2540
|
+
/**
|
|
2541
|
+
* Query audit logs
|
|
2542
|
+
*
|
|
2543
|
+
* @param filters - Query filters
|
|
2544
|
+
* @returns Query result
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* const result = await queryLogs({
|
|
2548
|
+
* userId: 'user-123',
|
|
2549
|
+
* action: 'UPDATE',
|
|
2550
|
+
* limit: 50
|
|
2551
|
+
* });
|
|
2552
|
+
*/
|
|
2553
|
+
declare function queryLogs(filters?: AuditQueryFilters): Promise<{
|
|
2554
|
+
logs: Array<{
|
|
2555
|
+
id: string;
|
|
2556
|
+
tableName: string;
|
|
2557
|
+
recordId: string;
|
|
2558
|
+
action: AuditAction;
|
|
2559
|
+
oldValue: Record<string, unknown> | null;
|
|
2560
|
+
newValue: Record<string, unknown> | null;
|
|
2561
|
+
userId: string;
|
|
2562
|
+
timestamp: Date;
|
|
2563
|
+
}>;
|
|
2564
|
+
total: number;
|
|
2565
|
+
hasMore: boolean;
|
|
2566
|
+
}>;
|
|
2567
|
+
/**
|
|
2568
|
+
* Export audit logs as CSV
|
|
2569
|
+
*
|
|
2570
|
+
* @param filters - Query filters
|
|
2571
|
+
* @returns CSV string
|
|
2572
|
+
*
|
|
2573
|
+
* @example
|
|
2574
|
+
* const csv = await exportAuditLogs({ userId: 'user-123' });
|
|
2575
|
+
*/
|
|
2576
|
+
declare function exportAuditLogs(filters?: AuditQueryFilters): Promise<string>;
|
|
2577
|
+
/**
|
|
2578
|
+
* Get audit statistics for a user
|
|
2579
|
+
*
|
|
2580
|
+
* @param userId - User ID
|
|
2581
|
+
* @returns Statistics
|
|
2582
|
+
*/
|
|
2583
|
+
declare function getAuditStats(userId: string): Promise<{
|
|
2584
|
+
total: number;
|
|
2585
|
+
byAction: Record<string, number>;
|
|
2586
|
+
byTable: Record<string, number>;
|
|
2587
|
+
lastActivity: Date | null;
|
|
2588
|
+
}>;
|
|
2589
|
+
/**
|
|
2590
|
+
* Create database trigger for audit logging
|
|
2591
|
+
*
|
|
2592
|
+
* This generates the SQL for creating a PostgreSQL trigger
|
|
2593
|
+
*
|
|
2594
|
+
* @example
|
|
2595
|
+
* const sql = createTriggerSQL('users', ['id', 'email', 'name']);
|
|
2596
|
+
*/
|
|
2597
|
+
declare function createTriggerSQL(tableName: string, _trackFields?: string[]): string;
|
|
2598
|
+
/**
|
|
2599
|
+
* Create audit triggers for multiple tables
|
|
2600
|
+
*
|
|
2601
|
+
* @param tables - Tables to create triggers for
|
|
2602
|
+
* @returns SQL for all triggers
|
|
2603
|
+
*/
|
|
2604
|
+
declare function createTriggersForTables(tables: string[]): string;
|
|
2605
|
+
/**
|
|
2606
|
+
* Audit recorder API
|
|
2607
|
+
*/
|
|
2608
|
+
declare const recorder: {
|
|
2609
|
+
configure: typeof configureRecorder;
|
|
2610
|
+
recordMutation: typeof recordMutation;
|
|
2611
|
+
flushRecords: typeof flushRecords;
|
|
2612
|
+
queryLogs: typeof queryLogs;
|
|
2613
|
+
exportAuditLogs: typeof exportAuditLogs;
|
|
2614
|
+
getAuditStats: typeof getAuditStats;
|
|
2615
|
+
createTriggerSQL: typeof createTriggerSQL;
|
|
2616
|
+
createTriggersForTables: typeof createTriggersForTables;
|
|
2617
|
+
};
|
|
2618
|
+
|
|
2619
|
+
/**
|
|
2620
|
+
* Module 4: Audit Log (Enterprise)
|
|
2621
|
+
* Shadow recording for database mutations
|
|
2622
|
+
*/
|
|
2623
|
+
|
|
2624
|
+
/**
|
|
2625
|
+
* Main audit API
|
|
2626
|
+
*
|
|
2627
|
+
* @example
|
|
2628
|
+
* import { audit } from '@vocoweb/kernel';
|
|
2629
|
+
*
|
|
2630
|
+
* // Record a mutation
|
|
2631
|
+
* await audit.recordMutation(
|
|
2632
|
+
* 'users',
|
|
2633
|
+
* 'UPDATE',
|
|
2634
|
+
* 'user-123',
|
|
2635
|
+
* { name: 'Old Name' },
|
|
2636
|
+
* { name: 'New Name' },
|
|
2637
|
+
* 'user-456'
|
|
2638
|
+
* );
|
|
2639
|
+
*
|
|
2640
|
+
* // Query logs
|
|
2641
|
+
* const result = await audit.queryLogs({ userId: 'user-123' });
|
|
2642
|
+
*
|
|
2643
|
+
* // Export logs
|
|
2644
|
+
* const csv = await audit.exportAuditLogs({ userId: 'user-123' });
|
|
2645
|
+
*/
|
|
2646
|
+
declare const audit: {
|
|
2647
|
+
configure: typeof configureRecorder;
|
|
2648
|
+
recordMutation: typeof recordMutation;
|
|
2649
|
+
flushRecords: typeof flushRecords;
|
|
2650
|
+
queryLogs: typeof queryLogs;
|
|
2651
|
+
getAuditStats: typeof getAuditStats;
|
|
2652
|
+
exportAuditLogs: typeof exportAuditLogs;
|
|
2653
|
+
createTriggerSQL: typeof createTriggerSQL;
|
|
2654
|
+
createTriggersForTables: typeof createTriggersForTables;
|
|
2655
|
+
};
|
|
2656
|
+
|
|
2657
|
+
/**
|
|
2658
|
+
* @vocoweb/kernel
|
|
2659
|
+
*
|
|
2660
|
+
* Production-ready authentication, payments, and compliance kernel for B2B SaaS.
|
|
2661
|
+
*
|
|
2662
|
+
* @example
|
|
2663
|
+
* ```ts
|
|
2664
|
+
* import { auth, billing, legal, privacy } from '@vocoweb/kernel';
|
|
2665
|
+
* ```
|
|
2666
|
+
*/
|
|
2667
|
+
|
|
2668
|
+
declare const VERSION = "1.0.0";
|
|
2669
|
+
|
|
2670
|
+
export { type AccessibilityConfig, AccessibilityViolation, type AppConfig, AriaValidationResult, AuditAction, AuditQueryFilters, AuditRecorderConfig, type AuthRequest, type AuthStateChangeCallback, type AuthSubscription, BillingClient, type CheckoutOptions, type CheckoutResult, ClientType, ComplianceLevel, type ComplianceMap, type ComplianceMapConfig, ContrastResult, type Customer, DEFAULT_ALLOWED_DESTINATIONS, DEFAULT_BLOCKED_DESTINATIONS, type DataExportRecord, DataRegion, type DataResidencyConfig, type DeletionResult, type DeletionStatusDetails, type DeletionTracker, type DependencyAction, type DestinationRule, EU_COUNTRY_CODES, type EgressBlockEvent, type ExternalApiCall, type ExternalApiConfig, type Invoice, type InvoiceStatus, type IpGeolocation, type KernelConfig, KeyboardNavigationResult, type MiddlewareOptions, type OAuthOptions, type OAuthProvider, type PaymentMethodType, type PortalOptions, type Price, type Product, type RequestAnalysis, type ResetPasswordOptions, type ResidencyConfig, SUPABASE_EU_REGIONS, type ScheduledDeletion, type SignInWithPasswordOptions, type SignUpOptions, type StripeConfig, type Subscription, type SubscriptionStatus, type SupabaseConfig, type TaxCalculation, type UpdateSubscriptionOptions, type UpdateUserOptions, type UserRole, type UserWithRole, VERSION, type VatInfo, type VerifiedUser, VocoAccessibilityError, VocoAuthClient, VocoAuthError, VocoBillingError, VocoComplianceError, VocoConfigError, VocoError, VocoNetworkError, VocoValidationError, type WebhookEvent, type WebhookEventHandler, WebhookEvents, accessibility, addToWhitelist, analyzeRequest, audit, auditColorScheme, auth, billing, calculateTax, camelToKebab, cancelScheduledDeletion, capitalize, checkColorContrast, checkDeletionStatus, checkDestinationAgainstRules, checkRequiredEnvVars, checkout$1 as checkout, chunk, clamp, clearVatCache, clientAuth, cn, config, configureRecorder, createCheckoutSession, createDataResidencyMiddleware, createDeferred, createExportFilename, createInvoice, createMiddleware, createPortalSession, createSafeFetch, createTriggerSQL, createTriggersForTables, createWhitelist, dataExport, debounce, decodeToken, deepClone, deleteUser, detectRegion, detectRegionFromHeaders, detectUrlRegion, detector, exportAuditLogs, exportUserData as exportUser, exportUserData, exportUserDataAsJson, expressWebhookHandler, filterDefined, flushRecords, formatApiError, formatCurrency, formatDate, formatList, formatRelativeTime, generateId, getAccessToken, getAccessibilityConfig, getAppConfig, getAuditStats, getBrowserClient, getCheckoutSession, getClient, getConfig, getEnv, getErrorMessage, getInitials, getInvoice, getInvoiceLines, getInvoices, getIpGeolocation, getProduct, getResidencyConfig, getServerClient, getServiceRoleClient, getSession, getStandardVatRate, getStripeConfig, getSuggestedColorPairings, getSupabaseConfig, getUpcomingInvoice, getUser, getUserById, getUserExport, getUserInvoices, getWhitelistStats, groupBy, handleWebhook, handleWebhookRequest, hasPendingExports, hasRole, invoices$1 as invoices, isAuthenticated, isBrowser, isClientInitialized, isDefined, isDestinationAllowed, isEuCountry, isPrivateIp, isServer, isValidEmail, isValidVatFormat, isVocoError, kebabToCamel, legal, exportUserData as legalExportUserData, listProducts, loadConfigFromEnv, loginWithGitHub, loginWithGoogle, loginWithOAuth, logout, middleware, obliterate, obliterateUserData, offWebhookEvent, onAuthStateChange, onWebhookEvent, parseIpFromHeaders, parseVatNumber, payInvoice, pluralize, privacy, processPendingExports, processScheduledDeletions, queryLogs, quickVatCheck, recordMutation, recorder, refreshSession, removeFromWhitelist, requestDataExport, requireRole, requireUser, resetClients, resetConfig, resetPassword, residency, retry, roundTo, safeJsonParse, scheduleDeletion, sendInvoice, serverAuth, setConfig, shouldApplyReverseCharge, loginWithOAuth as signInWithOAuth, signInWithPassword, signUp, sleep, testKeyboardNavigation, throttle, throwContrastError, truncate, updateUser, updateUserRole, validateAriaLabel, validateConfig, validateEnvironment, validateFocusIndicator, validateInteractiveElements, validateVat, validateWhitelist, validators, vat$1 as vat, verifySession, verifyToken, verifyWebhook, voidInvoice, webhook$1 as webhook, whitelist, withTimeout };
|