@claude-flow/security 3.0.0-alpha.9 → 3.0.1

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.
Files changed (116) hide show
  1. package/dist/CVE-REMEDIATION.d.ts +17 -6
  2. package/dist/CVE-REMEDIATION.d.ts.map +1 -1
  3. package/dist/CVE-REMEDIATION.js +328 -12
  4. package/dist/CVE-REMEDIATION.js.map +1 -1
  5. package/dist/index.d.ts +8 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +26 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/keychain-adapter.d.ts +48 -0
  10. package/dist/keychain-adapter.d.ts.map +1 -0
  11. package/dist/keychain-adapter.js +0 -0
  12. package/dist/keychain-adapter.js.map +1 -0
  13. package/dist/mcp-caller-identity.d.ts +101 -0
  14. package/dist/mcp-caller-identity.d.ts.map +1 -0
  15. package/dist/mcp-caller-identity.js +0 -0
  16. package/dist/mcp-caller-identity.js.map +1 -0
  17. package/dist/mcp-composition-inspector.d.ts +133 -0
  18. package/dist/mcp-composition-inspector.d.ts.map +1 -0
  19. package/dist/mcp-composition-inspector.js +254 -0
  20. package/dist/mcp-composition-inspector.js.map +1 -0
  21. package/dist/oauth/browser.d.ts +31 -0
  22. package/dist/oauth/browser.d.ts.map +1 -0
  23. package/dist/oauth/browser.js +55 -0
  24. package/dist/oauth/browser.js.map +1 -0
  25. package/dist/oauth/callback-server.d.ts +37 -0
  26. package/dist/oauth/callback-server.d.ts.map +1 -0
  27. package/dist/oauth/callback-server.js +86 -0
  28. package/dist/oauth/callback-server.js.map +1 -0
  29. package/dist/oauth/client.d.ts +57 -0
  30. package/dist/oauth/client.d.ts.map +1 -0
  31. package/dist/oauth/client.js +120 -0
  32. package/dist/oauth/client.js.map +1 -0
  33. package/dist/oauth/pkce.d.ts +25 -0
  34. package/dist/oauth/pkce.d.ts.map +1 -0
  35. package/dist/oauth/pkce.js +36 -0
  36. package/dist/oauth/pkce.js.map +1 -0
  37. package/dist/path-validator.d.ts +23 -0
  38. package/dist/path-validator.d.ts.map +1 -1
  39. package/dist/path-validator.js +128 -5
  40. package/dist/path-validator.js.map +1 -1
  41. package/dist/policy/canonical.d.ts +5 -0
  42. package/dist/policy/canonical.d.ts.map +1 -0
  43. package/dist/policy/canonical.js +30 -0
  44. package/dist/policy/canonical.js.map +1 -0
  45. package/dist/policy/engine.d.ts +30 -0
  46. package/dist/policy/engine.d.ts.map +1 -0
  47. package/dist/policy/engine.js +319 -0
  48. package/dist/policy/engine.js.map +1 -0
  49. package/dist/policy/envelope.d.ts +9 -0
  50. package/dist/policy/envelope.d.ts.map +1 -0
  51. package/dist/policy/envelope.js +90 -0
  52. package/dist/policy/envelope.js.map +1 -0
  53. package/dist/policy/evaluator.d.ts +4 -0
  54. package/dist/policy/evaluator.d.ts.map +1 -0
  55. package/dist/policy/evaluator.js +119 -0
  56. package/dist/policy/evaluator.js.map +1 -0
  57. package/dist/policy/index.d.ts +7 -0
  58. package/dist/policy/index.d.ts.map +1 -0
  59. package/dist/policy/index.js +7 -0
  60. package/dist/policy/index.js.map +1 -0
  61. package/dist/policy/product-plane.d.ts +238 -0
  62. package/dist/policy/product-plane.d.ts.map +1 -0
  63. package/dist/policy/product-plane.js +1022 -0
  64. package/dist/policy/product-plane.js.map +1 -0
  65. package/dist/policy/types.d.ts +187 -0
  66. package/dist/policy/types.d.ts.map +1 -0
  67. package/dist/policy/types.js +2 -0
  68. package/dist/policy/types.js.map +1 -0
  69. package/dist/safe-git.d.ts +22 -0
  70. package/dist/safe-git.d.ts.map +1 -0
  71. package/dist/safe-git.js +63 -0
  72. package/dist/safe-git.js.map +1 -0
  73. package/package.json +17 -5
  74. package/.claude-flow/data/pending-insights.jsonl +0 -6
  75. package/.claude-flow/neural/stats.json +0 -6
  76. package/__tests__/acceptance/security-compliance.test.ts +0 -674
  77. package/__tests__/authorization-propagator.test.ts +0 -155
  78. package/__tests__/credential-generator.test.ts +0 -310
  79. package/__tests__/fixtures/configurations.ts +0 -425
  80. package/__tests__/fixtures/index.ts +0 -21
  81. package/__tests__/helpers/create-mock.ts +0 -469
  82. package/__tests__/helpers/index.ts +0 -32
  83. package/__tests__/input-validator.test.ts +0 -382
  84. package/__tests__/integration/security-flow.test.ts +0 -606
  85. package/__tests__/password-hasher.test.ts +0 -239
  86. package/__tests__/path-validator.test.ts +0 -302
  87. package/__tests__/plugin-integrity-verifier.test.ts +0 -199
  88. package/__tests__/safe-executor.test.ts +0 -292
  89. package/__tests__/token-generator.test.ts +0 -371
  90. package/__tests__/tool-output-guardrail.test.ts +0 -256
  91. package/__tests__/unit/credential-generator.test.ts +0 -182
  92. package/__tests__/unit/password-hasher.test.ts +0 -359
  93. package/__tests__/unit/path-validator.test.ts +0 -509
  94. package/__tests__/unit/safe-executor.test.ts +0 -667
  95. package/__tests__/unit/token-generator.test.ts +0 -310
  96. package/ruvector.db +0 -0
  97. package/src/CVE-REMEDIATION.ts +0 -251
  98. package/src/application/index.ts +0 -10
  99. package/src/application/services/security-application-service.ts +0 -193
  100. package/src/authorization/propagator.ts +0 -279
  101. package/src/credential-generator.ts +0 -368
  102. package/src/domain/entities/security-context.ts +0 -173
  103. package/src/domain/index.ts +0 -17
  104. package/src/domain/services/security-domain-service.ts +0 -296
  105. package/src/index.ts +0 -314
  106. package/src/input-validator.ts +0 -466
  107. package/src/password-hasher.ts +0 -277
  108. package/src/path-validator.ts +0 -525
  109. package/src/plugins/integrity-verifier.ts +0 -265
  110. package/src/safe-executor.ts +0 -546
  111. package/src/token-generator.ts +0 -463
  112. package/src/tool-output-guardrail.ts +0 -360
  113. package/tmp.json +0 -0
  114. package/tsconfig.json +0 -9
  115. package/tsconfig.tsbuildinfo +0 -1
  116. package/vitest.config.ts +0 -20
