@fabrika/auth-core 0.9.0-dev.1 → 0.9.0-dev.10

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.
Files changed (44) hide show
  1. package/package.json +4 -3
  2. package/src/contract-canonical.ts +1 -0
  3. package/src/contract.ts +6 -0
  4. package/src/dev-environment.ts +6 -0
  5. package/src/framework-release.ts +2 -0
  6. package/src/framework-variables.ts +9 -0
  7. package/src/index.ts +4 -0
  8. package/src/managed-environment.ts +136 -0
  9. package/src/ops.ts +1933 -0
  10. package/src/rpc.ts +8 -8
  11. package/src/terminal.ts +105 -0
  12. package/src/token.ts +73 -13
  13. package/src/types.ts +5 -2
  14. package/src/wire.ts +6 -0
  15. package/types/src/app-environment.d.ts +24 -0
  16. package/types/src/canonical-path.d.ts +20 -0
  17. package/types/src/contract-canonical.d.ts +19 -0
  18. package/types/src/contract.d.ts +800 -0
  19. package/types/src/dev-environment.d.ts +37 -0
  20. package/types/src/device.d.ts +144 -0
  21. package/types/src/endpoint-digest.d.ts +58 -0
  22. package/types/src/endpoints.d.ts +65 -0
  23. package/types/src/environment.d.ts +58 -0
  24. package/types/src/framework-release.d.ts +2 -0
  25. package/types/src/framework-variables.d.ts +86 -0
  26. package/types/src/index.d.ts +28 -0
  27. package/types/src/installation-endpoint.d.ts +46 -0
  28. package/types/src/json.d.ts +13 -0
  29. package/types/src/locale.d.ts +14 -0
  30. package/types/src/mail.d.ts +67 -0
  31. package/types/src/managed-environment.d.ts +32 -0
  32. package/types/src/membership.d.ts +318 -0
  33. package/types/src/oauth.d.ts +7 -0
  34. package/types/src/ops.d.ts +657 -0
  35. package/types/src/path-segment.d.ts +5 -0
  36. package/types/src/permissions.d.ts +50 -0
  37. package/types/src/requirement.d.ts +24 -0
  38. package/types/src/rpc.d.ts +283 -0
  39. package/types/src/sha256.d.ts +2 -0
  40. package/types/src/terminal.d.ts +72 -0
  41. package/types/src/token.d.ts +240 -0
  42. package/types/src/types.d.ts +196 -0
  43. package/types/src/wire.d.ts +65 -0
  44. package/types/src/workloads.d.ts +25 -0
