@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 +1 -1
- package/src/poll.js +2 -5
- package/src/vault.js +5 -4
package/package.json
CHANGED
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 =
|
|
18
|
-
pollInterval =
|
|
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
|
|
109
|
+
const suronJson = readSuronJson(configPath);
|
|
110
110
|
|
|
111
|
-
const rawUrl = process.env.SURON_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,
|
|
115
|
+
const requestId = await requestAccess(apiUrl, suronJson.id);
|
|
116
116
|
|
|
117
117
|
await pollUntilApproved(apiUrl, requestId, timeout, pollInterval);
|
|
118
118
|
|
|
119
|
-
|
|
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
|
}
|