diff --git a/.changeset/eleven-books-happen.md b/.changeset/eleven-books-happen.md new file mode 100644 index 00000000000..180424dced8 --- /dev/null +++ b/.changeset/eleven-books-happen.md @@ -0,0 +1,5 @@ +--- +"@aws-amplify/ui-react-liveness": patch +--- + +chore(liveness): remove distance check while connecting diff --git a/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/__tests__/index.test.ts b/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/__tests__/index.test.ts index 97ee6990e2e..7b939cddc2d 100644 --- a/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/__tests__/index.test.ts +++ b/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/__tests__/index.test.ts @@ -414,6 +414,24 @@ describe('Liveness Machine', () => { }); describe('notRecording', () => { + it('should reach waitForSessionInfo', async () => { + await transitionToInitializeLivenessStream(service); + await flushPromises(); // checkFaceDistanceBeforeRecording + + service.send({ + type: 'SET_SESSION_INFO', + data: { + sessionInfo: mockSessionInformation, + }, + }); + jest.advanceTimersToNextTimer(); // initializeLivenessStream + await flushPromises(); // { notRecording: 'waitForSessionInfo' } + + expect(service.state.value).toEqual({ + notRecording: 'waitForSessionInfo', + }); + }); + it('should reach recording state on START_RECORDING', async () => { await transitionToInitializeLivenessStream(service); await flushPromises(); // checkFaceDistanceBeforeRecording diff --git a/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/index.ts b/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/index.ts index 038748c007a..140ff3e1de4 100644 --- a/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/index.ts +++ b/packages/react-liveness/src/components/FaceLivenessDetector/service/machine/index.ts @@ -221,33 +221,9 @@ export const livenessMachine = createMachine( target: '#livenessMachine.recording', cond: 'hasServerSessionInfo', }, - 100: { target: 'detectFaceDistanceDuringLoading' }, + 100: { target: 'waitForSessionInfo' }, }, }, - detectFaceDistanceDuringLoading: { - invoke: { - src: 'detectFaceDistanceWhileLoading', - onDone: { - target: 'checkFaceDistanceDuringLoading', - actions: ['updateFaceDistanceWhileLoading'], - }, - }, - }, - checkFaceDistanceDuringLoading: { - always: [ - { - target: 'failure', - cond: 'hasNotEnoughFaceDistanceBeforeRecording', - }, - { - target: 'waitForSessionInfo', - }, - ], - }, - failure: { - entry: 'sendTimeoutAfterFaceDistanceDelay', - type: 'final', - }, }, }, recording: {