@softr/cli 0.1.0 → 0.1.1-se21216.6
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/cli.mjs +24 -6
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6098,9 +6098,9 @@ var SoftrApiError = class extends Error {
|
|
|
6098
6098
|
body;
|
|
6099
6099
|
hint;
|
|
6100
6100
|
};
|
|
6101
|
-
function hintFor(status) {
|
|
6101
|
+
function hintFor(status, client) {
|
|
6102
6102
|
if (status === 401 || status === 403) {
|
|
6103
|
-
return "The token was not accepted: revoked, from another environment, missing access to this workflow, or its statements do not grant this action. Run: softr login";
|
|
6103
|
+
return client.kind === "proxy" ? "The target refused the request: no access to this workflow, or its credential is gone." : "The token was not accepted: revoked, from another environment, missing access to this workflow, or its statements do not grant this action. Run: softr login";
|
|
6104
6104
|
}
|
|
6105
6105
|
if (status === 409) {
|
|
6106
6106
|
return "The workflow changed on the server since the last pull. Pull again with --force, then re-apply your edits.";
|
|
@@ -6108,7 +6108,7 @@ function hintFor(status) {
|
|
|
6108
6108
|
return void 0;
|
|
6109
6109
|
}
|
|
6110
6110
|
function authHeaders(client) {
|
|
6111
|
-
return { Authorization: `Bearer ${client.token}` };
|
|
6111
|
+
return client.kind === "proxy" ? {} : { Authorization: `Bearer ${client.token}` };
|
|
6112
6112
|
}
|
|
6113
6113
|
async function send(client, service, method, path13, body) {
|
|
6114
6114
|
const init = {
|
|
@@ -6129,7 +6129,7 @@ async function send(client, service, method, path13, body) {
|
|
|
6129
6129
|
`${method} ${path13} failed with status ${response.status}${text ? `: ${text}` : ""}`,
|
|
6130
6130
|
response.status,
|
|
6131
6131
|
text,
|
|
6132
|
-
hintFor(response.status)
|
|
6132
|
+
hintFor(response.status, client)
|
|
6133
6133
|
);
|
|
6134
6134
|
}
|
|
6135
6135
|
async function apiRequest(client, method, path13, body) {
|
|
@@ -14514,7 +14514,7 @@ function normalizeUrl(value, source) {
|
|
|
14514
14514
|
} catch {
|
|
14515
14515
|
throw new CliError(`${source} is not a valid URL: ${value}`);
|
|
14516
14516
|
}
|
|
14517
|
-
return url.origin
|
|
14517
|
+
return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
|
|
14518
14518
|
}
|
|
14519
14519
|
function resolveTarget(remembered) {
|
|
14520
14520
|
const pick = (envVar, rememberedValue, fallback) => {
|
|
@@ -14547,6 +14547,8 @@ function tokenKind(token) {
|
|
|
14547
14547
|
|
|
14548
14548
|
// src/config/credentials.ts
|
|
14549
14549
|
var TOKEN_ENV_VAR = "SOFTR_TOKEN";
|
|
14550
|
+
var AUTH_ENV_VAR = "SOFTR_AUTH";
|
|
14551
|
+
var PROXY_AUTH = "proxy";
|
|
14550
14552
|
var REFRESH_MARGIN_MS = 5 * 60 * 1e3;
|
|
14551
14553
|
function credentialsPath() {
|
|
14552
14554
|
return path6.join(homedir(), ".softr", "credentials.json");
|
|
@@ -14611,6 +14613,9 @@ async function refreshedAccessToken(target, stored) {
|
|
|
14611
14613
|
}
|
|
14612
14614
|
}
|
|
14613
14615
|
async function authenticatedClient(target) {
|
|
14616
|
+
if (process.env[AUTH_ENV_VAR] === PROXY_AUTH) {
|
|
14617
|
+
return { target, kind: "proxy" };
|
|
14618
|
+
}
|
|
14614
14619
|
const fromEnv = process.env[TOKEN_ENV_VAR];
|
|
14615
14620
|
if (fromEnv) {
|
|
14616
14621
|
return { target, token: fromEnv, kind: tokenKind(fromEnv) };
|
|
@@ -15542,6 +15547,11 @@ function registerLogin(program3) {
|
|
|
15542
15547
|
).option("--no-browser", "browser login, but print the URL instead of opening it (for remote shells and agents)").action(async (opts, command) => {
|
|
15543
15548
|
const options = globalOptions(command);
|
|
15544
15549
|
const target = resolveTarget();
|
|
15550
|
+
if (process.env[AUTH_ENV_VAR] === "proxy") {
|
|
15551
|
+
throw new CliError(
|
|
15552
|
+
`Login is not needed: the target authenticates the requests itself ($${AUTH_ENV_VAR}=proxy).`
|
|
15553
|
+
);
|
|
15554
|
+
}
|
|
15545
15555
|
const token = (opts.token ?? process.env[TOKEN_ENV_VAR] ?? "").trim();
|
|
15546
15556
|
const saved = token ? pastedToken(token) : opts.browser ? await interactiveLogin(target) : await browserLogin(target, true);
|
|
15547
15557
|
const identity = await identify({ target, token: saved.token, kind: saved.kind });
|
|
@@ -15561,6 +15571,14 @@ function registerLogin(program3) {
|
|
|
15561
15571
|
const options = globalOptions(command);
|
|
15562
15572
|
const target = resolveTarget();
|
|
15563
15573
|
const client = await authenticatedClient(target);
|
|
15574
|
+
if (client.kind === "proxy") {
|
|
15575
|
+
emit(
|
|
15576
|
+
options,
|
|
15577
|
+
`Requests to ${targetHost(target)} carry no token: the target authenticates them itself ($${AUTH_ENV_VAR}=proxy).`,
|
|
15578
|
+
{ kind: "proxy", host: targetHost(target) }
|
|
15579
|
+
);
|
|
15580
|
+
return;
|
|
15581
|
+
}
|
|
15564
15582
|
const identity = await identify(client);
|
|
15565
15583
|
const stored = process.env[TOKEN_ENV_VAR] ? void 0 : await storedToken(target);
|
|
15566
15584
|
const expiry = stored?.expiresAt ? ` Expires ${stored.expiresAt.slice(0, 16).replace("T", " ")} UTC.` : "";
|
|
@@ -16672,7 +16690,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
|
|
|
16672
16690
|
// package.json
|
|
16673
16691
|
var package_default = {
|
|
16674
16692
|
name: "@softr/cli",
|
|
16675
|
-
version: "0.1.
|
|
16693
|
+
version: "0.1.1-se21216.6",
|
|
16676
16694
|
description: "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
|
|
16677
16695
|
keywords: [
|
|
16678
16696
|
"softr",
|