@aws-amplify/ui-react-liveness 3.0.16 → 3.0.17

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.
Files changed (20) hide show
  1. package/dist/esm/components/FaceLivenessDetector/displayText.mjs +2 -0
  2. package/dist/esm/components/FaceLivenessDetector/service/machine/machine.mjs +20 -7
  3. package/dist/esm/components/FaceLivenessDetector/service/types/error.mjs +1 -0
  4. package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/CustomWebSocketFetchHandler.mjs +3 -6
  5. package/dist/esm/components/FaceLivenessDetector/service/utils/eventUtils.mjs +7 -1
  6. package/dist/esm/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.mjs +5 -1
  7. package/dist/esm/components/FaceLivenessDetector/utils/getDisplayText.mjs +3 -1
  8. package/dist/esm/version.mjs +1 -1
  9. package/dist/index.js +37 -14
  10. package/dist/styles.css +1 -1
  11. package/dist/types/components/FaceLivenessDetector/displayText.d.ts +2 -0
  12. package/dist/types/components/FaceLivenessDetector/service/types/error.d.ts +1 -0
  13. package/dist/types/components/FaceLivenessDetector/service/types/machine.d.ts +2 -2
  14. package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/CustomWebSocketFetchHandler.d.ts +1 -0
  15. package/dist/types/components/FaceLivenessDetector/service/utils/eventUtils.d.ts +1 -0
  16. package/dist/types/components/FaceLivenessDetector/service/utils/liveness.d.ts +1 -0
  17. package/dist/types/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.d.ts +2 -0
  18. package/dist/types/components/FaceLivenessDetector/shared/Hint.d.ts +1 -1
  19. package/dist/types/version.d.ts +1 -1
  20. package/package.json +4 -4
@@ -1,5 +1,7 @@
1
1
  const defaultErrorDisplayText = {
2
2
  errorLabelText: 'Error',
3
+ connectionTimeoutHeaderText: 'Connection time out',
4
+ connectionTimeoutMessageText: 'Connection has timed out.',
3
5
  timeoutHeaderText: 'Time out',
4
6
  timeoutMessageText: "Face didn't fit inside oval in time limit. Try again and completely fill the oval with face in it.",
5
7
  faceDistanceHeaderText: 'Forward movement detected',
@@ -7,7 +7,7 @@ import { BlazeFaceFaceDetection } from '../utils/blazefaceFaceDetection.mjs';
7
7
  import { getFaceMatchStateInLivenessOval } from '../utils/getFaceMatchStateInLivenessOval.mjs';
8
8
  import { LivenessStreamProvider } from '../utils/streamProvider.mjs';
9
9
  import { FreshnessColorDisplay } from '../utils/freshnessColorDisplay.mjs';
10
- import { isServerSesssionInformationEvent, isDisconnectionEvent, isValidationExceptionEvent, isInternalServerExceptionEvent, isThrottlingExceptionEvent, isServiceQuotaExceededExceptionEvent, isInvalidSignatureRegionException } from '../utils/eventUtils.mjs';
10
+ import { isServerSesssionInformationEvent, isDisconnectionEvent, isValidationExceptionEvent, isInternalServerExceptionEvent, isThrottlingExceptionEvent, isServiceQuotaExceededExceptionEvent, isInvalidSignatureRegionException, isConnectionTimeoutError } from '../utils/eventUtils.mjs';
11
11
  import { STATIC_VIDEO_CONSTRAINTS } from '../../utils/helpers.mjs';
12
12
  import { WS_CLOSURE_CODE } from '../utils/constants.mjs';
13
13
 
@@ -56,14 +56,20 @@ const responseStreamActor = async (callback) => {
56
56
  }
57
57
  }
58
58
  catch (error) {
59
- let returnedError = error;
60
59
  if (isInvalidSignatureRegionException(error)) {
61
- returnedError = new Error('Invalid region in FaceLivenessDetector or credentials are scoped to the wrong region.');
62
- }
63
- if (returnedError instanceof Error) {
64
60
  callback({
65
61
  type: 'SERVER_ERROR',
66
- data: { error: returnedError },
62
+ data: {
63
+ error: new Error('Invalid region in FaceLivenessDetector or credentials are scoped to the wrong region.'),
64
+ },
65
+ });
66
+ }
67
+ else if (error instanceof Error) {
68
+ callback({
69
+ type: isConnectionTimeoutError(error)
70
+ ? 'CONNECTION_TIMEOUT'
71
+ : 'SERVER_ERROR',
72
+ data: { error },
67
73
  });
68
74
  }
69
75
  }
