@seliseblocks/cli-os 0.1.2 → 0.1.4
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/AI_USAGE_GUIDE.md +18 -38
- package/README.md +13 -36
- package/dist/commands/auth/status.js +16 -55
- package/dist/commands/deselect.d.ts +1 -0
- package/dist/commands/deselect.js +31 -0
- package/dist/commands/doctor.js +3 -4
- package/dist/commands/init.js +4 -2
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +15 -55
- package/dist/commands/new/web.js +1 -1
- package/dist/commands/release/builds/list.js +4 -2
- package/dist/commands/release/deploy.js +5 -3
- package/dist/commands/release/status.js +4 -2
- package/dist/index.js +32 -60
- package/dist/lib/auth.d.ts +4 -11
- package/dist/lib/auth.js +43 -18
- package/dist/lib/config.d.ts +1 -2
- package/dist/lib/config.js +45 -13
- package/dist/lib/open-browser.js +26 -3
- package/dist/lib/secret-store.d.ts +0 -1
- package/dist/lib/secret-store.js +1 -4
- package/dist/lib/token-store.d.ts +0 -1
- package/dist/lib/token-store.js +1 -5
- package/dist/lib/token.d.ts +0 -1
- package/dist/lib/token.js +0 -4
- package/dist/lib/workspace.d.ts +1 -0
- package/dist/lib/workspace.js +17 -0
- package/package.json +1 -1
- package/dist/commands/auth/add.d.ts +0 -1
- package/dist/commands/auth/add.js +0 -51
- package/dist/commands/auth/list.d.ts +0 -1
- package/dist/commands/auth/list.js +0 -33
- package/dist/commands/auth/repair.d.ts +0 -1
- package/dist/commands/auth/repair.js +0 -39
- package/dist/commands/auth/show.d.ts +0 -1
- package/dist/commands/auth/show.js +0 -23
- package/dist/commands/auth/use.d.ts +0 -1
- package/dist/commands/auth/use.js +0 -15
- package/dist/commands/login-device.d.ts +0 -1
- package/dist/commands/login-device.js +0 -6
- package/dist/lib/login-server.d.ts +0 -1
- package/dist/lib/login-server.js +0 -43
- package/dist/lib/pkce.d.ts +0 -4
- package/dist/lib/pkce.js +0 -9
- package/dist/lib/prompt.d.ts +0 -2
- package/dist/lib/prompt.js +0 -36
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { parseFlags } from "../../lib/args.js";
|
|
2
|
-
import { readConfig } from "../../lib/config.js";
|
|
3
|
-
import { writeOutput } from "../../lib/output.js";
|
|
4
|
-
export async function authList(argv = []) {
|
|
5
|
-
const { flags } = parseFlags(argv);
|
|
6
|
-
const config = await readConfig();
|
|
7
|
-
const names = Object.keys(config.accounts);
|
|
8
|
-
if (names.length === 0) {
|
|
9
|
-
if (flags.json) {
|
|
10
|
-
writeOutput({ activeAccount: config.activeAccount ?? null, accounts: [] }, flags);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
console.log("No OIDC accounts configured.");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (flags.json) {
|
|
17
|
-
writeOutput({
|
|
18
|
-
activeAccount: config.activeAccount ?? null,
|
|
19
|
-
accounts: names.map((name) => ({
|
|
20
|
-
name,
|
|
21
|
-
active: config.activeAccount === name,
|
|
22
|
-
apiUrl: config.accounts[name].apiUrl,
|
|
23
|
-
oidcUrl: config.accounts[name].oidcUrl
|
|
24
|
-
}))
|
|
25
|
-
}, flags);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
for (const name of names) {
|
|
29
|
-
const profile = config.accounts[name];
|
|
30
|
-
const active = config.activeAccount === name ? "*" : " ";
|
|
31
|
-
console.log(`${active} ${name} ${profile.apiUrl} ${profile.oidcUrl}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function authRepair(argv: string[]): Promise<void>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { booleanFlag, parseFlags } from "../../lib/args.js";
|
|
2
|
-
import { confirmMutation } from "../../lib/confirm.js";
|
|
3
|
-
import { getAccountProfile, normalizeAccountName, readConfig } from "../../lib/config.js";
|
|
4
|
-
import { writeOutput } from "../../lib/output.js";
|
|
5
|
-
import { removeAccountSecrets } from "../../lib/secret-store.js";
|
|
6
|
-
import { clearTokenStore } from "../../lib/token-store.js";
|
|
7
|
-
export async function authRepair(argv) {
|
|
8
|
-
const { args, flags } = parseFlags(argv);
|
|
9
|
-
const config = await readConfig();
|
|
10
|
-
const account = args[0] ? normalizeAccountName(args[0]) : getAccountProfile(config).name;
|
|
11
|
-
if (!config.accounts[account]) {
|
|
12
|
-
throw new Error(`OIDC account '${account}' is not configured.`);
|
|
13
|
-
}
|
|
14
|
-
const result = {
|
|
15
|
-
account,
|
|
16
|
-
clearedClientSecret: true,
|
|
17
|
-
clearedTokenCache: "all accounts",
|
|
18
|
-
nextSteps: [
|
|
19
|
-
["blocks-os auth:add", account === "default" ? "" : account, "--client-id <id>", "--client-secret <secret>"].filter(Boolean).join(" "),
|
|
20
|
-
`blocks-os login${account === "default" ? "" : ` --account ${account}`}`
|
|
21
|
-
]
|
|
22
|
-
};
|
|
23
|
-
if (booleanFlag(flags, "dry-run")) {
|
|
24
|
-
writeOutput({ dryRun: true, ...result }, flags);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
await confirmMutation(flags, `Repair local auth state for '${account}'. This clears the account client secret and all cached OAuth tokens, but keeps account profile config.`);
|
|
28
|
-
await removeAccountSecrets(account);
|
|
29
|
-
await clearTokenStore();
|
|
30
|
-
if (flags.json) {
|
|
31
|
-
writeOutput(result, flags);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
console.log(`Repaired local auth state for '${account}'.`);
|
|
35
|
-
console.log("Client secret and cached OAuth tokens were cleared.");
|
|
36
|
-
console.log("Next:");
|
|
37
|
-
for (const step of result.nextSteps)
|
|
38
|
-
console.log(` ${step}`);
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function authShow(argv: string[]): Promise<void>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { parseFlags, stringFlag } from "../../lib/args.js";
|
|
2
|
-
import { getAccountProfile, readConfig } from "../../lib/config.js";
|
|
3
|
-
import { getClientSecret, secretStoreInfo } from "../../lib/secret-store.js";
|
|
4
|
-
export async function authShow(argv) {
|
|
5
|
-
const { args, flags } = parseFlags(argv);
|
|
6
|
-
const config = await readConfig();
|
|
7
|
-
const account = args[0] || stringFlag(flags, "account") || config.activeAccount;
|
|
8
|
-
const { name, profile } = getAccountProfile(config, account);
|
|
9
|
-
const secretInfo = await secretStoreInfo();
|
|
10
|
-
console.log(JSON.stringify({
|
|
11
|
-
account: name,
|
|
12
|
-
active: config.activeAccount === name,
|
|
13
|
-
apiUrl: profile.apiUrl,
|
|
14
|
-
clientId: profile.clientId,
|
|
15
|
-
clientSecret: await getClientSecret(name) ? "configured" : "missing",
|
|
16
|
-
secretStorage: secretInfo,
|
|
17
|
-
oidcUrl: profile.oidcUrl,
|
|
18
|
-
osUrl: profile.osUrl,
|
|
19
|
-
redirectUri: profile.redirectUri,
|
|
20
|
-
rootTenantId: profile.rootTenantId,
|
|
21
|
-
scope: profile.scope
|
|
22
|
-
}, null, 2));
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function authUse(argv: string[]): Promise<void>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { parseFlags } from "../../lib/args.js";
|
|
2
|
-
import { normalizeAccountName, readConfig, writeConfig } from "../../lib/config.js";
|
|
3
|
-
export async function authUse(argv) {
|
|
4
|
-
const { args } = parseFlags(argv);
|
|
5
|
-
const account = normalizeAccountName(args[0]);
|
|
6
|
-
const config = await readConfig();
|
|
7
|
-
if (!config.accounts[account]) {
|
|
8
|
-
throw new Error("OIDC account is not configured. Run 'blocks-os auth:add --client-id <id> --client-secret <secret>' first.");
|
|
9
|
-
}
|
|
10
|
-
await writeConfig({
|
|
11
|
-
...config,
|
|
12
|
-
activeAccount: account
|
|
13
|
-
});
|
|
14
|
-
console.log(`Active account is now '${account}'.`);
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function loginDevice(argv: string[]): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function waitForAuthorizationCode(port: number, expectedState?: string): Promise<string>;
|
package/dist/lib/login-server.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createServer } from "node:http";
|
|
2
|
-
export async function waitForAuthorizationCode(port, expectedState) {
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
const server = createServer((request, response) => {
|
|
5
|
-
const url = new URL(request.url ?? "/", `http://127.0.0.1:${port}`);
|
|
6
|
-
if (url.pathname !== "/callback") {
|
|
7
|
-
response.writeHead(404);
|
|
8
|
-
response.end("Not found");
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const error = url.searchParams.get("error");
|
|
12
|
-
const code = url.searchParams.get("code");
|
|
13
|
-
const state = url.searchParams.get("state");
|
|
14
|
-
if (error) {
|
|
15
|
-
response.writeHead(400, { "Content-Type": "text/plain" });
|
|
16
|
-
response.end(`Blocks OS login failed: ${error}`);
|
|
17
|
-
server.close();
|
|
18
|
-
reject(new Error(error));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (expectedState && state !== expectedState) {
|
|
22
|
-
response.writeHead(400, { "Content-Type": "text/plain" });
|
|
23
|
-
response.end("Blocks OS login failed: invalid state");
|
|
24
|
-
server.close();
|
|
25
|
-
reject(new Error("Invalid authorization state"));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (!code) {
|
|
29
|
-
response.writeHead(400, { "Content-Type": "text/plain" });
|
|
30
|
-
response.end("Blocks OS login failed: missing code");
|
|
31
|
-
server.close();
|
|
32
|
-
reject(new Error("Missing authorization code"));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
response.writeHead(200, { "Content-Type": "text/plain" });
|
|
36
|
-
response.end("Blocks OS login complete. You can close this tab.");
|
|
37
|
-
server.close();
|
|
38
|
-
resolve(code);
|
|
39
|
-
});
|
|
40
|
-
server.on("error", reject);
|
|
41
|
-
server.listen(port, "127.0.0.1");
|
|
42
|
-
});
|
|
43
|
-
}
|
package/dist/lib/pkce.d.ts
DELETED
package/dist/lib/pkce.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
-
function base64Url(input) {
|
|
3
|
-
return input.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
4
|
-
}
|
|
5
|
-
export function createPkcePair() {
|
|
6
|
-
const verifier = base64Url(randomBytes(32));
|
|
7
|
-
const challenge = base64Url(createHash("sha256").update(verifier).digest());
|
|
8
|
-
return { challenge, verifier };
|
|
9
|
-
}
|
package/dist/lib/prompt.d.ts
DELETED
package/dist/lib/prompt.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "node:readline";
|
|
2
|
-
import { createInterface as createPromiseInterface } from "node:readline/promises";
|
|
3
|
-
import { stdin as input, stdout as output } from "node:process";
|
|
4
|
-
export async function promptValue(label, defaultValue) {
|
|
5
|
-
const rl = createPromiseInterface({ input, output });
|
|
6
|
-
try {
|
|
7
|
-
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
8
|
-
const answer = await rl.question(`${label}${suffix}: `);
|
|
9
|
-
return answer.trim() || defaultValue || "";
|
|
10
|
-
}
|
|
11
|
-
finally {
|
|
12
|
-
rl.close();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export async function promptSecret(label, defaultValue) {
|
|
16
|
-
if (!input.isTTY || !output.isTTY)
|
|
17
|
-
return promptValue(label, defaultValue);
|
|
18
|
-
return new Promise((resolve) => {
|
|
19
|
-
const rl = createInterface({ input, output, terminal: true });
|
|
20
|
-
const muted = rl;
|
|
21
|
-
muted._writeToOutput = (value) => {
|
|
22
|
-
if (value === "\r\n" || value === "\n" || value === "\r") {
|
|
23
|
-
output.write(value);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
output.write("*".repeat(value.length));
|
|
27
|
-
};
|
|
28
|
-
const suffix = defaultValue ? " (configured, press Enter to keep)" : "";
|
|
29
|
-
output.write(`${label}${suffix}: `);
|
|
30
|
-
rl.question("", (answer) => {
|
|
31
|
-
rl.close();
|
|
32
|
-
output.write("\n");
|
|
33
|
-
resolve(answer.trim() || defaultValue || "");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|