@highflame/policy 2.0.7 → 2.0.9

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 (128) hide show
  1. package/_schemas/overwatch/context.json +163 -1
  2. package/_schemas/overwatch/schema.cedarschema +45 -0
  3. package/dist/actions.gen.d.ts +0 -1
  4. package/dist/actions.gen.js +0 -1
  5. package/dist/annotations.d.ts +0 -1
  6. package/dist/annotations.js +0 -1
  7. package/dist/builder.d.ts +0 -1
  8. package/dist/builder.js +0 -1
  9. package/dist/context.gen.d.ts +0 -1
  10. package/dist/context.gen.js +0 -1
  11. package/dist/engine.d.ts +0 -1
  12. package/dist/engine.js +0 -1
  13. package/dist/entities.gen.d.ts +0 -1
  14. package/dist/entities.gen.js +0 -1
  15. package/dist/entity-metadata-types.gen.d.ts +0 -1
  16. package/dist/entity-metadata-types.gen.js +0 -1
  17. package/dist/errors.d.ts +0 -1
  18. package/dist/errors.js +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +0 -1
  21. package/dist/overwatch-context.gen.d.ts +13 -1
  22. package/dist/overwatch-context.gen.js +13 -1
  23. package/dist/overwatch-defaults.gen.d.ts +1 -2
  24. package/dist/overwatch-defaults.gen.js +346 -2
  25. package/dist/overwatch-entities.gen.d.ts +0 -1
  26. package/dist/overwatch-entities.gen.js +0 -1
  27. package/dist/palisade-context.gen.d.ts +0 -1
  28. package/dist/palisade-context.gen.js +0 -1
  29. package/dist/palisade-entities.gen.d.ts +0 -1
  30. package/dist/palisade-entities.gen.js +0 -1
  31. package/dist/parser.d.ts +0 -1
  32. package/dist/parser.js +0 -1
  33. package/dist/schema.gen.d.ts +0 -1
  34. package/dist/schema.gen.js +0 -1
  35. package/dist/schemas.d.ts +0 -1
  36. package/dist/schemas.js +0 -1
  37. package/dist/service-schemas.gen.d.ts +0 -1
  38. package/dist/service-schemas.gen.js +0 -1
  39. package/dist/types.d.ts +0 -1
  40. package/dist/types.js +0 -1
  41. package/package.json +1 -2
  42. package/dist/actions.gen.d.ts.map +0 -1
  43. package/dist/actions.gen.js.map +0 -1
  44. package/dist/annotations.d.ts.map +0 -1
  45. package/dist/annotations.js.map +0 -1
  46. package/dist/builder.d.ts.map +0 -1
  47. package/dist/builder.js.map +0 -1
  48. package/dist/context.gen.d.ts.map +0 -1
  49. package/dist/context.gen.js.map +0 -1
  50. package/dist/engine.d.ts.map +0 -1
  51. package/dist/engine.js.map +0 -1
  52. package/dist/engine.test.d.ts +0 -8
  53. package/dist/engine.test.d.ts.map +0 -1
  54. package/dist/engine.test.js +0 -190
  55. package/dist/engine.test.js.map +0 -1
  56. package/dist/entities.gen.d.ts.map +0 -1
  57. package/dist/entities.gen.js.map +0 -1
  58. package/dist/entity-metadata-types.gen.d.ts.map +0 -1
  59. package/dist/entity-metadata-types.gen.js.map +0 -1
  60. package/dist/errors.d.ts.map +0 -1
  61. package/dist/errors.js.map +0 -1
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/overwatch-context.gen.d.ts.map +0 -1
  65. package/dist/overwatch-context.gen.js.map +0 -1
  66. package/dist/overwatch-defaults.gen.d.ts.map +0 -1
  67. package/dist/overwatch-defaults.gen.js.map +0 -1
  68. package/dist/overwatch-defaults.test.d.ts +0 -8
  69. package/dist/overwatch-defaults.test.d.ts.map +0 -1
  70. package/dist/overwatch-defaults.test.js +0 -145
  71. package/dist/overwatch-defaults.test.js.map +0 -1
  72. package/dist/overwatch-entities.gen.d.ts.map +0 -1
  73. package/dist/overwatch-entities.gen.js.map +0 -1
  74. package/dist/overwatch-rebac.test.d.ts +0 -25
  75. package/dist/overwatch-rebac.test.d.ts.map +0 -1
  76. package/dist/overwatch-rebac.test.js +0 -301
  77. package/dist/overwatch-rebac.test.js.map +0 -1
  78. package/dist/palisade-context.gen.d.ts.map +0 -1
  79. package/dist/palisade-context.gen.js.map +0 -1
  80. package/dist/palisade-entities.gen.d.ts.map +0 -1
  81. package/dist/palisade-entities.gen.js.map +0 -1
  82. package/dist/parser.d.ts.map +0 -1
  83. package/dist/parser.js.map +0 -1
  84. package/dist/parser.test.d.ts +0 -8
  85. package/dist/parser.test.d.ts.map +0 -1
  86. package/dist/parser.test.js +0 -212
  87. package/dist/parser.test.js.map +0 -1
  88. package/dist/schema.gen.d.ts.map +0 -1
  89. package/dist/schema.gen.js.map +0 -1
  90. package/dist/schemas.d.ts.map +0 -1
  91. package/dist/schemas.js.map +0 -1
  92. package/dist/schemas.test.d.ts +0 -8
  93. package/dist/schemas.test.d.ts.map +0 -1
  94. package/dist/schemas.test.js +0 -375
  95. package/dist/schemas.test.js.map +0 -1
  96. package/dist/service-schemas.gen.d.ts.map +0 -1
  97. package/dist/service-schemas.gen.js.map +0 -1
  98. package/dist/studio-ui.test.d.ts +0 -8
  99. package/dist/studio-ui.test.d.ts.map +0 -1
  100. package/dist/studio-ui.test.js +0 -687
  101. package/dist/studio-ui.test.js.map +0 -1
  102. package/dist/types.d.ts.map +0 -1
  103. package/dist/types.js.map +0 -1
  104. package/src/actions.gen.ts +0 -57
  105. package/src/annotations.ts +0 -243
  106. package/src/builder.ts +0 -799
  107. package/src/context.gen.ts +0 -10
  108. package/src/engine.test.ts +0 -370
  109. package/src/engine.ts +0 -497
  110. package/src/entities.gen.ts +0 -65
  111. package/src/entity-metadata-types.gen.ts +0 -19
  112. package/src/errors.ts +0 -195
  113. package/src/index.ts +0 -62
  114. package/src/overwatch-context.gen.ts +0 -32
  115. package/src/overwatch-defaults.gen.ts +0 -907
  116. package/src/overwatch-defaults.test.ts +0 -176
  117. package/src/overwatch-entities.gen.ts +0 -41
  118. package/src/overwatch-rebac.test.ts +0 -346
  119. package/src/palisade-context.gen.ts +0 -28
  120. package/src/palisade-entities.gen.ts +0 -49
  121. package/src/parser.test.ts +0 -251
  122. package/src/parser.ts +0 -579
  123. package/src/schema.gen.ts +0 -134
  124. package/src/schemas.test.ts +0 -445
  125. package/src/schemas.ts +0 -91
  126. package/src/service-schemas.gen.ts +0 -608
  127. package/src/studio-ui.test.ts +0 -813
  128. package/src/types.ts +0 -66
