@outseta/react 0.3.3 → 0.3.5

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/dist/index.js CHANGED
@@ -1968,6 +1968,13 @@ var LineItemType = {
1968
1968
  PlanCredit: 7,
1969
1969
  AddOnCredit: 8
1970
1970
  };
1971
+ var CancelationStatus = {
1972
+ Pending: 0,
1973
+ Unknown: 1,
1974
+ Completed: 2,
1975
+ Removed: 3,
1976
+ Deleted: 4
1977
+ };
1971
1978
  var OAuthService = {
1972
1979
  None: 0,
1973
1980
  Gmail: 1
@@ -2200,13 +2207,6 @@ var BackGroundTaskType = {
2200
2207
  SendInvoicePaidEmailTask: 20,
2201
2208
  ResendTrialLimitEmailTask: 21
2202
2209
  };
2203
- var CancelationStatus = {
2204
- Pending: 0,
2205
- Unknown: 1,
2206
- Completed: 2,
2207
- Removed: 3,
2208
- Deleted: 4
2209
- };
2210
2210
  var RegistrationField = {
2211
2211
  PersonFirstName: 1,
2212
2212
  PersonLastName: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outseta/react",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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"
@@ -2396,6 +2396,48 @@ export const LineItemType = {
2396
2396
  AddOnCredit: 8,
2397
2397
  } as const;
2398
2398
 
2399
+ /**
2400
+ * @nullable
2401
+ */
2402
+ export type AccountCancelationAllOfAccount = Account | null;
2403
+
2404
+ /**
2405
+ * @nullable
2406
+ */
2407
+ export type AccountCancelationAllOfLastPlan = Plan | null;
2408
+
2409
+ export type AccountCancelationAllOf = {
2410
+ SubmittedDateTime?: string;
2411
+ /** @nullable */
2412
+ CancelationReason?: string | null;
2413
+ /** @nullable */
2414
+ Comment?: string | null;
2415
+ CancelationStatus?: CancelationStatus;
2416
+ /** @nullable */
2417
+ Account?: AccountCancelationAllOfAccount;
2418
+ /** @nullable */
2419
+ LastPlan?: AccountCancelationAllOfLastPlan;
2420
+ /** @nullable */
2421
+ SubscribingStartDate?: string | null;
2422
+ };
2423
+
2424
+ export type AccountCancelation = AbstractQcountBean & AccountCancelationAllOf;
2425
+
2426
+ /**
2427
+ * `0` - Pending, `1` - Unknown, `2` - Completed, `3` - Removed, `4` - Deleted
2428
+ */
2429
+ export type CancelationStatus = typeof CancelationStatus[keyof typeof CancelationStatus];
2430
+
2431
+
2432
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
2433
+ export const CancelationStatus = {
2434
+ Pending: 0,
2435
+ Unknown: 1,
2436
+ Completed: 2,
2437
+ Removed: 3,
2438
+ Deleted: 4,
2439
+ } as const;
2440
+
2399
2441
  /**
2400
2442
  * @nullable
2401
2443
  */
@@ -2715,6 +2757,30 @@ as a fallback if they cannot produce a primary code.
2715
2757
  recovery_codes_available?: boolean | null;
2716
2758
  }
2717
2759
 
2760
+ /**
2761
+ * Request body for POST /api/v1/tokens/two-factor: the challenge token
2762
+ from the login response plus the user's one-time code. Property names are
2763
+ snake_case to match the wire format of the token endpoints.
2764
+
2765
+ The action binds the body as a loose JObject at runtime; this type
2766
+ exists so the API docs describe the body instead of an opaque data
2767
+ parameter (see [OpenApiRequestBody] on the action).
2768
+ */
2769
+ export interface TwoFactorVerifyRequest {
2770
+ /**
2771
+ * The challenge_token returned by POST /api/v1/tokens when
2772
+ two-factor authentication is required. Echo it back verbatim.
2773
+ * @nullable
2774
+ */
2775
+ challenge_token?: string | null;
2776
+ /**
2777
+ * The user's one-time code: the emailed code for an Email challenge,
2778
+ or the current code from their authenticator app for a Totp challenge.
2779
+ * @nullable
2780
+ */
2781
+ code?: string | null;
2782
+ }
2783
+
2718
2784
  export interface PasswordPayload {
2719
2785
  /** @nullable */
2720
2786
  Password?: string | null;
@@ -4166,48 +4232,6 @@ export const BackGroundTaskType = {
4166
4232
  ResendTrialLimitEmailTask: 21,
4167
4233
  } as const;
4168
4234
 
4169
- /**
4170
- * @nullable
4171
- */
4172
- export type AccountCancelationAllOfAccount = Account | null;
4173
-
4174
- /**
4175
- * @nullable
4176
- */
4177
- export type AccountCancelationAllOfLastPlan = Plan | null;
4178
-
4179
- export type AccountCancelationAllOf = {
4180
- SubmittedDateTime?: string;
4181
- /** @nullable */
4182
- CancelationReason?: string | null;
4183
- /** @nullable */
4184
- Comment?: string | null;
4185
- CancelationStatus?: CancelationStatus;
4186
- /** @nullable */
4187
- Account?: AccountCancelationAllOfAccount;
4188
- /** @nullable */
4189
- LastPlan?: AccountCancelationAllOfLastPlan;
4190
- /** @nullable */
4191
- SubscribingStartDate?: string | null;
4192
- };
4193
-
4194
- export type AccountCancelation = AbstractQcountBean & AccountCancelationAllOf;
4195
-
4196
- /**
4197
- * `0` - Pending, `1` - Unknown, `2` - Completed, `3` - Removed, `4` - Deleted
4198
- */
4199
- export type CancelationStatus = typeof CancelationStatus[keyof typeof CancelationStatus];
4200
-
4201
-
4202
- // eslint-disable-next-line @typescript-eslint/no-redeclare
4203
- export const CancelationStatus = {
4204
- Pending: 0,
4205
- Unknown: 1,
4206
- Completed: 2,
4207
- Removed: 3,
4208
- Deleted: 4,
4209
- } as const;
4210
-
4211
4235
  export interface PasswordChangeModel {
4212
4236
  /** @nullable */
4213
4237
  ExistingPassword?: 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: