@safetech/inheriti-cli 0.0.10-dev.0 → 0.0.11-dev.0
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/main.js +29 -21
- package/dist/main.js.map +4 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -49032,7 +49032,7 @@ var init_crypto = __esm({
|
|
|
49032
49032
|
}
|
|
49033
49033
|
});
|
|
49034
49034
|
|
|
49035
|
-
// ../../node_modules/.pnpm/@safetech+inheriti-client-sdk@1.17.
|
|
49035
|
+
// ../../node_modules/.pnpm/@safetech+inheriti-client-sdk@1.17.18_@tanstack+react-query@5.103.2_react@19.3.0__react_572aca652e6ee9c45ed1974fa2041406/node_modules/@safetech/inheriti-client-sdk/dist/node-base.js
|
|
49036
49036
|
var node_base_exports = {};
|
|
49037
49037
|
__export(node_base_exports, {
|
|
49038
49038
|
BusinessOrganizationSelectionError: () => te5,
|
|
@@ -49946,7 +49946,7 @@ function ta3(n12) {
|
|
|
49946
49946
|
}
|
|
49947
49947
|
var Re4, Ee5, Se5, M6, q5, $e4, oe5, de5, Ae5, h5, be5, _e4, He4, We4, I5, b5, le5, ce5, pe5, cr4, Qe4, A5, ur4, je4, Ye4, K6, xe5, Xe4, Y6, Je4, wr4, Ar4, St4, br4, _r4, Cr4, xr3, te5, N5, ne5, me5, Me5, Ur3, J5, ge5, S5, H5, he5, fe5, Ie5, Ke4, Ue4, Le4, qe4, Ge4, ze4, ve5, Pe4, v7, Yt4, Qr3, Ve4, jr4, Zt4, Jt4;
|
|
49948
49948
|
var init_node_base = __esm({
|
|
49949
|
-
"../../node_modules/.pnpm/@safetech+inheriti-client-sdk@1.17.
|
|
49949
|
+
"../../node_modules/.pnpm/@safetech+inheriti-client-sdk@1.17.18_@tanstack+react-query@5.103.2_react@19.3.0__react_572aca652e6ee9c45ed1974fa2041406/node_modules/@safetech/inheriti-client-sdk/dist/node-base.js"() {
|
|
49950
49950
|
init_node();
|
|
49951
49951
|
init_crypto();
|
|
49952
49952
|
init_node();
|
|
@@ -98655,7 +98655,7 @@ import { pathToFileURL } from "node:url";
|
|
|
98655
98655
|
// src/configuration.ts
|
|
98656
98656
|
init_dist();
|
|
98657
98657
|
init_node_base2();
|
|
98658
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
98658
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
98659
98659
|
import { homedir as homedir2 } from "node:os";
|
|
98660
98660
|
import { resolve as resolve2 } from "node:path";
|
|
98661
98661
|
var CliConfigurationInvalid = class extends Error {
|
|
@@ -98673,7 +98673,9 @@ function defaultConfigurationPath(environmentVariables) {
|
|
|
98673
98673
|
if (environmentVariables.INHERITI_ELEMENTS_CONFIG) return environmentVariables.INHERITI_ELEMENTS_CONFIG;
|
|
98674
98674
|
const home = environmentVariables.HOME ?? homedir2();
|
|
98675
98675
|
const base = environmentVariables.XDG_CONFIG_HOME ?? resolve2(home, ".config");
|
|
98676
|
-
|
|
98676
|
+
const current = resolve2(base, "inheriti", "config.json");
|
|
98677
|
+
const legacy = resolve2(base, "inheriti-elements", "config.json");
|
|
98678
|
+
return existsSync(current) || !existsSync(legacy) ? current : legacy;
|
|
98677
98679
|
}
|
|
98678
98680
|
var FILE_KEYS = {
|
|
98679
98681
|
apiUrl: "INHERITI_ELEMENTS_API_URL",
|
|
@@ -98806,6 +98808,7 @@ function required(environmentVariables, name, setting) {
|
|
|
98806
98808
|
|
|
98807
98809
|
// src/session-store.ts
|
|
98808
98810
|
import { chmod as chmod2, mkdir as mkdir3, readFile as readFile4, rm as rm4, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
|
|
98811
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
98809
98812
|
import { homedir as homedir3 } from "node:os";
|
|
98810
98813
|
import { dirname as dirname2, resolve as resolve4 } from "node:path";
|
|
98811
98814
|
|
|
@@ -98907,8 +98910,11 @@ var SessionStoreUnreadable = class extends Error {
|
|
|
98907
98910
|
code;
|
|
98908
98911
|
};
|
|
98909
98912
|
function defaultSessionPath(environmentVariables) {
|
|
98910
|
-
|
|
98911
|
-
|
|
98913
|
+
if (environmentVariables.INHERITI_ELEMENTS_STATE_DIR) return resolve4(environmentVariables.INHERITI_ELEMENTS_STATE_DIR, "session.json");
|
|
98914
|
+
const stateHome = environmentVariables.XDG_STATE_HOME ?? resolve4(homedir3(), ".local", "state");
|
|
98915
|
+
const current = resolve4(stateHome, "inheriti", "session.json");
|
|
98916
|
+
const legacy = resolve4(stateHome, "inheriti-elements", "session.json");
|
|
98917
|
+
return existsSync2(current) || !existsSync2(legacy) ? current : legacy;
|
|
98912
98918
|
}
|
|
98913
98919
|
var FileOperatorSessionStore = class {
|
|
98914
98920
|
constructor(path9, keys2) {
|
|
@@ -98921,8 +98927,9 @@ var FileOperatorSessionStore = class {
|
|
|
98921
98927
|
let raw;
|
|
98922
98928
|
try {
|
|
98923
98929
|
raw = await readFile4(this.path, "utf8");
|
|
98924
|
-
} catch {
|
|
98925
|
-
return void 0;
|
|
98930
|
+
} catch (error) {
|
|
98931
|
+
if (error.code === "ENOENT") return void 0;
|
|
98932
|
+
throw new SessionStoreUnreadable("session_file_unreadable");
|
|
98926
98933
|
}
|
|
98927
98934
|
if (!await this.isOwnerOnly()) {
|
|
98928
98935
|
await this.clear();
|
|
@@ -98951,7 +98958,8 @@ var FileOperatorSessionStore = class {
|
|
|
98951
98958
|
}
|
|
98952
98959
|
async isOwnerOnly() {
|
|
98953
98960
|
try {
|
|
98954
|
-
|
|
98961
|
+
const file2 = await stat2(this.path);
|
|
98962
|
+
return process.platform === "win32" || (file2.mode & 63) === 0;
|
|
98955
98963
|
} catch {
|
|
98956
98964
|
return false;
|
|
98957
98965
|
}
|
|
@@ -99152,6 +99160,7 @@ async function login(context, terminal) {
|
|
|
99152
99160
|
if (await context.sessions.load()) await context.keyVault?.clear();
|
|
99153
99161
|
const callbackUrl = await waitForCallback(context, terminal);
|
|
99154
99162
|
await context.core.auth.completeAuthorizationCode(callbackUrl);
|
|
99163
|
+
if (!await context.sessions.load()) throw new SessionStoreUnreadable("session_file_unreadable");
|
|
99155
99164
|
terminal.write("Signed in.");
|
|
99156
99165
|
return 0;
|
|
99157
99166
|
}
|
|
@@ -99161,6 +99170,7 @@ async function loginWithDevice(context, terminal) {
|
|
|
99161
99170
|
terminal.write(`Open ${started.verificationUri} and enter the code: ${started.userCode}`);
|
|
99162
99171
|
terminal.write("Waiting for approval\u2026");
|
|
99163
99172
|
await context.core.auth.pollDeviceAuthorization();
|
|
99173
|
+
if (!await context.sessions.load()) throw new SessionStoreUnreadable("session_file_unreadable");
|
|
99164
99174
|
terminal.write("Signed in.");
|
|
99165
99175
|
return 0;
|
|
99166
99176
|
}
|
|
@@ -99242,7 +99252,7 @@ function callbackPage(failure) {
|
|
|
99242
99252
|
const resources = new URL(import.meta.url.endsWith("/main.js") ? "./" : "../", import.meta.url);
|
|
99243
99253
|
const font = readFileSync4(new URL("assets/font-app.ttf", resources)).toString("base64");
|
|
99244
99254
|
const logo = readFileSync4(new URL("assets/tray.png", resources)).toString("base64");
|
|
99245
|
-
return readFileSync4(new URL("templates/login-callback.html", resources), "utf8").replace("{{font}}", font).replace("{{logo}}", logo).replaceAll("{{heading}}", signedIn ? "
|
|
99255
|
+
return readFileSync4(new URL("templates/login-callback.html", resources), "utf8").replace("{{font}}", font).replace("{{logo}}", logo).replaceAll("{{heading}}", signedIn ? "Return to your terminal" : "Sign-in failed").replace("{{statusLabel}}", signedIn ? "Finalizing sign-in" : "Sign-in error").replace("{{statusClass}}", signedIn ? "" : "failed").replace("{{message}}", signedIn ? "Sign-in is complete only when your terminal says Signed in." : escapeHtml(failure));
|
|
99246
99256
|
}
|
|
99247
99257
|
function escapeHtml(value2) {
|
|
99248
99258
|
return value2.replace(/[&<>"]/gu, (character) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[character] ?? character);
|
|
@@ -99252,9 +99262,9 @@ function openBrowser(url2, platform4 = process.platform) {
|
|
|
99252
99262
|
const command2 = platform4 === "darwin" ? "open" : platform4 === "win32" ? "powershell.exe" : "xdg-open";
|
|
99253
99263
|
const args = platform4 === "win32" ? ["-NoProfile", "-NonInteractive", "-Command", `Start-Process -FilePath '${url2.replaceAll("'", "''")}'`] : [url2];
|
|
99254
99264
|
try {
|
|
99255
|
-
const browser = spawn4(command2, args, { stdio: "ignore", detached: true });
|
|
99265
|
+
const browser = spawn4(command2, args, platform4 === "win32" ? { stdio: "ignore" } : { stdio: "ignore", detached: true });
|
|
99256
99266
|
browser.once("error", () => void 0);
|
|
99257
|
-
browser.unref();
|
|
99267
|
+
if (platform4 !== "win32") browser.unref();
|
|
99258
99268
|
} catch {
|
|
99259
99269
|
}
|
|
99260
99270
|
}
|
|
@@ -107985,7 +107995,7 @@ async function executeWithSecrets(options, values, signal) {
|
|
|
107985
107995
|
let privateDirectory;
|
|
107986
107996
|
const socketDeliveries = [];
|
|
107987
107997
|
if (options.tempFiles.length > 0 || options.sockets.length > 0) {
|
|
107988
|
-
privateDirectory = await mkdtemp3(join4(tmpdir2(), "inheriti-
|
|
107998
|
+
privateDirectory = await mkdtemp3(join4(tmpdir2(), "inheriti-use-"));
|
|
107989
107999
|
try {
|
|
107990
108000
|
if (process.platform !== "win32") await chmod3(privateDirectory, 448);
|
|
107991
108001
|
assertActive(signal);
|
|
@@ -108262,12 +108272,9 @@ function completionScript(shell) {
|
|
|
108262
108272
|
// src/completion/cache.ts
|
|
108263
108273
|
import { mkdirSync, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "node:fs";
|
|
108264
108274
|
import { dirname as dirname3, resolve as resolve5 } from "node:path";
|
|
108265
|
-
import { homedir as homedir4 } from "node:os";
|
|
108266
108275
|
var TTL_MS = 6e4;
|
|
108267
108276
|
function completionCachePath(environmentVariables) {
|
|
108268
|
-
|
|
108269
|
-
const base = environmentVariables.INHERITI_ELEMENTS_STATE_DIR ?? resolve5(environmentVariables.XDG_STATE_HOME ?? resolve5(home, ".local", "state"), "inheriti-elements");
|
|
108270
|
-
return resolve5(base, "completion-cache.json");
|
|
108277
|
+
return resolve5(dirname3(defaultSessionPath(environmentVariables)), "completion-cache.json");
|
|
108271
108278
|
}
|
|
108272
108279
|
async function cached(path9, key, produce, now = Date.now()) {
|
|
108273
108280
|
const file2 = read2(path9);
|
|
@@ -108500,7 +108507,7 @@ async function selectedOrganization(context, configuration, configurationPath, t
|
|
|
108500
108507
|
init_node_base2();
|
|
108501
108508
|
import { createHash as createHash3 } from "node:crypto";
|
|
108502
108509
|
import { mkdtemp as mkdtemp4, open as open2, rm as rm6, stat as stat3, writeFile as writeFile6 } from "node:fs/promises";
|
|
108503
|
-
import { existsSync as
|
|
108510
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
108504
108511
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
108505
108512
|
import { dirname as dirname5, isAbsolute as isAbsolute2, join as join5 } from "node:path";
|
|
108506
108513
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
@@ -108521,7 +108528,7 @@ async function notifyCliUpdate(context, terminal, version3, sessionPath) {
|
|
|
108521
108528
|
function npmCommand(file2) {
|
|
108522
108529
|
if (process.platform !== "win32") return { command: "npm", args: ["install", "--global", file2] };
|
|
108523
108530
|
const candidates2 = [process.env.npm_execpath, join5(dirname5(process.execPath), "node_modules", "npm", "bin", "npm-cli.js")];
|
|
108524
|
-
const script = candidates2.find((candidate) => candidate && isAbsolute2(candidate) && candidate.endsWith("npm-cli.js") &&
|
|
108531
|
+
const script = candidates2.find((candidate) => candidate && isAbsolute2(candidate) && candidate.endsWith("npm-cli.js") && existsSync4(candidate));
|
|
108525
108532
|
if (!script) throw new Error("npm-cli.js is unavailable. Install npm with Node.js and retry.");
|
|
108526
108533
|
return { command: process.execPath, args: [script, "install", "--global", file2] };
|
|
108527
108534
|
}
|
|
@@ -108619,7 +108626,7 @@ import { basename as basename2 } from "node:path";
|
|
|
108619
108626
|
|
|
108620
108627
|
// src/completion/install.ts
|
|
108621
108628
|
import { appendFile, lstat, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile7 } from "node:fs/promises";
|
|
108622
|
-
import { homedir as
|
|
108629
|
+
import { homedir as homedir4 } from "node:os";
|
|
108623
108630
|
import { dirname as dirname6, resolve as resolve7 } from "node:path";
|
|
108624
108631
|
var MARKER = "# inheriti shell completion";
|
|
108625
108632
|
async function exists(path9) {
|
|
@@ -108632,7 +108639,7 @@ async function exists(path9) {
|
|
|
108632
108639
|
}
|
|
108633
108640
|
}
|
|
108634
108641
|
async function completionInstallPath(shell, env4, platform4 = process.platform) {
|
|
108635
|
-
const home = env4.HOME ||
|
|
108642
|
+
const home = env4.HOME || homedir4();
|
|
108636
108643
|
if (shell === "fish") return resolve7(env4.XDG_CONFIG_HOME || resolve7(home, ".config"), "fish/completions/inheriti.fish");
|
|
108637
108644
|
if (shell === "zsh") return resolve7(env4.ZDOTDIR || home, ".zshrc");
|
|
108638
108645
|
if (platform4 === "darwin") {
|
|
@@ -109794,6 +109801,7 @@ var MESSAGES = {
|
|
|
109794
109801
|
elements_api_unavailable: "The plan service is unavailable. Try again shortly.",
|
|
109795
109802
|
plan_request_failed: "Could not reach the plan service.",
|
|
109796
109803
|
session_file_corrupt: "The stored session was unreadable and has been cleared. Sign in again.",
|
|
109804
|
+
session_file_unreadable: "The stored session could not be read. Check access to the CLI state folder, then retry.",
|
|
109797
109805
|
session_permissions_widened: "The stored session was readable by others and has been cleared. Sign in again.",
|
|
109798
109806
|
InteractiveTerminalRequired: "Signing in needs an interactive terminal.",
|
|
109799
109807
|
BrowserUnavailable: "Could not open a browser. Sign in with `inheriti login --device`.",
|