@fabrika/iam-contract 0.9.0-dev.4 → 0.9.0-dev.41
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 -4
- package/src/access.ts +3 -0
- package/src/index.ts +343 -22
- package/src/oauth.ts +218 -17
- package/src/password-policy.ts +43 -0
- package/types/src/access.d.ts +2 -0
- package/types/src/index.d.ts +309 -22
- package/types/src/oauth.d.ts +91 -6
- package/types/src/password-policy.d.ts +34 -0
package/types/src/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RpcProcedureContract } from '@fabrika/app';
|
|
2
|
-
import type { AppActionDef, AppDelegationDef, AppLinkMountDef, AppMemberItem, AppSchema, AppScopeDef, Locale, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef, WorkloadKind } from '@fabrika/auth-core';
|
|
2
|
+
import type { AppActionDef, AppDelegationDef, AppLinkMountDef, AppMemberItem, AppSchema, AppScopeDef, DimensionValue, Locale, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef, WorkloadKind } from '@fabrika/auth-core';
|
|
3
|
+
import type { InstallationBrand } from '@fabrika/proxy-core/brand';
|
|
4
|
+
import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy';
|
|
3
5
|
/** A plain list response. */
|
|
4
6
|
export interface ListResponse<T> {
|
|
5
7
|
items: T[];
|
|
@@ -34,8 +36,10 @@ export interface GrantDto {
|
|
|
34
36
|
permissions: string[] | null;
|
|
35
37
|
/** Scope dimension; null = global (both rise/fall together). */
|
|
36
38
|
scopeType: string | null;
|
|
37
|
-
/** Opaque, app-owned scope value; null = global. */
|
|
39
|
+
/** Opaque, app-owned scope value; null = global. The first of `scopeValues` (ADR-0085). */
|
|
38
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;
|
|
39
43
|
/** App id this grant applies to; null = all apps (cross-app). */
|
|
40
44
|
app: string | null;
|
|
41
45
|
grantedBy: string | null;
|
|
@@ -47,9 +51,18 @@ export interface GrantDto {
|
|
|
47
51
|
export interface PrincipalDetail extends PrincipalListItem {
|
|
48
52
|
/** The mailbox is listed in `IAM_BOOTSTRAP_ADMINS`: an internal user with it is an installation admin. */
|
|
49
53
|
bootstrapMailbox: boolean;
|
|
50
|
-
grants:
|
|
51
|
-
/**
|
|
54
|
+
grants: PrincipalGrantDto[];
|
|
55
|
+
/** Permissions at IAM only. Prefer `access` for the per-application view. */
|
|
52
56
|
permissions: PermissionEntry[];
|
|
57
|
+
access: PrincipalAppAccess[];
|
|
58
|
+
/** Presentation capabilities. Every mutation still checks the caller live. */
|
|
59
|
+
management: {
|
|
60
|
+
account: boolean;
|
|
61
|
+
passwordLinks: boolean;
|
|
62
|
+
audit: boolean;
|
|
63
|
+
};
|
|
64
|
+
activatedAt: number | null;
|
|
65
|
+
disabledAt: number | null;
|
|
53
66
|
authentication: {
|
|
54
67
|
/** OIDC is linked when this user has claimed an identity-provider subject. */
|
|
55
68
|
oidc: {
|
|
@@ -58,9 +71,28 @@ export interface PrincipalDetail extends PrincipalListItem {
|
|
|
58
71
|
/** Password access is globally opt-in and then enabled per user. */
|
|
59
72
|
password: {
|
|
60
73
|
state: 'unavailable' | 'disabled' | 'pending' | 'enabled';
|
|
74
|
+
delivery: 'email' | 'manual';
|
|
75
|
+
latestAction: {
|
|
76
|
+
purpose: 'enrollment' | 'reset';
|
|
77
|
+
createdAt: number;
|
|
78
|
+
expiresAt: number;
|
|
79
|
+
closedAt: number | null;
|
|
80
|
+
} | null;
|
|
61
81
|
};
|
|
62
82
|
};
|
|
63
83
|
}
|
|
84
|
+
export interface PrincipalGrantDto extends GrantDto {
|
|
85
|
+
roleName: string | null;
|
|
86
|
+
rolePermissions: string[];
|
|
87
|
+
grantedByLabel: string | null;
|
|
88
|
+
canManage: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface PrincipalAppAccess {
|
|
91
|
+
app: string;
|
|
92
|
+
/** Resolved by IAM using the same per-app resolver as token issuance; empty for a disabled account. */
|
|
93
|
+
permissions: PermissionEntry[];
|
|
94
|
+
lastSignInAt: number | null;
|
|
95
|
+
}
|
|
64
96
|
export interface InviteRequest {
|
|
65
97
|
email: string;
|
|
66
98
|
/** Omitted: `internal`. An `external` user signs in by password only, and OIDC never claims it. */
|
|
@@ -76,8 +108,11 @@ export interface UpdatePrincipalRequest {
|
|
|
76
108
|
export interface SessionDto {
|
|
77
109
|
id: string;
|
|
78
110
|
principalId: string;
|
|
79
|
-
/**
|
|
80
|
-
|
|
111
|
+
/**
|
|
112
|
+
* How the human proved who they were; `local_dev` is IAM's `LOCAL_DEV_LOGIN` bypass, `terminal_assertion` an
|
|
113
|
+
* application's word about who stands at an enrolled terminal.
|
|
114
|
+
*/
|
|
115
|
+
authenticationMethod: 'oidc' | 'password' | 'local_dev' | 'terminal_assertion';
|
|
81
116
|
/** The app this session is bound to (an ADR-0022 child); null = the IAM session itself. */
|
|
82
117
|
app: string | null;
|
|
83
118
|
/** The IAM session this was derived from; null on an IAM session. Revoking that one revokes this. */
|
|
@@ -87,7 +122,15 @@ export interface SessionDto {
|
|
|
87
122
|
createdAt: number;
|
|
88
123
|
expiresAt: number;
|
|
89
124
|
revokedAt: number | null;
|
|
125
|
+
/** Why this session cannot be used now, independently of its own stored lifecycle. */
|
|
126
|
+
unavailableReason: 'revoked' | 'expired' | 'parent_ended' | 'account_disabled' | 'method_disabled' | null;
|
|
127
|
+
}
|
|
128
|
+
export interface SessionList extends CursorList<SessionDto> {
|
|
129
|
+
/** App sessions belonging to the sign-ins on this page, when `signInsOnly` is requested. */
|
|
130
|
+
applications: SessionDto[];
|
|
90
131
|
}
|
|
132
|
+
/** The most scope values one grant holds (ADR-0085). */
|
|
133
|
+
export declare const MAX_GRANT_SCOPE_VALUES = 100;
|
|
91
134
|
export interface CreateGrantRequest {
|
|
92
135
|
principalId: string;
|
|
93
136
|
/** A named role/policy key — XOR `permissions` (supply exactly one). */
|
|
@@ -98,11 +141,79 @@ export interface CreateGrantRequest {
|
|
|
98
141
|
scopeType?: string | null;
|
|
99
142
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
100
143
|
scopeValue?: string | null;
|
|
144
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
145
|
+
scopeValues?: string[];
|
|
101
146
|
/** App id (a registered app id); null / omitted = all apps (cross-app). */
|
|
102
147
|
app?: string | null;
|
|
103
148
|
expiresAt?: number | null;
|
|
104
149
|
}
|
|
105
|
-
/**
|
|
150
|
+
/** Change access within its original application, preserving the grant's identity and author. */
|
|
151
|
+
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
|
|
152
|
+
id: string;
|
|
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
|
+
}
|
|
216
|
+
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
106
217
|
export interface AppDto {
|
|
107
218
|
id: string;
|
|
108
219
|
/** The name the app's schema declares for people; null when it declares none. */
|
|
@@ -111,11 +222,8 @@ export interface AppDto {
|
|
|
111
222
|
installation: boolean;
|
|
112
223
|
}
|
|
113
224
|
/** A role available for the calling app — a built-in or a DB row (app/custom). */
|
|
114
|
-
export interface RoleDto {
|
|
225
|
+
export interface RoleDto extends RoleDef {
|
|
115
226
|
key: string;
|
|
116
|
-
name: string;
|
|
117
|
-
description?: string;
|
|
118
|
-
permissions: string[];
|
|
119
227
|
/** 'builtin' (cross-app, e.g. admin), 'app' (reconciled), or 'custom' (admin-made). */
|
|
120
228
|
origin: 'builtin' | 'app' | 'custom';
|
|
121
229
|
}
|
|
@@ -147,6 +255,10 @@ export interface AppSchemaDto {
|
|
|
147
255
|
};
|
|
148
256
|
/** `labels` when the app's directory shows labels to `members.list` holders. */
|
|
149
257
|
directory?: 'labels';
|
|
258
|
+
/** The app's identification page at a terminal (ADR-0067); absent when the app declares none. */
|
|
259
|
+
terminal?: {
|
|
260
|
+
identify: string;
|
|
261
|
+
};
|
|
150
262
|
}
|
|
151
263
|
/** A custom policy (an origin='custom' role row) for an app. */
|
|
152
264
|
export interface PolicyDto {
|
|
@@ -177,13 +289,23 @@ export interface ApiKeyDto {
|
|
|
177
289
|
createdAt: number;
|
|
178
290
|
}
|
|
179
291
|
/**
|
|
180
|
-
* One API key with its live credential
|
|
181
|
-
* `grants.delete` by an installation administrator and read again at every
|
|
292
|
+
* One API key with its live credential, as `apiKeys.get` and each row of `apiKeys.list` answer it. Its permissions are
|
|
293
|
+
* its grants, edited with `grants.create`, `grants.update` and `grants.delete` by an installation administrator and read again at every
|
|
294
|
+
* token exchange. An IAM older than the list's credential answers list rows without `credential`.
|
|
182
295
|
*/
|
|
183
296
|
export interface ApiKeyDetail extends ApiKeyDto {
|
|
184
297
|
/** The key's live credential, or null when none is live (a revoked key). */
|
|
185
298
|
credential: ApiKeyCredentialDto | null;
|
|
186
299
|
}
|
|
300
|
+
/** A grant of `apiKeys.get`'s key, naming who granted it. */
|
|
301
|
+
export interface ApiKeyGrantDto extends GrantDto {
|
|
302
|
+
/** The granting principal's label, or its id when IAM no longer knows it; null when nobody granted it. */
|
|
303
|
+
grantedByLabel: string | null;
|
|
304
|
+
}
|
|
305
|
+
/** `apiKeys.get`: one key whose grants name who granted them. */
|
|
306
|
+
export interface GetApiKeyResponse extends ApiKeyDetail {
|
|
307
|
+
grants: ApiKeyGrantDto[];
|
|
308
|
+
}
|
|
187
309
|
export interface ApiKeyCredentialDto {
|
|
188
310
|
/** The app the key mints tokens for; null = every app. A grant at another app never reaches the key's token. */
|
|
189
311
|
app: string | null;
|
|
@@ -200,6 +322,8 @@ export interface ProvisionApiKeyRequest {
|
|
|
200
322
|
scopeType?: string | null;
|
|
201
323
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
202
324
|
scopeValue?: string | null;
|
|
325
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
326
|
+
scopeValues?: string[];
|
|
203
327
|
/** App id (a registered app id); null / omitted = all apps. */
|
|
204
328
|
app?: string | null;
|
|
205
329
|
expiresAt?: number | null;
|
|
@@ -207,7 +331,7 @@ export interface ProvisionApiKeyRequest {
|
|
|
207
331
|
/**
|
|
208
332
|
* Provisioning result. `apiKey` (a `px_…` credential bound to the new service principal) is shown
|
|
209
333
|
* exactly ONCE — copy it now, it is not retrievable later. Carried as a bearer (or a declared
|
|
210
|
-
* header) directly to apps on the
|
|
334
|
+
* header) directly to apps on the IAM-native path (`mintFromKey`), no Cloudflare Access in
|
|
211
335
|
* front.
|
|
212
336
|
*/
|
|
213
337
|
export interface ProvisionApiKeyResponse {
|
|
@@ -330,6 +454,7 @@ export interface PrincipalIdInput {
|
|
|
330
454
|
export interface ListSessionsInput extends PageInput {
|
|
331
455
|
/** Whose sessions to list. */
|
|
332
456
|
principalId: string;
|
|
457
|
+
signInsOnly?: boolean;
|
|
333
458
|
}
|
|
334
459
|
export interface SessionIdInput {
|
|
335
460
|
id: string;
|
|
@@ -356,6 +481,27 @@ export interface GrantIdInput {
|
|
|
356
481
|
export interface AppInput {
|
|
357
482
|
app: string;
|
|
358
483
|
}
|
|
484
|
+
export interface ListScopeValuesInput {
|
|
485
|
+
/** The application id, `<app>@<env>`. */
|
|
486
|
+
app: string;
|
|
487
|
+
/** The dimension whose values the console offers. */
|
|
488
|
+
scopeType: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Why the application's own list is not there, so the console falls back to the listed values or free text:
|
|
492
|
+
* `no_source` (the dimension names no procedure), `not_held` (the administrator holds the procedure's action nowhere at
|
|
493
|
+
* the application), `no_origin` (IAM knows no address of it), `refused` (its proxy or the application answered
|
|
494
|
+
* 401/403/404), `timeout`, `unreachable` (any other failure to answer) or `malformed` (an answer that is no list).
|
|
495
|
+
*/
|
|
496
|
+
export type ScopeValuesUnavailable = 'no_source' | 'not_held' | 'no_origin' | 'refused' | 'timeout' | 'unreachable' | 'malformed';
|
|
497
|
+
/** What the application answered as the administrator, or why it could not be asked. Information, never a check. */
|
|
498
|
+
export type ScopeValuesResult = {
|
|
499
|
+
source: 'application';
|
|
500
|
+
values: DimensionValue[];
|
|
501
|
+
} | {
|
|
502
|
+
source: 'unavailable';
|
|
503
|
+
reason: ScopeValuesUnavailable;
|
|
504
|
+
};
|
|
359
505
|
/**
|
|
360
506
|
* The public origins IAM will hand this app a session at (ADR-0022). Declarative: the whole set is
|
|
361
507
|
* stated, so removing one is the same call as adding one and a stale entry cannot survive a deploy.
|
|
@@ -395,7 +541,14 @@ export interface ListAuditInput {
|
|
|
395
541
|
resourceType?: string;
|
|
396
542
|
resourceId?: string;
|
|
397
543
|
principalId?: string;
|
|
544
|
+
/** The person affected by the change, distinct from `principalId` (the actor). */
|
|
545
|
+
subjectPrincipalId?: string;
|
|
398
546
|
action?: string;
|
|
547
|
+
/**
|
|
548
|
+
* Leave out the admin reads (`iam.admin.access`), which IAM writes for every `/admin/*` request, so a feed of what
|
|
549
|
+
* changed reads changes and not the reads that page through it. An IAM older than this field ignores it.
|
|
550
|
+
*/
|
|
551
|
+
changesOnly?: boolean;
|
|
399
552
|
requestId?: string;
|
|
400
553
|
before?: string;
|
|
401
554
|
limit?: number;
|
|
@@ -468,6 +621,38 @@ export interface IssueMembershipKeyResponse {
|
|
|
468
621
|
id: string;
|
|
469
622
|
expiresAt: number;
|
|
470
623
|
}
|
|
624
|
+
/** An application that may assert a person on a terminal, with the action patterns of the person that survive there. */
|
|
625
|
+
export interface TerminalAsserterDto {
|
|
626
|
+
app: string;
|
|
627
|
+
ceiling: string[];
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* An enrolled browser, as an operator sees it. Its own grants are ordinary grants on `terminalId`, which is its service
|
|
631
|
+
* principal; the cookie is never shown.
|
|
632
|
+
*/
|
|
633
|
+
export interface TerminalDto {
|
|
634
|
+
terminalId: string;
|
|
635
|
+
label: string;
|
|
636
|
+
/** The administrator who enrolled it; null once that principal is gone. */
|
|
637
|
+
enrolledBy: string | null;
|
|
638
|
+
/** Seconds a person's session on it lasts. */
|
|
639
|
+
sessionTtl: number;
|
|
640
|
+
asserters: TerminalAsserterDto[];
|
|
641
|
+
status: 'active' | 'revoked';
|
|
642
|
+
createdAt: number;
|
|
643
|
+
lastSeenAt: number | null;
|
|
644
|
+
revokedAt: number | null;
|
|
645
|
+
}
|
|
646
|
+
export type ListTerminalsInput = PageInput;
|
|
647
|
+
export interface TerminalIdInput {
|
|
648
|
+
terminalId: string;
|
|
649
|
+
}
|
|
650
|
+
/** Replace a terminal's whole profile. The ceiling is empty by default: the person brings only their identity. */
|
|
651
|
+
export interface SetTerminalProfileRequest extends TerminalIdInput {
|
|
652
|
+
label: string;
|
|
653
|
+
sessionTtl: number;
|
|
654
|
+
asserters: TerminalAsserterDto[];
|
|
655
|
+
}
|
|
471
656
|
/**
|
|
472
657
|
* An application whose people the caller administers: it holds the application's `members.manage` globally there.
|
|
473
658
|
* `roles` are the application's global roles the caller may grant, those whose every action it holds itself.
|
|
@@ -505,8 +690,10 @@ export interface GrantAppRoleRequest {
|
|
|
505
690
|
export interface GrantAppRoleResponse {
|
|
506
691
|
principalId: string;
|
|
507
692
|
role: string;
|
|
508
|
-
/** False when the person held the role already. */
|
|
693
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
509
694
|
granted: boolean;
|
|
695
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
696
|
+
pending?: GrantRequestDto;
|
|
510
697
|
}
|
|
511
698
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
512
699
|
export interface RevokeAppRoleRequest {
|
|
@@ -515,8 +702,23 @@ export interface RevokeAppRoleRequest {
|
|
|
515
702
|
principalId: string;
|
|
516
703
|
}
|
|
517
704
|
export interface RevokeAppRoleResponse {
|
|
518
|
-
/** False when the person held no such grant. */
|
|
705
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
519
706
|
revoked: boolean;
|
|
707
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
708
|
+
pending?: GrantRequestDto;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
|
|
712
|
+
* proxy's error pages on every application host. `null` shows the fabrika mark. An installation serves one client, so
|
|
713
|
+
* this is one setting of the installation, kept by IAM.
|
|
714
|
+
*/
|
|
715
|
+
export interface InstallationBrandDto {
|
|
716
|
+
brand: InstallationBrand | null;
|
|
717
|
+
/** When it was last set or cleared, in epoch seconds; null when it never was. */
|
|
718
|
+
updatedAt: number | null;
|
|
719
|
+
}
|
|
720
|
+
export interface SetInstallationBrandRequest {
|
|
721
|
+
brand: InstallationBrand;
|
|
520
722
|
}
|
|
521
723
|
export interface IamAdminRpcContract {
|
|
522
724
|
me: RpcProcedure<void, MeDto>;
|
|
@@ -536,7 +738,7 @@ export interface IamAdminRpcContract {
|
|
|
536
738
|
* derived from it — a child is only valid while its parent is — so this is one call, not a sweep.
|
|
537
739
|
*/
|
|
538
740
|
sessions: {
|
|
539
|
-
list: RpcProcedure<ListSessionsInput,
|
|
741
|
+
list: RpcProcedure<ListSessionsInput, SessionList>;
|
|
540
742
|
revoke: RpcProcedure<SessionIdInput, RevokedSessionsResponse>;
|
|
541
743
|
revokeAll: RpcProcedure<PrincipalIdInput, RevokedSessionsResponse>;
|
|
542
744
|
};
|
|
@@ -545,10 +747,36 @@ export interface IamAdminRpcContract {
|
|
|
545
747
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>;
|
|
546
748
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>;
|
|
547
749
|
};
|
|
750
|
+
/**
|
|
751
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
752
|
+
* with a grant request instead of changing anything.
|
|
753
|
+
*/
|
|
548
754
|
grants: {
|
|
549
755
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
550
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
551
|
-
|
|
756
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>;
|
|
757
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>;
|
|
758
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>;
|
|
759
|
+
};
|
|
760
|
+
/**
|
|
761
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
762
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
763
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
764
|
+
*/
|
|
765
|
+
grantRequests: {
|
|
766
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>;
|
|
767
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>;
|
|
768
|
+
};
|
|
769
|
+
/** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
|
|
770
|
+
grantApproval: {
|
|
771
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>;
|
|
772
|
+
};
|
|
773
|
+
connections: {
|
|
774
|
+
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>;
|
|
775
|
+
revoke: RpcProcedure<GrantIdInput, OkResponse>;
|
|
776
|
+
};
|
|
777
|
+
/** A dimension's values, asked of the application as the signed-in administrator (ADR-0085 §4). */
|
|
778
|
+
scopeValues: {
|
|
779
|
+
list: RpcProcedure<ListScopeValuesInput, ScopeValuesResult>;
|
|
552
780
|
};
|
|
553
781
|
apps: {
|
|
554
782
|
list: RpcProcedure<void, ListResponse<AppDto>>;
|
|
@@ -565,8 +793,8 @@ export interface IamAdminRpcContract {
|
|
|
565
793
|
delete: RpcProcedure<PolicyIdInput, OkResponse>;
|
|
566
794
|
};
|
|
567
795
|
apiKeys: {
|
|
568
|
-
list: RpcProcedure<ListApiKeysInput, CursorList<
|
|
569
|
-
get: RpcProcedure<ApiKeyIdInput,
|
|
796
|
+
list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>;
|
|
797
|
+
get: RpcProcedure<ApiKeyIdInput, GetApiKeyResponse>;
|
|
570
798
|
provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>;
|
|
571
799
|
rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>;
|
|
572
800
|
revoke: RpcProcedure<ApiKeyIdInput, OkResponse>;
|
|
@@ -587,6 +815,15 @@ export interface IamAdminRpcContract {
|
|
|
587
815
|
list: RpcProcedure<ListAuditInput, CursorList<AuditEventDto>>;
|
|
588
816
|
listAuthLog: RpcProcedure<ListAuthLogInput, CursorList<AuthLogDto>>;
|
|
589
817
|
};
|
|
818
|
+
/**
|
|
819
|
+
* Enrolled terminals. A browser is enrolled at IAM's `/auth/terminals/enroll`, never here. Revoking a terminal ends
|
|
820
|
+
* every session issued on it.
|
|
821
|
+
*/
|
|
822
|
+
terminals: {
|
|
823
|
+
list: RpcProcedure<ListTerminalsInput, CursorList<TerminalDto>>;
|
|
824
|
+
setProfile: RpcProcedure<SetTerminalProfileRequest, TerminalDto>;
|
|
825
|
+
revoke: RpcProcedure<TerminalIdInput, OkResponse>;
|
|
826
|
+
};
|
|
590
827
|
/**
|
|
591
828
|
* An application's own people, administered by whoever holds the application's `members.manage` globally there: no
|
|
592
829
|
* installation admin needed. Each change writes its audit row under the application.
|
|
@@ -597,7 +834,57 @@ export interface IamAdminRpcContract {
|
|
|
597
834
|
grant: RpcProcedure<GrantAppRoleRequest, GrantAppRoleResponse>;
|
|
598
835
|
revoke: RpcProcedure<RevokeAppRoleRequest, RevokeAppRoleResponse>;
|
|
599
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* The installation's client logo (ADR-0066), an installation administrator's (`iam.admin`) to read and to change. A
|
|
839
|
+
* change writes `iam.brand.update` in its own transaction. IAM's pages show it on their next render; the proxy's
|
|
840
|
+
* pages once Control republishes their manifests.
|
|
841
|
+
*/
|
|
842
|
+
brand: {
|
|
843
|
+
get: RpcProcedure<void, InstallationBrandDto>;
|
|
844
|
+
set: RpcProcedure<SetInstallationBrandRequest, InstallationBrandDto>;
|
|
845
|
+
clear: RpcProcedure<void, InstallationBrandDto>;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* The installation's minimum password length (ADR-0020), an installation administrator's (`iam.admin`) to read and to
|
|
849
|
+
* change. A change writes `iam.password_policy.update` in its own transaction and applies to the next password set,
|
|
850
|
+
* reset or chosen at an invitation; stored passwords stay as they are.
|
|
851
|
+
*/
|
|
852
|
+
passwordPolicy: {
|
|
853
|
+
get: RpcProcedure<void, PasswordPolicyDto>;
|
|
854
|
+
set: RpcProcedure<SetPasswordPolicyRequest, PasswordPolicyDto>;
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* A person's second factor (TOTP), an installation administrator's (`iam.admin`) to read and to reset. The person
|
|
858
|
+
* enrols at IAM's `SECOND_FACTOR_ENROL_PATH`, never here. A reset removes the authenticator and its recovery codes
|
|
859
|
+
* and writes `iam.second_factor.reset`; the next sign-in asks for no code.
|
|
860
|
+
*/
|
|
861
|
+
secondFactor: {
|
|
862
|
+
get: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
|
|
863
|
+
reset: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
/** Where a signed-in administrator enrols an authenticator app, on IAM's own origin. */
|
|
867
|
+
export declare const SECOND_FACTOR_ENROL_PATH = "/auth/second-factor/enrol";
|
|
868
|
+
/** A person's second factor as an installation administrator sees it. */
|
|
869
|
+
export interface SecondFactorDto {
|
|
870
|
+
/** When the person confirmed the authenticator, in epoch seconds; null when none is enrolled. */
|
|
871
|
+
enrolledAt: number | null;
|
|
872
|
+
/** Recovery codes not used yet; 0 without an authenticator. */
|
|
873
|
+
recoveryCodesLeft: number;
|
|
874
|
+
/** Whether this installation can enrol an authenticator at all: it holds the key that seals the secrets. */
|
|
875
|
+
available: boolean;
|
|
876
|
+
}
|
|
877
|
+
export interface UserConnectionDto {
|
|
878
|
+
id: string;
|
|
879
|
+
clientId: string;
|
|
880
|
+
app: string;
|
|
881
|
+
resource: string;
|
|
882
|
+
scopes: string[];
|
|
883
|
+
createdAt: number;
|
|
884
|
+
expiresAt: number;
|
|
885
|
+
status: 'active' | 'revoked' | 'expired' | 'unavailable';
|
|
600
886
|
}
|
|
601
|
-
export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef };
|
|
887
|
+
export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, DimensionValue, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef, };
|
|
602
888
|
export * from './access';
|
|
603
889
|
export * from './oauth';
|
|
890
|
+
export * from './password-policy';
|
package/types/src/oauth.d.ts
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import type { KeyGrant } from '@fabrika/auth-core';
|
|
2
|
+
/**
|
|
3
|
+
* The kinds of managed client an installation registers. A label only: every kind gets the same authorization code
|
|
4
|
+
* flow with S256 PKCE, the same RFC 8707 resources and the same scope ceilings (ADR-0049).
|
|
5
|
+
*/
|
|
6
|
+
export declare const OAUTH_CLIENT_PROVIDERS: readonly ["claude", "chatgpt", "external"];
|
|
7
|
+
export type OAuthClientProvider = (typeof OAUTH_CLIENT_PROVIDERS)[number];
|
|
8
|
+
/**
|
|
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. 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.
|
|
13
|
+
*/
|
|
14
|
+
export interface OAuthIdentityResource {
|
|
15
|
+
app: string;
|
|
16
|
+
resource: string;
|
|
17
|
+
roles?: OAuthIdentityRole[];
|
|
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;
|
|
26
|
+
/** The one scope of an identity resource: it names the person and grants nothing. */
|
|
27
|
+
export declare const OAUTH_IDENTITY_SCOPE = "identity";
|
|
2
28
|
/** Managed CIMD registrations only; public dynamic registration is not part of this contract. */
|
|
3
29
|
export interface OAuthManagedClient {
|
|
4
|
-
provider:
|
|
30
|
+
provider: OAuthClientProvider;
|
|
5
31
|
clientId: string;
|
|
6
32
|
redirectUris: string[];
|
|
33
|
+
/** Present only on an `external` client: it is served this resource alone, never a registered one. */
|
|
34
|
+
identity?: OAuthIdentityResource;
|
|
7
35
|
}
|
|
8
36
|
/** RFC 7523 §2.2: the `client_assertion_type` of a JWT client assertion (`private_key_jwt`). */
|
|
9
37
|
export declare const OAUTH_CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
|
|
@@ -33,16 +61,27 @@ export type OAuthClientCredential = {
|
|
|
33
61
|
method: 'private_key_jwt';
|
|
34
62
|
assertion: string;
|
|
35
63
|
};
|
|
64
|
+
export interface OAuthScopeGrant {
|
|
65
|
+
scope: string;
|
|
66
|
+
permissions: KeyGrant[];
|
|
67
|
+
/**
|
|
68
|
+
* A scope dimension type. Such a scope is requested only as `<scope>:<value>`, and each of its scope-less permissions
|
|
69
|
+
* is narrowed to `{ type: parameter, value }`: `deploy:alpha` with parameter `app` holds its actions at app `alpha` only.
|
|
70
|
+
*/
|
|
71
|
+
parameter?: string;
|
|
72
|
+
}
|
|
36
73
|
export interface OAuthResourceDto {
|
|
37
74
|
app: string;
|
|
38
75
|
resource: string;
|
|
39
76
|
/** IAM resolves these app-owned grants; OAuth scope text alone never authorizes an action. */
|
|
40
|
-
scopeGrants:
|
|
41
|
-
scope: string;
|
|
42
|
-
permissions: KeyGrant[];
|
|
43
|
-
}[];
|
|
77
|
+
scopeGrants: OAuthScopeGrant[];
|
|
44
78
|
/** Used only when scope is omitted. No configured default means invalid_scope, never all scopes. */
|
|
45
79
|
defaultScopes?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* `cli`: served only to the installation's command-line client, through the device grant. Absent: served only to the
|
|
82
|
+
* operator's managed clients, through an authorization code. A token for one never comes from the other's flow.
|
|
83
|
+
*/
|
|
84
|
+
client?: 'cli';
|
|
46
85
|
}
|
|
47
86
|
/** No access token, refresh token, hash, or authorization code appears in a grant DTO. */
|
|
48
87
|
export interface OAuthGrantDto {
|
|
@@ -77,6 +116,8 @@ export type OAuthAuthorizationParseResult = {
|
|
|
77
116
|
} | {
|
|
78
117
|
kind: 'invalid_request';
|
|
79
118
|
};
|
|
119
|
+
/** RFC 8628 §3.4: the grant type a device client polls the token endpoint with. */
|
|
120
|
+
export declare const OAUTH_DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
80
121
|
export type OAuthTokenRequest = {
|
|
81
122
|
grant_type: 'authorization_code';
|
|
82
123
|
client_id: string;
|
|
@@ -89,7 +130,32 @@ export type OAuthTokenRequest = {
|
|
|
89
130
|
client_id: string;
|
|
90
131
|
refresh_token: string;
|
|
91
132
|
resource: string;
|
|
133
|
+
} | {
|
|
134
|
+
grant_type: typeof OAUTH_DEVICE_CODE_GRANT_TYPE;
|
|
135
|
+
client_id: string;
|
|
136
|
+
device_code: string;
|
|
137
|
+
resource: string;
|
|
92
138
|
};
|
|
139
|
+
/** RFC 8628 §3.1, with every resource the grant is asked for (RFC 8707): each token names one of them. */
|
|
140
|
+
export interface OAuthDeviceAuthorizationRequest {
|
|
141
|
+
client_id: string;
|
|
142
|
+
scope: string[];
|
|
143
|
+
resources: string[];
|
|
144
|
+
}
|
|
145
|
+
/** RFC 8628 §3.2. */
|
|
146
|
+
export interface OAuthDeviceAuthorizationResponse {
|
|
147
|
+
device_code: string;
|
|
148
|
+
user_code: string;
|
|
149
|
+
verification_uri: string;
|
|
150
|
+
verification_uri_complete: string;
|
|
151
|
+
expires_in: number;
|
|
152
|
+
interval: number;
|
|
153
|
+
}
|
|
154
|
+
/** The lifetimes a person picks between when approving a device: an hour, a day, a week. */
|
|
155
|
+
export declare const OAUTH_DEVICE_GRANT_LIFETIMES_SECONDS: readonly [3600, 86400, 604800];
|
|
156
|
+
export type OAuthDeviceGrantLifetime = (typeof OAUTH_DEVICE_GRANT_LIFETIMES_SECONDS)[number];
|
|
157
|
+
/** How many resources one device grant may name. */
|
|
158
|
+
export declare const MAX_OAUTH_DEVICE_RESOURCES = 8;
|
|
93
159
|
export interface OAuthTokenResponse {
|
|
94
160
|
access_token: string;
|
|
95
161
|
token_type: 'Bearer';
|
|
@@ -107,9 +173,10 @@ export interface OAuthAuthorizationServerMetadata {
|
|
|
107
173
|
authorization_endpoint: string;
|
|
108
174
|
token_endpoint: string;
|
|
109
175
|
revocation_endpoint: string;
|
|
176
|
+
device_authorization_endpoint: string;
|
|
110
177
|
jwks_uri: string;
|
|
111
178
|
response_types_supported: ['code'];
|
|
112
|
-
grant_types_supported: ['authorization_code', 'refresh_token'];
|
|
179
|
+
grant_types_supported: ['authorization_code', 'refresh_token', typeof OAUTH_DEVICE_CODE_GRANT_TYPE];
|
|
113
180
|
code_challenge_methods_supported: ['S256'];
|
|
114
181
|
token_endpoint_auth_methods_supported: ['none', 'private_key_jwt'];
|
|
115
182
|
token_endpoint_auth_signing_alg_values_supported: OAuthClientAssertionAlgorithm[];
|
|
@@ -120,13 +187,31 @@ export interface OAuthAuthorizationServerMetadata {
|
|
|
120
187
|
client_id_metadata_document_supported: true;
|
|
121
188
|
}
|
|
122
189
|
export declare function parseOAuthManagedClient(value: unknown): OAuthManagedClient | null;
|
|
190
|
+
/** The scopes an identity resource's authorization asks for: none, or exactly `identity`. */
|
|
191
|
+
export declare function resolveOAuthIdentityScopes(scope: string | undefined): string[] | null;
|
|
123
192
|
/** A fetched document cannot enlarge the managed registration's exact redirect allowlist. */
|
|
124
193
|
export declare function parseOAuthClientMetadata(value: unknown, registration: OAuthManagedClient): OAuthClientMetadataDocument | null;
|
|
125
194
|
export declare function parseOAuthResourceDto(value: unknown): OAuthResourceDto | null;
|
|
195
|
+
/** Separates a parameterized scope from its value: `deploy:alpha`. */
|
|
196
|
+
export declare const SCOPE_PARAMETER_SEPARATOR = ":";
|
|
197
|
+
/**
|
|
198
|
+
* The resource's grant a requested scope token selects and the narrowed permissions it holds, or null when the token
|
|
199
|
+
* selects none: an unknown scope, a parameterized scope without its value, a value on a scope that takes none.
|
|
200
|
+
*/
|
|
201
|
+
export declare function resolveOAuthScopeToken(token: string, resource: OAuthResourceDto): KeyGrant[] | null;
|
|
126
202
|
export declare function resolveOAuthAuthorizationScopes(scope: string | undefined, resource: OAuthResourceDto): string[] | null;
|
|
127
203
|
export declare function parseOAuthAuthorizationAttempt(value: unknown): OAuthAuthorizationParseResult;
|
|
128
204
|
export declare function parseOAuthAuthorizationRequest(value: unknown): OAuthAuthorizationRequest | null;
|
|
129
205
|
export declare function parseOAuthTokenRequest(value: unknown): OAuthTokenRequest | null;
|
|
206
|
+
/**
|
|
207
|
+
* A device authorization request: its client, at least one scope and one to `MAX_OAUTH_DEVICE_RESOURCES` distinct
|
|
208
|
+
* resources. `resource` is the one parameter that may repeat (RFC 8707 §2), so the caller collects it into a list.
|
|
209
|
+
*/
|
|
210
|
+
export declare function parseOAuthDeviceAuthorizationRequest(value: {
|
|
211
|
+
fields: Record<string, string>;
|
|
212
|
+
resources: string[];
|
|
213
|
+
}): OAuthDeviceAuthorizationRequest | null;
|
|
214
|
+
export declare function isOAuthDeviceGrantLifetime(value: number): value is OAuthDeviceGrantLifetime;
|
|
130
215
|
/**
|
|
131
216
|
* The client credential of a token or revocation request (RFC 7521 §4.2). Neither assertion field is no
|
|
132
217
|
* credential; a half-present pair, another assertion type or an oversized assertion is null.
|