@fabrika/iam-contract 0.9.0-dev.34 → 0.9.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/index.ts +96 -5
- package/src/oauth.ts +71 -4
- package/types/src/index.d.ts +85 -5
- package/types/src/oauth.d.ts +24 -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.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"test": "bun test"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@fabrika/app": "0.9.0-dev.
|
|
31
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
32
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.36",
|
|
31
|
+
"@fabrika/auth-core": "0.9.0-dev.36",
|
|
32
|
+
"@fabrika/proxy-core": "0.9.0-dev.36"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -181,6 +181,76 @@ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId'
|
|
|
181
181
|
id: string
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
// ── Grant requests: a console grant that waits for a second administrator (ADR-0083) ───────
|
|
185
|
+
|
|
186
|
+
/** How long a grant request stays open for a decision. */
|
|
187
|
+
export const GRANT_REQUEST_TTL_SECONDS = 7 * 24 * 60 * 60
|
|
188
|
+
|
|
189
|
+
export const GRANT_REQUEST_KINDS = ['create', 'update', 'revoke'] as const
|
|
190
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number]
|
|
191
|
+
|
|
192
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
193
|
+
export const GRANT_REQUEST_STATUSES = ['pending', 'approved', 'rejected', 'failed', 'expired'] as const
|
|
194
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number]
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
198
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
199
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
200
|
+
*/
|
|
201
|
+
export interface GrantRequestDto {
|
|
202
|
+
id: string
|
|
203
|
+
app: string
|
|
204
|
+
kind: GrantRequestKind
|
|
205
|
+
principalId: string
|
|
206
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
207
|
+
principalLabel: string | null
|
|
208
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
209
|
+
grantId: string | null
|
|
210
|
+
roleKey: string | null
|
|
211
|
+
permissions: string[] | null
|
|
212
|
+
scopeType: string | null
|
|
213
|
+
scopeValue: string | null
|
|
214
|
+
/** The grant's own expiry; null for none. */
|
|
215
|
+
grantExpiresAt: number | null
|
|
216
|
+
requestedBy: string
|
|
217
|
+
requestedByLabel: string | null
|
|
218
|
+
requestedAt: number
|
|
219
|
+
/** When the request lapses without a decision. */
|
|
220
|
+
expiresAt: number
|
|
221
|
+
status: GrantRequestStatus
|
|
222
|
+
decidedBy: string | null
|
|
223
|
+
decidedAt: number | null
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
227
|
+
export interface PendingGrantChange {
|
|
228
|
+
pending: GrantRequestDto
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
232
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange
|
|
233
|
+
|
|
234
|
+
export interface ListGrantRequestsInput {
|
|
235
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
236
|
+
app?: string
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface DecideGrantRequestInput {
|
|
240
|
+
id: string
|
|
241
|
+
decision: 'approve' | 'reject'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
|
|
246
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
|
|
247
|
+
*/
|
|
248
|
+
export interface SetGrantApprovalRequest {
|
|
249
|
+
app: string
|
|
250
|
+
required: boolean
|
|
251
|
+
revision: number
|
|
252
|
+
}
|
|
253
|
+
|
|
184
254
|
// ── Apps (read-only; the live registry derived from the schema tables) ────────
|
|
185
255
|
|
|
186
256
|
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
@@ -694,8 +764,10 @@ export interface GrantAppRoleRequest {
|
|
|
694
764
|
export interface GrantAppRoleResponse {
|
|
695
765
|
principalId: string
|
|
696
766
|
role: string
|
|
697
|
-
/** False when the person held the role already. */
|
|
767
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
698
768
|
granted: boolean
|
|
769
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
770
|
+
pending?: GrantRequestDto
|
|
699
771
|
}
|
|
700
772
|
|
|
701
773
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
@@ -706,8 +778,10 @@ export interface RevokeAppRoleRequest {
|
|
|
706
778
|
}
|
|
707
779
|
|
|
708
780
|
export interface RevokeAppRoleResponse {
|
|
709
|
-
/** False when the person held no such grant. */
|
|
781
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
710
782
|
revoked: boolean
|
|
783
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
784
|
+
pending?: GrantRequestDto
|
|
711
785
|
}
|
|
712
786
|
|
|
713
787
|
/**
|
|
@@ -752,11 +826,28 @@ export interface IamAdminRpcContract {
|
|
|
752
826
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>
|
|
753
827
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>
|
|
754
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
831
|
+
* with a grant request instead of changing anything.
|
|
832
|
+
*/
|
|
755
833
|
grants: {
|
|
756
834
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
757
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
758
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
759
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
835
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>
|
|
836
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>
|
|
837
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
841
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
842
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
843
|
+
*/
|
|
844
|
+
grantRequests: {
|
|
845
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>
|
|
846
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>
|
|
847
|
+
}
|
|
848
|
+
/** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
|
|
849
|
+
grantApproval: {
|
|
850
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>
|
|
760
851
|
}
|
|
761
852
|
connections: {
|
|
762
853
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>
|
package/src/oauth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isCimdClientId, isOAuthClientId, isOAuthResourceUri, parseOAuthScopes } from '@fabrika/auth-core'
|
|
1
|
+
import { BUILTIN_ROLE_KEYS, isCimdClientId, isOAuthClientId, isOAuthResourceUri, parseOAuthScopes } from '@fabrika/auth-core'
|
|
2
2
|
import type { KeyGrant } from '@fabrika/auth-core'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,11 +12,37 @@ function isOAuthClientProvider(value: unknown): value is OAuthClientProvider {
|
|
|
12
12
|
return OAUTH_CLIENT_PROVIDERS.some((provider) => provider === value)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The one resource an identity-only client is served: its own, outside the installation. A token for it carries the
|
|
17
|
+
* person's identity and no permission, under `app`, an id no installation service or application holds. With `roles`,
|
|
18
|
+
* the application's roles are IAM's to grant: the token names those the person holds there, and a person holding none
|
|
19
|
+
* is refused.
|
|
20
|
+
*/
|
|
21
|
+
export interface OAuthIdentityResource {
|
|
22
|
+
app: string
|
|
23
|
+
resource: string
|
|
24
|
+
roles?: OAuthIdentityRole[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A role of an external application: IAM grants it and names it in the token; the application decides what it allows. */
|
|
28
|
+
export interface OAuthIdentityRole {
|
|
29
|
+
key: string
|
|
30
|
+
name: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** How many roles one external application declares. */
|
|
34
|
+
export const MAX_OAUTH_IDENTITY_ROLES = 32
|
|
35
|
+
|
|
36
|
+
/** The one scope of an identity resource: it names the person and grants nothing. */
|
|
37
|
+
export const OAUTH_IDENTITY_SCOPE = 'identity'
|
|
38
|
+
|
|
15
39
|
/** Managed CIMD registrations only; public dynamic registration is not part of this contract. */
|
|
16
40
|
export interface OAuthManagedClient {
|
|
17
41
|
provider: OAuthClientProvider
|
|
18
42
|
clientId: string
|
|
19
43
|
redirectUris: string[]
|
|
44
|
+
/** Present only on an `external` client: it is served this resource alone, never a registered one. */
|
|
45
|
+
identity?: OAuthIdentityResource
|
|
20
46
|
}
|
|
21
47
|
|
|
22
48
|
/** RFC 7523 §2.2: the `client_assertion_type` of a JWT client assertion (`private_key_jwt`). */
|
|
@@ -189,9 +215,50 @@ export function parseOAuthManagedClient(value: unknown): OAuthManagedClient | nu
|
|
|
189
215
|
const provider = field(value, 'provider')
|
|
190
216
|
const clientId = field(value, 'clientId')
|
|
191
217
|
const uris = redirectUris(field(value, 'redirectUris'))
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
218
|
+
const rawIdentity = field(value, 'identity')
|
|
219
|
+
if (!isOAuthClientProvider(provider) || !isCimdClientId(clientId) || uris === null) return null
|
|
220
|
+
if (rawIdentity === undefined) return { provider, clientId, redirectUris: uris }
|
|
221
|
+
const identity = parseOAuthIdentityResource(rawIdentity)
|
|
222
|
+
// Claude and ChatGPT are authoring clients; only an external application signs people in for itself.
|
|
223
|
+
return identity === null || provider !== 'external' ? null : { provider, clientId, redirectUris: uris, identity }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const IDENTITY_KEYS = ['app', 'resource', 'roles']
|
|
227
|
+
const ROLE_KEYS = ['key', 'name']
|
|
228
|
+
/** An app id as every fabrika config writes one; no `@`, so never an application environment's id. */
|
|
229
|
+
const IDENTITY_APP = /^[a-z0-9][a-z0-9-]{0,62}$/
|
|
230
|
+
/** A role key; never a built-in one (`admin` means every action of an application). */
|
|
231
|
+
const IDENTITY_ROLE_KEY = /^[a-z0-9][a-z0-9-]{0,62}$/
|
|
232
|
+
|
|
233
|
+
function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null {
|
|
234
|
+
const app = field(value, 'app')
|
|
235
|
+
const resource = field(value, 'resource')
|
|
236
|
+
const rawRoles = field(value, 'roles')
|
|
237
|
+
if (!hasOnlyKeys(value, IDENTITY_KEYS) || typeof app !== 'string' || !IDENTITY_APP.test(app) || !isOAuthResourceUri(resource)) return null
|
|
238
|
+
if (rawRoles === undefined) return { app, resource }
|
|
239
|
+
const roles = parseOAuthIdentityRoles(rawRoles)
|
|
240
|
+
return roles === null ? null : { app, resource, roles }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parseOAuthIdentityRoles(value: unknown): OAuthIdentityRole[] | null {
|
|
244
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_OAUTH_IDENTITY_ROLES) return null
|
|
245
|
+
const roles: OAuthIdentityRole[] = []
|
|
246
|
+
for (const entry of value) {
|
|
247
|
+
const key = field(entry, 'key')
|
|
248
|
+
const name = field(entry, 'name')
|
|
249
|
+
if (
|
|
250
|
+
!hasOnlyKeys(entry, ROLE_KEYS) || typeof key !== 'string' || !IDENTITY_ROLE_KEY.test(key) || BUILTIN_ROLE_KEYS.includes(key)
|
|
251
|
+
|| !isNonemptyText(name)
|
|
252
|
+
|| name.length > 100 || roles.some((role) => role.key === key)
|
|
253
|
+
) return null
|
|
254
|
+
roles.push({ key, name })
|
|
255
|
+
}
|
|
256
|
+
return roles
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** The scopes an identity resource's authorization asks for: none, or exactly `identity`. */
|
|
260
|
+
export function resolveOAuthIdentityScopes(scope: string | undefined): string[] | null {
|
|
261
|
+
return scope === undefined || scope === OAUTH_IDENTITY_SCOPE ? [OAUTH_IDENTITY_SCOPE] : null
|
|
195
262
|
}
|
|
196
263
|
|
|
197
264
|
/** A fetched document cannot enlarge the managed registration's exact redirect allowlist. */
|
package/types/src/index.d.ts
CHANGED
|
@@ -145,6 +145,65 @@ export interface CreateGrantRequest {
|
|
|
145
145
|
export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
|
|
146
146
|
id: string;
|
|
147
147
|
}
|
|
148
|
+
/** How long a grant request stays open for a decision. */
|
|
149
|
+
export declare const GRANT_REQUEST_TTL_SECONDS: number;
|
|
150
|
+
export declare const GRANT_REQUEST_KINDS: readonly ["create", "update", "revoke"];
|
|
151
|
+
export type GrantRequestKind = (typeof GRANT_REQUEST_KINDS)[number];
|
|
152
|
+
/** `failed`: approved, but the change no longer applied when the approval wrote it. `expired`: no decision in time. */
|
|
153
|
+
export declare const GRANT_REQUEST_STATUSES: readonly ["pending", "approved", "rejected", "failed", "expired"];
|
|
154
|
+
export type GrantRequestStatus = (typeof GRANT_REQUEST_STATUSES)[number];
|
|
155
|
+
/**
|
|
156
|
+
* A grant, grant edit or revocation at an application whose console grants wait for approval: it has no effect until
|
|
157
|
+
* another administrator of the application approves it (ADR-0083 §4). The grant fields are the change's: the new grant
|
|
158
|
+
* for `create` and `update`, the revoked one for `revoke`.
|
|
159
|
+
*/
|
|
160
|
+
export interface GrantRequestDto {
|
|
161
|
+
id: string;
|
|
162
|
+
app: string;
|
|
163
|
+
kind: GrantRequestKind;
|
|
164
|
+
principalId: string;
|
|
165
|
+
/** The principal's label as an administrator sees it; null when the principal is gone. */
|
|
166
|
+
principalLabel: string | null;
|
|
167
|
+
/** The grant an `update` edits or a `revoke` removes; null for `create`. */
|
|
168
|
+
grantId: string | null;
|
|
169
|
+
roleKey: string | null;
|
|
170
|
+
permissions: string[] | null;
|
|
171
|
+
scopeType: string | null;
|
|
172
|
+
scopeValue: string | null;
|
|
173
|
+
/** The grant's own expiry; null for none. */
|
|
174
|
+
grantExpiresAt: number | null;
|
|
175
|
+
requestedBy: string;
|
|
176
|
+
requestedByLabel: string | null;
|
|
177
|
+
requestedAt: number;
|
|
178
|
+
/** When the request lapses without a decision. */
|
|
179
|
+
expiresAt: number;
|
|
180
|
+
status: GrantRequestStatus;
|
|
181
|
+
decidedBy: string | null;
|
|
182
|
+
decidedAt: number | null;
|
|
183
|
+
}
|
|
184
|
+
/** What a grant change answers at an application whose grants wait: the request, and nothing changed. */
|
|
185
|
+
export interface PendingGrantChange {
|
|
186
|
+
pending: GrantRequestDto;
|
|
187
|
+
}
|
|
188
|
+
/** `grants.create` and `grants.update`: the grant, or the request when the application's grants wait. */
|
|
189
|
+
export type GrantChangeResponse = GrantDto | PendingGrantChange;
|
|
190
|
+
export interface ListGrantRequestsInput {
|
|
191
|
+
/** One application's requests; omitted, every application the caller administers. */
|
|
192
|
+
app?: string;
|
|
193
|
+
}
|
|
194
|
+
export interface DecideGrantRequestInput {
|
|
195
|
+
id: string;
|
|
196
|
+
decision: 'approve' | 'reject';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
|
|
200
|
+
* `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
|
|
201
|
+
*/
|
|
202
|
+
export interface SetGrantApprovalRequest {
|
|
203
|
+
app: string;
|
|
204
|
+
required: boolean;
|
|
205
|
+
revision: number;
|
|
206
|
+
}
|
|
148
207
|
/** The set of app ids IAM knows about — the choices for a grant's `app`. */
|
|
149
208
|
export interface AppDto {
|
|
150
209
|
id: string;
|
|
@@ -599,8 +658,10 @@ export interface GrantAppRoleRequest {
|
|
|
599
658
|
export interface GrantAppRoleResponse {
|
|
600
659
|
principalId: string;
|
|
601
660
|
role: string;
|
|
602
|
-
/** False when the person held the role already. */
|
|
661
|
+
/** False when the person held the role already, or the grant waits for approval (`pending`). */
|
|
603
662
|
granted: boolean;
|
|
663
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
664
|
+
pending?: GrantRequestDto;
|
|
604
665
|
}
|
|
605
666
|
/** Remove the global grant of `role` from a person. Repeating it answers the same. */
|
|
606
667
|
export interface RevokeAppRoleRequest {
|
|
@@ -609,8 +670,10 @@ export interface RevokeAppRoleRequest {
|
|
|
609
670
|
principalId: string;
|
|
610
671
|
}
|
|
611
672
|
export interface RevokeAppRoleResponse {
|
|
612
|
-
/** False when the person held no such grant. */
|
|
673
|
+
/** False when the person held no such grant, or the revocation waits for approval (`pending`). */
|
|
613
674
|
revoked: boolean;
|
|
675
|
+
/** The grant request, when the application's grants wait for approval (ADR-0083). */
|
|
676
|
+
pending?: GrantRequestDto;
|
|
614
677
|
}
|
|
615
678
|
/**
|
|
616
679
|
* The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
|
|
@@ -652,11 +715,28 @@ export interface IamAdminRpcContract {
|
|
|
652
715
|
issueReset: RpcProcedure<PrincipalIdInput, PasswordActionDelivery>;
|
|
653
716
|
disable: RpcProcedure<PrincipalIdInput, OkResponse>;
|
|
654
717
|
};
|
|
718
|
+
/**
|
|
719
|
+
* At an application whose grants wait for approval (ADR-0083), each change runs its checks and answers `pending`
|
|
720
|
+
* with a grant request instead of changing anything.
|
|
721
|
+
*/
|
|
655
722
|
grants: {
|
|
656
723
|
/** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
|
|
657
|
-
create: RpcProcedure<CreateGrantRequest,
|
|
658
|
-
update: RpcProcedure<UpdateGrantInput,
|
|
659
|
-
delete: RpcProcedure<GrantIdInput, OkResponse
|
|
724
|
+
create: RpcProcedure<CreateGrantRequest, GrantChangeResponse>;
|
|
725
|
+
update: RpcProcedure<UpdateGrantInput, GrantChangeResponse>;
|
|
726
|
+
delete: RpcProcedure<GrantIdInput, OkResponse & Partial<PendingGrantChange>>;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* The open grant requests at the applications the caller administers, and their decision: an administrator of the
|
|
730
|
+
* application, a person in a signed-in session, approves another's request, and approving makes the change with the
|
|
731
|
+
* approver's own checks. The requester may reject (withdraw) their own.
|
|
732
|
+
*/
|
|
733
|
+
grantRequests: {
|
|
734
|
+
list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>;
|
|
735
|
+
decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>;
|
|
736
|
+
};
|
|
737
|
+
/** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
|
|
738
|
+
grantApproval: {
|
|
739
|
+
set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>;
|
|
660
740
|
};
|
|
661
741
|
connections: {
|
|
662
742
|
list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>;
|
package/types/src/oauth.d.ts
CHANGED
|
@@ -5,11 +5,33 @@ import type { KeyGrant } from '@fabrika/auth-core';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const OAUTH_CLIENT_PROVIDERS: readonly ["claude", "chatgpt", "external"];
|
|
7
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";
|
|
8
28
|
/** Managed CIMD registrations only; public dynamic registration is not part of this contract. */
|
|
9
29
|
export interface OAuthManagedClient {
|
|
10
30
|
provider: OAuthClientProvider;
|
|
11
31
|
clientId: string;
|
|
12
32
|
redirectUris: string[];
|
|
33
|
+
/** Present only on an `external` client: it is served this resource alone, never a registered one. */
|
|
34
|
+
identity?: OAuthIdentityResource;
|
|
13
35
|
}
|
|
14
36
|
/** RFC 7523 §2.2: the `client_assertion_type` of a JWT client assertion (`private_key_jwt`). */
|
|
15
37
|
export declare const OAUTH_CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
|
|
@@ -165,6 +187,8 @@ export interface OAuthAuthorizationServerMetadata {
|
|
|
165
187
|
client_id_metadata_document_supported: true;
|
|
166
188
|
}
|
|
167
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;
|
|
168
192
|
/** A fetched document cannot enlarge the managed registration's exact redirect allowlist. */
|
|
169
193
|
export declare function parseOAuthClientMetadata(value: unknown, registration: OAuthManagedClient): OAuthClientMetadataDocument | null;
|
|
170
194
|
export declare function parseOAuthResourceDto(value: unknown): OAuthResourceDto | null;
|