@blocksdiy/react-common 1.60.0 → 1.61.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Who is an admin of an agent — the client twin of wf-actions-py `agent_admin.py`.
|
|
3
3
|
*
|
|
4
|
-
* A caller is an agent admin when they are signed in AND (they
|
|
4
|
+
* A caller is an agent admin when they are signed in AND (they build or manage the app, OR the
|
|
5
5
|
* agent restricts nothing — `adminRoles` unset or empty — OR their role is one of `adminRoles`,
|
|
6
6
|
* matched by trimmed name, case-sensitive). Anything else is not an admin (fail closed).
|
|
7
7
|
*
|
|
@@ -15,6 +15,7 @@ export interface AgentAdminCaller {
|
|
|
15
15
|
role?: string;
|
|
16
16
|
}
|
|
17
17
|
export declare const BUILD_PERMISSION = "build";
|
|
18
|
+
export declare const MANAGE_PERMISSION = "manage";
|
|
18
19
|
/**
|
|
19
20
|
* `adminRoles`: `undefined` or empty = no restriction; `null` = present but malformed, which makes
|
|
20
21
|
* nobody an admin (the server reads it the same way — garbage must not mean "no restriction").
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-admin.d.ts","sourceRoot":"","sources":["../../src/utils/agent-admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,gBAAgB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-admin.d.ts","sourceRoot":"","sources":["../../src/utils/agent-admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAI1C;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,gBAAgB,GAAG,IAAI,GAAG,SAAS,EACzC,YAAY,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,KAC/C,OAeF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,MAAM,EAAE,GAAG,IAAI,GAAG,SAWtE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Who is an admin of an agent — the client twin of wf-actions-py `agent_admin.py`.
|
|
3
3
|
*
|
|
4
|
-
* A caller is an agent admin when they are signed in AND (they
|
|
4
|
+
* A caller is an agent admin when they are signed in AND (they build or manage the app, OR the
|
|
5
5
|
* agent restricts nothing — `adminRoles` unset or empty — OR their role is one of `adminRoles`,
|
|
6
6
|
* matched by trimmed name, case-sensitive). Anything else is not an admin (fail closed).
|
|
7
7
|
*
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* display-only; the server decides independently every turn.
|
|
11
11
|
*/
|
|
12
12
|
export const BUILD_PERMISSION = "build";
|
|
13
|
+
export const MANAGE_PERMISSION = "manage";
|
|
14
|
+
/** App users who administer every agent of the app regardless of its admin roles. */
|
|
15
|
+
const AGENT_ADMIN_PERMISSIONS = [BUILD_PERMISSION, MANAGE_PERMISSION];
|
|
13
16
|
/**
|
|
14
17
|
* `adminRoles`: `undefined` or empty = no restriction; `null` = present but malformed, which makes
|
|
15
18
|
* nobody an admin (the server reads it the same way — garbage must not mean "no restriction").
|
|
@@ -18,7 +21,7 @@ export const isAgentAdmin = (user, adminRoles) => {
|
|
|
18
21
|
if (user?.isAuthenticated !== true || adminRoles === null) {
|
|
19
22
|
return false;
|
|
20
23
|
}
|
|
21
|
-
if (user.permission
|
|
24
|
+
if (user.permission && AGENT_ADMIN_PERMISSIONS.includes(user.permission)) {
|
|
22
25
|
return true;
|
|
23
26
|
}
|
|
24
27
|
if (!adminRoles || adminRoles.length === 0) {
|