@fabrika/iam-contract 0.9.0-dev.5 → 0.9.0-dev.50
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 +7 -5
- package/src/index.ts +297 -12
- package/src/oauth-registry.ts +68 -0
- package/src/oauth.ts +251 -17
- package/src/passkeys.ts +144 -0
- package/src/password-policy.ts +1 -1
- package/src/requested-keys.ts +71 -0
- package/src/scim.ts +19 -0
- package/types/src/index.d.ts +253 -13
- package/types/src/oauth-registry.d.ts +60 -0
- package/types/src/oauth.d.ts +103 -6
- package/types/src/passkeys.d.ts +131 -0
- package/types/src/password-policy.d.ts +1 -1
- package/types/src/requested-keys.d.ts +61 -0
- package/types/src/scim.d.ts +15 -0
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.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"src",
|
|
15
|
+
"!src/**/__tests__/**",
|
|
15
16
|
"types"
|
|
16
17
|
],
|
|
17
18
|
"exports": {
|
|
@@ -22,11 +23,12 @@
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
25
|
-
"typecheck": "
|
|
26
|
+
"typecheck": "tsrs --build tsconfig.test.json",
|
|
27
|
+
"test": "bun test"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@fabrika/app": "0.9.0-dev.
|
|
29
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
30
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.50",
|
|
31
|
+
"@fabrika/auth-core": "0.9.0-dev.50",
|
|
32
|
+
"@fabrika/proxy-core": "0.9.0-dev.50"
|
|
31
33
|
}
|
|
32
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
AppMemberItem,
|
|
17
17
|
AppSchema,
|
|
18
18
|
AppScopeDef,
|
|
19
|
+
DimensionValue,
|
|
19
20
|
Locale,
|
|
20
21
|
PermissionEntry,
|
|
21
22
|
PermissionSource,
|
|
@@ -25,7 +26,25 @@ import type {
|
|
|
25
26
|
WorkloadKind,
|
|
26
27
|
} from '@fabrika/auth-core'
|
|
27
28
|
import type { InstallationBrand } from '@fabrika/proxy-core/brand'
|
|
29
|
+
import type {
|
|
30
|
+
ExternalAppDto,
|
|
31
|
+
ExternalAppInput,
|
|
32
|
+
OAuthClientDto,
|
|
33
|
+
OAuthClientInput,
|
|
34
|
+
PutExternalAppRequest,
|
|
35
|
+
PutOAuthClientRequest,
|
|
36
|
+
} from './oauth-registry'
|
|
37
|
+
import type {
|
|
38
|
+
IssuePasskeyChallengeRequest,
|
|
39
|
+
PasskeyDto,
|
|
40
|
+
PasskeyResetResponse,
|
|
41
|
+
PasskeyStepUpChallenge,
|
|
42
|
+
VerifiedPasskeyAssertion,
|
|
43
|
+
VerifyPasskeyAssertionRequest,
|
|
44
|
+
} from './passkeys'
|
|
28
45
|
import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy'
|
|
46
|
+
import type { ProvisionRequestedApiKeyRequest, RequestedApiKey, RequestedApiKeyInput, RequestedApiKeyResponse } from './requested-keys'
|
|
47
|
+
import type { ScimSettingsDto, ScimTokenIssuedDto } from './scim'
|
|
29
48
|
|
|
30
49
|
// ── Common wrappers ───────────────────────────────────────────────────────────
|
|
31
50
|
|
|
@@ -69,8 +88,10 @@ export interface GrantDto {
|
|
|
69
88
|
permissions: string[] | null
|
|
70
89
|
/** Scope dimension; null = global (both rise/fall together). */
|
|
71
90
|
scopeType: string | null
|
|
72
|
-
/** Opaque, app-owned scope value; null = global. */
|
|
91
|
+
/** Opaque, app-owned scope value; null = global. The first of `scopeValues` (ADR-0085). */
|
|
73
92
|
scopeValue: string | null
|
|
93
|
+
/** Every value of `scopeType` the grant holds, sorted; null = global. A grant of one value lists one. */
|
|
94
|
+
scopeValues: string[] | null
|
|
74
95
|
/** App id this grant applies to; null = all apps (cross-app). */
|
|
75
96
|
app: string | null
|
|
76
97
|
grantedBy: string | null
|
|
@@ -161,6 +182,9 @@ export interface SessionList extends CursorList<SessionDto> {
|
|
|
161
182
|
|
|
162
183
|
// ── Grants ────────────────────────────────────────────────────────────────────
|
|
163
184
|
|
|
185
|
+
/** The most scope values one grant holds (ADR-0085). */
|
|
186
|
+
export const MAX_GRANT_SCOPE_VALUES = 100
|
|
187
|
+
|
|
164
188
|
export interface CreateGrantRequest {
|
|
165
189
|
principalId: string
|
|
166
190
|
/** A named role/policy key — XOR `permissions` (supply exactly one). */
|
|
@@ -171,25 +195,135 @@ export interface CreateGrantRequest {
|
|
|
171
195
|
scopeType?: string | null
|
|
172
196
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
173
197
|
scopeValue?: string | null
|
|
198
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
199
|
+
scopeValues?: string[]
|
|
174
200
|
/** App id (a registered app id); null / omitted = all apps (cross-app). */
|
|
175
201
|
app?: string | null
|
|
176
202
|
expiresAt?: number | null
|
|
203
|
+
/**
|
|
204
|
+
* The approval request in Control this grant carries out (ADR-0083 §8): an agent's grant, approved by the caller.
|
|
205
|
+
* IAM records it in the change's audit row, and in its grant request's where the application's grants wait. It is
|
|
206
|
+
* the caller's statement, recorded under the caller; it authorizes nothing.
|
|
207
|
+
*/
|
|
208
|
+
approvalRequest?: GrantApprovalRequestRef
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The Control approval request a console grant carries out, and who asked for it. IAM refuses ids over 200 characters, a
|
|
213
|
+
* label over 500 and a client id over 2048.
|
|
214
|
+
*/
|
|
215
|
+
export interface GrantApprovalRequestRef {
|
|
216
|
+
id: string
|
|
217
|
+
requester: { id: string; label: string; clientId?: string }
|
|
177
218
|
}
|
|
178
219
|
|
|
179
220
|
/** Change access within its original application, preserving the grant's identity and author. */
|
|
180
|
-
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
|
|
221
|
+
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app' | 'approvalRequest'> {
|
|
181
222
|
id: string
|
|
182
223
|
}
|
|
183
224
|
|
|
225
|
+
// ── Grant requests: a console grant that waits for a second administrator (ADR-0083) ───────
|
|
226
|
+
|
|
227
|
+
/** How long a grant request stays open for a decision. */
|
|
228
|
+
export const GRANT_REQUEST_TTL_SECONDS = 7 * 24 * 60 * 60
|
|
229
|
+
|
|
230
|
+
export const GRANT_REQUEST_KINDS = ['create', 'update', 'revoke'] as const
|
|
231
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number]
|
|
232
|
+
|
|
233
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
234
|
+
export const GRANT_REQUEST_STATUSES = ['pending', 'approved', 'rejected', 'failed', 'expired'] as const
|
|
235
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number]
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
239
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
240
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
241
|
+
*/
|
|
242
|
+
export interface GrantRequestDto {
|
|
243
|
+
id: string
|
|
244
|
+
app: string
|
|
245
|
+
kind: GrantRequestKind
|
|
246
|
+
principalId: string
|
|
247
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
248
|
+
principalLabel: string | null
|
|
249
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
250
|
+
grantId: string | null
|
|
251
|
+
roleKey: string | null
|
|
252
|
+
permissions: string[] | null
|
|
253
|
+
scopeType: string | null
|
|
254
|
+
/** The first requested value; `scopeValues` holds every one. */
|
|
255
|
+
scopeValue: string | null
|
|
256
|
+
/** Every requested value, sorted (ADR-0085); null for a global grant. */
|
|
257
|
+
scopeValues: string[] | null
|
|
258
|
+
/** The grant's own expiry; null for none. */
|
|
259
|
+
grantExpiresAt: number | null
|
|
260
|
+
requestedBy: string
|
|
261
|
+
requestedByLabel: string | null
|
|
262
|
+
requestedAt: number
|
|
263
|
+
/** When the request lapses without a decision. */
|
|
264
|
+
expiresAt: number
|
|
265
|
+
status: GrantRequestStatus
|
|
266
|
+
decidedBy: string | null
|
|
267
|
+
decidedAt: number | null
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
271
|
+
export interface PendingGrantChange {
|
|
272
|
+
pending: GrantRequestDto
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
276
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange
|
|
277
|
+
|
|
278
|
+
export interface ListGrantRequestsInput {
|
|
279
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
280
|
+
app?: string
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface DecideGrantRequestInput {
|
|
284
|
+
id: string
|
|
285
|
+
decision: 'approve' | 'reject'
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** An environment's `credentials` mode as IAM keeps it for its own key issuance to a machine caller (ADR-0083 §8). */
|
|
289
|
+
export const CREDENTIALS_MODES = ['off', 'person', 'refuse'] as const
|
|
290
|
+
|
|
291
|
+
export type CredentialsMode = (typeof CREDENTIALS_MODES)[number]
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* What an environment does with an agent's `write` grant (ADR-0090 §5), as Control mirrors its `agent-write` category:
|
|
295
|
+
* `open` serves it, `passkey` serves it when the approving person confirms with a passkey, `refuse` never serves it.
|
|
296
|
+
*/
|
|
297
|
+
export const AGENT_WRITE_GATES = ['open', 'passkey', 'refuse'] as const
|
|
298
|
+
|
|
299
|
+
export type AgentWriteGate = (typeof AGENT_WRITE_GATES)[number]
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Control's mirror of an application environment's approval gates in IAM, set with the provisioning key (ADR-0083 §4,
|
|
303
|
+
* §8, ADR-0090 §5): whether its console grants wait (`required`), its `credentials` mode and its `agentWrite` gate.
|
|
304
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds. A
|
|
305
|
+
* request without `credentials` (an older Control's) clears IAM's mode, which then reads as `person`; one without
|
|
306
|
+
* `agentWrite` clears that gate, which then reads as `refuse`.
|
|
307
|
+
*/
|
|
308
|
+
export interface SetGrantApprovalRequest {
|
|
309
|
+
app: string
|
|
310
|
+
required: boolean
|
|
311
|
+
revision: number
|
|
312
|
+
credentials?: CredentialsMode
|
|
313
|
+
agentWrite?: AgentWriteGate
|
|
314
|
+
}
|
|
315
|
+
|
|
184
316
|
// ── Apps (read-only; the live registry derived from the schema tables) ────────
|
|
185
317
|
|
|
186
|
-
/** The set of app ids
|
|
318
|
+
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
187
319
|
export interface AppDto {
|
|
188
320
|
id: string
|
|
189
321
|
/** The name the app's schema declares for people; null when it declares none. */
|
|
190
322
|
displayName: string | null
|
|
191
323
|
/** One of the installation's own apps (a platform audience): a user administrator grants nothing there (ADR-0058). */
|
|
192
324
|
installation: boolean
|
|
325
|
+
/** Registered in IAM as an external application (ADR-0089): it has no deploy target, only roles and OAuth clients. */
|
|
326
|
+
externalApplication: boolean
|
|
193
327
|
}
|
|
194
328
|
|
|
195
329
|
// ── Roles & policies (per-app, DB-backed) ─────────────────────────────────────
|
|
@@ -271,7 +405,7 @@ export interface ApiKeyDto {
|
|
|
271
405
|
|
|
272
406
|
/**
|
|
273
407
|
* One API key with its live credential, as `apiKeys.get` and each row of `apiKeys.list` answer it. Its permissions are
|
|
274
|
-
* its grants, edited with `grants.create` and `grants.delete` by an installation administrator and read again at every
|
|
408
|
+
* its grants, edited with `grants.create`, `grants.update` and `grants.delete` by an installation administrator and read again at every
|
|
275
409
|
* token exchange. An IAM older than the list's credential answers list rows without `credential`.
|
|
276
410
|
*/
|
|
277
411
|
export interface ApiKeyDetail extends ApiKeyDto {
|
|
@@ -279,6 +413,17 @@ export interface ApiKeyDetail extends ApiKeyDto {
|
|
|
279
413
|
credential: ApiKeyCredentialDto | null
|
|
280
414
|
}
|
|
281
415
|
|
|
416
|
+
/** A grant of `apiKeys.get`'s key, naming who granted it. */
|
|
417
|
+
export interface ApiKeyGrantDto extends GrantDto {
|
|
418
|
+
/** The granting principal's label, or its id when IAM no longer knows it; null when nobody granted it. */
|
|
419
|
+
grantedByLabel: string | null
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** `apiKeys.get`: one key whose grants name who granted them. */
|
|
423
|
+
export interface GetApiKeyResponse extends ApiKeyDetail {
|
|
424
|
+
grants: ApiKeyGrantDto[]
|
|
425
|
+
}
|
|
426
|
+
|
|
282
427
|
export interface ApiKeyCredentialDto {
|
|
283
428
|
/** The app the key mints tokens for; null = every app. A grant at another app never reaches the key's token. */
|
|
284
429
|
app: string | null
|
|
@@ -296,6 +441,8 @@ export interface ProvisionApiKeyRequest {
|
|
|
296
441
|
scopeType?: string | null
|
|
297
442
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
298
443
|
scopeValue?: string | null
|
|
444
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
445
|
+
scopeValues?: string[]
|
|
299
446
|
/** App id (a registered app id); null / omitted = all apps. */
|
|
300
447
|
app?: string | null
|
|
301
448
|
expiresAt?: number | null
|
|
@@ -304,7 +451,7 @@ export interface ProvisionApiKeyRequest {
|
|
|
304
451
|
/**
|
|
305
452
|
* Provisioning result. `apiKey` (a `px_…` credential bound to the new service principal) is shown
|
|
306
453
|
* exactly ONCE — copy it now, it is not retrievable later. Carried as a bearer (or a declared
|
|
307
|
-
* header) directly to apps on the
|
|
454
|
+
* header) directly to apps on the IAM-native path (`mintFromKey`), no Cloudflare Access in
|
|
308
455
|
* front.
|
|
309
456
|
*/
|
|
310
457
|
export interface ProvisionApiKeyResponse {
|
|
@@ -465,6 +612,28 @@ export interface AppInput {
|
|
|
465
612
|
app: string
|
|
466
613
|
}
|
|
467
614
|
|
|
615
|
+
// ── Live scope values (ADR-0085 §4) ────────────────────────────────────────────
|
|
616
|
+
|
|
617
|
+
export interface ListScopeValuesInput {
|
|
618
|
+
/** The application id, `<app>@<env>`. */
|
|
619
|
+
app: string
|
|
620
|
+
/** The dimension whose values the console offers. */
|
|
621
|
+
scopeType: string
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Why the application's own list is not there, so the console falls back to the listed values or free text:
|
|
626
|
+
* `no_source` (the dimension names no procedure), `not_held` (the administrator holds the procedure's action nowhere at
|
|
627
|
+
* the application), `no_origin` (IAM knows no address of it), `refused` (its proxy or the application answered
|
|
628
|
+
* 401/403/404), `timeout`, `unreachable` (any other failure to answer) or `malformed` (an answer that is no list).
|
|
629
|
+
*/
|
|
630
|
+
export type ScopeValuesUnavailable = 'no_source' | 'not_held' | 'no_origin' | 'refused' | 'timeout' | 'unreachable' | 'malformed'
|
|
631
|
+
|
|
632
|
+
/** What the application answered as the administrator, or why it could not be asked. Information, never a check. */
|
|
633
|
+
export type ScopeValuesResult =
|
|
634
|
+
| { source: 'application'; values: DimensionValue[] }
|
|
635
|
+
| { source: 'unavailable'; reason: ScopeValuesUnavailable }
|
|
636
|
+
|
|
468
637
|
/**
|
|
469
638
|
* The public origins IAM will hand this app a session at (ADR-0022). Declarative: the whole set is
|
|
470
639
|
* stated, so removing one is the same call as adding one and a stale entry cannot survive a deploy.
|
|
@@ -683,8 +852,10 @@ export interface GrantAppRoleRequest {
|
|
|
683
852
|
export interface GrantAppRoleResponse {
|
|
684
853
|
principalId: string
|
|
685
854
|
role: string
|
|
686
|
-
/** False when the person held the role already. */
|
|
855
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
687
856
|
granted: boolean
|
|
857
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
858
|
+
pending?: GrantRequestDto
|
|
688
859
|
}
|
|
689
860
|
|
|
690
861
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
@@ -695,8 +866,10 @@ export interface RevokeAppRoleRequest {
|
|
|
695
866
|
}
|
|
696
867
|
|
|
697
868
|
export interface RevokeAppRoleResponse {
|
|
698
|
-
/** False when the person held no such grant. */
|
|
869
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
699
870
|
revoked: boolean
|
|
871
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
872
|
+
pending?: GrantRequestDto
|
|
700
873
|
}
|
|
701
874
|
|
|
702
875
|
/**
|
|
@@ -741,16 +914,37 @@ export interface IamAdminRpcContract {
|
|
|
741
914
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>
|
|
742
915
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>
|
|
743
916
|
}
|
|
917
|
+
/**
|
|
918
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
919
|
+
* with a grant request instead of changing anything.
|
|
920
|
+
*/
|
|
744
921
|
grants: {
|
|
745
922
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
746
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
747
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
748
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
923
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>
|
|
924
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>
|
|
925
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
929
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
930
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
931
|
+
*/
|
|
932
|
+
grantRequests: {
|
|
933
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>
|
|
934
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>
|
|
935
|
+
}
|
|
936
|
+
/** An application environment's approval gates in IAM: the provisioning key's alone, which Control holds. */
|
|
937
|
+
grantApproval: {
|
|
938
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>
|
|
749
939
|
}
|
|
750
940
|
connections: {
|
|
751
941
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>
|
|
752
942
|
revoke: RpcProcedure<GrantIdInput, OkResponse>
|
|
753
943
|
}
|
|
944
|
+
/** A dimension's values, asked of the application as the signed-in administrator (ADR-0085 §4). */
|
|
945
|
+
scopeValues: {
|
|
946
|
+
list: RpcProcedure<ListScopeValuesInput, ScopeValuesResult>
|
|
947
|
+
}
|
|
754
948
|
apps: {
|
|
755
949
|
list: RpcProcedure<void, ListResponse<AppDto>>
|
|
756
950
|
getSchema: RpcProcedure<AppInput, AppSchemaDto>
|
|
@@ -759,6 +953,26 @@ export interface IamAdminRpcContract {
|
|
|
759
953
|
roles: {
|
|
760
954
|
list: RpcProcedure<ListRolesInput, ListResponse<RoleDto>>
|
|
761
955
|
}
|
|
956
|
+
/**
|
|
957
|
+
* Applications outside the installation that sign people in through IAM (ADR-0089), an installation administrator's
|
|
958
|
+
* (`iam.admin`). `put` replaces the whole application, its roles and its clients in one transaction; removing a client
|
|
959
|
+
* or the application revokes its OAuth grants there.
|
|
960
|
+
*/
|
|
961
|
+
externalApps: {
|
|
962
|
+
list: RpcProcedure<void, ListResponse<ExternalAppDto>>
|
|
963
|
+
get: RpcProcedure<ExternalAppInput, ExternalAppDto>
|
|
964
|
+
put: RpcProcedure<PutExternalAppRequest, ExternalAppDto>
|
|
965
|
+
delete: RpcProcedure<ExternalAppInput, OkResponse>
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Every registered OAuth client, listed for an installation administrator. An MCP authoring client is written with
|
|
969
|
+
* the provisioning key only; a client of an external application only through `externalApps.put`.
|
|
970
|
+
*/
|
|
971
|
+
oauthClients: {
|
|
972
|
+
list: RpcProcedure<void, ListResponse<OAuthClientDto>>
|
|
973
|
+
put: RpcProcedure<PutOAuthClientRequest, OAuthClientDto>
|
|
974
|
+
delete: RpcProcedure<OAuthClientInput, OkResponse>
|
|
975
|
+
}
|
|
762
976
|
policies: {
|
|
763
977
|
list: RpcProcedure<AppInput, ListResponse<PolicyDto>>
|
|
764
978
|
create: RpcProcedure<CreatePolicyInput, PolicyDto>
|
|
@@ -767,8 +981,15 @@ export interface IamAdminRpcContract {
|
|
|
767
981
|
}
|
|
768
982
|
apiKeys: {
|
|
769
983
|
list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>
|
|
770
|
-
get: RpcProcedure<ApiKeyIdInput,
|
|
984
|
+
get: RpcProcedure<ApiKeyIdInput, GetApiKeyResponse>
|
|
771
985
|
provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>
|
|
986
|
+
/**
|
|
987
|
+
* A key a person approved in Control for the agent that asked (ADR-0083 §8): a person in a signed-in session only,
|
|
988
|
+
* idempotent by the approval request's id, answered encrypted to the agent's public key.
|
|
989
|
+
*/
|
|
990
|
+
provisionRequested: RpcProcedure<ProvisionRequestedApiKeyRequest, RequestedApiKey>
|
|
991
|
+
/** The key an approval request issued, by its id: how Control follows an execution whose outcome it did not see. */
|
|
992
|
+
requested: RpcProcedure<RequestedApiKeyInput, RequestedApiKeyResponse>
|
|
772
993
|
rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>
|
|
773
994
|
revoke: RpcProcedure<ApiKeyIdInput, OkResponse>
|
|
774
995
|
}
|
|
@@ -826,6 +1047,55 @@ export interface IamAdminRpcContract {
|
|
|
826
1047
|
get: RpcProcedure<void, PasswordPolicyDto>
|
|
827
1048
|
set: RpcProcedure<SetPasswordPolicyRequest, PasswordPolicyDto>
|
|
828
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* SCIM provisioning by the organization's identity provider (ADR-0091), an installation administrator's in a signed-in
|
|
1052
|
+
* session. `rotateToken` creates the installation's one token or replaces it (the old one stops working at once) and
|
|
1053
|
+
* answers the secret once; `revokeToken` removes it, after which every SCIM request is refused. Each writes
|
|
1054
|
+
* `iam.scim.token.rotate` or `iam.scim.token.revoke`.
|
|
1055
|
+
*/
|
|
1056
|
+
scim: {
|
|
1057
|
+
get: RpcProcedure<void, ScimSettingsDto>
|
|
1058
|
+
rotateToken: RpcProcedure<void, ScimTokenIssuedDto>
|
|
1059
|
+
revokeToken: RpcProcedure<void, ScimSettingsDto>
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* A person's second factor (TOTP), an installation administrator's (`iam.admin`) to read and to reset. The person
|
|
1063
|
+
* enrols at IAM's `SECOND_FACTOR_ENROL_PATH`, never here. A reset removes the authenticator and its recovery codes
|
|
1064
|
+
* and writes `iam.second_factor.reset`; the next sign-in asks for no code.
|
|
1065
|
+
*/
|
|
1066
|
+
secondFactor: {
|
|
1067
|
+
get: RpcProcedure<PrincipalIdInput, SecondFactorDto>
|
|
1068
|
+
reset: RpcProcedure<PrincipalIdInput, SecondFactorDto>
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* A person's passkeys. A person registers and removes their own on IAM's account page (`ACCOUNT_PAGE_PATH`).
|
|
1072
|
+
* `challenge` and `verify` are the step-up seam, for a person in a signed-in session, never a `px_` key: a challenge
|
|
1073
|
+
* bound to an opaque string, which the person answers on IAM's page at its `url`, and its verification against the
|
|
1074
|
+
* same string. `listOf` and `reset` are an installation administrator's (`iam.admin`); the reset removes every
|
|
1075
|
+
* passkey and writes `iam.passkey.reset`.
|
|
1076
|
+
*/
|
|
1077
|
+
passkeys: {
|
|
1078
|
+
challenge: RpcProcedure<IssuePasskeyChallengeRequest, PasskeyStepUpChallenge>
|
|
1079
|
+
verify: RpcProcedure<VerifyPasskeyAssertionRequest, VerifiedPasskeyAssertion>
|
|
1080
|
+
listOf: RpcProcedure<PrincipalIdInput, ListResponse<PasskeyDto>>
|
|
1081
|
+
reset: RpcProcedure<PrincipalIdInput, PasskeyResetResponse>
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/** The signed-in person's own page on IAM's origin: their connections and their passkeys. */
|
|
1086
|
+
export const ACCOUNT_PAGE_PATH = '/auth/account'
|
|
1087
|
+
|
|
1088
|
+
/** Where a signed-in administrator enrols an authenticator app, on IAM's own origin. */
|
|
1089
|
+
export const SECOND_FACTOR_ENROL_PATH = '/auth/second-factor/enrol'
|
|
1090
|
+
|
|
1091
|
+
/** A person's second factor as an installation administrator sees it. */
|
|
1092
|
+
export interface SecondFactorDto {
|
|
1093
|
+
/** When the person confirmed the authenticator, in epoch seconds; null when none is enrolled. */
|
|
1094
|
+
enrolledAt: number | null
|
|
1095
|
+
/** Recovery codes not used yet; 0 without an authenticator. */
|
|
1096
|
+
recoveryCodesLeft: number
|
|
1097
|
+
/** Whether this installation can enrol an authenticator at all: it holds the key that seals the secrets. */
|
|
1098
|
+
available: boolean
|
|
829
1099
|
}
|
|
830
1100
|
|
|
831
1101
|
export interface UserConnectionDto {
|
|
@@ -839,7 +1109,22 @@ export interface UserConnectionDto {
|
|
|
839
1109
|
status: 'active' | 'revoked' | 'expired' | 'unavailable'
|
|
840
1110
|
}
|
|
841
1111
|
|
|
842
|
-
export type {
|
|
1112
|
+
export type {
|
|
1113
|
+
AppActionDef,
|
|
1114
|
+
AppMemberItem,
|
|
1115
|
+
AppSchema,
|
|
1116
|
+
AppScopeDef,
|
|
1117
|
+
DimensionValue,
|
|
1118
|
+
PermissionEntry,
|
|
1119
|
+
PermissionSource,
|
|
1120
|
+
PrincipalAffiliation,
|
|
1121
|
+
PrincipalType,
|
|
1122
|
+
RoleDef,
|
|
1123
|
+
}
|
|
843
1124
|
export * from './access'
|
|
844
1125
|
export * from './oauth'
|
|
1126
|
+
export * from './oauth-registry'
|
|
1127
|
+
export * from './passkeys'
|
|
845
1128
|
export * from './password-policy'
|
|
1129
|
+
export * from './requested-keys'
|
|
1130
|
+
export * from './scim'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The OAuth clients IAM serves and the external applications they sign people in to (ADR-0089). An installation
|
|
2
|
+
// administrator registers an external application with its roles and clients; the operator, with the provisioning key,
|
|
3
|
+
// registers an MCP authoring client. IAM checks every write; the console reads these shapes only to show them.
|
|
4
|
+
|
|
5
|
+
import type { OAuthClientProvider, OAuthIdentityRole } from './oauth'
|
|
6
|
+
|
|
7
|
+
/** How many clients one external application has. */
|
|
8
|
+
export const MAX_EXTERNAL_APP_CLIENTS = 16
|
|
9
|
+
|
|
10
|
+
/** One client of an external application: its client id, its exact redirect URIs and where IAM fetches its document. */
|
|
11
|
+
export interface ExternalAppClient {
|
|
12
|
+
clientId: string
|
|
13
|
+
redirectUris: string[]
|
|
14
|
+
/** Where IAM fetches the Client ID Metadata Document when it is not the client id itself. */
|
|
15
|
+
metadataUrl?: string | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An external application as a whole: an app id with no deploy target, its identity resource, its display name, its
|
|
20
|
+
* roles (each granting no action) and its clients. `externalApps.put` replaces all of it at once.
|
|
21
|
+
*/
|
|
22
|
+
export interface PutExternalAppRequest {
|
|
23
|
+
app: string
|
|
24
|
+
name: string
|
|
25
|
+
resource: string
|
|
26
|
+
/** Absent, null or empty: no roles, and every active user signs in. */
|
|
27
|
+
roles?: OAuthIdentityRole[] | null
|
|
28
|
+
clients: ExternalAppClient[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ExternalAppDto {
|
|
32
|
+
app: string
|
|
33
|
+
/** Null for an application an earlier release's import of the deploy variable registered, which named none. */
|
|
34
|
+
name: string | null
|
|
35
|
+
resource: string
|
|
36
|
+
/** Null when the application declares no roles. */
|
|
37
|
+
roles: OAuthIdentityRole[] | null
|
|
38
|
+
clients: { clientId: string; redirectUris: string[]; metadataUrl: string | null }[]
|
|
39
|
+
createdAt: number
|
|
40
|
+
updatedAt: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ExternalAppInput {
|
|
44
|
+
app: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A registered OAuth client: an MCP authoring client (`externalApp` null) or a client of an external application. */
|
|
48
|
+
export interface OAuthClientDto {
|
|
49
|
+
clientId: string
|
|
50
|
+
label: OAuthClientProvider
|
|
51
|
+
redirectUris: string[]
|
|
52
|
+
metadataUrl: string | null
|
|
53
|
+
externalApp: string | null
|
|
54
|
+
createdAt: number
|
|
55
|
+
updatedAt: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An MCP authoring client, written with the provisioning key only. */
|
|
59
|
+
export interface PutOAuthClientRequest {
|
|
60
|
+
clientId: string
|
|
61
|
+
label: OAuthClientProvider
|
|
62
|
+
redirectUris: string[]
|
|
63
|
+
metadataUrl?: string | null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface OAuthClientInput {
|
|
67
|
+
clientId: string
|
|
68
|
+
}
|