@vorim/sdk 3.12.0 → 3.16.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.
Files changed (127) hide show
  1. package/dist/index.cjs +14 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +14 -2
  4. package/dist/index.d.ts +14 -2
  5. package/dist/index.js +14 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/integrations/anthropic.d.cts +1 -1
  8. package/dist/integrations/anthropic.d.ts +1 -1
  9. package/dist/integrations/ap2.d.cts +1 -1
  10. package/dist/integrations/ap2.d.ts +1 -1
  11. package/dist/integrations/aws-iam.cjs +225 -0
  12. package/dist/integrations/aws-iam.cjs.map +1 -0
  13. package/dist/integrations/aws-iam.d.cts +156 -0
  14. package/dist/integrations/aws-iam.d.ts +156 -0
  15. package/dist/integrations/aws-iam.js +199 -0
  16. package/dist/integrations/aws-iam.js.map +1 -0
  17. package/dist/integrations/bank-rails.d.cts +1 -1
  18. package/dist/integrations/bank-rails.d.ts +1 -1
  19. package/dist/integrations/circle.d.cts +1 -1
  20. package/dist/integrations/circle.d.ts +1 -1
  21. package/dist/integrations/cloudflare.d.cts +1 -1
  22. package/dist/integrations/cloudflare.d.ts +1 -1
  23. package/dist/integrations/coinbase-cdp.cjs +230 -0
  24. package/dist/integrations/coinbase-cdp.cjs.map +1 -0
  25. package/dist/integrations/coinbase-cdp.d.cts +169 -0
  26. package/dist/integrations/coinbase-cdp.d.ts +169 -0
  27. package/dist/integrations/coinbase-cdp.js +204 -0
  28. package/dist/integrations/coinbase-cdp.js.map +1 -0
  29. package/dist/integrations/crewai.d.cts +1 -1
  30. package/dist/integrations/crewai.d.ts +1 -1
  31. package/dist/integrations/entra.cjs +225 -0
  32. package/dist/integrations/entra.cjs.map +1 -0
  33. package/dist/integrations/entra.d.cts +155 -0
  34. package/dist/integrations/entra.d.ts +155 -0
  35. package/dist/integrations/entra.js +199 -0
  36. package/dist/integrations/entra.js.map +1 -0
  37. package/dist/integrations/fhir.cjs +304 -0
  38. package/dist/integrations/fhir.cjs.map +1 -0
  39. package/dist/integrations/fhir.d.cts +185 -0
  40. package/dist/integrations/fhir.d.ts +185 -0
  41. package/dist/integrations/fhir.js +278 -0
  42. package/dist/integrations/fhir.js.map +1 -0
  43. package/dist/integrations/guidewire.cjs +363 -0
  44. package/dist/integrations/guidewire.cjs.map +1 -0
  45. package/dist/integrations/guidewire.d.cts +258 -0
  46. package/dist/integrations/guidewire.d.ts +258 -0
  47. package/dist/integrations/guidewire.js +337 -0
  48. package/dist/integrations/guidewire.js.map +1 -0
  49. package/dist/integrations/hermes.d.cts +1 -1
  50. package/dist/integrations/hermes.d.ts +1 -1
  51. package/dist/integrations/langchain.d.cts +1 -1
  52. package/dist/integrations/langchain.d.ts +1 -1
  53. package/dist/integrations/langgraph.d.cts +1 -1
  54. package/dist/integrations/langgraph.d.ts +1 -1
  55. package/dist/integrations/legal.cjs +339 -0
  56. package/dist/integrations/legal.cjs.map +1 -0
  57. package/dist/integrations/legal.d.cts +225 -0
  58. package/dist/integrations/legal.d.ts +225 -0
  59. package/dist/integrations/legal.js +313 -0
  60. package/dist/integrations/legal.js.map +1 -0
  61. package/dist/integrations/life-sciences.cjs +335 -0
  62. package/dist/integrations/life-sciences.cjs.map +1 -0
  63. package/dist/integrations/life-sciences.d.cts +214 -0
  64. package/dist/integrations/life-sciences.d.ts +214 -0
  65. package/dist/integrations/life-sciences.js +309 -0
  66. package/dist/integrations/life-sciences.js.map +1 -0
  67. package/dist/integrations/lithic.cjs +290 -0
  68. package/dist/integrations/lithic.cjs.map +1 -0
  69. package/dist/integrations/lithic.d.cts +130 -0
  70. package/dist/integrations/lithic.d.ts +130 -0
  71. package/dist/integrations/lithic.js +264 -0
  72. package/dist/integrations/lithic.js.map +1 -0
  73. package/dist/integrations/llamaindex.d.cts +1 -1
  74. package/dist/integrations/llamaindex.d.ts +1 -1
  75. package/dist/integrations/marqeta.cjs +285 -0
  76. package/dist/integrations/marqeta.cjs.map +1 -0
  77. package/dist/integrations/marqeta.d.cts +121 -0
  78. package/dist/integrations/marqeta.d.ts +121 -0
  79. package/dist/integrations/marqeta.js +259 -0
  80. package/dist/integrations/marqeta.js.map +1 -0
  81. package/dist/integrations/modern-treasury.d.cts +1 -1
  82. package/dist/integrations/modern-treasury.d.ts +1 -1
  83. package/dist/integrations/nekuda.d.cts +1 -1
  84. package/dist/integrations/nekuda.d.ts +1 -1
  85. package/dist/integrations/okta.cjs +229 -0
  86. package/dist/integrations/okta.cjs.map +1 -0
  87. package/dist/integrations/okta.d.cts +172 -0
  88. package/dist/integrations/okta.d.ts +172 -0
  89. package/dist/integrations/okta.js +203 -0
  90. package/dist/integrations/okta.js.map +1 -0
  91. package/dist/integrations/openai.d.cts +1 -1
  92. package/dist/integrations/openai.d.ts +1 -1
  93. package/dist/integrations/paypal-agent.d.cts +1 -1
  94. package/dist/integrations/paypal-agent.d.ts +1 -1
  95. package/dist/integrations/plaid.d.cts +1 -1
  96. package/dist/integrations/plaid.d.ts +1 -1
  97. package/dist/integrations/ramp.cjs +206 -0
  98. package/dist/integrations/ramp.cjs.map +1 -0
  99. package/dist/integrations/ramp.d.cts +139 -0
  100. package/dist/integrations/ramp.d.ts +139 -0
  101. package/dist/integrations/ramp.js +180 -0
  102. package/dist/integrations/ramp.js.map +1 -0
  103. package/dist/integrations/shopify.d.cts +1 -1
  104. package/dist/integrations/shopify.d.ts +1 -1
  105. package/dist/integrations/siem.d.cts +1 -1
  106. package/dist/integrations/siem.d.ts +1 -1
  107. package/dist/integrations/skyfire.d.cts +1 -1
  108. package/dist/integrations/skyfire.d.ts +1 -1
  109. package/dist/integrations/stripe-acp.d.cts +1 -1
  110. package/dist/integrations/stripe-acp.d.ts +1 -1
  111. package/dist/integrations/stripe-issuing.cjs +316 -0
  112. package/dist/integrations/stripe-issuing.cjs.map +1 -0
  113. package/dist/integrations/stripe-issuing.d.cts +154 -0
  114. package/dist/integrations/stripe-issuing.d.ts +154 -0
  115. package/dist/integrations/stripe-issuing.js +290 -0
  116. package/dist/integrations/stripe-issuing.js.map +1 -0
  117. package/dist/integrations/truanon.d.cts +1 -1
  118. package/dist/integrations/truanon.d.ts +1 -1
  119. package/dist/integrations/ucp.d.cts +1 -1
  120. package/dist/integrations/ucp.d.ts +1 -1
  121. package/dist/integrations/vercel-ai.d.cts +1 -1
  122. package/dist/integrations/vercel-ai.d.ts +1 -1
  123. package/dist/integrations/x402.d.cts +1 -1
  124. package/dist/integrations/x402.d.ts +1 -1
  125. package/dist/{types-zzK9YOoa.d.cts → types-Lp1iHEDz.d.cts} +21 -1
  126. package/dist/{types-zzK9YOoa.d.ts → types-Lp1iHEDz.d.ts} +21 -1
  127. package/package.json +121 -1
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/integrations/aws-iam.ts
21
+ var aws_iam_exports = {};
22
+ __export(aws_iam_exports, {
23
+ VorimAwsIam: () => VorimAwsIam,
24
+ createVorimAwsIam: () => createVorimAwsIam
25
+ });
26
+ module.exports = __toCommonJS(aws_iam_exports);
27
+ var ESCALATION_OPS = /* @__PURE__ */ new Set(["CreateAccessKey", "CreateRole", "AttachRolePolicy", "PutRolePolicy"]);
28
+ var OPERATION_SCOPE = {
29
+ read: "agent:read",
30
+ CreateUser: "agent:write",
31
+ AssumeRole: "agent:write",
32
+ CreateRole: "agent:elevate",
33
+ AttachRolePolicy: "agent:elevate",
34
+ PutRolePolicy: "agent:elevate",
35
+ CreateAccessKey: "agent:elevate"
36
+ };
37
+ var VorimAwsIam = class {
38
+ sdk;
39
+ agentId;
40
+ accountId;
41
+ adminId;
42
+ minTrustScore;
43
+ escalatePrivileged;
44
+ escalationTimeoutMs;
45
+ onError;
46
+ constructor(sdk, config) {
47
+ if (!config?.agentId) throw new Error("[vorim] AWS IAM integration requires an agentId.");
48
+ if (!config?.accountId) throw new Error("[vorim] AWS IAM integration requires an accountId.");
49
+ this.sdk = sdk;
50
+ this.agentId = config.agentId;
51
+ this.accountId = config.accountId;
52
+ this.adminId = config.adminId;
53
+ this.minTrustScore = config.minTrustScore ?? 0;
54
+ this.escalatePrivileged = config.escalatePrivileged ?? true;
55
+ this.escalationTimeoutMs = config.escalationTimeoutMs ?? 3e5;
56
+ this.onError = config.onError ?? "closed";
57
+ }
58
+ isPrivileged(operation) {
59
+ return ESCALATION_OPS.has(operation);
60
+ }
61
+ scopeFor(operation) {
62
+ return OPERATION_SCOPE[operation] ?? "agent:write";
63
+ }
64
+ async authorize(action) {
65
+ const privileged = this.isPrivileged(action.operation);
66
+ const scope = this.scopeFor(action.operation);
67
+ try {
68
+ if (this.minTrustScore > 0) {
69
+ const trust = await this.sdk.verify(this.agentId);
70
+ if ((trust?.trust_score ?? 0) < this.minTrustScore) {
71
+ return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: privileged ? "privileged-denied" : "ordinary" };
72
+ }
73
+ }
74
+ if (privileged) {
75
+ if (!this.escalatePrivileged) {
76
+ return { authorized: false, reason: `${action.operation} requires a human admin and escalatePrivileged is off`, outcome: "privileged-denied" };
77
+ }
78
+ if (!this.adminId) {
79
+ return {
80
+ authorized: false,
81
+ reason: `${action.operation} requires a configured adminId (the approving human admin)`,
82
+ outcome: "privileged-denied"
83
+ };
84
+ }
85
+ const esc = await this.escalate(action, scope);
86
+ return {
87
+ authorized: esc.approved,
88
+ reason: esc.approved ? void 0 : esc.reason ?? "admin did not approve",
89
+ outcome: esc.approved ? "approved-by-admin" : "privileged-denied",
90
+ adminId: esc.approved ? this.adminId : void 0,
91
+ decisionId: esc.decisionId
92
+ };
93
+ }
94
+ const perm = await this.sdk.check(this.agentId, scope);
95
+ return perm.allowed ? { authorized: true, outcome: "ordinary", adminId: this.adminId } : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: "ordinary" };
96
+ } catch (e) {
97
+ return this.onError === "open" ? { authorized: true, reason: "vorim unreachable, failed open", outcome: privileged ? "approved-by-admin" : "ordinary" } : { authorized: false, reason: `vorim unreachable: ${e?.message ?? "error"}`, outcome: privileged ? "privileged-denied" : "ordinary" };
98
+ }
99
+ }
100
+ async escalate(action, scope) {
101
+ const decision = await this.sdk.beforeAction(
102
+ {
103
+ agentId: this.agentId,
104
+ actionType: "api_request",
105
+ actionTarget: `aws-iam:${action.operation}`,
106
+ requiredScope: scope,
107
+ payload: { operation: action.operation, target_id: action.targetId, policy: action.policy },
108
+ context: { integration: "aws-iam", account_id: this.accountId, requires_human_admin: true, admin_hint: this.adminId }
109
+ },
110
+ { throwOnDeny: false }
111
+ );
112
+ if (decision.decision === "escalate") {
113
+ const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
114
+ const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
115
+ return { approved, reason: approved ? void 0 : "admin refused", decisionId: decision.decisionId };
116
+ }
117
+ if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
118
+ if (decision.decision === "fallback")
119
+ return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
120
+ return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
121
+ }
122
+ async record(action, result, extra = {}) {
123
+ const scope = this.scopeFor(action.operation);
124
+ try {
125
+ await this.sdk.emit(
126
+ {
127
+ agent_id: this.agentId,
128
+ event_type: "api_request",
129
+ action: `aws-iam:${action.operation}${action.targetId ? " " + action.targetId : ""}`,
130
+ resource: action.targetId || this.accountId,
131
+ permission: scope,
132
+ result,
133
+ input_hash: action.inputHash,
134
+ metadata: {
135
+ integration: "aws-iam",
136
+ account_id: this.accountId,
137
+ operation: action.operation,
138
+ privileged: this.isPrivileged(action.operation),
139
+ ...action.policy ? { policy: action.policy } : {},
140
+ ...extra.outcome ? { outcome: extra.outcome } : {},
141
+ ...extra.adminId ?? this.adminId ? { approved_by_admin: extra.adminId ?? this.adminId } : {},
142
+ ...extra.decisionId ? { decision_id: extra.decisionId } : {},
143
+ ...extra.reason ? { reason: extra.reason } : {}
144
+ }
145
+ },
146
+ { sign: true }
147
+ );
148
+ return true;
149
+ } catch {
150
+ return false;
151
+ }
152
+ }
153
+ async guard(action, run) {
154
+ const auth = await this.authorize(action);
155
+ if (!auth.authorized) {
156
+ const recorded = await this.record(action, "denied", { reason: auth.reason, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
157
+ return { receipt: this.receipt(action, false, "denied", auth, recorded) };
158
+ }
159
+ try {
160
+ const value = await run();
161
+ const recorded = await this.record(action, "success", { outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
162
+ return { receipt: this.receipt(action, true, "success", auth, recorded), value };
163
+ } catch (e) {
164
+ const recorded = await this.record(action, "error", { reason: e?.message, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
165
+ throw Object.assign(e ?? new Error("aws iam operation failed"), {
166
+ vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
167
+ });
168
+ }
169
+ }
170
+ // --- Named helpers ---------------------------------------------------------
171
+ /** Guard iam:CreateUser. Requires agent:write. */
172
+ guardedCreateUser(meta, run) {
173
+ return this.guard({ operation: "CreateUser", targetId: meta.targetId, inputHash: meta.inputHash }, run);
174
+ }
175
+ /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */
176
+ guardedCreateRole(meta, run) {
177
+ return this.guard({ operation: "CreateRole", targetId: meta.targetId, inputHash: meta.inputHash }, run);
178
+ }
179
+ /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.
180
+ * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */
181
+ guardedAttachRolePolicy(meta, run) {
182
+ return this.guard({ operation: "AttachRolePolicy", targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);
183
+ }
184
+ /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */
185
+ guardedPutRolePolicy(meta, run) {
186
+ return this.guard({ operation: "PutRolePolicy", targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);
187
+ }
188
+ /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always
189
+ * escalates to the named admin — the single highest-stakes IAM op. */
190
+ guardedCreateAccessKey(meta, run) {
191
+ return this.guard({ operation: "CreateAccessKey", targetId: meta.targetId, inputHash: meta.inputHash }, run);
192
+ }
193
+ /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —
194
+ * lighter friction than CreateAccessKey, the safer path to nudge agents to. */
195
+ guardedAssumeRole(meta, run) {
196
+ return this.guard({ operation: "AssumeRole", targetId: meta.targetId, inputHash: meta.inputHash }, run);
197
+ }
198
+ receipt(action, authorized, result, auth, recorded) {
199
+ return {
200
+ authorized,
201
+ agentId: this.agentId,
202
+ accountId: this.accountId,
203
+ operation: action.operation,
204
+ targetId: action.targetId,
205
+ policy: action.policy,
206
+ privileged: this.isPrivileged(action.operation),
207
+ outcome: auth.outcome ?? "ordinary",
208
+ adminId: auth.adminId ?? this.adminId,
209
+ result,
210
+ scope: this.scopeFor(action.operation),
211
+ reason: auth.reason,
212
+ decisionId: auth.decisionId,
213
+ recorded
214
+ };
215
+ }
216
+ };
217
+ function createVorimAwsIam(sdk, config) {
218
+ return new VorimAwsIam(sdk, config);
219
+ }
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ VorimAwsIam,
223
+ createVorimAwsIam
224
+ });
225
+ //# sourceMappingURL=aws-iam.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/aws-iam.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — AWS IAM / STS Integration\n//\n// This guards an AI agent that manages AWS identity through IAM and STS —\n// creating users and roles, attaching policies, minting access keys, assuming\n// roles. Before each write runs it verifies the agent's Vorim identity and\n// scoped permission, and for the highest-stakes operations (minting a long-lived\n// access key, escalating privilege via a role/policy change) it escalates to a\n// named human admin and waits. Either way it signs a tamper-evident record.\n//\n// WHY IAM, NOT AGENTCORE\n// This connector guards the stable, universally-available IAM/STS admin surface\n// (free on any AWS account, no Bedrock/region gating). It is NOT Bedrock\n// AgentCore Identity: that is a separate, agent-native product that presupposes\n// a billable, Bedrock-enabled account. IAM is where the real privilege-\n// escalation and long-lived-credential minting happen, so it is the right first\n// target. An AgentCore connector can be a second wave.\n//\n// THE ESCALATION RULE (the wedge)\n// CreateAccessKey mints a long-lived, non-expiring static credential (the secret\n// is shown once, defaults to Active) — the single highest-stakes IAM op, and it\n// always escalates to a named human admin. Broad privilege-escalation ops\n// (CreateRole, AttachRolePolicy, PutRolePolicy) also escalate. Prefer steering\n// agents to AssumeRole (short-lived STS credentials), which passes with lighter\n// friction.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// read IAM -> agent:read\n// create user, assume role (STS) -> agent:write\n// create access key / create role / -> agent:elevate (named-admin approval)\n// attach or put role policy\n//\n// HONEST COMPLIANCE FRAMING\n// A signed, attributable record of each IAM change supports SOC 2 (CC6 logical\n// access, CC7 change monitoring). No regime mandates cryptographic signatures on\n// audit logs; signing satisfies the tamper-evident + attributable intent. Say\n// \"cryptographic proof of which agent made which change\", never \"required for\n// compliance\".\n//\n// This layer never holds AWS credentials and never calls AWS itself. You pass\n// the AWS SDK call as a closure; it authorizes, escalates if needed, runs it,\n// and signs the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const iam = createVorimAwsIam(vorim, {\n// agentId: 'agid_abc123',\n// accountId: '123456789012',\n// adminId: 'admin_42',\n// });\n//\n// const { receipt, value } = await iam.guardedCreateAccessKey(\n// { targetId: 'ci-bot' },\n// () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** The AWS IAM / STS operations this guard classifies (real API call names). */\nexport type AwsIamOperation =\n | 'CreateUser' // iam:CreateUser\n | 'CreateRole' // iam:CreateRole (+ trust/assume-role policy)\n | 'AttachRolePolicy' // iam:AttachRolePolicy (managed policy)\n | 'PutRolePolicy' // iam:PutRolePolicy (inline policy)\n | 'CreateAccessKey' // iam:CreateAccessKey (long-lived static credential)\n | 'AssumeRole' // sts:AssumeRole (short-lived credential)\n | 'read';\n\n/** Operations that mint a long-lived credential or escalate privilege — always\n * escalate to a named human admin. */\nconst ESCALATION_OPS = new Set<string>(['CreateAccessKey', 'CreateRole', 'AttachRolePolicy', 'PutRolePolicy']);\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n read: 'agent:read',\n CreateUser: 'agent:write',\n AssumeRole: 'agent:write',\n CreateRole: 'agent:elevate',\n AttachRolePolicy: 'agent:elevate',\n PutRolePolicy: 'agent:elevate',\n CreateAccessKey: 'agent:elevate',\n};\n\nexport interface AwsIamGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The AWS account id, e.g. '123456789012'. Recorded on every receipt. */\n accountId: string;\n /** The human admin who approves privileged operations. Required if any\n * escalation-class op will be run. */\n adminId?: string;\n minTrustScore?: number;\n /** For a privileged op, escalate to the named admin and wait. Default true. */\n escalatePrivileged?: boolean;\n escalationTimeoutMs?: number;\n onError?: 'closed' | 'open';\n}\n\nexport interface AwsIamAction {\n /** The IAM/STS operation, e.g. 'CreateAccessKey'. Drives scope + escalation. */\n operation: AwsIamOperation | string;\n /** The target the action affects (user name, role name/arn). Recorded. */\n targetId?: string;\n /** For AttachRolePolicy / PutRolePolicy: the policy arn/name being granted,\n * e.g. 'arn:aws:iam::aws:policy/AdministratorAccess'. Recorded. */\n policy?: string;\n inputHash?: string;\n}\n\nexport type AwsIamOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';\n\nexport interface AwsIamReceipt {\n authorized: boolean;\n agentId: string;\n accountId: string;\n operation: string;\n targetId?: string;\n policy?: string;\n privileged: boolean;\n outcome: AwsIamOutcome;\n adminId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimAwsIam {\n private sdk: VorimSDK;\n private agentId: string;\n private accountId: string;\n private adminId?: string;\n private minTrustScore: number;\n private escalatePrivileged: boolean;\n private escalationTimeoutMs: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: AwsIamGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] AWS IAM integration requires an agentId.');\n if (!config?.accountId) throw new Error('[vorim] AWS IAM integration requires an accountId.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.accountId = config.accountId;\n this.adminId = config.adminId;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.escalatePrivileged = config.escalatePrivileged ?? true;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 300_000;\n this.onError = config.onError ?? 'closed';\n }\n\n private isPrivileged(operation: string): boolean {\n return ESCALATION_OPS.has(operation);\n }\n\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:write';\n }\n\n async authorize(\n action: AwsIamAction,\n ): Promise<{ authorized: boolean; reason?: string; outcome: AwsIamOutcome; adminId?: string; decisionId?: string }> {\n const privileged = this.isPrivileged(action.operation);\n const scope = this.scopeFor(action.operation);\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: privileged ? 'privileged-denied' : 'ordinary' };\n }\n }\n\n if (privileged) {\n if (!this.escalatePrivileged) {\n return { authorized: false, reason: `${action.operation} requires a human admin and escalatePrivileged is off`, outcome: 'privileged-denied' };\n }\n if (!this.adminId) {\n return {\n authorized: false,\n reason: `${action.operation} requires a configured adminId (the approving human admin)`,\n outcome: 'privileged-denied',\n };\n }\n const esc = await this.escalate(action, scope);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'admin did not approve'),\n outcome: esc.approved ? 'approved-by-admin' : 'privileged-denied',\n adminId: esc.approved ? this.adminId : undefined,\n decisionId: esc.decisionId,\n };\n }\n\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, outcome: 'ordinary', adminId: this.adminId }\n : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: 'ordinary' };\n } catch (e: any) {\n return this.onError === 'open'\n ? { authorized: true, reason: 'vorim unreachable, failed open', outcome: privileged ? 'approved-by-admin' : 'ordinary' }\n : { authorized: false, reason: `vorim unreachable: ${e?.message ?? 'error'}`, outcome: privileged ? 'privileged-denied' : 'ordinary' };\n }\n }\n\n private async escalate(action: AwsIamAction, scope: PermissionScope): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `aws-iam:${action.operation}`,\n requiredScope: scope,\n payload: { operation: action.operation, target_id: action.targetId, policy: action.policy },\n context: { integration: 'aws-iam', account_id: this.accountId, requires_human_admin: true, admin_hint: this.adminId },\n },\n { throwOnDeny: false },\n );\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return { approved, reason: approved ? undefined : 'admin refused', decisionId: decision.decisionId };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n async record(\n action: AwsIamAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; outcome?: AwsIamOutcome; adminId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action.operation);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `aws-iam:${action.operation}${action.targetId ? ' ' + action.targetId : ''}`,\n resource: action.targetId || this.accountId,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'aws-iam',\n account_id: this.accountId,\n operation: action.operation,\n privileged: this.isPrivileged(action.operation),\n ...(action.policy ? { policy: action.policy } : {}),\n ...(extra.outcome ? { outcome: extra.outcome } : {}),\n ...(extra.adminId ?? this.adminId ? { approved_by_admin: extra.adminId ?? this.adminId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n async guard<T>(action: AwsIamAction, run: () => Promise<T>): Promise<{ receipt: AwsIamReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', { reason: auth.reason, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, false, 'denied', auth, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', { outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', { reason: e?.message, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n throw Object.assign(e ?? new Error('aws iam operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard iam:CreateUser. Requires agent:write. */\n guardedCreateUser<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateUser', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */\n guardedCreateRole<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateRole', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.\n * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */\n guardedAttachRolePolicy<T>(meta: { targetId?: string; policy?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'AttachRolePolicy', targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */\n guardedPutRolePolicy<T>(meta: { targetId?: string; policy?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'PutRolePolicy', targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always\n * escalates to the named admin — the single highest-stakes IAM op. */\n guardedCreateAccessKey<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateAccessKey', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —\n * lighter friction than CreateAccessKey, the safer path to nudge agents to. */\n guardedAssumeRole<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'AssumeRole', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: AwsIamAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; outcome?: AwsIamOutcome; adminId?: string; decisionId?: string },\n recorded: boolean,\n ): AwsIamReceipt {\n return {\n authorized,\n agentId: this.agentId,\n accountId: this.accountId,\n operation: action.operation,\n targetId: action.targetId,\n policy: action.policy,\n privileged: this.isPrivileged(action.operation),\n outcome: auth.outcome ?? 'ordinary',\n adminId: auth.adminId ?? this.adminId,\n result,\n scope: this.scopeFor(action.operation),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimAwsIam guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const iam = createVorimAwsIam(vorim, {\n * agentId: 'agid_abc123',\n * accountId: '123456789012',\n * adminId: 'admin_42',\n * });\n *\n * // Minting a long-lived access key always escalates to the named admin:\n * const { receipt } = await iam.guardedCreateAccessKey(\n * { targetId: 'ci-bot' },\n * () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),\n * );\n * ```\n */\nexport function createVorimAwsIam(sdk: VorimSDK, config: AwsIamGuardConfig): VorimAwsIam {\n return new VorimAwsIam(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2EA,IAAM,iBAAiB,oBAAI,IAAY,CAAC,mBAAmB,cAAc,oBAAoB,eAAe,CAAC;AAE7G,IAAM,kBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,iBAAiB;AACnB;AA+CO,I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;AACF;AAwBO,SAAS,kBAAkB,KAAe,QAAwC;AACvF,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
@@ -0,0 +1,156 @@
1
+ import { VorimSDK } from '../index.cjs';
2
+ import { P as PermissionScope } from '../types-Lp1iHEDz.cjs';
3
+
4
+ /** The AWS IAM / STS operations this guard classifies (real API call names). */
5
+ type AwsIamOperation = 'CreateUser' | 'CreateRole' | 'AttachRolePolicy' | 'PutRolePolicy' | 'CreateAccessKey' | 'AssumeRole' | 'read';
6
+ interface AwsIamGuardConfig {
7
+ /** The acting agent's Vorim id (agid_...). */
8
+ agentId: string;
9
+ /** The AWS account id, e.g. '123456789012'. Recorded on every receipt. */
10
+ accountId: string;
11
+ /** The human admin who approves privileged operations. Required if any
12
+ * escalation-class op will be run. */
13
+ adminId?: string;
14
+ minTrustScore?: number;
15
+ /** For a privileged op, escalate to the named admin and wait. Default true. */
16
+ escalatePrivileged?: boolean;
17
+ escalationTimeoutMs?: number;
18
+ onError?: 'closed' | 'open';
19
+ }
20
+ interface AwsIamAction {
21
+ /** The IAM/STS operation, e.g. 'CreateAccessKey'. Drives scope + escalation. */
22
+ operation: AwsIamOperation | string;
23
+ /** The target the action affects (user name, role name/arn). Recorded. */
24
+ targetId?: string;
25
+ /** For AttachRolePolicy / PutRolePolicy: the policy arn/name being granted,
26
+ * e.g. 'arn:aws:iam::aws:policy/AdministratorAccess'. Recorded. */
27
+ policy?: string;
28
+ inputHash?: string;
29
+ }
30
+ type AwsIamOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';
31
+ interface AwsIamReceipt {
32
+ authorized: boolean;
33
+ agentId: string;
34
+ accountId: string;
35
+ operation: string;
36
+ targetId?: string;
37
+ policy?: string;
38
+ privileged: boolean;
39
+ outcome: AwsIamOutcome;
40
+ adminId?: string;
41
+ result: 'success' | 'denied' | 'error';
42
+ scope: PermissionScope;
43
+ reason?: string;
44
+ decisionId?: string;
45
+ recorded: boolean;
46
+ }
47
+ declare class VorimAwsIam {
48
+ private sdk;
49
+ private agentId;
50
+ private accountId;
51
+ private adminId?;
52
+ private minTrustScore;
53
+ private escalatePrivileged;
54
+ private escalationTimeoutMs;
55
+ private onError;
56
+ constructor(sdk: VorimSDK, config: AwsIamGuardConfig);
57
+ private isPrivileged;
58
+ private scopeFor;
59
+ authorize(action: AwsIamAction): Promise<{
60
+ authorized: boolean;
61
+ reason?: string;
62
+ outcome: AwsIamOutcome;
63
+ adminId?: string;
64
+ decisionId?: string;
65
+ }>;
66
+ private escalate;
67
+ record(action: AwsIamAction, result: 'success' | 'denied' | 'error', extra?: {
68
+ reason?: string;
69
+ outcome?: AwsIamOutcome;
70
+ adminId?: string;
71
+ decisionId?: string;
72
+ }): Promise<boolean>;
73
+ guard<T>(action: AwsIamAction, run: () => Promise<T>): Promise<{
74
+ receipt: AwsIamReceipt;
75
+ value?: T;
76
+ }>;
77
+ /** Guard iam:CreateUser. Requires agent:write. */
78
+ guardedCreateUser<T>(meta: {
79
+ targetId?: string;
80
+ inputHash?: string;
81
+ }, run: () => Promise<T>): Promise<{
82
+ receipt: AwsIamReceipt;
83
+ value?: T | undefined;
84
+ }>;
85
+ /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */
86
+ guardedCreateRole<T>(meta: {
87
+ targetId?: string;
88
+ inputHash?: string;
89
+ }, run: () => Promise<T>): Promise<{
90
+ receipt: AwsIamReceipt;
91
+ value?: T | undefined;
92
+ }>;
93
+ /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.
94
+ * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */
95
+ guardedAttachRolePolicy<T>(meta: {
96
+ targetId?: string;
97
+ policy?: string;
98
+ inputHash?: string;
99
+ }, run: () => Promise<T>): Promise<{
100
+ receipt: AwsIamReceipt;
101
+ value?: T | undefined;
102
+ }>;
103
+ /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */
104
+ guardedPutRolePolicy<T>(meta: {
105
+ targetId?: string;
106
+ policy?: string;
107
+ inputHash?: string;
108
+ }, run: () => Promise<T>): Promise<{
109
+ receipt: AwsIamReceipt;
110
+ value?: T | undefined;
111
+ }>;
112
+ /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always
113
+ * escalates to the named admin — the single highest-stakes IAM op. */
114
+ guardedCreateAccessKey<T>(meta: {
115
+ targetId?: string;
116
+ inputHash?: string;
117
+ }, run: () => Promise<T>): Promise<{
118
+ receipt: AwsIamReceipt;
119
+ value?: T | undefined;
120
+ }>;
121
+ /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —
122
+ * lighter friction than CreateAccessKey, the safer path to nudge agents to. */
123
+ guardedAssumeRole<T>(meta: {
124
+ targetId?: string;
125
+ inputHash?: string;
126
+ }, run: () => Promise<T>): Promise<{
127
+ receipt: AwsIamReceipt;
128
+ value?: T | undefined;
129
+ }>;
130
+ private receipt;
131
+ }
132
+ /**
133
+ * Create a VorimAwsIam guard around a Vorim SDK instance.
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import createVorim from '@vorim/sdk';
138
+ * import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';
139
+ *
140
+ * const vorim = createVorim({ apiKey: 'agid_sk_...' });
141
+ * const iam = createVorimAwsIam(vorim, {
142
+ * agentId: 'agid_abc123',
143
+ * accountId: '123456789012',
144
+ * adminId: 'admin_42',
145
+ * });
146
+ *
147
+ * // Minting a long-lived access key always escalates to the named admin:
148
+ * const { receipt } = await iam.guardedCreateAccessKey(
149
+ * { targetId: 'ci-bot' },
150
+ * () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),
151
+ * );
152
+ * ```
153
+ */
154
+ declare function createVorimAwsIam(sdk: VorimSDK, config: AwsIamGuardConfig): VorimAwsIam;
155
+
156
+ export { type AwsIamAction, type AwsIamGuardConfig, type AwsIamOperation, type AwsIamOutcome, type AwsIamReceipt, VorimAwsIam, createVorimAwsIam };
@@ -0,0 +1,156 @@
1
+ import { VorimSDK } from '../index.js';
2
+ import { P as PermissionScope } from '../types-Lp1iHEDz.js';
3
+
4
+ /** The AWS IAM / STS operations this guard classifies (real API call names). */
5
+ type AwsIamOperation = 'CreateUser' | 'CreateRole' | 'AttachRolePolicy' | 'PutRolePolicy' | 'CreateAccessKey' | 'AssumeRole' | 'read';
6
+ interface AwsIamGuardConfig {
7
+ /** The acting agent's Vorim id (agid_...). */
8
+ agentId: string;
9
+ /** The AWS account id, e.g. '123456789012'. Recorded on every receipt. */
10
+ accountId: string;
11
+ /** The human admin who approves privileged operations. Required if any
12
+ * escalation-class op will be run. */
13
+ adminId?: string;
14
+ minTrustScore?: number;
15
+ /** For a privileged op, escalate to the named admin and wait. Default true. */
16
+ escalatePrivileged?: boolean;
17
+ escalationTimeoutMs?: number;
18
+ onError?: 'closed' | 'open';
19
+ }
20
+ interface AwsIamAction {
21
+ /** The IAM/STS operation, e.g. 'CreateAccessKey'. Drives scope + escalation. */
22
+ operation: AwsIamOperation | string;
23
+ /** The target the action affects (user name, role name/arn). Recorded. */
24
+ targetId?: string;
25
+ /** For AttachRolePolicy / PutRolePolicy: the policy arn/name being granted,
26
+ * e.g. 'arn:aws:iam::aws:policy/AdministratorAccess'. Recorded. */
27
+ policy?: string;
28
+ inputHash?: string;
29
+ }
30
+ type AwsIamOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';
31
+ interface AwsIamReceipt {
32
+ authorized: boolean;
33
+ agentId: string;
34
+ accountId: string;
35
+ operation: string;
36
+ targetId?: string;
37
+ policy?: string;
38
+ privileged: boolean;
39
+ outcome: AwsIamOutcome;
40
+ adminId?: string;
41
+ result: 'success' | 'denied' | 'error';
42
+ scope: PermissionScope;
43
+ reason?: string;
44
+ decisionId?: string;
45
+ recorded: boolean;
46
+ }
47
+ declare class VorimAwsIam {
48
+ private sdk;
49
+ private agentId;
50
+ private accountId;
51
+ private adminId?;
52
+ private minTrustScore;
53
+ private escalatePrivileged;
54
+ private escalationTimeoutMs;
55
+ private onError;
56
+ constructor(sdk: VorimSDK, config: AwsIamGuardConfig);
57
+ private isPrivileged;
58
+ private scopeFor;
59
+ authorize(action: AwsIamAction): Promise<{
60
+ authorized: boolean;
61
+ reason?: string;
62
+ outcome: AwsIamOutcome;
63
+ adminId?: string;
64
+ decisionId?: string;
65
+ }>;
66
+ private escalate;
67
+ record(action: AwsIamAction, result: 'success' | 'denied' | 'error', extra?: {
68
+ reason?: string;
69
+ outcome?: AwsIamOutcome;
70
+ adminId?: string;
71
+ decisionId?: string;
72
+ }): Promise<boolean>;
73
+ guard<T>(action: AwsIamAction, run: () => Promise<T>): Promise<{
74
+ receipt: AwsIamReceipt;
75
+ value?: T;
76
+ }>;
77
+ /** Guard iam:CreateUser. Requires agent:write. */
78
+ guardedCreateUser<T>(meta: {
79
+ targetId?: string;
80
+ inputHash?: string;
81
+ }, run: () => Promise<T>): Promise<{
82
+ receipt: AwsIamReceipt;
83
+ value?: T | undefined;
84
+ }>;
85
+ /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */
86
+ guardedCreateRole<T>(meta: {
87
+ targetId?: string;
88
+ inputHash?: string;
89
+ }, run: () => Promise<T>): Promise<{
90
+ receipt: AwsIamReceipt;
91
+ value?: T | undefined;
92
+ }>;
93
+ /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.
94
+ * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */
95
+ guardedAttachRolePolicy<T>(meta: {
96
+ targetId?: string;
97
+ policy?: string;
98
+ inputHash?: string;
99
+ }, run: () => Promise<T>): Promise<{
100
+ receipt: AwsIamReceipt;
101
+ value?: T | undefined;
102
+ }>;
103
+ /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */
104
+ guardedPutRolePolicy<T>(meta: {
105
+ targetId?: string;
106
+ policy?: string;
107
+ inputHash?: string;
108
+ }, run: () => Promise<T>): Promise<{
109
+ receipt: AwsIamReceipt;
110
+ value?: T | undefined;
111
+ }>;
112
+ /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always
113
+ * escalates to the named admin — the single highest-stakes IAM op. */
114
+ guardedCreateAccessKey<T>(meta: {
115
+ targetId?: string;
116
+ inputHash?: string;
117
+ }, run: () => Promise<T>): Promise<{
118
+ receipt: AwsIamReceipt;
119
+ value?: T | undefined;
120
+ }>;
121
+ /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —
122
+ * lighter friction than CreateAccessKey, the safer path to nudge agents to. */
123
+ guardedAssumeRole<T>(meta: {
124
+ targetId?: string;
125
+ inputHash?: string;
126
+ }, run: () => Promise<T>): Promise<{
127
+ receipt: AwsIamReceipt;
128
+ value?: T | undefined;
129
+ }>;
130
+ private receipt;
131
+ }
132
+ /**
133
+ * Create a VorimAwsIam guard around a Vorim SDK instance.
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import createVorim from '@vorim/sdk';
138
+ * import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';
139
+ *
140
+ * const vorim = createVorim({ apiKey: 'agid_sk_...' });
141
+ * const iam = createVorimAwsIam(vorim, {
142
+ * agentId: 'agid_abc123',
143
+ * accountId: '123456789012',
144
+ * adminId: 'admin_42',
145
+ * });
146
+ *
147
+ * // Minting a long-lived access key always escalates to the named admin:
148
+ * const { receipt } = await iam.guardedCreateAccessKey(
149
+ * { targetId: 'ci-bot' },
150
+ * () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),
151
+ * );
152
+ * ```
153
+ */
154
+ declare function createVorimAwsIam(sdk: VorimSDK, config: AwsIamGuardConfig): VorimAwsIam;
155
+
156
+ export { type AwsIamAction, type AwsIamGuardConfig, type AwsIamOperation, type AwsIamOutcome, type AwsIamReceipt, VorimAwsIam, createVorimAwsIam };