@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.
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.d.cts +1 -1
- package/dist/integrations/ap2.d.ts +1 -1
- package/dist/integrations/aws-iam.cjs +225 -0
- package/dist/integrations/aws-iam.cjs.map +1 -0
- package/dist/integrations/aws-iam.d.cts +156 -0
- package/dist/integrations/aws-iam.d.ts +156 -0
- package/dist/integrations/aws-iam.js +199 -0
- package/dist/integrations/aws-iam.js.map +1 -0
- package/dist/integrations/bank-rails.d.cts +1 -1
- package/dist/integrations/bank-rails.d.ts +1 -1
- package/dist/integrations/circle.d.cts +1 -1
- package/dist/integrations/circle.d.ts +1 -1
- package/dist/integrations/cloudflare.d.cts +1 -1
- package/dist/integrations/cloudflare.d.ts +1 -1
- package/dist/integrations/coinbase-cdp.cjs +230 -0
- package/dist/integrations/coinbase-cdp.cjs.map +1 -0
- package/dist/integrations/coinbase-cdp.d.cts +169 -0
- package/dist/integrations/coinbase-cdp.d.ts +169 -0
- package/dist/integrations/coinbase-cdp.js +204 -0
- package/dist/integrations/coinbase-cdp.js.map +1 -0
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/entra.cjs +225 -0
- package/dist/integrations/entra.cjs.map +1 -0
- package/dist/integrations/entra.d.cts +155 -0
- package/dist/integrations/entra.d.ts +155 -0
- package/dist/integrations/entra.js +199 -0
- package/dist/integrations/entra.js.map +1 -0
- package/dist/integrations/fhir.cjs +304 -0
- package/dist/integrations/fhir.cjs.map +1 -0
- package/dist/integrations/fhir.d.cts +185 -0
- package/dist/integrations/fhir.d.ts +185 -0
- package/dist/integrations/fhir.js +278 -0
- package/dist/integrations/fhir.js.map +1 -0
- package/dist/integrations/guidewire.cjs +363 -0
- package/dist/integrations/guidewire.cjs.map +1 -0
- package/dist/integrations/guidewire.d.cts +258 -0
- package/dist/integrations/guidewire.d.ts +258 -0
- package/dist/integrations/guidewire.js +337 -0
- package/dist/integrations/guidewire.js.map +1 -0
- package/dist/integrations/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/legal.cjs +339 -0
- package/dist/integrations/legal.cjs.map +1 -0
- package/dist/integrations/legal.d.cts +225 -0
- package/dist/integrations/legal.d.ts +225 -0
- package/dist/integrations/legal.js +313 -0
- package/dist/integrations/legal.js.map +1 -0
- package/dist/integrations/life-sciences.cjs +335 -0
- package/dist/integrations/life-sciences.cjs.map +1 -0
- package/dist/integrations/life-sciences.d.cts +214 -0
- package/dist/integrations/life-sciences.d.ts +214 -0
- package/dist/integrations/life-sciences.js +309 -0
- package/dist/integrations/life-sciences.js.map +1 -0
- package/dist/integrations/lithic.cjs +290 -0
- package/dist/integrations/lithic.cjs.map +1 -0
- package/dist/integrations/lithic.d.cts +130 -0
- package/dist/integrations/lithic.d.ts +130 -0
- package/dist/integrations/lithic.js +264 -0
- package/dist/integrations/lithic.js.map +1 -0
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/marqeta.cjs +285 -0
- package/dist/integrations/marqeta.cjs.map +1 -0
- package/dist/integrations/marqeta.d.cts +121 -0
- package/dist/integrations/marqeta.d.ts +121 -0
- package/dist/integrations/marqeta.js +259 -0
- package/dist/integrations/marqeta.js.map +1 -0
- package/dist/integrations/modern-treasury.d.cts +1 -1
- package/dist/integrations/modern-treasury.d.ts +1 -1
- package/dist/integrations/nekuda.d.cts +1 -1
- package/dist/integrations/nekuda.d.ts +1 -1
- package/dist/integrations/okta.cjs +229 -0
- package/dist/integrations/okta.cjs.map +1 -0
- package/dist/integrations/okta.d.cts +172 -0
- package/dist/integrations/okta.d.ts +172 -0
- package/dist/integrations/okta.js +203 -0
- package/dist/integrations/okta.js.map +1 -0
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/paypal-agent.d.cts +1 -1
- package/dist/integrations/paypal-agent.d.ts +1 -1
- package/dist/integrations/plaid.d.cts +1 -1
- package/dist/integrations/plaid.d.ts +1 -1
- package/dist/integrations/ramp.cjs +206 -0
- package/dist/integrations/ramp.cjs.map +1 -0
- package/dist/integrations/ramp.d.cts +139 -0
- package/dist/integrations/ramp.d.ts +139 -0
- package/dist/integrations/ramp.js +180 -0
- package/dist/integrations/ramp.js.map +1 -0
- package/dist/integrations/shopify.d.cts +1 -1
- package/dist/integrations/shopify.d.ts +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +1 -1
- package/dist/integrations/skyfire.d.ts +1 -1
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/stripe-issuing.cjs +316 -0
- package/dist/integrations/stripe-issuing.cjs.map +1 -0
- package/dist/integrations/stripe-issuing.d.cts +154 -0
- package/dist/integrations/stripe-issuing.d.ts +154 -0
- package/dist/integrations/stripe-issuing.js +290 -0
- package/dist/integrations/stripe-issuing.js.map +1 -0
- package/dist/integrations/truanon.d.cts +1 -1
- package/dist/integrations/truanon.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/x402.d.cts +1 -1
- package/dist/integrations/x402.d.ts +1 -1
- package/dist/{types-zzK9YOoa.d.cts → types-Lp1iHEDz.d.cts} +21 -1
- package/dist/{types-zzK9YOoa.d.ts → types-Lp1iHEDz.d.ts} +21 -1
- package/package.json +121 -1
|
@@ -0,0 +1,229 @@
|
|
|
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/okta.ts
|
|
21
|
+
var okta_exports = {};
|
|
22
|
+
__export(okta_exports, {
|
|
23
|
+
VorimOkta: () => VorimOkta,
|
|
24
|
+
createVorimOkta: () => createVorimOkta
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(okta_exports);
|
|
27
|
+
var ESCALATION_OPS = /* @__PURE__ */ new Set(["grantRole", "createApiToken"]);
|
|
28
|
+
var OPERATION_SCOPE = {
|
|
29
|
+
read: "agent:read",
|
|
30
|
+
createUser: "agent:write",
|
|
31
|
+
deactivateUser: "agent:write",
|
|
32
|
+
assignAppToUser: "agent:write",
|
|
33
|
+
addUserToGroup: "agent:write",
|
|
34
|
+
grantRole: "agent:elevate",
|
|
35
|
+
createApiToken: "agent:elevate"
|
|
36
|
+
};
|
|
37
|
+
var VorimOkta = class {
|
|
38
|
+
sdk;
|
|
39
|
+
agentId;
|
|
40
|
+
orgUrl;
|
|
41
|
+
adminId;
|
|
42
|
+
minTrustScore;
|
|
43
|
+
escalatePrivileged;
|
|
44
|
+
escalationTimeoutMs;
|
|
45
|
+
onError;
|
|
46
|
+
constructor(sdk, config) {
|
|
47
|
+
if (!config?.agentId) throw new Error("[vorim] Okta integration requires an agentId.");
|
|
48
|
+
if (!config?.orgUrl) throw new Error("[vorim] Okta integration requires an orgUrl.");
|
|
49
|
+
this.sdk = sdk;
|
|
50
|
+
this.agentId = config.agentId;
|
|
51
|
+
this.orgUrl = config.orgUrl;
|
|
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
|
+
/**
|
|
65
|
+
* Decide whether the acting agent may run this operation, before it runs.
|
|
66
|
+
* Order: trust floor, then the privileged gate (escalate a role grant or token
|
|
67
|
+
* mint to the named admin), then permission scope.
|
|
68
|
+
*/
|
|
69
|
+
async authorize(action) {
|
|
70
|
+
const privileged = this.isPrivileged(action.operation);
|
|
71
|
+
const scope = this.scopeFor(action.operation);
|
|
72
|
+
try {
|
|
73
|
+
if (this.minTrustScore > 0) {
|
|
74
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
75
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
76
|
+
return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: privileged ? "privileged-denied" : "ordinary" };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (privileged) {
|
|
80
|
+
if (!this.escalatePrivileged) {
|
|
81
|
+
return { authorized: false, reason: `${action.operation} requires a human admin and escalatePrivileged is off`, outcome: "privileged-denied" };
|
|
82
|
+
}
|
|
83
|
+
if (!this.adminId) {
|
|
84
|
+
return {
|
|
85
|
+
authorized: false,
|
|
86
|
+
reason: `${action.operation} requires a configured adminId (the approving human admin)`,
|
|
87
|
+
outcome: "privileged-denied"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const esc = await this.escalate(action, scope);
|
|
91
|
+
return {
|
|
92
|
+
authorized: esc.approved,
|
|
93
|
+
reason: esc.approved ? void 0 : esc.reason ?? "admin did not approve",
|
|
94
|
+
outcome: esc.approved ? "approved-by-admin" : "privileged-denied",
|
|
95
|
+
adminId: esc.approved ? this.adminId : void 0,
|
|
96
|
+
decisionId: esc.decisionId
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
100
|
+
return perm.allowed ? { authorized: true, outcome: "ordinary", adminId: this.adminId } : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: "ordinary" };
|
|
101
|
+
} catch (e) {
|
|
102
|
+
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" };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async escalate(action, scope) {
|
|
106
|
+
const decision = await this.sdk.beforeAction(
|
|
107
|
+
{
|
|
108
|
+
agentId: this.agentId,
|
|
109
|
+
actionType: "api_request",
|
|
110
|
+
actionTarget: `okta:${action.operation}`,
|
|
111
|
+
requiredScope: scope,
|
|
112
|
+
payload: { operation: action.operation, target_id: action.targetId, role: action.role },
|
|
113
|
+
context: { integration: "okta", org_url: this.orgUrl, requires_human_admin: true, admin_hint: this.adminId }
|
|
114
|
+
},
|
|
115
|
+
{ throwOnDeny: false }
|
|
116
|
+
);
|
|
117
|
+
if (decision.decision === "escalate") {
|
|
118
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
|
|
119
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
120
|
+
return { approved, reason: approved ? void 0 : "admin refused", decisionId: decision.decisionId };
|
|
121
|
+
}
|
|
122
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
123
|
+
if (decision.decision === "fallback")
|
|
124
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
125
|
+
return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
|
|
126
|
+
}
|
|
127
|
+
async record(action, result, extra = {}) {
|
|
128
|
+
const scope = this.scopeFor(action.operation);
|
|
129
|
+
try {
|
|
130
|
+
await this.sdk.emit(
|
|
131
|
+
{
|
|
132
|
+
agent_id: this.agentId,
|
|
133
|
+
event_type: "api_request",
|
|
134
|
+
action: `okta:${action.operation}${action.targetId ? " " + action.targetId : ""}`,
|
|
135
|
+
resource: action.targetId || this.orgUrl,
|
|
136
|
+
permission: scope,
|
|
137
|
+
result,
|
|
138
|
+
input_hash: action.inputHash,
|
|
139
|
+
metadata: {
|
|
140
|
+
integration: "okta",
|
|
141
|
+
org_url: this.orgUrl,
|
|
142
|
+
operation: action.operation,
|
|
143
|
+
privileged: this.isPrivileged(action.operation),
|
|
144
|
+
...action.role ? { role: action.role } : {},
|
|
145
|
+
...extra.outcome ? { outcome: extra.outcome } : {},
|
|
146
|
+
...extra.adminId ?? this.adminId ? { approved_by_admin: extra.adminId ?? this.adminId } : {},
|
|
147
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
148
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{ sign: true }
|
|
152
|
+
);
|
|
153
|
+
return true;
|
|
154
|
+
} catch {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async guard(action, run) {
|
|
159
|
+
const auth = await this.authorize(action);
|
|
160
|
+
if (!auth.authorized) {
|
|
161
|
+
const recorded = await this.record(action, "denied", { reason: auth.reason, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
|
|
162
|
+
return { receipt: this.receipt(action, false, "denied", auth, recorded) };
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const value = await run();
|
|
166
|
+
const recorded = await this.record(action, "success", { outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
|
|
167
|
+
return { receipt: this.receipt(action, true, "success", auth, recorded), value };
|
|
168
|
+
} catch (e) {
|
|
169
|
+
const recorded = await this.record(action, "error", { reason: e?.message, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
|
|
170
|
+
throw Object.assign(e ?? new Error("okta operation failed"), {
|
|
171
|
+
vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// --- Named helpers ---------------------------------------------------------
|
|
176
|
+
/** Guard creating a user (POST /api/v1/users). Requires agent:write. */
|
|
177
|
+
guardedCreateUser(meta, run) {
|
|
178
|
+
return this.guard({ operation: "createUser", targetId: meta.targetId, inputHash: meta.inputHash }, run);
|
|
179
|
+
}
|
|
180
|
+
/** Guard deactivating a user. Requires agent:write. */
|
|
181
|
+
guardedDeactivateUser(meta, run) {
|
|
182
|
+
return this.guard({ operation: "deactivateUser", targetId: meta.targetId, inputHash: meta.inputHash }, run);
|
|
183
|
+
}
|
|
184
|
+
/** Guard assigning an app to a user. Requires agent:write. */
|
|
185
|
+
guardedAssignAppToUser(meta, run) {
|
|
186
|
+
return this.guard({ operation: "assignAppToUser", targetId: meta.targetId, inputHash: meta.inputHash }, run);
|
|
187
|
+
}
|
|
188
|
+
/** Guard adding a user to a group. Requires agent:write. */
|
|
189
|
+
guardedAddUserToGroup(meta, run) {
|
|
190
|
+
return this.guard({ operation: "addUserToGroup", targetId: meta.targetId, inputHash: meta.inputHash }, run);
|
|
191
|
+
}
|
|
192
|
+
/** Guard granting an admin role (POST /api/v1/users/{id}/roles). Always
|
|
193
|
+
* escalates to the named admin. Pass the role (e.g. 'SUPER_ADMIN'). */
|
|
194
|
+
guardedGrantRole(meta, run) {
|
|
195
|
+
return this.guard({ operation: "grantRole", targetId: meta.targetId, role: meta.role, inputHash: meta.inputHash }, run);
|
|
196
|
+
}
|
|
197
|
+
/** Guard creating / rotating an API token (mints a long-lived, unscoped
|
|
198
|
+
* full-admin credential). Always escalates to the named admin. */
|
|
199
|
+
guardedCreateApiToken(meta, run) {
|
|
200
|
+
return this.guard({ operation: "createApiToken", targetId: meta.targetId, inputHash: meta.inputHash }, run);
|
|
201
|
+
}
|
|
202
|
+
receipt(action, authorized, result, auth, recorded) {
|
|
203
|
+
return {
|
|
204
|
+
authorized,
|
|
205
|
+
agentId: this.agentId,
|
|
206
|
+
orgUrl: this.orgUrl,
|
|
207
|
+
operation: action.operation,
|
|
208
|
+
targetId: action.targetId,
|
|
209
|
+
role: action.role,
|
|
210
|
+
privileged: this.isPrivileged(action.operation),
|
|
211
|
+
outcome: auth.outcome ?? "ordinary",
|
|
212
|
+
adminId: auth.adminId ?? this.adminId,
|
|
213
|
+
result,
|
|
214
|
+
scope: this.scopeFor(action.operation),
|
|
215
|
+
reason: auth.reason,
|
|
216
|
+
decisionId: auth.decisionId,
|
|
217
|
+
recorded
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function createVorimOkta(sdk, config) {
|
|
222
|
+
return new VorimOkta(sdk, config);
|
|
223
|
+
}
|
|
224
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
225
|
+
0 && (module.exports = {
|
|
226
|
+
VorimOkta,
|
|
227
|
+
createVorimOkta
|
|
228
|
+
});
|
|
229
|
+
//# sourceMappingURL=okta.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/okta.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Okta (Management API) Integration\n//\n// This guards an AI agent that administers an Okta org through the Okta\n// Management API — creating users, assigning apps, managing groups, granting\n// admin roles, minting API tokens. Before each write runs it verifies the\n// acting agent's Vorim identity and scoped permission, and for the two highest-\n// stakes operations (granting an admin role, minting an API token) it escalates\n// to a named human admin and waits. Either way it signs a tamper-evident record\n// of which agent did what, under which authority, and who approved it.\n//\n// WHY THIS LAYER\n// An Okta SSWS API token is unscoped: it inherits the full permissions of the\n// admin who created it, so an agent holding one can do anything that admin can,\n// and nothing proves which agent (not which other) made a given change. Vorim\n// binds each Management API write to a verified agent identity, caps what a\n// delegated agent may do, forces a human into the loop for the dangerous ops,\n// and signs the record. It composes with Okta's own OAuth-for-Okta service-app\n// model rather than replacing it: the closure holds the service-app key, Vorim\n// never does.\n//\n// THE ESCALATION RULE (the wedge)\n// Two operations mint or escalate standing authority and must always route to a\n// named human admin: granting an admin role (especially SUPER_ADMIN) and\n// creating/rotating an API token (which mints a long-lived, unscoped full-admin\n// credential). An agent may propose these; a human authorizes them.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// read directory -> agent:read\n// create/deactivate user, assign -> agent:write\n// app, manage group membership\n// grant admin role / mint token -> agent:elevate (named-admin approval;\n// segregation of duties)\n//\n// HONEST COMPLIANCE FRAMING\n// A signed, attributable record of each identity change supports SOC 2 (CC6\n// logical access, CC7 change monitoring) and access-governance review. No regime\n// mandates cryptographic signatures on audit logs; signing is a stronger-than-\n// required way to satisfy the tamper-evident + attributable intent. Say\n// \"cryptographic proof of which agent made which change, verifiable offline\",\n// never \"required for compliance\".\n//\n// This layer never holds the Okta token and never calls Okta itself. You pass\n// the Okta SDK / Management API call as a closure; it authorizes, escalates if\n// needed, runs it, and signs the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimOkta } from '@vorim/sdk/integrations/okta';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const okta = createVorimOkta(vorim, {\n// agentId: 'agid_abc123',\n// orgUrl: 'https://acme.okta.com',\n// adminId: 'admin_42', // the human who approves privileged ops\n// });\n//\n// const { receipt, value } = await okta.guardedCreateUser(\n// { targetId: 'user email or login' },\n// () => oktaClient.userApi.createUser({ body }),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** The Okta Management API operations this guard classifies. */\nexport type OktaOperation =\n | 'createUser' // POST /api/v1/users\n | 'deactivateUser' // POST /api/v1/users/{id}/lifecycle/deactivate\n | 'assignAppToUser' // POST /api/v1/apps/{appId}/users\n | 'addUserToGroup' // PUT /api/v1/groups/{groupId}/users/{userId}\n | 'grantRole' // POST /api/v1/users/{id}/roles (admin role)\n | 'createApiToken' // mint / rotate an API token\n | 'read';\n\n/** Operations that mint or escalate standing authority — always escalate to a\n * named human admin. */\nconst ESCALATION_OPS = new Set<string>(['grantRole', 'createApiToken']);\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n read: 'agent:read',\n createUser: 'agent:write',\n deactivateUser: 'agent:write',\n assignAppToUser: 'agent:write',\n addUserToGroup: 'agent:write',\n grantRole: 'agent:elevate',\n createApiToken: 'agent:elevate',\n};\n\nexport interface OktaGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The Okta org URL, e.g. 'https://acme.okta.com'. Recorded on every receipt\n * so a change is attributable to one org. */\n orgUrl: string;\n /** The human admin who approves privileged operations (grant role, mint\n * token). Required if any escalation-class op will be run. Recorded as the\n * approver. */\n adminId?: string;\n /** Minimum trust score the agent must hold before any write. Default 0. */\n minTrustScore?: number;\n /** For a privileged op, escalate to the named admin and wait for approval\n * instead of denying. Requires the runtime decision plane. Default true (an\n * unapproved role grant or token mint is exactly what this exists to stop). */\n escalatePrivileged?: boolean;\n /** Max time to wait for admin approval, ms. Default 300000 (5 min). */\n escalationTimeoutMs?: number;\n /** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface OktaAction {\n /** The Okta operation, e.g. 'createUser'. Drives the scope and whether the op\n * is escalation-class. Unknown labels default to write. */\n operation: OktaOperation | string;\n /** The target the action affects (user id/login, app id, group id). Recorded\n * for attribution. */\n targetId?: string;\n /** For grantRole: the role being granted, e.g. 'SUPER_ADMIN'. Recorded. */\n role?: string;\n /** Optional hash of the request body. */\n inputHash?: string;\n}\n\n/** How a privileged op resolved. */\nexport type OktaOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';\n\n/** An offline-verifiable receipt for one Okta Management API operation. */\nexport interface OktaReceipt {\n authorized: boolean;\n agentId: string;\n orgUrl: string;\n operation: string;\n targetId?: string;\n role?: string;\n /** True when the op mints/escalates authority (needs a human admin). */\n privileged: boolean;\n outcome: OktaOutcome;\n /** The admin recorded on the action. */\n adminId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimOkta {\n private sdk: VorimSDK;\n private agentId: string;\n private orgUrl: 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: OktaGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] Okta integration requires an agentId.');\n if (!config?.orgUrl) throw new Error('[vorim] Okta integration requires an orgUrl.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.orgUrl = config.orgUrl;\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 /**\n * Decide whether the acting agent may run this operation, before it runs.\n * Order: trust floor, then the privileged gate (escalate a role grant or token\n * mint to the named admin), then permission scope.\n */\n async authorize(\n action: OktaAction,\n ): Promise<{ authorized: boolean; reason?: string; outcome: OktaOutcome; 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: OktaAction, 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: `okta:${action.operation}`,\n requiredScope: scope,\n payload: { operation: action.operation, target_id: action.targetId, role: action.role },\n context: { integration: 'okta', org_url: this.orgUrl, 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: OktaAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; outcome?: OktaOutcome; 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: `okta:${action.operation}${action.targetId ? ' ' + action.targetId : ''}`,\n resource: action.targetId || this.orgUrl,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'okta',\n org_url: this.orgUrl,\n operation: action.operation,\n privileged: this.isPrivileged(action.operation),\n ...(action.role ? { role: action.role } : {}),\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: OktaAction, run: () => Promise<T>): Promise<{ receipt: OktaReceipt; 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('okta operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard creating a user (POST /api/v1/users). 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 deactivating a user. Requires agent:write. */\n guardedDeactivateUser<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'deactivateUser', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard assigning an app to a user. Requires agent:write. */\n guardedAssignAppToUser<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'assignAppToUser', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard adding a user to a group. Requires agent:write. */\n guardedAddUserToGroup<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'addUserToGroup', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard granting an admin role (POST /api/v1/users/{id}/roles). Always\n * escalates to the named admin. Pass the role (e.g. 'SUPER_ADMIN'). */\n guardedGrantRole<T>(meta: { targetId?: string; role?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'grantRole', targetId: meta.targetId, role: meta.role, inputHash: meta.inputHash }, run);\n }\n\n /** Guard creating / rotating an API token (mints a long-lived, unscoped\n * full-admin credential). Always escalates to the named admin. */\n guardedCreateApiToken<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'createApiToken', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: OktaAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; outcome?: OktaOutcome; adminId?: string; decisionId?: string },\n recorded: boolean,\n ): OktaReceipt {\n return {\n authorized,\n agentId: this.agentId,\n orgUrl: this.orgUrl,\n operation: action.operation,\n targetId: action.targetId,\n role: action.role,\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 VorimOkta guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimOkta } from '@vorim/sdk/integrations/okta';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const okta = createVorimOkta(vorim, {\n * agentId: 'agid_abc123',\n * orgUrl: 'https://acme.okta.com',\n * adminId: 'admin_42',\n * });\n *\n * // A role grant always escalates to the named admin:\n * const { receipt } = await okta.guardedGrantRole(\n * { targetId: 'user_9', role: 'SUPER_ADMIN' },\n * () => oktaClient.roleAssignmentApi.assignRoleToUser({ userId: 'user_9', assignRoleRequest }),\n * );\n * ```\n */\nexport function createVorimOkta(sdk: VorimSDK, config: OktaGuardConfig): VorimOkta {\n return new VorimOkta(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8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ACb,YAAY,KAAK,aAAa,OAAO,SAAS;AAAA,MAC9C,SAAS,KAAK,WAAW;AAAA,MACzB,SAAS,KAAK,WAAW,KAAK;AAAA,MAC9B;AAAA,MACA,OAAO,KAAK,SAAS,OAAO,SAAS;AAAA,MACrC,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAwBO,SAAS,gBAAgB,KAAe,QAAoC;AACjF,SAAO,IAAI,UAAU,KAAK,MAAM;AAClC;","names":[]}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import { P as PermissionScope } from '../types-Lp1iHEDz.cjs';
|
|
3
|
+
|
|
4
|
+
/** The Okta Management API operations this guard classifies. */
|
|
5
|
+
type OktaOperation = 'createUser' | 'deactivateUser' | 'assignAppToUser' | 'addUserToGroup' | 'grantRole' | 'createApiToken' | 'read';
|
|
6
|
+
interface OktaGuardConfig {
|
|
7
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
8
|
+
agentId: string;
|
|
9
|
+
/** The Okta org URL, e.g. 'https://acme.okta.com'. Recorded on every receipt
|
|
10
|
+
* so a change is attributable to one org. */
|
|
11
|
+
orgUrl: string;
|
|
12
|
+
/** The human admin who approves privileged operations (grant role, mint
|
|
13
|
+
* token). Required if any escalation-class op will be run. Recorded as the
|
|
14
|
+
* approver. */
|
|
15
|
+
adminId?: string;
|
|
16
|
+
/** Minimum trust score the agent must hold before any write. Default 0. */
|
|
17
|
+
minTrustScore?: number;
|
|
18
|
+
/** For a privileged op, escalate to the named admin and wait for approval
|
|
19
|
+
* instead of denying. Requires the runtime decision plane. Default true (an
|
|
20
|
+
* unapproved role grant or token mint is exactly what this exists to stop). */
|
|
21
|
+
escalatePrivileged?: boolean;
|
|
22
|
+
/** Max time to wait for admin approval, ms. Default 300000 (5 min). */
|
|
23
|
+
escalationTimeoutMs?: number;
|
|
24
|
+
/** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */
|
|
25
|
+
onError?: 'closed' | 'open';
|
|
26
|
+
}
|
|
27
|
+
interface OktaAction {
|
|
28
|
+
/** The Okta operation, e.g. 'createUser'. Drives the scope and whether the op
|
|
29
|
+
* is escalation-class. Unknown labels default to write. */
|
|
30
|
+
operation: OktaOperation | string;
|
|
31
|
+
/** The target the action affects (user id/login, app id, group id). Recorded
|
|
32
|
+
* for attribution. */
|
|
33
|
+
targetId?: string;
|
|
34
|
+
/** For grantRole: the role being granted, e.g. 'SUPER_ADMIN'. Recorded. */
|
|
35
|
+
role?: string;
|
|
36
|
+
/** Optional hash of the request body. */
|
|
37
|
+
inputHash?: string;
|
|
38
|
+
}
|
|
39
|
+
/** How a privileged op resolved. */
|
|
40
|
+
type OktaOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';
|
|
41
|
+
/** An offline-verifiable receipt for one Okta Management API operation. */
|
|
42
|
+
interface OktaReceipt {
|
|
43
|
+
authorized: boolean;
|
|
44
|
+
agentId: string;
|
|
45
|
+
orgUrl: string;
|
|
46
|
+
operation: string;
|
|
47
|
+
targetId?: string;
|
|
48
|
+
role?: string;
|
|
49
|
+
/** True when the op mints/escalates authority (needs a human admin). */
|
|
50
|
+
privileged: boolean;
|
|
51
|
+
outcome: OktaOutcome;
|
|
52
|
+
/** The admin recorded on the action. */
|
|
53
|
+
adminId?: string;
|
|
54
|
+
result: 'success' | 'denied' | 'error';
|
|
55
|
+
scope: PermissionScope;
|
|
56
|
+
reason?: string;
|
|
57
|
+
decisionId?: string;
|
|
58
|
+
recorded: boolean;
|
|
59
|
+
}
|
|
60
|
+
declare class VorimOkta {
|
|
61
|
+
private sdk;
|
|
62
|
+
private agentId;
|
|
63
|
+
private orgUrl;
|
|
64
|
+
private adminId?;
|
|
65
|
+
private minTrustScore;
|
|
66
|
+
private escalatePrivileged;
|
|
67
|
+
private escalationTimeoutMs;
|
|
68
|
+
private onError;
|
|
69
|
+
constructor(sdk: VorimSDK, config: OktaGuardConfig);
|
|
70
|
+
private isPrivileged;
|
|
71
|
+
private scopeFor;
|
|
72
|
+
/**
|
|
73
|
+
* Decide whether the acting agent may run this operation, before it runs.
|
|
74
|
+
* Order: trust floor, then the privileged gate (escalate a role grant or token
|
|
75
|
+
* mint to the named admin), then permission scope.
|
|
76
|
+
*/
|
|
77
|
+
authorize(action: OktaAction): Promise<{
|
|
78
|
+
authorized: boolean;
|
|
79
|
+
reason?: string;
|
|
80
|
+
outcome: OktaOutcome;
|
|
81
|
+
adminId?: string;
|
|
82
|
+
decisionId?: string;
|
|
83
|
+
}>;
|
|
84
|
+
private escalate;
|
|
85
|
+
record(action: OktaAction, result: 'success' | 'denied' | 'error', extra?: {
|
|
86
|
+
reason?: string;
|
|
87
|
+
outcome?: OktaOutcome;
|
|
88
|
+
adminId?: string;
|
|
89
|
+
decisionId?: string;
|
|
90
|
+
}): Promise<boolean>;
|
|
91
|
+
guard<T>(action: OktaAction, run: () => Promise<T>): Promise<{
|
|
92
|
+
receipt: OktaReceipt;
|
|
93
|
+
value?: T;
|
|
94
|
+
}>;
|
|
95
|
+
/** Guard creating a user (POST /api/v1/users). Requires agent:write. */
|
|
96
|
+
guardedCreateUser<T>(meta: {
|
|
97
|
+
targetId?: string;
|
|
98
|
+
inputHash?: string;
|
|
99
|
+
}, run: () => Promise<T>): Promise<{
|
|
100
|
+
receipt: OktaReceipt;
|
|
101
|
+
value?: T | undefined;
|
|
102
|
+
}>;
|
|
103
|
+
/** Guard deactivating a user. Requires agent:write. */
|
|
104
|
+
guardedDeactivateUser<T>(meta: {
|
|
105
|
+
targetId?: string;
|
|
106
|
+
inputHash?: string;
|
|
107
|
+
}, run: () => Promise<T>): Promise<{
|
|
108
|
+
receipt: OktaReceipt;
|
|
109
|
+
value?: T | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
/** Guard assigning an app to a user. Requires agent:write. */
|
|
112
|
+
guardedAssignAppToUser<T>(meta: {
|
|
113
|
+
targetId?: string;
|
|
114
|
+
inputHash?: string;
|
|
115
|
+
}, run: () => Promise<T>): Promise<{
|
|
116
|
+
receipt: OktaReceipt;
|
|
117
|
+
value?: T | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
/** Guard adding a user to a group. Requires agent:write. */
|
|
120
|
+
guardedAddUserToGroup<T>(meta: {
|
|
121
|
+
targetId?: string;
|
|
122
|
+
inputHash?: string;
|
|
123
|
+
}, run: () => Promise<T>): Promise<{
|
|
124
|
+
receipt: OktaReceipt;
|
|
125
|
+
value?: T | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
/** Guard granting an admin role (POST /api/v1/users/{id}/roles). Always
|
|
128
|
+
* escalates to the named admin. Pass the role (e.g. 'SUPER_ADMIN'). */
|
|
129
|
+
guardedGrantRole<T>(meta: {
|
|
130
|
+
targetId?: string;
|
|
131
|
+
role?: string;
|
|
132
|
+
inputHash?: string;
|
|
133
|
+
}, run: () => Promise<T>): Promise<{
|
|
134
|
+
receipt: OktaReceipt;
|
|
135
|
+
value?: T | undefined;
|
|
136
|
+
}>;
|
|
137
|
+
/** Guard creating / rotating an API token (mints a long-lived, unscoped
|
|
138
|
+
* full-admin credential). Always escalates to the named admin. */
|
|
139
|
+
guardedCreateApiToken<T>(meta: {
|
|
140
|
+
targetId?: string;
|
|
141
|
+
inputHash?: string;
|
|
142
|
+
}, run: () => Promise<T>): Promise<{
|
|
143
|
+
receipt: OktaReceipt;
|
|
144
|
+
value?: T | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
private receipt;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a VorimOkta guard around a Vorim SDK instance.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import createVorim from '@vorim/sdk';
|
|
154
|
+
* import { createVorimOkta } from '@vorim/sdk/integrations/okta';
|
|
155
|
+
*
|
|
156
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
157
|
+
* const okta = createVorimOkta(vorim, {
|
|
158
|
+
* agentId: 'agid_abc123',
|
|
159
|
+
* orgUrl: 'https://acme.okta.com',
|
|
160
|
+
* adminId: 'admin_42',
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* // A role grant always escalates to the named admin:
|
|
164
|
+
* const { receipt } = await okta.guardedGrantRole(
|
|
165
|
+
* { targetId: 'user_9', role: 'SUPER_ADMIN' },
|
|
166
|
+
* () => oktaClient.roleAssignmentApi.assignRoleToUser({ userId: 'user_9', assignRoleRequest }),
|
|
167
|
+
* );
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare function createVorimOkta(sdk: VorimSDK, config: OktaGuardConfig): VorimOkta;
|
|
171
|
+
|
|
172
|
+
export { type OktaAction, type OktaGuardConfig, type OktaOperation, type OktaOutcome, type OktaReceipt, VorimOkta, createVorimOkta };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import { P as PermissionScope } from '../types-Lp1iHEDz.js';
|
|
3
|
+
|
|
4
|
+
/** The Okta Management API operations this guard classifies. */
|
|
5
|
+
type OktaOperation = 'createUser' | 'deactivateUser' | 'assignAppToUser' | 'addUserToGroup' | 'grantRole' | 'createApiToken' | 'read';
|
|
6
|
+
interface OktaGuardConfig {
|
|
7
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
8
|
+
agentId: string;
|
|
9
|
+
/** The Okta org URL, e.g. 'https://acme.okta.com'. Recorded on every receipt
|
|
10
|
+
* so a change is attributable to one org. */
|
|
11
|
+
orgUrl: string;
|
|
12
|
+
/** The human admin who approves privileged operations (grant role, mint
|
|
13
|
+
* token). Required if any escalation-class op will be run. Recorded as the
|
|
14
|
+
* approver. */
|
|
15
|
+
adminId?: string;
|
|
16
|
+
/** Minimum trust score the agent must hold before any write. Default 0. */
|
|
17
|
+
minTrustScore?: number;
|
|
18
|
+
/** For a privileged op, escalate to the named admin and wait for approval
|
|
19
|
+
* instead of denying. Requires the runtime decision plane. Default true (an
|
|
20
|
+
* unapproved role grant or token mint is exactly what this exists to stop). */
|
|
21
|
+
escalatePrivileged?: boolean;
|
|
22
|
+
/** Max time to wait for admin approval, ms. Default 300000 (5 min). */
|
|
23
|
+
escalationTimeoutMs?: number;
|
|
24
|
+
/** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */
|
|
25
|
+
onError?: 'closed' | 'open';
|
|
26
|
+
}
|
|
27
|
+
interface OktaAction {
|
|
28
|
+
/** The Okta operation, e.g. 'createUser'. Drives the scope and whether the op
|
|
29
|
+
* is escalation-class. Unknown labels default to write. */
|
|
30
|
+
operation: OktaOperation | string;
|
|
31
|
+
/** The target the action affects (user id/login, app id, group id). Recorded
|
|
32
|
+
* for attribution. */
|
|
33
|
+
targetId?: string;
|
|
34
|
+
/** For grantRole: the role being granted, e.g. 'SUPER_ADMIN'. Recorded. */
|
|
35
|
+
role?: string;
|
|
36
|
+
/** Optional hash of the request body. */
|
|
37
|
+
inputHash?: string;
|
|
38
|
+
}
|
|
39
|
+
/** How a privileged op resolved. */
|
|
40
|
+
type OktaOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';
|
|
41
|
+
/** An offline-verifiable receipt for one Okta Management API operation. */
|
|
42
|
+
interface OktaReceipt {
|
|
43
|
+
authorized: boolean;
|
|
44
|
+
agentId: string;
|
|
45
|
+
orgUrl: string;
|
|
46
|
+
operation: string;
|
|
47
|
+
targetId?: string;
|
|
48
|
+
role?: string;
|
|
49
|
+
/** True when the op mints/escalates authority (needs a human admin). */
|
|
50
|
+
privileged: boolean;
|
|
51
|
+
outcome: OktaOutcome;
|
|
52
|
+
/** The admin recorded on the action. */
|
|
53
|
+
adminId?: string;
|
|
54
|
+
result: 'success' | 'denied' | 'error';
|
|
55
|
+
scope: PermissionScope;
|
|
56
|
+
reason?: string;
|
|
57
|
+
decisionId?: string;
|
|
58
|
+
recorded: boolean;
|
|
59
|
+
}
|
|
60
|
+
declare class VorimOkta {
|
|
61
|
+
private sdk;
|
|
62
|
+
private agentId;
|
|
63
|
+
private orgUrl;
|
|
64
|
+
private adminId?;
|
|
65
|
+
private minTrustScore;
|
|
66
|
+
private escalatePrivileged;
|
|
67
|
+
private escalationTimeoutMs;
|
|
68
|
+
private onError;
|
|
69
|
+
constructor(sdk: VorimSDK, config: OktaGuardConfig);
|
|
70
|
+
private isPrivileged;
|
|
71
|
+
private scopeFor;
|
|
72
|
+
/**
|
|
73
|
+
* Decide whether the acting agent may run this operation, before it runs.
|
|
74
|
+
* Order: trust floor, then the privileged gate (escalate a role grant or token
|
|
75
|
+
* mint to the named admin), then permission scope.
|
|
76
|
+
*/
|
|
77
|
+
authorize(action: OktaAction): Promise<{
|
|
78
|
+
authorized: boolean;
|
|
79
|
+
reason?: string;
|
|
80
|
+
outcome: OktaOutcome;
|
|
81
|
+
adminId?: string;
|
|
82
|
+
decisionId?: string;
|
|
83
|
+
}>;
|
|
84
|
+
private escalate;
|
|
85
|
+
record(action: OktaAction, result: 'success' | 'denied' | 'error', extra?: {
|
|
86
|
+
reason?: string;
|
|
87
|
+
outcome?: OktaOutcome;
|
|
88
|
+
adminId?: string;
|
|
89
|
+
decisionId?: string;
|
|
90
|
+
}): Promise<boolean>;
|
|
91
|
+
guard<T>(action: OktaAction, run: () => Promise<T>): Promise<{
|
|
92
|
+
receipt: OktaReceipt;
|
|
93
|
+
value?: T;
|
|
94
|
+
}>;
|
|
95
|
+
/** Guard creating a user (POST /api/v1/users). Requires agent:write. */
|
|
96
|
+
guardedCreateUser<T>(meta: {
|
|
97
|
+
targetId?: string;
|
|
98
|
+
inputHash?: string;
|
|
99
|
+
}, run: () => Promise<T>): Promise<{
|
|
100
|
+
receipt: OktaReceipt;
|
|
101
|
+
value?: T | undefined;
|
|
102
|
+
}>;
|
|
103
|
+
/** Guard deactivating a user. Requires agent:write. */
|
|
104
|
+
guardedDeactivateUser<T>(meta: {
|
|
105
|
+
targetId?: string;
|
|
106
|
+
inputHash?: string;
|
|
107
|
+
}, run: () => Promise<T>): Promise<{
|
|
108
|
+
receipt: OktaReceipt;
|
|
109
|
+
value?: T | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
/** Guard assigning an app to a user. Requires agent:write. */
|
|
112
|
+
guardedAssignAppToUser<T>(meta: {
|
|
113
|
+
targetId?: string;
|
|
114
|
+
inputHash?: string;
|
|
115
|
+
}, run: () => Promise<T>): Promise<{
|
|
116
|
+
receipt: OktaReceipt;
|
|
117
|
+
value?: T | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
/** Guard adding a user to a group. Requires agent:write. */
|
|
120
|
+
guardedAddUserToGroup<T>(meta: {
|
|
121
|
+
targetId?: string;
|
|
122
|
+
inputHash?: string;
|
|
123
|
+
}, run: () => Promise<T>): Promise<{
|
|
124
|
+
receipt: OktaReceipt;
|
|
125
|
+
value?: T | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
/** Guard granting an admin role (POST /api/v1/users/{id}/roles). Always
|
|
128
|
+
* escalates to the named admin. Pass the role (e.g. 'SUPER_ADMIN'). */
|
|
129
|
+
guardedGrantRole<T>(meta: {
|
|
130
|
+
targetId?: string;
|
|
131
|
+
role?: string;
|
|
132
|
+
inputHash?: string;
|
|
133
|
+
}, run: () => Promise<T>): Promise<{
|
|
134
|
+
receipt: OktaReceipt;
|
|
135
|
+
value?: T | undefined;
|
|
136
|
+
}>;
|
|
137
|
+
/** Guard creating / rotating an API token (mints a long-lived, unscoped
|
|
138
|
+
* full-admin credential). Always escalates to the named admin. */
|
|
139
|
+
guardedCreateApiToken<T>(meta: {
|
|
140
|
+
targetId?: string;
|
|
141
|
+
inputHash?: string;
|
|
142
|
+
}, run: () => Promise<T>): Promise<{
|
|
143
|
+
receipt: OktaReceipt;
|
|
144
|
+
value?: T | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
private receipt;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a VorimOkta guard around a Vorim SDK instance.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import createVorim from '@vorim/sdk';
|
|
154
|
+
* import { createVorimOkta } from '@vorim/sdk/integrations/okta';
|
|
155
|
+
*
|
|
156
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
157
|
+
* const okta = createVorimOkta(vorim, {
|
|
158
|
+
* agentId: 'agid_abc123',
|
|
159
|
+
* orgUrl: 'https://acme.okta.com',
|
|
160
|
+
* adminId: 'admin_42',
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* // A role grant always escalates to the named admin:
|
|
164
|
+
* const { receipt } = await okta.guardedGrantRole(
|
|
165
|
+
* { targetId: 'user_9', role: 'SUPER_ADMIN' },
|
|
166
|
+
* () => oktaClient.roleAssignmentApi.assignRoleToUser({ userId: 'user_9', assignRoleRequest }),
|
|
167
|
+
* );
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare function createVorimOkta(sdk: VorimSDK, config: OktaGuardConfig): VorimOkta;
|
|
171
|
+
|
|
172
|
+
export { type OktaAction, type OktaGuardConfig, type OktaOperation, type OktaOutcome, type OktaReceipt, VorimOkta, createVorimOkta };
|