@@ -141,6 +147,10 @@ const livenessMachine = createMachine({
141
147
  target: 'error',
142
148
  actions: 'updateErrorStateForServer',
143
149
  },
150
+ CONNECTION_TIMEOUT: {
151
+ target: 'error',
152
+ actions: 'updateErrorStateForConnectionTimeout',
153
+ },
144
154
  RUNTIME_ERROR: {
145
155
  target: 'error',
146
156
  },
@@ -298,7 +308,7 @@ const livenessMachine = createMachine({
298
308
  },
299
309
  },
300
310
  },
301
- // If `hasFaceMatchedInOval` is true, then move to `delayBeforeFlash`, which pauses
311
+ // If `hasFaceMatchedInOval` is true, then move to `delayBeforeFlash`, which pauses
302
312
  // for one second to show "Hold still" text before moving to `flashFreshnessColors`.
303
313
  // If not, move back to ovalMatching and re-evaluate match state
304
314
  checkMatch: {
@@ -592,6 +602,9 @@ const livenessMachine = createMachine({
592
602
  },
593
603
  }),
594
604
  resetErrorState: assign({ errorState: (_) => undefined }),
605
+ updateErrorStateForConnectionTimeout: assign({
606
+ errorState: (_) => LivenessErrorState.CONNECTION_TIMEOUT,
607
+ }),
595
608
  updateErrorStateForTimeout: assign({
596
609
  errorState: (_, event) => event.data?.errorState || LivenessErrorState.TIMEOUT,
597
610
  }),
@@ -2,6 +2,7 @@
2
2
  * The liveness error states
3
3
  */
