@atlasent/sdk 1.5.0 → 2.10.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/README.md +141 -27
- package/dist/hono.cjs +1943 -64
- package/dist/hono.cjs.map +1 -1
- package/dist/hono.d.cts +4 -4
- package/dist/hono.d.ts +4 -4
- package/dist/hono.js +1933 -64
- package/dist/hono.js.map +1 -1
- package/dist/index.cjs +5299 -210
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5465 -502
- package/dist/index.d.ts +5465 -502
- package/dist/index.js +5177 -209
- package/dist/index.js.map +1 -1
- package/dist/protect-C0t0fP1y.d.cts +1776 -0
- package/dist/protect-C0t0fP1y.d.ts +1776 -0
- package/dist/state.cjs +46 -0
- package/dist/state.cjs.map +1 -0
- package/dist/state.d.cts +152 -0
- package/dist/state.d.ts +152 -0
- package/dist/state.js +21 -0
- package/dist/state.js.map +1 -0
- package/package.json +29 -2
- package/dist/protect-BKxcoR_2.d.cts +0 -159
- package/dist/protect-BKxcoR_2.d.ts +0 -159
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error types for the AtlaSent TypeScript SDK.
|
|
3
|
-
*
|
|
4
|
-
* The SDK follows a fail-closed design: a clean policy DENY is
|
|
5
|
-
* returned as `EvaluateResponse.decision === "DENY"` (not thrown),
|
|
6
|
-
* but any failure to confirm authorization — network, timeout,
|
|
7
|
-
* bad response, invalid key, rate limit — throws an
|
|
8
|
-
* {@link AtlaSentError}.
|
|
9
|
-
*/
|
|
10
|
-
/** Discriminator for {@link AtlaSentError.code}. */
|
|
11
|
-
type AtlaSentErrorCode = "invalid_api_key" | "forbidden" | "rate_limited" | "timeout" | "network" | "bad_response" | "bad_request" | "server_error";
|
|
12
|
-
/** Initialization options for {@link AtlaSentError}. */
|
|
13
|
-
interface AtlaSentErrorInit {
|
|
14
|
-
status?: number;
|
|
15
|
-
code?: AtlaSentErrorCode;
|
|
16
|
-
requestId?: string;
|
|
17
|
-
retryAfterMs?: number;
|
|
18
|
-
cause?: unknown;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The only error type this SDK throws.
|
|
22
|
-
*
|
|
23
|
-
* Flat top-level properties mirror the convention used by Stripe,
|
|
24
|
-
* Octokit, and Supabase. `cause` is forwarded to the standard
|
|
25
|
-
* ES2022 `Error` constructor.
|
|
26
|
-
*/
|
|
27
|
-
declare class AtlaSentError extends Error {
|
|
28
|
-
name: string;
|
|
29
|
-
/** HTTP status code, when the error originated from an API response. */
|
|
30
|
-
readonly status: number | undefined;
|
|
31
|
-
/** Coarse category — useful for `switch` statements at call sites. */
|
|
32
|
-
readonly code: AtlaSentErrorCode | undefined;
|
|
33
|
-
/** Correlation ID echoed from the `X-Request-ID` header the SDK sent. */
|
|
34
|
-
readonly requestId: string | undefined;
|
|
35
|
-
/** Parsed `Retry-After` header value, in milliseconds. Only set for 429. */
|
|
36
|
-
readonly retryAfterMs: number | undefined;
|
|
37
|
-
constructor(message: string, init?: AtlaSentErrorInit);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Outcome of a denied decision.
|
|
41
|
-
*
|
|
42
|
-
* `"deny"` is what the current `/v1-evaluate` API returns. `"hold"`
|
|
43
|
-
* and `"escalate"` are reserved for forthcoming API decisions that
|
|
44
|
-
* put a permit into a pending state requiring human review; the
|
|
45
|
-
* union is declared now so call sites can `switch` exhaustively
|
|
46
|
-
* from the start and adopt new decisions without a breaking change.
|
|
47
|
-
*/
|
|
48
|
-
type AtlaSentDecision = "deny" | "hold" | "escalate";
|
|
49
|
-
/** Initialization options for {@link AtlaSentDeniedError}. */
|
|
50
|
-
interface AtlaSentDeniedErrorInit {
|
|
51
|
-
decision: AtlaSentDecision;
|
|
52
|
-
evaluationId: string;
|
|
53
|
-
reason?: string;
|
|
54
|
-
requestId?: string;
|
|
55
|
-
auditHash?: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Thrown by {@link atlasent.protect} when the policy engine refuses
|
|
59
|
-
* the action, or when a permit fails end-to-end verification.
|
|
60
|
-
*
|
|
61
|
-
* This is the **fail-closed boundary** of the SDK: every code path
|
|
62
|
-
* that short-circuits an action because authorization was not
|
|
63
|
-
* confirmed raises an `AtlaSentDeniedError`. Callers cannot silently
|
|
64
|
-
* proceed on a denial by forgetting to branch on a return value.
|
|
65
|
-
*
|
|
66
|
-
* Extends {@link AtlaSentError} so `instanceof AtlaSentError`
|
|
67
|
-
* catches denials as part of the SDK's single exception family;
|
|
68
|
-
* use `instanceof AtlaSentDeniedError` to distinguish a policy
|
|
69
|
-
* denial from a transport/auth error.
|
|
70
|
-
*/
|
|
71
|
-
declare class AtlaSentDeniedError extends AtlaSentError {
|
|
72
|
-
name: string;
|
|
73
|
-
/** Policy decision — `"deny"` today; `"hold"` / `"escalate"` reserved. */
|
|
74
|
-
readonly decision: AtlaSentDecision;
|
|
75
|
-
/** Opaque permit/decision id from `/v1-evaluate`. */
|
|
76
|
-
readonly evaluationId: string;
|
|
77
|
-
/** Human-readable explanation from the policy engine, if provided. */
|
|
78
|
-
readonly reason: string | undefined;
|
|
79
|
-
/** Hash-chained audit-trail entry associated with the decision. */
|
|
80
|
-
readonly auditHash: string | undefined;
|
|
81
|
-
constructor(init: AtlaSentDeniedErrorInit);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* `atlasent.protect(...)` — the one-call, fail-closed execution-time
|
|
86
|
-
* authorization boundary.
|
|
87
|
-
*
|
|
88
|
-
* ```ts
|
|
89
|
-
* import atlasent from "@atlasent/sdk";
|
|
90
|
-
*
|
|
91
|
-
* const permit = await atlasent.protect({
|
|
92
|
-
* agent: "deploy-bot",
|
|
93
|
-
* action: "deploy_to_production",
|
|
94
|
-
* context: { commit, approver },
|
|
95
|
-
* });
|
|
96
|
-
* // …run the action. If we got here, AtlaSent authorized it
|
|
97
|
-
* // end-to-end (evaluate + verifyPermit).
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* Unlike {@link AtlaSentClient.evaluate}, `protect` never returns a
|
|
101
|
-
* denied decision. On deny, it throws {@link AtlaSentDeniedError};
|
|
102
|
-
* on transport / auth / server failure it throws
|
|
103
|
-
* {@link AtlaSentError}. The action cannot execute unless a valid
|
|
104
|
-
* {@link Permit} is returned — this is the SDK's category boundary,
|
|
105
|
-
* not a helper.
|
|
106
|
-
*/
|
|
107
|
-
/** Input to {@link protect}. Same shape as `EvaluateRequest`. */
|
|
108
|
-
interface ProtectRequest {
|
|
109
|
-
agent: string;
|
|
110
|
-
action: string;
|
|
111
|
-
context?: Record<string, unknown>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Success return from {@link protect}. The action is authorized
|
|
115
|
-
* end-to-end — evaluation allowed AND the resulting permit verified.
|
|
116
|
-
*/
|
|
117
|
-
interface Permit {
|
|
118
|
-
/** Opaque permit / decision identifier. */
|
|
119
|
-
permitId: string;
|
|
120
|
-
/** Verification hash bound to the permit. */
|
|
121
|
-
permitHash: string;
|
|
122
|
-
/** Audit-trail entry associated with the decision (hash-chained). */
|
|
123
|
-
auditHash: string;
|
|
124
|
-
/** Human-readable reason from the policy engine. */
|
|
125
|
-
reason: string;
|
|
126
|
-
/** ISO 8601 timestamp of the verification. */
|
|
127
|
-
timestamp: string;
|
|
128
|
-
}
|
|
129
|
-
/** Configuration for the process-wide singleton used by {@link protect}. */
|
|
130
|
-
interface ConfigureOptions {
|
|
131
|
-
/** Overrides `ATLASENT_API_KEY` env var. */
|
|
132
|
-
apiKey?: string;
|
|
133
|
-
/** Overrides the default `https://api.atlasent.io`. */
|
|
134
|
-
baseUrl?: string;
|
|
135
|
-
/** Per-request timeout in ms. */
|
|
136
|
-
timeoutMs?: number;
|
|
137
|
-
/** Inject a custom fetch (primarily for tests). */
|
|
138
|
-
fetch?: typeof fetch;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Configure the singleton client used by {@link protect}. Optional —
|
|
142
|
-
* if `ATLASENT_API_KEY` is set in the environment, `protect` works
|
|
143
|
-
* without any configuration. Calling `configure` again replaces the
|
|
144
|
-
* singleton; subsequent `protect` calls use the new settings.
|
|
145
|
-
*/
|
|
146
|
-
declare function configure(options: ConfigureOptions): void;
|
|
147
|
-
/**
|
|
148
|
-
* Authorize an action end-to-end. On allow, returns a verified
|
|
149
|
-
* {@link Permit}. On anything else, throws:
|
|
150
|
-
*
|
|
151
|
-
* - {@link AtlaSentDeniedError} — policy denied, or the permit
|
|
152
|
-
* failed verification. Fail-closed: if this throws, the action
|
|
153
|
-
* MUST NOT proceed.
|
|
154
|
-
* - {@link AtlaSentError} — transport, timeout, auth, rate-limit,
|
|
155
|
-
* or server error. Same fail-closed contract: do not proceed.
|
|
156
|
-
*/
|
|
157
|
-
declare function protect(request: ProtectRequest): Promise<Permit>;
|
|
158
|
-
|
|
159
|
-
export { AtlaSentDeniedError as A, type ConfigureOptions as C, type Permit as P, AtlaSentError as a, type ProtectRequest as b, configure as c, type AtlaSentDecision as d, type AtlaSentDeniedErrorInit as e, type AtlaSentErrorCode as f, type AtlaSentErrorInit as g, protect as p };
|