@outseta/react 0.3.3 → 0.3.4

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/react",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "React hooks and components for the Outseta API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@tanstack/react-query": "^5.0.0",
22
- "@outseta/api-client": "0.3.3"
22
+ "@outseta/api-client": "0.3.4"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^18.0.0 || ^19.0.0"
@@ -2715,6 +2715,30 @@ as a fallback if they cannot produce a primary code.
2715
2715
  recovery_codes_available?: boolean | null;
2716
2716
  }
2717
2717
 
2718
+ /**
2719
+ * Request body for POST /api/v1/tokens/two-factor: the challenge token
2720
+ from the login response plus the user's one-time code. Property names are
2721
+ snake_case to match the wire format of the token endpoints.
2722
+
2723
+ The action binds the body as a loose JObject at runtime; this type
2724
+ exists so the API docs describe the body instead of an opaque data
2725
+ parameter (see [OpenApiRequestBody] on the action).
2726
+ */
2727
+ export interface TwoFactorVerifyRequest {
2728
+ /**
2729
+ * The challenge_token returned by POST /api/v1/tokens when
2730
+ two-factor authentication is required. Echo it back verbatim.
2731
+ * @nullable
2732
+ */
2733
+ challenge_token?: string | null;
2734
+ /**
2735
+ * The user's one-time code: the emailed code for an Email challenge,
2736
+ or the current code from their authenticator app for a Totp challenge.
2737
+ * @nullable
2738
+ */
2739
+ code?: string | null;
2740
+ }
2741
+
2718
2742
  export interface PasswordPayload {
2719
2743
  /** @nullable */
2720
2744
  Password?: string | null;
@@ -5840,13 +5864,6 @@ export type AuthGetTokenParams = {
5840
5864
  data: unknown | null;
5841
5865
  };
5842
5866
 
5843
- export type AuthVerifyTwoFactorTokenParams = {
5844
- /**
5845
- * @nullable
5846
- */
5847
- data: unknown | null;
5848
- };
5849
-
5850
5867
  export type AuthResendTwoFactorParams = {
5851
5868
  /**
5852
5869
  * @nullable
@@ -5868,13 +5885,6 @@ export type AuthVerifyTwoFactorRecoveryParams = {
5868
5885
  data: unknown | null;
5869
5886
  };
5870
5887
 
5871
- export type AuthRefreshTokenParams = {
5872
- /**
5873
- * @nullable
5874
- */
5875
- data: unknown | null;
5876
- };
5877
-
5878
5888
  export type TokenTwoFactorEnrollmentBeginEmailParams = {
5879
5889
  /**
5880
5890
  * @nullable
@@ -10,11 +10,9 @@ import type {
10
10
 
11
11
  import type {
12
12
  AuthGetTokenParams,
13
- AuthRefreshTokenParams,
14
13
  AuthResendTwoFactorParams,
15
14
  AuthSwitchTwoFactorMechanismParams,
16
15
  AuthVerifyTwoFactorRecoveryParams,
17
- AuthVerifyTwoFactorTokenParams,
18
16
  TokenPayload,
19
17
  TokenTwoFactorEnrollmentBeginEmailParams,
20
18
  TokenTwoFactorEnrollmentBeginTotpParams,
@@ -22,7 +20,8 @@ import type {
22
20
  TokenTwoFactorEnrollmentConfirmTotpParams,
23
21
  TwoFactorChallengePayload,
24
22
  TwoFactorEnrollmentConfirmationPayload,
25
- TwoFactorTotpEnrollmentPayload
23
+ TwoFactorTotpEnrollmentPayload,
24
+ TwoFactorVerifyRequest
26
25
  } from '../outsetaAPI.schemas';
27
26
 
28
27
  import { customFetch } from '../../mutator';
@@ -147,17 +146,18 @@ An incorrect code returns `400` (`invalid_grant`). A code has at most
147
146
  five attempts before the challenge locks. An expired challenge returns
148
147
  `410` (`challenge_expired`) — restart at `POST /api/v1/tokens`. The
149
148
  endpoint is rate limited to 10 requests per minute (`429`).
150
- * @summary Complete a two-factor login challenge and obtain a JWT access token.
149
+ * @summary Complete login when user has two-factor authentication enabled.
151
150
  */
152
151
  export const authVerifyTwoFactorToken = (
153
- params: AuthVerifyTwoFactorTokenParams,
152
+ twoFactorVerifyRequest: TwoFactorVerifyRequest,
154
153
  options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
155
154
  ) => {
156
155
 
157
156
 
158
157
  return customFetch<TokenPayload>(
159
158
  {url: `/api/v1/tokens/two-factor`, method: 'POST',
160
- params, signal
159
+ headers: {'Content-Type': 'application/json', },
160
+ data: twoFactorVerifyRequest, signal
161
161
  },
162
162
  options);
163
163
  }
@@ -165,8 +165,8 @@ export const authVerifyTwoFactorToken = (
165
165
 
166
166
 
167
167
  export const getAuthVerifyTwoFactorTokenMutationOptions = <TError = string,
168
- TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{params: AuthVerifyTwoFactorTokenParams}, TContext>, request?: SecondParameter<typeof customFetch>}
169
- ): UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{params: AuthVerifyTwoFactorTokenParams}, TContext> => {
168
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{data: TwoFactorVerifyRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
169
+ ): UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{data: TwoFactorVerifyRequest}, TContext> => {
170
170
 
171
171
  const mutationKey = ['authVerifyTwoFactorToken'];
172
172
  const {mutation: mutationOptions, request: requestOptions} = options ?
@@ -178,10 +178,10 @@ const {mutation: mutationOptions, request: requestOptions} = options ?
178
178
 
179
179
 
180
180
 
181
- const mutationFn: MutationFunction<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, {params: AuthVerifyTwoFactorTokenParams}> = (props) => {
182
- const {params} = props ?? {};
181
+ const mutationFn: MutationFunction<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, {data: TwoFactorVerifyRequest}> = (props) => {
182
+ const {data} = props ?? {};
183
183
 
184
- return authVerifyTwoFactorToken(params,requestOptions)
184
+ return authVerifyTwoFactorToken(data,requestOptions)
185
185
  }
186
186
 
187
187
 
@@ -190,18 +190,18 @@ const {mutation: mutationOptions, request: requestOptions} = options ?
190
190
  return { mutationFn, ...mutationOptions }}
191
191
 
192
192
  export type AuthVerifyTwoFactorTokenMutationResult = NonNullable<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>>
193
-
193
+ export type AuthVerifyTwoFactorTokenMutationBody = TwoFactorVerifyRequest
194
194
  export type AuthVerifyTwoFactorTokenMutationError = string
195
195
 
196
196
  /**
197
- * @summary Complete a two-factor login challenge and obtain a JWT access token.
197
+ * @summary Complete login when user has two-factor authentication enabled.
198
198
  */
199
199
  export const useAuthVerifyTwoFactorToken = <TError = string,
200
- TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{params: AuthVerifyTwoFactorTokenParams}, TContext>, request?: SecondParameter<typeof customFetch>}
200
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorToken>>, TError,{data: TwoFactorVerifyRequest}, TContext>, request?: SecondParameter<typeof customFetch>}
201
201
  ): UseMutationResult<
