@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/types/src/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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
3
|
import type { InstallationBrand } from '@fabrika/proxy-core/brand';
|
|
4
|
+
import type { ExternalAppDto, ExternalAppInput, OAuthClientDto, OAuthClientInput, PutExternalAppRequest, PutOAuthClientRequest } from './oauth-registry';
|
|
5
|
+
import type { IssuePasskeyChallengeRequest, PasskeyDto, PasskeyResetResponse, PasskeyStepUpChallenge, VerifiedPasskeyAssertion, VerifyPasskeyAssertionRequest } from './passkeys';
|
|
4
6
|
import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy';
|
|
7
|
+
import type { ProvisionRequestedApiKeyRequest, RequestedApiKey, RequestedApiKeyInput, RequestedApiKeyResponse } from './requested-keys';
|
|
8
|
+
import type { ScimSettingsDto, ScimTokenIssuedDto } from './scim';
|
|
5
9
|
/** A plain list response. */
|
|
6
10
|
export interface ListResponse<T> {
|
|
7
11
|
items: T[];
|
|
@@ -36,8 +40,10 @@ export interface GrantDto {
|
|
|
36
40
|
permissions: string[] | null;
|
|
37
41
|
/** Scope dimension; null = global (both rise/fall together). */
|
|
38
42
|
scopeType: string | null;
|
|
39
|
-
/** Opaque, app-owned scope value; null = global. */
|
|
43
|
+
/** Opaque, app-owned scope value; null = global. The first of `scopeValues` (ADR-0085). */
|
|
40
44
|
scopeValue: string | null;
|
|
45
|
+
/** Every value of `scopeType` the grant holds, sorted; null = global. A grant of one value lists one. */
|
|
46
|
+
scopeValues: string[] | null;
|
|
41
47
|
/** App id this grant applies to; null = all apps (cross-app). */
|
|
42
48
|
app: string | null;
|
|
43
49
|
grantedBy: string | null;
|
|
@@ -127,6 +133,8 @@ export interface SessionList extends CursorList<SessionDto> {
|
|
|
127
133
|
/** App sessions belonging to the sign-ins on this page, when `signInsOnly` is requested. */
|
|
128
134
|
applications: SessionDto[];
|
|
129
135
|
}
|
|
136
|
+
/** The most scope values one grant holds (ADR-0085). */
|
|
137
|
+
export declare const MAX_GRANT_SCOPE_VALUES = 100;
|
|
130
138
|
export interface CreateGrantRequest {
|
|
131
139
|
principalId: string;
|
|
132
140
|
/** A named role/policy key — XOR `permissions` (supply exactly one). */
|
|
@@ -137,21 +145,119 @@ export interface CreateGrantRequest {
|
|
|
137
145
|
scopeType?: string | null;
|
|
138
146
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
139
147
|
scopeValue?: string | null;
|
|
148
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
149
|
+
scopeValues?: string[];
|
|
140
150
|
/** App id (a registered app id); null / omitted = all apps (cross-app). */
|
|
141
151
|
app?: string | null;
|
|
142
152
|
expiresAt?: number | null;
|
|
153
|
+
/**
|
|
154
|
+
* The approval request in Control this grant carries out (ADR-0083 §8): an agent's grant, approved by the caller.
|
|
155
|
+
* IAM records it in the change's audit row, and in its grant request's where the application's grants wait. It is
|
|
156
|
+
* the caller's statement, recorded under the caller; it authorizes nothing.
|
|
157
|
+
*/
|
|
158
|
+
approvalRequest?: GrantApprovalRequestRef;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The Control approval request a console grant carries out, and who asked for it. IAM refuses ids over 200 characters, a
|
|
162
|
+
* label over 500 and a client id over 2048.
|
|
163
|
+
*/
|
|
164
|
+
export interface GrantApprovalRequestRef {
|
|
165
|
+
id: string;
|
|
166
|
+
requester: {
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
clientId?: string;
|
|
170
|
+
};
|
|
143
171
|
}
|
|
144
172
|
/** Change access within its original application, preserving the grant's identity and author. */
|
|
145
|
-
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
|
|
173
|
+
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app' | 'approvalRequest'> {
|
|
146
174
|
id: string;
|
|
147
175
|
}
|
|
148
|
-
/**
|
|
176
|
+
/** How long a grant request stays open for a decision. */
|
|
177
|
+
export declare const GRANT_REQUEST_TTL_SECONDS: number;
|
|
178
|
+
export declare const GRANT_REQUEST_KINDS: readonly ["create", "update", "revoke"];
|
|
179
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number];
|
|
180
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
181
|
+
export declare const GRANT_REQUEST_STATUSES: readonly ["pending", "approved", "rejected", "failed", "expired"];
|
|
182
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number];
|
|
183
|
+
/**
|
|
184
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
185
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
186
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
187
|
+
*/
|
|
188
|
+
export interface GrantRequestDto {
|
|
189
|
+
id: string;
|
|
190
|
+
app: string;
|
|
191
|
+
kind: GrantRequestKind;
|
|
192
|
+
principalId: string;
|
|
193
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
194
|
+
principalLabel: string | null;
|
|
195
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
196
|
+
grantId: string | null;
|
|
197
|
+
roleKey: string | null;
|
|
198
|
+
permissions: string[] | null;
|
|
199
|
+
scopeType: string | null;
|
|
200
|
+
/** The first requested value; `scopeValues` holds every one. */
|
|
201
|
+
scopeValue: string | null;
|
|
202
|
+
/** Every requested value, sorted (ADR-0085); null for a global grant. */
|
|
203
|
+
scopeValues: string[] | null;
|
|
204
|
+
/** The grant's own expiry; null for none. */
|
|
205
|
+
grantExpiresAt: number | null;
|
|
206
|
+
requestedBy: string;
|
|
207
|
+
requestedByLabel: string | null;
|
|
208
|
+
requestedAt: number;
|
|
209
|
+
/** When the request lapses without a decision. */
|
|
210
|
+
expiresAt: number;
|
|
211
|
+
status: GrantRequestStatus;
|
|
212
|
+
decidedBy: string | null;
|
|
213
|
+
decidedAt: number | null;
|
|
214
|
+
}
|
|
215
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
216
|
+
export interface PendingGrantChange {
|
|
217
|
+
pending: GrantRequestDto;
|
|
218
|
+
}
|
|
219
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
220
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange;
|
|
221
|
+
export interface ListGrantRequestsInput {
|
|
222
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
223
|
+
app?: string;
|
|
224
|
+
}
|
|
225
|
+
export interface DecideGrantRequestInput {
|
|
226
|
+
id: string;
|
|
227
|
+
decision: 'approve' | 'reject';
|
|
228
|
+
}
|
|
229
|
+
/** An environment's `credentials` mode as IAM keeps it for its own key issuance to a machine caller (ADR-0083 §8). */
|
|
230
|
+
export declare const CREDENTIALS_MODES: readonly ["off", "person", "refuse"];
|
|
231
|
+
export type CredentialsMode = (typeof CREDENTIALS_MODES)[number];
|
|
232
|
+
/**
|
|
233
|
+
* What an environment does with an agent's `write` grant (ADR-0090 §5), as Control mirrors its `agent-write` category:
|
|
234
|
+
* `open` serves it, `passkey` serves it when the approving person confirms with a passkey, `refuse` never serves it.
|
|
235
|
+
*/
|
|
236
|
+
export declare const AGENT_WRITE_GATES: readonly ["open", "passkey", "refuse"];
|
|
237
|
+
export type AgentWriteGate = (typeof AGENT_WRITE_GATES)[number];
|
|
238
|
+
/**
|
|
239
|
+
* Control's mirror of an application environment's approval gates in IAM, set with the provisioning key (ADR-0083 §4,
|
|
240
|
+
* §8, ADR-0090 §5): whether its console grants wait (`required`), its `credentials` mode and its `agentWrite` gate.
|
|
241
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds. A
|
|
242
|
+
* request without `credentials` (an older Control's) clears IAM's mode, which then reads as `person`; one without
|
|
243
|
+
* `agentWrite` clears that gate, which then reads as `refuse`.
|
|
244
|
+
*/
|
|
245
|
+
export interface SetGrantApprovalRequest {
|
|
246
|
+
app: string;
|
|
247
|
+
required: boolean;
|
|
248
|
+
revision: number;
|
|
249
|
+
credentials?: CredentialsMode;
|
|
250
|
+
agentWrite?: AgentWriteGate;
|
|
251
|
+
}
|
|
252
|
+
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
149
253
|
export interface AppDto {
|
|
150
254
|
id: string;
|
|
151
255
|
/** The name the app's schema declares for people; null when it declares none. */
|
|
152
256
|
displayName: string | null;
|
|
153
257
|
/** One of the installation's own apps (a platform audience): a user administrator grants nothing there (ADR-0058). */
|
|
154
258
|
installation: boolean;
|
|
259
|
+
/** Registered in IAM as an external application (ADR-0089): it has no deploy target, only roles and OAuth clients. */
|
|
260
|
+
externalApplication: boolean;
|
|
155
261
|
}
|
|
156
262
|
/** A role available for the calling app — a built-in or a DB row (app/custom). */
|
|
157
263
|
export interface RoleDto extends RoleDef {
|
|
@@ -222,13 +328,22 @@ export interface ApiKeyDto {
|
|
|
222
328
|
}
|
|
223
329
|
/**
|
|
224
330
|
* One API key with its live credential, as `apiKeys.get` and each row of `apiKeys.list` answer it. Its permissions are
|
|
225
|
-
* its grants, edited with `grants.create` and `grants.delete` by an installation administrator and read again at every
|
|
331
|
+
* its grants, edited with `grants.create`, `grants.update` and `grants.delete` by an installation administrator and read again at every
|
|
226
332
|
* token exchange. An IAM older than the list's credential answers list rows without `credential`.
|
|
227
333
|
*/
|
|
228
334
|
export interface ApiKeyDetail extends ApiKeyDto {
|
|
229
335
|
/** The key's live credential, or null when none is live (a revoked key). */
|
|
230
336
|
credential: ApiKeyCredentialDto | null;
|
|
231
337
|
}
|
|
338
|
+
/** A grant of `apiKeys.get`'s key, naming who granted it. */
|
|
339
|
+
export interface ApiKeyGrantDto extends GrantDto {
|
|
340
|
+
/** The granting principal's label, or its id when IAM no longer knows it; null when nobody granted it. */
|
|
341
|
+
grantedByLabel: string | null;
|
|
342
|
+
}
|
|
343
|
+
/** `apiKeys.get`: one key whose grants name who granted them. */
|
|
344
|
+
export interface GetApiKeyResponse extends ApiKeyDetail {
|
|
345
|
+
grants: ApiKeyGrantDto[];
|
|
346
|
+
}
|
|
232
347
|
export interface ApiKeyCredentialDto {
|
|
233
348
|
/** The app the key mints tokens for; null = every app. A grant at another app never reaches the key's token. */
|
|
234
349
|
app: string | null;
|
|
@@ -245,6 +360,8 @@ export interface ProvisionApiKeyRequest {
|
|
|
245
360
|
scopeType?: string | null;
|
|
246
361
|
/** Opaque, app-owned scope value; null / omitted = global. */
|
|
247
362
|
scopeValue?: string | null;
|
|
363
|
+
/** Several values of `scopeType`, one grant (ADR-0085); XOR `scopeValue`, at most `MAX_GRANT_SCOPE_VALUES`. */
|
|
364
|
+
scopeValues?: string[];
|
|
248
365
|
/** App id (a registered app id); null / omitted = all apps. */
|
|
249
366
|
app?: string | null;
|
|
250
367
|
expiresAt?: number | null;
|
|
@@ -252,7 +369,7 @@ export interface ProvisionApiKeyRequest {
|
|
|
252
369
|
/**
|
|
253
370
|
* Provisioning result. `apiKey` (a `px_…` credential bound to the new service principal) is shown
|
|
254
371
|
* exactly ONCE — copy it now, it is not retrievable later. Carried as a bearer (or a declared
|
|
255
|
-
* header) directly to apps on the
|
|
372
|
+
* header) directly to apps on the IAM-native path (`mintFromKey`), no Cloudflare Access in
|
|
256
373
|
* front.
|
|
257
374
|
*/
|
|
258
375
|
export interface ProvisionApiKeyResponse {
|
|
@@ -402,6 +519,27 @@ export interface GrantIdInput {
|
|
|
402
519
|
export interface AppInput {
|
|
403
520
|
app: string;
|
|
404
521
|
}
|
|
522
|
+
export interface ListScopeValuesInput {
|
|
523
|
+
/** The application id, `<app>@<env>`. */
|
|
524
|
+
app: string;
|
|
525
|
+
/** The dimension whose values the console offers. */
|
|
526
|
+
scopeType: string;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Why the application's own list is not there, so the console falls back to the listed values or free text:
|
|
530
|
+
* `no_source` (the dimension names no procedure), `not_held` (the administrator holds the procedure's action nowhere at
|
|
531
|
+
* the application), `no_origin` (IAM knows no address of it), `refused` (its proxy or the application answered
|
|
532
|
+
* 401/403/404), `timeout`, `unreachable` (any other failure to answer) or `malformed` (an answer that is no list).
|
|
533
|
+
*/
|
|
534
|
+
export type ScopeValuesUnavailable = 'no_source' | 'not_held' | 'no_origin' | 'refused' | 'timeout' | 'unreachable' | 'malformed';
|
|
535
|
+
/** What the application answered as the administrator, or why it could not be asked. Information, never a check. */
|
|
536
|
+
export type ScopeValuesResult = {
|
|
537
|
+
source: 'application';
|
|
538
|
+
values: DimensionValue[];
|
|
539
|
+
} | {
|
|
540
|
+
source: 'unavailable';
|
|
541
|
+
reason: ScopeValuesUnavailable;
|
|
542
|
+
};
|
|
405
543
|
/**
|
|
406
544
|
* The public origins IAM will hand this app a session at (ADR-0022). Declarative: the whole set is
|
|
407
545
|
* stated, so removing one is the same call as adding one and a stale entry cannot survive a deploy.
|
|
@@ -590,8 +728,10 @@ export interface GrantAppRoleRequest {
|
|
|
590
728
|
export interface GrantAppRoleResponse {
|
|
591
729
|
principalId: string;
|
|
592
730
|
role: string;
|
|
593
|
-
/** False when the person held the role already. */
|
|
731
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
594
732
|
granted: boolean;
|
|
733
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
734
|
+
pending?: GrantRequestDto;
|
|
595
735
|
}
|
|
596
736
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
597
737
|
export interface RevokeAppRoleRequest {
|
|
@@ -600,8 +740,10 @@ export interface RevokeAppRoleRequest {
|
|
|
600
740
|
principalId: string;
|
|
601
741
|
}
|
|
602
742
|
export interface RevokeAppRoleResponse {
|
|
603
|
-
/** False when the person held no such grant. */
|
|
743
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
604
744
|
revoked: boolean;
|
|
745
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
746
|
+
pending?: GrantRequestDto;
|
|
605
747
|
}
|
|
606
748
|
/**
|
|
607
749
|
* The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
|
|
@@ -643,16 +785,37 @@ export interface IamAdminRpcContract {
|
|
|
643
785
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>;
|
|
644
786
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>;
|
|
645
787
|
};
|
|
788
|
+
/**
|
|
789
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
790
|
+
* with a grant request instead of changing anything.
|
|
791
|
+
*/
|
|
646
792
|
grants: {
|
|
647
793
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
648
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
649
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
650
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
794
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>;
|
|
795
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>;
|
|
796
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
800
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
801
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
802
|
+
*/
|
|
803
|
+
grantRequests: {
|
|
804
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>;
|
|
805
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>;
|
|
806
|
+
};
|
|
807
|
+
/** An application environment's approval gates in IAM: the provisioning key's alone, which Control holds. */
|
|
808
|
+
grantApproval: {
|
|
809
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>;
|
|
651
810
|
};
|
|
652
811
|
connections: {
|
|
653
812
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>;
|
|
654
813
|
revoke: RpcProcedure<GrantIdInput, OkResponse>;
|
|
655
814
|
};
|
|
815
|
+
/** A dimension's values, asked of the application as the signed-in administrator (ADR-0085 §4). */
|
|
816
|
+
scopeValues: {
|
|
817
|
+
list: RpcProcedure<ListScopeValuesInput, ScopeValuesResult>;
|
|
818
|
+
};
|
|
656
819
|
apps: {
|
|
657
820
|
list: RpcProcedure<void, ListResponse<AppDto>>;
|
|
658
821
|
getSchema: RpcProcedure<AppInput, AppSchemaDto>;
|
|
@@ -661,6 +824,26 @@ export interface IamAdminRpcContract {
|
|
|
661
824
|
roles: {
|
|
662
825
|
list: RpcProcedure<ListRolesInput, ListResponse<RoleDto>>;
|
|
663
826
|
};
|
|
827
|
+
/**
|
|
828
|
+
* Applications outside the installation that sign people in through IAM (ADR-0089), an installation administrator's
|
|
829
|
+
* (`iam.admin`). `put` replaces the whole application, its roles and its clients in one transaction; removing a client
|
|
830
|
+
* or the application revokes its OAuth grants there.
|
|
831
|
+
*/
|
|
832
|
+
externalApps: {
|
|
833
|
+
list: RpcProcedure<void, ListResponse<ExternalAppDto>>;
|
|
834
|
+
get: RpcProcedure<ExternalAppInput, ExternalAppDto>;
|
|
835
|
+
put: RpcProcedure<PutExternalAppRequest, ExternalAppDto>;
|
|
836
|
+
delete: RpcProcedure<ExternalAppInput, OkResponse>;
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Every registered OAuth client, listed for an installation administrator. An MCP authoring client is written with
|
|
840
|
+
* the provisioning key only; a client of an external application only through `externalApps.put`.
|
|
841
|
+
*/
|
|
842
|
+
oauthClients: {
|
|
843
|
+
list: RpcProcedure<void, ListResponse<OAuthClientDto>>;
|
|
844
|
+
put: RpcProcedure<PutOAuthClientRequest, OAuthClientDto>;
|
|
845
|
+
delete: RpcProcedure<OAuthClientInput, OkResponse>;
|
|
846
|
+
};
|
|
664
847
|
policies: {
|
|
665
848
|
list: RpcProcedure<AppInput, ListResponse<PolicyDto>>;
|
|
666
849
|
create: RpcProcedure<CreatePolicyInput, PolicyDto>;
|
|
@@ -669,8 +852,15 @@ export interface IamAdminRpcContract {
|
|
|
669
852
|
};
|
|
670
853
|
apiKeys: {
|
|
671
854
|
list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>;
|
|
672
|
-
get: RpcProcedure<ApiKeyIdInput,
|
|
855
|
+
get: RpcProcedure<ApiKeyIdInput, GetApiKeyResponse>;
|
|
673
856
|
provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>;
|
|
857
|
+
/**
|
|
858
|
+
* A key a person approved in Control for the agent that asked (ADR-0083 §8): a person in a signed-in session only,
|
|
859
|
+
* idempotent by the approval request's id, answered encrypted to the agent's public key.
|
|
860
|
+
*/
|
|
861
|
+
provisionRequested: RpcProcedure<ProvisionRequestedApiKeyRequest, RequestedApiKey>;
|
|
862
|
+
/** The key an approval request issued, by its id: how Control follows an execution whose outcome it did not see. */
|
|
863
|
+
requested: RpcProcedure<RequestedApiKeyInput, RequestedApiKeyResponse>;
|
|
674
864
|
rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>;
|
|
675
865
|
revoke: RpcProcedure<ApiKeyIdInput, OkResponse>;
|
|
676
866
|
};
|
|
@@ -728,6 +918,52 @@ export interface IamAdminRpcContract {
|
|
|
728
918
|
get: RpcProcedure<void, PasswordPolicyDto>;
|
|
729
919
|
set: RpcProcedure<SetPasswordPolicyRequest, PasswordPolicyDto>;
|
|
730
920
|
};
|
|
921
|
+
/**
|
|
922
|
+
* SCIM provisioning by the organization's identity provider (ADR-0091), an installation administrator's in a signed-in
|
|
923
|
+
* session. `rotateToken` creates the installation's one token or replaces it (the old one stops working at once) and
|
|
924
|
+
* answers the secret once; `revokeToken` removes it, after which every SCIM request is refused. Each writes
|
|
925
|
+
* `iam.scim.token.rotate` or `iam.scim.token.revoke`.
|
|
926
|
+
*/
|
|
927
|
+
scim: {
|
|
928
|
+
get: RpcProcedure<void, ScimSettingsDto>;
|
|
929
|
+
rotateToken: RpcProcedure<void, ScimTokenIssuedDto>;
|
|
930
|
+
revokeToken: RpcProcedure<void, ScimSettingsDto>;
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* A person's second factor (TOTP), an installation administrator's (`iam.admin`) to read and to reset. The person
|
|
934
|
+
* enrols at IAM's `SECOND_FACTOR_ENROL_PATH`, never here. A reset removes the authenticator and its recovery codes
|
|
935
|
+
* and writes `iam.second_factor.reset`; the next sign-in asks for no code.
|
|
936
|
+
*/
|
|
937
|
+
secondFactor: {
|
|
938
|
+
get: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
|
|
939
|
+
reset: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* A person's passkeys. A person registers and removes their own on IAM's account page (`ACCOUNT_PAGE_PATH`).
|
|
943
|
+
* `challenge` and `verify` are the step-up seam, for a person in a signed-in session, never a `px_` key: a challenge
|
|
944
|
+
* bound to an opaque string, which the person answers on IAM's page at its `url`, and its verification against the
|
|
945
|
+
* same string. `listOf` and `reset` are an installation administrator's (`iam.admin`); the reset removes every
|
|
946
|
+
* passkey and writes `iam.passkey.reset`.
|
|
947
|
+
*/
|
|
948
|
+
passkeys: {
|
|
949
|
+
challenge: RpcProcedure<IssuePasskeyChallengeRequest, PasskeyStepUpChallenge>;
|
|
950
|
+
verify: RpcProcedure<VerifyPasskeyAssertionRequest, VerifiedPasskeyAssertion>;
|
|
951
|
+
listOf: RpcProcedure<PrincipalIdInput, ListResponse<PasskeyDto>>;
|
|
952
|
+
reset: RpcProcedure<PrincipalIdInput, PasskeyResetResponse>;
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
/** The signed-in person's own page on IAM's origin: their connections and their passkeys. */
|
|
956
|
+
export declare const ACCOUNT_PAGE_PATH = "/auth/account";
|
|
957
|
+
/** Where a signed-in administrator enrols an authenticator app, on IAM's own origin. */
|
|
958
|
+
export declare const SECOND_FACTOR_ENROL_PATH = "/auth/second-factor/enrol";
|
|
959
|
+
/** A person's second factor as an installation administrator sees it. */
|
|
960
|
+
export interface SecondFactorDto {
|
|
961
|
+
/** When the person confirmed the authenticator, in epoch seconds; null when none is enrolled. */
|
|
962
|
+
enrolledAt: number | null;
|
|
963
|
+
/** Recovery codes not used yet; 0 without an authenticator. */
|
|
964
|
+
recoveryCodesLeft: number;
|
|
965
|
+
/** Whether this installation can enrol an authenticator at all: it holds the key that seals the secrets. */
|
|
966
|
+
available: boolean;
|
|
731
967
|
}
|
|
732
968
|
export interface UserConnectionDto {
|
|
733
969
|
id: string;
|
|
@@ -739,7 +975,11 @@ export interface UserConnectionDto {
|
|
|
739
975
|
expiresAt: number;
|
|
740
976
|
status: 'active' | 'revoked' | 'expired' | 'unavailable';
|
|
741
977
|
}
|
|
742
|
-
export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef };
|
|
978
|
+
export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, DimensionValue, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef, };
|
|
743
979
|
export * from './access';
|
|
744
980
|
export * from './oauth';
|
|
981
|
+
export * from './oauth-registry';
|
|
982
|
+
export * from './passkeys';
|
|
745
983
|
export * from './password-policy';
|
|
984
|
+
export * from './requested-keys';
|
|
985
|
+
export * from './scim';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { OAuthClientProvider, OAuthIdentityRole } from './oauth';
|
|
2
|
+
/** How many clients one external application has. */
|
|
3
|
+
export declare const MAX_EXTERNAL_APP_CLIENTS = 16;
|
|
4
|
+
/** One client of an external application: its client id, its exact redirect URIs and where IAM fetches its document. */
|
|
5
|
+
export interface ExternalAppClient {
|
|
6
|
+
clientId: string;
|
|
7
|
+
redirectUris: string[];
|
|
8
|
+
/** Where IAM fetches the Client ID Metadata Document when it is not the client id itself. */
|
|
9
|
+
metadataUrl?: string | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An external application as a whole: an app id with no deploy target, its identity resource, its display name, its
|
|
13
|
+
* roles (each granting no action) and its clients. `externalApps.put` replaces all of it at once.
|
|
14
|
+
*/
|
|
15
|
+
export interface PutExternalAppRequest {
|
|
16
|
+
app: string;
|
|
17
|
+
name: string;
|
|
18
|
+
resource: string;
|
|
19
|
+
/** Absent, null or empty: no roles, and every active user signs in. */
|
|
20
|
+
roles?: OAuthIdentityRole[] | null;
|
|
21
|
+
clients: ExternalAppClient[];
|
|
22
|
+
}
|
|
23
|
+
export interface ExternalAppDto {
|
|
24
|
+
app: string;
|
|
25
|
+
/** Null for an application an earlier release's import of the deploy variable registered, which named none. */
|
|
26
|
+
name: string | null;
|
|
27
|
+
resource: string;
|
|
28
|
+
/** Null when the application declares no roles. */
|
|
29
|
+
roles: OAuthIdentityRole[] | null;
|
|
30
|
+
clients: {
|
|
31
|
+
clientId: string;
|
|
32
|
+
redirectUris: string[];
|
|
33
|
+
metadataUrl: string | null;
|
|
34
|
+
}[];
|
|
35
|
+
createdAt: number;
|
|
36
|
+
updatedAt: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ExternalAppInput {
|
|
39
|
+
app: string;
|
|
40
|
+
}
|
|
41
|
+
/** A registered OAuth client: an MCP authoring client (`externalApp` null) or a client of an external application. */
|
|
42
|
+
export interface OAuthClientDto {
|
|
43
|
+
clientId: string;
|
|
44
|
+
label: OAuthClientProvider;
|
|
45
|
+
redirectUris: string[];
|
|
46
|
+
metadataUrl: string | null;
|
|
47
|
+
externalApp: string | null;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
updatedAt: number;
|
|
50
|
+
}
|
|
51
|
+
/** An MCP authoring client, written with the provisioning key only. */
|
|
52
|
+
export interface PutOAuthClientRequest {
|
|
53
|
+
clientId: string;
|
|
54
|
+
label: OAuthClientProvider;
|
|
55
|
+
redirectUris: string[];
|
|
56
|
+
metadataUrl?: string | null;
|
|
57
|
+
}
|
|
58
|
+
export interface OAuthClientInput {
|
|
59
|
+
clientId: string;
|
|
60
|
+
}
|
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,35 @@ 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
|
+
/** Empty only for the agent client, which then asks for its default scope (ADR-0090 §2). */
|
|
143
|
+
scope: string[];
|
|
144
|
+
resources: string[];
|
|
145
|
+
/** The agent client's name for itself, shown to the person as the agent's own words; ignored for any other client. */
|
|
146
|
+
agent_label?: string;
|
|
147
|
+
}
|
|
148
|
+
/** RFC 8628 §3.2. */
|
|
149
|
+
export interface OAuthDeviceAuthorizationResponse {
|
|
150
|
+
device_code: string;
|
|
151
|
+
user_code: string;
|
|
152
|
+
verification_uri: string;
|
|
153
|
+
verification_uri_complete: string;
|
|
154
|
+
expires_in: number;
|
|
155
|
+
interval: number;
|
|
156
|
+
}
|
|
157
|
+
/** The lifetimes a person picks between when approving a device: an hour, a day, a week. */
|
|
158
|
+
export declare const OAUTH_DEVICE_GRANT_LIFETIMES_SECONDS: readonly [3600, 86400, 604800];
|
|
159
|
+
export type OAuthDeviceGrantLifetime = (typeof OAUTH_DEVICE_GRANT_LIFETIMES_SECONDS)[number];
|
|
160
|
+
/** How many resources one device grant may name. */
|
|
161
|
+
export declare const MAX_OAUTH_DEVICE_RESOURCES = 8;
|
|
93
162
|
export interface OAuthTokenResponse {
|
|
94
163
|
access_token: string;
|
|
95
164
|
token_type: 'Bearer';
|
|
@@ -107,9 +176,10 @@ export interface OAuthAuthorizationServerMetadata {
|
|
|
107
176
|
authorization_endpoint: string;
|
|
108
177
|
token_endpoint: string;
|
|
109
178
|
revocation_endpoint: string;
|
|
179
|
+
device_authorization_endpoint: string;
|
|
110
180
|
jwks_uri: string;
|
|
111
181
|
response_types_supported: ['code'];
|
|
112
|
-
grant_types_supported: ['authorization_code', 'refresh_token'];
|
|
182
|
+
grant_types_supported: ['authorization_code', 'refresh_token', typeof OAUTH_DEVICE_CODE_GRANT_TYPE];
|
|
113
183
|
code_challenge_methods_supported: ['S256'];
|
|
114
184
|
token_endpoint_auth_methods_supported: ['none', 'private_key_jwt'];
|
|
115
185
|
token_endpoint_auth_signing_alg_values_supported: OAuthClientAssertionAlgorithm[];
|
|
@@ -120,13 +190,40 @@ export interface OAuthAuthorizationServerMetadata {
|
|
|
120
190
|
client_id_metadata_document_supported: true;
|
|
121
191
|
}
|
|
122
192
|
export declare function parseOAuthManagedClient(value: unknown): OAuthManagedClient | null;
|
|
193
|
+
/** An HTTPS URL without credentials or a fragment, where IAM may fetch a client's metadata document. */
|
|
194
|
+
export declare function isHttpsDocumentUrl(value: string): boolean;
|
|
195
|
+
/** An external application's id: lowercase, without `@`, at most 63 characters. */
|
|
196
|
+
export declare function isOAuthIdentityAppId(value: unknown): value is string;
|
|
197
|
+
/** A role key an external application may declare: lowercase like an app id, and no built-in role key. */
|
|
198
|
+
export declare function isOAuthIdentityRoleKey(value: unknown): value is string;
|
|
199
|
+
/** An identity resource binding `{ app, resource, roles? }`, or null when it is not one; unknown keys are refused. */
|
|
200
|
+
export declare function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null;
|
|
201
|
+
/** The scopes an identity resource's authorization asks for: none, or exactly `identity`. */
|
|
202
|
+
export declare function resolveOAuthIdentityScopes(scope: string | undefined): string[] | null;
|
|
123
203
|
/** A fetched document cannot enlarge the managed registration's exact redirect allowlist. */
|
|
124
204
|
export declare function parseOAuthClientMetadata(value: unknown, registration: OAuthManagedClient): OAuthClientMetadataDocument | null;
|
|
125
205
|
export declare function parseOAuthResourceDto(value: unknown): OAuthResourceDto | null;
|
|
206
|
+
/** Separates a parameterized scope from its value: `deploy:alpha`. */
|
|
207
|
+
export declare const SCOPE_PARAMETER_SEPARATOR = ":";
|
|
208
|
+
/**
|
|
209
|
+
* The resource's grant a requested scope token selects and the narrowed permissions it holds, or null when the token
|
|
210
|
+
* selects none: an unknown scope, a parameterized scope without its value, a value on a scope that takes none.
|
|
211
|
+
*/
|
|
212
|
+
export declare function resolveOAuthScopeToken(token: string, resource: OAuthResourceDto): KeyGrant[] | null;
|
|
126
213
|
export declare function resolveOAuthAuthorizationScopes(scope: string | undefined, resource: OAuthResourceDto): string[] | null;
|
|
127
214
|
export declare function parseOAuthAuthorizationAttempt(value: unknown): OAuthAuthorizationParseResult;
|
|
128
215
|
export declare function parseOAuthAuthorizationRequest(value: unknown): OAuthAuthorizationRequest | null;
|
|
129
216
|
export declare function parseOAuthTokenRequest(value: unknown): OAuthTokenRequest | null;
|
|
217
|
+
/**
|
|
218
|
+
* A device authorization request: its client, at least one scope (the agent client may name none) and one to
|
|
219
|
+
* `MAX_OAUTH_DEVICE_RESOURCES` distinct resources. `resource` is the one parameter that may repeat (RFC 8707 §2), so the
|
|
220
|
+
* caller collects it into a list.
|
|
221
|
+
*/
|
|
222
|
+
export declare function parseOAuthDeviceAuthorizationRequest(value: {
|
|
223
|
+
fields: Record<string, string>;
|
|
224
|
+
resources: string[];
|
|
225
|
+
}): OAuthDeviceAuthorizationRequest | null;
|
|
226
|
+
export declare function isOAuthDeviceGrantLifetime(value: number): value is OAuthDeviceGrantLifetime;
|
|
130
227
|
/**
|
|
131
228
|
* The client credential of a token or revocation request (RFC 7521 §4.2). Neither assertion field is no
|
|
132
229
|
* credential; a half-present pair, another assertion type or an oversized assertion is null.
|