@limetry/sdk 1.2.55 → 1.2.58

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.
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Helpers that expand a small set of limits into full Limetry policy documents.
3
+ *
4
+ * Prefer these builders for CLI/MCP first-run instead of hand-rolled JSON.
5
+ */
6
+ import type { ActionPolicy, SpendingPolicy } from "../types.js";
7
+ /**
8
+ * Minimal input used by {@link createSlimPolicy} to build a {@link SpendingPolicy}.
9
+ */
10
+ export type SlimPolicyInput = {
11
+ /**
12
+ * Agent identity the policy governs.
13
+ */
14
+ agentId: string;
15
+ /**
16
+ * Owning organization id; defaults to `"default"`.
17
+ */
18
+ organizationId?: string;
19
+ /**
20
+ * Maximum amount allowed for a single transaction (minor units).
21
+ */
22
+ maxSingleTransactionMinor: number;
23
+ /**
24
+ * Maximum aggregate daily spend (minor units).
25
+ */
26
+ maxDailySpendMinor: number;
27
+ /**
28
+ * Maximum aggregate monthly spend (minor units); defaults to `maxDailySpendMinor * 30`.
29
+ */
30
+ maxMonthlySpendMinor?: number;
31
+ /**
32
+ * ISO 4217 currency code; defaults to `"USD"`.
33
+ */
34
+ currency?: string;
35
+ /**
36
+ * Per-minute transaction cap; defaults to `10`. Hour/day caps are derived from this.
37
+ */
38
+ maxTransactionsPerMinute?: number;
39
+ /**
40
+ * Optional merchant allowlist; when non-empty, allowlist enforcement is enabled.
41
+ */
42
+ allowedMerchantIds?: string[];
43
+ /**
44
+ * Optional stable policy id; a UUID is generated when omitted.
45
+ */
46
+ policyId?: string;
47
+ };
48
+ /**
49
+ * Minimal input used by {@link createSlimActionPolicy} to build an {@link ActionPolicy}.
50
+ */
51
+ export type SlimActionPolicyInput = {
52
+ /**
53
+ * Agent identity the policy governs.
54
+ */
55
+ agentId: string;
56
+ /**
57
+ * Owning organization id; defaults to `"default"`.
58
+ */
59
+ organizationId?: string;
60
+ /**
61
+ * Action types that are permitted when other rules pass.
62
+ */
63
+ allowedActionTypes: string[];
64
+ /**
65
+ * Action types that are always denied.
66
+ */
67
+ deniedActionTypes?: string[];
68
+ /**
69
+ * Glob/pattern list of resources that are allowed.
70
+ */
71
+ allowedResourcePatterns?: string[];
72
+ /**
73
+ * Glob/pattern list of resources that are blocked.
74
+ */
75
+ blockedResourcePatterns?: string[];
76
+ /**
77
+ * Maximum allowed intent cost in minor units.
78
+ */
79
+ maxCostMinor?: number;
80
+ /**
81
+ * Currency expected for cost checks when set.
82
+ */
83
+ currency?: string;
84
+ /**
85
+ * Optional stable policy id; a UUID is generated when omitted.
86
+ */
87
+ policyId?: string;
88
+ /**
89
+ * Audit retention mode; defaults to `"minimal"`.
90
+ */
91
+ auditMode?: "minimal" | "forensics";
92
+ /**
93
+ * Action types that still require human approval after allow rules pass.
94
+ */
95
+ requireApprovalActionTypes?: string[];
96
+ /**
97
+ * Resource patterns that force approval when matched.
98
+ */
99
+ requireApprovalResourcePatterns?: string[];
100
+ /**
101
+ * Inclusive cost threshold (minor units) that forces approval when cost is set.
102
+ */
103
+ approvalCostMinor?: number;
104
+ };
105
+ /**
106
+ * Builds a full {@link SpendingPolicy} from a small set of limits.
107
+ *
108
+ * Prefer this for CLI/MCP first-run instead of hand-rolled JSON. Sets version
109
+ * `1`, status `"active"`, sensible replay/isolation defaults, and derives
110
+ * velocity and monthly caps when those inputs are omitted.
111
+ *
112
+ * @param input - Slim spending limits and identity fields.
113
+ * @returns Fully populated {@link SpendingPolicy} ready for persistence or evaluation.
114
+ */
115
+ export declare function createSlimPolicy(input: SlimPolicyInput): SpendingPolicy;
116
+ /**
117
+ * Builds a generic {@link ActionPolicy} from a small set of action constraints.
118
+ *
119
+ * Sets version `1`, status `"active"`, `audit_mode` to the input or `"minimal"`,
120
+ * and an open-ended effective window starting now.
121
+ *
122
+ * @param input - Slim action constraints and identity fields.
123
+ * @returns Fully populated {@link ActionPolicy} ready for persistence or evaluation.
124
+ */
125
+ export declare function createSlimActionPolicy(input: SlimActionPolicyInput): ActionPolicy;
126
+ //# sourceMappingURL=slim-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slim-policy.d.ts","sourceRoot":"","sources":["../../src/policy/slim-policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAA;IACjC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAA;IAClC;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAA;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,WAAW,CAAA;IACnC;;OAEG;IACH,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAA;IACrC;;OAEG;IACH,+BAA+B,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1C;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,cAAc,CAkDvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAwBjF"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Helpers that expand a small set of limits into full Limetry policy documents.
3
+ *
4
+ * Prefer these builders for CLI/MCP first-run instead of hand-rolled JSON.
5
+ */
6
+ import { randomUUID } from "node:crypto";
7
+ /**
8
+ * Builds a full {@link SpendingPolicy} from a small set of limits.
9
+ *
10
+ * Prefer this for CLI/MCP first-run instead of hand-rolled JSON. Sets version
11
+ * `1`, status `"active"`, sensible replay/isolation defaults, and derives
12
+ * velocity and monthly caps when those inputs are omitted.
13
+ *
14
+ * @param input - Slim spending limits and identity fields.
15
+ * @returns Fully populated {@link SpendingPolicy} ready for persistence or evaluation.
16
+ */
17
+ export function createSlimPolicy(input) {
18
+ const currency = input.currency ?? "USD";
19
+ const policyId = input.policyId ?? randomUUID();
20
+ const now = new Date().toISOString();
21
+ const allowed = input.allowedMerchantIds ?? [];
22
+ const maxSingle = input.maxSingleTransactionMinor;
23
+ const maxDaily = input.maxDailySpendMinor;
24
+ const maxMonthly = input.maxMonthlySpendMinor ?? maxDaily * 30;
25
+ return {
26
+ policy_id: policyId,
27
+ version: 1,
28
+ organization_id: input.organizationId ?? "default",
29
+ agent_id: input.agentId,
30
+ limits: {
31
+ max_single_transaction_minor: maxSingle,
32
+ max_daily_spend_minor: maxDaily,
33
+ max_monthly_spend_minor: maxMonthly,
34
+ currency,
35
+ },
36
+ velocity: {
37
+ max_transactions_per_minute: input.maxTransactionsPerMinute ?? 10,
38
+ max_transactions_per_hour: (input.maxTransactionsPerMinute ?? 10) * 20,
39
+ max_transactions_per_day: (input.maxTransactionsPerMinute ?? 10) * 100,
40
+ max_aggregate_amount_per_hour_minor: Math.min(maxDaily, maxSingle * 20),
41
+ },
42
+ replay: {
43
+ nonce_window_seconds: 300,
44
+ max_clock_skew_seconds: 300,
45
+ require_monotonic_nonce: true,
46
+ },
47
+ isolation: {
48
+ max_concurrent_pending_intents: 5,
49
+ max_pending_aggregate_minor: maxSingle * 5,
50
+ intent_ttl_seconds: 300,
51
+ enforce_unique_payee_per_intent_batch: true,
52
+ },
53
+ destination_rules: {
54
+ allowed_merchant_ids: allowed,
55
+ allowed_mcc_codes: [],
56
+ blocked_merchant_ids: [],
57
+ require_merchant_allowlist: allowed.length > 0,
58
+ },
59
+ effective_window: {
60
+ effective_from: now,
61
+ expires_at: null,
62
+ },
63
+ status: "active",
64
+ updated_at: now,
65
+ };
66
+ }
67
+ /**
68
+ * Builds a generic {@link ActionPolicy} from a small set of action constraints.
69
+ *
70
+ * Sets version `1`, status `"active"`, `audit_mode` to the input or `"minimal"`,
71
+ * and an open-ended effective window starting now.
72
+ *
73
+ * @param input - Slim action constraints and identity fields.
74
+ * @returns Fully populated {@link ActionPolicy} ready for persistence or evaluation.
75
+ */
76
+ export function createSlimActionPolicy(input) {
77
+ const policyId = input.policyId ?? randomUUID();
78
+ const now = new Date().toISOString();
79
+ return {
80
+ policy_id: policyId,
81
+ version: 1,
82
+ organization_id: input.organizationId ?? "default",
83
+ agent_id: input.agentId,
84
+ allowed_action_types: input.allowedActionTypes,
85
+ denied_action_types: input.deniedActionTypes,
86
+ allowed_resource_patterns: input.allowedResourcePatterns,
87
+ blocked_resource_patterns: input.blockedResourcePatterns,
88
+ max_cost_minor: input.maxCostMinor,
89
+ currency: input.currency,
90
+ require_approval_action_types: input.requireApprovalActionTypes,
91
+ require_approval_resource_patterns: input.requireApprovalResourcePatterns,
92
+ approval_cost_minor: input.approvalCostMinor,
93
+ audit_mode: input.auditMode ?? "minimal",
94
+ status: "active",
95
+ updated_at: now,
96
+ effective_from: now,
97
+ expires_at: null,
98
+ };
99
+ }
100
+ //# sourceMappingURL=slim-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slim-policy.js","sourceRoot":"","sources":["../../src/policy/slim-policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAwGxC;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAA;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,UAAU,EAAE,CAAA;IAC/C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,kBAAkB,IAAI,EAAE,CAAA;IAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,yBAAyB,CAAA;IACjD,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAA;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,oBAAoB,IAAI,QAAQ,GAAG,EAAE,CAAA;IAE9D,OAAO;QACL,SAAS,EAAE,QAAQ;QACnB,OAAO,EAAE,CAAC;QACV,eAAe,EAAE,KAAK,CAAC,cAAc,IAAI,SAAS;QAClD,QAAQ,EAAE,KAAK,CAAC,OAAO;QACvB,MAAM,EAAE;YACN,4BAA4B,EAAE,SAAS;YACvC,qBAAqB,EAAE,QAAQ;YAC/B,uBAAuB,EAAE,UAAU;YACnC,QAAQ;SACT;QACD,QAAQ,EAAE;YACR,2BAA2B,EAAE,KAAK,CAAC,wBAAwB,IAAI,EAAE;YACjE,yBAAyB,EAAE,CAAC,KAAK,CAAC,wBAAwB,IAAI,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,uBAAuB;QACxD,cAAc,EAAE,KAAK,CAAC,YAAY;QAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,6BAA6B,EAAE,KAAK,CAAC,0BAA0B;QAC/D,kCAAkC,EAAE,KAAK,CAAC,+BAA+B;QACzE,mBAAmB,EAAE,KAAK,CAAC,iBAAiB;QAC5C,UAAU,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;QACxC,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,IAAI;KACjB,CAAA;AACH,CAAC"}
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Privacy helpers for scrubbing secrets from intents and building audit projections.
3
+ *
4
+ * Used when persisting authorization requests/responses and `policy.evaluated` /
5
+ * `action.recorded` audit detail blobs so raw credentials are never stored.
6
+ */
7
+ import type { ActionIntent } from "../types.js";
8
+ /**
9
+ * Audit retention modes for ActionPolicy.
10
+ * - minimal: store decision projection only (default)
11
+ * - forensics: store redacted intent + details after secret scrubbing
12
+ */
13
+ export type AuditMode = "minimal" | "forensics";
14
+ /**
15
+ * Default audit retention mode when a policy or env override is absent.
16
+ */
17
+ export declare const DEFAULT_AUDIT_MODE: AuditMode;
18
+ /**
19
+ * Returns whether a metadata/details key name looks like a secret or credential.
20
+ *
21
+ * @param key - Object key to test.
22
+ * @returns `true` when the key name matches known secret/credential patterns.
23
+ */
24
+ export declare function isSensitiveKey(key: string): boolean;
25
+ /**
26
+ * Strips query string, hash, and URL userinfo from a resource identifier.
27
+ *
28
+ * Non-URL resources are returned unchanged after trimming; if a `?` is present
29
+ * on a non-URL string, only the prefix before the query is kept.
30
+ *
31
+ * @param resource - Resource identifier (URL or opaque string).
32
+ * @returns Scrubbed resource string.
33
+ */
34
+ export declare function scrubResource(resource: string): string;
35
+ /**
36
+ * Drops or redacts sensitive keys from a string metadata map.
37
+ *
38
+ * Sensitive keys keep their key but get value `"[REDACTED]"`; other values
39
+ * pass through {@link scrubEmbeddedSecrets}. Returns `undefined` for empty
40
+ * or missing input.
41
+ *
42
+ * @param metadata - Optional string key/value metadata bag.
43
+ * @returns Redacted metadata, or `undefined` when empty/absent.
44
+ */
45
+ export declare function redactMetadata(metadata: Record<string, string> | undefined): Record<string, string> | undefined;
46
+ /**
47
+ * Recursively redacts sensitive keys and scrubs string values in open JSON bags.
48
+ *
49
+ * @param details - Optional open JSON object.
50
+ * @returns Redacted deep copy, or `undefined` when input is absent.
51
+ */
52
+ export declare function redactDetails(details: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
53
+ /**
54
+ * Redacts common secret patterns embedded in free-text / URL query values.
55
+ *
56
+ * Replaces query param values for token-like keys, Bearer tokens, and
57
+ * `sk_live` / `sk_test` style secret key literals.
58
+ *
59
+ * @param value - Free-text string that may embed secrets.
60
+ * @returns String with matched secret substrings replaced by `"[REDACTED]"`.
61
+ */
62
+ export declare function scrubEmbeddedSecrets(value: string): string;
63
+ /**
64
+ * Returns an {@link ActionIntent} safe to log or forward after secret scrubbing.
65
+ *
66
+ * Resource query strings are removed; sensitive metadata keys are redacted.
67
+ *
68
+ * @param intent - Original action intent.
69
+ * @returns Shallow copy with scrubbed `resource` and redacted `metadata`.
70
+ */
71
+ export declare function redactActionIntent(intent: ActionIntent): ActionIntent;
72
+ /**
73
+ * Intent fields retained in audit / authorization projections after scrubbing.
74
+ */
75
+ export type AuditIntentProjection = {
76
+ /**
77
+ * Intent identifier.
78
+ */
79
+ intent_id: string;
80
+ /**
81
+ * Policy identifier.
82
+ */
83
+ policy_id: string;
84
+ /**
85
+ * Agent identifier.
86
+ */
87
+ agent_id: string;
88
+ /**
89
+ * Action type string.
90
+ */
91
+ action_type: string;
92
+ /**
93
+ * Scrubbed resource identifier.
94
+ */
95
+ resource: string;
96
+ /**
97
+ * Optional cost object (unchanged; not secret-scrubbed beyond intent redaction).
98
+ */
99
+ cost?: ActionIntent["cost"];
100
+ /**
101
+ * Issue timestamp (ISO-8601).
102
+ */
103
+ issued_at: string;
104
+ /**
105
+ * Redacted metadata; present only in `forensics` mode projections.
106
+ */
107
+ metadata?: Record<string, string>;
108
+ };
109
+ /**
110
+ * Builds the intent payload stored in audit / authorization rows.
111
+ *
112
+ * `minimal` drops metadata; `forensics` keeps redacted metadata.
113
+ *
114
+ * @param intent - Original action intent.
115
+ * @param mode - Audit retention mode; defaults to {@link DEFAULT_AUDIT_MODE}.
116
+ * @returns Projection suitable for persistence.
117
+ */
118
+ export declare function projectIntentForAudit(intent: ActionIntent, mode?: AuditMode): AuditIntentProjection;
119
+ /**
120
+ * Inputs for {@link buildEvaluatedAuditDetails}.
121
+ */
122
+ export type EvaluatedAuditDetailsInput = {
123
+ /**
124
+ * Whether the policy evaluation approved the intent.
125
+ */
126
+ approved: boolean;
127
+ /**
128
+ * Human-readable decision reasons.
129
+ */
130
+ reasons: string[];
131
+ /**
132
+ * Policy identifier under evaluation.
133
+ */
134
+ policy_id: string;
135
+ /**
136
+ * Intent being audited.
137
+ */
138
+ intent: ActionIntent;
139
+ /**
140
+ * Optional audit mode; defaults to {@link DEFAULT_AUDIT_MODE}.
141
+ */
142
+ mode?: AuditMode;
143
+ /**
144
+ * When true, adds `legacy: true` to the details blob.
145
+ */
146
+ legacy?: boolean;
147
+ };
148
+ /**
149
+ * Builds the details blob for `policy.evaluated` audit events.
150
+ *
151
+ * @param input - Approval result, policy id, intent, and optional mode/legacy flags.
152
+ * @returns JSON-serializable audit details object.
153
+ */
154
+ export declare function buildEvaluatedAuditDetails(input: EvaluatedAuditDetailsInput): Record<string, unknown>;
155
+ /**
156
+ * Inputs for {@link buildRecordedAuditDetails}.
157
+ */
158
+ export type RecordedAuditDetailsInput = {
159
+ /**
160
+ * Recording outcome for the action.
161
+ */
162
+ outcome: "executed" | "skipped" | "blocked";
163
+ /**
164
+ * Correlated decision id, if any.
165
+ */
166
+ decision_id?: string | null;
167
+ /**
168
+ * Intent being audited.
169
+ */
170
+ intent: ActionIntent;
171
+ /**
172
+ * Optional open JSON details; included (redacted) only in `forensics` mode.
173
+ */
174
+ details?: Record<string, unknown>;
175
+ /**
176
+ * Optional audit mode; defaults to {@link DEFAULT_AUDIT_MODE}.
177
+ */
178
+ mode?: AuditMode;
179
+ };
180
+ /**
181
+ * Builds the details blob for `action.recorded` audit events.
182
+ *
183
+ * In `forensics` mode, includes a redacted `details` object (empty object when
184
+ * absent). In `minimal` mode, omits the `details` field.
185
+ *
186
+ * @param input - Outcome, intent, and optional decision id / details / mode.
187
+ * @returns JSON-serializable audit details object.
188
+ */
189
+ export declare function buildRecordedAuditDetails(input: RecordedAuditDetailsInput): Record<string, unknown>;
190
+ /**
191
+ * Resolves audit mode from a policy document or environment default.
192
+ *
193
+ * Prefers a valid `policy.audit_mode`, then a valid `envDefault`, otherwise
194
+ * {@link DEFAULT_AUDIT_MODE}.
195
+ *
196
+ * @param policy - Policy-like object that may carry `audit_mode`, or nullish.
197
+ * @param envDefault - Optional environment default string.
198
+ * @returns Resolved {@link AuditMode}.
199
+ */
200
+ export declare function resolveAuditMode(policy: {
201
+ audit_mode?: AuditMode | string | null;
202
+ } | null | undefined, envDefault?: string | null): AuditMode;
203
+ /**
204
+ * Builds a minimized authorization request projection for Cloud persistence.
205
+ *
206
+ * Keeps a digest of the original intent; never stores raw secrets.
207
+ *
208
+ * @param input - Tenant/policy ids, intent, digest hex, and optional audit mode.
209
+ * @returns JSON-serializable authorization request projection.
210
+ */
211
+ export declare function buildMinimizedAuthorizationRequest(input: {
212
+ /**
213
+ * Tenant identifier.
214
+ */
215
+ tenantId: string;
216
+ /**
217
+ * Policy identifier.
218
+ */
219
+ policyId: string;
220
+ /**
221
+ * Intent to project into the request.
222
+ */
223
+ intent: ActionIntent;
224
+ /**
225
+ * Hex digest of the original intent for correlation without storing secrets.
226
+ */
227
+ intentDigestHex: string;
228
+ /**
229
+ * Optional audit mode; defaults to {@link DEFAULT_AUDIT_MODE}.
230
+ */
231
+ mode?: AuditMode;
232
+ }): Record<string, unknown>;
233
+ /**
234
+ * Builds a minimized authorization response projection for Cloud persistence.
235
+ *
236
+ * @param input - Decision, reasons, digests, and optional ids / receipt / expiry.
237
+ * @returns JSON-serializable authorization response projection.
238
+ */
239
+ export declare function buildMinimizedAuthorizationResponse(input: {
240
+ /**
241
+ * Final authorization decision.
242
+ */
243
+ decision: "allow" | "deny";
244
+ /**
245
+ * Human-readable decision reasons.
246
+ */
247
+ reasons: string[];
248
+ /**
249
+ * Optional stable decision identifier.
250
+ */
251
+ decisionId?: string;
252
+ /**
253
+ * Optional authorization row identifier.
254
+ */
255
+ authorizationId?: string;
256
+ /**
257
+ * Hex digest of the original intent.
258
+ */
259
+ intentDigestHex: string;
260
+ /**
261
+ * Optional authorization expiry (ISO-8601), or null.
262
+ */
263
+ expiresAt?: string | null;
264
+ /**
265
+ * Optional opaque decision receipt from the engine.
266
+ */
267
+ decisionReceipt?: unknown;
268
+ }): Record<string, unknown>;
269
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/privacy/redact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,WAAW,CAAA;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAqB,CAAA;AAatD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAcpC;AAED;;;;;GAKG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