202
202
  Awaited<ReturnType<typeof authVerifyTwoFactorToken>>,
203
203
  TError,
204
- {params: AuthVerifyTwoFactorTokenParams},
204
+ {data: TwoFactorVerifyRequest},
205
205
  TContext
206
206
  > => {
207
207
 
@@ -375,8 +375,7 @@ requests per minute (`429`).
375
375
 
376
376
  Used by the embed login widget; the hosted Razor flow has its own
377
377
  equivalent action on the AuthenticationController.
378
- * @summary Complete a two-factor login challenge with a recovery code instead of
379
- the primary one-time code, and obtain a JWT access token.
378
+ * @summary Complete login with a two-factor recovery code.
380
379
  */
381
380
  export const authVerifyTwoFactorRecovery = (
382
381
  params: AuthVerifyTwoFactorRecoveryParams,
@@ -423,8 +422,7 @@ const {mutation: mutationOptions, request: requestOptions} = options ?
423
422
  export type AuthVerifyTwoFactorRecoveryMutationError = string
424
423
 
425
424
  /**
426
- * @summary Complete a two-factor login challenge with a recovery code instead of
427
- the primary one-time code, and obtain a JWT access token.
425
+ * @summary Complete login with a two-factor recovery code.
428
426
  */
429
427
  export const useAuthVerifyTwoFactorRecovery = <TError = string,
430
428
  TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authVerifyTwoFactorRecovery>>, TError,{params: AuthVerifyTwoFactorRecoveryParams}, TContext>, request?: SecondParameter<typeof customFetch>}
@@ -440,79 +438,6 @@ export const useAuthVerifyTwoFactorRecovery = <TError = string,
440
438
  return useMutation(mutationOptions);
441
439
  }
