@envseal/sdk 0.1.2 → 0.1.3

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 CHANGED
@@ -1,4 +1,4 @@
1
- import type { BrokerOptions } from '@envseal/core';
1
+ import { escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, type BrokerOptions, type TargetInfo } from '@envseal/core';
2
2
  import type { ManifestEntry, VerifyResult } from '@envseal/protocol';
3
3
  import type { Prompter } from '@envseal/prompters';
4
4
  /**
@@ -18,13 +18,11 @@ import type { Prompter } from '@envseal/prompters';
18
18
  * between a prompt-injected model and arbitrary code holding live
19
19
  * credentials. In CI these operations are simply unavailable, and say so.
20
20
  *
21
- * DUPLICATION: this file is a hand-maintained twin of
22
- * packages/mcp-server/src/confirm.ts. Its natural home is a `confirm()` method
23
- * on the `Prompter` interface every surface already knows how to draw a
24
- * dialog but @envseal/mcp-server does not depend on @envseal/sdk, and
25
- * @envseal/prompters was outside the scope of the change that added this. Both
26
- * packages test the behaviour independently, so drift shows up as a red test
27
- * rather than as a binding that quietly stops asking.
21
+ * DUPLICATION: this file remains a hand-maintained twin of
22
+ * packages/mcp-server/src/confirm.ts for the ask/outcome mapping, but the dialog
23
+ * BODY (escaping, truncation caps, fingerprints, warnings) is shared via
24
+ * useConfirmationBody from @envseal/core so the CLI, SDK and MCP surfaces
25
+ * can never drift on what the user is shown.
28
26
  */
29
27
  /** Value-entry key name carrying the `env_use` confirmation. */
30
28
  export declare const CONFIRM_KEY_USE = "APPROVE";
@@ -40,10 +38,13 @@ export interface ConfirmSurface {
40
38
  prompter: () => Promise<Prompter>;
41
39
  timeoutMs?: number;
42
40
  }
41
+ export declare const escapeForDisplay: typeof coreEscapeForDisplay;
42
+ export declare const displayArg: typeof coreDisplayArg;
43
43
  export declare function useConfirmationBody(info: {
44
44
  command: string[];
45
45
  keys: string[];
46
46
  networkEgress: boolean;
47
+ target?: TargetInfo;
47
48
  }, projectRoot: string): string;
48
49
  export declare function probeConfirmationBody(entry: ManifestEntry): string | null;
49
50
  /**
package/dist/confirm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from 'node:crypto';
2
+ import { useConfirmationBody as sharedUseConfirmationBody, escapeForDisplay as coreEscapeForDisplay, displayArg as coreDisplayArg, } from '@envseal/core';
2
3
  import { SepError, zero } from '@envseal/protocol';
3
4
  import { makeDisplayNonce } from '@envseal/prompters';
4
5
  /**
@@ -18,21 +19,17 @@ import { makeDisplayNonce } from '@envseal/prompters';
18
19
  * between a prompt-injected model and arbitrary code holding live
19
20
  * credentials. In CI these operations are simply unavailable, and say so.
20
21
  *
21
- * DUPLICATION: this file is a hand-maintained twin of
22
- * packages/mcp-server/src/confirm.ts. Its natural home is a `confirm()` method
23
- * on the `Prompter` interface every surface already knows how to draw a
24
- * dialog but @envseal/mcp-server does not depend on @envseal/sdk, and
25
- * @envseal/prompters was outside the scope of the change that added this. Both
26
- * packages test the behaviour independently, so drift shows up as a red test
27
- * rather than as a binding that quietly stops asking.
22
+ * DUPLICATION: this file remains a hand-maintained twin of
23
+ * packages/mcp-server/src/confirm.ts for the ask/outcome mapping, but the dialog
24
+ * BODY (escaping, truncation caps, fingerprints, warnings) is shared via
25
+ * useConfirmationBody from @envseal/core so the CLI, SDK and MCP surfaces
26
+ * can never drift on what the user is shown.
28
27
  */
29
28
  /** Value-entry key name carrying the `env_use` confirmation. */
30
29
  export const CONFIRM_KEY_USE = 'APPROVE';
31
30
  /** Value-entry key name carrying the `env_verify` probe-consent question. */