@@ -1,368 +0,0 @@
1
- /**
2
- * Credential Generator - CVE-3 Remediation
3
- *
4
- * Fixes hardcoded default credentials by providing secure random
5
- * credential generation for installation and runtime.
6
- *
7
- * Security Properties:
8
- * - Uses crypto.randomBytes for cryptographically secure randomness
9
- * - Configurable entropy levels
10
- * - No hardcoded defaults stored in code
11
- * - Secure credential storage recommendations
12
- *
13
- * @module v3/security/credential-generator
14
- */
15
-
16
- import { randomBytes, randomUUID } from 'crypto';
17
-
18
- export interface CredentialConfig {
19
- /**
20
- * Length of generated passwords.
21
- * Default: 32 characters
22
- */
23
- passwordLength?: number;
24
-
25
- /**
26
- * Length of generated API keys.
27
- * Default: 48 characters
28
- */
29
- apiKeyLength?: number;
30
-
31
- /**
32
- * Length of generated secrets (JWT, session, etc.).
33
- * Default: 64 characters
34
- */
35
- secretLength?: number;
36
-
37
- /**
38
- * Character set for password generation.
39
- * Default: alphanumeric + special
40
- */
41
- passwordCharset?: string;
42
-
43
- /**
44
- * Character set for API key generation.
45
- * Default: alphanumeric only (URL-safe)
46
- */
47
- apiKeyCharset?: string;
48
- }
49
-
50
- export interface GeneratedCredentials {
51
- adminPassword: string;
52
- servicePassword: string;
53
- jwtSecret: string;
54
- sessionSecret: string;
55
- encryptionKey: string;
56
- generatedAt: Date;
57
- expiresAt?: Date;
58
- }
59
-
60
- export interface ApiKeyCredential {
61
- key: string;
62
- prefix: string;
63
- keyId: string;
64
- createdAt: Date;
65
- }
66
-
67
- export class CredentialGeneratorError extends Error {
68
- constructor(
69
- message: string,
70
- public readonly code: string,
71
- ) {
72
- super(message);
73
- this.name = 'CredentialGeneratorError';
74
- }
75
- }
76
-
77
- /**
78
- * Character sets for credential generation
79
- */
80
- const CHARSETS = {
81
- UPPERCASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
82
- LOWERCASE: 'abcdefghijklmnopqrstuvwxyz',
83
- DIGITS: '0123456789',
84
- SPECIAL: '!@#$%^&*()_+-=[]{}|;:,.<>?',
85
- // URL-safe characters for API keys
86
- URL_SAFE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
87
- // Hex characters for secrets
88
- HEX: '0123456789abcdef',
89
- } as const;
90
-
91
- /**
92
- * Secure credential generator.
93
- *
94
- * This class provides cryptographically secure credential generation
95
- * to replace hardcoded default credentials.
96
- *
97
- * @example
98
- * ```typescript
99
- * const generator = new CredentialGenerator();
100
- * const credentials = generator.generateInstallationCredentials();
101
- * // Store credentials securely (environment variables, secrets manager)
102
- * ```
103
- */
104
- export class CredentialGenerator {
105
- private readonly config: Required<CredentialConfig>;
106
-
107
- constructor(config: CredentialConfig = {}) {
108
- this.config = {
109
- passwordLength: config.passwordLength ?? 32,
110
- apiKeyLength: config.apiKeyLength ?? 48,
111
- secretLength: config.secretLength ?? 64,
112
- passwordCharset: config.passwordCharset ??
113
- CHARSETS.UPPERCASE + CHARSETS.LOWERCASE + CHARSETS.DIGITS + CHARSETS.SPECIAL,
114
- apiKeyCharset: config.apiKeyCharset ?? CHARSETS.URL_SAFE,
115
- };
116
-
117
- this.validateConfig();
118
- }
119
-
120
- /**
121
- * Validates configuration parameters.
122
- */
123
- private validateConfig(): void {
124
- if (this.config.passwordLength < 16) {
125
- throw new CredentialGeneratorError(
126
- 'Password length must be at least 16 characters',
127
- 'INVALID_PASSWORD_LENGTH'
128
- );
129
- }
130
-
131
- if (this.config.apiKeyLength < 32) {
132
- throw new CredentialGeneratorError(
133
- 'API key length must be at least 32 characters',
134
- 'INVALID_API_KEY_LENGTH'
135
- );
136
- }
137
-
138
- if (this.config.secretLength < 32) {
139
- throw new CredentialGeneratorError(
140
- 'Secret length must be at least 32 characters',
141
- 'INVALID_SECRET_LENGTH'
142
- );
143
- }
144
- }
145
-
146
- /**
147
- * Generates a cryptographically secure random string using rejection sampling
148
- * to eliminate modulo bias.
149
- *
150
- * @param length - Length of the string to generate
151
- * @param charset - Character set to use
152
- * @returns Random string
153
- */
154
- private generateSecureString(length: number, charset: string): string {
155
- const charsetLength = charset.length;
156
- const result = new Array(length);
157
-
158
- // Calculate rejection threshold to eliminate modulo bias
159
- // For a byte (0-255), we reject values >= (256 - (256 % charsetLength))
160
- // This ensures uniform distribution over charset indices
161
- const maxValidValue = 256 - (256 % charsetLength);
162
-
163
- let i = 0;
164
- while (i < length) {
165
- // Generate more random bytes than needed to reduce iterations
166
- const randomBuffer = randomBytes(Math.max(length - i, 16));
167
-
168
- for (let j = 0; j < randomBuffer.length && i < length; j++) {
169
- const randomValue = randomBuffer[j];
170
-
171
- // Rejection sampling: only accept values below threshold
172
- if (randomValue < maxValidValue) {
173
- result[i] = charset[randomValue % charsetLength];
174
- i++;
175
- }
176
- // Values >= maxValidValue are rejected to avoid bias
177
- }
178
- }
179
-
180
- return result.join('');
181
- }
182
-
183
- /**
184
- * Generates a secure random password.
185
- *
186
- * @param length - Optional custom length (default from config)
187
- * @returns Secure random password
188
- */
189
- generatePassword(length?: number): string {
190
- const len = length ?? this.config.passwordLength;
191
-
192
- // Ensure password contains at least one of each required character type
193
- const password = this.generateSecureString(len, this.config.passwordCharset);
194
-
195
- // Validate the generated password meets requirements
196
- if (!this.hasRequiredCharacterTypes(password)) {
197
- // Regenerate if requirements not met (rare case)
198
- return this.generatePassword(length);
199
- }
200
-
201
- return password;
202
- }
203
-
204
- /**
205
- * Checks if password has required character types.
206
- */
207
- private hasRequiredCharacterTypes(password: string): boolean {
208
- const hasUppercase = /[A-Z]/.test(password);
209
- const hasLowercase = /[a-z]/.test(password);
210
- const hasDigit = /\d/.test(password);
211
- const hasSpecial = /[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]/.test(password);
212
-
213
- return hasUppercase && hasLowercase && hasDigit && hasSpecial;
214
- }
215
-
216
- /**
217
- * Generates a secure API key.
218
- *
219
- * @param prefix - Optional prefix for the key (e.g., 'cf_')
220
- * @returns API key credential with metadata
221
- */
222
- generateApiKey(prefix = 'cf_'): ApiKeyCredential {
223
- const keyBody = this.generateSecureString(
224
- this.config.apiKeyLength - prefix.length,
225
- this.config.apiKeyCharset
226
- );
227
-
228
- const key = `${prefix}${keyBody}`;
229
- const keyId = randomUUID();
230
-
231
- return {
232
- key,
233
- prefix,
234
- keyId,
235
- createdAt: new Date(),
236
- };
237
- }
238
-
239
- /**
240
- * Generates a secure secret for JWT, sessions, etc.
241
- *
242
- * @param length - Optional custom length (default from config)
243
- * @returns Hex-encoded secret
244
- */
245
- generateSecret(length?: number): string {
246
- const len = length ?? this.config.secretLength;
247
- // Generate raw bytes and encode as hex for consistent storage
248
- return randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len);
249
- }
250
-
251
- /**
252
- * Generates an encryption key suitable for AES-256.
253
- *
254
- * @returns 32-byte key encoded as hex (64 characters)
255
- */
256
- generateEncryptionKey(): string {
257
- return randomBytes(32).toString('hex');
258
- }
259
-
260
- /**
261
- * Generates a complete set of installation credentials.
262
- *
263
- * These should be stored securely (environment variables,
264
- * secrets manager, etc.) and NEVER committed to version control.
265
- *
266
- * @param expirationDays - Optional expiration period in days
267
- * @returns Complete credential set
268
- */
269
- generateInstallationCredentials(expirationDays?: number): GeneratedCredentials {
270
- const now = new Date();
271
- const expiresAt = expirationDays
272
- ? new Date(now.getTime() + expirationDays * 24 * 60 * 60 * 1000)
273
- : undefined;
274
-
275
- return {
276
- adminPassword: this.generatePassword(),
277
- servicePassword: this.generatePassword(),
278
- jwtSecret: this.generateSecret(64),
279
- sessionSecret: this.generateSecret(64),
280
- encryptionKey: this.generateEncryptionKey(),
281
- generatedAt: now,
282
- expiresAt,
283
- };
284
- }
285
-
286
- /**
287
- * Generates a secure session token.
288
- *
289
- * @returns URL-safe session token
290
- */
291
- generateSessionToken(): string {
292
- return this.generateSecureString(64, CHARSETS.URL_SAFE);
293
- }
294
-
295
- /**
296
- * Generates a secure CSRF token.
297
- *
298
- * @returns CSRF token
299
- */
300
- generateCsrfToken(): string {
301
- return randomBytes(32).toString('base64url');
302
- }
303
-
304
- /**
305
- * Generates a secure nonce for one-time use.
306
- *
307
- * @returns Unique nonce value
308
- */
309
- generateNonce(): string {
310
- return randomBytes(16).toString('hex');
311
- }
312
-
313
- /**
314
- * Creates a setup script output for secure credential deployment.
315
- *
316
- * @param credentials - Generated credentials
317
- * @returns Environment variable export script
318
- */
319
- createEnvScript(credentials: GeneratedCredentials): string {
320
- return `# Claude Flow V3 - Generated Credentials
321
- # Generated: ${credentials.generatedAt.toISOString()}
322
- # IMPORTANT: Store these securely and delete this file after use
323
-
324
- export CLAUDE_FLOW_ADMIN_PASSWORD="${credentials.adminPassword}"
325
- export CLAUDE_FLOW_SERVICE_PASSWORD="${credentials.servicePassword}"
326
- export CLAUDE_FLOW_JWT_SECRET="${credentials.jwtSecret}"
327
- export CLAUDE_FLOW_SESSION_SECRET="${credentials.sessionSecret}"
328
- export CLAUDE_FLOW_ENCRYPTION_KEY="${credentials.encryptionKey}"
329
- `;
330
- }
331
-
332
- /**
333
- * Creates a JSON configuration output for secure credential deployment.
334
- *
335
- * @param credentials - Generated credentials
336
- * @returns JSON configuration (for secrets manager import)
337
- */
338
- createJsonConfig(credentials: GeneratedCredentials): string {
339
- return JSON.stringify({
340
- 'claude-flow/admin-password': credentials.adminPassword,
341
- 'claude-flow/service-password': credentials.servicePassword,
342
- 'claude-flow/jwt-secret': credentials.jwtSecret,
343
- 'claude-flow/session-secret': credentials.sessionSecret,
344
- 'claude-flow/encryption-key': credentials.encryptionKey,
345
- 'claude-flow/generated-at': credentials.generatedAt.toISOString(),
346
- 'claude-flow/expires-at': credentials.expiresAt?.toISOString() ?? null,
347
- }, null, 2);
348
- }
349
- }
350
-
351
- /**
352
- * Factory function to create a production credential generator.
353
- *
354
- * @returns Configured CredentialGenerator instance
355
- */
356
- export function createCredentialGenerator(): CredentialGenerator {
357
- return new CredentialGenerator();
358
- }
359
-
360
- /**
361
- * Quick credential generation for CLI usage.
362
- *
363
- * @returns Generated installation credentials
364
- */
365
- export function generateCredentials(): GeneratedCredentials {
366
- const generator = new CredentialGenerator();
367
- return generator.generateInstallationCredentials();
368
- }
@@ -1,173 +0,0 @@
1
- /**
2
- * Security Context Entity - Domain Layer
3
- *
4
- * Represents security context for operations with validation and policy enforcement.
5
- *
6
- * @module v3/security/domain/entities
7
- */
8
-
9
- import { randomUUID } from 'crypto';
10
-
11
- /**
12
- * Permission levels
13
- */
14
- export type PermissionLevel = 'read' | 'write' | 'execute' | 'admin';
15
-
16
- /**
17
- * Security context properties
18
- */
19
- export interface SecurityContextProps {
20
- id?: string;
21
- principalId: string;
22
- principalType: 'agent' | 'user' | 'system';
23
- permissions: PermissionLevel[];
24
- allowedPaths?: string[];
25
- blockedPaths?: string[];
26
- allowedCommands?: string[];
27
- blockedCommands?: string[];
28
- metadata?: Record<string, unknown>;
29
- expiresAt?: Date;
30
- createdAt?: Date;
31
- }
32
-
33
- /**
34
- * Security Context - Entity
35
- */
36
- export class SecurityContext {
37
- private _id: string;
38
- private _principalId: string;
39
- private _principalType: 'agent' | 'user' | 'system';
40
- private _permissions: Set<PermissionLevel>;
41
- private _allowedPaths: Set<string>;
42
- private _blockedPaths: Set<string>;
43
- private _allowedCommands: Set<string>;
44
- private _blockedCommands: Set<string>;
45
- private _metadata: Record<string, unknown>;
46
- private _expiresAt?: Date;
47
- private _createdAt: Date;
48
-
49
- private constructor(props: SecurityContextProps) {
50
- this._id = props.id ?? randomUUID();
51
- this._principalId = props.principalId;
52
- this._principalType = props.principalType;
53
- this._permissions = new Set(props.permissions);
54
- this._allowedPaths = new Set(props.allowedPaths ?? []);
55
- this._blockedPaths = new Set(props.blockedPaths ?? []);
56
- this._allowedCommands = new Set(props.allowedCommands ?? []);
57
- this._blockedCommands = new Set(props.blockedCommands ?? []);
58
- this._metadata = props.metadata ?? {};
59
- this._expiresAt = props.expiresAt;
60
- this._createdAt = props.createdAt ?? new Date();
61
- }
62
-
63
- static create(props: SecurityContextProps): SecurityContext {
64
- return new SecurityContext(props);
65
- }
66
-
67
- static fromPersistence(props: SecurityContextProps): SecurityContext {
68
- return new SecurityContext(props);
69
- }
70
-
71
- get id(): string { return this._id; }
72
- get principalId(): string { return this._principalId; }
73
- get principalType(): string { return this._principalType; }
74
- get permissions(): PermissionLevel[] { return Array.from(this._permissions); }
75
- get allowedPaths(): string[] { return Array.from(this._allowedPaths); }
76
- get blockedPaths(): string[] { return Array.from(this._blockedPaths); }
77
- get allowedCommands(): string[] { return Array.from(this._allowedCommands); }
78
- get blockedCommands(): string[] { return Array.from(this._blockedCommands); }
79
- get metadata(): Record<string, unknown> { return { ...this._metadata }; }
80
- get expiresAt(): Date | undefined { return this._expiresAt; }
81
- get createdAt(): Date { return new Date(this._createdAt); }
82
-
83
- // Business Logic
84
-
85
- hasPermission(level: PermissionLevel): boolean {
86
- return this._permissions.has(level) || this._permissions.has('admin');
87
- }
88
-
89
- isExpired(): boolean {
90
- if (!this._expiresAt) return false;
91
- return Date.now() > this._expiresAt.getTime();
92
- }
93
-
94
- canAccessPath(path: string): boolean {
95
- if (this.isExpired()) return false;
96
-
97
- // Check blocked paths first
98
- for (const blocked of this._blockedPaths) {
99
- if (path.startsWith(blocked) || this.matchGlob(path, blocked)) {
100
- return false;
101
- }
102
- }
103
-
104
- // If no allowed paths specified, allow all non-blocked
105
- if (this._allowedPaths.size === 0) return true;
106
-
107
- // Check allowed paths
108
- for (const allowed of this._allowedPaths) {
109
- if (path.startsWith(allowed) || this.matchGlob(path, allowed)) {
110
- return true;
111
- }
112
- }
113
-
114
- return false;
115
- }
116
-
117
- canExecuteCommand(command: string): boolean {
118
- if (this.isExpired()) return false;
119
-
120
- const cmdBase = command.split(' ')[0];
121
-
122
- // Check blocked commands first
123
- if (this._blockedCommands.has(cmdBase) || this._blockedCommands.has(command)) {
124
- return false;
125
- }
126
-
127
- // If no allowed commands specified, allow all non-blocked
128
- if (this._allowedCommands.size === 0) return true;
129
-
130
- // Check allowed commands
131
- return this._allowedCommands.has(cmdBase) || this._allowedCommands.has(command);
132
- }
133
-
134
- private matchGlob(path: string, pattern: string): boolean {
135
- const regex = pattern
136
- .replace(/\*\*/g, '.*')
137
- .replace(/\*/g, '[^/]*')
138
- .replace(/\?/g, '.');
139
- return new RegExp(`^${regex}$`).test(path);
140
- }
141
-
142
- grantPermission(level: PermissionLevel): void {
143
- this._permissions.add(level);
144
- }
145
-
146
- revokePermission(level: PermissionLevel): void {
147
- this._permissions.delete(level);
148
- }
149
-
150
- addAllowedPath(path: string): void {
151
- this._allowedPaths.add(path);
152
- }
153
-
154
- addBlockedPath(path: string): void {
155
- this._blockedPaths.add(path);
156
- }
157
-
158
- toPersistence(): Record<string, unknown> {
159
- return {
160
- id: this._id,
161
- principalId: this._principalId,
162
- principalType: this._principalType,
163
- permissions: Array.from(this._permissions),
164
- allowedPaths: Array.from(this._allowedPaths),
165
- blockedPaths: Array.from(this._blockedPaths),
166
- allowedCommands: Array.from(this._allowedCommands),
167
- blockedCommands: Array.from(this._blockedCommands),
168
- metadata: this._metadata,
169
- expiresAt: this._expiresAt?.toISOString(),
170
- createdAt: this._createdAt.toISOString(),
171
- };
172
- }
173
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Security Domain Layer - Public Exports
3
- *
4
- * @module v3/security/domain
5
- */
6
-
7
- export {
8
- SecurityContext,
9
- type PermissionLevel,
10
- type SecurityContextProps,
11
- } from './entities/security-context.js';
12
-
13
- export {
14
- SecurityDomainService,
15
- type ValidationResult,
16
- type ThreatDetectionResult,
17
- } from './services/security-domain-service.js';