4
4
  const LivenessErrorState = {
5
+ CONNECTION_TIMEOUT: 'CONNECTION_TIMEOUT',
5
6
  TIMEOUT: 'TIMEOUT',
6
7
  RUNTIME_ERROR: 'RUNTIME_ERROR',
7
8
  FRESHNESS_TIMEOUT: 'FRESHNESS_TIMEOUT',
@@ -9,6 +9,7 @@ import { WS_CLOSURE_CODE } from '../constants.mjs';
9
9
  * Because of this the file is not fully typed at this time but we should eventually work on fully typing this file.
10
10
  */
11
11
  const DEFAULT_WS_CONNECTION_TIMEOUT_MS = 2000;
12
+ const WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE = 'Websocket connection timeout';
12
13
  const isWebSocketRequest = (request) => request.protocol === 'ws:' || request.protocol === 'wss:';
13
14
  const isReadableStream = (payload) => typeof ReadableStream === 'function' && payload instanceof ReadableStream;
14
15
  /**
@@ -108,11 +109,7 @@ class CustomWebSocketFetchHandler {
108
109
  return new Promise((resolve, reject) => {
109
110
  const timeout = setTimeout(() => {
110
111
  this.removeNotUsableSockets(socket.url);
111
- reject({
112
- $metadata: {
113
- httpStatusCode: 500,
114
- },
115
- });
112
+ reject(new Error(WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE));
116
113
  }, connectionTimeout);
117
114
  socket.onopen = () => {
118
115
  clearTimeout(timeout);
@@ -196,4 +193,4 @@ class CustomWebSocketFetchHandler {
196
193
  }
197
194
  }
198
195
 
199
- export { CustomWebSocketFetchHandler };
196
+ export { CustomWebSocketFetchHandler, WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE };
@@ -1,7 +1,13 @@
1
+ import { WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE } from './createStreamingClient/CustomWebSocketFetchHandler.mjs';
2
+
1
3
  const isServerSesssionInformationEvent = (value) => {
2
4
  return !!value
3
5
  ?.ServerSessionInformationEvent;
4
6
  };
7
+ const isConnectionTimeoutError = (error) => {
8
+ const { message } = error;
9
+ return message.includes(WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE);
10
+ };
5
11
  const isDisconnectionEvent = (value) => {
6
12
  return !!value
7
13
  ?.DisconnectionEvent;
@@ -27,4 +33,4 @@ const isInvalidSignatureRegionException = (error) => {
27
33
  return (name === 'InvalidSignatureException' && message.includes('valid region'));
28
34
  };
29
35
 
30
- export { isDisconnectionEvent, isInternalServerExceptionEvent, isInvalidSignatureRegionException, isServerSesssionInformationEvent, isServiceQuotaExceededExceptionEvent, isThrottlingExceptionEvent, isValidationExceptionEvent };
36
+ export { isConnectionTimeoutError, isDisconnectionEvent, isInternalServerExceptionEvent, isInvalidSignatureRegionException, isServerSesssionInformationEvent, isServiceQuotaExceededExceptionEvent, isThrottlingExceptionEvent, isValidationExceptionEvent };
@@ -19,10 +19,14 @@ import { LivenessClassNames } from '../types/classNames.mjs';
19
19
 
20
20
  const renderToastErrorModal = (props) => {
21
21
  const { error: errorState, displayText } = props;
22
- const { errorLabelText, timeoutHeaderText, timeoutMessageText, faceDistanceHeaderText, faceDistanceMessageText, multipleFacesHeaderText, multipleFacesMessageText, clientHeaderText, clientMessageText, serverHeaderText, serverMessageText, } = displayText;
22
+ const { connectionTimeoutHeaderText, connectionTimeoutMessageText, errorLabelText, timeoutHeaderText, timeoutMessageText, faceDistanceHeaderText, faceDistanceMessageText, multipleFacesHeaderText, multipleFacesMessageText, clientHeaderText, clientMessageText, serverHeaderText, serverMessageText, } = displayText;
23
23
  let heading;
24
24
  let message;
25
25
  switch (errorState) {
26
+ case LivenessErrorState.CONNECTION_TIMEOUT:
27
+ heading = connectionTimeoutHeaderText;
28
+ message = connectionTimeoutMessageText;
29
+ break;
26
30
  case LivenessErrorState.TIMEOUT:
27
31
  heading = timeoutHeaderText;
28
32
  message = timeoutMessageText;
@@ -12,7 +12,7 @@ function getDisplayText(overrideDisplayText) {
12
12
  ...defaultLivenessDisplayText,
13
13
  ...overrideDisplayText,
14
14
  };
15
- const { a11yVideoLabelText, cameraMinSpecificationsHeadingText, cameraMinSpecificationsMessageText, cameraNotFoundHeadingText, cameraNotFoundMessageText, cancelLivenessCheckText, clientHeaderText, clientMessageText, errorLabelText, hintCanNotIdentifyText, hintCenterFaceText, hintCenterFaceInstructionText, hintFaceOffCenterText, hintConnectingText, hintFaceDetectedText, hintHoldFaceForFreshnessText, hintIlluminationNormalText, hintIlluminationTooBrightText, hintIlluminationTooDarkText, hintMoveFaceFrontOfCameraText, hintTooManyFacesText, hintTooCloseText, hintTooFarText, hintVerifyingText, hintCheckCompleteText, hintMatchIndicatorText, faceDistanceHeaderText, faceDistanceMessageText, goodFitCaptionText, goodFitAltText, landscapeHeaderText, landscapeMessageText, multipleFacesHeaderText, multipleFacesMessageText, photosensitivityWarningBodyText, photosensitivityWarningHeadingText, photosensitivityWarningInfoText, photosensitivityWarningLabelText, photosensitivyWarningBodyText, photosensitivyWarningHeadingText, photosensitivyWarningInfoText, photosensitivyWarningLabelText, portraitMessageText, retryCameraPermissionsText, recordingIndicatorText, serverHeaderText, serverMessageText, startScreenBeginCheckText, timeoutHeaderText, timeoutMessageText, tooFarCaptionText, tooFarAltText, tryAgainText, waitingCameraPermissionText, } = displayText;
15
+ const { a11yVideoLabelText, cameraMinSpecificationsHeadingText, cameraMinSpecificationsMessageText, cameraNotFoundHeadingText, cameraNotFoundMessageText, cancelLivenessCheckText, connectionTimeoutHeaderText, connectionTimeoutMessageText, clientHeaderText, clientMessageText, errorLabelText, hintCanNotIdentifyText, hintCenterFaceText, hintCenterFaceInstructionText, hintFaceOffCenterText, hintConnectingText, hintFaceDetectedText, hintHoldFaceForFreshnessText, hintIlluminationNormalText, hintIlluminationTooBrightText, hintIlluminationTooDarkText, hintMoveFaceFrontOfCameraText, hintTooManyFacesText, hintTooCloseText, hintTooFarText, hintVerifyingText, hintCheckCompleteText, hintMatchIndicatorText, faceDistanceHeaderText, faceDistanceMessageText, goodFitCaptionText, goodFitAltText, landscapeHeaderText, landscapeMessageText, multipleFacesHeaderText, multipleFacesMessageText, photosensitivityWarningBodyText, photosensitivityWarningHeadingText, photosensitivityWarningInfoText, photosensitivityWarningLabelText, photosensitivyWarningBodyText, photosensitivyWarningHeadingText, photosensitivyWarningInfoText, photosensitivyWarningLabelText, portraitMessageText, retryCameraPermissionsText, recordingIndicatorText, serverHeaderText, serverMessageText, startScreenBeginCheckText, timeoutHeaderText, timeoutMessageText, tooFarCaptionText, tooFarAltText, tryAgainText, waitingCameraPermissionText, } = displayText;
16
16
  const hintDisplayText = {
17
17
  hintMoveFaceFrontOfCameraText,
18
18
  hintTooManyFacesText,
@@ -61,6 +61,8 @@ function getDisplayText(overrideDisplayText) {
61
61
  recordingIndicatorText,
62
62
  };
63
63
  const errorDisplayText = {
64
+ connectionTimeoutHeaderText,
65
+ connectionTimeoutMessageText,
64
66
  errorLabelText,
65
67
  timeoutHeaderText,
66
68
  timeoutMessageText,
@@ -1,3 +1,3 @@
1
- const VERSION = '3.0.16';
1
+ const VERSION = '3.0.17';
2
2
 
3
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -85,6 +85,7 @@ var FaceMatchState;
85
85
  * The liveness error states
86
86
  */
87
87
  const LivenessErrorState = {
88
+ CONNECTION_TIMEOUT: 'CONNECTION_TIMEOUT',
88
89
  TIMEOUT: 'TIMEOUT',
89
90
  RUNTIME_ERROR: 'RUNTIME_ERROR',
90
91
  FRESHNESS_TIMEOUT: 'FRESHNESS_TIMEOUT',
@@ -791,7 +792,7 @@ function getFaceMatchStateInLivenessOval({ face, ovalDetails, initialFaceInterse
791
792
  return { faceMatchState, faceMatchPercentage };
792
793
  }
793
794
 
794
- const VERSION = '3.0.16';
795
+ const VERSION = '3.0.17';
795
796
 
796
797
  const BASE_USER_AGENT = `ui-react-liveness/${VERSION}`;
797
798
  const getLivenessUserAgent = () => {
@@ -803,6 +804,7 @@ const getLivenessUserAgent = () => {
803
804
  * Because of this the file is not fully typed at this time but we should eventually work on fully typing this file.
804
805
  */
805
806
  const DEFAULT_WS_CONNECTION_TIMEOUT_MS = 2000;
807
+ const WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE = 'Websocket connection timeout';
806
808
  const isWebSocketRequest = (request) => request.protocol === 'ws:' || request.protocol === 'wss:';
807
809
  const isReadableStream = (payload) => typeof ReadableStream === 'function' && payload instanceof ReadableStream;
808
810
  /**
@@ -902,11 +904,7 @@ class CustomWebSocketFetchHandler {
902
904
  return new Promise((resolve, reject) => {
903
905
  const timeout = setTimeout(() => {
904
906
  this.removeNotUsableSockets(socket.url);
905
- reject({
906
- $metadata: {
907
- httpStatusCode: 500,
908
- },
909
- });
907
+ reject(new Error(WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE));
910
908
  }, connectionTimeout);
911
909
  socket.onopen = () => {
912
910
  clearTimeout(timeout);
@@ -1309,6 +1307,10 @@ const isServerSesssionInformationEvent = (value) => {
1309
1307
  return !!value
1310
1308
  ?.ServerSessionInformationEvent;
1311
1309
  };
1310
+ const isConnectionTimeoutError = (error) => {
1311
+ const { message } = error;
1312
+ return message.includes(WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE);
1313
+ };
1312
1314
  const isDisconnectionEvent = (value) => {
1313
1315
  return !!value
1314
1316
  ?.DisconnectionEvent;
@@ -1392,14 +1394,20 @@ const responseStreamActor = async (callback) => {
1392
1394
  }
1393
1395
  }
1394
1396
  catch (error) {
1395
- let returnedError = error;
1396
1397
  if (isInvalidSignatureRegionException(error)) {
1397
- returnedError = new Error('Invalid region in FaceLivenessDetector or credentials are scoped to the wrong region.');
1398
- }
1399
- if (returnedError instanceof Error) {
1400
1398
  callback({
1401
1399
  type: 'SERVER_ERROR',
1402
- data: { error: returnedError },
1400
+ data: {
1401
+ error: new Error('Invalid region in FaceLivenessDetector or credentials are scoped to the wrong region.'),
1402
+ },
1403
+ });
1404
+ }
1405
+ else if (error instanceof Error) {
1406
+ callback({
1407
+ type: isConnectionTimeoutError(error)
1408
+ ? 'CONNECTION_TIMEOUT'
1409
+ : 'SERVER_ERROR',
1410
+ data: { error },
1403
1411
  });
1404
1412
  }
1405
1413
  }
@@ -1477,6 +1485,10 @@ const livenessMachine = xstate.createMachine({
1477
1485
  target: 'error',
1478
1486
  actions: 'updateErrorStateForServer',
1479
1487
  },
1488
+ CONNECTION_TIMEOUT: {
1489
+ target: 'error',
1490
+ actions: 'updateErrorStateForConnectionTimeout',
1491
+ },
1480
1492
  RUNTIME_ERROR: {
1481
1493
  target: 'error',
1482
1494
  },
@@ -1634,7 +1646,7 @@ const livenessMachine = xstate.createMachine({
1634
1646
  },
1635
1647
  },
1636
1648
  },
1637
- // If `hasFaceMatchedInOval` is true, then move to `delayBeforeFlash`, which pauses
1649
+ // If `hasFaceMatchedInOval` is true, then move to `delayBeforeFlash`, which pauses
1638
1650
  // for one second to show "Hold still" text before moving to `flashFreshnessColors`.
1639
1651
  // If not, move back to ovalMatching and re-evaluate match state
1640
1652
  checkMatch: {
@@ -1928,6 +1940,9 @@ const livenessMachine = xstate.createMachine({
1928
1940
  },
1929
1941
  }),
1930
1942
  resetErrorState: xstate.assign({ errorState: (_) => undefined }),
1943
+ updateErrorStateForConnectionTimeout: xstate.assign({
1944
+ errorState: (_) => LivenessErrorState.CONNECTION_TIMEOUT,
1945
+ }),
1931
1946
  updateErrorStateForTimeout: xstate.assign({
1932
1947
  errorState: (_, event) => event.data?.errorState || LivenessErrorState.TIMEOUT,
1933
1948
  }),
@@ -2722,6 +2737,8 @@ const RecordingIcon = ({ children }) => {
2722
2737
 
2723
2738
  const defaultErrorDisplayText = {
2724
2739
  errorLabelText: 'Error',
2740
+ connectionTimeoutHeaderText: 'Connection time out',
2741
+ connectionTimeoutMessageText: 'Connection has timed out.',
2725
2742
  timeoutHeaderText: 'Time out',
2726
2743
  timeoutMessageText: "Face didn't fit inside oval in time limit. Try again and completely fill the oval with face in it.",
2727
2744
  faceDistanceHeaderText: 'Forward movement detected',
@@ -2782,10 +2799,14 @@ const defaultLivenessDisplayText = {
2782
2799
 
2783
2800
  const renderToastErrorModal = (props) => {
2784
2801
  const { error: errorState, displayText } = props;
2785
- const { errorLabelText, timeoutHeaderText, timeoutMessageText, faceDistanceHeaderText, faceDistanceMessageText, multipleFacesHeaderText, multipleFacesMessageText, clientHeaderText, clientMessageText, serverHeaderText, serverMessageText, } = displayText;
2802
+ const { connectionTimeoutHeaderText, connectionTimeoutMessageText, errorLabelText, timeoutHeaderText, timeoutMessageText, faceDistanceHeaderText, faceDistanceMessageText, multipleFacesHeaderText, multipleFacesMessageText, clientHeaderText, clientMessageText, serverHeaderText, serverMessageText, } = displayText;
2786
2803
  let heading;
2787
2804
  let message;
2788
2805
  switch (errorState) {
2806
+ case LivenessErrorState.CONNECTION_TIMEOUT:
2807
+ heading = connectionTimeoutHeaderText;
2808
+ message = connectionTimeoutMessageText;
2809
+ break;
2789
2810
  case LivenessErrorState.TIMEOUT:
2790
2811
  heading = timeoutHeaderText;
2791
2812
  message = timeoutMessageText;
@@ -3191,7 +3212,7 @@ function getDisplayText(overrideDisplayText) {
3191
3212
  ...defaultLivenessDisplayText,
3192
3213
  ...overrideDisplayText,
3193
3214
  };
3194
- const { a11yVideoLabelText, cameraMinSpecificationsHeadingText, cameraMinSpecificationsMessageText, cameraNotFoundHeadingText, cameraNotFoundMessageText, cancelLivenessCheckText, clientHeaderText, clientMessageText, errorLabelText, hintCanNotIdentifyText, hintCenterFaceText, hintCenterFaceInstructionText, hintFaceOffCenterText, hintConnectingText, hintFaceDetectedText, hintHoldFaceForFreshnessText, hintIlluminationNormalText, hintIlluminationTooBrightText, hintIlluminationTooDarkText, hintMoveFaceFrontOfCameraText, hintTooManyFacesText, hintTooCloseText, hintTooFarText, hintVerifyingText, hintCheckCompleteText, hintMatchIndicatorText, faceDistanceHeaderText, faceDistanceMessageText, goodFitCaptionText, goodFitAltText, landscapeHeaderText, landscapeMessageText, multipleFacesHeaderText, multipleFacesMessageText, photosensitivityWarningBodyText, photosensitivityWarningHeadingText, photosensitivityWarningInfoText, photosensitivityWarningLabelText, photosensitivyWarningBodyText, photosensitivyWarningHeadingText, photosensitivyWarningInfoText, photosensitivyWarningLabelText, portraitMessageText, retryCameraPermissionsText, recordingIndicatorText, serverHeaderText, serverMessageText, startScreenBeginCheckText, timeoutHeaderText, timeoutMessageText, tooFarCaptionText, tooFarAltText, tryAgainText, waitingCameraPermissionText, } = displayText;
3215
+ const { a11yVideoLabelText, cameraMinSpecificationsHeadingText, cameraMinSpecificationsMessageText, cameraNotFoundHeadingText, cameraNotFoundMessageText, cancelLivenessCheckText, connectionTimeoutHeaderText, connectionTimeoutMessageText, clientHeaderText, clientMessageText, errorLabelText, hintCanNotIdentifyText, hintCenterFaceText, hintCenterFaceInstructionText, hintFaceOffCenterText, hintConnectingText, hintFaceDetectedText, hintHoldFaceForFreshnessText, hintIlluminationNormalText, hintIlluminationTooBrightText, hintIlluminationTooDarkText, hintMoveFaceFrontOfCameraText, hintTooManyFacesText, hintTooCloseText, hintTooFarText, hintVerifyingText, hintCheckCompleteText, hintMatchIndicatorText, faceDistanceHeaderText, faceDistanceMessageText, goodFitCaptionText, goodFitAltText, landscapeHeaderText, landscapeMessageText, multipleFacesHeaderText, multipleFacesMessageText, photosensitivityWarningBodyText, photosensitivityWarningHeadingText, photosensitivityWarningInfoText, photosensitivityWarningLabelText, photosensitivyWarningBodyText, photosensitivyWarningHeadingText, photosensitivyWarningInfoText, photosensitivyWarningLabelText, portraitMessageText, retryCameraPermissionsText, recordingIndicatorText, serverHeaderText, serverMessageText, startScreenBeginCheckText, timeoutHeaderText, timeoutMessageText, tooFarCaptionText, tooFarAltText, tryAgainText, waitingCameraPermissionText, } = displayText;
3195
3216
  const hintDisplayText = {
3196
3217
  hintMoveFaceFrontOfCameraText,
3197
3218
  hintTooManyFacesText,
@@ -3240,6 +3261,8 @@ function getDisplayText(overrideDisplayText) {
3240
3261
  recordingIndicatorText,
3241
3262
  };
3242
3263
  const errorDisplayText = {
3264
+ connectionTimeoutHeaderText,
3265
+ connectionTimeoutMessageText,
3243
3266
  errorLabelText,
3244
3267
  timeoutHeaderText,
3245
3268
  timeoutMessageText,
package/dist/styles.css CHANGED
@@ -718,7 +718,7 @@
718
718
  --amplify-components-link-focus-color: var(--amplify-colors-font-focus);
719
719
  --amplify-components-link-hover-color: var(--amplify-colors-font-hover);
720
720
  --amplify-components-link-visited-color: var(--amplify-colors-font-interactive);
721
- --amplify-components-liveness-camera-module-background-color: var(--amplify-colors-black);
721
+ --amplify-components-liveness-camera-module-background-color: var(--amplify-colors-background-primary);
722
722
  --amplify-components-loader-width: var(--amplify-font-sizes-medium);
723
723
  --amplify-components-loader-height: var(--amplify-font-sizes-medium);
724
724
  --amplify-components-loader-font-size: var(--amplify-font-sizes-xs);
@@ -60,6 +60,8 @@ export type StreamDisplayText = {
60
60
  };
61
61
  export declare const defaultErrorDisplayText: {
62
62
  errorLabelText: string;
63
+ connectionTimeoutHeaderText: string;
64
+ connectionTimeoutMessageText: string;
63
65
  timeoutHeaderText: string;
64
66
  timeoutMessageText: string;
65
67
  faceDistanceHeaderText: string;
@@ -2,6 +2,7 @@
2
2
  * The liveness error states
3
3
  */
4
4
  export declare const LivenessErrorState: {
5
+ readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
5
6
  readonly TIMEOUT: "TIMEOUT";
6
7
  readonly RUNTIME_ERROR: "RUNTIME_ERROR";
7
8
  readonly FRESHNESS_TIMEOUT: "FRESHNESS_TIMEOUT";
@@ -53,7 +53,7 @@ export interface LivenessContext {
53
53
  shouldDisconnect?: boolean;
54
54
  videoAssociatedParams?: VideoAssociatedParams;
55
55
  }
56
- export type LivenessEventTypes = 'BEGIN' | 'START_RECORDING' | 'TIMEOUT' | 'ERROR' | 'CANCEL' | 'SET_SESSION_INFO' | 'DISCONNECT_EVENT' | 'SET_DOM_AND_CAMERA_DETAILS' | 'UPDATE_DEVICE_AND_STREAM' | 'SERVER_ERROR' | 'RUNTIME_ERROR' | 'RETRY_CAMERA_CHECK' | 'MOBILE_LANDSCAPE_WARNING';
56
+ export type LivenessEventTypes = 'BEGIN' | 'CONNECTION_TIMEOUT' | 'START_RECORDING' | 'TIMEOUT' | 'ERROR' | 'CANCEL' | 'SET_SESSION_INFO' | 'DISCONNECT_EVENT' | 'SET_DOM_AND_CAMERA_DETAILS' | 'UPDATE_DEVICE_AND_STREAM' | 'SERVER_ERROR' | 'RUNTIME_ERROR' | 'RETRY_CAMERA_CHECK' | 'MOBILE_LANDSCAPE_WARNING';
57
57
  export type LivenessEventData = Record<PropertyKey, any>;
58
58
  export interface LivenessEvent {
59
59
  type: LivenessEventTypes;
@@ -66,7 +66,7 @@ export interface StreamActorCallback {
66
66
  type: 'DISCONNECT_EVENT';
67
67
  }): void;
68
68
  (params: {
69
- type: 'SERVER_ERROR';
69
+ type: 'SERVER_ERROR' | 'CONNECTION_TIMEOUT';
70
70
  data: {
71
71
  error: Error;
72
72
  };
@@ -1,5 +1,6 @@
1
1
  import { HttpRequest, HttpResponse } from '@smithy/protocol-http';
2
2
  import { Provider, RequestHandler, RequestHandlerMetadata } from '@smithy/types';
3
+ export declare const WEBSOCKET_CONNECTION_TIMEOUT_MESSAGE = "Websocket connection timeout";
3
4
  export interface WebSocketFetchHandlerOptions {
4
5
  /**
5
6
  * The maximum time in milliseconds that the connection phase of a request
@@ -1,5 +1,6 @@
1
1
  import { LivenessResponseStream } from '@aws-sdk/client-rekognitionstreaming';
2
2
  export declare const isServerSesssionInformationEvent: (value: unknown) => value is LivenessResponseStream.ServerSessionInformationEventMember;
3
+ export declare const isConnectionTimeoutError: (error: unknown) => error is Error;
3
4
  export declare const isDisconnectionEvent: (value: unknown) => value is LivenessResponseStream.DisconnectionEventMember;
4
5
  export declare const isValidationExceptionEvent: (value: unknown) => value is LivenessResponseStream.ValidationExceptionMember;
5
6
  export declare const isInternalServerExceptionEvent: (value: unknown) => value is LivenessResponseStream.InternalServerExceptionMember;
@@ -61,6 +61,7 @@ export declare function estimateIllumination(videoEl: HTMLVideoElement): Illumin
61
61
  */
62
62
  export declare function isCameraDeviceVirtual(device: MediaDeviceInfo): boolean;
63
63
  export declare const LivenessErrorStateStringMap: {
64
+ CONNECTION_TIMEOUT: string;
64
65
  RUNTIME_ERROR: string;
65
66
  SERVER_ERROR: string;
66
67
  TIMEOUT: string;
@@ -13,6 +13,8 @@ export declare const renderErrorModal: ({ errorState, overrideErrorDisplayText,
13
13
  errorState: ErrorState;
14
14
  overrideErrorDisplayText?: Partial<{
15
15
  errorLabelText: string;
16
+ connectionTimeoutHeaderText: string;
17
+ connectionTimeoutMessageText: string;
16
18
  timeoutHeaderText: string;
17
19
  timeoutMessageText: string;
18
20
  faceDistanceHeaderText: string;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IlluminationState, FaceMatchState } from '../service';
3
3
  import { HintDisplayText } from '../displayText';
4
- export declare const selectErrorState: import("../hooks").LivenessSelectorFn<"TIMEOUT" | "RUNTIME_ERROR" | "FRESHNESS_TIMEOUT" | "SERVER_ERROR" | "CAMERA_FRAMERATE_ERROR" | "CAMERA_ACCESS_ERROR" | "FACE_DISTANCE_ERROR" | "MOBILE_LANDSCAPE_ERROR" | "MULTIPLE_FACES_ERROR" | undefined>;
4
+ export declare const selectErrorState: import("../hooks").LivenessSelectorFn<"CONNECTION_TIMEOUT" | "TIMEOUT" | "RUNTIME_ERROR" | "FRESHNESS_TIMEOUT" | "SERVER_ERROR" | "CAMERA_FRAMERATE_ERROR" | "CAMERA_ACCESS_ERROR" | "FACE_DISTANCE_ERROR" | "MOBILE_LANDSCAPE_ERROR" | "MULTIPLE_FACES_ERROR" | undefined>;
5
5
  export declare const selectFaceMatchState: import("../hooks").LivenessSelectorFn<FaceMatchState | undefined>;
6
6
  export declare const selectIlluminationState: import("../hooks").LivenessSelectorFn<IlluminationState | undefined>;
7
7
  export declare const selectIsFaceFarEnoughBeforeRecording: import("../hooks").LivenessSelectorFn<boolean | undefined>;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.16";
1
+ export declare const VERSION = "3.0.17";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-liveness",
3
- "version": "3.0.16",
3
+ "version": "3.0.17",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -42,13 +42,13 @@
42
42
  "typecheck": "tsc --noEmit"
43
43
  },
44
44
  "peerDependencies": {
45
- "aws-amplify": "^6.0.2",
45
+ "aws-amplify": "^6.0.26",
46
46
  "react": "^16.14.0 || ^17.0 || ^18.0",
47
47
  "react-dom": "^16.14.0 || ^17.0 || ^18.0"
48
48
  },
49
49
  "dependencies": {
50
- "@aws-amplify/ui": "6.0.12",
51
- "@aws-amplify/ui-react": "6.1.6",
50
+ "@aws-amplify/ui": "6.0.13",
51
+ "@aws-amplify/ui-react": "6.1.7",
52
52
  "@aws-sdk/client-rekognitionstreaming": "3.398.0",
53
53
  "@aws-sdk/util-format-url": "^3.410.0",
54
54
  "@smithy/eventstream-serde-browser": "^2.0.4",