442
440
  /**
443
- * Post the refresh token returned from `POST /api/v1/tokens` or the
444
- two-factor completion endpoints:
445
-
446
- { "refresh_token": "..." }
447
-
448
- On success the response is `200` with a new access token and refresh token:
449
-
450
- { "access_token": "eyJ...", "refresh_token": "...", "token_type": "Bearer", "expires_in": 31536000 }
451
-
452
- An invalid or expired refresh token returns `400` with a body of `invalid_grant`.
453
- * @summary Exchange a refresh token for a new access token.
454
- */
455
- export const authRefreshToken = (
456
- params: AuthRefreshTokenParams,
457
- options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
458
- ) => {
459
-
460
-
461
- return customFetch<TokenPayload>(
462
- {url: `/api/v1/tokens/refresh-token`, method: 'POST',
463
- params, signal
464
- },
465
- options);
466
- }
467
-
468
-
469
-
470
- export const getAuthRefreshTokenMutationOptions = <TError = string,
471
- TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authRefreshToken>>, TError,{params: AuthRefreshTokenParams}, TContext>, request?: SecondParameter<typeof customFetch>}
472
- ): UseMutationOptions<Awaited<ReturnType<typeof authRefreshToken>>, TError,{params: AuthRefreshTokenParams}, TContext> => {
473
-
474
- const mutationKey = ['authRefreshToken'];
475
- const {mutation: mutationOptions, request: requestOptions} = options ?
476
- options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
477
- options
478
- : {...options, mutation: {...options.mutation, mutationKey}}
479
- : {mutation: { mutationKey, }, request: undefined};
480
-
481
-
482
-
483
-
484
- const mutationFn: MutationFunction<Awaited<ReturnType<typeof authRefreshToken>>, {params: AuthRefreshTokenParams}> = (props) => {
485
- const {params} = props ?? {};
486
-
487
- return authRefreshToken(params,requestOptions)
488
- }
489
-
490
-
491
-
492
-
493
- return { mutationFn, ...mutationOptions }}
494
-
495
- export type AuthRefreshTokenMutationResult = NonNullable<Awaited<ReturnType<typeof authRefreshToken>>>
496
-
497
- export type AuthRefreshTokenMutationError = string
498
-
499
- /**
500
- * @summary Exchange a refresh token for a new access token.
501
- */
502
- export const useAuthRefreshToken = <TError = string,
503
- TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof authRefreshToken>>, TError,{params: AuthRefreshTokenParams}, TContext>, request?: SecondParameter<typeof customFetch>}
504
- ): UseMutationResult<
505
- Awaited<ReturnType<typeof authRefreshToken>>,
506
- TError,
507
- {params: AuthRefreshTokenParams},
508
- TContext
509
- > => {
510
-
511
- const mutationOptions = getAuthRefreshTokenMutationOptions(options);
512
-
513
- return useMutation(mutationOptions);
514
- }
515
- /**
516
441
  * Call this when `POST /api/v1/tokens` returned
517
442
  `two_factor_enrollment_required` and the user chooses email. Post the
518
443
  enrollment token from that response: