@stigmer/server 3.15.2-dev.20260913223433 → 3.15.3-dev.20260914100347

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.
Files changed (201) hide show
  1. package/dist/boot/compose.d.ts.map +1 -1
  2. package/dist/boot/compose.js +103 -9
  3. package/dist/boot/compose.js.map +1 -1
  4. package/dist/domain/iampolicy/access-lists.d.ts +27 -0
  5. package/dist/domain/iampolicy/access-lists.d.ts.map +1 -0
  6. package/dist/domain/iampolicy/access-lists.js +124 -0
  7. package/dist/domain/iampolicy/access-lists.js.map +1 -0
  8. package/dist/domain/iampolicy/constants.d.ts +135 -0
  9. package/dist/domain/iampolicy/constants.d.ts.map +1 -0
  10. package/dist/domain/iampolicy/constants.js +203 -0
  11. package/dist/domain/iampolicy/constants.js.map +1 -0
  12. package/dist/domain/iampolicy/controller.d.ts +29 -0
  13. package/dist/domain/iampolicy/controller.d.ts.map +1 -0
  14. package/dist/domain/iampolicy/controller.js +451 -0
  15. package/dist/domain/iampolicy/controller.js.map +1 -0
  16. package/dist/domain/iampolicy/display-resolver.d.ts +6 -0
  17. package/dist/domain/iampolicy/display-resolver.d.ts.map +1 -0
  18. package/dist/domain/iampolicy/display-resolver.js +90 -0
  19. package/dist/domain/iampolicy/display-resolver.js.map +1 -0
  20. package/dist/domain/iampolicy/grant-path.d.ts +42 -0
  21. package/dist/domain/iampolicy/grant-path.d.ts.map +1 -0
  22. package/dist/domain/iampolicy/grant-path.js +183 -0
  23. package/dist/domain/iampolicy/grant-path.js.map +1 -0
  24. package/dist/domain/iampolicy/grant-scope.d.ts +4 -0
  25. package/dist/domain/iampolicy/grant-scope.d.ts.map +1 -0
  26. package/dist/domain/iampolicy/grant-scope.js +34 -0
  27. package/dist/domain/iampolicy/grant-scope.js.map +1 -0
  28. package/dist/domain/iampolicy/membership.d.ts +111 -0
  29. package/dist/domain/iampolicy/membership.d.ts.map +1 -0
  30. package/dist/domain/iampolicy/membership.js +152 -0
  31. package/dist/domain/iampolicy/membership.js.map +1 -0
  32. package/dist/domain/iampolicy/permissions.d.ts +19 -0
  33. package/dist/domain/iampolicy/permissions.d.ts.map +1 -0
  34. package/dist/domain/iampolicy/permissions.js +27 -0
  35. package/dist/domain/iampolicy/permissions.js.map +1 -0
  36. package/dist/domain/iampolicy/resource-store.d.ts +4 -0
  37. package/dist/domain/iampolicy/resource-store.d.ts.map +1 -0
  38. package/dist/domain/iampolicy/resource-store.js +135 -0
  39. package/dist/domain/iampolicy/resource-store.js.map +1 -0
  40. package/dist/domain/iampolicy/role-lifecycle.d.ts +9 -0
  41. package/dist/domain/iampolicy/role-lifecycle.d.ts.map +1 -0
  42. package/dist/domain/iampolicy/role-lifecycle.js +106 -0
  43. package/dist/domain/iampolicy/role-lifecycle.js.map +1 -0
  44. package/dist/domain/iampolicy/roles.d.ts +11 -0
  45. package/dist/domain/iampolicy/roles.d.ts.map +1 -0
  46. package/dist/domain/iampolicy/roles.js +78 -0
  47. package/dist/domain/iampolicy/roles.js.map +1 -0
  48. package/dist/domain/iampolicy/specs.d.ts +7 -0
  49. package/dist/domain/iampolicy/specs.d.ts.map +1 -0
  50. package/dist/domain/iampolicy/specs.js +45 -0
  51. package/dist/domain/iampolicy/specs.js.map +1 -0
  52. package/dist/domain/iampolicy/steps.d.ts +18 -0
  53. package/dist/domain/iampolicy/steps.d.ts.map +1 -0
  54. package/dist/domain/iampolicy/steps.js +117 -0
  55. package/dist/domain/iampolicy/steps.js.map +1 -0
  56. package/dist/domain/iampolicy/store-contract.d.ts +8 -0
  57. package/dist/domain/iampolicy/store-contract.d.ts.map +1 -0
  58. package/dist/domain/iampolicy/store-contract.js +258 -0
  59. package/dist/domain/iampolicy/store-contract.js.map +1 -0
  60. package/dist/domain/iampolicy/store.d.ts +78 -0
  61. package/dist/domain/iampolicy/store.d.ts.map +1 -0
  62. package/dist/domain/iampolicy/store.js +13 -0
  63. package/dist/domain/iampolicy/store.js.map +1 -0
  64. package/dist/domain/iampolicy/wire-refusals.d.ts +25 -0
  65. package/dist/domain/iampolicy/wire-refusals.d.ts.map +1 -0
  66. package/dist/domain/iampolicy/wire-refusals.js +76 -0
  67. package/dist/domain/iampolicy/wire-refusals.js.map +1 -0
  68. package/dist/domain/identityaccount/constants.d.ts +33 -0
  69. package/dist/domain/identityaccount/constants.d.ts.map +1 -1
  70. package/dist/domain/identityaccount/constants.js +2 -48
  71. package/dist/domain/identityaccount/constants.js.map +1 -1
  72. package/dist/domain/identityaccount/controller.d.ts +8 -1
  73. package/dist/domain/identityaccount/controller.d.ts.map +1 -1
  74. package/dist/domain/identityaccount/controller.js +54 -29
  75. package/dist/domain/identityaccount/controller.js.map +1 -1
  76. package/dist/domain/identityaccount/operator.d.ts.map +1 -1
  77. package/dist/domain/identityaccount/operator.js +2 -4
  78. package/dist/domain/identityaccount/operator.js.map +1 -1
  79. package/dist/domain/identityaccount/provisioning.d.ts +20 -1
  80. package/dist/domain/identityaccount/provisioning.d.ts.map +1 -1
  81. package/dist/domain/identityaccount/provisioning.js +17 -3
  82. package/dist/domain/identityaccount/provisioning.js.map +1 -1
  83. package/dist/domain/identityaccount/resolve.d.ts +23 -0
  84. package/dist/domain/identityaccount/resolve.d.ts.map +1 -1
  85. package/dist/domain/identityaccount/resolve.js +17 -0
  86. package/dist/domain/identityaccount/resolve.js.map +1 -1
  87. package/dist/domain/identityaccount/store-contract.d.ts +4 -18
  88. package/dist/domain/identityaccount/store-contract.d.ts.map +1 -1
  89. package/dist/domain/identityaccount/store-contract.js +12 -47
  90. package/dist/domain/identityaccount/store-contract.js.map +1 -1
  91. package/dist/extensions/authorization-queries.d.ts +81 -0
  92. package/dist/extensions/authorization-queries.d.ts.map +1 -0
  93. package/dist/extensions/authorization-queries.js +2 -0
  94. package/dist/extensions/authorization-queries.js.map +1 -0
  95. package/dist/extensions/drivers.d.ts +49 -2
  96. package/dist/extensions/drivers.d.ts.map +1 -1
  97. package/dist/extensions/identity.d.ts +14 -0
  98. package/dist/extensions/identity.d.ts.map +1 -1
  99. package/dist/extensions/identity.js +18 -1
  100. package/dist/extensions/identity.js.map +1 -1
  101. package/dist/extensions/policy-grant-scope.d.ts +50 -0
  102. package/dist/extensions/policy-grant-scope.d.ts.map +1 -0
  103. package/dist/extensions/policy-grant-scope.js +2 -0
  104. package/dist/extensions/policy-grant-scope.js.map +1 -0
  105. package/dist/extensions/registry.d.ts +23 -1
  106. package/dist/extensions/registry.d.ts.map +1 -1
  107. package/dist/extensions/registry.js +30 -0
  108. package/dist/extensions/registry.js.map +1 -1
  109. package/dist/extensions/resource-authorization.d.ts +63 -0
  110. package/dist/extensions/resource-authorization.d.ts.map +1 -1
  111. package/dist/index.d.ts +7 -1
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +2 -0
  114. package/dist/index.js.map +1 -1
  115. package/dist/pipeline/apiresource-meta.d.ts +56 -1
  116. package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
  117. package/dist/pipeline/apiresource-meta.js +155 -1
  118. package/dist/pipeline/apiresource-meta.js.map +1 -1
  119. package/dist/pipeline/interceptors/auth.d.ts +12 -0
  120. package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
  121. package/dist/pipeline/interceptors/auth.js +13 -1
  122. package/dist/pipeline/interceptors/auth.js.map +1 -1
  123. package/dist/pipeline/steps/authorize.d.ts +20 -5
  124. package/dist/pipeline/steps/authorize.d.ts.map +1 -1
  125. package/dist/pipeline/steps/authorize.js +37 -17
  126. package/dist/pipeline/steps/authorize.js.map +1 -1
  127. package/dist/pipeline/steps/defaults.d.ts +10 -0
  128. package/dist/pipeline/steps/defaults.d.ts.map +1 -1
  129. package/dist/pipeline/steps/defaults.js +39 -0
  130. package/dist/pipeline/steps/defaults.js.map +1 -1
  131. package/dist/store/port-contract.d.ts +61 -0
  132. package/dist/store/port-contract.d.ts.map +1 -0
  133. package/dist/store/port-contract.js +67 -0
  134. package/dist/store/port-contract.js.map +1 -0
  135. package/package.json +4 -4
  136. package/src/boot/compose.ts +107 -10
  137. package/src/domain/iampolicy/__tests__/access-lists.test.ts +238 -0
  138. package/src/domain/iampolicy/__tests__/constants.test.ts +388 -0
  139. package/src/domain/iampolicy/__tests__/controller.test.ts +960 -0
  140. package/src/domain/iampolicy/__tests__/display-resolver.test.ts +138 -0
  141. package/src/domain/iampolicy/__tests__/grant-path.test.ts +474 -0
  142. package/src/domain/iampolicy/__tests__/grant-scope.test.ts +61 -0
  143. package/src/domain/iampolicy/__tests__/iampolicy.test.ts +532 -0
  144. package/src/domain/iampolicy/__tests__/membership.test.ts +447 -0
  145. package/src/domain/iampolicy/__tests__/permissions.test.ts +41 -0
  146. package/src/domain/iampolicy/__tests__/resource-store.test.ts +165 -0
  147. package/src/domain/iampolicy/__tests__/role-lifecycle.test.ts +361 -0
  148. package/src/domain/iampolicy/__tests__/roles.test.ts +53 -0
  149. package/src/domain/iampolicy/__tests__/specs.test.ts +41 -0
  150. package/src/domain/iampolicy/__tests__/steps.test.ts +278 -0
  151. package/src/domain/iampolicy/__tests__/support.ts +195 -0
  152. package/src/domain/iampolicy/__tests__/wire-refusals.test.ts +117 -0
  153. package/src/domain/iampolicy/access-lists.ts +191 -0
  154. package/src/domain/iampolicy/constants.ts +243 -0
  155. package/src/domain/iampolicy/controller.ts +798 -0
  156. package/src/domain/iampolicy/display-resolver.ts +123 -0
  157. package/src/domain/iampolicy/grant-path.ts +270 -0
  158. package/src/domain/iampolicy/grant-scope.ts +36 -0
  159. package/src/domain/iampolicy/membership.ts +298 -0
  160. package/src/domain/iampolicy/permissions.ts +35 -0
  161. package/src/domain/iampolicy/resource-store.ts +186 -0
  162. package/src/domain/iampolicy/role-lifecycle.ts +132 -0
  163. package/src/domain/iampolicy/roles.ts +95 -0
  164. package/src/domain/iampolicy/specs.ts +53 -0
  165. package/src/domain/iampolicy/steps.ts +178 -0
  166. package/src/domain/iampolicy/store-contract.ts +450 -0
  167. package/src/domain/iampolicy/store.ts +103 -0
  168. package/src/domain/iampolicy/wire-refusals.ts +110 -0
  169. package/src/domain/identityaccount/__tests__/provisioning.test.ts +19 -7
  170. package/src/domain/identityaccount/__tests__/resolve.test.ts +113 -2
  171. package/src/domain/identityaccount/constants.ts +16 -31
  172. package/src/domain/identityaccount/controller.ts +65 -35
  173. package/src/domain/identityaccount/operator.ts +5 -5
  174. package/src/domain/identityaccount/provisioning.ts +43 -5
  175. package/src/domain/identityaccount/resolve.ts +43 -0
  176. package/src/domain/identityaccount/store-contract.ts +22 -70
  177. package/src/extensions/__tests__/composed-support.ts +87 -0
  178. package/src/extensions/__tests__/iam-policy-composed.test.ts +373 -0
  179. package/src/extensions/__tests__/iam-policy-points.test.ts +169 -0
  180. package/src/extensions/__tests__/identity-account-composed.test.ts +12 -78
  181. package/src/extensions/__tests__/identity.test.ts +62 -0
  182. package/src/extensions/__tests__/tier-truthfulness.test.ts +8 -0
  183. package/src/extensions/authorization-queries.ts +97 -0
  184. package/src/extensions/drivers.ts +49 -2
  185. package/src/extensions/identity.ts +21 -0
  186. package/src/extensions/policy-grant-scope.ts +50 -0
  187. package/src/extensions/registry.ts +62 -1
  188. package/src/extensions/resource-authorization.ts +65 -0
  189. package/src/index.ts +20 -0
  190. package/src/pipeline/__tests__/grantable-roles-for.test.ts +87 -0
  191. package/src/pipeline/__tests__/kind-by-enum-name.test.ts +107 -0
  192. package/src/pipeline/__tests__/kind-served-by-edition.test.ts +107 -0
  193. package/src/pipeline/apiresource-meta.ts +181 -1
  194. package/src/pipeline/interceptors/auth.ts +14 -1
  195. package/src/pipeline/steps/__tests__/authorize-annotation-completeness.test.ts +73 -3
  196. package/src/pipeline/steps/__tests__/authorize.test.ts +134 -9
  197. package/src/pipeline/steps/__tests__/derived-id.test.ts +49 -0
  198. package/src/pipeline/steps/authorize.ts +46 -21
  199. package/src/pipeline/steps/defaults.ts +42 -0
  200. package/src/store/__tests__/port-contract.test.ts +123 -0
  201. package/src/store/port-contract.ts +102 -0
