@aws-amplify/ui-react-liveness 0.0.0-next-43a297e-20230410194306
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/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/esm/components/FaceLivenessDetector/FaceLivenessDetector.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCheck.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/StartLiveness/StartLiveness.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/StartLiveness/helpers.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/displayText.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/hooks/useLivenessActor.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/hooks/useLivenessSelector.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/hooks/useMediaStreamInVideo.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/providers/FaceLivenessDetectorProvider.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/machine/index.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/types/faceDetection.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/types/liveness.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/blazefaceFaceDetection.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/constants.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/eventUtils.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/freshnessColorDisplay.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/liveness.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/streamProvider.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/support.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/videoRecorder.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/CancelButton.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/DefaultStartScreenComponents.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/GoodFitIllustration.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/Hint.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/LandscapeErrorModal.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/LivenessIconWithPopover.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/MatchIndicator.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/Overlay.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/RecordingIcon.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/StartScreenFigure.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/Toast.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/shared/TooFarIllustration.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/types/classNames.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/utils/device.mjs +1 -0
- package/dist/esm/components/FaceLivenessDetector/utils/getDisplayText.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.mjs +1 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +5028 -0
- package/dist/styles.js +2 -0
- package/dist/types/components/FaceLivenessDetector/FaceLivenessDetector.d.ts +12 -0
- package/dist/types/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.d.ts +18 -0
- package/dist/types/components/FaceLivenessDetector/LivenessCheck/LivenessCheck.d.ts +15 -0
- package/dist/types/components/FaceLivenessDetector/LivenessCheck/index.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/StartLiveness/StartLiveness.d.ts +9 -0
- package/dist/types/components/FaceLivenessDetector/StartLiveness/helpers.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/StartLiveness/index.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/displayText.d.ts +62 -0
- package/dist/types/components/FaceLivenessDetector/hooks/index.d.ts +3 -0
- package/dist/types/components/FaceLivenessDetector/hooks/useLivenessActor.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/hooks/useLivenessSelector.d.ts +4 -0
- package/dist/types/components/FaceLivenessDetector/hooks/useMediaStreamInVideo.d.ts +7 -0
- package/dist/types/components/FaceLivenessDetector/index.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/providers/FaceLivenessDetectorProvider.d.ts +12 -0
- package/dist/types/components/FaceLivenessDetector/providers/index.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/service/index.d.ts +3 -0
- package/dist/types/components/FaceLivenessDetector/service/machine/index.d.ts +6 -0
- package/dist/types/components/FaceLivenessDetector/service/types/faceDetection.d.ts +36 -0
- package/dist/types/components/FaceLivenessDetector/service/types/index.d.ts +3 -0
- package/dist/types/components/FaceLivenessDetector/service/types/liveness.d.ts +98 -0
- package/dist/types/components/FaceLivenessDetector/service/types/machine.d.ts +102 -0
- package/dist/types/components/FaceLivenessDetector/service/types/service.d.ts +74 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/blazefaceFaceDetection.d.ts +18 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/constants.d.ts +3 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/eventUtils.d.ts +12 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/freshnessColorDisplay.d.ts +22 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/index.d.ts +6 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/liveness.d.ts +101 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/streamProvider.d.ts +37 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/support.d.ts +8 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/videoRecorder.d.ts +30 -0
- package/dist/types/components/FaceLivenessDetector/shared/CancelButton.d.ts +5 -0
- package/dist/types/components/FaceLivenessDetector/shared/DefaultStartScreenComponents.d.ts +27 -0
- package/dist/types/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.d.ts +29 -0
- package/dist/types/components/FaceLivenessDetector/shared/GoodFitIllustration.d.ts +7 -0
- package/dist/types/components/FaceLivenessDetector/shared/Hint.d.ts +12 -0
- package/dist/types/components/FaceLivenessDetector/shared/LandscapeErrorModal.d.ts +10 -0
- package/dist/types/components/FaceLivenessDetector/shared/LivenessIconWithPopover.d.ts +9 -0
- package/dist/types/components/FaceLivenessDetector/shared/MatchIndicator.d.ts +8 -0
- package/dist/types/components/FaceLivenessDetector/shared/Overlay.d.ts +11 -0
- package/dist/types/components/FaceLivenessDetector/shared/RecordingIcon.d.ts +6 -0
- package/dist/types/components/FaceLivenessDetector/shared/StartScreenFigure.d.ts +8 -0
- package/dist/types/components/FaceLivenessDetector/shared/Toast.d.ts +9 -0
- package/dist/types/components/FaceLivenessDetector/shared/TooFarIllustration.d.ts +7 -0
- package/dist/types/components/FaceLivenessDetector/shared/index.d.ts +8 -0
- package/dist/types/components/FaceLivenessDetector/types/classNames.d.ts +27 -0
- package/dist/types/components/FaceLivenessDetector/utils/device.d.ts +10 -0
- package/dist/types/components/FaceLivenessDetector/utils/getDisplayText.d.ts +17 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/version.d.ts +1 -0
- package/package.json +101 -0
package/dist/styles.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FaceLivenessDetectorProps as FaceLivenessDetectorPropsFromUi } from './service';
|
|
3
|
+
import { StartScreenComponents } from './shared/DefaultStartScreenComponents';
|
|
4
|
+
import { LivenessDisplayText } from './displayText';
|
|
5
|
+
import { CheckScreenComponents } from './shared/FaceLivenessErrorModal';
|
|
6
|
+
declare type FaceLivenessDetectorComponents = StartScreenComponents & CheckScreenComponents;
|
|
7
|
+
export interface FaceLivenessDetectorProps extends FaceLivenessDetectorPropsFromUi {
|
|
8
|
+
components?: FaceLivenessDetectorComponents;
|
|
9
|
+
displayText?: LivenessDisplayText;
|
|
10
|
+
}
|
|
11
|
+
export default function FaceLivenessDetector(props: FaceLivenessDetectorProps): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FaceMatchState } from '../service';
|
|
3
|
+
import { ErrorDisplayText, HintDisplayText, StreamDisplayText } from '../displayText';
|
|
4
|
+
import { CheckScreenComponents } from '../shared/FaceLivenessErrorModal';
|
|
5
|
+
export declare const selectVideoConstraints: import("../hooks").LivenessSelectorFn<MediaTrackConstraints>;
|
|
6
|
+
export declare const selectVideoStream: import("../hooks").LivenessSelectorFn<MediaStream>;
|
|
7
|
+
export declare const selectFaceMatchPercentage: import("../hooks").LivenessSelectorFn<number>;
|
|
8
|
+
export declare const selectFaceMatchState: import("../hooks").LivenessSelectorFn<FaceMatchState>;
|
|
9
|
+
export interface LivenessCameraModuleProps {
|
|
10
|
+
isMobileScreen: boolean;
|
|
11
|
+
isRecordingStopped: boolean;
|
|
12
|
+
streamDisplayText: Required<StreamDisplayText>;
|
|
13
|
+
hintDisplayText: Required<HintDisplayText>;
|
|
14
|
+
errorDisplayText: Required<ErrorDisplayText>;
|
|
15
|
+
components?: CheckScreenComponents;
|
|
16
|
+
testId?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const LivenessCameraModule: (props: LivenessCameraModuleProps) => JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { LivenessErrorState } from '../service';
|
|
3
|
+
import { HintDisplayText, CameraDisplayText, StreamDisplayText, ErrorDisplayText } from '../displayText';
|
|
4
|
+
import { CheckScreenComponents } from '../shared/FaceLivenessErrorModal';
|
|
5
|
+
export declare const selectErrorState: import("../hooks").LivenessSelectorFn<LivenessErrorState | null>;
|
|
6
|
+
export declare const selectIsRecordingStopped: import("../hooks").LivenessSelectorFn<boolean>;
|
|
7
|
+
interface LivenessCheckProps {
|
|
8
|
+
hintDisplayText: Required<HintDisplayText>;
|
|
9
|
+
cameraDisplayText: Required<CameraDisplayText>;
|
|
10
|
+
streamDisplayText: Required<StreamDisplayText>;
|
|
11
|
+
errorDisplayText: Required<ErrorDisplayText>;
|
|
12
|
+
components?: CheckScreenComponents;
|
|
13
|
+
}
|
|
14
|
+
export declare const LivenessCheck: React.FC<LivenessCheckProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LivenessCheck';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InstructionDisplayText } from '../displayText';
|
|
3
|
+
import { StartScreenComponents } from '../shared/DefaultStartScreenComponents';
|
|
4
|
+
export interface StartLivenessProps {
|
|
5
|
+
beginLivenessCheck: () => void;
|
|
6
|
+
components?: StartScreenComponents;
|
|
7
|
+
instructionDisplayText: Required<InstructionDisplayText>;
|
|
8
|
+
}
|
|
9
|
+
export declare function StartLiveness(props: StartLivenessProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getVideoConstraints(): MediaTrackConstraints | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StartLiveness';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare type HintDisplayText = {
|
|
2
|
+
hintMoveFaceFrontOfCameraText?: string;
|
|
3
|
+
hintTooManyFacesText?: string;
|
|
4
|
+
hintFaceDetectedText?: string;
|
|
5
|
+
hintCanNotIdentifyText?: string;
|
|
6
|
+
hintTooCloseText?: string;
|
|
7
|
+
hintTooFarText?: string;
|
|
8
|
+
hintHoldFacePositionCountdownText?: string;
|
|
9
|
+
hintConnectingText?: string;
|
|
10
|
+
hintVerifyingText?: string;
|
|
11
|
+
hintIlluminationTooBrightText?: string;
|
|
12
|
+
hintIlluminationTooDarkText?: string;
|
|
13
|
+
hintIlluminationNormalText?: string;
|
|
14
|
+
hintHoldFaceForFreshnessText?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type CameraDisplayText = {
|
|
17
|
+
cameraMinSpecificationsHeadingText?: string;
|
|
18
|
+
cameraMinSpecificationsMessageText?: string;
|
|
19
|
+
cameraNotFoundHeadingText?: string;
|
|
20
|
+
cameraNotFoundMessageText?: string;
|
|
21
|
+
retryCameraPermissionsText?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type InstructionDisplayText = {
|
|
24
|
+
instructionsHeaderHeadingText?: string;
|
|
25
|
+
instructionsHeaderBodyText?: string;
|
|
26
|
+
instructionsBeginCheckText?: string;
|
|
27
|
+
photosensitivyWarningHeadingText?: string;
|
|
28
|
+
photosensitivyWarningBodyText?: string;
|
|
29
|
+
photosensitivyWarningInfoText?: string;
|
|
30
|
+
instructionListHeadingText?: string;
|
|
31
|
+
goodFitCaptionText?: string;
|
|
32
|
+
goodFitAltText?: string;
|
|
33
|
+
tooFarCaptionText?: string;
|
|
34
|
+
tooFarAltText?: string;
|
|
35
|
+
instructionListStepOneText?: string;
|
|
36
|
+
instructionListStepTwoText?: string;
|
|
37
|
+
instructionListStepThreeText?: string;
|
|
38
|
+
instructionListStepFourText?: string;
|
|
39
|
+
};
|
|
40
|
+
export declare type StreamDisplayText = {
|
|
41
|
+
recordingIndicatorText?: string;
|
|
42
|
+
cancelLivenessCheckText?: string;
|
|
43
|
+
};
|
|
44
|
+
export declare const defaultErrorDisplayText: {
|
|
45
|
+
timeoutHeaderText: string;
|
|
46
|
+
timeoutMessageText: string;
|
|
47
|
+
faceDistanceHeaderText: string;
|
|
48
|
+
faceDistanceMessageText: string;
|
|
49
|
+
clientHeaderText: string;
|
|
50
|
+
clientMessageText: string;
|
|
51
|
+
serverHeaderText: string;
|
|
52
|
+
serverMessageText: string;
|
|
53
|
+
landscapeHeaderText: string;
|
|
54
|
+
landscapeMessageText: string;
|
|
55
|
+
portraitMessageText: string;
|
|
56
|
+
tryAgainText: string;
|
|
57
|
+
};
|
|
58
|
+
export declare type ErrorDisplayTextFoo = typeof defaultErrorDisplayText;
|
|
59
|
+
export declare type ErrorDisplayText = Partial<ErrorDisplayTextFoo>;
|
|
60
|
+
export declare const defaultLivenessDisplayText: Required<LivenessDisplayText>;
|
|
61
|
+
export interface LivenessDisplayText extends HintDisplayText, CameraDisplayText, InstructionDisplayText, ErrorDisplayText, StreamDisplayText {
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useLivenessActor(): [import("xstate").State<import("../service").LivenessContext, import("../service").LivenessEvent, any, any, any>, (event: import("xstate").SingleOrArray<import("xstate").Event<import("../service").LivenessEvent>> | import("xstate").SCXML.Event<import("../service").LivenessEvent>, payload?: import("xstate").EventData | undefined) => import("xstate").State<import("../service").LivenessContext, import("../service").LivenessEvent, any, any, any>];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LivenessMachineState } from '../service';
|
|
2
|
+
export declare type LivenessSelectorFn<T> = (state: LivenessMachineState) => T;
|
|
3
|
+
export declare function createLivenessSelector<T>(selector: LivenessSelectorFn<T>): LivenessSelectorFn<T>;
|
|
4
|
+
export declare function useLivenessSelector<T>(selector: LivenessSelectorFn<T>): T;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UseMediaStreamInVideo {
|
|
3
|
+
videoRef: React.MutableRefObject<HTMLVideoElement | null>;
|
|
4
|
+
videoHeight: number | undefined;
|
|
5
|
+
videoWidth: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function useMediaStreamInVideo(stream: MediaStream, videoConstraints: MediaTrackConstraints): UseMediaStreamInVideo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FaceLivenessDetector, FaceLivenessDetectorProps, } from './FaceLivenessDetector';
|
package/dist/types/components/FaceLivenessDetector/providers/FaceLivenessDetectorProvider.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LivenessInterpreter, FaceLivenessDetectorProps } from '../service';
|
|
3
|
+
interface FaceLivenessDetectorContextType {
|
|
4
|
+
componentProps: FaceLivenessDetectorProps;
|
|
5
|
+
service: LivenessInterpreter;
|
|
6
|
+
}
|
|
7
|
+
export interface FaceLivenessDetectorProviderProps extends FaceLivenessDetectorContextType {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function FaceLivenessDetectorProvider({ children, ...props }: FaceLivenessDetectorProviderProps): JSX.Element;
|
|
11
|
+
export declare function useFaceLivenessDetector(): FaceLivenessDetectorContextType;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FaceLivenessDetectorProvider';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LivenessContext, LivenessEvent } from '../types';
|
|
2
|
+
export declare const MIN_FACE_MATCH_TIME = 500;
|
|
3
|
+
export declare const livenessMachine: import("xstate").StateMachine<LivenessContext, any, LivenessEvent, {
|
|
4
|
+
value: any;
|
|
5
|
+
context: TContext;
|
|
6
|
+
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, LivenessEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bounding box of a face.
|
|
3
|
+
*/
|
|
4
|
+
export interface Face {
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
timestampMs: number;
|
|
10
|
+
probability?: number;
|
|
11
|
+
rightEye: number[];
|
|
12
|
+
leftEye: number[];
|
|
13
|
+
mouth: number[];
|
|
14
|
+
nose: number[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The abstract class representing FaceDetection
|
|
18
|
+
* to be implemented for different libraries.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class FaceDetection {
|
|
21
|
+
modelLoadingPromise: Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Triggers the `loadModels` method and stores
|
|
24
|
+
* the corresponding promise to be awaited later.
|
|
25
|
+
*/
|
|
26
|
+
triggerModelLoading(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Loads the face detection models.
|
|
29
|
+
*/
|
|
30
|
+
abstract loadModels(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Detects the faces in the video element.
|
|
33
|
+
* @param videoEl The video element to detect faces in.
|
|
34
|
+
*/
|
|
35
|
+
abstract detectFaces(videoEl: HTMLVideoElement): Promise<Face[]>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props for the FaceLivenessDetector
|
|
3
|
+
*/
|
|
4
|
+
export interface FaceLivenessDetectorProps {
|
|
5
|
+
/**
|
|
6
|
+
* The sessionId as returned by CreateStreamingLivenessSession API
|
|
7
|
+
*/
|
|
8
|
+
sessionId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Callback that signals when the liveness session has completed analysis.
|
|
11
|
+
* At this point a request can be made to GetFaceLivenessSessionResults.
|
|
12
|
+
*/
|
|
13
|
+
onAnalysisComplete: () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* The AWS region to stream the video to, for current regional support see the documentation here: FIXME LINK
|
|
16
|
+
*/
|
|
17
|
+
region: string;
|
|
18
|
+
/**
|
|
19
|
+
* Callback called when the user cancels the flow
|
|
20
|
+
*/
|
|
21
|
+
onUserCancel?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback called when there is error occured on any step
|
|
24
|
+
*/
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Optional parameter for the disabling the Start/Get Ready Screen, default: false
|
|
28
|
+
*/
|
|
29
|
+
disableInstructionScreen?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Optional parameter for advanced options for the component
|
|
32
|
+
*/
|
|
33
|
+
config?: FaceLivenessDetectorConfig;
|
|
34
|
+
}
|
|
35
|
+
export interface FaceLivenessDetectorConfig {
|
|
36
|
+
/**
|
|
37
|
+
* overrides the Wasm backend binary CDN path
|
|
38
|
+
* default is https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.11.0/dist/.
|
|
39
|
+
* When overriding this path ensure that the wasm version matches the version of @tensorflow/tfjs-backend-wasm installed by npm
|
|
40
|
+
*/
|
|
41
|
+
binaryPath?: string;
|
|
42
|
+
/**
|
|
43
|
+
* overrides the Blazeface model and weights bin CDN URL
|
|
44
|
+
* default is https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1/model.json?tfjs-format=file
|
|
45
|
+
*/
|
|
46
|
+
faceModelUrl?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The coordiates of any bounding box
|
|
50
|
+
*/
|
|
51
|
+
export interface BoundingBox {
|
|
52
|
+
top: number;
|
|
53
|
+
right: number;
|
|
54
|
+
bottom: number;
|
|
55
|
+
left: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The details of the generated liveness oval
|
|
59
|
+
*/
|
|
60
|
+
export interface LivenessOvalDetails {
|
|
61
|
+
flippedCenterX: number | undefined;
|
|
62
|
+
centerX: number | undefined;
|
|
63
|
+
centerY: number | undefined;
|
|
64
|
+
width: number | undefined;
|
|
65
|
+
height: number | undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The illumination states
|
|
69
|
+
*/
|
|
70
|
+
export declare enum IlluminationState {
|
|
71
|
+
DARK = "dark",
|
|
72
|
+
BRIGHT = "bright",
|
|
73
|
+
NORMAL = "normal"
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The detected face states with respect to the liveness oval
|
|
77
|
+
*/
|
|
78
|
+
export declare enum FaceMatchState {
|
|
79
|
+
MATCHED = "MATCHED",
|
|
80
|
+
TOO_FAR = "TOO FAR",
|
|
81
|
+
TOO_CLOSE = "TOO CLOSE",
|
|
82
|
+
CANT_IDENTIFY = "CANNOT IDENTIFY",
|
|
83
|
+
FACE_IDENTIFIED = "ONE FACE IDENTIFIED",
|
|
84
|
+
TOO_MANY = "TOO MANY FACES"
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The liveness error states
|
|
88
|
+
*/
|
|
89
|
+
export declare enum LivenessErrorState {
|
|
90
|
+
TIMEOUT = "TIMEOUT",
|
|
91
|
+
RUNTIME_ERROR = "RUNTIME_ERROR",
|
|
92
|
+
FRESHNESS_TIMEOUT = "FRESHNESS_TIMEOUT",
|
|
93
|
+
SERVER_ERROR = "SERVER_ERROR",
|
|
94
|
+
CAMERA_FRAMERATE_ERROR = "CAMERA_FRAMERATE_ERROR",
|
|
95
|
+
CAMERA_ACCESS_ERROR = "CAMERA_ACCESS_ERROR",
|
|
96
|
+
FACE_DISTANCE_ERROR = "FACE_DISTANCE_ERROR",
|
|
97
|
+
MOBILE_LANDSCAPE_ERROR = "MOBILE_LANDSCAPE_ERROR"
|
|
98
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ActorRef, Interpreter, State } from 'xstate';
|
|
2
|
+
import { ValidationException, InternalServerException, ThrottlingException, ServiceQuotaExceededException, SessionInformation } from '@aws-sdk/client-rekognitionstreaming';
|
|
3
|
+
import { FaceLivenessDetectorProps, FaceMatchState, LivenessErrorState, LivenessOvalDetails, IlluminationState } from './liveness';
|
|
4
|
+
import { VideoRecorder, LivenessStreamProvider, FreshnessColorDisplay } from '../utils';
|
|
5
|
+
import { Face, FaceDetection } from './faceDetection';
|
|
6
|
+
export interface FaceMatchAssociatedParams {
|
|
7
|
+
illuminationState: IlluminationState;
|
|
8
|
+
faceMatchState: FaceMatchState;
|
|
9
|
+
faceMatchPercentage: number;
|
|
10
|
+
currentDetectedFace: Face;
|
|
11
|
+
startFace: Face;
|
|
12
|
+
endFace: Face;
|
|
13
|
+
initialFaceMatchTime: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FreshnessColorAssociatedParams {
|
|
16
|
+
freshnessColorEl: HTMLCanvasElement;
|
|
17
|
+
freshnessColors: string[];
|
|
18
|
+
freshnessColorsComplete: boolean;
|
|
19
|
+
freshnessColorDisplay: FreshnessColorDisplay;
|
|
20
|
+
}
|
|
21
|
+
export interface OvalAssociatedParams {
|
|
22
|
+
faceDetector: FaceDetection;
|
|
23
|
+
initialFace: Face;
|
|
24
|
+
ovalDetails: LivenessOvalDetails;
|
|
25
|
+
scaleFactor: number;
|
|
26
|
+
}
|
|
27
|
+
export interface VideoAssociatedParams {
|
|
28
|
+
videoConstraints: MediaTrackConstraints;
|
|
29
|
+
videoEl: HTMLVideoElement;
|
|
30
|
+
canvasEl: HTMLCanvasElement;
|
|
31
|
+
videoMediaStream: MediaStream;
|
|
32
|
+
videoRecorder: VideoRecorder;
|
|
33
|
+
recordingStartTimestampMs: number;
|
|
34
|
+
isMobile: boolean | undefined;
|
|
35
|
+
}
|
|
36
|
+
export interface LivenessContext {
|
|
37
|
+
maxFailedAttempts: number;
|
|
38
|
+
failedAttempts: number;
|
|
39
|
+
componentProps: FaceLivenessDetectorProps;
|
|
40
|
+
serverSessionInformation: SessionInformation;
|
|
41
|
+
challengeId: string;
|
|
42
|
+
videoAssociatedParams: VideoAssociatedParams;
|
|
43
|
+
ovalAssociatedParams: OvalAssociatedParams;
|
|
44
|
+
faceMatchAssociatedParams: FaceMatchAssociatedParams;
|
|
45
|
+
freshnessColorAssociatedParams: FreshnessColorAssociatedParams;
|
|
46
|
+
errorState: LivenessErrorState | null;
|
|
47
|
+
livenessStreamProvider: LivenessStreamProvider;
|
|
48
|
+
responseStreamActorRef: ActorRef<any>;
|
|
49
|
+
shouldDisconnect: boolean | undefined;
|
|
50
|
+
faceMatchStateBeforeStart: FaceMatchState;
|
|
51
|
+
isFaceFarEnoughBeforeRecording: boolean;
|
|
52
|
+
isRecordingStopped: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare type LivenessEventTypes = 'BEGIN' | 'START_RECORDING' | 'TIMEOUT' | 'ERROR' | 'CANCEL' | 'SET_SESSION_INFO' | 'DISCONNECT_EVENT' | 'SET_DOM_AND_CAMERA_DETAILS' | 'SERVER_ERROR' | 'RETRY_CAMERA_CHECK' | 'MOBILE_LANDSCAPE_WARNING';
|
|
55
|
+
export declare type LivenessEventData = Record<PropertyKey, any>;
|
|
56
|
+
export interface LivenessEvent {
|
|
57
|
+
type: LivenessEventTypes;
|
|
58
|
+
data?: LivenessEventData;
|
|
59
|
+
}
|
|
60
|
+
export declare type LivenessMachineState = State<LivenessContext, LivenessEvent>;
|
|
61
|
+
export declare type LivenessInterpreter = Interpreter<LivenessContext, any, LivenessEvent, any, any>;
|
|
62
|
+
export interface StreamActorCallback {
|
|
63
|
+
(params: {
|
|
64
|
+
type: 'DISCONNECT_EVENT';
|
|
65
|
+
}): void;
|
|
66
|
+
(params: {
|
|
67
|
+
type: 'SERVER_ERROR';
|
|
68
|
+
data: {
|
|
69
|
+
error: Error;
|
|
70
|
+
};
|
|
71
|
+
}): void;
|
|
72
|
+
(params: {
|
|
73
|
+
type: 'SERVER_ERROR';
|
|
74
|
+
data: {
|
|
75
|
+
error: ValidationException;
|
|
76
|
+
};
|
|
77
|
+
}): void;
|
|
78
|
+
(params: {
|
|
79
|
+
type: 'SERVER_ERROR';
|
|
80
|
+
data: {
|
|
81
|
+
error: InternalServerException;
|
|
82
|
+
};
|
|
83
|
+
}): void;
|
|
84
|
+
(params: {
|
|
85
|
+
type: 'SERVER_ERROR';
|
|
86
|
+
data: {
|
|
87
|
+
error: ThrottlingException;
|
|
88
|
+
};
|
|
89
|
+
}): void;
|
|
90
|
+
(params: {
|
|
91
|
+
type: 'SERVER_ERROR';
|
|
92
|
+
data: {
|
|
93
|
+
error: ServiceQuotaExceededException;
|
|
94
|
+
};
|
|
95
|
+
}): void;
|
|
96
|
+
(params: {
|
|
97
|
+
type: 'SET_SESSION_INFO';
|
|
98
|
+
data: {
|
|
99
|
+
sessionInfo: SessionInformation | undefined;
|
|
100
|
+
};
|
|
101
|
+
}): void;
|
|
102
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare enum ChallengeType {
|
|
2
|
+
FACE_MOVEMENT = "FACE_MOVEMENT"
|
|
3
|
+
}
|
|
4
|
+
export interface OvalParameters {
|
|
5
|
+
width: number;
|
|
6
|
+
centerX: number;
|
|
7
|
+
centerY: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientFaceMovementAndLightChallenge {
|
|
10
|
+
ovalParameters: OvalParameters;
|
|
11
|
+
}
|
|
12
|
+
export interface ClientChallenge {
|
|
13
|
+
faceMovementAndLightChallenge: ClientFaceMovementAndLightChallenge;
|
|
14
|
+
}
|
|
15
|
+
export interface SessionInformation {
|
|
16
|
+
challenge: ClientChallenge;
|
|
17
|
+
}
|
|
18
|
+
export interface BoundingBoxWithSize {
|
|
19
|
+
height: number;
|
|
20
|
+
width: number;
|
|
21
|
+
top: number;
|
|
22
|
+
left: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RecordingTimestamps {
|
|
25
|
+
videoStart: number;
|
|
26
|
+
initialFaceDetected: number;
|
|
27
|
+
faceDetectedInTargetPositionStart: number;
|
|
28
|
+
faceDetectedInTargetPositionEnd: number;
|
|
29
|
+
}
|
|
30
|
+
export declare enum Color {
|
|
31
|
+
BLACK = "rgb(0, 0, 0)",
|
|
32
|
+
WHITE = "rgb(255, 255, 255)",
|
|
33
|
+
RED = "rgb(255, 0, 0)",
|
|
34
|
+
YELLOW = "rgb(255, 255, 0)",
|
|
35
|
+
LIME = "rgb(0, 255, 0)",
|
|
36
|
+
CYAN = "rgb(0, 255, 255)",
|
|
37
|
+
BLUE = "rgb(0, 0, 255)",
|
|
38
|
+
VIOLET = "rgb(255, 0, 255)"
|
|
39
|
+
}
|
|
40
|
+
export declare enum FreshnessColor {
|
|
41
|
+
BLACK = "rgb_0_0_0",
|
|
42
|
+
BLUE = "rgb_0_0_255",
|
|
43
|
+
CYAN = "rgb_0_255_255",
|
|
44
|
+
LIME = "rgb_0_255_0",
|
|
45
|
+
RED = "rgb_255_0_0",
|
|
46
|
+
VIOLET = "rgb_255_0_255",
|
|
47
|
+
WHITE = "rgb_255_255_255",
|
|
48
|
+
YELLOW = "rgb_255_255_0"
|
|
49
|
+
}
|
|
50
|
+
export interface ClientFreshnessColorSequence {
|
|
51
|
+
color: string;
|
|
52
|
+
downscrollDuration: number;
|
|
53
|
+
flatDisplayDuration: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ColorSequence {
|
|
56
|
+
colorTimestampList: ColorTimestamp[];
|
|
57
|
+
}
|
|
58
|
+
export interface ColorTimestamp {
|
|
59
|
+
color: Color;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ServerFaceMovementAndLightChallenge {
|
|
63
|
+
challengeId: string;
|
|
64
|
+
initialFacePosition: BoundingBoxWithSize;
|
|
65
|
+
targetFacePosition: BoundingBoxWithSize;
|
|
66
|
+
recordingTimestamps: RecordingTimestamps;
|
|
67
|
+
colorSequence: ColorSequence;
|
|
68
|
+
}
|
|
69
|
+
export interface ServerChallenge {
|
|
70
|
+
faceMovementAndLightChallenge: ServerFaceMovementAndLightChallenge;
|
|
71
|
+
}
|
|
72
|
+
export interface ClientSessionInformation {
|
|
73
|
+
challenge: ServerChallenge;
|
|
74
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@tensorflow/tfjs-backend-cpu';
|
|
2
|
+
import { FaceDetection, Face } from '../types';
|
|
3
|
+
declare type BlazeFaceModelBackend = 'wasm' | 'cpu';
|
|
4
|
+
/**
|
|
5
|
+
* The BlazeFace implementation of the FaceDetection interface.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BlazeFaceFaceDetection extends FaceDetection {
|
|
8
|
+
modelBackend: BlazeFaceModelBackend;
|
|
9
|
+
faceModelUrl: string | undefined;
|
|
10
|
+
binaryPath: string;
|
|
11
|
+
private _model;
|
|
12
|
+
constructor(binaryPath?: string, faceModelUrl?: string);
|
|
13
|
+
loadModels(): Promise<void>;
|
|
14
|
+
detectFaces(videoEl: HTMLVideoElement): Promise<Face[]>;
|
|
15
|
+
private _loadWebAssemblyBackend;
|
|
16
|
+
private _loadCPUBackend;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FaceMovementAndLightServerChallenge, LivenessResponseStream, OvalParameters, ServerChallenge, SessionInformation } from '@aws-sdk/client-rekognitionstreaming';
|
|
2
|
+
export declare const isServerSesssionInformationEvent: (value: unknown) => value is LivenessResponseStream.ServerSessionInformationEventMember;
|
|
3
|
+
export declare const isOvalParameters: (value: unknown) => value is OvalParameters;
|
|
4
|
+
export declare const isFaceMovementAndLightChallenge: (value: unknown) => value is FaceMovementAndLightServerChallenge;
|
|
5
|
+
export declare const isServerChallenge: (value: unknown) => value is ServerChallenge;
|
|
6
|
+
export declare const isSessionInformation: (value: unknown) => value is SessionInformation;
|
|
7
|
+
export declare const isDisconnectionEvent: (value: unknown) => value is LivenessResponseStream.DisconnectionEventMember;
|
|
8
|
+
export declare const isValidationExceptionEvent: (value: unknown) => value is LivenessResponseStream.ValidationExceptionMember;
|
|
9
|
+
export declare const isInternalServerExceptionEvent: (value: unknown) => value is LivenessResponseStream.InternalServerExceptionMember;
|
|
10
|
+
export declare const isThrottlingExceptionEvent: (value: unknown) => value is LivenessResponseStream.ThrottlingExceptionMember;
|
|
11
|
+
export declare const isServiceQuotaExceededExceptionEvent: (value: unknown) => value is LivenessResponseStream.ServiceQuotaExceededExceptionMember;
|
|
12
|
+
export declare const isInvalidSignatureRegionException: (error: unknown) => error is Error;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LivenessContext } from '../types/machine';
|
|
2
|
+
import { ClientFreshnessColorSequence } from '../types/service';
|
|
3
|
+
export declare class FreshnessColorDisplay {
|
|
4
|
+
private freshnessColorsSequence;
|
|
5
|
+
private context;
|
|
6
|
+
private stageIndex;
|
|
7
|
+
private stage;
|
|
8
|
+
private currColorIndex;
|
|
9
|
+
private currColorSequence;
|
|
10
|
+
private prevColorSequence;
|
|
11
|
+
private timeLastFlatOrScrollChange;
|
|
12
|
+
private timeFaceMatched;
|
|
13
|
+
private timeLastFaceMatchChecked;
|
|
14
|
+
private isFirstTick;
|
|
15
|
+
constructor(context: LivenessContext, freshnessColorsSequence: ClientFreshnessColorSequence[]);
|
|
16
|
+
displayColorTick(): Promise<boolean>;
|
|
17
|
+
private init;
|
|
18
|
+
private displayNextColorTick;
|
|
19
|
+
private incrementStageIndex;
|
|
20
|
+
private matchFaceInOval;
|
|
21
|
+
private sendColorStartTime;
|
|
22
|
+
}
|