@outseta/react 0.3.2 → 0.3.3

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.2",
3
+ "version": "0.3.3",
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.2"
22
+ "@outseta/api-client": "0.3.3"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^18.0.0 || ^19.0.0"
@@ -2642,6 +2642,8 @@ export interface TokenPayload {
2642
2642
  /** @nullable */
2643
2643
  id_token?: string | null;
2644
2644
  /** @nullable */
2645
+ refresh_token?: string | null;
2646
+ /** @nullable */
2645
2647
  token_type?: string | null;
2646
2648
  }
2647
2649
 
@@ -3593,6 +3595,8 @@ export type SendGridDomainAuthenticationAllOf = {
3593
3595
  LastValidationAttempt?: string | null;
3594
3596
  /** @nullable */
3595
3597
  DnsEntries?: DnsEntry[] | null;
3598
+ /** @nullable */
3599
+ LegacyDnsEntries?: DnsEntry[] | null;
3596
3600
  };
3597
3601
 
3598
3602
  export type SendGridDomainAuthentication = AbstractQcountBean & SendGridDomainAuthenticationAllOf;
@@ -5864,6 +5868,13 @@ export type AuthVerifyTwoFactorRecoveryParams = {
5864
5868
  data: unknown | null;
5865
5869
  };
5866
5870
 
5871
+ export type AuthRefreshTokenParams = {
5872
+ /**
5873
+ * @nullable
5874
+ */
5875
+ data: unknown | null;
5876
+ };
5877
+
5867
5878
  export type TokenTwoFactorEnrollmentBeginEmailParams = {
5868
5879
  /**
5869
5880
  * @nullable
@@ -10,6 +10,7 @@ import type {
10
10
 
11
11
  import type {
12
12
  AuthGetTokenParams,
13
+ AuthRefreshTokenParams,
13
14
  AuthResendTwoFactorParams,
14
15
  AuthSwitchTwoFactorMechanismParams,
15
16
  AuthVerifyTwoFactorRecoveryParams,
@@ -36,9 +37,9 @@ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
36
37
 
37
38
  { "username": "user@example.com", "password": "their-password" }
38
39
 
39
- On success the response is `200` with an access token:
40
+ On success the response is `200` with an access token and refresh token:
40
41
 
41
- { "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 31536000 }
42
+ { "access_token": "eyJ...", "refresh_token": "...", "token_type": "Bearer", "expires_in": 31536000 }
42
43
 
43
44
  **Two-factor authentication.** If the user has a verified 2FA method,
44
45
  the password alone is not enough. After verifying the password this
@@ -140,7 +141,7 @@ authenticator app):
140
141
  On success the response is `200` with the final access token, in the
141
142
  same shape as `POST /api/v1/tokens`:
142
143
 
143
- { "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 31536000 }
144
+ { "access_token": "eyJ...", "refresh_token": "...", "token_type": "Bearer", "expires_in": 31536000 }
144
145
 
145
146
  An incorrect code returns `400` (`invalid_grant`). A code has at most
146
147
  five attempts before the challenge locks. An expired challenge returns
@@ -439,6 +440,79 @@ export const useAuthVerifyTwoFactorRecovery = <TError = string,
439
440
  return useMutation(mutationOptions);
440
441
  }
441
442
  /**
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
+ /**
442
516
  * Call this when `POST /api/v1/tokens` returned
443
517
  `two_factor_enrollment_required` and the user chooses email. Post the
444
518
  enrollment token from that response: