@limetry/cli 1.2.55 → 1.2.58
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/commands/auth/login.d.ts +27 -0
- package/dist/commands/auth/login.d.ts.map +1 -0
- package/dist/commands/auth/login.js +66 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/governance/index.d.ts +97 -0
- package/dist/commands/governance/index.d.ts.map +1 -0
- package/dist/commands/governance/index.js +286 -0
- package/dist/commands/governance/index.js.map +1 -0
- package/dist/commands/setup/index.d.ts +23 -0
- package/dist/commands/setup/index.d.ts.map +1 -0
- package/dist/commands/setup/index.js +114 -0
- package/dist/commands/setup/index.js.map +1 -0
- package/dist/commands/token/create.d.ts +34 -0
- package/dist/commands/token/create.d.ts.map +1 -0
- package/dist/commands/token/create.js +74 -0
- package/dist/commands/token/create.js.map +1 -0
- package/dist/commands/token/list.d.ts +13 -0
- package/dist/commands/token/list.d.ts.map +1 -0
- package/dist/commands/token/list.js +53 -0
- package/dist/commands/token/list.js.map +1 -0
- package/dist/commands/token/revoke.d.ts +14 -0
- package/dist/commands/token/revoke.d.ts.map +1 -0
- package/dist/commands/token/revoke.js +48 -0
- package/dist/commands/token/revoke.js.map +1 -0
- package/dist/commands/token/scope.d.ts +16 -0
- package/dist/commands/token/scope.d.ts.map +1 -0
- package/dist/commands/token/scope.js +35 -0
- package/dist/commands/token/scope.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/config.d.ts +92 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +119 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/errors.d.ts +44 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +143 -0
- package/dist/utils/errors.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token create` — creates an access token via the Limetry API.
|
|
3
|
+
*
|
|
4
|
+
* Options: `--name`, `--scopes`, `--expires`. Missing name/scopes are prompted interactively.
|
|
5
|
+
*
|
|
6
|
+
* Side effects: `POST {baseUrl}/v1/tokens` with Bearer `apiKey`; prints the one-time token
|
|
7
|
+
* secret; may `process.exit(1)`. Requires prior `limetry login` / config via {@link requireAuth}.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Commander options for `limetry token create`.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateTokenOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Token display name; prompted when omitted.
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Scope strings; checkbox-prompted when empty.
|
|
19
|
+
*/
|
|
20
|
+
scopes?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Expiration date parseable by `Date`; stored as ISO `expiresAt` or null.
|
|
23
|
+
*/
|
|
24
|
+
expires?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new access token and prints the secret once.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Name, scopes, and optional expiration from CLI flags.
|
|
30
|
+
* @returns Resolves when the token is created and printed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function tokenCreateCommand(options: CreateTokenOptions): Promise<void>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/token/create.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;GAEG;AACH,UAAU,kBAAkB;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DnF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token create` — creates an access token via the Limetry API.
|
|
3
|
+
*
|
|
4
|
+
* Options: `--name`, `--scopes`, `--expires`. Missing name/scopes are prompted interactively.
|
|
5
|
+
*
|
|
6
|
+
* Side effects: `POST {baseUrl}/v1/tokens` with Bearer `apiKey`; prints the one-time token
|
|
7
|
+
* secret; may `process.exit(1)`. Requires prior `limetry login` / config via {@link requireAuth}.
|
|
8
|
+
*/
|
|
9
|
+
import inquirer from "inquirer";
|
|
10
|
+
import fetch from "node-fetch";
|
|
11
|
+
import { logError, logInfo, logSuccess, requireAuth } from "../../utils/config.js";
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new access token and prints the secret once.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Name, scopes, and optional expiration from CLI flags.
|
|
16
|
+
* @returns Resolves when the token is created and printed.
|
|
17
|
+
*/
|
|
18
|
+
export async function tokenCreateCommand(options) {
|
|
19
|
+
const config = requireAuth();
|
|
20
|
+
let name = options.name;
|
|
21
|
+
let scopes = options.scopes || [];
|
|
22
|
+
if (!name) {
|
|
23
|
+
const answers = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: "input",
|
|
26
|
+
name: "name",
|
|
27
|
+
message: "Token name:",
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
name = answers.name;
|
|
31
|
+
}
|
|
32
|
+
if (scopes.length === 0) {
|
|
33
|
+
const answers = await inquirer.prompt([
|
|
34
|
+
{
|
|
35
|
+
type: "checkbox",
|
|
36
|
+
name: "scopes",
|
|
37
|
+
message: "Select scopes:",
|
|
38
|
+
choices: ["read:rules", "write:rules", "read:tokens", "write:tokens"],
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
scopes = answers.scopes;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
logInfo("Creating access token...");
|
|
45
|
+
const response = await fetch(`${config.baseUrl}/v1/tokens`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
name,
|
|
53
|
+
scopes,
|
|
54
|
+
expiresAt: options.expires ? new Date(options.expires).toISOString() : null,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
const error = (await response.json());
|
|
59
|
+
throw new Error(String(error.message || "Failed to create token"));
|
|
60
|
+
}
|
|
61
|
+
const data = (await response.json());
|
|
62
|
+
console.log("\n" + "=".repeat(60));
|
|
63
|
+
logSuccess("Access token created");
|
|
64
|
+
console.log(`ID: ${data.id}`);
|
|
65
|
+
console.log(`Token: ${data.token}`);
|
|
66
|
+
console.log("=".repeat(60));
|
|
67
|
+
logInfo("Save this token securely. You won't be able to see it again.");
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
logError(error instanceof Error ? error.message : "Failed to create token");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/token/create.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAoBlF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA2B;IAClE,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAE5B,IA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ACjB,MAAM,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA4B,CAAA;YAChE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,wBAAwB,CAAC,CAAC,CAAA;QACpE,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAkC,CAAA;QAErE,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;QAClC,UAAU,CAAC,sBAAsB,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QAChC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3B,OAAO,CAAC,8DAA8D,CAAC,CAAA;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAA;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token list` — lists access tokens for the authenticated API key.
|
|
3
|
+
*
|
|
4
|
+
* Side effects: `GET {baseUrl}/v1/tokens`; prints token metadata to stdout;
|
|
5
|
+
* may `process.exit(1)`. Requires config via {@link requireAuth}.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Fetches and prints all access tokens for the current API key.
|
|
9
|
+
*
|
|
10
|
+
* @returns Resolves when listing completes (including empty list).
|
|
11
|
+
*/
|
|
12
|
+
export declare function tokenListCommand(): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/token/list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmDtD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token list` — lists access tokens for the authenticated API key.
|
|
3
|
+
*
|
|
4
|
+
* Side effects: `GET {baseUrl}/v1/tokens`; prints token metadata to stdout;
|
|
5
|
+
* may `process.exit(1)`. Requires config via {@link requireAuth}.
|
|
6
|
+
*/
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import fetch from "node-fetch";
|
|
9
|
+
import { logError, logInfo, requireAuth } from "../../utils/config.js";
|
|
10
|
+
/**
|
|
11
|
+
* Fetches and prints all access tokens for the current API key.
|
|
12
|
+
*
|
|
13
|
+
* @returns Resolves when listing completes (including empty list).
|
|
14
|
+
*/
|
|
15
|
+
export async function tokenListCommand() {
|
|
16
|
+
const config = requireAuth();
|
|
17
|
+
try {
|
|
18
|
+
logInfo("Fetching access tokens...");
|
|
19
|
+
const response = await fetch(`${config.baseUrl}/v1/tokens`, {
|
|
20
|
+
method: "GET",
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error("Failed to fetch tokens");
|
|
27
|
+
}
|
|
28
|
+
const data = (await response.json());
|
|
29
|
+
if (data.length === 0) {
|
|
30
|
+
logInfo("No access tokens found");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log("\n" + chalk.bold("Access Tokens:"));
|
|
34
|
+
console.log("=".repeat(80));
|
|
35
|
+
data.forEach((token, idx) => {
|
|
36
|
+
const expires = token.expiresAt
|
|
37
|
+
? new Date(token.expiresAt).toLocaleDateString()
|
|
38
|
+
: "Never";
|
|
39
|
+
console.log(`${idx + 1}. ${chalk.green("●")} ${token.name}`);
|
|
40
|
+
console.log(` ID: ${token.id}`);
|
|
41
|
+
console.log(` Token: ${token.token}`);
|
|
42
|
+
console.log(` Scopes: ${token.scopes.join(", ")}`);
|
|
43
|
+
console.log(` Created: ${new Date(token.createdAt).toLocaleDateString()}`);
|
|
44
|
+
console.log(` Expires: ${expires}`);
|
|
45
|
+
console.log("");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logError(error instanceof Error ? error.message : "Failed to fetch tokens");
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/token/list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEtE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAE5B,IAAI,CAAC;QACH,OAAO,CAAC,2BAA2B,CAAC,CAAA;QAEpC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,YAAY,EAAE;YAC1D,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE;aACzC;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC3C,CAAC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;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAA;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token revoke` — deletes an access token after interactive confirmation.
|
|
3
|
+
*
|
|
4
|
+
* Side effects: prompts for confirmation; `DELETE {baseUrl}/v1/tokens/{tokenId}`;
|
|
5
|
+
* may `process.exit(1)`. Requires config via {@link requireAuth}.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Revokes the given access token after the user confirms.
|
|
9
|
+
*
|
|
10
|
+
* @param tokenId - Token id argument from `limetry token revoke <tokenId>`.
|
|
11
|
+
* @returns Resolves when revoked or the user cancels.
|
|
12
|
+
*/
|
|
13
|
+
export declare function tokenRevokeCommand(tokenId: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=revoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../../src/commands/token/revoke.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCvE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token revoke` — deletes an access token after interactive confirmation.
|
|
3
|
+
*
|
|
4
|
+
* Side effects: prompts for confirmation; `DELETE {baseUrl}/v1/tokens/{tokenId}`;
|
|
5
|
+
* may `process.exit(1)`. Requires config via {@link requireAuth}.
|
|
6
|
+
*/
|
|
7
|
+
import inquirer from "inquirer";
|
|
8
|
+
import fetch from "node-fetch";
|
|
9
|
+
import { logError, logInfo, logSuccess, requireAuth } from "../../utils/config.js";
|
|
10
|
+
/**
|
|
11
|
+
* Revokes the given access token after the user confirms.
|
|
12
|
+
*
|
|
13
|
+
* @param tokenId - Token id argument from `limetry token revoke <tokenId>`.
|
|
14
|
+
* @returns Resolves when revoked or the user cancels.
|
|
15
|
+
*/
|
|
16
|
+
export async function tokenRevokeCommand(tokenId) {
|
|
17
|
+
const config = requireAuth();
|
|
18
|
+
const answers = await inquirer.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: "confirm",
|
|
21
|
+
name: "confirm",
|
|
22
|
+
message: `Are you sure you want to revoke token ${tokenId}?`,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
if (!answers.confirm) {
|
|
27
|
+
logInfo("Cancelled");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
logInfo("Revoking token...");
|
|
32
|
+
const response = await fetch(`${config.baseUrl}/v1/tokens/${tokenId}`, {
|
|
33
|
+
method: "DELETE",
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new Error("Failed to revoke token");
|
|
40
|
+
}
|
|
41
|
+
logSuccess("Token revoked");
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
logError(error instanceof Error ? error.message : "Failed to revoke token");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=revoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../../src/commands/token/revoke.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAElF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAe;IACtD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAE5B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACpC;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,yCAAyC,OAAO,GAAG;YAC5D,OAAO,EAAE,KAAK;SACf;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,CAAC,WAAW,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IAED,IAAI,CAAC;QACH,OAAO,CAAC,mBAAmB,CAAC,CAAA;QAE5B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,cAAc,OAAO,EAAE,EAAE;YACrE,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE;aACzC;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC3C,CAAC;QAED,UAAU,CAAC,eAAe,CAAC,CAAA;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAA;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token scope` — placeholder for scope add/remove/view actions.
|
|
3
|
+
*
|
|
4
|
+
* Accepted actions: `add`, `remove`, `view`. Scope mutation is not implemented in-CLI;
|
|
5
|
+
* users are directed to `limetry token list` or the web portal.
|
|
6
|
+
*
|
|
7
|
+
* Side effects: may `process.exit(1)` for unknown actions; no API writes.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Handles `limetry token scope <action>` for add/remove/view.
|
|
11
|
+
*
|
|
12
|
+
* @param action - One of `add`, `remove`, or `view`.
|
|
13
|
+
* @returns Resolves after printing guidance (or exits on unknown action).
|
|
14
|
+
*/
|
|
15
|
+
export declare function tokenScopeCommand(action: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/commands/token/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `limetry token scope` — placeholder for scope add/remove/view actions.
|
|
3
|
+
*
|
|
4
|
+
* Accepted actions: `add`, `remove`, `view`. Scope mutation is not implemented in-CLI;
|
|
5
|
+
* users are directed to `limetry token list` or the web portal.
|
|
6
|
+
*
|
|
7
|
+
* Side effects: may `process.exit(1)` for unknown actions; no API writes.
|
|
8
|
+
*/
|
|
9
|
+
import { logError, logInfo } from "../../utils/config.js";
|
|
10
|
+
/**
|
|
11
|
+
* Handles `limetry token scope <action>` for add/remove/view.
|
|
12
|
+
*
|
|
13
|
+
* @param action - One of `add`, `remove`, or `view`.
|
|
14
|
+
* @returns Resolves after printing guidance (or exits on unknown action).
|
|
15
|
+
*/
|
|
16
|
+
export async function tokenScopeCommand(action) {
|
|
17
|
+
const actions = ["add", "remove", "view"];
|
|
18
|
+
if (!actions.includes(action)) {
|
|
19
|
+
logError(`Unknown action: ${action}. Use add, remove, or view.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
if (action === "view") {
|
|
24
|
+
logInfo("List tokens first: limetry token list");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
logInfo(`Scope action: ${action}`);
|
|
28
|
+
logInfo("Scope management available via the web portal");
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
logError(error instanceof Error ? error.message : "Failed to manage scopes");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/commands/token/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAc;IACpD,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAEzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,mBAAmB,MAAM,6BAA6B,CAAC,CAAA;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,IAAI,CAAC;QACH,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,CAAC,uCAAuC,CAAC,CAAA;YAChD,OAAM;QACR,CAAC;QAED,OAAO,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAA;QAClC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAA;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Limetry CLI entrypoint (`\@limetry/cli`).
|
|
4
|
+
*
|
|
5
|
+
* Registers Commander commands for setup, auth, policy, eval, approvals, audit,
|
|
6
|
+
* and token management. Parses `process.argv` and exits via Commander.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Limetry CLI entrypoint (`\@limetry/cli`).
|
|
4
|
+
*
|
|
5
|
+
* Registers Commander commands for setup, auth, policy, eval, approvals, audit,
|
|
6
|
+
* and token management. Parses `process.argv` and exits via Commander.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { APP_VERSION } from "@limetry/sdk";
|
|
11
|
+
import { Command } from "commander";
|
|
12
|
+
import { loginCommand } from "./commands/auth/login.js";
|
|
13
|
+
import { approvalsListCommand, approvalsResolveCommand, auditTailCommand, doctorCommand, evalCommand, policyApplyCommand, } from "./commands/governance/index.js";
|
|
14
|
+
import { setupCommand } from "./commands/setup/index.js";
|
|
15
|
+
import { tokenCreateCommand } from "./commands/token/create.js";
|
|
16
|
+
import { tokenListCommand } from "./commands/token/list.js";
|
|
17
|
+
import { tokenRevokeCommand } from "./commands/token/revoke.js";
|
|
18
|
+
import { tokenScopeCommand } from "./commands/token/scope.js";
|
|
19
|
+
import { installCliErrorHandlers } from "./utils/errors.js";
|
|
20
|
+
installCliErrorHandlers();
|
|
21
|
+
const program = new Command();
|
|
22
|
+
program
|
|
23
|
+
.name("limetry")
|
|
24
|
+
.description("Limetry CLI — agent action governance and telemetry")
|
|
25
|
+
.version(APP_VERSION);
|
|
26
|
+
program
|
|
27
|
+
.command("setup")
|
|
28
|
+
.description("Interactive setup — local server or hosted API key")
|
|
29
|
+
.action(setupCommand);
|
|
30
|
+
program
|
|
31
|
+
.command("doctor")
|
|
32
|
+
.description("Check config, server health, and API auth")
|
|
33
|
+
.action(doctorCommand);
|
|
34
|
+
program
|
|
35
|
+
.command("login")
|
|
36
|
+
.description("Authenticate with Limetry (JWT)")
|
|
37
|
+
.action(loginCommand);
|
|
38
|
+
const policyCmd = program.command("policy");
|
|
39
|
+
policyCmd.description("Manage action policies");
|
|
40
|
+
policyCmd
|
|
41
|
+
.command("apply")
|
|
42
|
+
.description("Upsert an ActionPolicy from flags or a JSON file")
|
|
43
|
+
.option("-f, --file <path>", "Path to ActionPolicy JSON")
|
|
44
|
+
.option("--agent-id <id>", "Agent id for slim policy")
|
|
45
|
+
.option("--allow <types...>", "Allowed action types")
|
|
46
|
+
.option("--deny <types...>", "Denied action types")
|
|
47
|
+
.option("--block-resource <patterns...>", "Blocked resource patterns")
|
|
48
|
+
.option("--max-cost <minor>", "Max cost in minor units")
|
|
49
|
+
.action(policyApplyCommand);
|
|
50
|
+
program
|
|
51
|
+
.command("eval")
|
|
52
|
+
.description("Evaluate an ActionIntent JSON from --file or stdin")
|
|
53
|
+
.option("-f, --file <path>", "Path to ActionIntent JSON")
|
|
54
|
+
.action(evalCommand);
|
|
55
|
+
const approvalsCmd = program.command("approvals");
|
|
56
|
+
approvalsCmd.description("List and resolve pending approvals");
|
|
57
|
+
approvalsCmd
|
|
58
|
+
.command("list")
|
|
59
|
+
.description("List approvals")
|
|
60
|
+
.option("--status <status>", "pending | approved | denied | all", "pending")
|
|
61
|
+
.action(approvalsListCommand);
|
|
62
|
+
approvalsCmd
|
|
63
|
+
.command("approve")
|
|
64
|
+
.description("Approve a pending approval (optionally re-bind intent JSON)")
|
|
65
|
+
.argument("<approvalId>", "Approval id")
|
|
66
|
+
.option("--reviewer <name>", "Reviewer identity")
|
|
67
|
+
.option("-f, --intent-file <path>", "Exact ActionIntent JSON for payload-hash check")
|
|
68
|
+
.action((approvalId, options) => approvalsResolveCommand({
|
|
69
|
+
approvalId,
|
|
70
|
+
decision: "approve",
|
|
71
|
+
reviewer: options.reviewer,
|
|
72
|
+
intentFile: options.intentFile,
|
|
73
|
+
}));
|
|
74
|
+
approvalsCmd
|
|
75
|
+
.command("deny")
|
|
76
|
+
.description("Deny a pending approval")
|
|
77
|
+
.argument("<approvalId>", "Approval id")
|
|
78
|
+
.option("--reviewer <name>", "Reviewer identity")
|
|
79
|
+
.action((approvalId, options) => approvalsResolveCommand({
|
|
80
|
+
approvalId,
|
|
81
|
+
decision: "deny",
|
|
82
|
+
reviewer: options.reviewer,
|
|
83
|
+
}));
|
|
84
|
+
const auditCmd = program.command("audit");
|
|
85
|
+
auditCmd.description("Query audit / telemetry events");
|
|
86
|
+
auditCmd
|
|
87
|
+
.command("tail")
|
|
88
|
+
.description("List recent audit events")
|
|
89
|
+
.option("-n, --limit <count>", "Number of events", "20")
|
|
90
|
+
.option("--event-type <type>", "Filter by event type")
|
|
91
|
+
.option("--agent-id <id>", "Filter by agent id")
|
|
92
|
+
.action(auditTailCommand);
|
|
93
|
+
const tokenCmd = program.command("token");
|
|
94
|
+
tokenCmd.description("Manage access tokens");
|
|
95
|
+
tokenCmd
|
|
96
|
+
.command("create")
|
|
97
|
+
.description("Create a new access token")
|
|
98
|
+
.option("-n, --name <name>", "Token name")
|
|
99
|
+
.option("-s, --scopes <scopes...>", "Token scopes")
|
|
100
|
+
.option("-e, --expires <date>", "Expiration date")
|
|
101
|
+
.action(tokenCreateCommand);
|
|
102
|
+
tokenCmd
|
|
103
|
+
.command("list")
|
|
104
|
+
.description("List your access tokens")
|
|
105
|
+
.action(tokenListCommand);
|
|
106
|
+
tokenCmd
|
|
107
|
+
.command("revoke")
|
|
108
|
+
.description("Revoke an access token")
|
|
109
|
+
.argument("<tokenId>", "Token ID to revoke")
|
|
110
|
+
.action(tokenRevokeCommand);
|
|
111
|
+
tokenCmd
|
|
112
|
+
.command("scope <action>")
|
|
113
|
+
.description("Manage token scopes")
|
|
114
|
+
.action(tokenScopeCommand);
|
|
115
|
+
program.parse();
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,kBAAkB,GACnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,uBAAuB,EAAE,CAAA;AAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,qDAAqD,CAAC;KAClE,OAAO,CAAC,WAAW,CAAC,CAAA;AAEvB,OAAO;KACJ,OAA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,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AACzC,QAAQ,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAA;AAE5C,QAAQ;KACL,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC;KACzC,MAAM,CAAC,0BAA0B,EAAE,cAAc,CAAC;KAClD,MAAM,CAAC,sBAAsB,EAAE,iBAAiB,CAAC;KACjD,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAE7B,QAAQ;KACL,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,yBAAyB,CAAC;KACtC,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAE3B,QAAQ;KACL,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,wBAAwB,CAAC;KACrC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;KAC3C,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAE7B,QAAQ;KACL,OAAO,CAAC,gBAAgB,CAAC;KACzB,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAE5B,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local CLI config I/O, interactive prompts, and console logging helpers.
|
|
3
|
+
*
|
|
4
|
+
* Config path: `~/.limetry/config.json`.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Persisted CLI credentials and API endpoint settings.
|
|
8
|
+
*/
|
|
9
|
+
export interface CliConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Limetry API base URL (no trailing slash required).
|
|
12
|
+
*/
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* Bearer API key / `LIMETRY_BEARER_TOKEN` used for API calls.
|
|
16
|
+
*/
|
|
17
|
+
apiKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* JWT from `limetry login`, when authenticated via email/password.
|
|
20
|
+
*/
|
|
21
|
+
jwtToken?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Tenant id returned by login or supplied for multi-tenant APIs.
|
|
24
|
+
*/
|
|
25
|
+
tenantId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Authenticated user id from login.
|
|
28
|
+
*/
|
|
29
|
+
userId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Authenticated user email from login.
|
|
32
|
+
*/
|
|
33
|
+
email?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads `~/.limetry/config.json` when present.
|
|
37
|
+
*
|
|
38
|
+
* @returns Parsed {@link CliConfig}, or `null` when missing or unreadable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getConfig(): CliConfig | null;
|
|
41
|
+
/**
|
|
42
|
+
* Writes CLI config to `~/.limetry/config.json`.
|
|
43
|
+
*
|
|
44
|
+
* Side effects: overwrites the config file; logs to stderr on write failure.
|
|
45
|
+
*
|
|
46
|
+
* @param config - Full config object to persist.
|
|
47
|
+
* @returns Nothing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function saveConfig(config: CliConfig): void;
|
|
50
|
+
/**
|
|
51
|
+
* Interactively prompts for an email address.
|
|
52
|
+
*
|
|
53
|
+
* @returns Validated email string from the user.
|
|
54
|
+
*/
|
|
55
|
+
export declare function promptForEmail(): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Interactively prompts for a password (masked).
|
|
58
|
+
*
|
|
59
|
+
* @returns Password string from the user.
|
|
60
|
+
*/
|
|
61
|
+
export declare function promptForPassword(): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Prints a green success line to stdout.
|
|
64
|
+
*
|
|
65
|
+
* @param message - Message body after the checkmark.
|
|
66
|
+
* @returns Nothing.
|
|
67
|
+
*/
|
|
68
|
+
export declare function logSuccess(message: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Prints a red error line to stderr.
|
|
71
|
+
*
|
|
72
|
+
* @param message - Message body after the cross mark.
|
|
73
|
+
* @returns Nothing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function logError(message: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Prints a blue info line to stdout.
|
|
78
|
+
*
|
|
79
|
+
* @param message - Message body after the info mark.
|
|
80
|
+
* @returns Nothing.
|
|
81
|
+
*/
|
|
82
|
+
export declare function logInfo(message: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Loads config or exits the process when not authenticated.
|
|
85
|
+
*
|
|
86
|
+
* Side effects: prints an error and calls `process.exit(1)` when config is missing.
|
|
87
|
+
*
|
|
88
|
+
* @returns Loaded {@link CliConfig}.
|
|
89
|
+
* @throws Never returns when unauthenticated; exits the process instead.
|
|
90
|
+
*/
|
|
91
|
+
export declare function requireAuth(): CliConfig;
|
|
92
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,SAAS,GAAG,IAAI,CAO5C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAMlD;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAUzD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,SAAS,CAOvC"}
|