@fabrika/iam 0.9.0-dev.37 → 0.9.0-dev.39

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.
@@ -0,0 +1,6 @@
1
+ -- The procedure IAM asks, as the administrator, for a dimension's values (ADR-0085 §4). SQLite/D1 dialect;
2
+ -- `../migrations-postgres/0037_scope_value_sources.sql` states the same outcome.
3
+ --
4
+ -- A JSON object { endpoint, path, action }; NULL names none, which is every scope reconciled before this file, so the
5
+ -- console keeps the listed values or free text for them until the application's next deploy reconciles a source.
6
+ ALTER TABLE app_scopes ADD COLUMN value_source TEXT;
@@ -0,0 +1,6 @@
1
+ -- The procedure IAM asks, as the administrator, for a dimension's values (ADR-0085 §4). Postgres dialect;
2
+ -- `../migrations/0037_scope_value_sources.sql` states the same outcome.
3
+ --
4
+ -- A JSON object { endpoint, path, action }; NULL names none, which is every scope reconciled before this file, so the
5
+ -- console keeps the listed values or free text for them until the application's next deploy reconciles a source.
6
+ ALTER TABLE app_scopes ADD COLUMN value_source TEXT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/iam",
3
- "version": "0.9.0-dev.37",
3
+ "version": "0.9.0-dev.39",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/contember/fabrika-platform.git",
@@ -56,16 +56,16 @@
56
56
  "prune:auth-log": "bun src/node/prune.ts"
57
57
  },
58
58
  "dependencies": {
59
- "@fabrika/app": "0.9.0-dev.37",
60
- "@fabrika/auth": "0.9.0-dev.37",
61
- "@fabrika/auth-core": "0.9.0-dev.37",
62
- "@fabrika/control-contract": "0.9.0-dev.37",
63
- "@fabrika/email": "0.9.0-dev.37",
64
- "@fabrika/iam-contract": "0.9.0-dev.37",
65
- "@fabrika/platform": "0.9.0-dev.37",
66
- "@fabrika/platform-node": "0.9.0-dev.37",
67
- "@fabrika/provider-cloudflare": "0.9.0-dev.37",
68
- "@fabrika/proxy-core": "0.9.0-dev.37",
59
+ "@fabrika/app": "0.9.0-dev.39",
60
+ "@fabrika/auth": "0.9.0-dev.39",
61
+ "@fabrika/auth-core": "0.9.0-dev.39",
62
+ "@fabrika/control-contract": "0.9.0-dev.39",
63
+ "@fabrika/email": "0.9.0-dev.39",
64
+ "@fabrika/iam-contract": "0.9.0-dev.39",
65
+ "@fabrika/platform": "0.9.0-dev.39",
66
+ "@fabrika/platform-node": "0.9.0-dev.39",
67
+ "@fabrika/provider-cloudflare": "0.9.0-dev.39",
68
+ "@fabrika/proxy-core": "0.9.0-dev.39",
69
69
  "jose": "^5.9.0",
70
70
  "uqr": "^0.1.3",
71
71
  "zod": "^3.25.76"
@@ -1,5 +1,12 @@
1
1
  import { appSchemaSchema } from '@fabrika/auth'
2
- import { type AppDelegationDef, type AppLinkMountDef, type DimensionValue, LOCALES, type RoleDef } from '@fabrika/auth-core'
2
+ import {
3
+ type AppDelegationDef,
4
+ type AppLinkMountDef,
5
+ type DimensionValue,
6
+ type DimensionValueSource,
7
+ LOCALES,
8
+ type RoleDef,
9
+ } from '@fabrika/auth-core'
3
10
 
4
11
  import {
5
12
  type AppDto,
@@ -14,7 +21,7 @@ import type { z } from 'zod'
14
21
  import { parsePresentation } from '../app-presentation'
15
22
  import { normalizeOrigin } from '../handoff'
16
23
  import { BUILTIN_ROLES } from '../roles'
17
- import { parseStoredPermissions, parseStoredValueList } from '../stored-permissions'
24
+ import { parseStoredPermissions, parseStoredValueList, parseStoredValueSource } from '../stored-permissions'
18
25
  import { type AdminContext, adminEvent, fail } from './context'
19
26
  import { dbRoleToDef, knownApps } from './grant-support'
20
27
  import { error, json, readJson } from './http'
@@ -177,6 +184,7 @@ export async function putAppSchema(c: AdminContext, app: string): Promise<Respon
177
184
  directory: s.directory ?? null,
178
185
  lookups: s.lookups ?? null,
179
186
  values: s.values ?? null,
187
+ valueSource: s.valueSource ?? null,
180
188
  })),
181
189
  actions: schema.actions.map((a) => ({ action: a.action, description: a.description ?? null })),
182
190
  roles: Object.entries(schema.roles).map(([roleKey, def]) => ({
@@ -254,6 +262,7 @@ async function readAppSchemaDto(c: AdminContext, app: string): Promise<AppSchema
254
262
  ...(r.members_directory === 'labels' ? { directory: 'labels' } : {}),
255
263
  ...(r.members_lookup === null ? {} : { lookups: parseStoredPermissions(r.members_lookup) }),
256
264
  ...valueListOf(r.value_list),
265
+ ...valueSourceOf(r.value_source),
257
266
  })),
258
267
  actions: actionRows.map((r) => ({ action: r.action, ...(r.description !== null ? { description: r.description } : {}) })),
259
268
  roles,
@@ -309,6 +318,12 @@ export async function getAppSchemaUseCase(c: AdminContext, input: AppInput): Pro
309
318
  return readAppSchemaDto(c, app)
310
319
  }
311
320
 
321
+ /** A scope's value source as the schema answers it: present only when the stored source parses. */
322
+ function valueSourceOf(stored: string | null): { valueSource?: DimensionValueSource } {
323
+ const valueSource = parseStoredValueSource(stored)
324
+ return valueSource === null ? {} : { valueSource }
325
+ }
326
+
312
327
  /** A scope's listed values as the schema answers them: present only when the stored list parses. */
313
328
  function valueListOf(stored: string | null): { values?: DimensionValue[] } {
314
329
  const values = parseStoredValueList(stored)
@@ -12,8 +12,11 @@ export interface AdminContext {
12
12
  services: Services
13
13
  request: Request
14
14
  url: URL
15
- /** The resolved admin caller (already gated on its administration). `label` is null for a label-less key. */
16
- admin: { id: string; type: PrincipalType; label: string | null; permissions: PermissionEntry[] }
15
+ /**
16
+ * The resolved admin caller (already gated on its administration). `label` is null for a label-less key; `session`
17
+ * is true only for a signed-in session's console token, never for a `px_` key.
18
+ */
19
+ admin: { id: string; type: PrincipalType; label: string | null; permissions: PermissionEntry[]; session: boolean }
17
20
  /** The installation, or the people of some applications (ADR-0058); every user-admin rule reads it. */
18
21
  administration: Administration
19
22
  /** IAM's own app id — the audience the admin was resolved against; used for audit labeling. */
package/src/admin/rpc.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  import type { AdminContext } from './handlers'
20
20
  import { adminUseCases } from './handlers'
21
21
  import { ADMIN_ACTION, extractCredentials, IAM_APP, resolveAdmin } from './router'
22
+ import { listScopeValuesUseCase } from './scope-values'
22
23
  import { administrationOf } from './user-admin'
23
24
 
24
25
  const t = initRpc<IamAppContext>()
@@ -128,6 +129,13 @@ export const adminRpcRouter: RpcRouterFor<IamAppContext, IamAdminRpcContract> =
128
129
  .require(ADMIN_ACTION)
129
130
  .mutation(({ ctx, input }) => setGrantApprovalUseCase(context(ctx), input)),
130
131
  }),
