@7365admin1/core 3.53.4 → 3.53.5
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +106 -36
- package/dist/index.js +495 -477
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -185
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/invite-org-scope.test.mjs +7 -1
- package/test/role-member-org-scope.test.mjs +4 -1
- package/test/staff-bypass-tenant-scope.test.mjs +38 -0
package/package.json
CHANGED
|
@@ -106,6 +106,12 @@ test("the two service-provider invites still resolve their caller themselves", (
|
|
|
106
106
|
for (const source of [verificationService, verificationServiceV2]) {
|
|
107
107
|
const body = fn(source, "createServiceProviderInvite");
|
|
108
108
|
assert.match(body, /resolveInviteActor\(invitedBy\)/);
|
|
109
|
-
assert.match(
|
|
109
|
+
assert.match(
|
|
110
|
+
body,
|
|
111
|
+
// Widened to the property this pinned — a staff clause resolved from the
|
|
112
|
+
// session, ahead of the caller's own orgs. The staff clause is now the
|
|
113
|
+
// cross-client grant (`staffMayBypass`), not identity alone.
|
|
114
|
+
/staffMayBypass\(actor\)[\s\S]{0,80}actor\.orgIds\.includes\(orgId\)/,
|
|
115
|
+
);
|
|
110
116
|
}
|
|
111
117
|
});
|
|
@@ -103,7 +103,10 @@ test("the membership is authorised before it is written", () => {
|
|
|
103
103
|
|
|
104
104
|
test("reach is staff, or membership, or an invitation — and nothing else", () => {
|
|
105
105
|
const body = fn(authz, "requireOrgReach");
|
|
106
|
-
|
|
106
|
+
// The staff road is now the cross-client GRANT, not identity alone
|
|
107
|
+
// (`staffMayBypass`) — still one road, asked one notch harder. Widened to the
|
|
108
|
+
// property this pinned, never weakened: a staff clause must still be first.
|
|
109
|
+
assert.match(body, /if \(staffMayBypass\(actor\)\) return id;/);
|
|
107
110
|
assert.match(body, /actor\.orgIds\.includes\(org\)/);
|
|
108
111
|
assert.match(body, /await hasOrgInvitation\(id, org\)/);
|
|
109
112
|
assert.match(body, /throw new UnauthorizedError\("Not authorized\."\)/);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
const { CROSS_CLIENT_GRANT, staffMayBypass } = await import(
|
|
5
|
+
"./.build/utils/console-permission.util.mjs"
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The bypass is what let platform identity alone skip tenant scoping. These
|
|
10
|
+
* pin the ZERO-LOCKOUT property: every spelling a real staff role carries today
|
|
11
|
+
* still bypasses, so nobody loses access on deploy.
|
|
12
|
+
*/
|
|
13
|
+
const staff = (permissions) => ({ isSuperAdmin: true, staffPermissions: permissions });
|
|
14
|
+
|
|
15
|
+
test("the two spellings a live staff role carries today still bypass", () => {
|
|
16
|
+
// `createDefaultUser` seeds `permissions: []`; the live staff account holds ["*"].
|
|
17
|
+
assert.equal(staffMayBypass(staff([])), true, "empty list must mean everything");
|
|
18
|
+
assert.equal(staffMayBypass(staff(["*"])), true, "wildcard must mean everything");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("a partial staff role is governed, and the grant is a real catalogue string", () => {
|
|
22
|
+
assert.equal(staffMayBypass(staff(["promo-codes:create-promo-code"])), false);
|
|
23
|
+
assert.equal(staffMayBypass(staff(["organizations:see-all-organizations"])), true);
|
|
24
|
+
assert.equal(staffMayBypass(staff(["organizations:see-organization-details"])), true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a non-staff caller never bypasses, however their list reads", () => {
|
|
28
|
+
assert.equal(staffMayBypass({ isSuperAdmin: false, staffPermissions: [] }), false);
|
|
29
|
+
assert.equal(staffMayBypass({ isSuperAdmin: false, staffPermissions: ["*"] }), false);
|
|
30
|
+
assert.equal(staffMayBypass({ isSuperAdmin: false }), false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("the grant is the organizations module — the control must not pass", () => {
|
|
34
|
+
assert.equal(CROSS_CLIENT_GRANT.resource, "organizations");
|
|
35
|
+
// Control: a resource that is NOT the grant must be refused for a partial
|
|
36
|
+
// role, or this test would pass against any implementation.
|
|
37
|
+
assert.equal(staffMayBypass(staff(["users:see-all-users"])), false);
|
|
38
|
+
});
|