@revealui/core 0.3.0 → 0.5.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/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.js +20 -3
- package/dist/client/richtext/index.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
- package/dist/collections/operations/create.d.ts +2 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +28 -1
- package/dist/database/type-adapter.d.ts.map +1 -1
- package/dist/features.d.ts +7 -3
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +2 -0
- package/dist/globals/GlobalOperations.d.ts.map +1 -1
- package/dist/globals/GlobalOperations.js +12 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/license.d.ts +6 -0
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +14 -1
- package/dist/monitoring/alerts.d.ts +4 -4
- package/dist/monitoring/alerts.d.ts.map +1 -1
- package/dist/plugins/nested-docs.d.ts.map +1 -1
- package/dist/plugins/nested-docs.js +0 -1
- package/dist/queries/queryBuilder.d.ts.map +1 -1
- package/dist/queries/queryBuilder.js +4 -3
- package/dist/richtext/index.d.ts.map +1 -1
- package/dist/storage/vercel-blob.d.ts.map +1 -1
- package/dist/storage/vercel-blob.js +3 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/extensions.d.ts.map +1 -1
- package/dist/types/frontend.d.ts.map +1 -1
- package/dist/types/legacy.d.ts.map +1 -1
- package/dist/types/query.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/utils/error-responses.d.ts.map +1 -1
- package/dist/utils/error-responses.js +2 -3
- package/package.json +23 -23
- package/dist/caching/app-cache.d.ts +0 -242
- package/dist/caching/app-cache.d.ts.map +0 -1
- package/dist/caching/app-cache.js +0 -438
- package/dist/caching/cdn-config.d.ts +0 -155
- package/dist/caching/cdn-config.d.ts.map +0 -1
- package/dist/caching/cdn-config.js +0 -415
- package/dist/caching/edge-cache.d.ts +0 -177
- package/dist/caching/edge-cache.d.ts.map +0 -1
- package/dist/caching/edge-cache.js +0 -414
- package/dist/caching/service-worker.d.ts +0 -157
- package/dist/caching/service-worker.d.ts.map +0 -1
- package/dist/caching/service-worker.js +0 -438
- package/dist/client/admin/utils/auth.d.ts +0 -23
- package/dist/client/admin/utils/auth.d.ts.map +0 -1
- package/dist/client/admin/utils/auth.js +0 -52
- package/dist/client/http/client.d.ts +0 -15
- package/dist/client/http/client.d.ts.map +0 -1
- package/dist/client/http/client.js +0 -49
- package/dist/client/http/fetchBanner.d.ts +0 -18
- package/dist/client/http/fetchBanner.d.ts.map +0 -1
- package/dist/client/http/fetchBanner.js +0 -44
- package/dist/client/http/fetchCard.d.ts +0 -18
- package/dist/client/http/fetchCard.d.ts.map +0 -1
- package/dist/client/http/fetchCard.js +0 -46
- package/dist/client/http/fetchEvents.d.ts +0 -18
- package/dist/client/http/fetchEvents.d.ts.map +0 -1
- package/dist/client/http/fetchEvents.js +0 -44
- package/dist/client/http/fetchHero.d.ts +0 -17
- package/dist/client/http/fetchHero.d.ts.map +0 -1
- package/dist/client/http/fetchHero.js +0 -55
- package/dist/client/http/fetchMainInfos.d.ts +0 -17
- package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
- package/dist/client/http/fetchMainInfos.js +0 -44
- package/dist/client/http/fetchVideos.d.ts +0 -13
- package/dist/client/http/fetchVideos.d.ts.map +0 -1
- package/dist/client/http/fetchVideos.js +0 -36
- package/dist/client/http/index.d.ts +0 -19
- package/dist/client/http/index.d.ts.map +0 -1
- package/dist/client/http/index.js +0 -11
- package/dist/error-handling/circuit-breaker.d.ts +0 -262
- package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
- package/dist/error-handling/circuit-breaker.js +0 -550
- package/dist/error-handling/retry.d.ts +0 -194
- package/dist/error-handling/retry.d.ts.map +0 -1
- package/dist/error-handling/retry.js +0 -455
- package/dist/errors/index.d.ts +0 -23
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -40
- package/dist/generated/agents/index.d.ts +0 -8
- package/dist/generated/agents/index.d.ts.map +0 -1
- package/dist/generated/agents/index.js +0 -7
- package/dist/generated/components/index.d.ts +0 -8
- package/dist/generated/components/index.d.ts.map +0 -1
- package/dist/generated/components/index.js +0 -7
- package/dist/generated/functions/index.d.ts +0 -8
- package/dist/generated/functions/index.d.ts.map +0 -1
- package/dist/generated/functions/index.js +0 -7
- package/dist/generated/hooks/index.d.ts +0 -8
- package/dist/generated/hooks/index.d.ts.map +0 -1
- package/dist/generated/hooks/index.js +0 -7
- package/dist/generated/plans/index.d.ts +0 -8
- package/dist/generated/plans/index.d.ts.map +0 -1
- package/dist/generated/plans/index.js +0 -7
- package/dist/generated/prompts/index.d.ts +0 -8
- package/dist/generated/prompts/index.d.ts.map +0 -1
- package/dist/generated/prompts/index.js +0 -7
- package/dist/generated/tools/index.d.ts +0 -8
- package/dist/generated/tools/index.d.ts.map +0 -1
- package/dist/generated/tools/index.js +0 -7
- package/dist/generated/types/supabase.d.ts +0 -193
- package/dist/generated/types/supabase.d.ts.map +0 -1
- package/dist/generated/types/supabase.js +0 -5
- package/dist/optimization/asset-optimizer.d.ts +0 -206
- package/dist/optimization/asset-optimizer.d.ts.map +0 -1
- package/dist/optimization/asset-optimizer.js +0 -336
- package/dist/optimization/build-optimizer.d.ts +0 -202
- package/dist/optimization/build-optimizer.d.ts.map +0 -1
- package/dist/optimization/build-optimizer.js +0 -271
- package/dist/optimization/bundle-analyzer.d.ts +0 -98
- package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
- package/dist/optimization/bundle-analyzer.js +0 -346
- package/dist/optimization/code-splitting.d.ts +0 -121
- package/dist/optimization/code-splitting.d.ts.map +0 -1
- package/dist/optimization/code-splitting.js +0 -261
- package/dist/plugin/index.d.ts +0 -12
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -4
- package/dist/security/audit.d.ts +0 -188
- package/dist/security/audit.d.ts.map +0 -1
- package/dist/security/audit.js +0 -433
- package/dist/security/auth.d.ts +0 -110
- package/dist/security/auth.d.ts.map +0 -1
- package/dist/security/auth.js +0 -257
- package/dist/security/authorization.d.ts +0 -211
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -492
- package/dist/security/encryption.d.ts +0 -226
- package/dist/security/encryption.d.ts.map +0 -1
- package/dist/security/encryption.js +0 -534
- package/dist/security/gdpr-storage.d.ts +0 -102
- package/dist/security/gdpr-storage.d.ts.map +0 -1
- package/dist/security/gdpr-storage.js +0 -65
- package/dist/security/gdpr.d.ts +0 -320
- package/dist/security/gdpr.d.ts.map +0 -1
- package/dist/security/gdpr.js +0 -531
- package/dist/security/headers.d.ts +0 -184
- package/dist/security/headers.d.ts.map +0 -1
- package/dist/security/headers.js +0 -420
- package/dist/utils/jwt-validation.d.ts +0 -14
- package/dist/utils/jwt-validation.d.ts.map +0 -1
- package/dist/utils/jwt-validation.js +0 -36
- package/dist/utils/request-headers.d.ts +0 -15
- package/dist/utils/request-headers.d.ts.map +0 -1
- package/dist/utils/request-headers.js +0 -31
package/dist/security/audit.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Audit Logging System
|
|
3
|
-
*
|
|
4
|
-
* Track security-relevant events and user actions for compliance
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Audit logging system
|
|
8
|
-
*/
|
|
9
|
-
export class AuditSystem {
|
|
10
|
-
storage;
|
|
11
|
-
filters = [];
|
|
12
|
-
constructor(storage) {
|
|
13
|
-
this.storage = storage;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Log audit event
|
|
17
|
-
*/
|
|
18
|
-
async log(event) {
|
|
19
|
-
const fullEvent = {
|
|
20
|
-
...event,
|
|
21
|
-
id: crypto.randomUUID(),
|
|
22
|
-
timestamp: new Date().toISOString(),
|
|
23
|
-
};
|
|
24
|
-
// Apply filters
|
|
25
|
-
const shouldLog = this.filters.every((filter) => filter(fullEvent));
|
|
26
|
-
if (!shouldLog) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await this.storage.write(fullEvent);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Log authentication event
|
|
33
|
-
*/
|
|
34
|
-
async logAuth(type, actorId, result, metadata) {
|
|
35
|
-
await this.log({
|
|
36
|
-
type,
|
|
37
|
-
severity: result === 'failure' ? 'medium' : 'low',
|
|
38
|
-
actor: {
|
|
39
|
-
id: actorId,
|
|
40
|
-
type: 'user',
|
|
41
|
-
},
|
|
42
|
-
action: type.replace('auth.', ''),
|
|
43
|
-
result,
|
|
44
|
-
metadata,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Log data access event
|
|
49
|
-
*/
|
|
50
|
-
async logDataAccess(action, actorId, resourceType, resourceId, result, changes) {
|
|
51
|
-
await this.log({
|
|
52
|
-
type: `data.${action}`,
|
|
53
|
-
severity: action === 'delete' ? 'high' : 'medium',
|
|
54
|
-
actor: {
|
|
55
|
-
id: actorId,
|
|
56
|
-
type: 'user',
|
|
57
|
-
},
|
|
58
|
-
resource: {
|
|
59
|
-
type: resourceType,
|
|
60
|
-
id: resourceId,
|
|
61
|
-
},
|
|
62
|
-
action,
|
|
63
|
-
result,
|
|
64
|
-
changes,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Log permission change
|
|
69
|
-
*/
|
|
70
|
-
async logPermissionChange(action, actorId, targetUserId, permission, result) {
|
|
71
|
-
await this.log({
|
|
72
|
-
type: `permission.${action}`,
|
|
73
|
-
severity: 'high',
|
|
74
|
-
actor: {
|
|
75
|
-
id: actorId,
|
|
76
|
-
type: 'user',
|
|
77
|
-
},
|
|
78
|
-
resource: {
|
|
79
|
-
type: 'user',
|
|
80
|
-
id: targetUserId,
|
|
81
|
-
},
|
|
82
|
-
action,
|
|
83
|
-
result,
|
|
84
|
-
metadata: {
|
|
85
|
-
permission,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Log security event
|
|
91
|
-
*/
|
|
92
|
-
async logSecurityEvent(type, severity, actorId, message, metadata) {
|
|
93
|
-
await this.log({
|
|
94
|
-
type: `security.${type}`,
|
|
95
|
-
severity,
|
|
96
|
-
actor: {
|
|
97
|
-
id: actorId,
|
|
98
|
-
type: 'user',
|
|
99
|
-
},
|
|
100
|
-
action: type,
|
|
101
|
-
result: 'failure',
|
|
102
|
-
message,
|
|
103
|
-
metadata,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Log GDPR event
|
|
108
|
-
*/
|
|
109
|
-
async logGDPREvent(type, actorId, result, metadata) {
|
|
110
|
-
await this.log({
|
|
111
|
-
type: `gdpr.${type}`,
|
|
112
|
-
severity: 'high',
|
|
113
|
-
actor: {
|
|
114
|
-
id: actorId,
|
|
115
|
-
type: 'user',
|
|
116
|
-
},
|
|
117
|
-
action: type,
|
|
118
|
-
result,
|
|
119
|
-
metadata,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Query audit logs
|
|
124
|
-
*/
|
|
125
|
-
async query(query) {
|
|
126
|
-
return this.storage.query(query);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Count audit logs
|
|
130
|
-
*/
|
|
131
|
-
async count(query) {
|
|
132
|
-
return this.storage.count(query);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Add filter
|
|
136
|
-
*/
|
|
137
|
-
addFilter(filter) {
|
|
138
|
-
this.filters.push(filter);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Remove filter
|
|
142
|
-
*/
|
|
143
|
-
removeFilter(filter) {
|
|
144
|
-
const index = this.filters.indexOf(filter);
|
|
145
|
-
if (index > -1) {
|
|
146
|
-
this.filters.splice(index, 1);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* In-memory audit storage (for development)
|
|
152
|
-
*/
|
|
153
|
-
export class InMemoryAuditStorage {
|
|
154
|
-
events = [];
|
|
155
|
-
maxEvents;
|
|
156
|
-
constructor(maxEvents = 10000) {
|
|
157
|
-
this.maxEvents = maxEvents;
|
|
158
|
-
}
|
|
159
|
-
async write(event) {
|
|
160
|
-
this.events.push(event);
|
|
161
|
-
// Trim old events
|
|
162
|
-
if (this.events.length > this.maxEvents) {
|
|
163
|
-
this.events.shift();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
async query(query) {
|
|
167
|
-
let results = [...this.events];
|
|
168
|
-
// Filter by type
|
|
169
|
-
if (query.types && query.types.length > 0) {
|
|
170
|
-
results = results.filter((e) => query.types?.includes(e.type));
|
|
171
|
-
}
|
|
172
|
-
// Filter by actor
|
|
173
|
-
if (query.actorId) {
|
|
174
|
-
results = results.filter((e) => e.actor.id === query.actorId);
|
|
175
|
-
}
|
|
176
|
-
// Filter by resource
|
|
177
|
-
if (query.resourceType) {
|
|
178
|
-
results = results.filter((e) => e.resource?.type === query.resourceType);
|
|
179
|
-
}
|
|
180
|
-
if (query.resourceId) {
|
|
181
|
-
results = results.filter((e) => e.resource?.id === query.resourceId);
|
|
182
|
-
}
|
|
183
|
-
// Filter by date range
|
|
184
|
-
if (query.startDate) {
|
|
185
|
-
const startDate = query.startDate;
|
|
186
|
-
results = results.filter((e) => new Date(e.timestamp) >= startDate);
|
|
187
|
-
}
|
|
188
|
-
if (query.endDate) {
|
|
189
|
-
const endDate = query.endDate;
|
|
190
|
-
results = results.filter((e) => new Date(e.timestamp) <= endDate);
|
|
191
|
-
}
|
|
192
|
-
// Filter by severity
|
|
193
|
-
if (query.severity && query.severity.length > 0) {
|
|
194
|
-
results = results.filter((e) => query.severity?.includes(e.severity));
|
|
195
|
-
}
|
|
196
|
-
// Filter by result
|
|
197
|
-
if (query.result && query.result.length > 0) {
|
|
198
|
-
results = results.filter((e) => query.result?.includes(e.result));
|
|
199
|
-
}
|
|
200
|
-
// Sort by timestamp (newest first)
|
|
201
|
-
results.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
202
|
-
// Apply pagination
|
|
203
|
-
const offset = query.offset || 0;
|
|
204
|
-
const limit = query.limit || 100;
|
|
205
|
-
return results.slice(offset, offset + limit);
|
|
206
|
-
}
|
|
207
|
-
async count(query) {
|
|
208
|
-
const results = await this.query({ ...query, limit: undefined, offset: undefined });
|
|
209
|
-
return results.length;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Clear all events
|
|
213
|
-
*/
|
|
214
|
-
clear() {
|
|
215
|
-
this.events = [];
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Get all events
|
|
219
|
-
*/
|
|
220
|
-
getAll() {
|
|
221
|
-
return [...this.events];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Audit trail decorator
|
|
226
|
-
*/
|
|
227
|
-
export function AuditTrail(type, action, options) {
|
|
228
|
-
return (_target, _propertyKey, descriptor) => {
|
|
229
|
-
const originalMethod = descriptor.value;
|
|
230
|
-
descriptor.value = async function (...args) {
|
|
231
|
-
const actorId = this.user?.id || 'system';
|
|
232
|
-
const before = options?.captureChanges ? args[0] : undefined;
|
|
233
|
-
let result = 'success';
|
|
234
|
-
let error;
|
|
235
|
-
try {
|
|
236
|
-
const returnValue = await originalMethod.apply(this, args);
|
|
237
|
-
// Log audit event
|
|
238
|
-
if (this.audit) {
|
|
239
|
-
await this.audit.log({
|
|
240
|
-
type,
|
|
241
|
-
severity: options?.severity || 'medium',
|
|
242
|
-
actor: {
|
|
243
|
-
id: actorId,
|
|
244
|
-
type: 'user',
|
|
245
|
-
},
|
|
246
|
-
resource: options?.resourceType
|
|
247
|
-
? {
|
|
248
|
-
type: options.resourceType,
|
|
249
|
-
id: args[0]?.id || 'unknown',
|
|
250
|
-
}
|
|
251
|
-
: undefined,
|
|
252
|
-
action,
|
|
253
|
-
result,
|
|
254
|
-
changes: options?.captureChanges
|
|
255
|
-
? {
|
|
256
|
-
before: before,
|
|
257
|
-
after: returnValue,
|
|
258
|
-
}
|
|
259
|
-
: undefined,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return returnValue;
|
|
263
|
-
}
|
|
264
|
-
catch (err) {
|
|
265
|
-
result = 'failure';
|
|
266
|
-
error = err;
|
|
267
|
-
// Log failure
|
|
268
|
-
if (this.audit) {
|
|
269
|
-
await this.audit.log({
|
|
270
|
-
type,
|
|
271
|
-
severity: 'high',
|
|
272
|
-
actor: {
|
|
273
|
-
id: actorId,
|
|
274
|
-
type: 'user',
|
|
275
|
-
},
|
|
276
|
-
resource: options?.resourceType
|
|
277
|
-
? {
|
|
278
|
-
type: options.resourceType,
|
|
279
|
-
id: args[0]?.id || 'unknown',
|
|
280
|
-
}
|
|
281
|
-
: undefined,
|
|
282
|
-
action,
|
|
283
|
-
result,
|
|
284
|
-
message: error.message,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
throw error;
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
return descriptor;
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Audit middleware
|
|
295
|
-
*/
|
|
296
|
-
export function createAuditMiddleware(audit, getUser) {
|
|
297
|
-
return async (request, next) => {
|
|
298
|
-
const user = getUser(request);
|
|
299
|
-
const startTime = Date.now();
|
|
300
|
-
try {
|
|
301
|
-
const response = await next();
|
|
302
|
-
// Log successful request
|
|
303
|
-
await audit.log({
|
|
304
|
-
type: 'data.read',
|
|
305
|
-
severity: 'low',
|
|
306
|
-
actor: {
|
|
307
|
-
id: user.id,
|
|
308
|
-
type: 'user',
|
|
309
|
-
ip: user.ip,
|
|
310
|
-
userAgent: user.userAgent,
|
|
311
|
-
},
|
|
312
|
-
action: request.method,
|
|
313
|
-
result: 'success',
|
|
314
|
-
metadata: {
|
|
315
|
-
path: request.url,
|
|
316
|
-
duration: Date.now() - startTime,
|
|
317
|
-
status: response.status,
|
|
318
|
-
},
|
|
319
|
-
});
|
|
320
|
-
return response;
|
|
321
|
-
}
|
|
322
|
-
catch (error) {
|
|
323
|
-
// Log failed request
|
|
324
|
-
await audit.log({
|
|
325
|
-
type: 'data.read',
|
|
326
|
-
severity: 'medium',
|
|
327
|
-
actor: {
|
|
328
|
-
id: user.id,
|
|
329
|
-
type: 'user',
|
|
330
|
-
ip: user.ip,
|
|
331
|
-
userAgent: user.userAgent,
|
|
332
|
-
},
|
|
333
|
-
action: request.method,
|
|
334
|
-
result: 'failure',
|
|
335
|
-
message: error instanceof Error ? error.message : 'Unknown error',
|
|
336
|
-
metadata: {
|
|
337
|
-
path: request.url,
|
|
338
|
-
duration: Date.now() - startTime,
|
|
339
|
-
},
|
|
340
|
-
});
|
|
341
|
-
throw error;
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Audit report generator
|
|
347
|
-
*/
|
|
348
|
-
export class AuditReportGenerator {
|
|
349
|
-
audit;
|
|
350
|
-
constructor(audit) {
|
|
351
|
-
this.audit = audit;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Generate security report
|
|
355
|
-
*/
|
|
356
|
-
async generateSecurityReport(startDate, endDate) {
|
|
357
|
-
const allEvents = await this.audit.query({
|
|
358
|
-
startDate,
|
|
359
|
-
endDate,
|
|
360
|
-
});
|
|
361
|
-
const securityViolations = allEvents.filter((e) => e.type.startsWith('security.')).length;
|
|
362
|
-
const failedLogins = allEvents.filter((e) => e.type === 'auth.failed_login').length;
|
|
363
|
-
const permissionChanges = allEvents.filter((e) => e.type.startsWith('permission.')).length;
|
|
364
|
-
const dataExports = allEvents.filter((e) => e.type === 'data.export').length;
|
|
365
|
-
const criticalEvents = allEvents.filter((e) => e.severity === 'critical');
|
|
366
|
-
return {
|
|
367
|
-
totalEvents: allEvents.length,
|
|
368
|
-
securityViolations,
|
|
369
|
-
failedLogins,
|
|
370
|
-
permissionChanges,
|
|
371
|
-
dataExports,
|
|
372
|
-
criticalEvents,
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Generate user activity report
|
|
377
|
-
*/
|
|
378
|
-
async generateUserActivityReport(userId, startDate, endDate) {
|
|
379
|
-
const events = await this.audit.query({
|
|
380
|
-
actorId: userId,
|
|
381
|
-
startDate,
|
|
382
|
-
endDate,
|
|
383
|
-
});
|
|
384
|
-
const actionsByType = events.reduce((acc, event) => {
|
|
385
|
-
acc[event.type] = (acc[event.type] || 0) + 1;
|
|
386
|
-
return acc;
|
|
387
|
-
}, {});
|
|
388
|
-
const failedActions = events.filter((e) => e.result === 'failure').length;
|
|
389
|
-
return {
|
|
390
|
-
totalActions: events.length,
|
|
391
|
-
actionsByType,
|
|
392
|
-
failedActions,
|
|
393
|
-
recentActions: events.slice(0, 10),
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Generate compliance report
|
|
398
|
-
*/
|
|
399
|
-
async generateComplianceReport(startDate, endDate) {
|
|
400
|
-
const events = await this.audit.query({
|
|
401
|
-
startDate,
|
|
402
|
-
endDate,
|
|
403
|
-
});
|
|
404
|
-
const dataAccesses = events.filter((e) => e.type === 'data.read').length;
|
|
405
|
-
const dataModifications = events.filter((e) => e.type === 'data.update' || e.type === 'data.create').length;
|
|
406
|
-
const dataDeletions = events.filter((e) => e.type === 'data.delete').length;
|
|
407
|
-
const gdprRequests = events.filter((e) => e.type.startsWith('gdpr.')).length;
|
|
408
|
-
// Check if audit trail is complete (no gaps)
|
|
409
|
-
const auditTrailComplete = this.checkAuditTrailContinuity(events);
|
|
410
|
-
return {
|
|
411
|
-
dataAccesses,
|
|
412
|
-
dataModifications,
|
|
413
|
-
dataDeletions,
|
|
414
|
-
gdprRequests,
|
|
415
|
-
auditTrailComplete,
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Check audit trail continuity
|
|
420
|
-
*/
|
|
421
|
-
checkAuditTrailContinuity(events) {
|
|
422
|
-
if (events.length === 0)
|
|
423
|
-
return true;
|
|
424
|
-
// Sort by timestamp
|
|
425
|
-
const sorted = events.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
426
|
-
// Check for gaps (simplified - just check if we have events)
|
|
427
|
-
return sorted.length > 0;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Global audit system
|
|
432
|
-
*/
|
|
433
|
-
export const audit = new AuditSystem(new InMemoryAuditStorage());
|
package/dist/security/auth.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication Utilities
|
|
3
|
-
*
|
|
4
|
-
* OAuth support, password hashing, and two-factor authentication.
|
|
5
|
-
* JWT-based auth was removed — session auth is handled by @revealui/auth.
|
|
6
|
-
*/
|
|
7
|
-
export interface User {
|
|
8
|
-
id: string;
|
|
9
|
-
email: string;
|
|
10
|
-
username?: string;
|
|
11
|
-
roles: string[];
|
|
12
|
-
permissions: string[];
|
|
13
|
-
metadata?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* OAuth configuration
|
|
17
|
-
*/
|
|
18
|
-
export interface OAuthConfig {
|
|
19
|
-
provider: 'google' | 'github' | 'microsoft' | 'custom';
|
|
20
|
-
clientId: string;
|
|
21
|
-
clientSecret: string;
|
|
22
|
-
redirectUri: string;
|
|
23
|
-
scope?: string[];
|
|
24
|
-
authorizationUrl?: string;
|
|
25
|
-
tokenUrl?: string;
|
|
26
|
-
userInfoUrl?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* OAuth provider configurations
|
|
30
|
-
*/
|
|
31
|
-
export declare const OAuthProviders: {
|
|
32
|
-
google: {
|
|
33
|
-
authorizationUrl: string;
|
|
34
|
-
tokenUrl: string;
|
|
35
|
-
userInfoUrl: string;
|
|
36
|
-
scope: string[];
|
|
37
|
-
};
|
|
38
|
-
github: {
|
|
39
|
-
authorizationUrl: string;
|
|
40
|
-
tokenUrl: string;
|
|
41
|
-
userInfoUrl: string;
|
|
42
|
-
scope: string[];
|
|
43
|
-
};
|
|
44
|
-
microsoft: {
|
|
45
|
-
authorizationUrl: string;
|
|
46
|
-
tokenUrl: string;
|
|
47
|
-
userInfoUrl: string;
|
|
48
|
-
scope: string[];
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* OAuth client
|
|
53
|
-
*/
|
|
54
|
-
export declare class OAuthClient {
|
|
55
|
-
private config;
|
|
56
|
-
constructor(config: OAuthConfig);
|
|
57
|
-
/**
|
|
58
|
-
* Get authorization URL
|
|
59
|
-
*/
|
|
60
|
-
getAuthorizationUrl(state?: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* Exchange code for token
|
|
63
|
-
*/
|
|
64
|
-
exchangeCodeForToken(code: string): Promise<{
|
|
65
|
-
access_token: string;
|
|
66
|
-
refresh_token?: string;
|
|
67
|
-
expires_in: number;
|
|
68
|
-
token_type: string;
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* Get user info
|
|
72
|
-
*/
|
|
73
|
-
getUserInfo(accessToken: string): Promise<{
|
|
74
|
-
id: string;
|
|
75
|
-
email: string;
|
|
76
|
-
name?: string;
|
|
77
|
-
picture?: string;
|
|
78
|
-
}>;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Hash password with PBKDF2 and random salt
|
|
82
|
-
*/
|
|
83
|
-
declare function hashPassword(password: string): Promise<string>;
|
|
84
|
-
/**
|
|
85
|
-
* Verify password against stored hash
|
|
86
|
-
*/
|
|
87
|
-
declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
88
|
-
export declare const PasswordHasher: {
|
|
89
|
-
readonly hash: typeof hashPassword;
|
|
90
|
-
readonly verify: typeof verifyPassword;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Generate TOTP secret
|
|
94
|
-
*/
|
|
95
|
-
declare function generateSecret(): string;
|
|
96
|
-
/**
|
|
97
|
-
* Generate TOTP code
|
|
98
|
-
*/
|
|
99
|
-
declare function generateCode(secret: string, timestamp?: number): string;
|
|
100
|
-
/**
|
|
101
|
-
* Verify TOTP code
|
|
102
|
-
*/
|
|
103
|
-
declare function verifyCode(secret: string, code: string, window?: number): boolean;
|
|
104
|
-
export declare const TwoFactorAuth: {
|
|
105
|
-
readonly generateSecret: typeof generateSecret;
|
|
106
|
-
readonly generateCode: typeof generateCode;
|
|
107
|
-
readonly verifyCode: typeof verifyCode;
|
|
108
|
-
};
|
|
109
|
-
export {};
|
|
110
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/security/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;CAmB1B,CAAC;AAEF;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,EAAE,WAAW;IAQ/B;;OAEG;IACH,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAe3C;;OAEG;IACG,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAChD,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IA8BF;;OAEG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9C,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CAsBH;AAgBD;;GAEG;AACH,iBAAe,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU7D;AAED;;GAEG;AACH,iBAAe,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBpF;AAED,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAyCX;;GAEG;AACH,iBAAS,cAAc,IAAI,MAAM,CAShC;AAED;;GAEG;AACH,iBAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBhE;AAED;;GAEG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,OAAO,CAiB7E;AAED,eAAO,MAAM,aAAa;;;;CAIhB,CAAC"}
|