@@ -0,0 +1,203 @@
1
+ /**
2
+ * IamPolicy domain constants (20260913.01, T01_0_plan.md §3a;
3
+ * T01_1_review.md Q-OR-6b, Q-OR-9; slice 2 ruling Q-S2-1): the derived
4
+ * policy id and the one spelling of a triple it hashes, the kinds the
5
+ * legacy-creator rule scans, and the byte-pinned wire copy.
6
+ *
7
+ * The derived id (Q-OR-9). A policy's id is a pure function of its triple:
8
+ * `iamp_` + `derivedId` (pipeline/steps/defaults.ts, the encoder shared
9
+ * with the identity account) over the triple's canonical text. The text
10
+ * IS the tuple notation the contract's own comment documents
11
+ * (`principal.kind:principal.id#principal.relation@resource.kind:resource.id#relation`,
12
+ * spec.proto), the principal's `#` present even when its qualifier is
13
+ * empty, so the natural key has one spelling and the primary key is the
14
+ * one home of "one row per triple" in open source: two concurrent grants
15
+ * converge by primary key with no secondary index and no scan. The golden
16
+ * vectors in __tests__/constants.test.ts are wire-adjacent contract: a
17
+ * change here re-addresses every policy open source ever wrote.
18
+ *
19
+ * The text's one weakness (Q-S2-1): `ApiResourceRef` fields carry no
20
+ * character pattern, so an id or relation holding one of the three
21
+ * delimiters could spell another triple's text (`a#b` with an empty
22
+ * qualifier and `a` with qualifier `b#` read alike). `malformedTripleField`
23
+ * names such a field; `policyIdFor` refuses to hash such a spec; the grant
24
+ * path turns the same check into INVALID_ARGUMENT before any read or write.
25
+ * No legitimate reference carries a delimiter: every kind is an enum member
26
+ * name, every id a `prefix_ulid`, a slug or the public wildcard `*`, every
27
+ * relation an FGA relation name — and OpenFGA itself rejects `:` and `#`
28
+ * in ids, so the cloud loses nothing it could ever have written.
29
+ *
30
+ * `BLUEPRINT_KINDS` (Q-OR-6b) is the legacy-creator rule's whole scan: the
31
+ * kinds an admin authors. Sessions, executions, keys and memories are
32
+ * personal and stay with their creator by DD-002 rule 2; they never appear
33
+ * here.
34
+ *
35
+ * The copy moved from the cloud's iam/policy/handlers.ts as-is: the CLI,
36
+ * console and SDK show these sentences verbatim, so they are contract. The
37
+ * new sentences are the two edition refusals (the federation shape), the
38
+ * unknown permission, the unknown principal kind (the resource sentence's
39
+ * shape) and the malformed triple.
40
+ */
41
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
42
+ import { kindEnumName } from "../../pipeline/apiresource-meta.js";
43
+ import { derivedId } from "../../pipeline/steps/defaults.js";
44
+ /** The kind's id prefix (kind_meta `iam_policy.id_prefix`). */
45
+ export const POLICY_ID_PREFIX = "iamp";
46
+ /**
47
+ * The proto's `api_version` const (api.proto). The cloud's Java-era rows
48
+ * carry `iam.stigmer.com/v1` and are read as they are (Q-OR-9); every row
49
+ * this domain writes carries the contract's value.
50
+ */
51
+ export const IAM_POLICY_API_VERSION = "iam.stigmer.ai/v1";
52
+ export const IAM_POLICY_KIND = "IamPolicy";
53
+ /** The three characters the canonical text is built from; none may appear inside a field. */
54
+ export const TRIPLE_DELIMITERS = [":", "#", "@"];
55
+ function completeTriple(spec) {
56
+ if (spec.principal === undefined || spec.resource === undefined) {
57
+ throw new Error("policy spec must carry principal and resource");
58
+ }
59
+ return {
60
+ principal: spec.principal,
61
+ resource: spec.resource,
62
+ relation: spec.relation,
63
+ };
64
+ }
65
+ /**
66
+ * The proto's tuple notation, the one spelling of a triple:
67
+ * `principal.kind:principal.id#principal.relation@resource.kind:resource.id#relation`.
68
+ * The principal's `#` is always present (an empty qualifier reads `#@`),
69
+ * so the same triple never has two texts.
70
+ */
71
+ export function canonicalTripleText(spec) {
72
+ const { principal, resource, relation } = completeTriple(spec);
73
+ return `${principal.kind}:${principal.id}#${principal.relation}@${resource.kind}:${resource.id}#${relation}`;
74
+ }
75
+ /**
76
+ * The first field, in the text's order, holding a delimiter — or
77
+ * `undefined` for a well-formed triple. Named in the proto's field paths so
78
+ * a refusal tells the caller exactly what to fix. Total over a spec
79
+ * missing a reference: that is `completeTriple`'s refusal, not this one.
80
+ */
81
+ export function malformedTripleField(spec) {
82
+ const fields = [
83
+ ["principal.kind", spec.principal?.kind ?? ""],
84
+ ["principal.id", spec.principal?.id ?? ""],
85
+ ["principal.relation", spec.principal?.relation ?? ""],
86
+ ["resource.kind", spec.resource?.kind ?? ""],
87
+ ["resource.id", spec.resource?.id ?? ""],
88
+ ["relation", spec.relation],
89
+ ];
90
+ for (const [path, value] of fields) {
91
+ if (TRIPLE_DELIMITERS.some((delimiter) => value.includes(delimiter))) {
92
+ return path;
93
+ }
94
+ }
95
+ return undefined;
96
+ }
97
+ /**
98
+ * The derived policy id of a triple. Pure; refuses a spec missing either
99
+ * reference (a triple is the whole key) and a spec whose text would be
100
+ * ambiguous (Q-S2-1) — both are the assert behind the grant path's gate,
101
+ * which is where a caller hears INVALID_ARGUMENT.
102
+ */
103
+ export function policyIdFor(spec) {
104
+ const text = canonicalTripleText(spec);
105
+ const malformed = malformedTripleField(spec);
106
+ if (malformed !== undefined) {
107
+ throw new Error(malformedTripleMessage(malformed));
108
+ }
109
+ return derivedId(POLICY_ID_PREFIX, text);
110
+ }
111
+ /**
112
+ * The kinds an admin authors — the legacy-creator rule's scan (Q-OR-6b),
113
+ * in registry order. A caller who created one of these idp-shaped, before
114
+ * an account existed, becomes admin on first sign-in.
115
+ */
116
+ export const BLUEPRINT_KINDS = [
117
+ ApiResourceKind.agent,
118
+ ApiResourceKind.workflow,
119
+ ApiResourceKind.skill,
120
+ ApiResourceKind.mcp_server,
121
+ ApiResourceKind.environment,
122
+ ApiResourceKind.schedule,
123
+ ];
124
+ /**
125
+ * The principal kinds a PERSON may grant a role to — the user `create`
126
+ * lane's grantee vocabulary (2026-09-14, session 9 ruling Q-S9-2; the
127
+ * security read's finding 41). A role names a person, so the one grantee
128
+ * is the identity account. A row whose principal is a RESOURCE
129
+ * (`organization:A#organization@platform_client:X`, `#managed_org`) is a
130
+ * structural link, and structural links are `bootstrapPolicy`'s — the
131
+ * platform's own lane, which skips role validation by design.
132
+ *
133
+ * Why the rule is load-bearing: the read side treats every principal
134
+ * outside this vocabulary as a structural parent (`findScopeTuple`,
135
+ * resource-store.ts, which derives its exclusion FROM this constant so the
136
+ * two cannot drift), and the hierarchy walk follows it. Without the arm, a
137
+ * person with `can_grant_access` on organization B could write
138
+ * `organization:A#member@organization:B` and B's Members page, asked for
139
+ * inherited access, would list A's people. The cloud's `create` had the
140
+ * same gap; the store's exclusion also keeps the cloud's Java-era `team`,
141
+ * which is not an ApiResourceKind and so no wire spec can name.
142
+ */
143
+ export const USER_GRANT_PRINCIPAL_KINDS = [
144
+ ApiResourceKind.identity_account,
145
+ ];
146
+ // ---------------------------------------------------------------------------
147
+ // Byte-pinned copy (the cloud handlers' sentences, moved as-is).
148
+ // ---------------------------------------------------------------------------
149
+ /** get on a missing policy (NOT_FOUND). */
150
+ export function policyNotFoundMessage(id) {
151
+ return `IAM policy not found: ${id}`;
152
+ }
153
+ /** A grant on a kind whose kind_meta lists no grantable roles (INVALID_ARGUMENT, every edition). */
154
+ export function noGrantableRolesMessage(kind) {
155
+ return `No roles can be granted on resource kind '${kind}'. Role assignments for this resource kind are system-managed.`;
156
+ }
157
+ /** A role the kind does not list (INVALID_ARGUMENT); the grantable list in kind_meta order. */
158
+ export function roleNotGrantableMessage(role, kind, grantable) {
159
+ return `Role '${role}' cannot be granted on resource kind '${kind}'. Grantable roles: [${grantable.join(", ")}]`;
160
+ }
161
+ /** checkMyPermission for a caller with no identity (UNAUTHENTICATED). */
162
+ export const AUTHENTICATION_REQUIRED_MESSAGE = "Authentication required to check permissions";
163
+ /**
164
+ * A spec whose resource kind is not an ApiResourceKind member name
165
+ * (INVALID_ARGUMENT; the cloud's `kindFromSpecString` sentence). The grant
166
+ * path is where a permissive Authorizer's caller hears it; an enforcing
167
+ * Authorizer denies the unknown kind at position 1 first (slice 1, ruling 2).
168
+ */
169
+ export function unknownResourceKindMessage(kind) {
170
+ return `Unknown resource kind: '${kind}'`;
171
+ }
172
+ // ---------------------------------------------------------------------------
173
+ // New copy (this entry's refusals).
174
+ // ---------------------------------------------------------------------------
175
+ /**
176
+ * A grant on a kind outside the composed grant scope (UNIMPLEMENTED) — the
177
+ * federation and kind-registry degrade-by-probe posture: the sentence a
178
+ * person can act on, naming the editions that serve it.
179
+ */
180
+ export const PER_RESOURCE_GRANTS_UNIMPLEMENTED_MESSAGE = "per-resource access grants are served by the Enterprise and Cloud editions";
181
+ /** The tuple-half queries on a composition without an AuthorizationQueryEngine (UNIMPLEMENTED). */
182
+ export const AUTHORIZATION_QUERIES_UNIMPLEMENTED_MESSAGE = "authorization queries are served by the Enterprise and Cloud editions";
183
+ /** checkMyPermission with a relation that is no IamPermission name (INVALID_ARGUMENT). */
184
+ export function unknownPermissionMessage(relation) {
185
+ return `unknown permission '${relation}'`;
186
+ }
187
+ /** A spec whose principal kind is not an ApiResourceKind member name (INVALID_ARGUMENT). */
188
+ export function unknownPrincipalKindMessage(kind) {
189
+ return `Unknown principal kind: '${kind}'`;
190
+ }
191
+ /**
192
+ * A user grant whose principal is not a person (INVALID_ARGUMENT; Q-S9-2),
193
+ * in the role sentence's shape: the offending kind, then the vocabulary.
194
+ */
195
+ export function principalNotGrantableMessage(kind) {
196
+ const grantable = USER_GRANT_PRINCIPAL_KINDS.map((k) => kindEnumName(k));
197
+ return `Principal kind '${kind}' cannot be granted a role. Grantable principal kinds: [${grantable.join(", ")}]`;
198
+ }
199
+ /** A triple field holding a canonical-text delimiter (INVALID_ARGUMENT; Q-S2-1). */
200
+ export function malformedTripleMessage(field) {
201
+ return `policy ${field} must not contain ':', '#' or '@'`;
202
+ }
203
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/domain/iampolicy/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAMtH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,+DAA+D;AAC/D,MA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AU,sBAAsB,CAAC,KAAa;IAClD,OAAO,UAAU,KAAK,mCAAmC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ConnectRouter } from "@connectrpc/connect";
2
+ import type { ServerEdition } from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
3
+ import type { Logger } from "../../boot/logger.js";
4
+ import type { AuthorizationQueryEngine } from "../../extensions/authorization-queries.js";
5
+ import type { Authorizer } from "../../extensions/authorizer.js";
6
+ import type { PolicyGrantScope } from "../../extensions/policy-grant-scope.js";
7
+ import type { AccountsByCaller } from "../identityaccount/resolve.js";
8
+ import type { AccountsByIds } from "./display-resolver.js";
9
+ import type { IamPolicyGrantPath } from "./grant-path.js";
10
+ import type { IamPolicyStore } from "./store.js";
11
+ /** The reads this controller makes of the identity-account port: the caller's account and display enrichment. */
12
+ export type IamPolicyAccounts = AccountsByCaller & AccountsByIds;
13
+ export interface IamPolicyControllerDeps {
14
+ readonly grantPath: IamPolicyGrantPath;
15
+ readonly policies: IamPolicyStore;
16
+ readonly accounts: IamPolicyAccounts;
17
+ /** The ONE composed Authorizer — position 1 of every chain and every direct handler's `authorizeDirect`. */
18
+ readonly authorizer: Authorizer;
19
+ /** The composed grant scope, or open source's organization-only default (compose.ts installs it at the `??` site). */
20
+ readonly grantScope: PolicyGrantScope;
21
+ /** The composed query engine — undefined = the tuple-half RPCs refuse UNIMPLEMENTED. */
22
+ readonly queries: AuthorizationQueryEngine | undefined;
23
+ /** The served edition — `checkMyPermission`'s first arm reads a kind's tier against it. */
24
+ readonly edition: ServerEdition;
25
+ readonly logger: Logger;
26
+ }
27
+ /** Registers both IamPolicy services on the router (routes stage). */
28
+ export declare function registerIamPolicyServices(router: ConnectRouter, deps: IamPolicyControllerDeps): void;
29
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/domain/iampolicy/controller.ts"],"names":[],"mappings":"AAgGA,OA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