@fabrika/iam-contract 0.9.0-dev.2 → 0.9.0-dev.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/iam-contract",
3
- "version": "0.9.0-dev.2",
3
+ "version": "0.9.0-dev.21",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,10 +22,11 @@
22
22
  }
23
23
  },
24
24
  "scripts": {
25
- "typecheck": "tsc --noEmit"
25
+ "typecheck": "tsrs --build tsconfig.lib.json"
26
26
  },
27
27
  "dependencies": {
28
- "@fabrika/app": "0.9.0-dev.2",
29
- "@fabrika/auth-core": "0.9.0-dev.2"
28
+ "@fabrika/app": "0.9.0-dev.21",
29
+ "@fabrika/auth-core": "0.9.0-dev.21",
30
+ "@fabrika/proxy-core": "0.9.0-dev.21"
30
31
  }
31
32
  }
package/src/access.ts CHANGED
@@ -11,6 +11,8 @@ export const IAM_ACTIONS = Object.freeze({
11
11
  ADMIN: 'iam.admin',
12
12
  /** Manage the people of applications, never of the installation's own apps. Global, or in `app` values. */
13
13
  USERS_MANAGE: 'iam.users.manage',
14
+ /** Enrol a browser as a terminal (ADR-0067). Global only; its profile and revocation stay `iam.admin`'s. */
15
+ TERMINALS_MANAGE: 'iam.terminals.manage',
14
16
  })
15
17
 
