@fabrika/iam-contract 0.9.0-dev.35 → 0.9.0-dev.37
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 +4 -4
- package/src/index.ts +109 -6
- package/src/oauth.ts +39 -6
- package/types/src/index.d.ts +97 -6
- package/types/src/oauth.d.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/iam-contract",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"test": "bun test"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@fabrika/app": "0.9.0-dev.
|
|
31
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
32
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.37",
|
|
31
|
+
"@fabrika/auth-core": "0.9.0-dev.37",
|
|
32
|
+
"@fabrika/proxy-core": "0.9.0-dev.37"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -69,8 +69,10 @@ export interface GrantDto {
|
|
|
69
69
|
permissions: string[] | null
|
|
70
70
|
/** Scope dimension; null = global (both rise/fall together). */
|
|
71
71
|
scopeType: string | null
|
|
72
|
-
/** Opaque, app-owned scope value; null = global. */
|
|
72
|
+
/** Opaque, app-owned scope value; null = global. The first of `scopeValues` (ADR-0085). */
|
|
73
73
|
scopeValue: string | null
|
|
74
|
+
/** Every value of `scopeType` the grant holds, sorted; null = global. A grant of one value lists one. */
|
|
75
|
+
scopeValues: string[] | null
|
|
74
76
|
/** App id this grant applies to; null = all apps (cross-app). */
|
|
75
77
|
app: string | null
|
|
76
78
|
grantedBy: string | null
|
|
@@ -161,6 +163,9 @@ export interface SessionList extends CursorList<SessionDto> {
|
|
|
161
163
|
|
|
162
164
|
// ── Grants ────────────────────────────────────────────────────────────────────
|
|
163
165
|
|
|
166
|
+
/** The most scope values one grant holds (ADR-0085). */
|
|
167
|
+
export const MAX_GRANT_SCOPE_VALUES = 100
|
|
168
|
+
|
|
164
169
|
export interface CreateGrantRequest {
|
|
165
170
|
principalId: string
|
|
166
171
|
/** A named role/policy key — XOR `permissions` (supply exactly one). */
|
|
@@ -171,6 +176,8 @@ export interface CreateGrantRequest {
|
|
|
171
176
|
scopeType?: string | null
|
|
172
177
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
173
178
|
scopeValue?: string | null
|
|
179
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
180
|
+
scopeValues?: string[]
|
|
174
181
|
/** App id (a registered app id); null / omitted = all apps (cross-app). */
|
|
175
182
|
app?: string | null
|
|
176
183
|
expiresAt?: number | null
|
|
@@ -181,6 +188,79 @@ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId'
|
|
|
181
188
|
id: string
|
|
182
189
|
}
|
|
183
190
|
|
|
191
|
+
// ── Grant requests: a console grant that waits for a second administrator (ADR-0083) ───────
|
|
192
|
+
|
|
193
|
+
/** How long a grant request stays open for a decision. */
|
|
194
|
+
export const GRANT_REQUEST_TTL_SECONDS = 7 * 24 * 60 * 60
|
|
195
|
+
|
|
196
|
+
export const GRANT_REQUEST_KINDS = ['create', 'update', 'revoke'] as const
|
|
197
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number]
|
|
198
|
+
|
|
199
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
200
|
+
export const GRANT_REQUEST_STATUSES = ['pending', 'approved', 'rejected', 'failed', 'expired'] as const
|
|
201
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number]
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
205
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
206
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
207
|
+
*/
|
|
208
|
+
export interface GrantRequestDto {
|
|
209
|
+
id: string
|
|
210
|
+
app: string
|
|
211
|
+
kind: GrantRequestKind
|
|
212
|
+
principalId: string
|
|
213
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
214
|
+
principalLabel: string | null
|
|
215
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
216
|
+
grantId: string | null
|
|
217
|
+
roleKey: string | null
|
|
218
|
+
permissions: string[] | null
|
|
219
|
+
scopeType: string | null
|
|
220
|
+
/** The first requested value; `scopeValues` holds every one. */
|
|
221
|
+
scopeValue: string | null
|
|
222
|
+
/** Every requested value, sorted (ADR-0085); null for a global grant. */
|
|
223
|
+
scopeValues: string[] | null
|
|
224
|
+
/** The grant's own expiry; null for none. */
|
|
225
|
+
grantExpiresAt: number | null
|
|
226
|
+
requestedBy: string
|
|
227
|
+
requestedByLabel: string | null
|
|
228
|
+
requestedAt: number
|
|
229
|
+
/** When the request lapses without a decision. */
|
|
230
|
+
expiresAt: number
|
|
231
|
+
status: GrantRequestStatus
|
|
232
|
+
decidedBy: string | null
|
|
233
|
+
decidedAt: number | null
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
237
|
+
export interface PendingGrantChange {
|
|
238
|
+
pending: GrantRequestDto
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
242
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange
|
|
243
|
+
|
|
244
|
+
export interface ListGrantRequestsInput {
|
|
245
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
246
|
+
app?: string
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface DecideGrantRequestInput {
|
|
250
|
+
id: string
|
|
251
|
+
decision: 'approve' | 'reject'
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
|
|
256
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
|
|
257
|
+
*/
|
|
258
|
+
export interface SetGrantApprovalRequest {
|
|
259
|
+
app: string
|
|
260
|
+
required: boolean
|
|
261
|
+
revision: number
|
|
262
|
+
}
|
|
263
|
+
|
|
184
264
|
// ── Apps (read-only; the live registry derived from the schema tables) ────────
|
|
185
265
|
|
|
186
266
|
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
@@ -307,6 +387,8 @@ export interface ProvisionApiKeyRequest {
|
|
|
307
387
|
scopeType?: string | null
|
|
308
388
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
309
389
|
scopeValue?: string | null
|
|
390
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
391
|
+
scopeValues?: string[]
|
|
310
392
|
/** App id (a registered app id); null / omitted = all apps. */
|
|
311
393
|
app?: string | null
|
|
312
394
|
expiresAt?: number | null
|
|
@@ -694,8 +776,10 @@ export interface GrantAppRoleRequest {
|
|
|
694
776
|
export interface GrantAppRoleResponse {
|
|
695
777
|
principalId: string
|
|
696
778
|
role: string
|
|
697
|
-
/** False when the person held the role already. */
|
|
779
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
698
780
|
granted: boolean
|
|
781
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
782
|
+
pending?: GrantRequestDto
|
|
699
783
|
}
|
|
700
784
|
|
|
701
785
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
@@ -706,8 +790,10 @@ export interface RevokeAppRoleRequest {
|
|
|
706
790
|
}
|
|
707
791
|
|
|
708
792
|
export interface RevokeAppRoleResponse {
|
|
709
|
-
/** False when the person held no such grant. */
|
|
793
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
710
794
|
revoked: boolean
|
|
795
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
796
|
+
pending?: GrantRequestDto
|
|
711
797
|
}
|
|
712
798
|
|
|
713
799
|
/**
|
|
@@ -752,11 +838,28 @@ export interface IamAdminRpcContract {
|
|
|
752
838
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>
|
|
753
839
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>
|
|
754
840
|
}
|
|
841
|
+
/**
|
|
842
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
843
|
+
* with a grant request instead of changing anything.
|
|
844
|
+
*/
|
|
755
845
|
grants: {
|
|
756
846
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
757
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
758
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
759
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
847
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>
|
|
848
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>
|
|
849
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
853
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
854
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
855
|
+
*/
|
|
856
|
+
grantRequests: {
|
|
857
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>
|
|
858
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>
|
|
859
|
+
}
|
|
860
|
+
/** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
|
|
861
|
+
grantApproval: {
|
|
862
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>
|
|
760
863
|
}
|
|
761
864
|
connections: {
|
|
762
865
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>
|
package/src/oauth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isCimdClientId, isOAuthClientId, isOAuthResourceUri, parseOAuthScopes } from '@fabrika/auth-core'
|
|
1
|
+
import { BUILTIN_ROLE_KEYS, isCimdClientId, isOAuthClientId, isOAuthResourceUri, parseOAuthScopes } from '@fabrika/auth-core'
|
|
2
2
|
import type { KeyGrant } from '@fabrika/auth-core'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -14,13 +14,25 @@ function isOAuthClientProvider(value: unknown): value is OAuthClientProvider {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The one resource an identity-only client is served: its own, outside the installation. A token for it carries the
|
|
17
|
-
* person's identity and no permission, under `app`, an id no installation service or application holds.
|
|
17
|
+
* person's identity and no permission, under `app`, an id no installation service or application holds. With `roles`,
|
|
18
|
+
* the application's roles are IAM's to grant: the token names those the person holds there, and a person holding none
|
|
19
|
+
* is refused.
|
|
18
20
|
*/
|
|
19
21
|
export interface OAuthIdentityResource {
|
|
20
22
|
app: string
|
|
21
23
|
resource: string
|
|
24
|
+
roles?: OAuthIdentityRole[]
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
/** A role of an external application: IAM grants it and names it in the token; the application decides what it allows. */
|
|
28
|
+
export interface OAuthIdentityRole {
|
|
29
|
+
key: string
|
|
30
|
+
name: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** How many roles one external application declares. */
|
|
34
|
+
export const MAX_OAUTH_IDENTITY_ROLES = 32
|
|
35
|
+
|
|
24
36
|
/** The one scope of an identity resource: it names the person and grants nothing. */
|
|
25
37
|
export const OAUTH_IDENTITY_SCOPE = 'identity'
|
|
26
38
|
|
|
@@ -211,16 +223,37 @@ export function parseOAuthManagedClient(value: unknown): OAuthManagedClient | nu
|
|
|
211
223
|
return identity === null || provider !== 'external' ? null : { provider, clientId, redirectUris: uris, identity }
|
|
212
224
|
}
|
|
213
225
|
|
|
214
|
-
const IDENTITY_KEYS = ['app', 'resource']
|
|
226
|
+
const IDENTITY_KEYS = ['app', 'resource', 'roles']
|
|
227
|
+
const ROLE_KEYS = ['key', 'name']
|
|
215
228
|
/** An app id as every fabrika config writes one; no `@`, so never an application environment's id. */
|
|
216
229
|
const IDENTITY_APP = /^[a-z0-9][a-z0-9-]{0,62}$/
|
|
230
|
+
/** A role key; never a built-in one (`admin` means every action of an application). */
|
|
231
|
+
const IDENTITY_ROLE_KEY = /^[a-z0-9][a-z0-9-]{0,62}$/
|
|
217
232
|
|
|
218
233
|
function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null {
|
|
219
234
|
const app = field(value, 'app')
|
|
220
235
|
const resource = field(value, 'resource')
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
236
|
+
const rawRoles = field(value, 'roles')
|
|
237
|
+
if (!hasOnlyKeys(value, IDENTITY_KEYS) || typeof app !== 'string' || !IDENTITY_APP.test(app) || !isOAuthResourceUri(resource)) return null
|
|
238
|
+
if (rawRoles === undefined) return { app, resource }
|
|
239
|
+
const roles = parseOAuthIdentityRoles(rawRoles)
|
|
240
|
+
return roles === null ? null : { app, resource, roles }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parseOAuthIdentityRoles(value: unknown): OAuthIdentityRole[] | null {
|
|
244
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_OAUTH_IDENTITY_ROLES) return null
|
|
245
|
+
const roles: OAuthIdentityRole[] = []
|
|
246
|
+
for (const entry of value) {
|
|
247
|
+
const key = field(entry, 'key')
|
|
248
|
+
const name = field(entry, 'name')
|
|
249
|
+
if (
|
|
250
|
+
!hasOnlyKeys(entry, ROLE_KEYS) || typeof key !== 'string' || !IDENTITY_ROLE_KEY.test(key) || BUILTIN_ROLE_KEYS.includes(key)
|
|
251
|
+
|| !isNonemptyText(name)
|
|
252
|
+
|| name.length > 100 || roles.some((role) => role.key === key)
|
|
253
|
+
) return null
|
|
254
|
+
roles.push({ key, name })
|
|
255
|
+
}
|
|
256
|
+
return roles
|
|
224
257
|
}
|
|
225
258
|
|
|
226
259
|
/** The scopes an identity resource's authorization asks for: none, or exactly `identity`. */
|
package/types/src/index.d.ts
CHANGED
|
@@ -36,8 +36,10 @@ export interface GrantDto {
|
|
|
36
36
|
permissions: string[] | null;
|
|
37
37
|
/** Scope dimension; null = global (both rise/fall together). */
|
|
38
38
|
scopeType: string | null;
|
|
39
|
-
/** Opaque, app-owned scope value; null = global. */
|
|
39
|
+
/** Opaque, app-owned scope value; null = global. The first of `scopeValues` (ADR-0085). */
|
|
40
40
|
scopeValue: string | null;
|
|
41
|
+
/** Every value of `scopeType` the grant holds, sorted; null = global. A grant of one value lists one. */
|
|
42
|
+
scopeValues: string[] | null;
|
|
41
43
|
/** App id this grant applies to; null = all apps (cross-app). */
|
|
42
44
|
app: string | null;
|
|
43
45
|
grantedBy: string | null;
|
|
@@ -127,6 +129,8 @@ export interface SessionList extends CursorList<SessionDto> {
|
|
|
127
129
|
/** App sessions belonging to the sign-ins on this page, when `signInsOnly` is requested. */
|
|
128
130
|
applications: SessionDto[];
|
|
129
131
|
}
|
|
132
|
+
/** The most scope values one grant holds (ADR-0085). */
|
|
133
|
+
export declare const MAX_GRANT_SCOPE_VALUES = 100;
|
|
130
134
|
export interface CreateGrantRequest {
|
|
131
135
|
principalId: string;
|
|
132
136
|
/** A named role/policy key — XOR `permissions` (supply exactly one). */
|
|
@@ -137,6 +141,8 @@ export interface CreateGrantRequest {
|
|
|
137
141
|
scopeType?: string | null;
|
|
138
142
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
139
143
|
scopeValue?: string | null;
|
|
144
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
145
|
+
scopeValues?: string[];
|
|
140
146
|
/** App id (a registered app id); null / omitted = all apps (cross-app). */
|
|
141
147
|
app?: string | null;
|
|
142
148
|
expiresAt?: number | null;
|
|
@@ -145,6 +151,68 @@ export interface CreateGrantRequest {
|
|
|
145
151
|
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
|
|
146
152
|
id: string;
|
|
147
153
|
}
|
|
154
|
+
/** How long a grant request stays open for a decision. */
|
|
155
|
+
export declare const GRANT_REQUEST_TTL_SECONDS: number;
|
|
156
|
+
export declare const GRANT_REQUEST_KINDS: readonly ["create", "update", "revoke"];
|
|
157
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number];
|
|
158
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
159
|
+
export declare const GRANT_REQUEST_STATUSES: readonly ["pending", "approved", "rejected", "failed", "expired"];
|
|
160
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number];
|
|
161
|
+
/**
|
|
162
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
163
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
164
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
165
|
+
*/
|
|
166
|
+
export interface GrantRequestDto {
|
|
167
|
+
id: string;
|
|
168
|
+
app: string;
|
|
169
|
+
kind: GrantRequestKind;
|
|
170
|
+
principalId: string;
|
|
171
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
172
|
+
principalLabel: string | null;
|
|
173
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
174
|
+
grantId: string | null;
|
|
175
|
+
roleKey: string | null;
|
|
176
|
+
permissions: string[] | null;
|
|
177
|
+
scopeType: string | null;
|
|
178
|
+
/** The first requested value; `scopeValues` holds every one. */
|
|
179
|
+
scopeValue: string | null;
|
|
180
|
+
/** Every requested value, sorted (ADR-0085); null for a global grant. */
|
|
181
|
+
scopeValues: string[] | null;
|
|
182
|
+
/** The grant's own expiry; null for none. */
|
|
183
|
+
grantExpiresAt: number | null;
|
|
184
|
+
requestedBy: string;
|
|
185
|
+
requestedByLabel: string | null;
|
|
186
|
+
requestedAt: number;
|
|
187
|
+
/** When the request lapses without a decision. */
|
|
188
|
+
expiresAt: number;
|
|
189
|
+
status: GrantRequestStatus;
|
|
190
|
+
decidedBy: string | null;
|
|
191
|
+
decidedAt: number | null;
|
|
192
|
+
}
|
|
193
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
194
|
+
export interface PendingGrantChange {
|
|
195
|
+
pending: GrantRequestDto;
|
|
196
|
+
}
|
|
197
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
198
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange;
|
|
199
|
+
export interface ListGrantRequestsInput {
|
|
200
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
201
|
+
app?: string;
|
|
202
|
+
}
|
|
203
|
+
export interface DecideGrantRequestInput {
|
|
204
|
+
id: string;
|
|
205
|
+
decision: 'approve' | 'reject';
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
|
|
209
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
|
|
210
|
+
*/
|
|
211
|
+
export interface SetGrantApprovalRequest {
|
|
212
|
+
app: string;
|
|
213
|
+
required: boolean;
|
|
214
|
+
revision: number;
|
|
215
|
+
}
|
|
148
216
|
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
149
217
|
export interface AppDto {
|
|
150
218
|
id: string;
|
|
@@ -254,6 +322,8 @@ export interface ProvisionApiKeyRequest {
|
|
|
254
322
|
scopeType?: string | null;
|
|
255
323
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
256
324
|
scopeValue?: string | null;
|
|
325
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
326
|
+
scopeValues?: string[];
|
|
257
327
|
/** App id (a registered app id); null / omitted = all apps. */
|
|
258
328
|
app?: string | null;
|
|
259
329
|
expiresAt?: number | null;
|
|
@@ -599,8 +669,10 @@ export interface GrantAppRoleRequest {
|
|
|
599
669
|
export interface GrantAppRoleResponse {
|
|
600
670
|
principalId: string;
|
|
601
671
|
role: string;
|
|
602
|
-
/** False when the person held the role already. */
|
|
672
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
603
673
|
granted: boolean;
|
|
674
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
675
|
+
pending?: GrantRequestDto;
|
|
604
676
|
}
|
|
605
677
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
606
678
|
export interface RevokeAppRoleRequest {
|
|
@@ -609,8 +681,10 @@ export interface RevokeAppRoleRequest {
|
|
|
609
681
|
principalId: string;
|
|
610
682
|
}
|
|
611
683
|
export interface RevokeAppRoleResponse {
|
|
612
|
-
/** False when the person held no such grant. */
|
|
684
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
613
685
|
revoked: boolean;
|
|
686
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
687
|
+
pending?: GrantRequestDto;
|
|
614
688
|
}
|
|
615
689
|
/**
|
|
616
690
|
* The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
|
|
@@ -652,11 +726,28 @@ export interface IamAdminRpcContract {
|
|
|
652
726
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>;
|
|
653
727
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>;
|
|
654
728
|
};
|
|
729
|
+
/**
|
|
730
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
731
|
+
* with a grant request instead of changing anything.
|
|
732
|
+
*/
|
|
655
733
|
grants: {
|
|
656
734
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
657
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
658
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
659
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
735
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>;
|
|
736
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>;
|
|
737
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>;
|
|
738
|
+
};
|
|
739
|
+
/**
|
|
740
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
741
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
742
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
743
|
+
*/
|
|
744
|
+
grantRequests: {
|
|
745
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>;
|
|
746
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>;
|
|
747
|
+
};
|
|
748
|
+
/** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
|
|
749
|
+
grantApproval: {
|
|
750
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>;
|
|
660
751
|
};
|
|
661
752
|
connections: {
|
|
662
753
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>;
|
package/types/src/oauth.d.ts
CHANGED
|
@@ -7,12 +7,22 @@ export declare const OAUTH_CLIENT_PROVIDERS: readonly ["claude", "chatgpt", "ext
|
|
|
7
7
|
export type OAuthClientProvider = (typeof OAUTH_CLIENT_PROVIDERS)[number];
|
|
8
8
|
/**
|
|
9
9
|
* The one resource an identity-only client is served: its own, outside the installation. A token for it carries the
|
|
10
|
-
* person's identity and no permission, under `app`, an id no installation service or application holds.
|
|
10
|
+
* person's identity and no permission, under `app`, an id no installation service or application holds. With `roles`,
|
|
11
|
+
* the application's roles are IAM's to grant: the token names those the person holds there, and a person holding none
|
|
12
|
+
* is refused.
|
|
11
13
|
*/
|
|
12
14
|
export interface OAuthIdentityResource {
|
|
13
15
|
app: string;
|
|
14
16
|
resource: string;
|
|
17
|
+
roles?: OAuthIdentityRole[];
|
|
15
18
|
}
|
|
19
|
+
/** A role of an external application: IAM grants it and names it in the token; the application decides what it allows. */
|
|
20
|
+
export interface OAuthIdentityRole {
|
|
21
|
+
key: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/** How many roles one external application declares. */
|
|
25
|
+
export declare const MAX_OAUTH_IDENTITY_ROLES = 32;
|
|
16
26
|
/** The one scope of an identity resource: it names the person and grants nothing. */
|
|
17
27
|
export declare const OAUTH_IDENTITY_SCOPE = "identity";
|
|
18
28
|
/** Managed CIMD registrations only; public dynamic registration is not part of this contract. */
|