@@ -0,0 +1,50 @@
1
+ import type { PermissionEntry, Scope } from './types';
2
+ /**
3
+ * Wildcard action matching. The pattern is one of:
4
+ * - '*' — matches every action
5
+ * - 'prefix.*' — matches the `prefix` namespace and anything nested under it
6
+ * (e.g. 'project.*' matches 'project.read' and 'project.settings.update',
7
+ * but NOT 'projects.read' — the boundary is the dot)
8
+ * - exact — matches only that exact action string
9
+ *
10
+ * Examples:
11
+ * matchAction('*', 'x.y') === true
12
+ * matchAction('project.*', 'project.read') === true
13
+ * matchAction('project.*', 'project.settings.update') === true
14
+ * matchAction('project.read', 'project.read') === true
15
+ * matchAction('project.read', 'project.write') === false
16
+ * matchAction('project.*', 'projects.read') === false
17
+ */
18
+ export declare function matchAction(pattern: string, action: string): boolean;
19
+ /**
20
+ * Does `entries` grant `action` at the given scope? Mirrors `can()` semantics exactly:
21
+ * - scope === undefined → scope-less: ONLY entries with scope === null satisfy (global perms only).
22
+ * - scope === <Scope> → entries with scope === null OR an entry scoped to the SAME
23
+ * (type, value) pair satisfy.
24
+ *
25
+ * Within the satisfying entries, the entry's `action` is matched against the requested
26
+ * `action` using `matchAction` (so a wildcard entry like 'project.*' grants 'project.read').
27
+ */
28
+ export declare function permits(entries: PermissionEntry[], action: string, scope?: Scope): boolean;
29
+ /**
30
+ * The set of scope values `entries` grant `action` on within a single `dimension`
31
+ * (scope type) — the resolution behind `scopedTo()`, shared so the real SDK context and
32
+ * any fake/test context agree exactly:
33
+ * - `null` → unrestricted: a matching GLOBAL entry (scope === null) exists, so the
34
+ * principal holds the action everywhere (e.g. an admin / app-wide grant);
35
+ * - non-empty → exactly the scope values of the matching entries scoped to `dimension`;
36
+ * - `[]` → no matching entry: no scoped access at all within `dimension`.
37
+ * A matching global entry short-circuits to `null` (it dominates any scoped entries).
38
+ * Entries scoped to a DIFFERENT dimension are ignored (they say nothing about `dimension`).
39
+ */
40
+ export declare function scopedValues(entries: PermissionEntry[], action: string, dimension: string): string[] | null;
41
+ /**
42
+ * Validate a role/policy/inline action PATTERN against an app's action `catalog`.
43
+ * The catalog holds concrete action strings the app actually exposes (no wildcards).
44
+ * - '*' → always valid (the universal wildcard).
45
+ * - exact match → valid iff the catalog contains the pattern verbatim.
46
+ * - 'prefix.*' → valid iff some catalog action starts with `prefix.` (i.e. the
47
+ * namespace is non-empty), so we never grant a wildcard over nothing.
48
+ * - otherwise → invalid.
49
+ */
50
+ export declare function isActionAllowed(pattern: string, catalog: readonly string[]): boolean;
@@ -0,0 +1,24 @@
1
+ import { type EndpointRequirement } from './contract';
2
+ import { type AuthenticatedRequirement, type TokenCaller } from './installation-endpoint';
3
+ import type { AccessTokenClaims } from './token';
4
+ import type { PermissionEntry } from './types';
5
+ /**
6
+ * Whether a token's permissions meet an endpoint's requirement. This is authorization, not a gate: it reads only the
7
+ * token. `member` is any permission of this application; an action is that action in some scope, global included.
8
+ * The access form narrows it to one scope afterwards, against the application's own data. The `app` form is the
9
+ * action held as a global grant, so an entry scoped to any value does not meet it. Several capabilities need every
10
+ * one of their actions. `authenticated`, which only an installation row carries, needs no permission.
11
+ */
12
+ export declare function satisfies(requirement: EndpointRequirement | AuthenticatedRequirement, perms: readonly PermissionEntry[]): boolean;
13
+ /**
14
+ * The caller kind a verified token presents: a `user` principal is `human`, a `service` principal is `machine`, a
15
+ * connector key of application `<id>` is `app:<id>`, and a token bound to no principal is a share link. An OAuth
16
+ * resource token is `oauth`, which only an installation row admits. A job, webhook or public procedure token is no
17
+ * caller: `null` is refused by every endpoint.
18
+ */
19
+ export declare function callerOf(claims: AccessTokenClaims): TokenCaller | null;
20
+ /**
21
+ * Whether a caller may be admitted at an endpoint path. A connector caller `app:<id>` reaches only an export's paths
22
+ * (ADR-0022 "Principal kinds"); every other caller is not limited by the path.
23
+ */
24
+ export declare function callerAdmittedAt(caller: TokenCaller, path: string): boolean;
@@ -0,0 +1,283 @@
1
+ import type { ApproveDeviceAuthorizationInput, ApproveDeviceAuthorizationResult, DenyDeviceAuthorizationResult, InspectDeviceAuthorizationInput, InspectDeviceAuthorizationResult, ListOwnDeviceAuthorizationsInput, ListOwnDeviceAuthorizationsResult } from './device';
2
+ import type { Jwks } from './token';
3
+ import type { PermissionEntry, PrincipalType, Scope } from './types';
4
+ export interface MintTokenInput {
5
+ /** The app requesting a permission token (the SDK bakes this into its constructor). */
6
+ app: string;
7
+ /** The opaque session cookie value (`__Host-px_session`); null when the browser has no session. */
8
+ session: string | null;
9
+ requestId: string;
10
+ }
11
+ export type MintTokenResult =
12
+ /** `expiresAt` (unix seconds) lets the SDK refresh ahead of expiry. */
13
+ {
14
+ ok: true;
15
+ token: string;
16
+ expiresAt: number;
17
+ }
18
+ /** `token_too_large`: the principal holds more than fits in one header; a decided refusal, never a login bounce. */
19
+ | {
20
+ ok: false;
21
+ reason: 'no_session' | 'invalid_session' | 'unknown_principal' | 'disabled' | 'token_too_large';
22
+ };
23
+ export interface MintFromKeyInput {
24
+ /** The app requesting the token (the SDK bakes this into its constructor). */
25
+ app: string;
26
+ /** The opaque `px_` credential (bearer / path token). */
27
+ key: string;
28
+ requestId: string;
29
+ }
30
+ export type MintFromKeyResult = {
31
+ ok: true;
32
+ token: string;
33
+ expiresAt: number;
34
+ } | {
35
+ ok: false;
36
+ reason: 'invalid_key' | 'unknown_principal' | 'disabled' | 'token_too_large';
37
+ };
38
+ export interface ExchangeAuthCodeInput {
39
+ /** The app redeeming the code. A code issued for another app is refused. */
40
+ app: string;
41
+ /** The single-use code, as it arrived in the callback query. */
42
+ code: string;
43
+ /** Browser-held proof for the S256 challenge integrity-bound into the code. */
44
+ verifier: string;
45
+ requestId: string;
46
+ }
47
+ export type ExchangeAuthCodeResult =
48
+ /**
49
+ * `session` is the opaque APP session the proxy sets as a host-only cookie; `returnUrl` is where
50
+ * the browser goes next and is carried server-side so a caller cannot redirect it elsewhere.
51
+ * `expiresAt` is the session's absolute expiry, for the cookie's `Max-Age`.
52
+ */
53
+ {
54
+ ok: true;
55
+ session: string;
56
+ returnUrl: string;
57
+ expiresAt: number;
58
+ }
59
+ /** Every failure is terminal — a code is single-use, so there is nothing to retry. */
60
+ | {
61
+ ok: false;
62
+ reason: 'invalid_code' | 'expired_code' | 'wrong_app' | 'invalid_verifier' | 'unknown_principal' | 'disabled';
63
+ };
64
+ /**
65
+ * Redemption, as a contract of its own rather than a method on `IamRpc`. Only the proxy calls it, and
66
+ * `IamRpc` is held by every SDK consumer — folding it in would hand the ability to convert a code
67
+ * into a session to everything that holds the management key.
68
+ */
69
+ export interface IamHandoffRpc {
70
+ exchangeAuthCode(input: ExchangeAuthCodeInput): Promise<ExchangeAuthCodeResult>;
71
+ }
72
+ /**
73
+ * Where the proxy answers the handoff, on every app host it fronts. Reserved: an app route at this
74
+ * path is shadowed by the proxy and never reaches the upstream, so it is deliberately namespaced.
75
+ */
76
+ export declare const AUTH_CALLBACK_PATH = "/__fabrika/auth/callback";
77
+ /** Query parameter carrying the single-use code on the callback. */
78
+ export declare const AUTH_CODE_PARAM = "code";
79
+ /** Public nonce that selects the app-host handoff cookie on the callback. */
80
+ export declare const AUTH_HANDOFF_STATE_PARAM = "state";
81
+ /** S256 challenge sent to IAM when the proxy starts a handoff. */
82
+ export declare const AUTH_HANDOFF_CHALLENGE_PARAM = "code_challenge";
83
+ /** Dynamic app-host cookie prefix; the public state suffix permits concurrent login tabs. */
84
+ export declare const HANDOFF_COOKIE_PREFIX = "__Host-px_handoff_";
85
+ /** A login attempt may wait at IAM or an upstream IdP before the code itself is issued. */
86
+ export declare const HANDOFF_COOKIE_TTL_SECONDS: number;
87
+ /**
88
+ * How long a code may be held before redemption. Seconds, not minutes: it travels in one redirect
89
+ * and is redeemed by the next request, so anything longer is only a larger replay window.
90
+ */
91
+ export declare const AUTH_CODE_TTL_SECONDS = 120;
92
+ /** One grant on a `px_` credential — an action pattern + optional scope. */
93
+ export interface KeyGrant {
94
+ action: string;
95
+ /** Omitted/null = global (the issuer must hold the action globally). */
96
+ scope?: Scope | null;
97
+ }
98
+ /**
99
+ * Create a NEW service (machine) principal and bind the key to it — the folded `issueServiceToken`.
100
+ * The issuer must hold every `permissions` action on `scope` (the same delegation rule as a grant).
101
+ */
102
+ export interface IssueKeyServiceSpec {
103
+ /** Display label for the new service principal + the credential. */
104
+ label: string;
105
+ /** Inline action patterns granted to the new service principal; delegation-checked on `scope`. */
106
+ permissions: string[];
107
+ /** Scope the grant + the delegation check apply to; omitted/null → global. */
108
+ scope?: Scope | null;
109
+ }
110
+ export interface IssueKeyInput {
111
+ app: string;
112
+ /**
113
+ * The IAM-native credential the ISSUER is resolved from server-side (never self-asserted):
114
+ * a `px_token` access JWT (verified against IAM's signing keys) or a `px_` key. Null = absent.
115
+ */
116
+ credential: string | null;
117
+ requestId: string;
118
+ /**
119
+ * Create a NEW machine principal and bind the key to it (the folded `issueServiceToken`). When set,
120
+ * `principalId` / `permissions` (the bind / standalone modes) are ignored.
121
+ */
122
+ service?: IssueKeyServiceSpec;
123
+ /**
124
+ * Bind to a principal (the credential then carries that principal's LIVE perms; inline
125
+ * `permissions` downscope it). v1: only the issuer's OWN id. Omit for a standalone credential.
126
+ */
127
+ principalId?: string;
128
+ /** Inline grants — the frozen set (standalone) and/or a downscope restriction (bound). */
129
+ permissions?: KeyGrant[];
130
+ label?: string;
131
+ /** Absolute credential expiry (unix seconds), after now and at most `MAX_KEY_LIFETIME_SECONDS` ahead. */
132
+ expiresAt: number;
133
+ }
134
+ /**
135
+ * The longest a `px_` credential `issueKey` writes may live, in every mode. A key is a standing copy
136
+ * of authority that outlives any token it was issued from, so it must end; 30 days is also the
137
+ * builder's device-authorized key lifetime.
138
+ */
139
+ export declare const MAX_KEY_LIFETIME_SECONDS: number;
140
+ export type IssueKeyResult =
141
+ /**
142
+ * Plaintext `px_` token returned ONCE; `id` is the credential's stable handle (revoke). `principalId`
143
+ * is present when the key is bound to a principal (a `service` create or a self-bind), absent for a
144
+ * standalone (anonymous) credential.
145
+ */
146
+ {
147
+ ok: true;
148
+ token: string;
149
+ id: string;
150
+ principalId?: string;
151
+ } | {
152
+ ok: false;
153
+ reason: 'missing_token' | 'invalid_token' | 'unknown_principal' | 'disabled' | 'not_allowed';
154
+ };
155
+ /**
156
+ * A resolved caller identity + its frozen permission snapshot. Produced by `accessClaimsToResolved`
157
+ * from a verified access token (`token.ts`); consumed where a principal's resolved perms are needed
158
+ * as a plain serializable value.
159
+ */
160
+ export interface ResolvedPrincipal {
161
+ id: string;
162
+ type: PrincipalType;
163
+ label: string;
164
+ permissions: PermissionEntry[];
165
+ requestId: string;
166
+ }
167
+ export interface AuditInput {
168
+ /**
169
+ * The caller's verified access token — the one the proxy injected. IAM verifies it and records
170
+ * the app it was minted for; there is no `app` field, so a caller cannot name another app.
171
+ */
172
+ credential: string;
173
+ requestId: string;
174
+ /** NULL for an anonymous-credential event (a share link has no principal). */
175
+ principalId: string | null;
176
+ /** Snapshot — survives principal deletion (the credential/token label for anonymous events). */
177
+ principalLabel: string;
178
+ /** Set for an anonymous-credential event — the issuing credential id. */
179
+ credentialId?: string;
180
+ action: string;
181
+ resourceType: string;
182
+ resourceId?: string;
183
+ diff?: unknown;
184
+ metadata?: unknown;
185
+ }
186
+ export interface RevokeKeyInput {
187
+ app: string;
188
+ /** The IAM-native credential the CALLER (authorizer) is resolved from; null = absent. */
189
+ credential: string | null;
190
+ requestId: string;
191
+ /** The credential id (the `id` returned by `issueKey`), NOT the plaintext `px_` token. */
192
+ id: string;
193
+ }
194
+ export type RevokeKeyResult =
195
+ /** `revoked` is false when the credential was already revoked (idempotent). */
196
+ {
197
+ ok: true;
198
+ revoked: boolean;
199
+ } | {
200
+ ok: false;
201
+ reason: 'missing_token' | 'invalid_token' | 'unknown_principal' | 'disabled' | 'not_allowed' | 'not_found';
202
+ };
203
+ export interface ListPrincipalsInput {
204
+ /** Self-asserted caller app id; superseded by the credential's aud on a valid `px_token`. */
205
+ app: string;
206
+ /** The IAM-native credential the CALLER is resolved from (px_token / px_ key); null = absent. */
207
+ credential: string | null;
208
+ requestId: string;
209
+ }
210
+ export interface PrincipalListItem {
211
+ /** IAM principal id (UUIDv7) — stable, safe to store on domain rows (assignee/actor). */
212
+ id: string;
213
+ type: PrincipalType;
214
+ /** Human-readable: the user's email. */
215
+ label: string;
216
+ /** The user's email (users always have one; null only defensively). */
217
+ email: string | null;
218
+ /** True when the principal is soft-disabled (kept listable so labels still resolve). */
219
+ disabled: boolean;
220
+ }
221
+ export type ListPrincipalsResult = {
222
+ ok: true;
223
+ principals: PrincipalListItem[];
224
+ }
225
+ /** `not_allowed` when the caller has no verified app / no permission on it (a zero-grant user). */
226
+ | {
227
+ ok: false;
228
+ reason: 'missing_token' | 'invalid_token' | 'unknown_principal' | 'disabled' | 'not_allowed';
229
+ };
230
+ /**
231
+ * The RPC contract. The Worker's `WorkerEntrypoint` `implements IamRpc`; the SDK types its
232
+ * binding as `Service<IamRpc>` (so the SDK never imports the Worker). Methods return plain
233
+ * serializable objects (RPC-friendly).
234
+ */
235
+ export interface IamRpc {
236
+ inspectDeviceAuthorization(input: InspectDeviceAuthorizationInput): Promise<InspectDeviceAuthorizationResult>;
237
+ approveDeviceAuthorization(input: ApproveDeviceAuthorizationInput): Promise<ApproveDeviceAuthorizationResult>;
238
+ denyDeviceAuthorization(input: InspectDeviceAuthorizationInput): Promise<DenyDeviceAuthorizationResult>;
239
+ listOwnDeviceAuthorizations(input: ListOwnDeviceAuthorizationsInput): Promise<ListOwnDeviceAuthorizationsResult>;
240
+ /**
241
+ * Mint a short-lived, per-app permission token from the browser's SSO session — the
242
+ * IAM-native auth path. The SDK middleware calls this only when its cached permission
243
+ * token is missing/near-expiry (≈ once per TTL), NOT per request: every other request verifies
244
+ * the cached token locally against `getJwks`.
245
+ */
246
+ mintToken(input: MintTokenInput): Promise<MintTokenResult>;
247
+ /**
248
+ * Mint a per-app access token from an opaque `px_` credential (API key / share link) — the other
249
+ * front over the same resolve→sign core as `mintToken`. Called by the SDK middleware once per TTL
250
+ * when a request carries a `px_` bearer/path credential; every other request verifies the cached
251
+ * token locally. Fails closed (`invalid_key`/`unknown_principal`/`disabled`).
252
+ */
253
+ mintFromKey(input: MintFromKeyInput): Promise<MintFromKeyResult>;
254
+ /**
255
+ * Mint an opaque, stored, revocable `px_` credential (API key / share link). Delegated: the issuer
256
+ * is resolved from the forwarded credentials and may only grant what it holds, only exact actions of the
257
+ * app's catalog, and only with an expiry inside `MAX_KEY_LIFETIME_SECONDS`. Returns the
258
+ * plaintext token ONCE; `id` is the durable handle for revoke.
259
+ */
260
+ issueKey(input: IssueKeyInput): Promise<IssueKeyResult>;
261
+ /**
262
+ * The public signing key set. The SDK fetches it ONCE per isolate (cached) over the binding —
263
+ * which never traverses the Access edge — then verifies every permission token locally.
264
+ */
265
+ getJwks(): Promise<Jwks>;
266
+ audit(event: AuditInput): Promise<void>;
267
+ /**
268
+ * List the USER principals who can access the caller's app (its people directory). The caller
269
+ * is resolved from the forwarded Access credentials and the app is the aud-VERIFIED app — so an
270
+ * operator only ever sees its own app's roster. Authorized for any member that holds at least
271
+ * one permission on the app; a zero-grant authenticated user gets `not_allowed`. Read-only.
272
+ */
273
+ listPrincipals(input: ListPrincipalsInput): Promise<ListPrincipalsResult>;
274
+ /**
275
+ * Revoke a previously-issued opaque `px_` credential (an API key / share link) by id. The caller
276
+ * is resolved from the forwarded Access credentials and authorized: the credential must be bound to
277
+ * the caller's verified app (any other is `not_found`); then the original issuer may always revoke,
278
+ * and otherwise, for an anonymous credential, the caller must hold every granted action (an
279
+ * admin / app-wide operator). Idempotent — revoking an already-revoked credential returns
280
+ * `{ ok: true, revoked: false }`. An unknown id returns `{ ok: false, reason: 'not_found' }`.
281
+ */
282
+ revokeKey(input: RevokeKeyInput): Promise<RevokeKeyResult>;
283
+ }
@@ -0,0 +1,2 @@
1
+ /** The SHA-256 of `text`'s UTF-8 bytes, as 64 lower-case hex digits. */
2
+ export declare function sha256Hex(text: string): string;
@@ -0,0 +1,72 @@
1
+ import type { MembershipCaller } from './membership';
2
+ /** The terminal declaration of a contract: the page on the application's own origin that identifies a person. */
3
+ export interface TerminalArtifact {
4
+ readonly identify: string;
5
+ }
6
+ /** The longest identification path a contract declares. */
7
+ export declare const MAX_TERMINAL_IDENTIFY_PATH_LENGTH = 200;
8
+ /** The query parameter IAM appends to the identification page: the identification's id. */
9
+ export declare const IDENTIFICATION_QUERY_PARAMETER = "identification";
10
+ /**
11
+ * Why `path` is not an identification page, or `null`: an absolute, canonical path on the application's own origin,
12
+ * with no query or fragment (IAM appends its own) and outside the platform's `/__fabrika`.
13
+ */
14
+ export declare function terminalIdentifyProblem(path: string): string | null;
15
+ /** Every identification operation carries the caller's verified credential: a public procedure's workload token. */
16
+ export type TerminalCaller = MembershipCaller;
17
+ /**
18
+ * Why IAM refused. `not_found` is an identification that is unknown, expired, consumed, cancelled, of another
19
+ * application, or whose terminal no longer lists the application: alike, so an id reveals nothing. `invalid_principal`
20
+ * is a principal that cannot sign in on a terminal: unknown, disabled, not a person, or external (ADR-0051).
21
+ */
22
+ export type TerminalFailure = {
23
+ ok: false;
24
+ reason: 'missing_token' | 'invalid_token' | 'not_allowed' | 'not_found' | 'invalid_principal';
25
+ };
26
+ export type TerminalFailureReason = TerminalFailure['reason'];
27
+ /** The terminal an identification was opened on, as the token's `terminal` claim names it. */
28
+ export interface IdentificationTerminal {
29
+ id: string;
30
+ label: string;
31
+ }
32
+ /** Read an open identification: the id is the `identification` query parameter of the identification page. */
33
+ export interface InspectIdentificationInput extends TerminalCaller {
34
+ id: string;
35
+ }
36
+ /** `expiresAt` is unix seconds. The application keys its throttle of guesses on `terminal.id`. */
37
+ export type InspectIdentificationResult = {
38
+ ok: true;
39
+ terminal: IdentificationTerminal;
40
+ expiresAt: number;
41
+ } | TerminalFailure;
42
+ /**
43
+ * The application's word that `principalId` stands at the identification's terminal. IAM consumes the identification
44
+ * (single use), signs the person in under the terminal's ceiling, and answers the URL the browser goes to next: IAM's
45
+ * completion of the identification, which issues the handoff code only to the terminal's own browser. The application
46
+ * never holds a code.
47
+ */
48
+ export interface AssertIdentityInput extends TerminalCaller {
49
+ id: string;
50
+ principalId: string;
51
+ }
52
+ export type AssertIdentityResult = {
53
+ ok: true;
54
+ completionUrl: string;
55
+ } | TerminalFailure;
56
+ /** End an identification the person abandoned. Repeating it, or cancelling a consumed one, answers `not_found`. */
57
+ export interface CancelIdentificationInput extends TerminalCaller {
58
+ id: string;
59
+ }
60
+ export type CancelIdentificationResult = {
61
+ ok: true;
62
+ } | TerminalFailure;
63
+ /**
64
+ * The identification operations IAM serves an application: on the membership transport (`/membership/<method>`) and
65
+ * on its application entrypoint. A SEPARATE interface from `IamMembershipRpc`, so a transport that predates terminals
66
+ * still satisfies that one.
67
+ */
68
+ export interface IamTerminalRpc {
69
+ inspectIdentification(input: InspectIdentificationInput): Promise<InspectIdentificationResult>;
70
+ assertIdentity(input: AssertIdentityInput): Promise<AssertIdentityResult>;
71
+ cancelIdentification(input: CancelIdentificationInput): Promise<CancelIdentificationResult>;
72
+ }