@aws-amplify/ui 6.8.1 → 6.9.0

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.
@@ -1,6 +1,6 @@
1
1
  import { Amplify } from 'aws-amplify';
2
- import 'aws-amplify/utils';
3
2
  import '@aws-amplify/core/internals/utils';
3
+ import 'aws-amplify/utils';
4
4
  import '../../utils/setUserAgent/constants.mjs';
5
5
  import '../../types/authenticator/user.mjs';
6
6
  import '../../types/authenticator/attributes.mjs';
@@ -1,5 +1,5 @@
1
+ import { AmplifyErrorCode } from '@aws-amplify/core/internals/utils';
1
2
  import { Hub } from 'aws-amplify/utils';
2
- import '@aws-amplify/core/internals/utils';
3
3
  import '../../utils/setUserAgent/constants.mjs';
4
4
  import { isFunction } from '../../utils/utils.mjs';
5
5
 
@@ -8,7 +8,7 @@ import { isFunction } from '../../utils/utils.mjs';
8
8
  * xstate events.
9
9
  */
10
10
  const defaultAuthHubHandler = ({ payload }, service, options) => {
11
- const { event } = payload;
11
+ const { data, event } = payload;
12
12
  const { send } = service;
13
13
  const { onSignIn, onSignOut } = options ?? {};
14
14
  switch (event) {
@@ -22,14 +22,20 @@ const defaultAuthHubHandler = ({ payload }, service, options) => {
22
22
  send('SIGN_IN_WITH_REDIRECT');
23
23
  break;
24
24
  }
25
- case 'signedOut':
26
- case 'tokenRefresh_failure': {
27
- if (event === 'signedOut' && isFunction(onSignOut)) {
25
+ case 'signedOut': {
26
+ if (isFunction(onSignOut)) {
28
27
  onSignOut();
29
28
  }
30
29
  send('SIGN_OUT');
31
30
  break;
32
31
  }
32
+ case 'tokenRefresh_failure': {
33
+ if (data?.error?.name === AmplifyErrorCode.NetworkError) {
34
+ return;
35
+ }
36
+ send('SIGN_OUT');
37
+ break;
38
+ }
33
39
  }
34
40
  };
35
41
  /**
@@ -1,6 +1,6 @@
1
1
  import { actions } from 'xstate';
2
- import 'aws-amplify/utils';
3
2
  import '@aws-amplify/core/internals/utils';
3
+ import 'aws-amplify/utils';
4
4
  import '../../utils/setUserAgent/constants.mjs';
5
5
  import '../../types/authenticator/user.mjs';
6
6
  import '../../types/authenticator/attributes.mjs';
@@ -1,5 +1,5 @@
1
1
  import { createMachine, sendUpdate } from 'xstate';
2
- import { fetchUserAttributes, resetPassword, resendSignUpCode, confirmSignIn, signInWithRedirect } from 'aws-amplify/auth';
2
+ import { fetchUserAttributes, resetPassword, confirmSignIn, signInWithRedirect } from 'aws-amplify/auth';
3
3
  import { runValidators } from '../../../validators/index.mjs';
4
4
  import ACTIONS from '../actions.mjs';
5
5
  import { defaultServices } from '../defaultServices.mjs';
@@ -277,7 +277,7 @@ function signInActor({ services }) {
277
277
  return resetPassword({ username });
278
278
  },
279
279
  handleResendSignUpCode({ username }) {
280
- return resendSignUpCode({ username });
280
+ return services.handleResendSignUpCode({ username });
281
281
  },
282
282
  handleSignIn({ formValues, username }) {
283
283
  const { password } = formValues;
@@ -1,5 +1,5 @@
1
1
  import { createMachine, sendUpdate } from 'xstate';
2
- import { autoSignIn, fetchUserAttributes, resendSignUpCode, signInWithRedirect } from 'aws-amplify/auth';
2
+ import { autoSignIn, fetchUserAttributes, signInWithRedirect } from 'aws-amplify/auth';
3
3
  import { getSignUpInput } from '../utils.mjs';
4
4
  import { runValidators } from '../../../validators/index.mjs';
5
5
  import ACTIONS from '../actions.mjs';
@@ -263,7 +263,7 @@ function signUpActor({ services }) {
263
263
  return services.handleConfirmSignUp(input);
264
264
  },
265
265
  resendSignUpCode({ username }) {
266
- return resendSignUpCode({ username });
266
+ return services.handleResendSignUpCode({ username });
267
267
  },
268
268
  signInWithRedirect(_, { data }) {
269
269
  return signInWithRedirect(data);
@@ -1,7 +1,7 @@
1
1
  import { Amplify } from 'aws-amplify';
2
- import { getCurrentUser, signIn, signUp, confirmSignIn, confirmSignUp, confirmResetPassword, resetPassword } from 'aws-amplify/auth';
3
- import 'aws-amplify/utils';
2
+ import { getCurrentUser, signIn, signUp, confirmSignIn, confirmSignUp, confirmResetPassword, resetPassword, resendSignUpCode } from 'aws-amplify/auth';
4
3
  import '@aws-amplify/core/internals/utils';
4
+ import 'aws-amplify/utils';
5
5
  import '../../utils/setUserAgent/constants.mjs';
6
6
  import '../../types/authenticator/user.mjs';
7
7
  import '../../types/authenticator/attributes.mjs';
@@ -54,6 +54,7 @@ const defaultServices = {
54
54
  handleConfirmSignUp: confirmSignUp,
55
55
  handleForgotPasswordSubmit: confirmResetPassword,
56
56
  handleForgotPassword: resetPassword,
57
+ handleResendSignUpCode: resendSignUpCode,
57
58
  // Validation hooks for overriding
58
59
  async validateCustomSignUp(_, __) { },
59
60
  async validateFormPassword(formData, touchData, passwordSettings) {
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils$1 = require('aws-amplify/utils');
6
5
  var utils = require('@aws-amplify/core/internals/utils');
6
+ var utils$1 = require('aws-amplify/utils');
7
7
  var auth = require('aws-amplify/auth');
8
8
  var awsAmplify = require('aws-amplify');
9
9
  var xstate = require('xstate');
@@ -583,7 +583,7 @@ function getName(path) {
583
583
  * xstate events.
584
584
  */
585
585
  const defaultAuthHubHandler = ({ payload }, service, options) => {
586
- const { event } = payload;
586
+ const { data, event } = payload;
587
587
  const { send } = service;
588
588
  const { onSignIn, onSignOut } = options ?? {};
589
589
  switch (event) {
@@ -597,14 +597,20 @@ const defaultAuthHubHandler = ({ payload }, service, options) => {
597
597
  send('SIGN_IN_WITH_REDIRECT');
598
598
  break;
599
599
  }
600
- case 'signedOut':
601
- case 'tokenRefresh_failure': {
602
- if (event === 'signedOut' && isFunction(onSignOut)) {
600
+ case 'signedOut': {
601
+ if (isFunction(onSignOut)) {
603
602
  onSignOut();
604
603
  }
605
604
  send('SIGN_OUT');
606
605
  break;
607
606
  }
607
+ case 'tokenRefresh_failure': {
608
+ if (data?.error?.name === utils.AmplifyErrorCode.NetworkError) {
609
+ return;
610
+ }
611
+ send('SIGN_OUT');
612
+ break;
613
+ }
608
614
  }
609
615
  };
610
616
  /**
@@ -4131,6 +4137,7 @@ const defaultServices = {
4131
4137
  handleConfirmSignUp: auth.confirmSignUp,
4132
4138
  handleForgotPasswordSubmit: auth.confirmResetPassword,
4133
4139
  handleForgotPassword: auth.resetPassword,
4140
+ handleResendSignUpCode: auth.resendSignUpCode,
4134
4141
  // Validation hooks for overriding
4135
4142
  async validateCustomSignUp(_, __) { },
4136
4143
  async validateFormPassword(formData, touchData, passwordSettings) {
@@ -4642,7 +4649,7 @@ function signInActor({ services }) {
4642
4649
  return auth.resetPassword({ username });
4643
4650
  },
4644
4651
  handleResendSignUpCode({ username }) {
4645
- return auth.resendSignUpCode({ username });
4652
+ return services.handleResendSignUpCode({ username });
4646
4653
  },
4647
4654
  handleSignIn({ formValues, username }) {
4648
4655
  const { password } = formValues;
@@ -4942,7 +4949,7 @@ function signUpActor({ services }) {
4942
4949
  return services.handleConfirmSignUp(input);
4943
4950
  },
4944
4951
  resendSignUpCode({ username }) {
4945
- return auth.resendSignUpCode({ username });
4952
+ return services.handleResendSignUpCode({ username });
4946
4953
  },
4947
4954
  signInWithRedirect(_, { data }) {
4948
4955
  return auth.signInWithRedirect(data);
@@ -1,5 +1,5 @@
1
1
  import { UserAttributeKey } from 'aws-amplify/auth';
2
- import { confirmResetPassword, confirmSignIn, confirmSignUp, resetPassword, signIn, signUp } from 'aws-amplify/auth';
2
+ import { confirmResetPassword, confirmSignIn, confirmSignUp, resendSignUpCode, resetPassword, signIn, signUp } from 'aws-amplify/auth';
3
3
  import { AuthFormData, AuthTouchData, PasswordSettings, SocialProvider, ValidatorResult } from '../../types';
4
4
  export declare const defaultServices: {
5
5
  getAmplifyConfig(): Promise<{
@@ -221,6 +221,7 @@ export declare const defaultServices: {
221
221
  handleConfirmSignUp: typeof confirmSignUp;
222
222
  handleForgotPasswordSubmit: typeof confirmResetPassword;
223
223
  handleForgotPassword: typeof resetPassword;
224
+ handleResendSignUpCode: typeof resendSignUpCode;
224
225
  validateCustomSignUp(_: AuthFormData, __: AuthTouchData): Promise<ValidatorResult>;
225
226
  validateFormPassword(formData: AuthFormData, touchData: AuthTouchData, passwordSettings: PasswordSettings): Promise<ValidatorResult>;
226
227
  validateConfirmPassword(formData: AuthFormData, touchData: AuthTouchData): Promise<ValidatorResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {