@outseta/api-client 0.2.5 → 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/README.md +8 -23
- package/dist/index.js +1403 -1
- package/package.json +1 -1
- package/src/client.ts +7 -0
- package/src/generated/models/authGetTokenParams.ts +8 -0
- package/src/generated/models/authResendTwoFactorParams.ts +8 -0
- package/src/generated/models/authSwitchTwoFactorMechanismParams.ts +8 -0
- package/src/generated/models/authVerifyTwoFactorRecoveryParams.ts +8 -0
- package/src/generated/models/authVerifyTwoFactorTokenParams.ts +8 -0
- package/src/generated/models/index.ts +13 -0
- package/src/generated/models/tokenPayload.ts +13 -0
- package/src/generated/models/tokenTwoFactorEnrollmentBeginEmailParams.ts +8 -0
- package/src/generated/models/tokenTwoFactorEnrollmentBeginTotpParams.ts +8 -0
- package/src/generated/models/tokenTwoFactorEnrollmentConfirmEmailParams.ts +8 -0
- package/src/generated/models/tokenTwoFactorEnrollmentConfirmTotpParams.ts +8 -0
- package/src/generated/models/twoFactorChallengePayload.ts +69 -0
- package/src/generated/models/twoFactorEnrollmentConfirmationPayload.ts +35 -0
- package/src/generated/models/twoFactorTotpEnrollmentPayload.ts +39 -0
- package/src/generated/public/public.ts +659 -0
- package/src/index.ts +8 -3
|
@@ -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
|
+
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createClient, customFetch } from "./client.js";
|
|
1
|
+
export { createClient, customFetch, withClient } from "./client.js";
|
|
2
2
|
export type {
|
|
3
3
|
OutsetaCredentials,
|
|
4
4
|
OutsetaApiKeyCredentials,
|
|
@@ -7,5 +7,10 @@ export type {
|
|
|
7
7
|
OutsetaRequestInit,
|
|
8
8
|
} from "./client.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
|
|
10
|
+
// Generated API functions and model types
|
|
11
|
+
export * from "./generated/activity/activity.js";
|
|
12
|
+
export * from "./generated/billing/billing.js";
|
|
13
|
+
export * from "./generated/crm/crm.js";
|
|
14
|
+
export * from "./generated/email/email.js";
|
|
15
|
+
export * from "./generated/support/support.js";
|
|
16
|
+
export * from "./generated/models/index.js";
|