@things-factory/auth-base 10.1.181 → 10.1.183

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/auth-base",
3
- "version": "10.1.181",
3
+ "version": "10.1.183",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -49,5 +49,5 @@
49
49
  "passport-jwt": "^4.0.0",
50
50
  "passport-local": "^1.0.0"
51
51
  },
52
- "gitHead": "a4387dbc9c5be49ac7bd0e85a59fbcd650f47138"
52
+ "gitHead": "c36684e0db8353f5f4523ed55111df3154bae19e"
53
53
  }
@@ -0,0 +1,22 @@
1
+ import { buildSchema } from 'type-graphql'
2
+
3
+ import { loadCompiled } from './compiled'
4
+
5
+ /**
6
+ * Reading roles does not list who holds them (ADR-0139).
7
+ *
8
+ * The `user:query` gate stood on `RoleQuery.users`, a field resolver, while `Role` declared `users` itself - and
9
+ * type-graphql keeps the declaration's directives, so the gate was never in the served schema: `role:query` alone listed
10
+ * every role's people. It now stands on the declaration; this reads the schema that is served, not the source.
11
+ */
12
+ const { schema: declared } = loadCompiled('service/index')
13
+ const { privilegeDirectiveResolver, privilegeOfField } = loadCompiled('service/privilege/privilege-directive')
14
+
15
+ describe("a role's people", () => {
16
+ it('★ Role.users asks user:query in the served schema', async () => {
17
+ const schema = await buildSchema({ resolvers: declared.resolverClasses, validate: false })
18
+ privilegeDirectiveResolver(schema, { modules: [] })
19
+ const gate = privilegeOfField('Role', 'users')
20
+ expect([gate.known, gate['gate']?.category, gate['gate']?.privilege]).toEqual([true, 'user', 'query'])
21
+ })
22
+ })