package/src/engine.ts DELETED
@@ -1,497 +0,0 @@
1
- /**
2
- * Highflame Policy Engine - TypeScript Wrapper
3
- * Wraps @cedar-policy/cedar-wasm with Highflame-specific types
4
- */
5
-
6
- import * as fs from "node:fs";
7
- import * as cedar from "@cedar-policy/cedar-wasm/nodejs";
8
- import { EntityType, EntityUID, Entity } from "./entities.gen.js";
9
- import { ActionType } from "./actions.gen.js";
10
-
11
- // =============================================================================
12
- // INPUT VALIDATION LIMITS (consistent across all language SDKs)
13
- // =============================================================================
14
-
15
- /**
16
- * Default limits for input validation.
17
- * These are consistent across Go, TypeScript, and Python SDKs.
18
- */
19
- export const DEFAULT_LIMITS = {
20
- /** Maximum number of keys in a context map */
21
- maxContextKeys: 100,
22
- /** Maximum length of any string value (1MB) */
23
- maxStringLength: 1_000_000,
24
- /** Maximum nesting depth for objects/arrays */
25
- maxNestingDepth: 10,
26
- /** Maximum total context size in bytes (10MB) */
27
- maxContextSizeBytes: 10_000_000,
28
- } as const;
29
-
30
- export interface InputLimits {
31
- maxContextKeys?: number;
32
- maxStringLength?: number;
33
- maxNestingDepth?: number;
34
- maxContextSizeBytes?: number;
35
- }
36
-
37
- export interface EngineOptions {
38
- /** Cedar schema string (optional - can also use loadSchema() method) */
39
- schema?: string;
40
- /** Custom input validation limits */
41
- limits?: InputLimits;
42
- /** Skip input validation (not recommended for production) */
43
- skipValidation?: boolean;
44
- }
45
-
46
- /**
47
- * Error thrown when input validation fails.
48
- */
49
- export class InputValidationError extends Error {
50
- constructor(message: string) {
51
- super(message);
52
- this.name = "InputValidationError";
53
- }
54
- }
55
-
56
- /**
57
- * Validate context input against configured limits.
58
- * @throws InputValidationError if validation fails
59
- */
60
- function validateContext(
61
- context: Record<string, unknown> | undefined,
62
- limits: Required<InputLimits>,
63
- depth: number = 0
64
- ): void {
65
- if (!context) return;
66
-
67
- // Check nesting depth
68
- if (depth > limits.maxNestingDepth) {
69
- throw new InputValidationError(
70
- `Context nesting depth exceeds maximum of ${limits.maxNestingDepth}`
71
- );
72
- }
73
-
74
- const keys = Object.keys(context);
75
-
76
- // Check number of keys (only at top level)
77
- if (depth === 0 && keys.length > limits.maxContextKeys) {
78
- throw new InputValidationError(
79
- `Context has ${keys.length} keys, exceeds maximum of ${limits.maxContextKeys}`
80
- );
81
- }
82
-
83
- // Check total size (only at top level)
84
- if (depth === 0) {
85
- let contextStr: string;
86
- try {
87
- contextStr = JSON.stringify(context);
88
- } catch (e) {
89
- throw new InputValidationError(
90
- `Context is invalid or too complex: ${e instanceof Error ? e.message : String(e)}`
91
- );
92
- }
93
- if (contextStr.length > limits.maxContextSizeBytes) {
94
- throw new InputValidationError(
95
- `Context size (${contextStr.length} bytes) exceeds maximum of ${limits.maxContextSizeBytes} bytes`
96
- );
97
- }
98
- }
99
-
100
- // Validate each value
101
- for (const value of Object.values(context)) {
102
- validateValue(value, limits, depth);
103
- }
104
- }
105
-
106
- function validateValue(
107
- value: unknown,
108
- limits: Required<InputLimits>,
109
- depth: number
110
- ): void {
111
- if (value === null || value === undefined) return;
112
-
113
- if (typeof value === "string") {
114
- if (value.length > limits.maxStringLength) {
115
- throw new InputValidationError(
116
- `String value length (${value.length}) exceeds maximum of ${limits.maxStringLength}`
117
- );
118
- }
119
- return;
120
- }
121
-
122
- if (Array.isArray(value)) {
123
- if (depth + 1 > limits.maxNestingDepth) {
124
- throw new InputValidationError(
125
- `Array nesting depth exceeds maximum of ${limits.maxNestingDepth}`
126
- );
127
- }
128
- for (const item of value) {
129
- validateValue(item, limits, depth + 1);
130
- }
131
- return;
132
- }
133
-
134
- if (typeof value === "object") {
135
- validateContext(value as Record<string, unknown>, limits, depth + 1);
136
- }
137
- }
138
-
139
- export class Decision {
140
- readonly effect: "Allow" | "Deny";
141
- readonly determining_policies: string[];
142
- readonly reason?: string;
143
-
144
- constructor(effect: "Allow" | "Deny", determining_policies: string[], reason?: string) {
145
- this.effect = effect;
146
- this.determining_policies = determining_policies;
147
- this.reason = reason;
148
- }
149
-
150
- isAllowed(): boolean {
151
- return this.effect === "Allow";
152
- }
153
-
154
- isDenied(): boolean {
155
- return this.effect === "Deny";
156
- }
157
- }
158
-
159
- export interface EvaluateRequest {
160
- principal: EntityUID;
161
- /**
162
- * Action to evaluate. Can be:
163
- * - A generated ActionType value (e.g., ActionType.CallTool)
164
- * - A namespaced action string (e.g., 'Overwatch::Action::"call_tool"')
165
- */
166
- action: ActionType | string;
167
- resource: EntityUID;
168
- context?: Record<string, unknown>;
169
- entities?: Entity[];
170
- }
171
-
172
- /**
173
- * Convert a value to Cedar JSON format
174
- */
175
- function toCedarValue(value: unknown): cedar.CedarValueJson {
176
- if (value === null || value === undefined) {
177
- return null;
178
- }
179
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
180
- return value;
181
- }
182
- if (Array.isArray(value)) {
183
- return value.map(toCedarValue);
184
- }
185
- if (typeof value === "object") {
186
- const result: Record<string, cedar.CedarValueJson> = {};
187
- for (const [k, v] of Object.entries(value)) {
188
- result[k] = toCedarValue(v);
189
- }
190
- return result;
191
- }
192
- return String(value);
193
- }
194
-
195
- /**
196
- * Parse an action string into Cedar EntityUID format.
197
- * Handles both non-namespaced and namespaced actions:
198
- * - "call_tool" → { type: "Action", id: "call_tool" }
199
- * - "Overwatch::Action::\"call_tool\"" → { type: "Overwatch::Action", id: "call_tool" }
200
- * - "Overwatch::Action::call_tool" → { type: "Overwatch::Action", id: "call_tool" }
201
- */
202
- function parseActionString(action: string): cedar.EntityUidJson {
203
- // Check if action contains namespace separator
204
- if (!action.includes("::")) {
205
- // Non-namespaced action
206
- return { type: "Action", id: action };
207
- }
208
-
209
- // Namespaced action - find the last :: separator
210
- const lastSeparator = action.lastIndexOf("::");
211
- const actionType = action.substring(0, lastSeparator);
212
- let actionId = action.substring(lastSeparator + 2);
213
-
214
- // Remove surrounding quotes if present (e.g., "call_tool" → call_tool)
215
- if (actionId.startsWith('"') && actionId.endsWith('"')) {
216
- actionId = actionId.slice(1, -1);
217
- }
218
-
219
- return { type: actionType, id: actionId };
220
- }
221
-
222
- /**
223
- * Extract @id annotations from Cedar policy text and return a
224
- * Record<PolicyId, Policy> for cedar-wasm. This ensures that
225
- * determining_policies in evaluation results use the @id values
226
- * instead of positional IDs (policy0, policy1...).
227
- *
228
- * Falls back to the raw string when no @id annotations are found.
229
- */
230
- function extractPolicyIds(policyText: string): cedar.StaticPolicySet {
231
- const parts = cedar.policySetTextToParts(policyText);
232
- if (parts.type !== "success" || parts.policies.length === 0) {
233
- return policyText;
234
- }
235
-
236
- const policyMap: Record<string, string> = {};
237
- let hasAnnotationIds = false;
238
-
239
- for (let i = 0; i < parts.policies.length; i++) {
240
- const policy = parts.policies[i];
241
- const idMatch = policy.match(/@id\("([^"]+)"\)/);
242
- if (idMatch) {
243
- policyMap[idMatch[1]] = policy;
244
- hasAnnotationIds = true;
245
- } else {
246
- policyMap[`policy${i}`] = policy;
247
- }
248
- }
249
-
250
- return hasAnnotationIds ? policyMap : policyText;
251
- }
252
-
253
- /**
254
- * PolicyEngine wraps cedar-wasm with Highflame schema types.
255
- */
256
- export class PolicyEngine {
257
- private policySet: cedar.StaticPolicySet = "";
258
- private schema: string | undefined;
259
- private options: EngineOptions;
260
- private limits: Required<InputLimits>;
261
-
262
- constructor(options?: EngineOptions) {
263
- this.options = options ?? {};
264
- this.schema = options?.schema;
265
- this.limits = {
266
- maxContextKeys: options?.limits?.maxContextKeys ?? DEFAULT_LIMITS.maxContextKeys,
267
- maxStringLength: options?.limits?.maxStringLength ?? DEFAULT_LIMITS.maxStringLength,
268
- maxNestingDepth: options?.limits?.maxNestingDepth ?? DEFAULT_LIMITS.maxNestingDepth,
269
- maxContextSizeBytes: options?.limits?.maxContextSizeBytes ?? DEFAULT_LIMITS.maxContextSizeBytes,
270
- };
271
- }
272
-
273
- /**
274
- * Load Cedar policies from a file.
275
- */
276
- loadPoliciesFromFile(path: string): void {
277
- const content = fs.readFileSync(path, "utf-8");
278
- this.loadPolicy(content);
279
- }
280
-
281
- /**
282
- * Load a single Cedar policy text string.
283
- * Uses @id annotations as policy IDs when available.
284
- */
285
- loadPolicy(policy: string): void {
286
- this.policySet = extractPolicyIds(policy);
287
- }
288
-
289
- /**
290
- * Load multiple Cedar policy texts (concatenated with newlines).
291
- * Uses @id annotations as policy IDs when available.
292
- */
293
- loadPolicies(policies: string[]): void {
294
- this.policySet = extractPolicyIds(policies.join("\n"));
295
- }
296
-
297
- /**
298
- * Load schema from a Cedar schema string.
299
- */
300
- loadSchema(schema: string): void {
301
- this.schema = schema;
302
- }
303
-
304
- /**
305
- * Load schema from a Cedar schema file.
306
- */
307
- loadSchemaFromFile(path: string): void {
308
- const content = fs.readFileSync(path, "utf-8");
309
- this.loadSchema(content);
310
- }
311
-
312
- /**
313
- * Evaluate a policy request and return a decision.
314
- * @throws InputValidationError if context validation fails
315
- */
316
- evaluate(req: EvaluateRequest): Decision {
317
- // Validate input unless explicitly skipped
318
- if (!this.options.skipValidation) {
319
- validateContext(req.context, this.limits);
320
- }
321
-
322
- // Build EntityUIDs in Cedar JSON format
323
- const principal: cedar.EntityUidJson = {
324
- type: req.principal.type,
325
- id: req.principal.id,
326
- };
327
- const action: cedar.EntityUidJson = parseActionString(req.action);
328
- const resource: cedar.EntityUidJson = {
329
- type: req.resource.type,
330
- id: req.resource.id,
331
- };
332
-
333
- // Convert context to Cedar format
334
- const context: cedar.Context = {};
335
- if (req.context) {
336
- for (const [k, v] of Object.entries(req.context)) {
337
- context[k] = toCedarValue(v);
338
- }
339
- }
340
-
341
- // Convert entities to Cedar JSON format
342
- const entities = (req.entities || []).map(e => ({
343
- uid: e.uid,
344
- attrs: e.attrs ? Object.fromEntries(
345
- Object.entries(e.attrs).map(([k, v]) => [k, toCedarValue(v)])
346
- ) : {},
347
- parents: e.parents || [],
348
- }));
349
-
350
- // Build the authorization call
351
- const call: cedar.AuthorizationCall = {
352
- principal,
353
- action,
354
- resource,
355
- context,
356
- policies: { staticPolicies: this.policySet },
357
- entities,
358
- };
359
-
360
- // Add schema if available
361
- if (this.schema) {
362
- call.schema = this.schema;
363
- }
364
-
365
- const result = cedar.isAuthorized(call);
366
-
367
- if (result.type === "failure") {
368
- return new Decision(
369
- "Deny",
370
- [],
371
- result.errors.map(e => e.message).join("; "),
372
- );
373
- }
374
-
375
- return new Decision(
376
- result.response.decision === "allow" ? "Allow" : "Deny",
377
- result.response.diagnostics.reason,
378
- result.response.diagnostics.errors.length > 0
379
- ? result.response.diagnostics.errors.map(e => e.error.message).join("; ")
380
- : undefined,
381
- );
382
- }
383
-
384
- /**
385
- * Convenience method for simple evaluations.
386
- * @throws InputValidationError if context validation fails
387
- */
388
- evaluateSimple(
389
- principalType: EntityType,
390
- principalId: string,
391
- action: ActionType | string,
392
- resourceType: EntityType,
393
- resourceId: string,
394
- context?: Record<string, unknown>
395
- ): Decision {
396
- return this.evaluate({
397
- principal: { type: principalType, id: principalId },
398
- action,
399
- resource: { type: resourceType, id: resourceId },
400
- context,
401
- });
402
- }
403
-
404
- /**
405
- * Validate policies against the schema.
406
- * Returns validation errors or empty array if valid.
407
- */
408
- validatePolicies(policies: string): string[] {
409
- if (!this.schema) {
410
- throw new Error("Schema is required for validation. Provide schema via constructor options or loadSchema().");
411
- }
412
-
413
- const result = cedar.validate({
414
- validationSettings: { mode: "strict" },
415
- schema: this.schema,
416
- policies: { staticPolicies: policies },
417
- });
418
-
419
- if (result.type === "failure") {
420
- return result.errors.map(e => e.message);
421
- }
422
-
423
- return result.validationErrors.map(e => e.error.message);
424
- }
425
- }
426
-
427
- /**
428
- * PolicyValidator provides static validation against the Highflame schema.
429
- * Use this for quick validation without creating an engine instance.
430
- */
431
- export class PolicyValidator {
432
- private schema: string;
433
-
434
- /**
435
- * Create a validator with a Cedar schema.
436
- * @param schema Cedar schema string (required)
437
- */
438
- constructor(schema: string) {
439
- this.schema = schema;
440
- }
441
-
442
- /**
443
- * Validate Cedar policy text against the schema.
444
- */
445
- validate(policies: string): { valid: boolean; errors: string[] } {
446
- const result = cedar.validate({
447
- validationSettings: { mode: "strict" },
448
- schema: this.schema,
449
- policies: { staticPolicies: policies },
450
- });
451
-
452
- if (result.type === "failure") {
453
- return {
454
- valid: false,
455
- errors: result.errors.map(e => e.message),
456
- };
457
- }
458
-
459
- if (result.validationErrors.length > 0) {
460
- return {
461
- valid: false,
462
- errors: result.validationErrors.map(e => e.error.message),
463
- };
464
- }
465
-
466
- return { valid: true, errors: [] };
467
- }
468
-
469
- /**
470
- * Check if a policy parses correctly (syntax check only).
471
- */
472
- checkSyntax(policies: string): { valid: boolean; errors: string[] } {
473
- const result = cedar.checkParsePolicySet({ staticPolicies: policies });
474
- if (result.type === "failure") {
475
- return {
476
- valid: false,
477
- errors: result.errors.map(e => e.message),
478
- };
479
- }
480
- return { valid: true, errors: [] };
481
- }
482
- }
483
-
484
- /**
485
- * Validate a Cedar policy against a schema.
486
- * Convenience function that doesn't require creating a validator instance.
487
- * @param schema Cedar schema string
488
- * @param policy Policy text to validate
489
- */
490
- export function validatePolicy(schema: string, policy: string): { valid: boolean; errors: string[] } {
491
- const validator = new PolicyValidator(schema);
492
- return validator.validate(policy);
493
- }
494
-
495
- // Re-export types
496
- export { EntityType, EntityUID, Entity, newEntityUID, newEntity } from "./entities.gen.js";
497
- export { ActionType, actionUID } from "./actions.gen.js";
@@ -1,65 +0,0 @@
1
- // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
- // Source: schema/highflame.cedarschema
3
-
4
- /**
5
- * Entity types defined in the Highflame Cedar schema.
6
- */
7
- export const EntityType = {
8
- Agent: 'Agent',
9
- Artifact: 'Artifact',
10
- ExternalAPI: 'ExternalAPI',
11
- FilePath: 'FilePath',
12
- GitBranch: 'GitBranch',
13
- HttpEndpoint: 'HttpEndpoint',
14
- LlmPrompt: 'LlmPrompt',
15
- Memory: 'Memory',
16
- Model: 'Model',
17
- Package: 'Package',
18
- Repository: 'Repository',
19
- Resource: 'Resource',
20
- ResponseData: 'ResponseData',
21
- Scanner: 'Scanner',
22
- Server: 'Server',
23
- Service: 'Service',
24
- Tool: 'Tool',
25
- User: 'User',
26
- } as const;
27
-
28
- export type EntityType = (typeof EntityType)[keyof typeof EntityType];
29
-
30
- /**
31
- * Cedar entity unique identifier.
32
- */
33
- export interface EntityUID {
34
- type: EntityType | string;
35
- id: string;
36
- }
37
-
38
- /**
39
- * Cedar entity with attributes.
40
- */
41
- export interface Entity {
42
- uid: EntityUID;
43
- attrs?: Record<string, unknown>;
44
- parents?: EntityUID[];
45
- }
46
-
47
- /**
48
- * Create a new EntityUID.
49
- * Services should use this with their own identity from config/environment.
50
- * @example newEntityUID(EntityType.Scanner, process.env.SERVICE_ID)
51
- */
52
- export function newEntityUID(type: EntityType | string, id: string): EntityUID {
53
- return { type, id };
54
- }
55
-
56
- /**
57
- * Create a new Entity.
58
- */
59
- export function newEntity(type: EntityType | string, id: string, attrs?: Record<string, unknown>): Entity {
60
- return {
61
- uid: { type, id },
62
- attrs: attrs ?? {},
63
- parents: [],
64
- };
65
- }
@@ -1,19 +0,0 @@
1
- // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
-
3
- /**
4
- * Entity metadata for a service, extracted from Cedar schema appliesTo blocks.
5
- * Used by Studio UI to populate dropdowns in policy editor.
6
- */
7
- export interface ServiceEntityMetadata {
8
- readonly principals: readonly string[];
9
- readonly resources: readonly string[];
10
- readonly actions: readonly string[];
11
- }
12
-
13
- /**
14
- * Entity metadata for a specific action.
15
- */
16
- export interface ActionEntityMetadata {
17
- readonly principals: readonly string[];
18
- readonly resources: readonly string[];
19
- }