guardrail-compliance 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/dist/audit/emitter.d.ts +97 -0
- package/dist/audit/emitter.d.ts.map +1 -0
- package/dist/audit/emitter.js +197 -0
- package/dist/audit/events.d.ts +304 -0
- package/dist/audit/events.d.ts.map +1 -0
- package/dist/audit/events.js +267 -0
- package/dist/audit/index.d.ts +11 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +51 -0
- package/dist/audit/storage.d.ts +93 -0
- package/dist/audit/storage.d.ts.map +1 -0
- package/dist/audit/storage.js +337 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts +2 -0
- package/dist/automation/__tests__/compliance-scheduler.test.d.ts.map +1 -0
- package/dist/automation/__tests__/compliance-scheduler.test.js +140 -0
- package/dist/automation/audit-logger.d.ts +129 -0
- package/dist/automation/audit-logger.d.ts.map +1 -0
- package/dist/automation/audit-logger.js +473 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts +1 -0
- package/dist/automation/compliance-scheduler-fixed.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler-fixed.js +1 -0
- package/dist/automation/compliance-scheduler.d.ts +83 -0
- package/dist/automation/compliance-scheduler.d.ts.map +1 -0
- package/dist/automation/compliance-scheduler.js +414 -0
- package/dist/automation/dashboard.d.ts +194 -0
- package/dist/automation/dashboard.d.ts.map +1 -0
- package/dist/automation/dashboard.js +768 -0
- package/dist/automation/email-service.d.ts +69 -0
- package/dist/automation/email-service.d.ts.map +1 -0
- package/dist/automation/email-service.js +218 -0
- package/dist/automation/evidence-collector.d.ts +140 -0
- package/dist/automation/evidence-collector.d.ts.map +1 -0
- package/dist/automation/evidence-collector.js +682 -0
- package/dist/automation/index.d.ts +8 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +24 -0
- package/dist/automation/pdf-exporter.d.ts +90 -0
- package/dist/automation/pdf-exporter.d.ts.map +1 -0
- package/dist/automation/pdf-exporter.js +381 -0
- package/dist/automation/reporting-engine.d.ts +116 -0
- package/dist/automation/reporting-engine.d.ts.map +1 -0
- package/dist/automation/reporting-engine.js +329 -0
- package/dist/container/index.d.ts +4 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +19 -0
- package/dist/container/kubernetes.d.ts +94 -0
- package/dist/container/kubernetes.d.ts.map +1 -0
- package/dist/container/kubernetes.js +268 -0
- package/dist/container/rules.d.ts +27 -0
- package/dist/container/rules.d.ts.map +1 -0
- package/dist/container/rules.js +216 -0
- package/dist/container/scanner.d.ts +50 -0
- package/dist/container/scanner.d.ts.map +1 -0
- package/dist/container/scanner.js +143 -0
- package/dist/frameworks/engine.d.ts +108 -0
- package/dist/frameworks/engine.d.ts.map +1 -0
- package/dist/frameworks/engine.js +206 -0
- package/dist/frameworks/gdpr.d.ts +6 -0
- package/dist/frameworks/gdpr.d.ts.map +1 -0
- package/dist/frameworks/gdpr.js +198 -0
- package/dist/frameworks/hipaa.d.ts +6 -0
- package/dist/frameworks/hipaa.d.ts.map +1 -0
- package/dist/frameworks/hipaa.js +183 -0
- package/dist/frameworks/index.d.ts +8 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +30 -0
- package/dist/frameworks/iso27001.d.ts +63 -0
- package/dist/frameworks/iso27001.d.ts.map +1 -0
- package/dist/frameworks/iso27001.js +331 -0
- package/dist/frameworks/nist.d.ts +62 -0
- package/dist/frameworks/nist.d.ts.map +1 -0
- package/dist/frameworks/nist.js +424 -0
- package/dist/frameworks/pci.d.ts +6 -0
- package/dist/frameworks/pci.d.ts.map +1 -0
- package/dist/frameworks/pci.js +201 -0
- package/dist/frameworks/soc2.d.ts +7 -0
- package/dist/frameworks/soc2.d.ts.map +1 -0
- package/dist/frameworks/soc2.js +248 -0
- package/dist/iac/drift-detector.d.ts +64 -0
- package/dist/iac/drift-detector.d.ts.map +1 -0
- package/dist/iac/drift-detector.js +134 -0
- package/dist/iac/index.d.ts +4 -0
- package/dist/iac/index.d.ts.map +1 -0
- package/dist/iac/index.js +19 -0
- package/dist/iac/rules.d.ts +17 -0
- package/dist/iac/rules.d.ts.map +1 -0
- package/dist/iac/rules.js +385 -0
- package/dist/iac/scanner.d.ts +104 -0
- package/dist/iac/scanner.d.ts.map +1 -0
- package/dist/iac/scanner.js +343 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/pii/data-flow.d.ts +58 -0
- package/dist/pii/data-flow.d.ts.map +1 -0
- package/dist/pii/data-flow.js +154 -0
- package/dist/pii/detector.d.ts +60 -0
- package/dist/pii/detector.d.ts.map +1 -0
- package/dist/pii/detector.js +267 -0
- package/dist/pii/index.d.ts +4 -0
- package/dist/pii/index.d.ts.map +1 -0
- package/dist/pii/index.js +19 -0
- package/dist/pii/patterns.d.ts +36 -0
- package/dist/pii/patterns.d.ts.map +1 -0
- package/dist/pii/patterns.js +108 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +20 -0
- package/dist/policy/opa-engine.d.ts +121 -0
- package/dist/policy/opa-engine.d.ts.map +1 -0
- package/dist/policy/opa-engine.js +423 -0
- package/package.json +31 -0
- package/src/audit/emitter.ts +383 -0
- package/src/audit/events.ts +351 -0
- package/src/audit/index.ts +35 -0
- package/src/audit/storage.ts +394 -0
- package/src/automation/__tests__/compliance-scheduler.test.ts +183 -0
- package/src/automation/audit-logger.ts +629 -0
- package/src/automation/compliance-scheduler-fixed.ts +0 -0
- package/src/automation/compliance-scheduler.ts +516 -0
- package/src/automation/dashboard.ts +947 -0
- package/src/automation/email-service.ts +230 -0
- package/src/automation/evidence-collector.ts +866 -0
- package/src/automation/index.ts +8 -0
- package/src/automation/pdf-exporter.ts +434 -0
- package/src/automation/reporting-engine.ts +462 -0
- package/src/container/index.ts +3 -0
- package/src/container/kubernetes.ts +379 -0
- package/src/container/rules.ts +244 -0
- package/src/container/scanner.ts +202 -0
- package/src/frameworks/engine.ts +298 -0
- package/src/frameworks/gdpr.ts +204 -0
- package/src/frameworks/hipaa.ts +209 -0
- package/src/frameworks/index.ts +23 -0
- package/src/frameworks/iso27001.ts +398 -0
- package/src/frameworks/nist.ts +518 -0
- package/src/frameworks/pci.ts +226 -0
- package/src/frameworks/soc2.ts +281 -0
- package/src/iac/drift-detector.ts +197 -0
- package/src/iac/index.ts +3 -0
- package/src/iac/rules.ts +420 -0
- package/src/iac/scanner.ts +445 -0
- package/src/index.ts +17 -0
- package/src/pii/data-flow.ts +216 -0
- package/src/pii/detector.ts +327 -0
- package/src/pii/index.ts +3 -0
- package/src/pii/patterns.ts +128 -0
- package/src/policy/index.ts +5 -0
- package/src/policy/opa-engine.ts +504 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Trail Emitter
|
|
3
|
+
*
|
|
4
|
+
* Central audit event emission with tier-gating.
|
|
5
|
+
* Usage: audit.emit(eventInput) from CLI, MCP, VS Code, etc.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
AuditEvent,
|
|
10
|
+
AuditEventInput,
|
|
11
|
+
AuditSurface,
|
|
12
|
+
AuditActionCategory,
|
|
13
|
+
AuditResult,
|
|
14
|
+
AuditTier,
|
|
15
|
+
AuditEventMetadata,
|
|
16
|
+
createAuditEvent,
|
|
17
|
+
AuditActions,
|
|
18
|
+
} from './events';
|
|
19
|
+
import {
|
|
20
|
+
AuditStorageAdapter,
|
|
21
|
+
createStorageAdapter,
|
|
22
|
+
} from './storage';
|
|
23
|
+
|
|
24
|
+
// Singleton storage instance
|
|
25
|
+
let storageInstance: AuditStorageAdapter | null = null;
|
|
26
|
+
|
|
27
|
+
// Configuration
|
|
28
|
+
interface AuditConfig {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
tier: AuditTier;
|
|
31
|
+
basePath: string;
|
|
32
|
+
storageType: 'local' | 'server';
|
|
33
|
+
serverUrl?: string;
|
|
34
|
+
serverApiKey?: string;
|
|
35
|
+
actor?: {
|
|
36
|
+
id: string;
|
|
37
|
+
type: 'user' | 'system' | 'ci' | 'api';
|
|
38
|
+
name?: string;
|
|
39
|
+
email?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const defaultConfig: AuditConfig = {
|
|
44
|
+
enabled: true,
|
|
45
|
+
tier: 'free',
|
|
46
|
+
basePath: process.cwd(),
|
|
47
|
+
storageType: 'local',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let currentConfig: AuditConfig = { ...defaultConfig };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Configure the audit system
|
|
54
|
+
*/
|
|
55
|
+
export function configureAudit(config: Partial<AuditConfig>): void {
|
|
56
|
+
currentConfig = { ...currentConfig, ...config };
|
|
57
|
+
|
|
58
|
+
// Reset storage instance if config changed
|
|
59
|
+
storageInstance = null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get or create storage instance
|
|
64
|
+
*/
|
|
65
|
+
function getStorage(): AuditStorageAdapter {
|
|
66
|
+
if (!storageInstance) {
|
|
67
|
+
storageInstance = createStorageAdapter({
|
|
68
|
+
type: currentConfig.storageType,
|
|
69
|
+
basePath: currentConfig.basePath,
|
|
70
|
+
apiUrl: currentConfig.serverUrl,
|
|
71
|
+
apiKey: currentConfig.serverApiKey,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return storageInstance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if audit is enabled for the current tier
|
|
79
|
+
*/
|
|
80
|
+
function isAuditEnabled(): boolean {
|
|
81
|
+
if (!currentConfig.enabled) return false;
|
|
82
|
+
|
|
83
|
+
// Minimal logging for free/starter (just basic events, no full trail)
|
|
84
|
+
// Full audit trail requires compliance+ tier
|
|
85
|
+
return true; // Always log something, tier controls detail level
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Check if full audit trail is available (Compliance+ tier)
|
|
90
|
+
*/
|
|
91
|
+
export function hasFullAuditAccess(): boolean {
|
|
92
|
+
return ['compliance', 'enterprise', 'unlimited'].includes(currentConfig.tier);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get current actor from config or environment
|
|
97
|
+
*/
|
|
98
|
+
function getCurrentActor(): AuditEvent['actor'] {
|
|
99
|
+
if (currentConfig.actor) {
|
|
100
|
+
return currentConfig.actor;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const env = process.env as Record<string, string | undefined>;
|
|
104
|
+
|
|
105
|
+
// Try to detect from environment
|
|
106
|
+
const userId = env['GUARDRAIL_USER_ID'] || env['USER'] || 'anonymous';
|
|
107
|
+
const userName = env['GUARDRAIL_USER_NAME'] || env['USERNAME'];
|
|
108
|
+
const userEmail = env['GUARDRAIL_USER_EMAIL'];
|
|
109
|
+
|
|
110
|
+
// Detect CI environment
|
|
111
|
+
if (env['CI'] || env['GITHUB_ACTIONS'] || env['GITLAB_CI']) {
|
|
112
|
+
return {
|
|
113
|
+
id: env['GITHUB_ACTOR'] || env['GITLAB_USER_LOGIN'] || 'ci-system',
|
|
114
|
+
type: 'ci',
|
|
115
|
+
name: env['GITHUB_ACTOR'] || env['GITLAB_USER_NAME'],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
id: userId,
|
|
121
|
+
type: 'user',
|
|
122
|
+
name: userName,
|
|
123
|
+
email: userEmail,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Emit an audit event
|
|
129
|
+
*/
|
|
130
|
+
export async function emit(input: AuditEventInput): Promise<AuditEvent | null> {
|
|
131
|
+
if (!isAuditEnabled()) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const storage = getStorage();
|
|
136
|
+
const prevHash = await storage.getLastHash();
|
|
137
|
+
|
|
138
|
+
// Override tier with current config tier (for proper redaction)
|
|
139
|
+
const event = createAuditEvent({
|
|
140
|
+
...input,
|
|
141
|
+
tier: currentConfig.tier,
|
|
142
|
+
}, prevHash);
|
|
143
|
+
|
|
144
|
+
await storage.append(event);
|
|
145
|
+
|
|
146
|
+
return event;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Helper to emit with common defaults
|
|
151
|
+
*/
|
|
152
|
+
export async function emitAction(
|
|
153
|
+
surface: AuditSurface,
|
|
154
|
+
action: string,
|
|
155
|
+
category: AuditActionCategory,
|
|
156
|
+
target: AuditEvent['target'],
|
|
157
|
+
result: AuditResult,
|
|
158
|
+
metadata?: AuditEventMetadata
|
|
159
|
+
): Promise<AuditEvent | null> {
|
|
160
|
+
return emit({
|
|
161
|
+
actor: getCurrentActor(),
|
|
162
|
+
surface,
|
|
163
|
+
action,
|
|
164
|
+
category,
|
|
165
|
+
target,
|
|
166
|
+
tier: currentConfig.tier,
|
|
167
|
+
result,
|
|
168
|
+
metadata,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Convenience methods for common CLI actions
|
|
173
|
+
|
|
174
|
+
export async function emitScanStart(
|
|
175
|
+
surface: AuditSurface,
|
|
176
|
+
projectPath: string,
|
|
177
|
+
args?: string[]
|
|
178
|
+
): Promise<AuditEvent | null> {
|
|
179
|
+
return emitAction(
|
|
180
|
+
surface,
|
|
181
|
+
AuditActions.SCAN_START,
|
|
182
|
+
'scan',
|
|
183
|
+
{ type: 'project', path: projectPath },
|
|
184
|
+
'success',
|
|
185
|
+
{ command: 'scan', args, projectPath }
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function emitScanComplete(
|
|
190
|
+
surface: AuditSurface,
|
|
191
|
+
projectPath: string,
|
|
192
|
+
result: AuditResult,
|
|
193
|
+
metadata?: { score?: number; grade?: string; issueCount?: number; durationMs?: number }
|
|
194
|
+
): Promise<AuditEvent | null> {
|
|
195
|
+
return emitAction(
|
|
196
|
+
surface,
|
|
197
|
+
AuditActions.SCAN_COMPLETE,
|
|
198
|
+
'scan',
|
|
199
|
+
{ type: 'project', path: projectPath },
|
|
200
|
+
result,
|
|
201
|
+
{ command: 'scan', projectPath, ...metadata }
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export async function emitShipCheck(
|
|
206
|
+
surface: AuditSurface,
|
|
207
|
+
projectPath: string,
|
|
208
|
+
result: AuditResult,
|
|
209
|
+
metadata?: { score?: number; grade?: string; canShip?: boolean }
|
|
210
|
+
): Promise<AuditEvent | null> {
|
|
211
|
+
return emitAction(
|
|
212
|
+
surface,
|
|
213
|
+
AuditActions.SHIP_CHECK,
|
|
214
|
+
'ship',
|
|
215
|
+
{ type: 'project', path: projectPath },
|
|
216
|
+
result,
|
|
217
|
+
{ command: 'ship', projectPath, custom: metadata }
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export async function emitRealityStart(
|
|
222
|
+
surface: AuditSurface,
|
|
223
|
+
url: string,
|
|
224
|
+
flows?: string[]
|
|
225
|
+
): Promise<AuditEvent | null> {
|
|
226
|
+
return emitAction(
|
|
227
|
+
surface,
|
|
228
|
+
AuditActions.REALITY_START,
|
|
229
|
+
'reality',
|
|
230
|
+
{ type: 'url', path: url },
|
|
231
|
+
'success',
|
|
232
|
+
{ command: 'reality', custom: { url, flows } }
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export async function emitRealityComplete(
|
|
237
|
+
surface: AuditSurface,
|
|
238
|
+
url: string,
|
|
239
|
+
result: AuditResult,
|
|
240
|
+
metadata?: { durationMs?: number; testsPassed?: number; testsFailed?: number }
|
|
241
|
+
): Promise<AuditEvent | null> {
|
|
242
|
+
return emitAction(
|
|
243
|
+
surface,
|
|
244
|
+
AuditActions.REALITY_COMPLETE,
|
|
245
|
+
'reality',
|
|
246
|
+
{ type: 'url', path: url },
|
|
247
|
+
result,
|
|
248
|
+
{ command: 'reality', ...metadata }
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export async function emitAutopilotAction(
|
|
253
|
+
surface: AuditSurface,
|
|
254
|
+
action: 'enable' | 'disable' | 'run' | 'report',
|
|
255
|
+
projectPath: string,
|
|
256
|
+
result: AuditResult,
|
|
257
|
+
metadata?: AuditEventMetadata
|
|
258
|
+
): Promise<AuditEvent | null> {
|
|
259
|
+
const actionMap = {
|
|
260
|
+
enable: AuditActions.AUTOPILOT_ENABLE,
|
|
261
|
+
disable: AuditActions.AUTOPILOT_DISABLE,
|
|
262
|
+
run: AuditActions.AUTOPILOT_RUN,
|
|
263
|
+
report: AuditActions.AUTOPILOT_REPORT,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
return emitAction(
|
|
267
|
+
surface,
|
|
268
|
+
actionMap[action],
|
|
269
|
+
'autopilot',
|
|
270
|
+
{ type: 'project', path: projectPath },
|
|
271
|
+
result,
|
|
272
|
+
{ command: 'autopilot', projectPath, ...metadata }
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export async function emitFixPlan(
|
|
277
|
+
surface: AuditSurface,
|
|
278
|
+
projectPath: string,
|
|
279
|
+
result: AuditResult,
|
|
280
|
+
metadata?: { fixCount?: number; scope?: string }
|
|
281
|
+
): Promise<AuditEvent | null> {
|
|
282
|
+
return emitAction(
|
|
283
|
+
surface,
|
|
284
|
+
AuditActions.FIX_PLAN,
|
|
285
|
+
'fix',
|
|
286
|
+
{ type: 'project', path: projectPath },
|
|
287
|
+
result,
|
|
288
|
+
{ command: 'fix', projectPath, ...metadata }
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export async function emitFixApply(
|
|
293
|
+
surface: AuditSurface,
|
|
294
|
+
projectPath: string,
|
|
295
|
+
result: AuditResult,
|
|
296
|
+
metadata?: { fixCount?: number; filesModified?: number }
|
|
297
|
+
): Promise<AuditEvent | null> {
|
|
298
|
+
return emitAction(
|
|
299
|
+
surface,
|
|
300
|
+
AuditActions.FIX_APPLY,
|
|
301
|
+
'fix',
|
|
302
|
+
{ type: 'project', path: projectPath },
|
|
303
|
+
result,
|
|
304
|
+
{ command: 'fix', projectPath, ...metadata }
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export async function emitGateCheck(
|
|
309
|
+
surface: AuditSurface,
|
|
310
|
+
projectPath: string,
|
|
311
|
+
passed: boolean,
|
|
312
|
+
metadata?: { policy?: string; score?: number }
|
|
313
|
+
): Promise<AuditEvent | null> {
|
|
314
|
+
return emitAction(
|
|
315
|
+
surface,
|
|
316
|
+
passed ? AuditActions.GATE_PASS : AuditActions.GATE_FAIL,
|
|
317
|
+
'gate',
|
|
318
|
+
{ type: 'project', path: projectPath },
|
|
319
|
+
passed ? 'success' : 'failure',
|
|
320
|
+
{ command: 'gate', projectPath, ...metadata }
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export async function emitToolInvoke(
|
|
325
|
+
surface: AuditSurface,
|
|
326
|
+
toolName: string,
|
|
327
|
+
args: Record<string, unknown>,
|
|
328
|
+
result: AuditResult,
|
|
329
|
+
metadata?: AuditEventMetadata
|
|
330
|
+
): Promise<AuditEvent | null> {
|
|
331
|
+
return emitAction(
|
|
332
|
+
surface,
|
|
333
|
+
AuditActions.TOOL_INVOKE,
|
|
334
|
+
'tool',
|
|
335
|
+
{ type: 'tool', name: toolName },
|
|
336
|
+
result,
|
|
337
|
+
{ command: toolName, custom: { args }, ...metadata }
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export async function emitAuth(
|
|
342
|
+
surface: AuditSurface,
|
|
343
|
+
action: 'login' | 'logout' | 'token_refresh',
|
|
344
|
+
result: AuditResult,
|
|
345
|
+
metadata?: { method?: string }
|
|
346
|
+
): Promise<AuditEvent | null> {
|
|
347
|
+
const actionMap = {
|
|
348
|
+
login: AuditActions.AUTH_LOGIN,
|
|
349
|
+
logout: AuditActions.AUTH_LOGOUT,
|
|
350
|
+
token_refresh: AuditActions.AUTH_TOKEN_REFRESH,
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
return emitAction(
|
|
354
|
+
surface,
|
|
355
|
+
actionMap[action],
|
|
356
|
+
'auth',
|
|
357
|
+
{ type: 'auth' },
|
|
358
|
+
result,
|
|
359
|
+
metadata
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Export the audit object for convenient usage
|
|
364
|
+
export const audit = {
|
|
365
|
+
configure: configureAudit,
|
|
366
|
+
emit,
|
|
367
|
+
emitAction,
|
|
368
|
+
emitScanStart,
|
|
369
|
+
emitScanComplete,
|
|
370
|
+
emitShipCheck,
|
|
371
|
+
emitRealityStart,
|
|
372
|
+
emitRealityComplete,
|
|
373
|
+
emitAutopilotAction,
|
|
374
|
+
emitFixPlan,
|
|
375
|
+
emitFixApply,
|
|
376
|
+
emitGateCheck,
|
|
377
|
+
emitToolInvoke,
|
|
378
|
+
emitAuth,
|
|
379
|
+
hasFullAccess: hasFullAuditAccess,
|
|
380
|
+
getStorage,
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export default audit;
|