@outseta/api-client 0.3.0 → 0.3.1

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": "@outseta/api-client",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generated API client for the Outseta REST API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type AuthGetTokenParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type AuthResendTwoFactorParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type AuthSwitchTwoFactorMechanismParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type AuthVerifyTwoFactorRecoveryParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type AuthVerifyTwoFactorTokenParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -99,6 +99,11 @@ export * from './article';
99
99
  export * from './articleAllOf';
100
100
  export * from './articleAllOfCategory';
101
101
  export * from './articleGetAllArticlesParams';
102
+ export * from './authGetTokenParams';
103
+ export * from './authResendTwoFactorParams';
104
+ export * from './authSwitchTwoFactorMechanismParams';
105
+ export * from './authVerifyTwoFactorRecoveryParams';
106
+ export * from './authVerifyTwoFactorTokenParams';
102
107
  export * from './backGroundTaskType';
103
108
  export * from './billSettings';
104
109
  export * from './billSettingsAllOf';
@@ -464,6 +469,11 @@ export * from './taxRateAllOf';
464
469
  export * from './template';
465
470
  export * from './templateAllOf';
466
471
  export * from './temporaryPasswordModel';
472
+ export * from './tokenPayload';
473
+ export * from './tokenTwoFactorEnrollmentBeginEmailParams';
474
+ export * from './tokenTwoFactorEnrollmentBeginTotpParams';
475
+ export * from './tokenTwoFactorEnrollmentConfirmEmailParams';
476
+ export * from './tokenTwoFactorEnrollmentConfirmTotpParams';
467
477
  export * from './transaction';
468
478
  export * from './transactionAllOf';
469
479
  export * from './transactionAllOfAccount';
@@ -471,6 +481,9 @@ export * from './transactionAllOfInvoice';
471
481
  export * from './transactionsAddPaymentTransactionBody';
472
482
  export * from './translation';
473
483
  export * from './translationAllOf';
484
+ export * from './twoFactorChallengePayload';
485
+ export * from './twoFactorEnrollmentConfirmationPayload';
486
+ export * from './twoFactorTotpEnrollmentPayload';
474
487
  export * from './usage';
475
488
  export * from './usageAddUsageBody';
476
489
  export * from './usageAllOf';
@@ -0,0 +1,13 @@
1
+ // @ts-nocheck
2
+
3
+ export interface TokenPayload {
4
+ /** @nullable */
5
+ access_token?: string | null;
6
+ /** @nullable */
7
+ authentication_callback_url?: string | null;
8
+ expires_in?: number;
9
+ /** @nullable */
10
+ id_token?: string | null;
11
+ /** @nullable */
12
+ token_type?: string | null;
13
+ }
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type TokenTwoFactorEnrollmentBeginEmailParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type TokenTwoFactorEnrollmentBeginTotpParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type TokenTwoFactorEnrollmentConfirmEmailParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ // @ts-nocheck
2
+
3
+ export type TokenTwoFactorEnrollmentConfirmTotpParams = {
4
+ /**
5
+ * @nullable
6
+ */
7
+ data: unknown | null;
8
+ };
@@ -0,0 +1,69 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * Returned when a login cannot complete with a password alone because the
5
+ user has two-factor authentication enabled. Carries the opaque challenge
6
+ token that must be echoed back to POST /api/v1/tokens/two-factor
7
+ (or the recovery / resend / switch-mechanism endpoints) along with enough
8
+ metadata for a client to render the verification step without a second
9
+ round-trip. The property names are snake_case to match the wire format of
10
+ the other token endpoints (see TokenPayload).
11
+ */
12
+ export interface TwoFactorChallengePayload {
13
+ /**
14
+ * Present and true on the 202 response from POST /api/v1/tokens
15
+ when the user has at least one verified 2FA method. Absent on the
16
+ resend / switch-mechanism responses, which only ever follow an
17
+ already-issued login challenge.
18
+ * @nullable
19
+ */
20
+ two_factor_required?: boolean | null;
21
+ /**
22
+ * Present and true instead of two_factor_required
23
+ when the tenant forces 2FA but the user has not yet enrolled any
24
+ method. In that case only challenge_token and
25
+ expires_in are populated and the client must route the
26
+ user through the mid-login enrollment endpoints
27
+ (/api/v1/tokens/two-factor/enroll/...) before a token can be issued.
28
+ * @nullable
29
+ */
30
+ two_factor_enrollment_required?: boolean | null;
31
+ /**
32
+ * Short-lived signed JWT (audience outseta:2fa-challenge) that
33
+ identifies this challenge. Echo it back verbatim to complete the login.
34
+ * @nullable
35
+ */
36
+ challenge_token?: string | null;
37
+ /**
38
+ * The mechanism this challenge was issued against: Email or
39
+ Totp (authenticator app). For Email a code has already
40
+ been sent to the user; for Totp the user reads the current
41
+ code from their authenticator app and nothing is sent.
42
+ * @nullable
43
+ */
44
+ mechanism?: string | null;
45
+ /**
46
+ * A masked view of where an emailed code was sent (e.g. b***@outseta.com),
47
+ suitable for display. Empty when mechanism is Totp.
48
+ * @nullable
49
+ */
50
+ masked_destination?: string | null;
51
+ /** Seconds until the challenge expires (600). After this the
52
+ challenge_token can no longer be verified and the login must restart. */
53
+ expires_in?: number;
54
+ /**
55
+ * Every verified mechanism enrolled for this user (excluding recovery
56
+ codes), e.g. ["Totp", "Email"]. A client can offer a
57
+ "use a different method" option for any value other than the current
58
+ mechanism via POST /api/v1/tokens/two-factor/switch-mechanism.
59
+ * @nullable
60
+ */
61
+ available_mechanisms?: string[] | null;
62
+ /**
63
+ * true when the user has a batch of recovery codes on file, in
64
+ which case POST /api/v1/tokens/two-factor/recovery can be used
65
+ as a fallback if they cannot produce a primary code.
66
+ * @nullable
67
+ */
68
+ recovery_codes_available?: boolean | null;
69
+ }
@@ -0,0 +1,35 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * Returned from the mid-login enrollment confirm endpoints
5
+ (POST /api/v1/tokens/two-factor/enroll/{email|totp}/confirm) once the
6
+ user has proven control of the new mechanism. Completes a forced-enrollment
7
+ login: it both finalizes the JWT access token and surfaces the freshly
8
+ generated recovery codes. The property names are snake_case to match the
9
+ wire format of the other token endpoints (see TokenPayload).
10
+ */
11
+ export interface TwoFactorEnrollmentConfirmationPayload {
12
+ /** Always true on a success response; the enrollment is now active. */
13
+ confirmed?: boolean;
14
+ /**
15
+ * The user's recovery codes, generated as part of first-time enrollment.
16
+ These are shown once and never returned again — prompt the user
17
+ to store them somewhere safe. Each code is single-use at
18
+ POST /api/v1/tokens/two-factor/recovery.
19
+ * @nullable
20
+ */
21
+ recovery_codes?: string[] | null;
22
+ /**
23
+ * The JWT access token. Use it as Authorization: bearer {access_token}
24
+ for subsequent API calls — login is complete.
25
+ * @nullable
26
+ */
27
+ access_token?: string | null;
28
+ /**
29
+ * Always Bearer.
30
+ * @nullable
31
+ */
32
+ token_type?: string | null;
33
+ /** Seconds until the access token expires. */
34
+ expires_in?: number;
35
+ }
@@ -0,0 +1,39 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * Returned from POST /api/v1/tokens/two-factor/enroll/totp/begin when a
5
+ user forced into 2FA chooses to enroll an authenticator app. Carries the
6
+ shared secret in the three forms a client may need to present it, plus the
7
+ challenge token the user's first generated code is confirmed against. The
8
+ property names are snake_case to match the wire format of the other token
9
+ endpoints (see TokenPayload).
10
+ */
11
+ export interface TwoFactorTotpEnrollmentPayload {
12
+ /**
13
+ * Short-lived signed JWT identifying the enrollment-test challenge.
14
+ Echo it back to POST /api/v1/tokens/two-factor/enroll/totp/confirm
15
+ along with the first code from the authenticator app.
16
+ * @nullable
17
+ */
18
+ challenge_token?: string | null;
19
+ /**
20
+ * The Base32-encoded shared secret. Offer this for manual entry by users
21
+ who cannot scan the QR code.
22
+ * @nullable
23
+ */
24
+ secret?: string | null;
25
+ /**
26
+ * The full otpauth://totp/... URI encoding the secret, issuer and
27
+ parameters. Most authenticator apps add an account directly from this.
28
+ * @nullable
29
+ */
30
+ otpauth_uri?: string | null;
31
+ /**
32
+ * A QR code rendering of otpauth_uri as a PNG, Base64
33
+ encoded — render it as an <img> for the user to scan.
34
+ * @nullable
35
+ */
36
+ qr_code_png_base64?: string | null;
37
+ /** Seconds until the enrollment-test challenge expires (600). */
38
+ expires_in?: number;
39
+ }
@@ -0,0 +1,659 @@
1
+ // @ts-nocheck
2
+ import type {
3
+ AuthGetTokenParams,
4
+ AuthResendTwoFactorParams,
5
+ AuthSwitchTwoFactorMechanismParams,
6
+ AuthVerifyTwoFactorRecoveryParams,
7
+ AuthVerifyTwoFactorTokenParams,
8
+ TokenPayload,
9
+ TokenTwoFactorEnrollmentBeginEmailParams,
10
+ TokenTwoFactorEnrollmentBeginTotpParams,
11
+ TokenTwoFactorEnrollmentConfirmEmailParams,
12
+ TokenTwoFactorEnrollmentConfirmTotpParams,
13
+ TwoFactorChallengePayload,
14
+ TwoFactorEnrollmentConfirmationPayload,
15
+ TwoFactorTotpEnrollmentPayload
16
+ } from '.././models';
17
+
18
+ import { customFetch } from '../../client';
19
+
20
+ /**
21
+ * Post a JSON body with the user's credentials:
22
+
23
+ { "username": "user@example.com", "password": "their-password" }
24
+
25
+ On success the response is `200` with an access token:
26
+
27
+ { "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 31536000 }
28
+
29
+ **Two-factor authentication.** If the user has a verified 2FA method,
30
+ the password alone is not enough. After verifying the password this
31
+ endpoint instead returns `202 Accepted` with a challenge that must be
32
+ satisfied via `POST /api/v1/tokens/two-factor`:
33
+
34
+ {
35
+ "two_factor_required": true,
36
+ "challenge_token": "eyJ...",
37
+ "mechanism": "Totp",
38
+ "masked_destination": "",
39
+ "expires_in": 600,
40
+ "available_mechanisms": ["Totp", "Email"],
41
+ "recovery_codes_available": true
42
+ }
43
+
44
+ `mechanism` is the method this challenge targets. When it is `Email`,
45
+ a one-time code has already been emailed to the user (see
46
+ `masked_destination`); when it is `Totp`, the user reads the current
47
+ code from their authenticator app and nothing is sent.
48
+ `available_mechanisms` lists every method the user has enrolled so a
49
+ client can offer a switch via `POST /api/v1/tokens/two-factor/switch-mechanism`.
50
+
51
+ If the tenant forces 2FA but the user has not enrolled yet, the `202`
52
+ body instead contains `"two_factor_enrollment_required": true` with a
53
+ `challenge_token` to drive the mid-login enrollment endpoints.
54
+
55
+ Invalid credentials return `400` with a body of `invalid_grant`.
56
+ * @summary Log a user in and obtain a JWT access token.
57
+ */
58
+ export type authGetTokenResponse200 = {
59
+ data: TokenPayload
60
+ status: 200
61
+ }
62
+
63
+ export type authGetTokenResponse202 = {
64
+ data: TwoFactorChallengePayload
65
+ status: 202
66
+ }
67
+
68
+ export type authGetTokenResponse400 = {
69
+ data: string
70
+ status: 400
71
+ }
72
+
73
+ export type authGetTokenResponseSuccess = (authGetTokenResponse200 | authGetTokenResponse202) & {
74
+ headers: Headers;
75
+ };
76
+ export type authGetTokenResponseError = (authGetTokenResponse400) & {
77
+ headers: Headers;
78
+ };
79
+
80
+ export type authGetTokenResponse = (authGetTokenResponseSuccess | authGetTokenResponseError)
81
+
82
+ export const getAuthGetTokenUrl = (params: AuthGetTokenParams,) => {
83
+ const normalizedParams = new URLSearchParams();
84
+
85
+ Object.entries(params || {}).forEach(([key, value]) => {
86
+
87
+ if (value !== undefined) {
88
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
89
+ }
90
+ });
91
+
92
+ const stringifiedParams = normalizedParams.toString();
93
+
94
+ return stringifiedParams.length > 0 ? `/api/v1/tokens?${stringifiedParams}` : `/api/v1/tokens`
95
+ }
96
+
97
+ export const authGetToken = async (params: AuthGetTokenParams, options?: RequestInit): Promise<authGetTokenResponse> => {
98
+
99
+ return customFetch<authGetTokenResponse>(getAuthGetTokenUrl(params),
100
+ {
101
+ ...options,
102
+ method: 'POST'
103
+
104
+
105
+ }
106
+ );}
107
+
108
+
109
+ /**
110
+ * Call this after `POST /api/v1/tokens` returns `two_factor_required`.
111
+ Post the challenge token from that response together with the user's
112
+ one-time code (the emailed code, or the current code from their
113
+ authenticator app):
114
+
115
+ { "challenge_token": "eyJ...", "code": "123456" }
116
+
117
+ On success the response is `200` with the final access token, in the
118
+ same shape as `POST /api/v1/tokens`:
119
+
120
+ { "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 31536000 }
121
+
122
+ An incorrect code returns `400` (`invalid_grant`). A code has at most
123
+ five attempts before the challenge locks. An expired challenge returns
124
+ `410` (`challenge_expired`) — restart at `POST /api/v1/tokens`. The
125
+ endpoint is rate limited to 10 requests per minute (`429`).
126
+ * @summary Complete a two-factor login challenge and obtain a JWT access token.
127
+ */
128
+ export type authVerifyTwoFactorTokenResponse200 = {
129
+ data: TokenPayload
130
+ status: 200
131
+ }
132
+
133
+ export type authVerifyTwoFactorTokenResponse400 = {
134
+ data: string
135
+ status: 400
136
+ }
137
+
138
+ export type authVerifyTwoFactorTokenResponse410 = {
139
+ data: string
140
+ status: 410
141
+ }
142
+
143
+ export type authVerifyTwoFactorTokenResponseSuccess = (authVerifyTwoFactorTokenResponse200) & {
144
+ headers: Headers;
145
+ };
146
+ export type authVerifyTwoFactorTokenResponseError = (authVerifyTwoFactorTokenResponse400 | authVerifyTwoFactorTokenResponse410) & {
147
+ headers: Headers;
148
+ };
149
+
150
+ export type authVerifyTwoFactorTokenResponse = (authVerifyTwoFactorTokenResponseSuccess | authVerifyTwoFactorTokenResponseError)
151
+
152
+ export const getAuthVerifyTwoFactorTokenUrl = (params: AuthVerifyTwoFactorTokenParams,) => {
153
+ const normalizedParams = new URLSearchParams();
154
+
155
+ Object.entries(params || {}).forEach(([key, value]) => {
156
+
157
+ if (value !== undefined) {
158
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
159
+ }
160
+ });
161
+
162
+ const stringifiedParams = normalizedParams.toString();
163
+
164
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor?${stringifiedParams}` : `/api/v1/tokens/two-factor`
165
+ }
166
+
167
+ export const authVerifyTwoFactorToken = async (params: AuthVerifyTwoFactorTokenParams, options?: RequestInit): Promise<authVerifyTwoFactorTokenResponse> => {
168
+
169
+ return customFetch<authVerifyTwoFactorTokenResponse>(getAuthVerifyTwoFactorTokenUrl(params),
170
+ {
171
+ ...options,
172
+ method: 'POST'
173
+
174
+
175
+ }
176
+ );}
177
+
178
+
179
+ /**
180
+ * Post the challenge token from the original `POST /api/v1/tokens` response:
181
+
182
+ { "challenge_token": "eyJ..." }
183
+
184
+ A fresh code is emailed and a new challenge is returned (superseding
185
+ the previous one), in the same shape as the `202` from
186
+ `POST /api/v1/tokens` minus `two_factor_required`. Only `Email`
187
+ challenges can be resent — there is nothing to resend for `Totp`
188
+ (the authenticator app generates codes locally), so a `Totp`
189
+ challenge returns `400` with a body of `not_supported`. Rate limited
190
+ to 3 requests per minute (`429`).
191
+ * @summary Re-send the one-time code for an in-progress email two-factor challenge.
192
+ */
193
+ export type authResendTwoFactorResponse200 = {
194
+ data: TwoFactorChallengePayload
195
+ status: 200
196
+ }
197
+
198
+ export type authResendTwoFactorResponse400 = {
199
+ data: string
200
+ status: 400
201
+ }
202
+
203
+ export type authResendTwoFactorResponse410 = {
204
+ data: string
205
+ status: 410
206
+ }
207
+
208
+ export type authResendTwoFactorResponseSuccess = (authResendTwoFactorResponse200) & {
209
+ headers: Headers;
210
+ };
211
+ export type authResendTwoFactorResponseError = (authResendTwoFactorResponse400 | authResendTwoFactorResponse410) & {
212
+ headers: Headers;
213
+ };
214
+
215
+ export type authResendTwoFactorResponse = (authResendTwoFactorResponseSuccess | authResendTwoFactorResponseError)
216
+
217
+ export const getAuthResendTwoFactorUrl = (params: AuthResendTwoFactorParams,) => {
218
+ const normalizedParams = new URLSearchParams();
219
+
220
+ Object.entries(params || {}).forEach(([key, value]) => {
221
+
222
+ if (value !== undefined) {
223
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
224
+ }
225
+ });
226
+
227
+ const stringifiedParams = normalizedParams.toString();
228
+
229
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/resend?${stringifiedParams}` : `/api/v1/tokens/two-factor/resend`
230
+ }
231
+
232
+ export const authResendTwoFactor = async (params: AuthResendTwoFactorParams, options?: RequestInit): Promise<authResendTwoFactorResponse> => {
233
+
234
+ return customFetch<authResendTwoFactorResponse>(getAuthResendTwoFactorUrl(params),
235
+ {
236
+ ...options,
237
+ method: 'POST'
238
+
239
+
240
+ }
241
+ );}
242
+
243
+
244
+ /**
245
+ * When a user has more than one method enrolled (see
246
+ `available_mechanisms` on the login response) they can switch the
247
+ active challenge — for example from `Totp` to `Email` when they have
248
+ lost access to their authenticator. Post the current challenge token
249
+ and the desired mechanism:
250
+
251
+ { "challenge_token": "eyJ...", "mechanism": "Email" }
252
+
253
+ A fresh challenge for that mechanism is returned (and, for `Email`, a
254
+ code is sent), in the same shape as the `202` from `POST /api/v1/tokens`
255
+ minus `two_factor_required`. An unrecognized mechanism returns `400`
256
+ (`invalid_mechanism`); a mechanism the user has not enrolled returns
257
+ `400` (`not_enrolled`). Rate limited to 5 requests per minute (`429`).
258
+ * @summary Switch an in-progress login challenge to a different enrolled mechanism.
259
+ */
260
+ export type authSwitchTwoFactorMechanismResponse200 = {
261
+ data: TwoFactorChallengePayload
262
+ status: 200
263
+ }
264
+
265
+ export type authSwitchTwoFactorMechanismResponse400 = {
266
+ data: string
267
+ status: 400
268
+ }
269
+
270
+ export type authSwitchTwoFactorMechanismResponseSuccess = (authSwitchTwoFactorMechanismResponse200) & {
271
+ headers: Headers;
272
+ };
273
+ export type authSwitchTwoFactorMechanismResponseError = (authSwitchTwoFactorMechanismResponse400) & {
274
+ headers: Headers;
275
+ };
276
+
277
+ export type authSwitchTwoFactorMechanismResponse = (authSwitchTwoFactorMechanismResponseSuccess | authSwitchTwoFactorMechanismResponseError)
278
+
279
+ export const getAuthSwitchTwoFactorMechanismUrl = (params: AuthSwitchTwoFactorMechanismParams,) => {
280
+ const normalizedParams = new URLSearchParams();
281
+
282
+ Object.entries(params || {}).forEach(([key, value]) => {
283
+
284
+ if (value !== undefined) {
285
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
286
+ }
287
+ });
288
+
289
+ const stringifiedParams = normalizedParams.toString();
290
+
291
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/switch-mechanism?${stringifiedParams}` : `/api/v1/tokens/two-factor/switch-mechanism`
292
+ }
293
+
294
+ export const authSwitchTwoFactorMechanism = async (params: AuthSwitchTwoFactorMechanismParams, options?: RequestInit): Promise<authSwitchTwoFactorMechanismResponse> => {
295
+
296
+ return customFetch<authSwitchTwoFactorMechanismResponse>(getAuthSwitchTwoFactorMechanismUrl(params),
297
+ {
298
+ ...options,
299
+ method: 'POST'
300
+
301
+
302
+ }
303
+ );}
304
+
305
+
306
+ /**
307
+ * A fallback for users who cannot produce their primary code but still
308
+ have a recovery code on file (see `recovery_codes_available` on the
309
+ login response). Post the challenge token together with one recovery
310
+ code:
311
+
312
+ { "challenge_token": "eyJ...", "recovery_code": "abcd-efgh-ijkl" }
313
+
314
+ On success the response is `200` with the final access token, in the
315
+ same shape as `POST /api/v1/tokens`. Each recovery code is single-use.
316
+ An incorrect code returns `400` (`invalid_grant`); an expired
317
+ challenge returns `410` (`challenge_expired`). Rate limited to 10
318
+ requests per minute (`429`).
319
+
320
+ Used by the embed login widget; the hosted Razor flow has its own
321
+ equivalent action on the AuthenticationController.
322
+ * @summary Complete a two-factor login challenge with a recovery code instead of
323
+ the primary one-time code, and obtain a JWT access token.
324
+ */
325
+ export type authVerifyTwoFactorRecoveryResponse200 = {
326
+ data: TokenPayload
327
+ status: 200
328
+ }
329
+
330
+ export type authVerifyTwoFactorRecoveryResponse400 = {
331
+ data: string
332
+ status: 400
333
+ }
334
+
335
+ export type authVerifyTwoFactorRecoveryResponse410 = {
336
+ data: string
337
+ status: 410
338
+ }
339
+
340
+ export type authVerifyTwoFactorRecoveryResponseSuccess = (authVerifyTwoFactorRecoveryResponse200) & {
341
+ headers: Headers;
342
+ };
343
+ export type authVerifyTwoFactorRecoveryResponseError = (authVerifyTwoFactorRecoveryResponse400 | authVerifyTwoFactorRecoveryResponse410) & {
344
+ headers: Headers;
345
+ };
346
+
347
+ export type authVerifyTwoFactorRecoveryResponse = (authVerifyTwoFactorRecoveryResponseSuccess | authVerifyTwoFactorRecoveryResponseError)
348
+
349
+ export const getAuthVerifyTwoFactorRecoveryUrl = (params: AuthVerifyTwoFactorRecoveryParams,) => {
350
+ const normalizedParams = new URLSearchParams();
351
+
352
+ Object.entries(params || {}).forEach(([key, value]) => {
353
+
354
+ if (value !== undefined) {
355
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
356
+ }
357
+ });
358
+
359
+ const stringifiedParams = normalizedParams.toString();
360
+
361
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/recovery?${stringifiedParams}` : `/api/v1/tokens/two-factor/recovery`
362
+ }
363
+
364
+ export const authVerifyTwoFactorRecovery = async (params: AuthVerifyTwoFactorRecoveryParams, options?: RequestInit): Promise<authVerifyTwoFactorRecoveryResponse> => {
365
+
366
+ return customFetch<authVerifyTwoFactorRecoveryResponse>(getAuthVerifyTwoFactorRecoveryUrl(params),
367
+ {
368
+ ...options,
369
+ method: 'POST'
370
+
371
+
372
+ }
373
+ );}
374
+
375
+
376
+ /**
377
+ * Call this when `POST /api/v1/tokens` returned
378
+ `two_factor_enrollment_required` and the user chooses email. Post the
379
+ enrollment token from that response:
380
+
381
+ { "enrollment_token": "eyJ..." }
382
+
383
+ A verification code is emailed to the user and a challenge is returned:
384
+
385
+ {
386
+ "challenge_token": "eyJ...",
387
+ "mechanism": "Email",
388
+ "masked_destination": "b***@outseta.com",
389
+ "expires_in": 600
390
+ }
391
+
392
+ Confirm the code via `POST /api/v1/tokens/two-factor/enroll/email/confirm`.
393
+ Returns `401` if the enrollment token is invalid/expired and `403` if
394
+ forced enrollment does not apply to this user. Rate limited to 5
395
+ requests per minute (`429`).
396
+ * @summary Begin email enrollment during a forced-2FA login.
397
+ */
398
+ export type tokenTwoFactorEnrollmentBeginEmailResponse200 = {
399
+ data: TwoFactorChallengePayload
400
+ status: 200
401
+ }
402
+
403
+ export type tokenTwoFactorEnrollmentBeginEmailResponse401 = {
404
+ data: string
405
+ status: 401
406
+ }
407
+
408
+ export type tokenTwoFactorEnrollmentBeginEmailResponse403 = {
409
+ data: string
410
+ status: 403
411
+ }
412
+
413
+ export type tokenTwoFactorEnrollmentBeginEmailResponseSuccess = (tokenTwoFactorEnrollmentBeginEmailResponse200) & {
414
+ headers: Headers;
415
+ };
416
+ export type tokenTwoFactorEnrollmentBeginEmailResponseError = (tokenTwoFactorEnrollmentBeginEmailResponse401 | tokenTwoFactorEnrollmentBeginEmailResponse403) & {
417
+ headers: Headers;
418
+ };
419
+
420
+ export type tokenTwoFactorEnrollmentBeginEmailResponse = (tokenTwoFactorEnrollmentBeginEmailResponseSuccess | tokenTwoFactorEnrollmentBeginEmailResponseError)
421
+
422
+ export const getTokenTwoFactorEnrollmentBeginEmailUrl = (params: TokenTwoFactorEnrollmentBeginEmailParams,) => {
423
+ const normalizedParams = new URLSearchParams();
424
+
425
+ Object.entries(params || {}).forEach(([key, value]) => {
426
+
427
+ if (value !== undefined) {
428
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
429
+ }
430
+ });
431
+
432
+ const stringifiedParams = normalizedParams.toString();
433
+
434
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/enroll/email/begin?${stringifiedParams}` : `/api/v1/tokens/two-factor/enroll/email/begin`
435
+ }
436
+
437
+ export const tokenTwoFactorEnrollmentBeginEmail = async (params: TokenTwoFactorEnrollmentBeginEmailParams, options?: RequestInit): Promise<tokenTwoFactorEnrollmentBeginEmailResponse> => {
438
+
439
+ return customFetch<tokenTwoFactorEnrollmentBeginEmailResponse>(getTokenTwoFactorEnrollmentBeginEmailUrl(params),
440
+ {
441
+ ...options,
442
+ method: 'POST'
443
+
444
+
445
+ }
446
+ );}
447
+
448
+
449
+ export type tokenTwoFactorEnrollmentBeginTotpResponse200 = {
450
+ data: TwoFactorTotpEnrollmentPayload
451
+ status: 200
452
+ }
453
+
454
+ export type tokenTwoFactorEnrollmentBeginTotpResponse401 = {
455
+ data: string
456
+ status: 401
457
+ }
458
+
459
+ export type tokenTwoFactorEnrollmentBeginTotpResponse403 = {
460
+ data: string
461
+ status: 403
462
+ }
463
+
464
+ export type tokenTwoFactorEnrollmentBeginTotpResponseSuccess = (tokenTwoFactorEnrollmentBeginTotpResponse200) & {
465
+ headers: Headers;
466
+ };
467
+ export type tokenTwoFactorEnrollmentBeginTotpResponseError = (tokenTwoFactorEnrollmentBeginTotpResponse401 | tokenTwoFactorEnrollmentBeginTotpResponse403) & {
468
+ headers: Headers;
469
+ };
470
+
471
+ export type tokenTwoFactorEnrollmentBeginTotpResponse = (tokenTwoFactorEnrollmentBeginTotpResponseSuccess | tokenTwoFactorEnrollmentBeginTotpResponseError)
472
+
473
+ export const getTokenTwoFactorEnrollmentBeginTotpUrl = (params: TokenTwoFactorEnrollmentBeginTotpParams,) => {
474
+ const normalizedParams = new URLSearchParams();
475
+
476
+ Object.entries(params || {}).forEach(([key, value]) => {
477
+
478
+ if (value !== undefined) {
479
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
480
+ }
481
+ });
482
+
483
+ const stringifiedParams = normalizedParams.toString();
484
+
485
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/enroll/totp/begin?${stringifiedParams}` : `/api/v1/tokens/two-factor/enroll/totp/begin`
486
+ }
487
+
488
+ export const tokenTwoFactorEnrollmentBeginTotp = async (params: TokenTwoFactorEnrollmentBeginTotpParams, options?: RequestInit): Promise<tokenTwoFactorEnrollmentBeginTotpResponse> => {
489
+
490
+ return customFetch<tokenTwoFactorEnrollmentBeginTotpResponse>(getTokenTwoFactorEnrollmentBeginTotpUrl(params),
491
+ {
492
+ ...options,
493
+ method: 'POST'
494
+
495
+
496
+ }
497
+ );}
498
+
499
+
500
+ /**
501
+ * Post the enrollment token (from `POST /api/v1/tokens`), the challenge
502
+ token (from `.../enroll/email/begin`), and the emailed code:
503
+
504
+ { "enrollment_token": "eyJ...", "challenge_token": "eyJ...", "code": "123456" }
505
+
506
+ On success email 2FA is enabled and login completes — the response
507
+ carries the final access token plus the user's one-time recovery codes:
508
+
509
+ {
510
+ "confirmed": true,
511
+ "recovery_codes": ["abcd-efgh-ijkl", "..."],
512
+ "access_token": "eyJ...",
513
+ "token_type": "Bearer",
514
+ "expires_in": 31536000
515
+ }
516
+
517
+ Show the `recovery_codes` to the user once — they are not returned
518
+ again. An incorrect code returns `400` (`invalid_grant`); an expired
519
+ challenge returns `410` (`challenge_expired`). Rate limited to 10
520
+ requests per minute (`429`).
521
+ * @summary Confirm email enrollment and complete a forced-2FA login.
522
+ */
523
+ export type tokenTwoFactorEnrollmentConfirmEmailResponse200 = {
524
+ data: TwoFactorEnrollmentConfirmationPayload
525
+ status: 200
526
+ }
527
+
528
+ export type tokenTwoFactorEnrollmentConfirmEmailResponse400 = {
529
+ data: string
530
+ status: 400
531
+ }
532
+
533
+ export type tokenTwoFactorEnrollmentConfirmEmailResponse401 = {
534
+ data: string
535
+ status: 401
536
+ }
537
+
538
+ export type tokenTwoFactorEnrollmentConfirmEmailResponse410 = {
539
+ data: string
540
+ status: 410
541
+ }
542
+
543
+ export type tokenTwoFactorEnrollmentConfirmEmailResponseSuccess = (tokenTwoFactorEnrollmentConfirmEmailResponse200) & {
544
+ headers: Headers;
545
+ };
546
+ export type tokenTwoFactorEnrollmentConfirmEmailResponseError = (tokenTwoFactorEnrollmentConfirmEmailResponse400 | tokenTwoFactorEnrollmentConfirmEmailResponse401 | tokenTwoFactorEnrollmentConfirmEmailResponse410) & {
547
+ headers: Headers;
548
+ };
549
+
550
+ export type tokenTwoFactorEnrollmentConfirmEmailResponse = (tokenTwoFactorEnrollmentConfirmEmailResponseSuccess | tokenTwoFactorEnrollmentConfirmEmailResponseError)
551
+
552
+ export const getTokenTwoFactorEnrollmentConfirmEmailUrl = (params: TokenTwoFactorEnrollmentConfirmEmailParams,) => {
553
+ const normalizedParams = new URLSearchParams();
554
+
555
+ Object.entries(params || {}).forEach(([key, value]) => {
556
+
557
+ if (value !== undefined) {
558
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
559
+ }
560
+ });
561
+
562
+ const stringifiedParams = normalizedParams.toString();
563
+
564
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/enroll/email/confirm?${stringifiedParams}` : `/api/v1/tokens/two-factor/enroll/email/confirm`
565
+ }
566
+
567
+ export const tokenTwoFactorEnrollmentConfirmEmail = async (params: TokenTwoFactorEnrollmentConfirmEmailParams, options?: RequestInit): Promise<tokenTwoFactorEnrollmentConfirmEmailResponse> => {
568
+
569
+ return customFetch<tokenTwoFactorEnrollmentConfirmEmailResponse>(getTokenTwoFactorEnrollmentConfirmEmailUrl(params),
570
+ {
571
+ ...options,
572
+ method: 'POST'
573
+
574
+
575
+ }
576
+ );}
577
+
578
+
579
+ /**
580
+ * Post the enrollment token (from `POST /api/v1/tokens`), the challenge
581
+ token (from `.../enroll/totp/begin`), and the current code from the
582
+ user's authenticator app:
583
+
584
+ { "enrollment_token": "eyJ...", "challenge_token": "eyJ...", "code": "123456" }
585
+
586
+ On success authenticator-app 2FA is enabled and login completes — the
587
+ response carries the final access token plus the user's one-time
588
+ recovery codes:
589
+
590
+ {
591
+ "confirmed": true,
592
+ "recovery_codes": ["abcd-efgh-ijkl", "..."],
593
+ "access_token": "eyJ...",
594
+ "token_type": "Bearer",
595
+ "expires_in": 31536000
596
+ }
597
+
598
+ Show the `recovery_codes` to the user once — they are not returned
599
+ again. An incorrect code returns `400` (`invalid_grant`); an expired
600
+ challenge returns `410` (`challenge_expired`). Rate limited to 10
601
+ requests per minute (`429`).
602
+ * @summary Confirm authenticator-app (TOTP) enrollment and complete a forced-2FA login.
603
+ */
604
+ export type tokenTwoFactorEnrollmentConfirmTotpResponse200 = {
605
+ data: TwoFactorEnrollmentConfirmationPayload
606
+ status: 200
607
+ }
608
+
609
+ export type tokenTwoFactorEnrollmentConfirmTotpResponse400 = {
610
+ data: string
611
+ status: 400
612
+ }
613
+
614
+ export type tokenTwoFactorEnrollmentConfirmTotpResponse401 = {
615
+ data: string
616
+ status: 401
617
+ }
618
+
619
+ export type tokenTwoFactorEnrollmentConfirmTotpResponse410 = {
620
+ data: string
621
+ status: 410
622
+ }
623
+
624
+ export type tokenTwoFactorEnrollmentConfirmTotpResponseSuccess = (tokenTwoFactorEnrollmentConfirmTotpResponse200) & {
625
+ headers: Headers;
626
+ };
627
+ export type tokenTwoFactorEnrollmentConfirmTotpResponseError = (tokenTwoFactorEnrollmentConfirmTotpResponse400 | tokenTwoFactorEnrollmentConfirmTotpResponse401 | tokenTwoFactorEnrollmentConfirmTotpResponse410) & {
628
+ headers: Headers;
629
+ };
630
+
631
+ export type tokenTwoFactorEnrollmentConfirmTotpResponse = (tokenTwoFactorEnrollmentConfirmTotpResponseSuccess | tokenTwoFactorEnrollmentConfirmTotpResponseError)
632
+
633
+ export const getTokenTwoFactorEnrollmentConfirmTotpUrl = (params: TokenTwoFactorEnrollmentConfirmTotpParams,) => {
634
+ const normalizedParams = new URLSearchParams();
635
+
636
+ Object.entries(params || {}).forEach(([key, value]) => {
637
+
638
+ if (value !== undefined) {
639
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
640
+ }
641
+ });
642
+
643
+ const stringifiedParams = normalizedParams.toString();
644
+
645
+ return stringifiedParams.length > 0 ? `/api/v1/tokens/two-factor/enroll/totp/confirm?${stringifiedParams}` : `/api/v1/tokens/two-factor/enroll/totp/confirm`
646
+ }
647
+
648
+ export const tokenTwoFactorEnrollmentConfirmTotp = async (params: TokenTwoFactorEnrollmentConfirmTotpParams, options?: RequestInit): Promise<tokenTwoFactorEnrollmentConfirmTotpResponse> => {
649
+
650
+ return customFetch<tokenTwoFactorEnrollmentConfirmTotpResponse>(getTokenTwoFactorEnrollmentConfirmTotpUrl(params),
651
+ {
652
+ ...options,
653
+ method: 'POST'
654
+
655
+
656
+ }
657
+ );}
658
+
659
+