32
31
  export const CONFIRM_KEY_PROBE = 'APPROVE_PROBE';
33
32
  const DEFAULT_TIMEOUT_MS = 120_000;
34
- /** Per-argument display cap; longer arguments are shown truncated, and said to be. */
35
- const MAX_ARG_CHARS = 300;
36
33
  /** Whole-dialog cap. Past this we refuse rather than ask about something unreadable. */
37
34
  const MAX_BODY_CHARS = 16 * 1024;
38
35
  const INSTRUCTION = 'Type yes to approve, or submit an empty box to deny.';
@@ -41,57 +38,13 @@ const INSTRUCTION = 'Type yes to approve, or submit an empty box to deny.';
41
38
  * `env_use` in a loop and stack up dialogs until one gets clicked through.
42
39
  */
43
40
  let confirmationOpen = false;
44
- /**
45
- * Model-supplied argv, key names and probe metadata land in a dialog the user
46
- * is about to trust. A raw newline lets a crafted argument forge extra lines —
47
- * "keys: none", "this command is safe" — inside the very block that exists to
48
- * tell the truth about the command. Render control characters visibly instead.
49
- */
50
- function escapeForDisplay(value) {
51
- let out = '';
52
- for (const ch of value) {
53
- const code = ch.codePointAt(0) ?? 0;
54
- if (code < 0x20 || (code >= 0x7f && code <= 0x9f)) {
55
- out += `<0x${code.toString(16).padStart(2, '0')}>`;
56
- }
57
- else {
58
- out += ch;
59
- }
60
- }
61
- return out;
62
- }
63
- function displayArg(arg) {
64
- const escaped = escapeForDisplay(arg);
65
- if (escaped.length <= MAX_ARG_CHARS) {
66
- return escaped;
67
- }
68
- const hidden = escaped.length - MAX_ARG_CHARS;
69
- return `${escaped.slice(0, MAX_ARG_CHARS)}[... ${hidden} more characters, not shown]`;
70
- }
41
+ // Re-exported so existing importers of the twins keep working; the
42
+ // implementations live in @envseal/core/display.ts and are shared across
43
+ // every binding (CLI, SDK and MCP alike).
44
+ export const escapeForDisplay = coreEscapeForDisplay;
45
+ export const displayArg = coreDisplayArg;
71
46
  export function useConfirmationBody(info, projectRoot) {
72
- const lines = [
73
- 'EnvSeal is about to run a program with these secrets in its environment.',
74
- '',
75
- ` project: ${escapeForDisplay(projectRoot)}`,
76
- ` keys: ${info.keys.length > 0 ? info.keys.map(escapeForDisplay).join(', ') : '(none)'}`,
77
- '',
78
- ' command, one argument per line, exactly as it will be run (no shell):',
79
- ];
80
- info.command.forEach((arg, index) => {
81
- lines.push(` [${index}] ${displayArg(arg)}`);
82
- });
83
- lines.push('');
84
- if (info.networkEgress) {
85
- lines.push(' WARNING: this command can reach the network, so it could send these', ' values somewhere. Only continue if you trust it.');
86
- }
87
- else {
88
- // Honest about what the check is worth: NETWORK_TOOLS plus a URL scan is a
89
- // heuristic, and claiming more would be the kind of overstatement this
90
- // project has already had to walk back once.
91
- lines.push(' No network tool or URL was recognised in this command. That is a', ' heuristic, not a guarantee: any program can open a socket.');
92
- }
93
- lines.push('', `${INSTRUCTION} Nothing runs unless you approve.`);
94
- return lines.join('\n');
47
+ return sharedUseConfirmationBody(info, projectRoot);
95
48
  }
96
49
  export function probeConfirmationBody(entry) {
97
50
  const probe = entry.verify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envseal/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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.2",
25
- "@envseal/prompters": "0.1.2",
26
- "@envseal/core": "0.1.2",
27
- "@envseal/registry": "0.1.2"
24
+ "@envseal/protocol": "0.1.3",
25
+ "@envseal/core": "0.1.3",
26
+ "@envseal/registry": "0.1.3",
27
+ "@envseal/prompters": "0.1.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "vitest": "^2.1.8"