@fabrika/iam-contract 0.9.0-dev.43 → 0.9.0-dev.44

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.43",
3
+ "version": "0.9.0-dev.44",
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.43",
31
- "@fabrika/auth-core": "0.9.0-dev.43",
32
- "@fabrika/proxy-core": "0.9.0-dev.43"
30
+ "@fabrika/app": "0.9.0-dev.44",
31
+ "@fabrika/auth-core": "0.9.0-dev.44",
32
+ "@fabrika/proxy-core": "0.9.0-dev.44"
33
33
  }
34
34
  }
package/src/index.ts CHANGED
@@ -26,7 +26,30 @@ import type {
26
26
  WorkloadKind,
27
27
  } from '@fabrika/auth-core'
28
28
  import type { InstallationBrand } from '@fabrika/proxy-core/brand'
29
+ import type {
30
+ ExternalAppDto,
31
+ ExternalAppInput,
32
+ ImportOAuthClientsRequest,
33
+ ImportOAuthClientsResponse,
34
+ OAuthClientDto,
35
+ OAuthClientInput,
36
+ PutExternalAppRequest,
37
+ PutOAuthClientRequest,
38
+ } from './oauth-registry'
39
+ import type {
40
+ IssuePasskeyChallengeRequest,
41
+ PasskeyChallenge,
42
+ PasskeyCreationOptions,
43
+ PasskeyDto,
44
+ PasskeyRequestOptions,
45
+ PasskeyResetResponse,
46
+ RegisterPasskeyRequest,
47
+ RemovePasskeyRequest,
48
+ VerifiedPasskeyAssertion,
49
+ VerifyPasskeyAssertionRequest,
50
+ } from './passkeys'
29
51
  import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy'
52
+ import type { ProvisionRequestedApiKeyRequest, RequestedApiKey, RequestedApiKeyInput, RequestedApiKeyResponse } from './requested-keys'
30
53
 
31
54
  // ── Common wrappers ───────────────────────────────────────────────────────────
32
55
 
@@ -182,10 +205,25 @@ export interface CreateGrantRequest {
182
205
  /** App id (a registered app id); null / omitted = all apps (cross-app). */
183
206
  app?: string | null
184
207
  expiresAt?: number | null
208
+ /**
209
+ * The approval request in Control this grant carries out (ADR-0083 §8): an agent's grant, approved by the caller.
210
+ * IAM records it in the change's audit row, and in its grant request's where the application's grants wait. It is
211
+ * the caller's statement, recorded under the caller; it authorizes nothing.
212
+ */
213
+ approvalRequest?: GrantApprovalRequestRef
214
+ }
215
+
216
+ /**
217
+ * The Control approval request a console grant carries out, and who asked for it. IAM refuses ids over 200 characters, a
218
+ * label over 500 and a client id over 2048.
219
+ */
220
+ export interface GrantApprovalRequestRef {
221
+ id: string
222
+ requester: { id: string; label: string; clientId?: string }
185
223
  }
186
224
 
187
225
  /** Change access within its original application, preserving the grant's identity and author. */
188
- export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
226
+ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app' | 'approvalRequest'> {
189
227
  id: string
190
228
  }
191
229
 
@@ -252,14 +290,22 @@ export interface DecideGrantRequestInput {
252
290
  decision: 'approve' | 'reject'
253
291
  }
254
292
 
293
+ /** An environment's `credentials` mode as IAM keeps it for its own key issuance to a machine caller (ADR-0083 §8). */
294
+ export const CREDENTIALS_MODES = ['off', 'person', 'refuse'] as const
295
+
296
+ export type CredentialsMode = (typeof CREDENTIALS_MODES)[number]
297
+
255
298
  /**
256
- * Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
257
- * `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
299
+ * Control's mirror of an application environment's approval gates in IAM, set with the provisioning key (ADR-0083 §4,
300
+ * §8): whether its console grants wait (`required`), and its `credentials` mode. `revision` is the environment's
301
+ * protection revision: IAM ignores one older than it holds, and answers what it holds. A request without `credentials`
302
+ * (an older Control's) clears IAM's mode, which then reads as `person`.
258
303
  */
259
304
  export interface SetGrantApprovalRequest {
260
305
  app: string
261
306
  required: boolean
262
307
  revision: number
308
+ credentials?: CredentialsMode
263
309
  }
264
310
 
265
311
  // ── Apps (read-only; the live registry derived from the schema tables) ────────
@@ -271,6 +317,8 @@ export interface AppDto {
271
317
  displayName: string | null
272
318
  /** One of the installation's own apps (a platform audience): a user administrator grants nothing there (ADR-0058). */
273
319
  installation: boolean
320
+ /** Registered in IAM as an external application (ADR-0089): it has no deploy target, only roles and OAuth clients. */
321
+ externalApplication: boolean
274
322
  }
275
323
 
276
324
  // ── Roles & policies (per-app, DB-backed) ─────────────────────────────────────
@@ -880,7 +928,7 @@ export interface IamAdminRpcContract {
880
928
  list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>
881
929
  decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>
882
930
  }
883
- /** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
931
+ /** An application environment's approval gates in IAM: the provisioning key's alone, which Control holds. */
884
932
  grantApproval: {
885
933
  set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>
886
934
  }