132
+ // A person who grants at the application asks it for a dimension's values (ADR-0085 §4); a mutation, because it
133
+ // issues a short-lived key and records it.
134
+ scopeValues: t.router({
135
+ list: t.procedure
136
+ .input(z.object({ app: nonEmpty, scopeType: nonEmpty }))
137
+ .mutation(({ ctx, input }) => listScopeValuesUseCase(context(ctx), input)),
138
+ }),
131
139
  apps: t.router({
132
140
  list: t.procedure.query(({ ctx }) => adminUseCases.listApps(context(ctx))),
133
141
  getSchema: t.procedure.input(appInput).query(({ ctx, input }) => adminUseCases.getAppSchema(context(ctx), input)),
@@ -0,0 +1,191 @@
1
+ // A dimension's values, asked of the application as the signed-in administrator (ADR-0085 §4). IAM issues a
2
+ // short-lived key of that person carrying only the source procedure's action, and calls the procedure through the
3
+ // application's proxy, which exchanges the key like any other: the proxy stays the only enforcement point.
4
+
5
+ import {
6
+ API_KEY_PREFIX,
7
+ type DimensionValueSource,
8
+ isReservedScopeType,
9
+ LOCAL_ENVIRONMENT,
10
+ MAX_DIMENSION_VALUES,
11
+ MAX_SCOPE_VALUE_SOURCE_BYTES,
12
+ parseDimensionValues,
13
+ type PermissionEntry,
14
+ SCOPE_VALUE_SOURCE_TIMEOUT_MS,
15
+ } from '@fabrika/auth-core'
16
+ import type { ListScopeValuesInput, ScopeValuesResult, ScopeValuesUnavailable } from '@fabrika/iam-contract'
17
+ import { uuidv7 } from '@fabrika/platform'
18
+ import { unixNow } from '../repositories/sql'
19
+ import { resolvePermissionsAt } from '../resolve'
20
+ import { generateToken, hashToken } from '../secret'
21
+ import { parseStoredValueSource } from '../stored-permissions'
22
+ import { type AdminContext, adminEvent, fail } from './context'
23
+ import { requireManagedApp } from './user-admin'
24
+
25
+ /** How long the key IAM issues for one call lives: the call's deadline, and the token the proxy mints from it with it. */
26
+ export const SCOPE_VALUE_KEY_TTL_SECONDS = 60
27
+
28
+ /** The fetch IAM calls the application's proxy with; a test passes its own. */
29
+ export type SourceFetch = (input: Request) => Promise<Response>
30
+
31
+ /**
32
+ * The values `input.scopeType` of `input.app` lists for the caller. Only a person signed in to the console who may
33
+ * grant at the application asks (`requireManagedApp`); the key is that person's own, bound to the application, carries
34
+ * only the source's action in the scopes the person holds it, and expires with the call. Its issue is audited in the
35
+ * key's own transaction. A refusal by the application or its absence answers `unavailable`, never an error.
36
+ */
37
+ export async function listScopeValuesUseCase(
38
+ c: AdminContext,
39
+ input: ListScopeValuesInput,
40
+ sourceFetch: SourceFetch = (request) => fetch(request),
41
+ ): Promise<ScopeValuesResult> {
42
+ requireManagedApp(c, input.app)
43
+ if (c.admin.type !== 'user' || !c.admin.session) {
44
+ return fail(403, 'only a person signed in to the console asks an application for its values; a key does not')
45
+ }
46
+ const { appSchema, handoff, principals } = c.services.repositories
47
+ const scope = await appSchema.getScope(input.app, input.scopeType)
48
+ if (scope === null) return fail(404, `'${input.scopeType}' is not a scope of '${input.app}'`)
49
+ const source = parseStoredValueSource(scope.value_source)
50
+ if (source === null) return unavailable('no_source')
51
+ const target = sourceUrl(await handoff.listReturnOrigins(input.app), source, c.services.config.environment === LOCAL_ENVIRONMENT)
52
+ if (target === null) return unavailable('no_origin')
53
+ const principal = await principals.getPrincipalById(c.admin.id)
54
+ if (principal === null) return fail(404, 'principal not found')
55
+ const grants = keyGrants(await resolvePermissionsAt(c.services, principal, input.app), source.action)
56
+ if (grants === null) return unavailable('not_held')
57
+
58
+ const key = `${API_KEY_PREFIX}${generateToken()}`
59
+ const credentialId = uuidv7()
60
+ const expiresAt = unixNow() + SCOPE_VALUE_KEY_TTL_SECONDS
61
+ const { credentials, audit } = c.services.repositories
62
+ await audit.commit([
63
+ ...credentials.credentialStatements(credentialId, {
64
+ tokenHash: await hashToken(key),
65
+ label: `scope values: ${input.scopeType}`,
66
+ principalId: principal.id,
67
+ app: input.app,
68
+ issuedBy: principal.id,
69
+ expiresAt,
70
+ grants,
71
+ }),
72
+ audit.eventStatement(adminEvent(c, {
73
+ action: 'iam.scope_values.read',
74
+ resourceType: 'credential',
75
+ resourceId: credentialId,
76
+ metadata: { app: input.app, scopeType: input.scopeType, endpoint: source.endpoint, action: source.action, expiresAt },
77
+ })),
78
+ ])
79
+ return await askSource(sourceFetch, target, key)
80
+ }
81
+
82
+ function unavailable(reason: ScopeValuesUnavailable): ScopeValuesResult {
83
+ return { source: 'unavailable', reason }
84
+ }
85
+
86
+ /**
87
+ * The procedure's URL on the application's one registered origin, or null. The key goes only where its application is
88
+ * served: an environment registering several origins (a dev environment's workspace sandboxes, each serving its own
89
+ * contract) names none, a plain `http:` origin only in a local IAM, and never a path that would leave the origin.
90
+ */
91
+ function sourceUrl(origins: readonly string[], source: DimensionValueSource, local: boolean): URL | null {
92
+ const [origin] = origins
93
+ if (origin === undefined || origins.length !== 1) return null
94
+ try {
95
+ const url = new URL(source.path, origin)
96
+ if (url.protocol !== 'https:' && !(local && url.protocol === 'http:')) return null
97
+ return url.origin === origin && url.pathname === source.path && url.search === '' ? url : null
98
+ } catch {
99
+ return null
100
+ }
101
+ }
102
+
103
+ /**
104
+ * The key's grants: the caller's entries of `action`, as they hold them (one global entry, else each scope), or null
105
+ * when they hold it nowhere or in more scopes than a list holds values. A self-bound key's grants only narrow the person's
106
+ * live permissions at every mint, so the key never carries more than the person holds then.
107
+ */
108
+ function keyGrants(
109
+ held: readonly PermissionEntry[],
110
+ action: string,
111
+ ): { action: string; scopeType: string | null; scopeValue: string | null }[] | null {
112
+ const entries = held.filter((entry) => entry.action === action && (entry.scope === null || !isReservedScopeType(entry.scope.type)))
113
+ if (entries.some((entry) => entry.scope === null)) return [{ action, scopeType: null, scopeValue: null }]
114
+ if (entries.length === 0 || entries.length > MAX_DIMENSION_VALUES) return null
115
+ const seen = new Set<string>()
116
+ const grants: { action: string; scopeType: string | null; scopeValue: string | null }[] = []
117
+ for (const { scope } of entries) {
118
+ if (scope === null) continue
119
+ const key = JSON.stringify([scope.type, scope.value])
120
+ if (seen.has(key)) continue
121
+ seen.add(key)
122
+ grants.push({ action, scopeType: scope.type, scopeValue: scope.value })
123
+ }
124
+ return grants
125
+ }
126
+
127
+ /**
128
+ * One call of the source through the application's proxy, with the key as the bearer: no redirect (it carries a
129
+ * credential), one deadline for the answer and its body, and a bounded read. Every failure is an `unavailable` reason.
130
+ */
131
+ async function askSource(sourceFetch: SourceFetch, target: URL, key: string): Promise<ScopeValuesResult> {
132
+ const signal = AbortSignal.timeout(SCOPE_VALUE_SOURCE_TIMEOUT_MS)
133
+ let response: Response
134
+ try {
135
+ response = await sourceFetch(
136
+ new Request(target, {
137
+ method: 'POST',
138
+ redirect: 'manual',
139
+ signal,
140
+ headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json', accept: 'application/json' },
141
+ body: '{}',
142
+ }),
143
+ )
144
+ } catch {
145
+ return unavailable(signal.aborted ? 'timeout' : 'unreachable')
146
+ }
147
+ if (response.status !== 200) {
148
+ await response.body?.cancel().catch(() => {})
149
+ return unavailable(response.status === 401 || response.status === 403 || response.status === 404 ? 'refused' : 'unreachable')
150
+ }
151
+ const body = await boundedJson(response)
152
+ if (body === TIMED_OUT || signal.aborted) return unavailable('timeout')
153
+ if (body === null || typeof body !== 'object' || Array.isArray(body)) return unavailable('malformed')
154
+ const values = parseDimensionValues(Reflect.get(body, 'result'))
155
+ return values === null ? unavailable('malformed') : { source: 'application', values }
156
+ }
157
+
158
+ const TIMED_OUT = Symbol('timed out')
159
+
160
+ /** The answer's JSON, null when it is larger than `MAX_SCOPE_VALUE_SOURCE_BYTES` or no JSON, `TIMED_OUT` past the deadline. */
161
+ async function boundedJson(response: Response): Promise<unknown> {
162
+ if (response.body === null || Number(response.headers.get('content-length') ?? '0') > MAX_SCOPE_VALUE_SOURCE_BYTES) {
163
+ await response.body?.cancel().catch(() => {})
164
+ return null
165
+ }
166
+ const reader = response.body.getReader()
167
+ const decoder = new TextDecoder('utf-8', { fatal: true })
168
+ let bytes = 0
169
+ let text = ''
170
+ try {
171
+ while (true) {
172
+ const chunk = await reader.read()
173
+ if (chunk.done) break
174
+ bytes += chunk.value.byteLength
175
+ if (bytes > MAX_SCOPE_VALUE_SOURCE_BYTES) {
176
+ await reader.cancel().catch(() => {})
177
+ return null
178
+ }
179
+ text += decoder.decode(chunk.value, { stream: true })
180
+ }
181
+ text += decoder.decode()
182
+ } catch (error) {
183
+ return error instanceof DOMException && (error.name === 'TimeoutError' || error.name === 'AbortError') ? TIMED_OUT : null
184
+ }
185
+ try {
186
+ const parsed: unknown = JSON.parse(text)
187
+ return parsed
188
+ } catch {
189
+ return null
190
+ }
191
+ }
@@ -1,4 +1,4 @@
1
- import { type DimensionValue, parseJsonStringArray, terminalIdentifyProblem, type WorkloadKind } from '@fabrika/auth-core'
1
+ import { type DimensionValue, type DimensionValueSource, parseJsonStringArray, terminalIdentifyProblem, type WorkloadKind } from '@fabrika/auth-core'
2
2
  import { type SqlDatabase, type SqlStatement } from '@fabrika/platform'
3
3
 
4
4
  import { type AuditEventInput, auditEventStatement, AuditWriter } from './audit'
@@ -42,6 +42,8 @@ export interface AppScopeRow {
42
42
  members_lookup: string | null
43
43
  /** A JSON array of the `{ value, label? }` the console offers for a grant here (ADR-0085), or null for none. */
44
44
  value_list: string | null
45
+ /** A JSON object `{ endpoint, path, action }`: the procedure IAM asks for the values (ADR-0085 §4), or null for none. */
46
+ value_source: string | null
45
47
  }
46
48
 
47
49
  /** A share-link mount (the `app_link_mounts` table). `grants` is a JSON array of exact actions. */
@@ -353,6 +355,7 @@ export class AppSchemaRepository {
353
355
  members?: { manage: string; list: string } | null
354
356
  directory?: 'labels' | null
355
357
  values?: readonly DimensionValue[] | null
358
+ valueSource?: DimensionValueSource | null
356
359
  lookups?: string[] | null
357
360
  }[]
358
361
  actions: { action: string; description?: string | null }[]
@@ -439,8 +442,8 @@ export class AppSchemaRepository {
439
442
  statements.push(
440
443
  this.db
441
444
  .prepare(
442
- `INSERT INTO app_scopes (app, scope_type, label, parent_scope, creator_role, members_manage, members_list, members_directory, members_lookup, value_list)
443
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
445
+ `INSERT INTO app_scopes (app, scope_type, label, parent_scope, creator_role, members_manage, members_list, members_directory, members_lookup, value_list, value_source)
446
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
444
447
  ON CONFLICT (app, scope_type) DO UPDATE SET
445
448
  label = excluded.label,
446
449
  parent_scope = excluded.parent_scope,
@@ -449,7 +452,8 @@ export class AppSchemaRepository {
449
452
  members_list = excluded.members_list,
450
453
  members_directory = excluded.members_directory,
451
454
  members_lookup = excluded.members_lookup,
452
- value_list = excluded.value_list`,
455
+ value_list = excluded.value_list,
456
+ value_source = excluded.value_source`,
453
457
  )
454
458
  .bind(
455
459
  app,
@@ -462,6 +466,9 @@ export class AppSchemaRepository {
462
466
  scope.directory ?? null,
463
467
  scope.lookups == null || scope.lookups.length === 0 ? null : JSON.stringify(scope.lookups),
464
468
  scope.values == null ? null : JSON.stringify(scope.values),
469
+ scope.valueSource == null
470
+ ? null
471
+ : JSON.stringify({ endpoint: scope.valueSource.endpoint, path: scope.valueSource.path, action: scope.valueSource.action }),
465
472
  ),
466
473
  )
467
474
  }
@@ -1,4 +1,4 @@
1
- import { type DimensionValue, dimensionValuesProblem, parseJsonStringArray } from '@fabrika/auth-core'
1
+ import { type DimensionValue, type DimensionValueSource, dimensionValuesProblem, isCanonicalPath, parseJsonStringArray } from '@fabrika/auth-core'
2
2
 
3
3
  /** A role's stored `via`: relation → actions. A malformed row contributes nothing, as an unparseable grant does. */
4
4
  export function parseStoredVia(json: string | null): Record<string, string[]> {
@@ -56,3 +56,24 @@ export function parseStoredValueList(json: string | null): DimensionValue[] | nu
56
56
  }
57
57
  return dimensionValuesProblem(values) === null ? values : null
58
58
  }
59
+
60
+ /**
61
+ * A scope's stored `value_source` (ADR-0085 §4), or null for none. A row that does not parse names none: the console
62
+ * then falls back to the listed values or free text, never to a path IAM did not store.
63
+ */
64
+ export function parseStoredValueSource(json: string | null): DimensionValueSource | null {
65
+ if (json === null) return null
66
+ let value: unknown
67
+ try {
68
+ value = JSON.parse(json)
69
+ } catch {
70
+ return null
71
+ }
72
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return null
73
+ const endpoint: unknown = Reflect.get(value, 'endpoint')
74
+ const path: unknown = Reflect.get(value, 'path')
75
+ const action: unknown = Reflect.get(value, 'action')
76
+ if (typeof endpoint !== 'string' || typeof path !== 'string' || typeof action !== 'string') return null
77
+ if (endpoint === '' || action === '' || !path.startsWith('/') || !isCanonicalPath(path)) return null
78
+ return { endpoint, path, action }
79
+ }
@@ -11,12 +11,16 @@ export interface AdminContext {
11
11
  services: Services;
12
12
  request: Request;
13
13
  url: URL;
14
- /** The resolved admin caller (already gated on its administration). `label` is null for a label-less key. */
14
+ /**
15
+ * The resolved admin caller (already gated on its administration). `label` is null for a label-less key; `session`
16
+ * is true only for a signed-in session's console token, never for a `px_` key.
17
+ */
15
18
  admin: {
16
19
  id: string;
17
20
  type: PrincipalType;
18
21
  label: string | null;
19
22
  permissions: PermissionEntry[];
23
+ session: boolean;
20
24
  };
21
25
  /** The installation, or the people of some applications (ADR-0058); every user-admin rule reads it. */
22
26
  administration: Administration;
@@ -0,0 +1,13 @@
1
+ import type { ListScopeValuesInput, ScopeValuesResult } from '@fabrika/iam-contract';
2
+ import { type AdminContext } from './context';
3
+ /** How long the key IAM issues for one call lives: the call's deadline, and the token the proxy mints from it with it. */
4
+ export declare const SCOPE_VALUE_KEY_TTL_SECONDS = 60;
5
+ /** The fetch IAM calls the application's proxy with; a test passes its own. */
6
+ export type SourceFetch = (input: Request) => Promise<Response>;
7
+ /**
8
+ * The values `input.scopeType` of `input.app` lists for the caller. Only a person signed in to the console who may
9
+ * grant at the application asks (`requireManagedApp`); the key is that person's own, bound to the application, carries
10
+ * only the source's action in the scopes the person holds it, and expires with the call. Its issue is audited in the
11
+ * key's own transaction. A refusal by the application or its absence answers `unavailable`, never an error.
12
+ */
13
+ export declare function listScopeValuesUseCase(c: AdminContext, input: ListScopeValuesInput, sourceFetch?: SourceFetch): Promise<ScopeValuesResult>;
@@ -1,4 +1,4 @@
1
- import { type DimensionValue, type WorkloadKind } from '@fabrika/auth-core';
1
+ import { type DimensionValue, type DimensionValueSource, type WorkloadKind } from '@fabrika/auth-core';
2
2
  import { type SqlDatabase } from '@fabrika/platform';
3
3
  import { type AuditEventInput, AuditWriter } from './audit';
4
4
  /** A role/policy bundle row (the `roles` table). `permissions` is a JSON array string. */
@@ -38,6 +38,8 @@ export interface AppScopeRow {
38
38
  members_lookup: string | null;
39
39
  /** A JSON array of the `{ value, label? }` the console offers for a grant here (ADR-0085), or null for none. */
40
40
  value_list: string | null;
41
+ /** A JSON object `{ endpoint, path, action }`: the procedure IAM asks for the values (ADR-0085 §4), or null for none. */
42
+ value_source: string | null;
41
43
  }
42
44
  /** A share-link mount (the `app_link_mounts` table). `grants` is a JSON array of exact actions. */
43
45
  export interface LinkMountRow {
@@ -190,6 +192,7 @@ export declare class AppSchemaRepository {
190
192
  } | null;
191
193
  directory?: 'labels' | null;
192
194
  values?: readonly DimensionValue[] | null;
195
+ valueSource?: DimensionValueSource | null;
193
196
  lookups?: string[] | null;
194
197
  }[];
195
198
  actions: {
@@ -1,4 +1,4 @@
1
- import { type DimensionValue } from '@fabrika/auth-core';
1
+ import { type DimensionValue, type DimensionValueSource } from '@fabrika/auth-core';
2
2
  /** A role's stored `via`: relation → actions. A malformed row contributes nothing, as an unparseable grant does. */
3
3
  export declare function parseStoredVia(json: string | null): Record<string, string[]>;
4
4
  /** Legacy rows retain valid patterns even when other entries are malformed. */
@@ -16,3 +16,8 @@ export declare function delegatedActions(role: {
16
16
  * lists none: the console then takes free text, which is what it did before any list.
17
17
  */
18
18
  export declare function parseStoredValueList(json: string | null): DimensionValue[] | null;
19
+ /**
20
+ * A scope's stored `value_source` (ADR-0085 §4), or null for none. A row that does not parse names none: the console
21
+ * then falls back to the listed values or free text, never to a path IAM did not store.
22
+ */
23
+ export declare function parseStoredValueSource(json: string | null): DimensionValueSource | null;