@envseal/http-server 0.1.3 → 0.1.4

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 (2) hide show
  1. package/dist/server.js +22 -15
  2. package/package.json +5 -5
package/dist/server.js CHANGED
@@ -4,7 +4,7 @@ import * as node_fs from 'node:fs';
4
4
  import * as node_os from 'node:os';
5
5
  import * as node_path from 'node:path';
6
6
  import { Broker } from '@envseal/core';
7
- import { createProbeApproval, createUseConfirm, dispatch, isSepToolName } from '@envseal/sdk';
7
+ import { createProbeApproval, createRevokeConfirm, createUseConfirm, dispatch, isSepToolName, } from '@envseal/sdk';
8
8
  import { selectPrompter } from '@envseal/prompters';
9
9
  import { generateOpenAPI } from './openapi.js';
10
10
  async function getOrCreateToken(token) {
@@ -13,21 +13,27 @@ async function getOrCreateToken(token) {
13
13
  }
14
14
  const tokenDir = node_path.join(node_os.homedir(), '.envseal');
15
15
  const tokenFile = node_path.join(tokenDir, 'api-token');
16
- // Create directory if needed
17
- if (!node_fs.existsSync(tokenDir)) {
18
- node_fs.mkdirSync(tokenDir, { recursive: true, mode: 0o700 });
19
- }
20
- // Check if token file exists
21
- if (node_fs.existsSync(tokenFile)) {
22
- const tokenBuf = node_fs.readFileSync(tokenFile);
23
- return tokenBuf.toString('utf8').trim();
16
+ const persistRequested = process.env.ENVSEAL_PERSIST_HTTP_TOKEN === '1';
17
+ const existingToken = node_fs.existsSync(tokenFile);
18
+ // S3: persist only when explicitly requested or a user-wide token already exists.
19
+ if (persistRequested || existingToken) {
20
+ // Create directory if needed
21
+ if (!node_fs.existsSync(tokenDir)) {
22
+ node_fs.mkdirSync(tokenDir, { recursive: true, mode: 0o700 });
23
+ }
24
+ if (existingToken) {
25
+ const tokenBuf = node_fs.readFileSync(tokenFile);
26
+ return tokenBuf.toString('utf8').trim();
27
+ }
28
+ // Generate new token (32 random bytes as hex)
29
+ const randomBytes = node_crypto.randomBytes(32);
30
+ const newToken = randomBytes.toString('hex');
31
+ // Write with 0o600 permissions
32
+ node_fs.writeFileSync(tokenFile, newToken, { mode: 0o600 });
33
+ return newToken;
24
34
  }
25
- // Generate new token (32 random bytes as hex)
26
- const randomBytes = node_crypto.randomBytes(32);
27
- const newToken = randomBytes.toString('hex');
28
- // Write with 0o600 permissions
29
- node_fs.writeFileSync(tokenFile, newToken, { mode: 0o600 });
30
- return newToken;
35
+ // Ephemeral listen token: 128-bit+, not written to ~/.envseal/api-token.
36
+ return node_crypto.randomBytes(32).toString('hex');
31
37
  }
32
38
  /**
33
39
  * Constant-time bearer token check. Shared by the /v1 route auth and the
@@ -63,6 +69,7 @@ export async function startHttpServer(opts) {
63
69
  // no way to ask anyone, and exec.ts reports the missing callback as "the
64
70
  // user denied the confirmation" for a user who was never asked.
65
71
  onConfirm: createUseConfirm(surface),
72
+ onRevokeConfirm: createRevokeConfirm(surface),
66
73
  // PLAN.md §6.4 probe consent, supplied by no binding before this.
67
74
  onApprovalNeeded: createProbeApproval(surface),
68
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envseal/http-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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.3",
25
- "@envseal/core": "0.1.3",
26
- "@envseal/prompters": "0.1.3",
27
- "@envseal/sdk": "0.1.3"
24
+ "@envseal/protocol": "0.1.4",
25
+ "@envseal/prompters": "0.1.4",
26
+ "@envseal/core": "0.1.4",
27
+ "@envseal/sdk": "0.1.4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "vitest": "^2.1.8"