@teamhanko/hanko-frontend-sdk 2.7.0 → 3.1.0

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.
@@ -1,5 +1,22 @@
1
1
  import { FlowError } from "./flowError";
2
2
  import { PublicKeyCredentialWithAssertionJSON, PublicKeyCredentialWithAttestationJSON } from "@github/webauthn-json";
3
+ /**
4
+ * Describes a single input field expected by an {@link Action}, including its constraints and any
5
+ * validation error from a previous submission attempt.
6
+ * @template TValue - The type of the input's value.
7
+ * @interface
8
+ * @category SDK
9
+ * @subcategory Flow Inputs
10
+ * @property {string} name - The name of the input field.
11
+ * @property {string} type - The input's type (e.g. `string`, `boolean`), as reported by the backend.
12
+ * @property {TValue} [value] - The current or previously submitted value, if any.
13
+ * @property {number} [min_length] - The minimum allowed length, for string inputs.
14
+ * @property {number} [max_length] - The maximum allowed length, for string inputs.
15
+ * @property {boolean} [required] - Indicates whether the input must be provided to run the action.
16
+ * @property {boolean} [hidden] - Indicates whether the input should not be shown in a UI.
17
+ * @property {FlowError} [error] - A validation error for this specific input, if the last submission failed.
18
+ * @property {AllowedInputValues[]} [allowed_values] - The set of allowed values, if the input is restricted to a fixed list.
19
+ */
3
20
  export interface Input<TValue> {
4
21
  readonly name: string;
5
22
  readonly type: string;
@@ -11,88 +28,273 @@ export interface Input<TValue> {
11
28
  readonly error?: FlowError;
12
29
  readonly allowed_values?: AllowedInputValues[];
13
30
  }
31
+ /**
32
+ * One entry of a restricted set of values an {@link Input} may be set to.
33
+ * @interface
34
+ * @category SDK
35
+ * @subcategory Flow Inputs
36
+ * @property {string} name - A human-readable label for the value.
37
+ * @property {string} value - The value to submit when this option is chosen.
38
+ */
14
39
  export interface AllowedInputValues {
15
40
  readonly name: string;
16
41
  readonly value: string;
17
42
  }
43
+ /**
44
+ * Inputs for submitting a new password during password recovery.
45
+ * @interface
46
+ * @category SDK
47
+ * @subcategory Flow Inputs
48
+ * @property {Input<string>} new_password - The new password to set.
49
+ */
18
50
  export interface PasswordRecoveryInputs {
19
51
  readonly new_password: Input<string>;
20
52
  }
53
+ /**
54
+ * Inputs for submitting a WebAuthn assertion response (passkey/security key login).
55
+ * @interface
56
+ * @category SDK
57
+ * @subcategory Flow Inputs
58
+ * @property {Input<PublicKeyCredentialWithAssertionJSON>} assertion_response - The assertion response produced by the browser's WebAuthn API.
59
+ */
21
60
  export interface WebauthnVerifyAssertionResponseInputs {
22
61
  readonly assertion_response: Input<PublicKeyCredentialWithAssertionJSON>;
23
62
  }
63
+ /**
64
+ * Inputs for submitting a WebAuthn attestation response (passkey/security key registration).
65
+ * @interface
66
+ * @category SDK
67
+ * @subcategory Flow Inputs
68
+ * @property {Input<PublicKeyCredentialWithAttestationJSON>} public_key - The attestation response produced by the browser's WebAuthn API.
69
+ */
24
70
  export interface WebauthnVerifyAttestationResponseInputs {
25
71
  readonly public_key: Input<PublicKeyCredentialWithAttestationJSON>;
26
72
  }
73
+ /**
74
+ * Inputs for submitting a login identifier during registration.
75
+ * @interface
76
+ * @category SDK
77
+ * @subcategory Flow Inputs
78
+ * @property {Input<string>} [email] - The email address to register with.
79
+ * @property {Input<string>} [username] - The username to register with.
80
+ */
27
81
  export interface RegisterLoginIdentifierInputs {
28
82
  readonly email?: Input<string>;
29
83
  readonly username?: Input<string>;
30
84
  }
85
+ /**
86
+ * Inputs for submitting a new password during registration.
87
+ * @interface
88
+ * @category SDK
89
+ * @subcategory Flow Inputs
90
+ * @property {Input<string>} new_password - The password to register with.
91
+ */
31
92
  export interface RegisterPasswordInputs {
32
93
  readonly new_password: Input<string>;
33
94
  }
95
+ /**
96
+ * Inputs for reporting the client's WebAuthn capabilities to the backend.
97
+ * @interface
98
+ * @category SDK
99
+ * @subcategory Flow Inputs
100
+ * @property {Input<boolean>} webauthn_available - Whether the WebAuthn API is available in the browser.
101
+ * @property {Input<boolean>} webauthn_conditional_mediation_available - Whether conditional mediation (passkey autofill) is supported.
102
+ * @property {Input<boolean>} webauthn_platform_authenticator_available - Whether a platform authenticator (e.g. Touch ID, Windows Hello) is available.
103
+ */
34
104
  export interface RegisterClientCapabilitiesInputs {
35
105
  readonly webauthn_available: Input<boolean>;
36
106
  readonly webauthn_conditional_mediation_available: Input<boolean>;
37
107
  readonly webauthn_platform_authenticator_available: Input<boolean>;
38
108
  }
109
+ /**
110
+ * Inputs for submitting a login identifier to continue a login.
111
+ * @interface
112
+ * @category SDK
113
+ * @subcategory Flow Inputs
114
+ * @property {Input<string>} [identifier] - A generic identifier, when the backend does not distinguish between email and username.
115
+ * @property {Input<string>} [email] - The email address to log in with.
116
+ * @property {Input<string>} [username] - The username to log in with.
117
+ */
39
118
  export interface ContinueWithLoginIdentifierInputs {
40
119
  readonly identifier?: Input<string>;
41
120
  readonly email?: Input<string>;
42
121
  readonly username?: Input<string>;
43
122
  }
123
+ /**
124
+ * Inputs for submitting a one-time passcode for verification.
125
+ * @interface
126
+ * @category SDK
127
+ * @subcategory Flow Inputs
128
+ * @property {Input<string>} code - The passcode the user received (e.g. via email).
129
+ */
44
130
  export interface VerifyPasscodeInputs {
45
131
  readonly code: Input<string>;
46
132
  }
133
+ /**
134
+ * Inputs for adding a new email address to the account.
135
+ * @interface
136
+ * @category SDK
137
+ * @subcategory Flow Inputs
138
+ * @property {Input<string>} email - The email address to add.
139
+ */
47
140
  export interface EmailCreateInputs {
48
141
  readonly email: Input<string>;
49
142
  }
143
+ /**
144
+ * Inputs for removing an email address from the account.
145
+ * @interface
146
+ * @category SDK
147
+ * @subcategory Flow Inputs
148
+ * @property {Input<string>} email_id - The ID of the email address to remove.
149
+ */
50
150
  export interface EmailDeleteInputs {
51
151
  readonly email_id: Input<string>;
52
152
  }
153
+ /**
154
+ * Inputs for marking an email address as the primary one.
155
+ * @interface
156
+ * @category SDK
157
+ * @subcategory Flow Inputs
158
+ * @property {Input<string>} email_id - The ID of the email address to set as primary.
159
+ */
53
160
  export interface EmailSetPrimaryInputs {
54
161
  readonly email_id: Input<string>;
55
162
  }
163
+ /**
164
+ * Inputs for requesting verification of an email address.
165
+ * @interface
166
+ * @category SDK
167
+ * @subcategory Flow Inputs
168
+ * @property {Input<string>} email_id - The ID of the email address to verify.
169
+ */
56
170
  export interface EmailVerifyInputs {
57
171
  readonly email_id: Input<string>;
58
172
  }
173
+ /**
174
+ * Inputs for submitting a password (e.g. for login).
175
+ * @interface
176
+ * @category SDK
177
+ * @subcategory Flow Inputs
178
+ * @property {Input<string>} password - The password to submit.
179
+ */
59
180
  export interface PasswordInputs {
60
181
  readonly password: Input<string>;
61
182
  }
183
+ /**
184
+ * Inputs for patching the user's public/unsafe metadata.
185
+ * @interface
186
+ * @category SDK
187
+ * @subcategory Flow Inputs
188
+ * @property {Input<Record<string, any>>} patch_metadata - The metadata patch to apply.
189
+ */
62
190
  export interface PatchMetadataInputs {
63
191
  readonly patch_metadata: Input<Record<string, any>>;
64
192
  }
193
+ /**
194
+ * Inputs for setting the account's username.
195
+ * @interface
196
+ * @category SDK
197
+ * @subcategory Flow Inputs
198
+ * @property {Input<string>} username - The username to set.
199
+ */
65
200
  export interface UsernameSetInputs {
66
201
  readonly username: Input<string>;
67
202
  }
203
+ /**
204
+ * Inputs for removing a registered security key.
205
+ * @interface
206
+ * @category SDK
207
+ * @subcategory Flow Inputs
208
+ * @property {Input<string>} security_key_id - The ID of the security key to remove.
209
+ */
68
210
  export interface SecurityKeyDeleteInputs {
69
211
  readonly security_key_id: Input<string>;
70
212
  }
213
+ /**
214
+ * Inputs for renaming a registered passkey.
215
+ * @interface
216
+ * @category SDK
217
+ * @subcategory Flow Inputs
218
+ * @property {Input<string>} passkey_id - The ID of the passkey to rename.
219
+ * @property {Input<string>} passkey_name - The new name for the passkey.
220
+ */
71
221
  export interface PasskeyCredentialRenameInputs {
72
222
  readonly passkey_id: Input<string>;
73
223
  readonly passkey_name: Input<string>;
74
224
  }
225
+ /**
226
+ * Inputs for removing a registered passkey.
227
+ * @interface
228
+ * @category SDK
229
+ * @subcategory Flow Inputs
230
+ * @property {Input<string>} passkey_id - The ID of the passkey to remove.
231
+ */
75
232
  export interface PasskeyCredentialDeleteInputs {
76
233
  readonly passkey_id: Input<string>;
77
234
  }
235
+ /**
236
+ * Inputs for exchanging a third-party OAuth callback token for a session.
237
+ * @interface
238
+ * @category SDK
239
+ * @subcategory Flow Inputs
240
+ * @property {Input<string>} token - The token received from the third-party provider's callback.
241
+ * @property {Input<string>} [code_verifier] - The PKCE code verifier matching the original authorization request, if PKCE was used.
242
+ */
78
243
  export interface ExchangeTokenInputs {
79
244
  readonly token: Input<string>;
80
245
  readonly code_verifier?: Input<string>;
81
246
  }
247
+ /**
248
+ * Inputs for starting a third-party OAuth login/registration/account-linking flow.
249
+ * @interface
250
+ * @category SDK
251
+ * @subcategory Flow Inputs
252
+ * @property {Input<string>} provider - The third-party provider to use.
253
+ * @property {Input<string>} redirect_to - The URL to redirect back to after the OAuth flow completes.
254
+ * @property {Input<string>} [code_verifier] - The PKCE code verifier to use for the authorization request, if PKCE is enabled.
255
+ */
82
256
  export interface ThirdpartyOauthInputs {
83
257
  readonly provider: Input<string>;
84
258
  readonly redirect_to: Input<string>;
85
259
  readonly code_verifier?: Input<string>;
86
260
  }
261
+ /**
262
+ * Inputs for unlinking a third-party OAuth provider from the account.
263
+ * @interface
264
+ * @category SDK
265
+ * @subcategory Flow Inputs
266
+ * @property {Input<string>} identity_id - The ID of the linked identity to remove.
267
+ */
87
268
  export interface DisconnectThirdpartyInputs {
88
269
  readonly identity_id: Input<string>;
89
270
  }
271
+ /**
272
+ * Inputs for setting whether the current device should be remembered for future logins.
273
+ * @interface
274
+ * @category SDK
275
+ * @subcategory Flow Inputs
276
+ * @property {Input<boolean>} remember_me - Whether to remember the device.
277
+ */
90
278
  export interface RememberMeInputs {
91
279
  readonly remember_me: Input<boolean>;
92
280
  }
281
+ /**
282
+ * Inputs for revoking one of the user's active sessions.
283
+ * @interface
284
+ * @category SDK
285
+ * @subcategory Flow Inputs
286
+ * @property {Input<string>} session_id - The ID of the session to revoke.
287
+ */
93
288
  export interface SessionDeleteInputs {
94
289
  readonly session_id: Input<string>;
95
290
  }
291
+ /**
292
+ * Inputs for submitting a one-time password (TOTP) code.
293
+ * @interface
294
+ * @category SDK
295
+ * @subcategory Flow Inputs
296
+ * @property {Input<string>} otp_code - The code generated by the user's authenticator app.
297
+ */
96
298
  export interface OTPCodeInputs {
97
299
  readonly otp_code: Input<string>;
98
300
  }
@@ -1,22 +1,77 @@
1
1
  import { CredentialCreationOptionsJSON, CredentialRequestOptionsJSON } from "@github/webauthn-json/src/webauthn-json/basic/json";
2
2
  import { Claims } from "../../Dto";
3
+ /**
4
+ * Payload of the `passcode_confirmation` state, describing the passcode that was sent to the user.
5
+ * @interface
6
+ * @category SDK
7
+ * @subcategory Flow Payloads
8
+ * @property {boolean} passcode_resent - Indicates whether the passcode was just resent.
9
+ * @property {number} resend_after - The number of seconds to wait before the passcode can be resent again.
10
+ */
3
11
  export interface PasscodeConfirmationPayload {
4
12
  readonly passcode_resent: boolean;
5
13
  readonly resend_after: number;
6
14
  }
15
+ /**
16
+ * Payload of the `login_passkey` state, carrying the options needed to perform the WebAuthn assertion ceremony.
17
+ * @interface
18
+ * @category SDK
19
+ * @subcategory Flow Payloads
20
+ * @property {CredentialRequestOptionsJSON} request_options - The WebAuthn request options to pass to `navigator.credentials.get()`.
21
+ */
7
22
  export interface LoginPasskeyPayload {
8
23
  readonly request_options: CredentialRequestOptionsJSON;
9
24
  }
25
+ /**
26
+ * Payload of the `mfa_otp_secret_creation` state, carrying the newly generated TOTP secret.
27
+ * @interface
28
+ * @category SDK
29
+ * @subcategory Flow Payloads
30
+ * @property {string} otp_secret - The generated TOTP secret.
31
+ * @property {string} otp_image_source - A data URL of a QR code image encoding the secret, for scanning with an authenticator app.
32
+ */
10
33
  export interface MFAOTPSecretCreationPayload {
11
34
  readonly otp_secret: string;
12
35
  readonly otp_image_source: string;
13
36
  }
37
+ /**
38
+ * Payload of states that expect a WebAuthn attestation (registration) ceremony to be performed,
39
+ * carrying the options needed to create the credential.
40
+ * @interface
41
+ * @category SDK
42
+ * @subcategory Flow Payloads
43
+ * @property {CredentialCreationOptionsJSON} creation_options - The WebAuthn creation options to pass to `navigator.credentials.create()`.
44
+ */
14
45
  export interface OnboardingVerifyPasskeyAttestationPayload {
15
46
  readonly creation_options: CredentialCreationOptionsJSON;
16
47
  }
48
+ /**
49
+ * Payload of the `login_init` state. `request_options` is present when passkey autofill / conditional
50
+ * mediation should be attempted immediately.
51
+ * @interface
52
+ * @category SDK
53
+ * @subcategory Flow Payloads
54
+ * @property {CredentialRequestOptionsJSON} [request_options] - The WebAuthn request options for conditional mediation, if applicable.
55
+ */
17
56
  export interface LoginInitPayload {
18
57
  readonly request_options?: CredentialRequestOptionsJSON;
19
58
  }
59
+ /**
60
+ * A WebAuthn credential (passkey or security key) registered to a user.
61
+ * @interface
62
+ * @category SDK
63
+ * @subcategory Flow Payloads
64
+ * @property {string} id - The credential's unique ID.
65
+ * @property {string} [name] - A user-assigned name for the credential.
66
+ * @property {string} public_key - The credential's public key.
67
+ * @property {string} attestation_type - The WebAuthn attestation type used during registration.
68
+ * @property {string} aaguid - The authenticator's AAGUID.
69
+ * @property {string} [last_used_at] - Timestamp of the last time the credential was used, if any.
70
+ * @property {string} created_at - Timestamp of when the credential was created.
71
+ * @property {string} transports - The transports supported by the authenticator (e.g. `usb`, `internal`).
72
+ * @property {string} backup_eligible - Whether the credential is eligible for backup (e.g. via a passkey provider).
73
+ * @property {string} backup_state - The credential's current backup state.
74
+ */
20
75
  export interface WebauthnCredential {
21
76
  readonly id: string;
22
77
  readonly name?: string;
@@ -29,17 +84,54 @@ export interface WebauthnCredential {
29
84
  readonly backup_eligible: string;
30
85
  readonly backup_state: string;
31
86
  }
87
+ /**
88
+ * A username assigned to a user.
89
+ * @interface
90
+ * @category SDK
91
+ * @subcategory Flow Payloads
92
+ * @property {string} id - The username's unique ID.
93
+ * @property {string} username - The username value.
94
+ * @property {string} created_at - Timestamp of when the username was created.
95
+ * @property {string} updated_at - Timestamp of when the username was last updated.
96
+ */
32
97
  export interface Username {
33
98
  id: string;
34
99
  username: string;
35
100
  created_at: string;
36
101
  updated_at: string;
37
102
  }
103
+ /**
104
+ * A third-party identity linked to a user, as seen through the flow API.
105
+ *
106
+ * Note: a same-named `Identity` interface also exists in `Dto.ts` for the standalone
107
+ * user-management REST API; it happens to have the same shape today, but the two are declared
108
+ * independently and are not guaranteed to stay in sync.
109
+ * @interface
110
+ * @category SDK
111
+ * @subcategory Flow Payloads
112
+ * @property {string} id - The subject ID with the third-party provider.
113
+ * @property {string} provider - The third-party provider name.
114
+ * @property {string} [identity_id] - The ID of the identity link itself.
115
+ */
38
116
  export interface Identity {
39
117
  readonly id: string;
40
118
  readonly provider: string;
41
119
  readonly identity_id?: string;
42
120
  }
121
+ /**
122
+ * An email address belonging to a user, as seen through the flow API.
123
+ *
124
+ * Note: a same-named `Email` interface also exists in `Dto.ts` for the standalone
125
+ * user-management REST API; the two are declared independently and have slightly different shapes.
126
+ * @interface
127
+ * @category SDK
128
+ * @subcategory Flow Payloads
129
+ * @property {string} id - The UUID of the email address.
130
+ * @property {string} address - The email address.
131
+ * @property {boolean} is_verified - Indicates whether the email address is verified.
132
+ * @property {boolean} is_primary - Indicates it's the primary email address.
133
+ * @property {Identity[]} [identities] - Third-party identities linked to this email address, if any.
134
+ */
43
135
  export interface Email {
44
136
  readonly id: string;
45
137
  readonly address: string;
@@ -47,15 +139,54 @@ export interface Email {
47
139
  readonly is_primary: boolean;
48
140
  readonly identities?: Identity[];
49
141
  }
142
+ /**
143
+ * A user's multi-factor authentication configuration.
144
+ * @interface
145
+ * @category SDK
146
+ * @subcategory Flow Payloads
147
+ * @property {boolean} auth_app_set_up - Whether an authenticator app (TOTP) has been set up.
148
+ * @property {boolean} totp_enabled - Whether TOTP is enabled as a second factor.
149
+ * @property {boolean} security_keys_enabled - Whether security keys are enabled as a second factor.
150
+ */
50
151
  export interface MFAConfig {
51
152
  readonly auth_app_set_up: boolean;
52
153
  readonly totp_enabled: boolean;
53
154
  readonly security_keys_enabled: boolean;
54
155
  }
156
+ /**
157
+ * A user's custom metadata, split into a `public_metadata` portion (readable by any client) and an
158
+ * `unsafe_metadata` portion (writable by any authenticated client).
159
+ * @template PublicMetadata - The shape of the public metadata.
160
+ * @template UnsafeMetadata - The shape of the unsafe metadata.
161
+ * @category SDK
162
+ * @subcategory Flow Payloads
163
+ * @property {PublicMetadata} [public_metadata] - Metadata visible to any client.
164
+ * @property {UnsafeMetadata} [unsafe_metadata] - Metadata that any authenticated client may write.
165
+ */
55
166
  export type UserMetadata<PublicMetadata extends Record<string, any> = {}, UnsafeMetadata extends Record<string, any> = {}> = {
56
167
  public_metadata?: PublicMetadata;
57
168
  unsafe_metadata?: UnsafeMetadata;
58
169
  };
170
+ /**
171
+ * A user's full profile as returned by the flow API.
172
+ * @interface
173
+ * @category SDK
174
+ * @subcategory Flow Payloads
175
+ * @property {string} user_id - The user's unique ID.
176
+ * @property {WebauthnCredential[]} [passkeys] - The user's registered passkeys.
177
+ * @property {WebauthnCredential[]} [security_keys] - The user's registered security keys.
178
+ * @property {MFAConfig} [mfa_config] - The user's multi-factor authentication configuration.
179
+ * @property {Email[]} [emails] - The user's email addresses.
180
+ * @property {Username} [username] - The user's username, if set.
181
+ * @property {UserMetadata} [metadata] - The user's custom metadata.
182
+ * @property {Identity[]} [identities] - Third-party identities linked to the user.
183
+ * @property {string} created_at - Timestamp of when the user was created.
184
+ * @property {string} updated_at - Timestamp of when the user was last updated.
185
+ * @property {string} [name] - The user's full name, if known (e.g. from a third-party provider).
186
+ * @property {string} [given_name] - The user's given name, if known.
187
+ * @property {string} [family_name] - The user's family name, if known.
188
+ * @property {string} [picture] - A URL to the user's profile picture, if known.
189
+ */
59
190
  export interface User {
60
191
  readonly user_id: string;
61
192
  readonly passkeys?: WebauthnCredential[];
@@ -72,6 +203,19 @@ export interface User {
72
203
  readonly family_name?: string;
73
204
  readonly picture?: string;
74
205
  }
206
+ /**
207
+ * One of a user's active sessions.
208
+ * @interface
209
+ * @category SDK
210
+ * @subcategory Flow Payloads
211
+ * @property {string} id - The session's unique ID.
212
+ * @property {string} [user_agent] - The parsed user agent of the client that created the session.
213
+ * @property {string} [user_agent_raw] - The raw user agent string of the client that created the session.
214
+ * @property {string} [ip_address] - The IP address the session was created from.
215
+ * @property {string} created_at - Timestamp of when the session was created.
216
+ * @property {string} last_used - Timestamp of when the session was last used.
217
+ * @property {boolean} current - Whether this is the session the current request is authenticated with.
218
+ */
75
219
  export interface Session {
76
220
  readonly id: string;
77
221
  readonly user_agent?: string;
@@ -81,22 +225,65 @@ export interface Session {
81
225
  readonly last_used: string;
82
226
  readonly current: boolean;
83
227
  }
228
+ /**
229
+ * Payload of the `profile_init` state, the entry point of the account/profile management flow.
230
+ * @interface
231
+ * @category SDK
232
+ * @subcategory Flow Payloads
233
+ * @property {User} user - The current user's profile.
234
+ * @property {Session[]} [sessions] - The user's active sessions.
235
+ */
84
236
  export interface ProfilePayload {
85
237
  readonly user: User;
86
238
  readonly sessions?: Session[];
87
239
  }
240
+ /**
241
+ * The method used to complete a login.
242
+ * @category SDK
243
+ * @subcategory Flow Payloads
244
+ */
88
245
  export type LoginMethod = "password" | "passkey" | "passcode" | "third_party";
246
+ /**
247
+ * The second-factor method used to complete a login, if any.
248
+ * @category SDK
249
+ * @subcategory Flow Payloads
250
+ */
89
251
  export type MFAMethod = "totp" | "security_key";
252
+ /**
253
+ * Describes how a user most recently logged in.
254
+ * @interface
255
+ * @category SDK
256
+ * @subcategory Flow Payloads
257
+ * @property {LoginMethod} login_method - The primary method used to log in.
258
+ * @property {MFAMethod} [mfa_method] - The second-factor method used, if any.
259
+ * @property {string} [third_party_provider] - The third-party provider used, if `login_method` is `third_party`.
260
+ */
90
261
  export interface LastLogin {
91
262
  readonly login_method: LoginMethod;
92
263
  readonly mfa_method?: MFAMethod;
93
264
  readonly third_party_provider?: string;
94
265
  }
266
+ /**
267
+ * Payload of the terminal `success` state, marking the end of a flow.
268
+ * @interface
269
+ * @category SDK
270
+ * @subcategory Flow Payloads
271
+ * @property {User} user - The authenticated user.
272
+ * @property {LastLogin} [last_login] - Details of how the user logged in, if applicable.
273
+ * @property {Claims} claims - The claims associated with the newly created session.
274
+ */
95
275
  export interface SuccessPayload {
96
276
  readonly user: User;
97
277
  readonly last_login?: LastLogin;
98
278
  readonly claims: Claims;
99
279
  }
280
+ /**
281
+ * Payload of the `thirdparty` state, carrying the URL to redirect the user to for the OAuth flow.
282
+ * @interface
283
+ * @category SDK
284
+ * @subcategory Flow Payloads
285
+ * @property {string} redirect_url - The URL to redirect the browser to in order to start the third-party OAuth flow.
286
+ */
100
287
  export interface ThirdPartyPayload {
101
288
  readonly redirect_url: string;
102
289
  }
@@ -1,6 +1,20 @@
1
1
  import { CredentialOnboardingChooserActions, DeviceTrustActions, LoginInitActions, LoginMethodChooserActions, LoginOTPActions, LoginPasskeyActions, LoginPasswordActions, LoginPasswordRecoveryActions, LoginSecurityKeyActions, MFAAOTPSecretCreationActions, MFAMethodChooserActions, MFASecurityKeyCreationActions, OnboardingCreatePasskeyActions, OnboardingEmailActions, OnboardingUsernameActions, OnboardingVerifyPasskeyAttestationActions, PasscodeConfirmationActions, PasswordCreationActions, PreflightActions, ProfileInitActions, RegistrationInitActions, ThirdPartyActions } from "./action";
2
2
  import { LoginInitPayload, LoginPasskeyPayload, MFAOTPSecretCreationPayload, OnboardingVerifyPasskeyAttestationPayload, PasscodeConfirmationPayload, ProfilePayload, SuccessPayload, ThirdPartyPayload } from "./payload";
3
+ /**
4
+ * The name of a possible state within a flow. Every flow (see {@link FlowName}) transitions between
5
+ * a subset of these states; use {@link Actions} and {@link Payloads} to look up what a given state
6
+ * exposes.
7
+ * @category SDK
8
+ * @subcategory Flow Types
9
+ */
3
10
  export type StateName = "account_deleted" | "credential_onboarding_chooser" | "device_trust" | "error" | "login_init" | "login_method_chooser" | "login_otp" | "login_passkey" | "login_password" | "login_password_recovery" | "login_security_key" | "mfa_method_chooser" | "mfa_otp_secret_creation" | "mfa_security_key_creation" | "onboarding_create_passkey" | "onboarding_email" | "onboarding_username" | "onboarding_verify_passkey_attestation" | "passcode_confirmation" | "password_creation" | "preflight" | "profile_init" | "registration_init" | "success" | "thirdparty" | "webauthn_credential_verification";
11
+ /**
12
+ * Maps each {@link StateName} to the interface describing the actions available in that state
13
+ * (`null` for states that expose no actions, e.g. terminal states).
14
+ * @interface
15
+ * @category SDK
16
+ * @subcategory Flow Types
17
+ */
4
18
  export interface Actions {
5
19
  readonly account_deleted: null;
6
20
  readonly credential_onboarding_chooser: CredentialOnboardingChooserActions;
@@ -29,6 +43,13 @@ export interface Actions {
29
43
  readonly thirdparty: ThirdPartyActions;
30
44
  readonly webauthn_credential_verification: OnboardingVerifyPasskeyAttestationActions;
31
45
  }
46
+ /**
47
+ * Maps each {@link StateName} to the type describing that state's payload data
48
+ * (`null` for states that carry no payload).
49
+ * @interface
50
+ * @category SDK
51
+ * @subcategory Flow Types
52
+ */
32
53
  export interface Payloads {
33
54
  readonly account_deleted: null;
34
55
  readonly credential_onboarding_chooser: null;