@suronai/sdk 0.1.28 → 0.1.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suronai/sdk",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "App SDK for Suron — await vault() to load secrets",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/poll.js CHANGED
@@ -1,8 +1,5 @@
1
1
  import { SuronDeniedError, SuronTimeoutError } from "./errors.js";
2
2
 
3
- const DEFAULT_TIMEOUT_MS = 300_000; // 5 minutes
4
- const DEFAULT_POLL_INTERVAL_MS = 3_000; // 3 seconds
5
-
6
3
  /**
7
4
  * Polls /status until the request is approved, denied, or times out.
8
5
  * @param {string} apiUrl
@@ -14,8 +11,8 @@ const DEFAULT_POLL_INTERVAL_MS = 3_000; // 3 seconds
14
11
  export async function pollUntilApproved(
15
12
  apiUrl,
16
13
  requestId,
17
- timeout = DEFAULT_TIMEOUT_MS,
18
- pollInterval = DEFAULT_POLL_INTERVAL_MS
14
+ timeout = 300_000,
15
+ pollInterval = 3_000
19
16
  ) {
20
17
  const deadline = Date.now() + timeout;
21
18
 
package/src/vault.js CHANGED
@@ -106,18 +106,19 @@ export async function vault(options = {}) {
106
106
  pollInterval = 3_000,
107
107
  } = options;
108
108
 
109
- const config = readSuronJson(configPath);
109
+ const suronJson = readSuronJson(configPath);
110
110
 
111
- const rawUrl = process.env.SURON_API_URL ?? config.api_url;
111
+ const rawUrl = process.env.SURON_API_URL ?? suronJson.api_url;
112
112
  if (!rawUrl) throw new SuronConfigError("SURON_API_URL not set. Run: suron login");
113
113
  const apiUrl = rawUrl.replace(/\/$/, "");
114
114
 
115
- const requestId = await requestAccess(apiUrl, config.id);
115
+ const requestId = await requestAccess(apiUrl, suronJson.id);
116
116
 
117
117
  await pollUntilApproved(apiUrl, requestId, timeout, pollInterval);
118
118
 
119
- const privateKey = await fetchKey(apiUrl, requestId);
119
+ let privateKey = await fetchKey(apiUrl, requestId);
120
120
  decryptEnv(privateKey, configPath);
121
+ privateKey = "";
121
122
  // Note: JS strings are immutable — there is no way to scrub the value from
122
123
  // heap memory. The reference is dropped here and will be GC'd normally.
123
124
  }