16
18
  export const IAM_SCOPES = Object.freeze({
@@ -40,6 +42,7 @@ export const IAM_APP_SCHEMA: AppSchema = {
40
42
  actions: [
41
43
  { action: IAM_ACTIONS.ADMIN, description: 'Administer identity and access for the installation' },
42
44
  { action: IAM_ACTIONS.USERS_MANAGE, description: 'Manage the people of applications: invite, sign out, reset, grant and revoke' },
45
+ { action: IAM_ACTIONS.TERMINALS_MANAGE, description: 'Enrol a shared computer as a terminal' },
43
46
  ],
44
47
  roles: {
45
48
  [USER_ADMIN_ROLE]: {
package/src/index.ts CHANGED
@@ -24,6 +24,8 @@ import type {
24
24
  RoleDef,
25
25
  WorkloadKind,
26
26
  } from '@fabrika/auth-core'
27
+ import type { InstallationBrand } from '@fabrika/proxy-core/brand'
28
+ import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy'
27
29
 
28
30
  // ── Common wrappers ───────────────────────────────────────────────────────────
29
31
 
@@ -81,17 +83,40 @@ export interface GrantDto {
81
83
  export interface PrincipalDetail extends PrincipalListItem {
82
84
  /** The mailbox is listed in `IAM_BOOTSTRAP_ADMINS`: an internal user with it is an installation admin. */
83
85
  bootstrapMailbox: boolean
84
- grants: GrantDto[]
85
- /** Effective permissions with `source` (grant / bootstrap / group:<ref>). */
86
+ grants: PrincipalGrantDto[]
87
+ /** Permissions at IAM only. Prefer `access` for the per-application view. */
86
88
  permissions: PermissionEntry[]
89
+ access: PrincipalAppAccess[]
90
+ /** Presentation capabilities. Every mutation still checks the caller live. */
91
+ management: { account: boolean; passwordLinks: boolean; audit: boolean }
92
+ activatedAt: number | null
93
+ disabledAt: number | null
87
94
  authentication: {
88
95
  /** OIDC is linked when this user has claimed an identity-provider subject. */
89
96
  oidc: { state: 'unavailable' | 'unlinked' | 'linked' }
90
97
  /** Password access is globally opt-in and then enabled per user. */
91
- password: { state: 'unavailable' | 'disabled' | 'pending' | 'enabled' }
98
+ password: {
99
+ state: 'unavailable' | 'disabled' | 'pending' | 'enabled'
100
+ delivery: 'email' | 'manual'
101
+ latestAction: { purpose: 'enrollment' | 'reset'; createdAt: number; expiresAt: number; closedAt: number | null } | null
102
+ }
92
103
  }
93
104
  }
94
105
 
106
+ export interface PrincipalGrantDto extends GrantDto {
107
+ roleName: string | null
108
+ rolePermissions: string[]
109
+ grantedByLabel: string | null
110
+ canManage: boolean
111
+ }
112
+
113
+ export interface PrincipalAppAccess {
114
+ app: string
115
+ /** Resolved by IAM using the same per-app resolver as token issuance; empty for a disabled account. */
116
+ permissions: PermissionEntry[]
117
+ lastSignInAt: number | null
118
+ }
119
+
95
120
  export interface InviteRequest {
96
121
  email: string
97
122
  /** Omitted: `internal`. An `external` user signs in by password only, and OIDC never claims it. */
@@ -111,8 +136,11 @@ export interface UpdatePrincipalRequest {
111
136
  export interface SessionDto {
112
137
  id: string
113
138
  principalId: string
114
- /** How the human proved who they were; `local_dev` is IAM's `LOCAL_DEV_LOGIN` bypass. */
115
- authenticationMethod: 'oidc' | 'password' | 'local_dev'
139
+ /**
140
+ * How the human proved who they were; `local_dev` is IAM's `LOCAL_DEV_LOGIN` bypass, `terminal_assertion` an
141
+ * application's word about who stands at an enrolled terminal.
142
+ */
143
+ authenticationMethod: 'oidc' | 'password' | 'local_dev' | 'terminal_assertion'
116
144
  /** The app this session is bound to (an ADR-0022 child); null = the IAM session itself. */
117
145
  app: string | null
118
146
  /** The IAM session this was derived from; null on an IAM session. Revoking that one revokes this. */
@@ -122,6 +150,13 @@ export interface SessionDto {
122
150
  createdAt: number
123
151
  expiresAt: number
124
152
  revokedAt: number | null
153
+ /** Why this session cannot be used now, independently of its own stored lifecycle. */
154
+ unavailableReason: 'revoked' | 'expired' | 'parent_ended' | 'account_disabled' | 'method_disabled' | null
155
+ }
156
+
157
+ export interface SessionList extends CursorList<SessionDto> {
158
+ /** App sessions belonging to the sign-ins on this page, when `signInsOnly` is requested. */
159
+ applications: SessionDto[]
125
160
  }
126
161
 
127
162
  // ── Grants ────────────────────────────────────────────────────────────────────
@@ -141,9 +176,14 @@ export interface CreateGrantRequest {
141
176
  expiresAt?: number | null
142
177
  }
143
178
 
179
+ /** Change access within its original application, preserving the grant's identity and author. */
180
+ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
181
+ id: string
182
+ }
183
+
144
184
  // ── Apps (read-only; the live registry derived from the schema tables) ────────
145
185
 
146
- /** The set of app ids propustka knows about — the choices for a grant's `app`. */
186
+ /** The set of app ids IAM knows about — the choices for a grant's `app`. */
147
187
  export interface AppDto {
148
188
  id: string
149
189
  /** The name the app's schema declares for people; null when it declares none. */
@@ -155,11 +195,8 @@ export interface AppDto {
155
195
  // ── Roles & policies (per-app, DB-backed) ─────────────────────────────────────
156
196
 
157
197
  /** A role available for the calling app — a built-in or a DB row (app/custom). */
158
- export interface RoleDto {
198
+ export interface RoleDto extends RoleDef {
159
199
  key: string
160
- name: string
161
- description?: string
162
- permissions: string[]
163
200
  /** 'builtin' (cross-app, e.g. admin), 'app' (reconciled), or 'custom' (admin-made). */
164
201
  origin: 'builtin' | 'app' | 'custom'
165
202
  }
@@ -192,6 +229,8 @@ export interface AppSchemaDto {
192
229
  members?: { manage: string; list: string }
193
230
  /** `labels` when the app's directory shows labels to `members.list` holders. */
194
231
  directory?: 'labels'
232
+ /** The app's identification page at a terminal (ADR-0067); absent when the app declares none. */
233
+ terminal?: { identify: string }
195
234
  }
196
235
 
197
236
  // ── Policies (origin='custom' roles, admin-composed) ──────────────────────────
@@ -231,8 +270,9 @@ export interface ApiKeyDto {
231
270
  }
232
271
 
233
272
  /**
234
- * One API key with its live credential. Its permissions are its grants, edited with `grants.create` and
235
- * `grants.delete` by an installation administrator and read again at every token exchange.
273
+ * One API key with its live credential, as `apiKeys.get` and each row of `apiKeys.list` answer it. Its permissions are
274
+ * its grants, edited with `grants.create` and `grants.delete` by an installation administrator and read again at every
275
+ * token exchange. An IAM older than the list's credential answers list rows without `credential`.
236
276
  */
237
277
  export interface ApiKeyDetail extends ApiKeyDto {
238
278
  /** The key's live credential, or null when none is live (a revoked key). */
@@ -264,7 +304,7 @@ export interface ProvisionApiKeyRequest {
264
304
  /**
265
305
  * Provisioning result. `apiKey` (a `px_…` credential bound to the new service principal) is shown
266
306
  * exactly ONCE — copy it now, it is not retrievable later. Carried as a bearer (or a declared
267
- * header) directly to apps on the propustka-native path (`mintFromKey`), no Cloudflare Access in
307
+ * header) directly to apps on the IAM-native path (`mintFromKey`), no Cloudflare Access in
268
308
  * front.
269
309
  */
270
310
  export interface ProvisionApiKeyResponse {
@@ -398,6 +438,7 @@ export interface PrincipalIdInput {
398
438
  export interface ListSessionsInput extends PageInput {
399
439
  /** Whose sessions to list. */
400
440
  principalId: string
441
+ signInsOnly?: boolean
401
442
  }
402
443
 
403
444
  export interface SessionIdInput {
@@ -471,7 +512,14 @@ export interface ListAuditInput {
471
512
  resourceType?: string
472
513
  resourceId?: string
473
514
  principalId?: string
515
+ /** The person affected by the change, distinct from `principalId` (the actor). */
516
+ subjectPrincipalId?: string
474
517
  action?: string
518
+ /**
519
+ * Leave out the admin reads (`iam.admin.access`), which IAM writes for every `/admin/*` request, so a feed of what
520
+ * changed reads changes and not the reads that page through it. An IAM older than this field ignores it.
521
+ */
522
+ changesOnly?: boolean
475
523
  requestId?: string
476
524
  before?: string
477
525
  limit?: number
@@ -557,6 +605,45 @@ export interface IssueMembershipKeyResponse {
557
605
  expiresAt: number
558
606
  }
559
607
 
608
+ // ── Terminals (ADR-0067) ──────────────────────────────────────────────────────
609
+
610
+ /** An application that may assert a person on a terminal, with the action patterns of the person that survive there. */
611
+ export interface TerminalAsserterDto {
612
+ app: string
613
+ ceiling: string[]
614
+ }
615
+
616
+ /**
617
+ * An enrolled browser, as an operator sees it. Its own grants are ordinary grants on `terminalId`, which is its service
618
+ * principal; the cookie is never shown.
619
+ */
620
+ export interface TerminalDto {
621
+ terminalId: string
622
+ label: string
623
+ /** The administrator who enrolled it; null once that principal is gone. */
624
+ enrolledBy: string | null
625
+ /** Seconds a person's session on it lasts. */
626
+ sessionTtl: number
627
+ asserters: TerminalAsserterDto[]
628
+ status: 'active' | 'revoked'
629
+ createdAt: number
630
+ lastSeenAt: number | null
631
+ revokedAt: number | null
632
+ }
633
+
634
+ export type ListTerminalsInput = PageInput
635
+
636
+ export interface TerminalIdInput {
637
+ terminalId: string
638
+ }
639
+
640
+ /** Replace a terminal's whole profile. The ceiling is empty by default: the person brings only their identity. */
641
+ export interface SetTerminalProfileRequest extends TerminalIdInput {
642
+ label: string
643
+ sessionTtl: number
644
+ asserters: TerminalAsserterDto[]
645
+ }
646
+
560
647
  // ── An application's own people, administered by its own administrator ───────
561
648
 
562
649
  /**
@@ -612,6 +699,21 @@ export interface RevokeAppRoleResponse {
612
699
  revoked: boolean
613
700
  }
614
701
 
702
+ /**
703
+ * The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
704
+ * proxy's error pages on every application host. `null` shows the fabrika mark. An installation serves one client, so
705
+ * this is one setting of the installation, kept by IAM.
706
+ */
707
+ export interface InstallationBrandDto {
708
+ brand: InstallationBrand | null
709
+ /** When it was last set or cleared, in epoch seconds; null when it never was. */
710
+ updatedAt: number | null
711
+ }
712
+
713
+ export interface SetInstallationBrandRequest {
714
+ brand: InstallationBrand
715
+ }
716
+
615
717
  export interface IamAdminRpcContract {
616
718
  me: RpcProcedure<void, MeDto>
617
719
  principals: {
@@ -630,7 +732,7 @@ export interface IamAdminRpcContract {
630
732
  * derived from it — a child is only valid while its parent is — so this is one call, not a sweep.
631
733
  */
632
734
  sessions: {
633
- list: RpcProcedure<ListSessionsInput, CursorList<SessionDto>>
735
+ list: RpcProcedure<ListSessionsInput, SessionList>
634
736
  revoke: RpcProcedure<SessionIdInput, RevokedSessionsResponse>
635
737
  revokeAll: RpcProcedure<PrincipalIdInput, RevokedSessionsResponse>
636
738
  }
@@ -642,8 +744,13 @@ export interface IamAdminRpcContract {
642
744
  grants: {
643
745
  /** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
644
746
  create: RpcProcedure<CreateGrantRequest, GrantDto>
747
+ update: RpcProcedure<UpdateGrantInput, GrantDto>
645
748
  delete: RpcProcedure<GrantIdInput, OkResponse>
646
749
  }
750
+ connections: {
751
+ list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>
752
+ revoke: RpcProcedure<GrantIdInput, OkResponse>
753
+ }
647
754
  apps: {
648
755
  list: RpcProcedure<void, ListResponse<AppDto>>
649
756
  getSchema: RpcProcedure<AppInput, AppSchemaDto>
@@ -659,7 +766,7 @@ export interface IamAdminRpcContract {
659
766
  delete: RpcProcedure<PolicyIdInput, OkResponse>
660
767
  }
661
768
  apiKeys: {
662
- list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDto>>
769
+ list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>
663
770
  get: RpcProcedure<ApiKeyIdInput, ApiKeyDetail>
664
771
  provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>
665
772
  rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>
@@ -681,6 +788,15 @@ export interface IamAdminRpcContract {
681
788
  list: RpcProcedure<ListAuditInput, CursorList<AuditEventDto>>
682
789
  listAuthLog: RpcProcedure<ListAuthLogInput, CursorList<AuthLogDto>>
683
790
  }
791
+ /**
792
+ * Enrolled terminals. A browser is enrolled at IAM's `/auth/terminals/enroll`, never here. Revoking a terminal ends
793
+ * every session issued on it.
794
+ */
795
+ terminals: {
796
+ list: RpcProcedure<ListTerminalsInput, CursorList<TerminalDto>>
797
+ setProfile: RpcProcedure<SetTerminalProfileRequest, TerminalDto>
798
+ revoke: RpcProcedure<TerminalIdInput, OkResponse>
799
+ }
684
800
  /**
685
801
  * An application's own people, administered by whoever holds the application's `members.manage` globally there: no
686
802
  * installation admin needed. Each change writes its audit row under the application.
@@ -691,8 +807,39 @@ export interface IamAdminRpcContract {
691
807
  grant: RpcProcedure<GrantAppRoleRequest, GrantAppRoleResponse>
692
808
  revoke: RpcProcedure<RevokeAppRoleRequest, RevokeAppRoleResponse>
693
809
  }
810
+ /**
811
+ * The installation's client logo (ADR-0066), an installation administrator's (`iam.admin`) to read and to change. A
812
+ * change writes `iam.brand.update` in its own transaction. IAM's pages show it on their next render; the proxy's
813
+ * pages once Control republishes their manifests.
814
+ */
815
+ brand: {
816
+ get: RpcProcedure<void, InstallationBrandDto>
817
+ set: RpcProcedure<SetInstallationBrandRequest, InstallationBrandDto>
818
+ clear: RpcProcedure<void, InstallationBrandDto>
819
+ }
820
+ /**
821
+ * The installation's minimum password length (ADR-0020), an installation administrator's (`iam.admin`) to read and to
822
+ * change. A change writes `iam.password_policy.update` in its own transaction and applies to the next password set,
823
+ * reset or chosen at an invitation; stored passwords stay as they are.
824
+ */
825
+ passwordPolicy: {
826
+ get: RpcProcedure<void, PasswordPolicyDto>
827
+ set: RpcProcedure<SetPasswordPolicyRequest, PasswordPolicyDto>
828
+ }
829
+ }
830
+
831
+ export interface UserConnectionDto {
832
+ id: string
833
+ clientId: string
834
+ app: string
835
+ resource: string
836
+ scopes: string[]
837
+ createdAt: number
838
+ expiresAt: number
839
+ status: 'active' | 'revoked' | 'expired' | 'unavailable'
694
840
  }
695
841
 
696
842
  export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef }
697
843
  export * from './access'
698
844
  export * from './oauth'
845
+ export * from './password-policy'
@@ -0,0 +1,43 @@
1
+ // The installation's password policy (ADR-0020): one minimum length for every principal of the installation, which an
2
+ // installation administrator may lower from the default down to the runtime's floor. IAM checks every value again; the
3
+ // console reads these numbers only to say what IAM will accept.
4
+
5
+ /** The minimum of an installation that never set one: NIST SP 800-63B's for a password that is the only factor. */
6
+ export const PASSWORD_DEFAULT_MIN_LENGTH = 15
7
+
8
+ /**
9
+ * The lowest minimum IAM accepts on a runtime whose verifiers meet OWASP's PBKDF2 cost. Below it a password is a PIN, and
10
+ * no throttle makes it one a person can be trusted with.
11
+ */
12
+ export const PASSWORD_MIN_LENGTH_FLOOR = 4
13
+
14
+ /** The most code points a password may have, whatever the minimum. */
15
+ export const PASSWORD_MAX_LENGTH = 256
16
+
17
+ /** Below this NIST asks for a second factor, which IAM does not have; the console says so. */
18
+ export const PASSWORD_SINGLE_FACTOR_FLOOR = 8
19
+
20
+ /** The password policy as IAM applies it now. */
21
+ export interface PasswordPolicyDto {
22
+ /** The minimum length in Unicode code points that IAM applies to every new password. */
23
+ minLength: number
24
+ /** The minimum of an installation that never set one, `PASSWORD_DEFAULT_MIN_LENGTH`. */
25
+ defaultMinLength: number
26
+ /**
27
+ * The lowest minimum this IAM accepts. `PASSWORD_MIN_LENGTH_FLOOR` where verifiers meet OWASP's PBKDF2 cost; the
28
+ * default on a runtime whose cost is lower (a Cloudflare Worker, backlog 201), where a short password is cheap to
29
+ * crack offline.
30
+ */
31
+ minLengthFloor: number
32
+ /** The most code points a password may have. */
33
+ maxLength: number
34
+ /** Whether the installation enables password sign-in at all; the minimum waits for it when it does not. */
35
+ passwordEnabled: boolean
36
+ /** When an administrator last changed the minimum, in epoch seconds; null when nobody ever did. */
37
+ updatedAt: number | null
38
+ }
39
+
40
+ export interface SetPasswordPolicyRequest {
41
+ /** A whole number from `minLengthFloor` to `maxLength`. */
42
+ minLength: number
43
+ }
@@ -6,6 +6,8 @@ export declare const IAM_ACTIONS: Readonly<{
6
6
  ADMIN: "iam.admin";
7
7
  /** Manage the people of applications, never of the installation's own apps. Global, or in `app` values. */
8
8
  USERS_MANAGE: "iam.users.manage";
9
+ /** Enrol a browser as a terminal (ADR-0067). Global only; its profile and revocation stay `iam.admin`'s. */
10
+ TERMINALS_MANAGE: "iam.terminals.manage";
9
11
  }>;
10
12
  export declare const IAM_SCOPES: Readonly<{
11
13
  /** One application environment, by its IAM id `<app>@<env>`. */
@@ -1,5 +1,7 @@
1
1
  import type { RpcProcedureContract } from '@fabrika/app';
2
2
  import type { AppActionDef, AppDelegationDef, AppLinkMountDef, AppMemberItem, AppSchema, AppScopeDef, 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[];
@@ -47,9 +49,18 @@ export interface GrantDto {
47
49
  export interface PrincipalDetail extends PrincipalListItem {
48
50
  /** The mailbox is listed in `IAM_BOOTSTRAP_ADMINS`: an internal user with it is an installation admin. */
49
51
  bootstrapMailbox: boolean;
50
- grants: GrantDto[];
51
- /** Effective permissions with `source` (grant / bootstrap / group:<ref>). */
52
+ grants: PrincipalGrantDto[];
53
+ /** Permissions at IAM only. Prefer `access` for the per-application view. */
52
54
  permissions: PermissionEntry[];
55
+ access: PrincipalAppAccess[];
56
+ /** Presentation capabilities. Every mutation still checks the caller live. */
57
+ management: {
58
+ account: boolean;
59
+ passwordLinks: boolean;
60
+ audit: boolean;
61
+ };
62
+ activatedAt: number | null;
63
+ disabledAt: number | null;
53
64
  authentication: {
54
65
  /** OIDC is linked when this user has claimed an identity-provider subject. */
55
66
  oidc: {
@@ -58,9 +69,28 @@ export interface PrincipalDetail extends PrincipalListItem {
58
69
  /** Password access is globally opt-in and then enabled per user. */
59
70
  password: {
60
71
  state: 'unavailable' | 'disabled' | 'pending' | 'enabled';
72
+ delivery: 'email' | 'manual';
73
+ latestAction: {
74
+ purpose: 'enrollment' | 'reset';
75
+ createdAt: number;
76
+ expiresAt: number;
77
+ closedAt: number | null;
78
+ } | null;
61
79
  };
62
80
  };
63
81
  }
82
+ export interface PrincipalGrantDto extends GrantDto {
83
+ roleName: string | null;
84
+ rolePermissions: string[];
85
+ grantedByLabel: string | null;
86
+ canManage: boolean;
87
+ }
88
+ export interface PrincipalAppAccess {
89
+ app: string;
90
+ /** Resolved by IAM using the same per-app resolver as token issuance; empty for a disabled account. */
91
+ permissions: PermissionEntry[];
92
+ lastSignInAt: number | null;
93
+ }
64
94
  export interface InviteRequest {
65
95
  email: string;
66
96
  /** Omitted: `internal`. An `external` user signs in by password only, and OIDC never claims it. */
@@ -76,8 +106,11 @@ export interface UpdatePrincipalRequest {
76
106
  export interface SessionDto {
77
107
  id: string;
78
108
  principalId: string;
79
- /** How the human proved who they were; `local_dev` is IAM's `LOCAL_DEV_LOGIN` bypass. */
80
- authenticationMethod: 'oidc' | 'password' | 'local_dev';
109
+ /**
110
+ * How the human proved who they were; `local_dev` is IAM's `LOCAL_DEV_LOGIN` bypass, `terminal_assertion` an
111
+ * application's word about who stands at an enrolled terminal.
112
+ */
113
+ authenticationMethod: 'oidc' | 'password' | 'local_dev' | 'terminal_assertion';
81
114
  /** The app this session is bound to (an ADR-0022 child); null = the IAM session itself. */
82
115
  app: string | null;
83
116
  /** The IAM session this was derived from; null on an IAM session. Revoking that one revokes this. */
@@ -87,6 +120,12 @@ export interface SessionDto {
87
120
  createdAt: number;
88
121
  expiresAt: number;
89
122
  revokedAt: number | null;
123
+ /** Why this session cannot be used now, independently of its own stored lifecycle. */
124
+ unavailableReason: 'revoked' | 'expired' | 'parent_ended' | 'account_disabled' | 'method_disabled' | null;
125
+ }
126
+ export interface SessionList extends CursorList<SessionDto> {
127
+ /** App sessions belonging to the sign-ins on this page, when `signInsOnly` is requested. */
128
+ applications: SessionDto[];
90
129
  }
91
130
  export interface CreateGrantRequest {
92
131
  principalId: string;
@@ -102,7 +141,11 @@ export interface CreateGrantRequest {
102
141
  app?: string | null;
103
142
  expiresAt?: number | null;
104
143
  }
105
- /** The set of app ids propustka knows about — the choices for a grant's `app`. */
144
+ /** Change access within its original application, preserving the grant's identity and author. */
145
+ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
146
+ id: string;
147
+ }
148
+ /** The set of app ids IAM knows about — the choices for a grant's `app`. */
106
149
  export interface AppDto {
107
150
  id: string;
108
151
  /** The name the app's schema declares for people; null when it declares none. */
@@ -111,11 +154,8 @@ export interface AppDto {
111
154
  installation: boolean;
112
155
  }
113
156
  /** A role available for the calling app — a built-in or a DB row (app/custom). */
114
- export interface RoleDto {
157
+ export interface RoleDto extends RoleDef {
115
158
  key: string;
116
- name: string;
117
- description?: string;
118
- permissions: string[];
119
159
  /** 'builtin' (cross-app, e.g. admin), 'app' (reconciled), or 'custom' (admin-made). */
120
160
  origin: 'builtin' | 'app' | 'custom';
121
161
  }
@@ -147,6 +187,10 @@ export interface AppSchemaDto {
147
187
  };
148
188
  /** `labels` when the app's directory shows labels to `members.list` holders. */
149
189
  directory?: 'labels';
190
+ /** The app's identification page at a terminal (ADR-0067); absent when the app declares none. */
191
+ terminal?: {
192
+ identify: string;
193
+ };
150
194
  }
151
195
  /** A custom policy (an origin='custom' role row) for an app. */
152
196
  export interface PolicyDto {
@@ -177,8 +221,9 @@ export interface ApiKeyDto {
177
221
  createdAt: number;
178
222
  }
179
223
  /**
180
- * One API key with its live credential. Its permissions are its grants, edited with `grants.create` and
181
- * `grants.delete` by an installation administrator and read again at every token exchange.
224
+ * 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
226
+ * token exchange. An IAM older than the list's credential answers list rows without `credential`.
182
227
  */
183
228
  export interface ApiKeyDetail extends ApiKeyDto {
184
229
  /** The key's live credential, or null when none is live (a revoked key). */
@@ -207,7 +252,7 @@ export interface ProvisionApiKeyRequest {
207
252
  /**
208
253
  * Provisioning result. `apiKey` (a `px_…` credential bound to the new service principal) is shown
209
254
  * exactly ONCE — copy it now, it is not retrievable later. Carried as a bearer (or a declared
210
- * header) directly to apps on the propustka-native path (`mintFromKey`), no Cloudflare Access in
255
+ * header) directly to apps on the IAM-native path (`mintFromKey`), no Cloudflare Access in
211
256
  * front.
212
257
  */
213
258
  export interface ProvisionApiKeyResponse {
@@ -330,6 +375,7 @@ export interface PrincipalIdInput {
330
375
  export interface ListSessionsInput extends PageInput {
331
376
  /** Whose sessions to list. */
332
377
  principalId: string;
378
+ signInsOnly?: boolean;
333
379
  }
334
380
  export interface SessionIdInput {
335
381
  id: string;
@@ -395,7 +441,14 @@ export interface ListAuditInput {
395
441
  resourceType?: string;
396
442
  resourceId?: string;
397
443
  principalId?: string;
444
+ /** The person affected by the change, distinct from `principalId` (the actor). */
445
+ subjectPrincipalId?: string;
398
446
  action?: string;
447
+ /**
448
+ * Leave out the admin reads (`iam.admin.access`), which IAM writes for every `/admin/*` request, so a feed of what
449
+ * changed reads changes and not the reads that page through it. An IAM older than this field ignores it.
450
+ */
451
+ changesOnly?: boolean;
399
452
  requestId?: string;
400
453
  before?: string;
401
454
  limit?: number;
@@ -468,6 +521,38 @@ export interface IssueMembershipKeyResponse {
468
521
  id: string;
469
522
  expiresAt: number;
470
523
  }
524
+ /** An application that may assert a person on a terminal, with the action patterns of the person that survive there. */
525
+ export interface TerminalAsserterDto {
526
+ app: string;
527
+ ceiling: string[];
528
+ }
529
+ /**
530
+ * An enrolled browser, as an operator sees it. Its own grants are ordinary grants on `terminalId`, which is its service
531
+ * principal; the cookie is never shown.
532
+ */
533
+ export interface TerminalDto {
534
+ terminalId: string;
535
+ label: string;
536
+ /** The administrator who enrolled it; null once that principal is gone. */
537
+ enrolledBy: string | null;
538
+ /** Seconds a person's session on it lasts. */
539
+ sessionTtl: number;
540
+ asserters: TerminalAsserterDto[];
541
+ status: 'active' | 'revoked';
542
+ createdAt: number;
543
+ lastSeenAt: number | null;
544
+ revokedAt: number | null;
545
+ }
546
+ export type ListTerminalsInput = PageInput;
547
+ export interface TerminalIdInput {
548
+ terminalId: string;
549
+ }
550
+ /** Replace a terminal's whole profile. The ceiling is empty by default: the person brings only their identity. */
551
+ export interface SetTerminalProfileRequest extends TerminalIdInput {
552
+ label: string;
553
+ sessionTtl: number;
554
+ asserters: TerminalAsserterDto[];
555
+ }
471
556
  /**
472
557
  * An application whose people the caller administers: it holds the application's `members.manage` globally there.
473
558
  * `roles` are the application's global roles the caller may grant, those whose every action it holds itself.
@@ -518,6 +603,19 @@ export interface RevokeAppRoleResponse {
518
603
  /** False when the person held no such grant. */
519
604
  revoked: boolean;
520
605
  }
606
+ /**
607
+ * The installation's client logo on fabrika's own pages (ADR-0066): IAM's sign-in, account and invitation pages, and the
608
+ * proxy's error pages on every application host. `null` shows the fabrika mark. An installation serves one client, so
609
+ * this is one setting of the installation, kept by IAM.
610
+ */
611
+ export interface InstallationBrandDto {
612
+ brand: InstallationBrand | null;
613
+ /** When it was last set or cleared, in epoch seconds; null when it never was. */
614
+ updatedAt: number | null;
615
+ }
616
+ export interface SetInstallationBrandRequest {
617
+ brand: InstallationBrand;
618
+ }
521
619
  export interface IamAdminRpcContract {
522
620
  me: RpcProcedure<void, MeDto>;
523
621
  principals: {
@@ -536,7 +634,7 @@ export interface IamAdminRpcContract {
536
634
  * derived from it — a child is only valid while its parent is — so this is one call, not a sweep.
537
635
  */
538
636
  sessions: {
539
- list: RpcProcedure<ListSessionsInput, CursorList<SessionDto>>;
637
+ list: RpcProcedure<ListSessionsInput, SessionList>;
540
638
  revoke: RpcProcedure<SessionIdInput, RevokedSessionsResponse>;
541
639
  revokeAll: RpcProcedure<PrincipalIdInput, RevokedSessionsResponse>;
542
640
  };
@@ -548,8 +646,13 @@ export interface IamAdminRpcContract {
548
646
  grants: {
549
647
  /** A role grant the principal already holds — same role, scope and app — answers 409 naming it. */
550
648
  create: RpcProcedure<CreateGrantRequest, GrantDto>;
649
+ update: RpcProcedure<UpdateGrantInput, GrantDto>;
551
650
  delete: RpcProcedure<GrantIdInput, OkResponse>;
552
651
  };
652
+ connections: {
653
+ list: RpcProcedure<ListSessionsInput, CursorList<UserConnectionDto>>;
654
+ revoke: RpcProcedure<GrantIdInput, OkResponse>;
655
+ };
553
656
  apps: {
554
657
  list: RpcProcedure<void, ListResponse<AppDto>>;
555
658
  getSchema: RpcProcedure<AppInput, AppSchemaDto>;
@@ -565,7 +668,7 @@ export interface IamAdminRpcContract {
565
668
  delete: RpcProcedure<PolicyIdInput, OkResponse>;
566
669
  };
567
670
  apiKeys: {
568
- list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDto>>;
671
+ list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>;
569
672
  get: RpcProcedure<ApiKeyIdInput, ApiKeyDetail>;
570
673
  provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>;
571
674
  rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>;
@@ -587,6 +690,15 @@ export interface IamAdminRpcContract {
587
690
  list: RpcProcedure<ListAuditInput, CursorList<AuditEventDto>>;
588
691
  listAuthLog: RpcProcedure<ListAuthLogInput, CursorList<AuthLogDto>>;
589
692
  };
693
+ /**
694
+ * Enrolled terminals. A browser is enrolled at IAM's `/auth/terminals/enroll`, never here. Revoking a terminal ends
695
+ * every session issued on it.
696
+ */
697
+ terminals: {
698
+ list: RpcProcedure<ListTerminalsInput, CursorList<TerminalDto>>;
699
+ setProfile: RpcProcedure<SetTerminalProfileRequest, TerminalDto>;
700
+ revoke: RpcProcedure<TerminalIdInput, OkResponse>;
701
+ };
590
702
  /**
591
703
  * An application's own people, administered by whoever holds the application's `members.manage` globally there: no
592
704
  * installation admin needed. Each change writes its audit row under the application.
@@ -597,7 +709,37 @@ export interface IamAdminRpcContract {
597
709
  grant: RpcProcedure<GrantAppRoleRequest, GrantAppRoleResponse>;
598
710
  revoke: RpcProcedure<RevokeAppRoleRequest, RevokeAppRoleResponse>;
599
711
  };
712
+ /**
713
+ * The installation's client logo (ADR-0066), an installation administrator's (`iam.admin`) to read and to change. A
714
+ * change writes `iam.brand.update` in its own transaction. IAM's pages show it on their next render; the proxy's
715
+ * pages once Control republishes their manifests.
716
+ */
717
+ brand: {
718
+ get: RpcProcedure<void, InstallationBrandDto>;
719
+ set: RpcProcedure<SetInstallationBrandRequest, InstallationBrandDto>;
720
+ clear: RpcProcedure<void, InstallationBrandDto>;
721
+ };
722
+ /**
723
+ * The installation's minimum password length (ADR-0020), an installation administrator's (`iam.admin`) to read and to
724
+ * change. A change writes `iam.password_policy.update` in its own transaction and applies to the next password set,
725
+ * reset or chosen at an invitation; stored passwords stay as they are.
726
+ */
727
+ passwordPolicy: {
728
+ get: RpcProcedure<void, PasswordPolicyDto>;
729
+ set: RpcProcedure<SetPasswordPolicyRequest, PasswordPolicyDto>;
730
+ };
731
+ }
732
+ export interface UserConnectionDto {
733
+ id: string;
734
+ clientId: string;
735
+ app: string;
736
+ resource: string;
737
+ scopes: string[];
738
+ createdAt: number;
739
+ expiresAt: number;
740
+ status: 'active' | 'revoked' | 'expired' | 'unavailable';
600
741
  }
601
742
  export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef };
602
743
  export * from './access';
603
744
  export * from './oauth';
745
+ export * from './password-policy';
@@ -0,0 +1,34 @@
1
+ /** The minimum of an installation that never set one: NIST SP 800-63B's for a password that is the only factor. */
2
+ export declare const PASSWORD_DEFAULT_MIN_LENGTH = 15;
3
+ /**
4
+ * The lowest minimum IAM accepts on a runtime whose verifiers meet OWASP's PBKDF2 cost. Below it a password is a PIN, and
5
+ * no throttle makes it one a person can be trusted with.
6
+ */
7
+ export declare const PASSWORD_MIN_LENGTH_FLOOR = 4;
8
+ /** The most code points a password may have, whatever the minimum. */
9
+ export declare const PASSWORD_MAX_LENGTH = 256;
10
+ /** Below this NIST asks for a second factor, which IAM does not have; the console says so. */
11
+ export declare const PASSWORD_SINGLE_FACTOR_FLOOR = 8;
12
+ /** The password policy as IAM applies it now. */
13
+ export interface PasswordPolicyDto {
14
+ /** The minimum length in Unicode code points that IAM applies to every new password. */
15
+ minLength: number;
16
+ /** The minimum of an installation that never set one, `PASSWORD_DEFAULT_MIN_LENGTH`. */
17
+ defaultMinLength: number;
18
+ /**
19
+ * The lowest minimum this IAM accepts. `PASSWORD_MIN_LENGTH_FLOOR` where verifiers meet OWASP's PBKDF2 cost; the
20
+ * default on a runtime whose cost is lower (a Cloudflare Worker, backlog 201), where a short password is cheap to
21
+ * crack offline.
22
+ */
23
+ minLengthFloor: number;
24
+ /** The most code points a password may have. */
25
+ maxLength: number;
26
+ /** Whether the installation enables password sign-in at all; the minimum waits for it when it does not. */
27
+ passwordEnabled: boolean;
28
+ /** When an administrator last changed the minimum, in epoch seconds; null when nobody ever did. */
29
+ updatedAt: number | null;
30
+ }
31
+ export interface SetPasswordPolicyRequest {
32
+ /** A whole number from `minLengthFloor` to `maxLength`. */
33
+ minLength: number;
34
+ }