@@ -900,6 +948,28 @@ export interface IamAdminRpcContract {
900
948
  roles: {
901
949
  list: RpcProcedure<ListRolesInput, ListResponse<RoleDto>>
902
950
  }
951
+ /**
952
+ * Applications outside the installation that sign people in through IAM (ADR-0089), an installation administrator's
953
+ * (`iam.admin`). `put` replaces the whole application, its roles and its clients in one transaction; removing a client
954
+ * or the application revokes its OAuth grants there.
955
+ */
956
+ externalApps: {
957
+ list: RpcProcedure<void, ListResponse<ExternalAppDto>>
958
+ get: RpcProcedure<ExternalAppInput, ExternalAppDto>
959
+ put: RpcProcedure<PutExternalAppRequest, ExternalAppDto>
960
+ delete: RpcProcedure<ExternalAppInput, OkResponse>
961
+ }
962
+ /**
963
+ * Every registered OAuth client, listed for an installation administrator. An MCP authoring client is written with
964
+ * the provisioning key only; a client of an external application only through `externalApps.put`.
965
+ */
966
+ oauthClients: {
967
+ list: RpcProcedure<void, ListResponse<OAuthClientDto>>
968
+ put: RpcProcedure<PutOAuthClientRequest, OAuthClientDto>
969
+ delete: RpcProcedure<OAuthClientInput, OkResponse>
970
+ /** The deploy's one import of its client list, with the provisioning key; every later call writes nothing. */
971
+ importOnce: RpcProcedure<ImportOAuthClientsRequest, ImportOAuthClientsResponse>
972
+ }
903
973
  policies: {
904
974
  list: RpcProcedure<AppInput, ListResponse<PolicyDto>>
905
975
  create: RpcProcedure<CreatePolicyInput, PolicyDto>
@@ -910,6 +980,13 @@ export interface IamAdminRpcContract {
910
980
  list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>
911
981
  get: RpcProcedure<ApiKeyIdInput, GetApiKeyResponse>
912
982
  provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>
983
+ /**
984
+ * A key a person approved in Control for the agent that asked (ADR-0083 §8): a person in a signed-in session only,
985
+ * idempotent by the approval request's id, answered encrypted to the agent's public key.
986
+ */
987
+ provisionRequested: RpcProcedure<ProvisionRequestedApiKeyRequest, RequestedApiKey>
988
+ /** The key an approval request issued, by its id: how Control follows an execution whose outcome it did not see. */
989
+ requested: RpcProcedure<RequestedApiKeyInput, RequestedApiKeyResponse>
913
990
  rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>
914
991
  revoke: RpcProcedure<ApiKeyIdInput, OkResponse>
915
992
  }
@@ -976,6 +1053,23 @@ export interface IamAdminRpcContract {
976
1053
  get: RpcProcedure<PrincipalIdInput, SecondFactorDto>
977
1054
  reset: RpcProcedure<PrincipalIdInput, SecondFactorDto>
978
1055
  }
1056
+ /**
1057
+ * A person's passkeys. The first six are the caller's own and need a person in a signed-in session, never a `px_` key:
1058
+ * the console runs the browser half of each ceremony. Registering another passkey while one exists, and removing one,
1059
+ * take an assertion by one of the person's passkeys bound to that change. `challenge` and `verify` are the step-up
1060
+ * seam: a challenge bound to an opaque string, and its verification against the same string. `listOf` and `reset`
1061
+ * are an installation administrator's (`iam.admin`); the reset removes every passkey and writes `iam.passkey.reset`.
1062
+ */
1063
+ passkeys: {
1064
+ list: RpcProcedure<void, ListResponse<PasskeyDto>>
1065
+ registrationOptions: RpcProcedure<void, PasskeyChallenge<PasskeyCreationOptions>>
1066
+ register: RpcProcedure<RegisterPasskeyRequest, PasskeyDto>
1067
+ remove: RpcProcedure<RemovePasskeyRequest, OkResponse>
1068
+ challenge: RpcProcedure<IssuePasskeyChallengeRequest, PasskeyChallenge<PasskeyRequestOptions>>
1069
+ verify: RpcProcedure<VerifyPasskeyAssertionRequest, VerifiedPasskeyAssertion>
1070
+ listOf: RpcProcedure<PrincipalIdInput, ListResponse<PasskeyDto>>
1071
+ reset: RpcProcedure<PrincipalIdInput, PasskeyResetResponse>
1072
+ }
979
1073
  }
980
1074
 
981
1075
  /** Where a signed-in administrator enrols an authenticator app, on IAM's own origin. */
@@ -1016,4 +1110,7 @@ export type {
1016
1110
  }
1017
1111
  export * from './access'
1018
1112
  export * from './oauth'
1113
+ export * from './oauth-registry'
1114
+ export * from './passkeys'
1019
1115
  export * from './password-policy'
1116
+ export * from './requested-keys'
@@ -0,0 +1,87 @@
1
+ // The OAuth clients IAM serves and the external applications they sign people in to (ADR-0089). An installation
2
+ // administrator registers an external application with its roles and clients; the operator, with the provisioning key,
3
+ // registers an MCP authoring client. IAM checks every write; the console reads these shapes only to show them.
4
+
5
+ import type { OAuthClientProvider, OAuthIdentityRole } from './oauth'
6
+
7
+ /**
8
+ * IAM's refusal of a registry write before the deploy imported its client list (release N of ADR-0089), answered with
9
+ * HTTP 409. The console and the CLI match it to say what to do instead of showing a generic conflict.
10
+ */
11
+ export const OAUTH_REGISTRY_NOT_IMPORTED = 'IAM takes registry writes once a deploy of this release has imported the OAuth client list '
12
+ + '(oauthClients.importOnce); until then it serves the clients of its OAUTH_CONFIG. Deploy the platform first.'
13
+
14
+ /** How many clients one external application has. */
15
+ export const MAX_EXTERNAL_APP_CLIENTS = 16
16
+
17
+ /** One client of an external application: its client id, its exact redirect URIs and where IAM fetches its document. */
18
+ export interface ExternalAppClient {
19
+ clientId: string
20
+ redirectUris: string[]
21
+ /** Where IAM fetches the Client ID Metadata Document when it is not the client id itself. */
22
+ metadataUrl?: string | null
23
+ }
24
+
25
+ /**
26
+ * An external application as a whole: an app id with no deploy target, its identity resource, its display name, its
27
+ * roles (each granting no action) and its clients. `externalApps.put` replaces all of it at once.
28
+ */
29
+ export interface PutExternalAppRequest {
30
+ app: string
31
+ name: string
32
+ resource: string
33
+ /** Absent, null or empty: no roles, and every active user signs in. */
34
+ roles?: OAuthIdentityRole[] | null
35
+ clients: ExternalAppClient[]
36
+ }
37
+
38
+ export interface ExternalAppDto {
39
+ app: string
40
+ /** Null for an application the deploy variable's import registered, which named none. */
41
+ name: string | null
42
+ resource: string
43
+ /** Null when the application declares no roles. */
44
+ roles: OAuthIdentityRole[] | null
45
+ clients: { clientId: string; redirectUris: string[]; metadataUrl: string | null }[]
46
+ createdAt: number
47
+ updatedAt: number
48
+ }
49
+
50
+ export interface ExternalAppInput {
51
+ app: string
52
+ }
53
+
54
+ /** A registered OAuth client: an MCP authoring client (`externalApp` null) or a client of an external application. */
55
+ export interface OAuthClientDto {
56
+ clientId: string
57
+ label: OAuthClientProvider
58
+ redirectUris: string[]
59
+ metadataUrl: string | null
60
+ externalApp: string | null
61
+ createdAt: number
62
+ updatedAt: number
63
+ }
64
+
65
+ /** An MCP authoring client, written with the provisioning key only. */
66
+ export interface PutOAuthClientRequest {
67
+ clientId: string
68
+ label: OAuthClientProvider
69
+ redirectUris: string[]
70
+ metadataUrl?: string | null
71
+ }
72
+
73
+ export interface OAuthClientInput {
74
+ clientId: string
75
+ }
76
+
77
+ /**
78
+ * The deploy variable's list, imported once (release N of ADR-0089): each entry in the shape `OAUTH_CONFIG.clients`
79
+ * takes, an `OAuthManagedClient` with an optional `metadataUrl`. IAM checks every entry again.
80
+ */
81
+ export interface ImportOAuthClientsRequest {
82
+ clients: unknown[]
83
+ }
84
+
85
+ export type ImportOAuthClientsResponse =
86
+ | { status: 'imported'; externalApps: string[]; oauthClients: string[] }
87
+ | { status: 'already_imported' }
package/src/oauth.ts CHANGED
@@ -230,11 +230,32 @@ const IDENTITY_APP = /^[a-z0-9][a-z0-9-]{0,62}$/
230
230
  /** A role key; never a built-in one (`admin` means every action of an application). */
231
231
  const IDENTITY_ROLE_KEY = /^[a-z0-9][a-z0-9-]{0,62}$/
232
232
 
233
- function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null {
233
+ /** An HTTPS URL without credentials or a fragment, where IAM may fetch a client's metadata document. */
234
+ export function isHttpsDocumentUrl(value: string): boolean {
235
+ try {
236
+ const url = new URL(value)
237
+ return url.protocol === 'https:' && url.username === '' && url.password === '' && url.hash === ''
238
+ } catch {
239
+ return false
240
+ }
241
+ }
242
+
243
+ /** An external application's id: lowercase, without `@`, at most 63 characters. */
244
+ export function isOAuthIdentityAppId(value: unknown): value is string {
245
+ return typeof value === 'string' && IDENTITY_APP.test(value)
246
+ }
247
+
248
+ /** A role key an external application may declare: lowercase like an app id, and no built-in role key. */
249
+ export function isOAuthIdentityRoleKey(value: unknown): value is string {
250
+ return typeof value === 'string' && IDENTITY_ROLE_KEY.test(value) && !BUILTIN_ROLE_KEYS.includes(value)
251
+ }
252
+
253
+ /** An identity resource binding `{ app, resource, roles? }`, or null when it is not one; unknown keys are refused. */
254
+ export function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null {
234
255
  const app = field(value, 'app')
235
256
  const resource = field(value, 'resource')
236
257
  const rawRoles = field(value, 'roles')
237
- if (!hasOnlyKeys(value, IDENTITY_KEYS) || typeof app !== 'string' || !IDENTITY_APP.test(app) || !isOAuthResourceUri(resource)) return null
258
+ if (!hasOnlyKeys(value, IDENTITY_KEYS) || !isOAuthIdentityAppId(app) || !isOAuthResourceUri(resource)) return null
238
259
  if (rawRoles === undefined) return { app, resource }
239
260
  const roles = parseOAuthIdentityRoles(rawRoles)
240
261
  return roles === null ? null : { app, resource, roles }
@@ -247,8 +268,7 @@ function parseOAuthIdentityRoles(value: unknown): OAuthIdentityRole[] | null {
247
268
  const key = field(entry, 'key')
248
269
  const name = field(entry, 'name')
249
270
  if (
250
- !hasOnlyKeys(entry, ROLE_KEYS) || typeof key !== 'string' || !IDENTITY_ROLE_KEY.test(key) || BUILTIN_ROLE_KEYS.includes(key)
251
- || !isNonemptyText(name)
271
+ !hasOnlyKeys(entry, ROLE_KEYS) || !isOAuthIdentityRoleKey(key) || !isNonemptyText(name)
252
272
  || name.length > 100 || roles.some((role) => role.key === key)
253
273
  ) return null
254
274
  roles.push({ key, name })
@@ -0,0 +1,140 @@
1
+ // A person's passkeys (WebAuthn), kept by IAM. The console runs the browser half of each ceremony; IAM issues the
2
+ // challenge and verifies the answer. Every binary value travels base64url-encoded, as in WebAuthn's JSON encodings.
3
+
4
+ /** How long a ceremony's challenge can be answered, in seconds. */
5
+ export const PASSKEY_CHALLENGE_TTL_SECONDS = 300
6
+
7
+ /** The longest label a person may give a passkey, in characters. */
8
+ export const MAX_PASSKEY_LABEL_LENGTH = 64
9
+
10
+ /** The longest binding a challenge may carry. */
11
+ export const MAX_PASSKEY_BINDING_LENGTH = 512
12
+
13
+ /** How many passkeys one person may keep. */
14
+ export const MAX_PASSKEYS_PER_PERSON = 20
15
+
16
+ /** The error `type` of `passkeys.challenge`'s refusal to a person with no passkey, so a caller tells it from other 409s. */
17
+ export const NO_PASSKEY_ERROR = 'no_passkey'
18
+
19
+ /** The binding of the assertion that registering another passkey takes, when the person already has one. */
20
+ export const PASSKEY_REGISTRATION_BINDING = 'iam:passkeys.register'
21
+
22
+ /** The binding of the assertion that removing the passkey `passkeyId` takes. */
23
+ export function passkeyRemovalBinding(passkeyId: string): string {
24
+ return `iam:passkeys.remove:${passkeyId}`
25
+ }
26
+
27
+ /** A passkey as its owner and an installation administrator see it. No key material. */
28
+ export interface PasskeyDto {
29
+ id: string
30
+ label: string
31
+ /** Epoch seconds. */
32
+ createdAt: number
33
+ /** Epoch seconds of the last accepted assertion; null before the first. */
34
+ lastUsedAt: number | null
35
+ }
36
+
37
+ export interface PasskeyCredentialDescriptor {
38
+ type: 'public-key'
39
+ /** The credential id, base64url. */
40
+ id: string
41
+ transports?: string[]
42
+ }
43
+
44
+ /** `PublicKeyCredentialCreationOptions` in its JSON encoding: what `navigator.credentials.create` takes. */
45
+ export interface PasskeyCreationOptions {
46
+ rp: { id: string; name: string }
47
+ user: { id: string; name: string; displayName: string }
48
+ challenge: string
49
+ pubKeyCredParams: { type: 'public-key'; alg: number }[]
50
+ timeout: number
51
+ /** The person's passkeys, so an authenticator holding one of them does not register it again. */
52
+ excludeCredentials: PasskeyCredentialDescriptor[]
53
+ authenticatorSelection: { residentKey: 'preferred'; userVerification: 'required' }
54
+ attestation: 'none'
55
+ }
56
+
57
+ /** `PublicKeyCredentialRequestOptions` in its JSON encoding: what `navigator.credentials.get` takes. */
58
+ export interface PasskeyRequestOptions {
59
+ challenge: string
60
+ rpId: string
61
+ timeout: number
62
+ /** The person's own passkeys; no other credential can answer. */
63
+ allowCredentials: PasskeyCredentialDescriptor[]
64
+ userVerification: 'required'
65
+ }
66
+
67
+ /** A challenge IAM issued, to be answered once before `expiresAt` (epoch seconds). */
68
+ export interface PasskeyChallenge<Options> {
69
+ challengeId: string
70
+ expiresAt: number
71
+ options: Options
72
+ }
73
+
74
+ /** What `navigator.credentials.create` answered, in its JSON encoding. */
75
+ export interface PasskeyRegistrationCredential {
76
+ id: string
77
+ rawId: string
78
+ type: 'public-key'
79
+ response: {
80
+ clientDataJSON: string
81
+ attestationObject: string
82
+ transports?: string[]
83
+ }
84
+ }
85
+
86
+ /** What `navigator.credentials.get` answered, in its JSON encoding. */
87
+ export interface PasskeyAssertionCredential {
88
+ id: string
89
+ rawId: string
90
+ type: 'public-key'
91
+ response: {
92
+ clientDataJSON: string
93
+ authenticatorData: string
94
+ signature: string
95
+ userHandle?: string
96
+ }
97
+ }
98
+
99
+ /** An answered assertion challenge. */
100
+ export interface PasskeyAssertion {
101
+ challengeId: string
102
+ credential: PasskeyAssertionCredential
103
+ }
104
+
105
+ export interface RegisterPasskeyRequest {
106
+ challengeId: string
107
+ label: string
108
+ credential: PasskeyRegistrationCredential
109
+ /** Required when the person already has a passkey: an assertion bound to `PASSKEY_REGISTRATION_BINDING`. */
110
+ stepUp?: PasskeyAssertion
111
+ }
112
+
113
+ export interface RemovePasskeyRequest {
114
+ passkeyId: string
115
+ /** An assertion by one of the person's passkeys, bound to `passkeyRemovalBinding(passkeyId)`. */
116
+ stepUp: PasskeyAssertion
117
+ }
118
+
119
+ export interface IssuePasskeyChallengeRequest {
120
+ /** What the assertion is for, compared verbatim at verification. Opaque to IAM. */
121
+ binding: string
122
+ }
123
+
124
+ export interface VerifyPasskeyAssertionRequest {
125
+ /** The binding the challenge was issued with. */
126
+ binding: string
127
+ assertion: PasskeyAssertion
128
+ }
129
+
130
+ /** A verified assertion: who answered, with which credential (its WebAuthn id, base64url), and when (epoch seconds). */
131
+ export interface VerifiedPasskeyAssertion {
132
+ principalId: string
133
+ credentialId: string
134
+ at: number
135
+ }
136
+
137
+ export interface PasskeyResetResponse {
138
+ /** How many passkeys the reset removed. */
139
+ removed: number
140
+ }
@@ -0,0 +1,71 @@
1
+ // A key for someone else, asked for through a Control approval request (ADR-0083 §8): the agent that asks sends a public
2
+ // key, and IAM encrypts the key it issues to it before it answers, so the key's plaintext leaves IAM only as a JWE that
3
+ // the agent's private key opens. The request's id is the idempotency key: a repeat answers the same key.
4
+
5
+ import { canonicalJson, sha256Hex } from '@fabrika/auth-core'
6
+
7
+ /** The public keys a requested key may be encrypted to: P-256 or X25519, as a JWK without its private part. */
8
+ export type RecipientPublicKey =
9
+ | { readonly kty: 'EC'; readonly crv: 'P-256'; readonly x: string; readonly y: string }
10
+ | { readonly kty: 'OKP'; readonly crv: 'X25519'; readonly x: string }
11
+
12
+ export const RECIPIENT_CURVES = ['P-256', 'X25519'] as const
13
+
14
+ /** The JWE a requested key travels in: compact, key agreement `ECDH-ES` straight to the recipient, `A256GCM` content. */
15
+ export const REQUESTED_KEY_JWE = { alg: 'ECDH-ES', enc: 'A256GCM' } as const
16
+
17
+ /** The members of a recipient key its RFC 7638 thumbprint hashes: the required public ones, nothing else. */
18
+ function thumbprintMembers(key: RecipientPublicKey): Record<string, string> {
19
+ return key.kty === 'EC' ? { crv: key.crv, kty: key.kty, x: key.x, y: key.y } : { crv: key.crv, kty: key.kty, x: key.x }
20
+ }
21
+
22
+ /**
23
+ * The RFC 7638 thumbprint of a recipient key (SHA-256, base64url): what the approval page shows and the agent prints
24
+ * beside the link, and the `kid` of the JWE IAM answers.
25
+ */
26
+ export function recipientKeyThumbprint(key: RecipientPublicKey): string {
27
+ const hex = sha256Hex(canonicalJson(thumbprintMembers(key)))
28
+ let binary = ''
29
+ for (let i = 0; i < hex.length; i += 2) binary += String.fromCharCode(Number.parseInt(hex.slice(i, i + 2), 16))
30
+ return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '')
31
+ }
32
+
33
+ /** Who asked for a requested key, as IAM records it beside the approver. */
34
+ export interface RequestedKeyApprovalRequest {
35
+ /** The Control approval request's id: the idempotency key of the issuance. At most 200 characters. */
36
+ id: string
37
+ requester: { id: string; label: string; clientId?: string }
38
+ }
39
+
40
+ /**
41
+ * `apiKeys.provisionRequested`: a service key a person approved in Control, issued by that person in a signed-in session.
42
+ * Its permissions are exact actions of `app`, in one scope value or global, and it expires at most 30 days ahead.
43
+ */
44
+ export interface ProvisionRequestedApiKeyRequest {
45
+ label: string
46
+ app: string
47
+ permissions: string[]
48
+ scopeType: string | null
49
+ scopeValue: string | null
50
+ /** Unix seconds; at most `MAX_KEY_LIFETIME_SECONDS` ahead. */
51
+ expiresAt: number
52
+ recipient: RecipientPublicKey
53
+ approvalRequest: RequestedKeyApprovalRequest
54
+ }
55
+
56
+ /** A requested key as IAM answers it: its service principal, and the key encrypted to the recipient. */
57
+ export interface RequestedApiKey {
58
+ principalId: string
59
+ /** The `px_` key, encrypted to the recipient (`REQUESTED_KEY_JWE`), whose thumbprint is the JWE's `kid`. */
60
+ jwe: string
61
+ expiresAt: number
62
+ }
63
+
64
+ export interface RequestedApiKeyInput {
65
+ approvalRequestId: string
66
+ }
67
+
68
+ /** `apiKeys.requested`: the key an approval request issued, or null when it issued none. */
69
+ export interface RequestedApiKeyResponse {
70
+ key: RequestedApiKey | null
71
+ }
@@ -1,7 +1,10 @@
1
1
  import type { RpcProcedureContract } from '@fabrika/app';
2
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, ImportOAuthClientsRequest, ImportOAuthClientsResponse, OAuthClientDto, OAuthClientInput, PutExternalAppRequest, PutOAuthClientRequest } from './oauth-registry';
5
+ import type { IssuePasskeyChallengeRequest, PasskeyChallenge, PasskeyCreationOptions, PasskeyDto, PasskeyRequestOptions, PasskeyResetResponse, RegisterPasskeyRequest, RemovePasskeyRequest, VerifiedPasskeyAssertion, VerifyPasskeyAssertionRequest } from './passkeys';
4
6
  import type { PasswordPolicyDto, SetPasswordPolicyRequest } from './password-policy';
7
+ import type { ProvisionRequestedApiKeyRequest, RequestedApiKey, RequestedApiKeyInput, RequestedApiKeyResponse } from './requested-keys';
5
8
  /** A plain list response. */
6
9
  export interface ListResponse<T> {
7
10
  items: T[];
@@ -146,9 +149,27 @@ export interface CreateGrantRequest {
146
149
  /** App id (a registered app id); null / omitted = all apps (cross-app). */
147
150
  app?: string | null;
148
151
  expiresAt?: number | null;
152
+ /**
153
+ * The approval request in Control this grant carries out (ADR-0083 §8): an agent's grant, approved by the caller.
154
+ * IAM records it in the change's audit row, and in its grant request's where the application's grants wait. It is
155
+ * the caller's statement, recorded under the caller; it authorizes nothing.
156
+ */
157
+ approvalRequest?: GrantApprovalRequestRef;
158
+ }
159
+ /**
160
+ * The Control approval request a console grant carries out, and who asked for it. IAM refuses ids over 200 characters, a
161
+ * label over 500 and a client id over 2048.
162
+ */
163
+ export interface GrantApprovalRequestRef {
164
+ id: string;
165
+ requester: {
166
+ id: string;
167
+ label: string;
168
+ clientId?: string;
169
+ };
149
170
  }
150
171
  /** Change access within its original application, preserving the grant's identity and author. */
151
- export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app'> {
172
+ export interface UpdateGrantInput extends Omit<CreateGrantRequest, 'principalId' | 'app' | 'approvalRequest'> {
152
173
  id: string;
153
174
  }
154
175
  /** How long a grant request stays open for a decision. */
@@ -204,14 +225,20 @@ export interface DecideGrantRequestInput {
204
225
  id: string;
205
226
  decision: 'approve' | 'reject';
206
227
  }
228
+ /** An environment's `credentials` mode as IAM keeps it for its own key issuance to a machine caller (ADR-0083 §8). */
229
+ export declare const CREDENTIALS_MODES: readonly ["off", "person", "refuse"];
230
+ export type CredentialsMode = (typeof CREDENTIALS_MODES)[number];
207
231
  /**
208
- * Whether an application's console grants wait for approval; Control's to set with the provisioning key (ADR-0083).
209
- * `revision` is the environment's protection revision: IAM ignores one older than it holds, and answers what it holds.
232
+ * Control's mirror of an application environment's approval gates in IAM, set with the provisioning key (ADR-0083 §4,
233
+ * §8): whether its console grants wait (`required`), and its `credentials` mode. `revision` is the environment's
234
+ * protection revision: IAM ignores one older than it holds, and answers what it holds. A request without `credentials`
235
+ * (an older Control's) clears IAM's mode, which then reads as `person`.
210
236
  */
211
237
  export interface SetGrantApprovalRequest {
212
238
  app: string;
213
239
  required: boolean;
214
240
  revision: number;
241
+ credentials?: CredentialsMode;
215
242
  }
216
243
  /** The set of app ids IAM knows about — the choices for a grant's `app`. */
217
244
  export interface AppDto {
@@ -220,6 +247,8 @@ export interface AppDto {
220
247
  displayName: string | null;
221
248
  /** One of the installation's own apps (a platform audience): a user administrator grants nothing there (ADR-0058). */
222
249
  installation: boolean;
250
+ /** Registered in IAM as an external application (ADR-0089): it has no deploy target, only roles and OAuth clients. */
251
+ externalApplication: boolean;
223
252
  }
224
253
  /** A role available for the calling app — a built-in or a DB row (app/custom). */
225
254
  export interface RoleDto extends RoleDef {
@@ -766,7 +795,7 @@ export interface IamAdminRpcContract {
766
795
  list: RpcProcedure<ListGrantRequestsInput, ListResponse<GrantRequestDto>>;
767
796
  decide: RpcProcedure<DecideGrantRequestInput, GrantRequestDto>;
768
797
  };
769
- /** Whether an application's console grants wait: an installation administrator's (`iam.admin`), which Control holds. */
798
+ /** An application environment's approval gates in IAM: the provisioning key's alone, which Control holds. */
770
799
  grantApproval: {
771
800
  set: RpcProcedure<SetGrantApprovalRequest, SetGrantApprovalRequest>;
772
801
  };
@@ -786,6 +815,28 @@ export interface IamAdminRpcContract {
786
815
  roles: {
787
816
  list: RpcProcedure<ListRolesInput, ListResponse<RoleDto>>;
788
817
  };
818
+ /**
819
+ * Applications outside the installation that sign people in through IAM (ADR-0089), an installation administrator's
820
+ * (`iam.admin`). `put` replaces the whole application, its roles and its clients in one transaction; removing a client
821
+ * or the application revokes its OAuth grants there.
822
+ */
823
+ externalApps: {
824
+ list: RpcProcedure<void, ListResponse<ExternalAppDto>>;
825
+ get: RpcProcedure<ExternalAppInput, ExternalAppDto>;
826
+ put: RpcProcedure<PutExternalAppRequest, ExternalAppDto>;
827
+ delete: RpcProcedure<ExternalAppInput, OkResponse>;
828
+ };
829
+ /**
830
+ * Every registered OAuth client, listed for an installation administrator. An MCP authoring client is written with
831
+ * the provisioning key only; a client of an external application only through `externalApps.put`.
832
+ */
833
+ oauthClients: {
834
+ list: RpcProcedure<void, ListResponse<OAuthClientDto>>;
835
+ put: RpcProcedure<PutOAuthClientRequest, OAuthClientDto>;
836
+ delete: RpcProcedure<OAuthClientInput, OkResponse>;
837
+ /** The deploy's one import of its client list, with the provisioning key; every later call writes nothing. */
838
+ importOnce: RpcProcedure<ImportOAuthClientsRequest, ImportOAuthClientsResponse>;
839
+ };
789
840
  policies: {
790
841
  list: RpcProcedure<AppInput, ListResponse<PolicyDto>>;
791
842
  create: RpcProcedure<CreatePolicyInput, PolicyDto>;
@@ -796,6 +847,13 @@ export interface IamAdminRpcContract {
796
847
  list: RpcProcedure<ListApiKeysInput, CursorList<ApiKeyDetail>>;
797
848
  get: RpcProcedure<ApiKeyIdInput, GetApiKeyResponse>;
798
849
  provision: RpcProcedure<ProvisionApiKeyRequest, ProvisionApiKeyResponse>;
850
+ /**
851
+ * A key a person approved in Control for the agent that asked (ADR-0083 §8): a person in a signed-in session only,
852
+ * idempotent by the approval request's id, answered encrypted to the agent's public key.
853
+ */
854
+ provisionRequested: RpcProcedure<ProvisionRequestedApiKeyRequest, RequestedApiKey>;
855
+ /** The key an approval request issued, by its id: how Control follows an execution whose outcome it did not see. */
856
+ requested: RpcProcedure<RequestedApiKeyInput, RequestedApiKeyResponse>;
799
857
  rotate: RpcProcedure<RotateApiKeyInput, RotateApiKeyResponse>;
800
858
  revoke: RpcProcedure<ApiKeyIdInput, OkResponse>;
801
859
  };
@@ -862,6 +920,23 @@ export interface IamAdminRpcContract {
862
920
  get: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
863
921
  reset: RpcProcedure<PrincipalIdInput, SecondFactorDto>;
864
922
  };
923
+ /**
924
+ * A person's passkeys. The first six are the caller's own and need a person in a signed-in session, never a `px_` key:
925
+ * the console runs the browser half of each ceremony. Registering another passkey while one exists, and removing one,
926
+ * take an assertion by one of the person's passkeys bound to that change. `challenge` and `verify` are the step-up
927
+ * seam: a challenge bound to an opaque string, and its verification against the same string. `listOf` and `reset`
928
+ * are an installation administrator's (`iam.admin`); the reset removes every passkey and writes `iam.passkey.reset`.
929
+ */
930
+ passkeys: {
931
+ list: RpcProcedure<void, ListResponse<PasskeyDto>>;
932
+ registrationOptions: RpcProcedure<void, PasskeyChallenge<PasskeyCreationOptions>>;
933
+ register: RpcProcedure<RegisterPasskeyRequest, PasskeyDto>;
934
+ remove: RpcProcedure<RemovePasskeyRequest, OkResponse>;
935
+ challenge: RpcProcedure<IssuePasskeyChallengeRequest, PasskeyChallenge<PasskeyRequestOptions>>;
936
+ verify: RpcProcedure<VerifyPasskeyAssertionRequest, VerifiedPasskeyAssertion>;
937
+ listOf: RpcProcedure<PrincipalIdInput, ListResponse<PasskeyDto>>;
938
+ reset: RpcProcedure<PrincipalIdInput, PasskeyResetResponse>;
939
+ };
865
940
  }
866
941
  /** Where a signed-in administrator enrols an authenticator app, on IAM's own origin. */
867
942
  export declare const SECOND_FACTOR_ENROL_PATH = "/auth/second-factor/enrol";
@@ -887,4 +962,7 @@ export interface UserConnectionDto {
887
962
  export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, DimensionValue, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef, };
888
963
  export * from './access';
889
964
  export * from './oauth';
965
+ export * from './oauth-registry';
966
+ export * from './passkeys';
890
967
  export * from './password-policy';
968
+ export * from './requested-keys';
@@ -0,0 +1,79 @@
1
+ import type { OAuthClientProvider, OAuthIdentityRole } from './oauth';
2
+ /**
3
+ * IAM's refusal of a registry write before the deploy imported its client list (release N of ADR-0089), answered with
4
+ * HTTP 409. The console and the CLI match it to say what to do instead of showing a generic conflict.
5
+ */
6
+ export declare const OAUTH_REGISTRY_NOT_IMPORTED: string;
7
+ /** How many clients one external application has. */
8
+ export declare const MAX_EXTERNAL_APP_CLIENTS = 16;
9
+ /** One client of an external application: its client id, its exact redirect URIs and where IAM fetches its document. */
10
+ export interface ExternalAppClient {
11
+ clientId: string;
12
+ redirectUris: string[];
13
+ /** Where IAM fetches the Client ID Metadata Document when it is not the client id itself. */
14
+ metadataUrl?: string | null;
15
+ }
16
+ /**
17
+ * An external application as a whole: an app id with no deploy target, its identity resource, its display name, its
18
+ * roles (each granting no action) and its clients. `externalApps.put` replaces all of it at once.
19
+ */
20
+ export interface PutExternalAppRequest {
21
+ app: string;
22
+ name: string;
23
+ resource: string;
24
+ /** Absent, null or empty: no roles, and every active user signs in. */
25
+ roles?: OAuthIdentityRole[] | null;
26
+ clients: ExternalAppClient[];
27
+ }
28
+ export interface ExternalAppDto {
29
+ app: string;
30
+ /** Null for an application the deploy variable's import registered, which named none. */
31
+ name: string | null;
32
+ resource: string;
33
+ /** Null when the application declares no roles. */
34
+ roles: OAuthIdentityRole[] | null;
35
+ clients: {
36
+ clientId: string;
37
+ redirectUris: string[];
38
+ metadataUrl: string | null;
39
+ }[];
40
+ createdAt: number;
41
+ updatedAt: number;
42
+ }
43
+ export interface ExternalAppInput {
44
+ app: string;
45
+ }
46
+ /** A registered OAuth client: an MCP authoring client (`externalApp` null) or a client of an external application. */
47
+ export interface OAuthClientDto {
48
+ clientId: string;
49
+ label: OAuthClientProvider;
50
+ redirectUris: string[];
51
+ metadataUrl: string | null;
52
+ externalApp: string | null;
53
+ createdAt: number;
54
+ updatedAt: number;
55
+ }
56
+ /** An MCP authoring client, written with the provisioning key only. */
57
+ export interface PutOAuthClientRequest {
58
+ clientId: string;
59
+ label: OAuthClientProvider;
60
+ redirectUris: string[];
61
+ metadataUrl?: string | null;
62
+ }
63
+ export interface OAuthClientInput {
64
+ clientId: string;
65
+ }
66
+ /**
67
+ * The deploy variable's list, imported once (release N of ADR-0089): each entry in the shape `OAUTH_CONFIG.clients`
68
+ * takes, an `OAuthManagedClient` with an optional `metadataUrl`. IAM checks every entry again.
69
+ */
70
+ export interface ImportOAuthClientsRequest {
71
+ clients: unknown[];
72
+ }
73
+ export type ImportOAuthClientsResponse = {
74
+ status: 'imported';
75
+ externalApps: string[];
76
+ oauthClients: string[];
77
+ } | {
78
+ status: 'already_imported';
79
+ };
@@ -187,6 +187,14 @@ export interface OAuthAuthorizationServerMetadata {
187
187
  client_id_metadata_document_supported: true;
188
188
  }
189
189
  export declare function parseOAuthManagedClient(value: unknown): OAuthManagedClient | null;
190
+ /** An HTTPS URL without credentials or a fragment, where IAM may fetch a client's metadata document. */
191
+ export declare function isHttpsDocumentUrl(value: string): boolean;
192
+ /** An external application's id: lowercase, without `@`, at most 63 characters. */
193
+ export declare function isOAuthIdentityAppId(value: unknown): value is string;
194
+ /** A role key an external application may declare: lowercase like an app id, and no built-in role key. */
195
+ export declare function isOAuthIdentityRoleKey(value: unknown): value is string;
196
+ /** An identity resource binding `{ app, resource, roles? }`, or null when it is not one; unknown keys are refused. */
197
+ export declare function parseOAuthIdentityResource(value: unknown): OAuthIdentityResource | null;
190
198
  /** The scopes an identity resource's authorization asks for: none, or exactly `identity`. */
191
199
  export declare function resolveOAuthIdentityScopes(scope: string | undefined): string[] | null;
192
200
  /** A fetched document cannot enlarge the managed registration's exact redirect allowlist. */
@@ -0,0 +1,128 @@
1
+ /** How long a ceremony's challenge can be answered, in seconds. */
2
+ export declare const PASSKEY_CHALLENGE_TTL_SECONDS = 300;
3
+ /** The longest label a person may give a passkey, in characters. */
4
+ export declare const MAX_PASSKEY_LABEL_LENGTH = 64;
5
+ /** The longest binding a challenge may carry. */
6
+ export declare const MAX_PASSKEY_BINDING_LENGTH = 512;
7
+ /** How many passkeys one person may keep. */
8
+ export declare const MAX_PASSKEYS_PER_PERSON = 20;
9
+ /** The error `type` of `passkeys.challenge`'s refusal to a person with no passkey, so a caller tells it from other 409s. */
10
+ export declare const NO_PASSKEY_ERROR = "no_passkey";
11
+ /** The binding of the assertion that registering another passkey takes, when the person already has one. */
12
+ export declare const PASSKEY_REGISTRATION_BINDING = "iam:passkeys.register";
13
+ /** The binding of the assertion that removing the passkey `passkeyId` takes. */
14
+ export declare function passkeyRemovalBinding(passkeyId: string): string;
15
+ /** A passkey as its owner and an installation administrator see it. No key material. */
16
+ export interface PasskeyDto {
17
+ id: string;
18
+ label: string;
19
+ /** Epoch seconds. */
20
+ createdAt: number;
21
+ /** Epoch seconds of the last accepted assertion; null before the first. */
22
+ lastUsedAt: number | null;
23
+ }
24
+ export interface PasskeyCredentialDescriptor {
25
+ type: 'public-key';
26
+ /** The credential id, base64url. */
27
+ id: string;
28
+ transports?: string[];
29
+ }
30
+ /** `PublicKeyCredentialCreationOptions` in its JSON encoding: what `navigator.credentials.create` takes. */
31
+ export interface PasskeyCreationOptions {
32
+ rp: {
33
+ id: string;
34
+ name: string;
35
+ };
36
+ user: {
37
+ id: string;
38
+ name: string;
39
+ displayName: string;
40
+ };
41
+ challenge: string;
42
+ pubKeyCredParams: {
43
+ type: 'public-key';
44
+ alg: number;
45
+ }[];
46
+ timeout: number;
47
+ /** The person's passkeys, so an authenticator holding one of them does not register it again. */
48
+ excludeCredentials: PasskeyCredentialDescriptor[];
49
+ authenticatorSelection: {
50
+ residentKey: 'preferred';
51
+ userVerification: 'required';
52
+ };
53
+ attestation: 'none';
54
+ }
55
+ /** `PublicKeyCredentialRequestOptions` in its JSON encoding: what `navigator.credentials.get` takes. */
56
+ export interface PasskeyRequestOptions {
57
+ challenge: string;
58
+ rpId: string;
59
+ timeout: number;
60
+ /** The person's own passkeys; no other credential can answer. */
61
+ allowCredentials: PasskeyCredentialDescriptor[];
62
+ userVerification: 'required';
63
+ }
64
+ /** A challenge IAM issued, to be answered once before `expiresAt` (epoch seconds). */
65
+ export interface PasskeyChallenge<Options> {
66
+ challengeId: string;
67
+ expiresAt: number;
68
+ options: Options;
69
+ }
70
+ /** What `navigator.credentials.create` answered, in its JSON encoding. */
71
+ export interface PasskeyRegistrationCredential {
72
+ id: string;
73
+ rawId: string;
74
+ type: 'public-key';
75
+ response: {
76
+ clientDataJSON: string;
77
+ attestationObject: string;
78
+ transports?: string[];
79
+ };
80
+ }
81
+ /** What `navigator.credentials.get` answered, in its JSON encoding. */
82
+ export interface PasskeyAssertionCredential {
83
+ id: string;
84
+ rawId: string;
85
+ type: 'public-key';
86
+ response: {
87
+ clientDataJSON: string;
88
+ authenticatorData: string;
89
+ signature: string;
90
+ userHandle?: string;
91
+ };
92
+ }
93
+ /** An answered assertion challenge. */
94
+ export interface PasskeyAssertion {
95
+ challengeId: string;
96
+ credential: PasskeyAssertionCredential;
97
+ }
98
+ export interface RegisterPasskeyRequest {
99
+ challengeId: string;
100
+ label: string;
101
+ credential: PasskeyRegistrationCredential;
102
+ /** Required when the person already has a passkey: an assertion bound to `PASSKEY_REGISTRATION_BINDING`. */
103
+ stepUp?: PasskeyAssertion;
104
+ }
105
+ export interface RemovePasskeyRequest {
106
+ passkeyId: string;
107
+ /** An assertion by one of the person's passkeys, bound to `passkeyRemovalBinding(passkeyId)`. */
108
+ stepUp: PasskeyAssertion;
109
+ }
110
+ export interface IssuePasskeyChallengeRequest {
111
+ /** What the assertion is for, compared verbatim at verification. Opaque to IAM. */
112
+ binding: string;
113
+ }
114
+ export interface VerifyPasskeyAssertionRequest {
115
+ /** The binding the challenge was issued with. */
116
+ binding: string;
117
+ assertion: PasskeyAssertion;
118
+ }
119
+ /** A verified assertion: who answered, with which credential (its WebAuthn id, base64url), and when (epoch seconds). */
120
+ export interface VerifiedPasskeyAssertion {
121
+ principalId: string;
122
+ credentialId: string;
123
+ at: number;
124
+ }
125
+ export interface PasskeyResetResponse {
126
+ /** How many passkeys the reset removed. */
127
+ removed: number;
128
+ }
@@ -0,0 +1,61 @@
1
+ /** The public keys a requested key may be encrypted to: P-256 or X25519, as a JWK without its private part. */
2
+ export type RecipientPublicKey = {
3
+ readonly kty: 'EC';
4
+ readonly crv: 'P-256';
5
+ readonly x: string;
6
+ readonly y: string;
7
+ } | {
8
+ readonly kty: 'OKP';
9
+ readonly crv: 'X25519';
10
+ readonly x: string;
11
+ };
12
+ export declare const RECIPIENT_CURVES: readonly ["P-256", "X25519"];
13
+ /** The JWE a requested key travels in: compact, key agreement `ECDH-ES` straight to the recipient, `A256GCM` content. */
14
+ export declare const REQUESTED_KEY_JWE: {
15
+ readonly alg: "ECDH-ES";
16
+ readonly enc: "A256GCM";
17
+ };
18
+ /**
19
+ * The RFC 7638 thumbprint of a recipient key (SHA-256, base64url): what the approval page shows and the agent prints
20
+ * beside the link, and the `kid` of the JWE IAM answers.
21
+ */
22
+ export declare function recipientKeyThumbprint(key: RecipientPublicKey): string;
23
+ /** Who asked for a requested key, as IAM records it beside the approver. */
24
+ export interface RequestedKeyApprovalRequest {
25
+ /** The Control approval request's id: the idempotency key of the issuance. At most 200 characters. */
26
+ id: string;
27
+ requester: {
28
+ id: string;
29
+ label: string;
30
+ clientId?: string;
31
+ };
32
+ }
33
+ /**
34
+ * `apiKeys.provisionRequested`: a service key a person approved in Control, issued by that person in a signed-in session.
35
+ * Its permissions are exact actions of `app`, in one scope value or global, and it expires at most 30 days ahead.
36
+ */
37
+ export interface ProvisionRequestedApiKeyRequest {
38
+ label: string;
39
+ app: string;
40
+ permissions: string[];
41
+ scopeType: string | null;
42
+ scopeValue: string | null;
43
+ /** Unix seconds; at most `MAX_KEY_LIFETIME_SECONDS` ahead. */
44
+ expiresAt: number;
45
+ recipient: RecipientPublicKey;
46
+ approvalRequest: RequestedKeyApprovalRequest;
47
+ }
48
+ /** A requested key as IAM answers it: its service principal, and the key encrypted to the recipient. */
49
+ export interface RequestedApiKey {
50
+ principalId: string;
51
+ /** The `px_` key, encrypted to the recipient (`REQUESTED_KEY_JWE`), whose thumbprint is the JWE's `kid`. */
52
+ jwe: string;
53
+ expiresAt: number;
54
+ }
55
+ export interface RequestedApiKeyInput {
56
+ approvalRequestId: string;
57
+ }
58
+ /** `apiKeys.requested`: the key an approval request issued, or null when it issued none. */
59
+ export interface RequestedApiKeyResponse {
60
+ key: RequestedApiKey | null;
61
+ }