@aws-amplify/ui 6.8.1 → 6.8.2

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,7 +1,7 @@
1
1
  import { Amplify } from 'aws-amplify';
2
2
  import { getCurrentUser, signIn, signUp, confirmSignIn, confirmSignUp, confirmResetPassword, resetPassword } from 'aws-amplify/auth';
3
- import 'aws-amplify/utils';
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';
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui",
3
- "version": "6.8.1",
3
+ "version": "6.8.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {