@cimplify/cli 0.3.0 → 0.4.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/{add-ZJNXWN2B.mjs → add-KKIYBATR.mjs} +3 -3
- package/dist/{assets-DMK2QOPD.mjs → assets-EBEMMENZ.mjs} +3 -3
- package/dist/auth-step-up-BIUYQJP6.mjs +82 -0
- package/dist/chunk-42PFJBC6.mjs +5707 -0
- package/dist/{chunk-YQVMG62Z.mjs → chunk-ASZVWVMM.mjs} +1 -1
- package/dist/{chunk-YI7UMMM7.mjs → chunk-DBZ3UOQ2.mjs} +1 -1
- package/dist/{chunk-I3XQSSOT.mjs → chunk-E2T2SBP5.mjs} +6 -2
- package/dist/{login-WSAW4BEA.mjs → chunk-GLXONXS3.mjs} +10 -132
- package/dist/{chunk-RZQTHTXX.mjs → chunk-ITAFAORS.mjs} +1 -1
- package/dist/{chunk-RRY3NEZZ.mjs → chunk-K5464A3L.mjs} +1 -1
- package/dist/{chunk-D7WMSGKK.mjs → chunk-MAOO6ZZ5.mjs} +22 -3
- package/dist/{chunk-QGBXGDA5.mjs → chunk-R3FDBXR6.mjs} +4 -4
- package/dist/{chunk-5IAYN7AJ.mjs → chunk-SDSOORT6.mjs} +5 -5
- package/dist/{chunk-LS2VTSMQ.mjs → chunk-UBAI443T.mjs} +9 -2
- package/dist/{chunk-MOZQODQS.mjs → chunk-VTR5R5NQ.mjs} +1 -1
- package/dist/{deploy-UKOOPJAE.mjs → deploy-3IFXUWPM.mjs} +7 -7
- package/dist/{dev-FD4PM3UD.mjs → dev-ONW2S77K.mjs} +4 -4
- package/dist/dispatcher.mjs +39 -26
- package/dist/{doctor-5LBLYT7M.mjs → doctor-BC6CMVRW.mjs} +8 -8
- package/dist/{domains-JQMV6GAP.mjs → domains-AHH56CL7.mjs} +4 -4
- package/dist/{env-EVMYQUIK.mjs → env-7ISJ73YI.mjs} +5 -5
- package/dist/{explain-3KBMWL6M.mjs → explain-MZOCDFZE.mjs} +2 -2
- package/dist/introspect-IVI65FEV.mjs +8 -0
- package/dist/{link-X3E4UZBF.mjs → link-DZSILT5N.mjs} +3 -3
- package/dist/{list-TE54SJIB.mjs → list-JOQRPYX4.mjs} +2 -2
- package/dist/login-3OD4ND2H.mjs +153 -0
- package/dist/{logout-DJDINVDF.mjs → logout-3RLBZ33M.mjs} +2 -2
- package/dist/{logs-KUKGEXR2.mjs → logs-YNN2PQ24.mjs} +3 -3
- package/dist/{projects-364HGWHO.mjs → projects-JSEC2YCX.mjs} +3 -3
- package/dist/repo-WOBWKEAO.mjs +8 -0
- package/dist/{rollback-5YALPQXL.mjs → rollback-DD4RNRFM.mjs} +4 -4
- package/dist/{status-W4HW3CX3.mjs → status-JSYXM5RT.mjs} +3 -3
- package/dist/{unlink-HIIW57OO.mjs → unlink-RFK74SFP.mjs} +2 -2
- package/dist/{update-5MRKRVZC.mjs → update-EDTG73FK.mjs} +3 -3
- package/dist/{whoami-LACWBSNL.mjs → whoami-DNZ7RUTH.mjs} +3 -3
- package/package.json +1 -1
- package/dist/chunk-MHK4WVNF.mjs +0 -5707
- package/dist/introspect-PFBI3JHO.mjs +0 -8
- package/dist/repo-26N2CHF6.mjs +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { REGISTRY_INDEX, REGISTRY } from './chunk-
|
|
3
|
-
import { promptYesNo } from './chunk-
|
|
2
|
+
import { REGISTRY_INDEX, REGISTRY } from './chunk-42PFJBC6.mjs';
|
|
3
|
+
import { promptYesNo } from './chunk-ITAFAORS.mjs';
|
|
4
4
|
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
5
|
-
import { CliError, CLI_ERROR_CODE, info, bold, dim, success, result, yellow } from './chunk-
|
|
5
|
+
import { CliError, CLI_ERROR_CODE, info, bold, dim, success, result, yellow } from './chunk-E2T2SBP5.mjs';
|
|
6
6
|
import { mkdirSync, existsSync, writeFileSync } from 'fs';
|
|
7
7
|
import { resolve, join, dirname } from 'path';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
3
|
-
import { ApiClient } from './chunk-
|
|
4
|
-
import { readAuth } from './chunk-
|
|
5
|
-
import { CliError, CLI_ERROR_CODE, step, yellow, dim, success, info, result, bold, green } from './chunk-
|
|
3
|
+
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
4
|
+
import { readAuth } from './chunk-UBAI443T.mjs';
|
|
5
|
+
import { CliError, CLI_ERROR_CODE, step, yellow, dim, success, info, result, bold, green } from './chunk-E2T2SBP5.mjs';
|
|
6
6
|
import { createHash } from 'crypto';
|
|
7
7
|
import { promises } from 'fs';
|
|
8
8
|
import path from 'path';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { startLoopbackServer, generateState, openBrowser } from './chunk-GLXONXS3.mjs';
|
|
3
|
+
import { parseArgs, flagString, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
4
|
+
import { resolveBaseUrl } from './chunk-MAOO6ZZ5.mjs';
|
|
5
|
+
import { readAuth, writeStepUp } from './chunk-UBAI443T.mjs';
|
|
6
|
+
import { isJsonMode, CliError, CLI_ERROR_CODE, step, info, dim, success, result } from './chunk-E2T2SBP5.mjs';
|
|
7
|
+
|
|
8
|
+
// src/commands/auth-step-up.ts
|
|
9
|
+
var FLAG_NO_BROWSER = "no-browser";
|
|
10
|
+
var FLAG_BASE_URL = "base-url";
|
|
11
|
+
var STEP_UP_PATH = "/cli/step-up";
|
|
12
|
+
var STEP_UP_JWT_TTL_MS = 5 * 6e4;
|
|
13
|
+
var CALLBACK_TIMEOUT_MS = 10 * 6e4;
|
|
14
|
+
async function run(argv) {
|
|
15
|
+
if (isJsonMode()) {
|
|
16
|
+
throw new CliError(
|
|
17
|
+
CLI_ERROR_CODE.INTERACTIVE_REQUIRED,
|
|
18
|
+
"step-up needs an interactive browser; --json mode is unsupported.",
|
|
19
|
+
{ remediation: "Run from a terminal with a browser available." }
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const args = parseArgs(argv);
|
|
23
|
+
const baseUrl = resolveBaseUrl(flagString(args, FLAG_BASE_URL));
|
|
24
|
+
const auth = await readAuth();
|
|
25
|
+
const dashboardUrl = deriveDashboardUrl(baseUrl);
|
|
26
|
+
const loopback = await startLoopbackServer(baseUrl);
|
|
27
|
+
const state = generateState();
|
|
28
|
+
const requestId = generateState();
|
|
29
|
+
const url = new URL(`${dashboardUrl}${STEP_UP_PATH}`);
|
|
30
|
+
url.searchParams.set("request_id", requestId);
|
|
31
|
+
url.searchParams.set("redirect_uri", loopback.redirectUri);
|
|
32
|
+
url.searchParams.set("state", state);
|
|
33
|
+
step("Opening browser for fresh-auth...");
|
|
34
|
+
info(dim(url.toString()));
|
|
35
|
+
if (!flagBool(args, FLAG_NO_BROWSER)) {
|
|
36
|
+
openBrowser(url.toString());
|
|
37
|
+
} else {
|
|
38
|
+
info("");
|
|
39
|
+
info(dim("Open the URL above in any browser to continue."));
|
|
40
|
+
}
|
|
41
|
+
let callback;
|
|
42
|
+
try {
|
|
43
|
+
callback = await loopback.awaitCallback(CALLBACK_TIMEOUT_MS);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
loopback.close();
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
if (callback.state !== state) {
|
|
49
|
+
throw new CliError(
|
|
50
|
+
CLI_ERROR_CODE.UNAUTHORIZED,
|
|
51
|
+
"Step-up state mismatch. Possible CSRF attempt \u2014 try again."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (!callback.step_up_token) {
|
|
55
|
+
throw new CliError(
|
|
56
|
+
CLI_ERROR_CODE.UNAUTHORIZED,
|
|
57
|
+
"Step-up callback missing step_up_token."
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const token = {
|
|
61
|
+
token: callback.step_up_token,
|
|
62
|
+
expiresAt: Date.now() + STEP_UP_JWT_TTL_MS,
|
|
63
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
64
|
+
};
|
|
65
|
+
await writeStepUp(token);
|
|
66
|
+
success(
|
|
67
|
+
`Step-up complete. Re-run your destructive command within ${Math.round(STEP_UP_JWT_TTL_MS / 6e4)} minutes.`
|
|
68
|
+
);
|
|
69
|
+
result({
|
|
70
|
+
step_up_active: true,
|
|
71
|
+
expires_at: new Date(token.expiresAt).toISOString(),
|
|
72
|
+
account: { id: auth.accountId }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function deriveDashboardUrl(apiBaseUrl) {
|
|
76
|
+
return apiBaseUrl.replace(
|
|
77
|
+
/^https?:\/\/api\./,
|
|
78
|
+
(m) => m.replace("api.", "app.")
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { run as default };
|