@envseal/sdk 0.1.3 → 0.1.5
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/confirm.d.ts +10 -0
- package/dist/confirm.js +51 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/package.json +5 -5
package/dist/confirm.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ import type { Prompter } from '@envseal/prompters';
|
|
|
26
26
|
*/
|
|
27
27
|
/** Value-entry key name carrying the `env_use` confirmation. */
|
|
28
28
|
export declare const CONFIRM_KEY_USE = "APPROVE";
|
|
29
|
+
/** Value-entry key name carrying the `env_revoke` confirmation. */
|
|
30
|
+
export declare const CONFIRM_KEY_REVOKE = "APPROVE_REVOKE";
|
|
29
31
|
/** Value-entry key name carrying the `env_verify` probe-consent question. */
|
|
30
32
|
export declare const CONFIRM_KEY_PROBE = "APPROVE_PROBE";
|
|
31
33
|
export interface ConfirmSurface {
|
|
@@ -46,6 +48,7 @@ export declare function useConfirmationBody(info: {
|
|
|
46
48
|
networkEgress: boolean;
|
|
47
49
|
target?: TargetInfo;
|
|
48
50
|
}, projectRoot: string): string;
|
|
51
|
+
export declare function revokeConfirmationBody(keys: string[], projectRoot: string): string;
|
|
49
52
|
export declare function probeConfirmationBody(entry: ManifestEntry): string | null;
|
|
50
53
|
/**
|
|
51
54
|
* `onConfirm` for the Broker: gates `env_use`.
|
|
@@ -56,6 +59,13 @@ export declare function probeConfirmationBody(entry: ManifestEntry): string | nu
|
|
|
56
59
|
* or for a silence — the defect this project already fixed once in the CLI.
|
|
57
60
|
*/
|
|
58
61
|
export declare function createUseConfirm(surface: ConfirmSurface): NonNullable<BrokerOptions['onConfirm']>;
|
|
62
|
+
/**
|
|
63
|
+
* `onRevokeConfirm` for the Broker: gates `env_revoke`.
|
|
64
|
+
*
|
|
65
|
+
* Same ask/outcome mapping as createUseConfirm. Throws rather than returning
|
|
66
|
+
* false when no human could be asked or when the ask expired unanswered.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createRevokeConfirm(surface: ConfirmSurface): NonNullable<BrokerOptions['onRevokeConfirm']>;
|
|
59
69
|
/**
|
|
60
70
|
* `onApprovalNeeded` for the Broker: PLAN.md §6.4 probe consent for
|
|
61
71
|
* `env_verify` against a host that is not registry-allowlisted.
|
package/dist/confirm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { useConfirmationBody as sharedUseConfirmationBody, escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, } from '@envseal/core';
|
|
2
|
+
import { useConfirmationBody as sharedUseConfirmationBody, revokeConfirmationBody as sharedRevokeConfirmationBody, escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, } from '@envseal/core';
|
|
3
3
|
import { SepError, zero } from '@envseal/protocol';
|
|
4
4
|
import { makeDisplayNonce } from '@envseal/prompters';
|
|
5
5
|
/**
|
|
@@ -27,6 +27,8 @@ import { makeDisplayNonce } from '@envseal/prompters';
|
|
|
27
27
|
*/
|
|
28
28
|
/** Value-entry key name carrying the `env_use` confirmation. */
|
|
29
29
|
export const CONFIRM_KEY_USE = 'APPROVE';
|
|
30
|
+
/** Value-entry key name carrying the `env_revoke` confirmation. */
|
|
31
|
+
export const CONFIRM_KEY_REVOKE = 'APPROVE_REVOKE';
|
|
30
32
|
/** Value-entry key name carrying the `env_verify` probe-consent question. */
|
|
31
33
|
export const CONFIRM_KEY_PROBE = 'APPROVE_PROBE';
|
|
32
34
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
@@ -46,6 +48,9 @@ export const displayArg = coreDisplayArg;
|
|
|
46
48
|
export function useConfirmationBody(info, projectRoot) {
|
|
47
49
|
return sharedUseConfirmationBody(info, projectRoot);
|
|
48
50
|
}
|
|
51
|
+
export function revokeConfirmationBody(keys, projectRoot) {
|
|
52
|
+
return sharedRevokeConfirmationBody(keys, projectRoot);
|
|
53
|
+
}
|
|
49
54
|
export function probeConfirmationBody(entry) {
|
|
50
55
|
const probe = entry.verify;
|
|
51
56
|
if (!probe) {
|
|
@@ -160,6 +165,50 @@ export function createUseConfirm(surface) {
|
|
|
160
165
|
}
|
|
161
166
|
};
|
|
162
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* `onRevokeConfirm` for the Broker: gates `env_revoke`.
|
|
170
|
+
*
|
|
171
|
+
* Same ask/outcome mapping as createUseConfirm. Throws rather than returning
|
|
172
|
+
* false when no human could be asked or when the ask expired unanswered.
|
|
173
|
+
*/
|
|
174
|
+
export function createRevokeConfirm(surface) {
|
|
175
|
+
return async (keys) => {
|
|
176
|
+
const outcome = await ask(surface, CONFIRM_KEY_REVOKE, 'Approve removing stored credentials? Nothing has been removed yet.', revokeConfirmationBody(keys, surface.projectRoot));
|
|
177
|
+
switch (outcome) {
|
|
178
|
+
case 'approved':
|
|
179
|
+
return true;
|
|
180
|
+
case 'denied':
|
|
181
|
+
return false;
|
|
182
|
+
case 'timed-out':
|
|
183
|
+
throw new SepError({
|
|
184
|
+
code: 'SEP_TICKET_EXPIRED',
|
|
185
|
+
userMessage: 'The env_revoke confirmation closed after its timeout with nobody answering it. Nothing was ' +
|
|
186
|
+
'removed. This is not a denial: ask the user to approve it, then call env_revoke again.',
|
|
187
|
+
});
|
|
188
|
+
case 'no-surface':
|
|
189
|
+
throw new SepError({
|
|
190
|
+
code: 'SEP_NO_INTERACTIVE_SURFACE',
|
|
191
|
+
userMessage: 'env_revoke needs the user to confirm before stored credentials are removed, ' +
|
|
192
|
+
'but there is no interactive surface here to ask on (this is what CI looks like to envseal). ' +
|
|
193
|
+
'Nothing was removed. ' +
|
|
194
|
+
'There is no flag or environment variable that skips this prompt in this binding: the request ' +
|
|
195
|
+
'came from a model, and the confirmation is the only control on it. ' +
|
|
196
|
+
'Run `envseal revoke` yourself in a session that has a browser or a terminal.',
|
|
197
|
+
});
|
|
198
|
+
case 'busy':
|
|
199
|
+
throw new SepError({
|
|
200
|
+
code: 'SEP_RATE_LIMITED',
|
|
201
|
+
userMessage: 'Another envseal confirmation is already open. Answer that one first, then call env_revoke again.',
|
|
202
|
+
});
|
|
203
|
+
case 'too-large':
|
|
204
|
+
throw new SepError({
|
|
205
|
+
code: 'SEP_FORMAT_INVALID',
|
|
206
|
+
userMessage: 'This revoke request is too large to display in a confirmation dialog, and envseal will not ask ' +
|
|
207
|
+
'anyone to approve something it cannot show them. Revoke fewer keys at once.',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
163
212
|
/**
|
|
164
213
|
* `onApprovalNeeded` for the Broker: PLAN.md §6.4 probe consent for
|
|
165
214
|
* `env_verify` against a host that is not registry-allowlisted.
|
|
@@ -172,7 +221,7 @@ export function createUseConfirm(surface) {
|
|
|
172
221
|
*/
|
|
173
222
|
export function createProbeApproval(surface) {
|
|
174
223
|
return async (entry) => {
|
|
175
|
-
const outcome = await ask(surface, CONFIRM_KEY_PROBE, `Approve sending ${entry.key} to a host that is not on envseal's allowlist? Nothing has been sent yet.`, probeConfirmationBody(entry));
|
|
224
|
+
const outcome = await ask(surface, CONFIRM_KEY_PROBE, `Approve sending ${escapeForDisplay(entry.key)} to a host that is not on envseal's allowlist? Nothing has been sent yet.`, probeConfirmationBody(entry));
|
|
176
225
|
return outcome === 'approved';
|
|
177
226
|
};
|
|
178
227
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export type Dialect = 'openai' | 'anthropic' | 'gemini';
|
|
|
12
12
|
export declare function toolsFor(dialect: Dialect): unknown[];
|
|
13
13
|
export declare function dispatch(broker: Broker, name: string, args: unknown): Promise<unknown>;
|
|
14
14
|
export { SEP_TOOL_NAMES } from '@envseal/protocol';
|
|
15
|
-
export { createUseConfirm, createProbeApproval, annotateVerifyResults, CONFIRM_KEY_USE, CONFIRM_KEY_PROBE, } from './confirm.js';
|
|
15
|
+
export { createUseConfirm, createRevokeConfirm, createProbeApproval, annotateVerifyResults, CONFIRM_KEY_USE, CONFIRM_KEY_REVOKE, CONFIRM_KEY_PROBE, } from './confirm.js';
|
|
16
16
|
export type { ConfirmSurface } from './confirm.js';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Broker } from '@envseal/core';
|
|
|
3
3
|
import { selectPrompter } from '@envseal/prompters';
|
|
4
4
|
import { SEP_TOOL_NAMES, INPUT_SCHEMAS, isSepError, } from '@envseal/protocol';
|
|
5
5
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
6
|
-
import { annotateVerifyResults, createProbeApproval, createUseConfirm } from './confirm.js';
|
|
6
|
+
import { annotateVerifyResults, createProbeApproval, createRevokeConfirm, createUseConfirm } from './confirm.js';
|
|
7
7
|
export function createBroker(opts) {
|
|
8
8
|
const root = opts?.root ?? findProjectRoot(process.cwd());
|
|
9
9
|
// Resolved lazily and memoised: `selectPrompter()` is async and this factory
|
|
@@ -25,6 +25,7 @@ export function createBroker(opts) {
|
|
|
25
25
|
// reports the absent callback as SEP_CONFIRMATION_DENIED — blaming a user
|
|
26
26
|
// who was never asked. See confirm.ts.
|
|
27
27
|
onConfirm: createUseConfirm(surface),
|
|
28
|
+
onRevokeConfirm: createRevokeConfirm(surface),
|
|
28
29
|
onApprovalNeeded: createProbeApproval(surface),
|
|
29
30
|
};
|
|
30
31
|
return new Broker(brokerOpts);
|
|
@@ -71,7 +72,7 @@ const TOOL_DESCRIPTIONS = {
|
|
|
71
72
|
'It will NOT print the secrets to you, will NOT export them into your own environment, and refuses to ' +
|
|
72
73
|
'run without explicit user confirmation. ' +
|
|
73
74
|
'To check whether a key exists instead of running a command, call env_describe.',
|
|
74
|
-
env_revoke: 'Removes stored credentials. Records in the audit log and emits the provider ' +
|
|
75
|
+
env_revoke: 'Removes stored credentials after user confirmation. Records in the audit log and emits the provider ' +
|
|
75
76
|
'rotation URL so you can help the user invalidate the old key.',
|
|
76
77
|
};
|
|
77
78
|
export function toolsFor(dialect) {
|
|
@@ -219,5 +220,5 @@ export async function dispatch(broker, name, args) {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
export { SEP_TOOL_NAMES } from '@envseal/protocol';
|
|
222
|
-
export { createUseConfirm, createProbeApproval, annotateVerifyResults, CONFIRM_KEY_USE, CONFIRM_KEY_PROBE, } from './confirm.js';
|
|
223
|
+
export { createUseConfirm, createRevokeConfirm, createProbeApproval, annotateVerifyResults, CONFIRM_KEY_USE, CONFIRM_KEY_REVOKE, CONFIRM_KEY_PROBE, } from './confirm.js';
|
|
223
224
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envseal/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod-to-json-schema": "^3.24.1",
|
|
24
|
-
"@envseal/protocol": "0.1.
|
|
25
|
-
"@envseal/core": "0.1.
|
|
26
|
-
"@envseal/registry": "0.1.
|
|
27
|
-
"@envseal/prompters": "0.1.
|
|
24
|
+
"@envseal/protocol": "0.1.5",
|
|
25
|
+
"@envseal/core": "0.1.5",
|
|
26
|
+
"@envseal/registry": "0.1.5",
|
|
27
|
+
"@envseal/prompters": "0.1.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"vitest": "^2.1.8"
|