@suronai/sdk 0.1.17 → 0.1.18
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/index.d.ts +7 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/vault.js +19 -0
package/index.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export interface VaultOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
export function vault(options?: VaultOptions): Promise<void>;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Safe wrapper around vault(). Handles all known Suron errors with
|
|
18
|
+
* console.error + process.exit(1). Unknown errors are re-thrown.
|
|
19
|
+
* Must be awaited before any code that reads process.env.
|
|
20
|
+
*/
|
|
21
|
+
export function Suron(options?: VaultOptions): Promise<void>;
|
|
22
|
+
|
|
16
23
|
export class SuronError extends Error {}
|
|
17
24
|
export class SuronConfigError extends SuronError {}
|
|
18
25
|
export class SuronAppNotFoundError extends SuronError {}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/vault.js
CHANGED
|
@@ -121,3 +121,22 @@ export async function vault(options = {}) {
|
|
|
121
121
|
// Note: JS strings are immutable — there is no way to scrub the value from
|
|
122
122
|
// heap memory. The reference is dropped here and will be GC'd normally.
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Drop-in safe wrapper around vault().
|
|
127
|
+
* Handles all known Suron errors with a console.error + process.exit(1).
|
|
128
|
+
* Unknown errors are re-thrown so the caller still sees them.
|
|
129
|
+
* @param {VaultOptions} [options]
|
|
130
|
+
* @returns {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
export async function Suron(options = {}) {
|
|
133
|
+
try {
|
|
134
|
+
await vault(options);
|
|
135
|
+
} catch (err) {
|
|
136
|
+
if (err instanceof SuronDeniedError) { console.error("[suron] Boot denied."); process.exit(1); }
|
|
137
|
+
if (err instanceof SuronTimeoutError) { console.error("[suron] Approval timed out."); process.exit(1); }
|
|
138
|
+
if (err instanceof SuronConfigError) { console.error("[suron]", err.message); process.exit(1); }
|
|
139
|
+
if (err instanceof SuronAppNotFoundError) { console.error("[suron]", err.message); process.exit(1); }
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
}
|