@pmate/cli 0.43.0 → 0.44.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/README.md +4 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +12 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -401,8 +401,8 @@ Roles group explicit actions and resource scopes. Platform roles use a bare name
|
|
|
401
401
|
|
|
402
402
|
```bash
|
|
403
403
|
pmate role definition list --json
|
|
404
|
-
pmate role definition create pmate/reviewer --display-name Reviewer --description "Review PMate apps"
|
|
405
|
-
pmate role permission create app:review --scope-type namespace --display-name "Review app" --description "Approve an app review"
|
|
404
|
+
pmate role definition create pmate/reviewer --level maintainer --display-name Reviewer --description "Review PMate apps"
|
|
405
|
+
pmate role permission create app:review --scope-type namespace --risk M --display-name "Review app" --description "Approve an app review"
|
|
406
406
|
pmate role grant add --role pmate/reviewer --permission app:review --namespace pmate
|
|
407
407
|
pmate role binding add --role pmate/reviewer --account <account-id>
|
|
408
408
|
pmate role check --permission app:review --namespace pmate --json
|
|
@@ -416,3 +416,5 @@ pmate role definition update pmate/reviewer --status disabled
|
|
|
416
416
|
For platform actions use `--scope platform`. Platform roles can grant namespace actions with `--namespace '*'`, including future namespaces; permission checks require a concrete namespace. Definitions and grants are independent, and disabled definitions grant no access. Platform authorization administrators can explicitly delegate new actions; namespace administrators remain bounded by their own namespace and permissions. All commands support `--base-url` and `--json`.
|
|
417
417
|
|
|
418
418
|
Root-only migration: `pmate role migration preview --json`, then `pmate role migration apply --json`. It preserves old records, migrates bindings to canonical role IDs, and records completion so revoked grants are not restored by rerunning migration.
|
|
419
|
+
|
|
420
|
+
Permission risk: H requires an admin-level role, M requires maintainer or admin, L allows dev or higher. The same role must carry the explicit scoped grant. New roles default to dev and new permissions default to H. Use `role definition update <role> --level ...` and `role permission update <permission> --risk ...`; omitted values are preserved. Root may preview/apply the one-time risk migration using `role migration preview|apply --risk-model --json`.
|
package/dist/index.d.ts
CHANGED
|
@@ -335,6 +335,9 @@ type OssCommandArgs = {
|
|
|
335
335
|
objectKey: string;
|
|
336
336
|
};
|
|
337
337
|
type RoleCommandArgs = {
|
|
338
|
+
risk?: "H" | "M" | "L";
|
|
339
|
+
level?: "admin" | "maintainer" | "dev";
|
|
340
|
+
riskModel?: boolean;
|
|
338
341
|
type: Command.Role;
|
|
339
342
|
resource: "definition" | "permission" | "grant" | "binding" | "migration" | "check";
|
|
340
343
|
action: "list" | "create" | "update" | "add" | "remove" | "preview" | "apply" | "check";
|
package/dist/index.js
CHANGED
|
@@ -22677,7 +22677,7 @@ var RoleCommandHandler = class {
|
|
|
22677
22677
|
};
|
|
22678
22678
|
const scope = args.scope === "platform" ? { type: "platform" } : { type: "namespace", namespace: args.namespace };
|
|
22679
22679
|
let result;
|
|
22680
|
-
if (args.resource === "migration") result = await request2("POST", "/authorization/migrate", { dryRun: args.action !== "apply" });
|
|
22680
|
+
if (args.resource === "migration") result = await request2("POST", args.riskModel ? "/authorization/migrate-risk" : "/authorization/migrate", { dryRun: args.action !== "apply" });
|
|
22681
22681
|
else if (args.resource === "check") result = await request2("POST", "/authz/permission", { permission: args.permission, scope, ...args.account ? { account: args.account } : {} });
|
|
22682
22682
|
else if (args.action === "list") {
|
|
22683
22683
|
const data = await request2("GET", "/authorization");
|
|
@@ -22691,7 +22691,7 @@ var RoleCommandHandler = class {
|
|
|
22691
22691
|
existing = inventory[args.resource === "definition" ? "definitions" : "permissions"].find((row) => row.id === id);
|
|
22692
22692
|
if (!existing) throw new Error(`Not found: ${id}`);
|
|
22693
22693
|
}
|
|
22694
|
-
const body = { ...args.resource === "definition" ? { roleId: id } : { id, scopeType: args.scopeType ?? existing?.scopeType }, displayName: args.displayName ?? existing?.displayName ?? id, description: args.description ?? existing?.description ?? id, status: args.status ?? existing?.status ?? "active" };
|
|
22694
|
+
const body = { ...args.resource === "definition" ? { roleId: id, level: args.level ?? existing?.level ?? "dev" } : { id, risk: args.risk ?? existing?.risk ?? "H", scopeType: args.scopeType ?? existing?.scopeType }, displayName: args.displayName ?? existing?.displayName ?? id, description: args.description ?? existing?.description ?? id, status: args.status ?? existing?.status ?? "active" };
|
|
22695
22695
|
result = await request2(args.action === "update" ? "PUT" : "POST", `/authorization/${args.resource === "definition" ? "roles" : "permissions"}`, body);
|
|
22696
22696
|
} else if (args.resource === "binding") result = await request2(args.action === "remove" ? "DELETE" : "POST", "/authorization/bindings", { account: args.account, roleId: args.role });
|
|
22697
22697
|
else result = await request2(args.action === "remove" ? "DELETE" : "POST", "/authorization/role-permissions", { roleId: args.role, permission: args.permission, scope });
|
|
@@ -25623,9 +25623,14 @@ function parseRoleArgs(tokens) {
|
|
|
25623
25623
|
args.description = void 0;
|
|
25624
25624
|
} else args.permission = id;
|
|
25625
25625
|
}
|
|
25626
|
-
const options = { "--role": "role", "--permission": "permission", "--account": "account", "--namespace": "namespace", "--scope": "scope", "--scope-type": "scopeType", "--status": "status", "--display-name": "displayName", "--description": "description", "--base-url": "baseUrl" };
|
|
25626
|
+
const options = { "--risk": "risk", "--level": "level", "--role": "role", "--permission": "permission", "--account": "account", "--namespace": "namespace", "--scope": "scope", "--scope-type": "scopeType", "--status": "status", "--display-name": "displayName", "--description": "description", "--base-url": "baseUrl" };
|
|
25627
25627
|
while (rest.length) {
|
|
25628
25628
|
const flag = rest.shift();
|
|
25629
|
+
if (flag === "--risk-model") {
|
|
25630
|
+
if (resource !== "migration") throw new Error("--risk-model requires role migration");
|
|
25631
|
+
args.riskModel = true;
|
|
25632
|
+
continue;
|
|
25633
|
+
}
|
|
25629
25634
|
if (flag === "--json") {
|
|
25630
25635
|
args.json = true;
|
|
25631
25636
|
continue;
|
|
@@ -25636,6 +25641,8 @@ function parseRoleArgs(tokens) {
|
|
|
25636
25641
|
if (args[key] !== void 0) throw new Error(`Duplicate role option: ${flag}`);
|
|
25637
25642
|
Object.assign(args, { [key]: value });
|
|
25638
25643
|
}
|
|
25644
|
+
if (args.risk && (!["H", "M", "L"].includes(args.risk) || resource !== "permission" || !["create", "update"].includes(action))) throw new Error("--risk H|M|L requires permission create/update");
|
|
25645
|
+
if (args.level && (!["admin", "maintainer", "dev"].includes(args.level) || resource !== "definition" || !["create", "update"].includes(action))) throw new Error("--level admin|maintainer|dev requires definition create/update");
|
|
25639
25646
|
if (args.role && !rolePattern.test(args.role)) throw new Error("Invalid role reference: use admin or blue/admin");
|
|
25640
25647
|
if (args.permission && !permissionPattern.test(args.permission)) throw new Error("Invalid permission: use app:create");
|
|
25641
25648
|
if (args.scopeType && !["platform", "namespace"].includes(args.scopeType)) throw new Error("Invalid --scope-type");
|
|
@@ -27069,11 +27076,11 @@ var HELP_TEXT = [
|
|
|
27069
27076
|
` ${import_chalk4.default.gray(" definition list [--base-url <url>] [--json]")}`,
|
|
27070
27077
|
` ${import_chalk4.default.gray(" definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]")}`,
|
|
27071
27078
|
` ${import_chalk4.default.gray(" definition update <role> [--display-name <name>] [--description <text>] [--status active|disabled]")}`,
|
|
27072
|
-
` ${import_chalk4.default.gray(" permission list|create|update [<action>] [--scope-type platform|namespace] [--status active|disabled]")}`,
|
|
27079
|
+
` ${import_chalk4.default.gray(" permission list|create|update [<action>] [--scope-type platform|namespace] [--risk H|M|L] [--status active|disabled]")}`,
|
|
27073
27080
|
` ${import_chalk4.default.gray(" grant list|add|remove --role <role> [--permission <action>] [--scope platform | --namespace <ns|*>]")}`,
|
|
27074
27081
|
` ${import_chalk4.default.gray(" binding list|add|remove [--account <id>] [--role <role>]")}`,
|
|
27075
27082
|
` ${import_chalk4.default.gray(" check --permission <action> (--scope platform | --namespace <ns>) [--account <id>]")}`,
|
|
27076
|
-
` ${import_chalk4.default.gray(" migration preview|apply (root only)")}`,
|
|
27083
|
+
` ${import_chalk4.default.gray(" migration preview|apply [--risk-model] (root only)")}`,
|
|
27077
27084
|
` ${import_chalk4.default.gray(" roles: admin (platform), blue/admin (namespace); shared flags: --base-url <url> --json")}`,
|
|
27078
27085
|
` ${import_chalk4.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
27079
27086
|
` ${import_chalk4.default.cyan("account")} View accounts and manage account role bindings`,
|