@aws-amplify/ui-react-liveness 3.0.13 → 3.0.15

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 (37) hide show
  1. package/dist/esm/components/FaceLivenessDetector/FaceLivenessDetectorCore.mjs +1 -5
  2. package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.mjs +4 -15
  3. package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCheck.mjs +1 -5
  4. package/dist/esm/components/FaceLivenessDetector/service/machine/index.mjs +144 -158
  5. package/dist/esm/components/FaceLivenessDetector/service/utils/{CustomWebSocketFetchHandler.mjs → createStreamingClient/CustomWebSocketFetchHandler.mjs} +4 -5
  6. package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.mjs +18 -0
  7. package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/createStreamingClient.mjs +27 -0
  8. package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/resolveCredentials.mjs +38 -0
  9. package/dist/esm/components/FaceLivenessDetector/service/utils/liveness.mjs +62 -67
  10. package/dist/esm/components/FaceLivenessDetector/service/utils/streamProvider.mjs +14 -35
  11. package/dist/esm/components/FaceLivenessDetector/service/utils/videoRecorder.mjs +1 -2
  12. package/dist/esm/components/FaceLivenessDetector/shared/DefaultStartScreenComponents.mjs +1 -5
  13. package/dist/esm/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.mjs +1 -5
  14. package/dist/esm/components/FaceLivenessDetector/shared/Hint.mjs +1 -5
  15. package/dist/esm/components/FaceLivenessDetector/types/classNames.mjs +0 -5
  16. package/dist/esm/version.mjs +1 -1
  17. package/dist/index.js +294 -275
  18. package/dist/styles.css +1 -1
  19. package/dist/types/components/FaceLivenessDetector/hooks/useLivenessActor.d.ts +1 -1
  20. package/dist/types/components/FaceLivenessDetector/service/machine/index.d.ts +3 -4
  21. package/dist/types/components/FaceLivenessDetector/service/types/credentials.d.ts +9 -10
  22. package/dist/types/components/FaceLivenessDetector/service/types/machine.d.ts +17 -18
  23. package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.d.ts +6 -0
  24. package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/createStreamingClient.d.ts +9 -0
  25. package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/index.d.ts +1 -0
  26. package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/resolveCredentials.d.ts +10 -0
  27. package/dist/types/components/FaceLivenessDetector/service/utils/liveness.d.ts +7 -9
  28. package/dist/types/components/FaceLivenessDetector/service/utils/streamProvider.d.ts +3 -10
  29. package/dist/types/components/FaceLivenessDetector/service/utils/videoRecorder.d.ts +1 -7
  30. package/dist/types/components/FaceLivenessDetector/shared/index.d.ts +0 -3
  31. package/dist/types/components/FaceLivenessDetector/types/classNames.d.ts +0 -5
  32. package/dist/types/version.d.ts +1 -1
  33. package/package.json +5 -4
  34. package/dist/types/components/FaceLivenessDetector/shared/GoodFitIllustration.d.ts +0 -7
  35. package/dist/types/components/FaceLivenessDetector/shared/StartScreenFigure.d.ts +0 -8
  36. package/dist/types/components/FaceLivenessDetector/shared/TooFarIllustration.d.ts +0 -7
  37. /package/dist/types/components/FaceLivenessDetector/service/utils/{CustomWebSocketFetchHandler.d.ts → createStreamingClient/CustomWebSocketFetchHandler.d.ts} +0 -0
package/dist/styles.css CHANGED
@@ -4205,7 +4205,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
4205
4205
 
4206
4206
  .amplify-liveness-landscape-error-modal {
4207
4207
  background-color: var(--amplify-colors-background-primary);
4208
- direction: column;
4208
+ flex-direction: column;
4209
4209
  text-align: center;
4210
4210
  align-items: center;
4211
4211
  justify-content: center;
@@ -1 +1 @@
1
- export declare function useLivenessActor(): [import("xstate").State<Partial<import("../service").HydratedLivenessContext>, 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<Partial<import("../service").HydratedLivenessContext>, import("../service").LivenessEvent, any, any, any>];
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>];
@@ -1,6 +1,5 @@
1
- import { LivenessEvent } from '../types';
2
- export declare const MIN_FACE_MATCH_TIME = 1000;
3
- export declare const livenessMachine: import("xstate").StateMachine<Partial<import("../types").HydratedLivenessContext>, any, LivenessEvent, {
1
+ import { LivenessContext, LivenessEvent } from '../types';
2
+ export declare const livenessMachine: import("xstate").StateMachine<LivenessContext, any, LivenessEvent, {
4
3
  value: any;
5
- context: Partial<import("../types").HydratedLivenessContext>;
4
+ context: LivenessContext;
6
5
  }, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, LivenessEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
@@ -1,16 +1,15 @@
1
+ import { CredentialsAndIdentityId } from 'aws-amplify/auth';
2
+ export type AwsCredentials = CredentialsAndIdentityId['credentials'];
3
+ export interface IdentityProvider<IdentityT extends AwsCredentials> {
4
+ (identityProperties?: Record<string, any>): Promise<IdentityT>;
5
+ }
1
6
  /**
2
- * These types are copied over / adapted from the aws-sdk/types package as they do not semantic versioning and we do not want these changing unexpectedly.
3
- * When Amplify Auth exports these types this file should be removed and the type definitions should come from the Amplify auth package
7
+ * @deprecated `AwsTemporaryCredentials` has been replaced with `AwsCredentials`.
8
+ *
9
+ * The `AwsTemporaryCredentials` type may be removed in a future major version of _@aws-amplify/ui-react-liveness_.
4
10
  */
5
- export interface AwsCredentials {
6
- readonly accessKeyId: string;
7
- readonly secretAccessKey: string;
8
- }
9
11
  export interface AwsTemporaryCredentials extends AwsCredentials {
10
12
  readonly sessionToken?: string;
11
13
  readonly expiration?: Date;
12
14
  }
13
- export interface IdentityProvider<IdentityT extends AwsTemporaryCredentials> {
14
- (identityProperties?: Record<string, any>): Promise<IdentityT>;
15
- }
16
- export type AwsCredentialProvider = IdentityProvider<AwsTemporaryCredentials>;
15
+ export type AwsCredentialProvider = IdentityProvider<AwsCredentials>;
@@ -36,24 +36,23 @@ export interface VideoAssociatedParams {
36
36
  selectedDeviceId?: string;
37
37
  selectableDevices?: MediaDeviceInfo[];
38
38
  }
39
- export type LivenessContext = Partial<HydratedLivenessContext>;
40
- export interface HydratedLivenessContext {
41
- maxFailedAttempts: number;
42
- failedAttempts: number;
43
- componentProps: FaceLivenessDetectorCoreProps;
44
- serverSessionInformation: SessionInformation;
45
- challengeId: string;
46
- videoAssociatedParams: VideoAssociatedParams;
47
- ovalAssociatedParams: OvalAssociatedParams;
48
- faceMatchAssociatedParams: FaceMatchAssociatedParams;
49
- freshnessColorAssociatedParams: FreshnessColorAssociatedParams;
50
- errorState: ErrorState;
51
- livenessStreamProvider: LivenessStreamProvider;
52
- responseStreamActorRef: ActorRef<any>;
53
- shouldDisconnect: boolean;
54
- faceMatchStateBeforeStart: FaceMatchState;
55
- isFaceFarEnoughBeforeRecording: boolean;
56
- isRecordingStopped: boolean;
39
+ export interface LivenessContext {
40
+ challengeId?: string;
41
+ componentProps?: FaceLivenessDetectorCoreProps;
42
+ errorState?: ErrorState;
43
+ faceMatchAssociatedParams?: FaceMatchAssociatedParams;
44
+ faceMatchStateBeforeStart?: FaceMatchState;
45
+ failedAttempts?: number;
46
+ freshnessColorAssociatedParams?: FreshnessColorAssociatedParams;
47
+ isFaceFarEnoughBeforeRecording?: boolean;
48
+ isRecordingStopped?: boolean;
49
+ livenessStreamProvider?: LivenessStreamProvider;
50
+ maxFailedAttempts?: number;
51
+ ovalAssociatedParams?: OvalAssociatedParams;
52
+ responseStreamActorRef?: ActorRef<any>;
53
+ serverSessionInformation?: SessionInformation;
54
+ shouldDisconnect?: boolean;
55
+ videoAssociatedParams?: VideoAssociatedParams;
57
56
  }
58
57
  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';
59
58
  export type LivenessEventData = Record<PropertyKey, any>;
@@ -0,0 +1,6 @@
1
+ import { SignatureV4 } from '@smithy/signature-v4';
2
+ import { HttpRequest as HttpRequest, RequestPresigningArguments } from '@smithy/types';
3
+ export declare const REQUEST_EXPIRY = 299;
4
+ export declare class Signer extends SignatureV4 {
5
+ presign(request: HttpRequest, options?: Omit<RequestPresigningArguments, 'expiresIn'>): Promise<HttpRequest>;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { RekognitionStreamingClient } from '@aws-sdk/client-rekognitionstreaming';
2
+ import { AwsCredentialProvider } from '../../types';
3
+ interface CreateClientConfig {
4
+ credentialsProvider?: AwsCredentialProvider;
5
+ endpointOverride?: string;
6
+ region: string;
7
+ }
8
+ export declare function createStreamingClient({ credentialsProvider, endpointOverride, region, }: CreateClientConfig): Promise<RekognitionStreamingClient>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export { createStreamingClient } from './createStreamingClient';
@@ -0,0 +1,10 @@
1
+ import { AwsCredentialProvider, AwsCredentials } from '../../types';
2
+ /**
3
+ * Resolves the `credentials` param to be passed to `RekognitionStreamingClient` which accepts either:
4
+ * - a `credentials` object
5
+ * - a `credentialsProvider` callback
6
+ *
7
+ * @param credentialsProvider optional `credentialsProvider` callback
8
+ * @returns {Promise<AwsCredentials | AwsCredentialProvider>} `credentials` object or valid `credentialsProvider` callback
9
+ */
10
+ export declare function resolveCredentials(credentialsProvider?: AwsCredentialProvider): Promise<AwsCredentials | AwsCredentialProvider>;
@@ -1,7 +1,7 @@
1
1
  import { LivenessOvalDetails, IlluminationState, Face, FaceMatchState, BoundingBox, ErrorState } from '../types';
2
2
  import { FaceDetection } from '../types/faceDetection';
3
3
  import { ClientFreshnessColorSequence } from '../types/service';
4
- import { ColorSequence, SessionInformation } from '@aws-sdk/client-rekognitionstreaming';
4
+ import { SessionInformation } from '@aws-sdk/client-rekognitionstreaming';
5
5
  interface OvalBoundingBox {
6
6
  ovalBoundingBox: BoundingBox;
7
7
  minOvalX: number;
@@ -36,7 +36,6 @@ export declare function getStaticLivenessOvalDetails({ width, height, widthSeed,
36
36
  centerYSeed?: number;
37
37
  ratioMultiplier?: number;
38
38
  }): LivenessOvalDetails;
39
- export declare function drawStaticOval(canvasEl: HTMLCanvasElement, videoEl: HTMLVideoElement, videoMediaStream: MediaStream): void;
40
39
  /**
41
40
  * Draws the provided liveness oval on the canvas.
42
41
  */
@@ -47,18 +46,18 @@ export declare function drawLivenessOvalInCanvas({ canvas, oval, scaleFactor, vi
47
46
  videoEl: HTMLVideoElement;
48
47
  isStartScreen?: boolean;
49
48
  }): void;
49
+ export declare function drawStaticOval(canvasEl: HTMLCanvasElement, videoEl: HTMLVideoElement, videoMediaStream: MediaStream): void;
50
50
  export declare function clearOvalCanvas({ canvas, }: {
51
51
  canvas: HTMLCanvasElement;
52
52
  }): void;
53
- interface FaceMatchStateInLivenessOval {
54
- faceMatchState: FaceMatchState;
55
- faceMatchPercentage: number;
56
- }
53
+ export declare function generateBboxFromLandmarks(face: Face, oval: LivenessOvalDetails): BoundingBox;
57
54
  /**
58
55
  * Returns the state of the provided face with respect to the provided liveness oval.
59
56
  */
60
- export declare function getFaceMatchStateInLivenessOval(face: Face, ovalDetails: LivenessOvalDetails, initialFaceIntersection: number, sessionInformation: SessionInformation): FaceMatchStateInLivenessOval;
61
- export declare function generateBboxFromLandmarks(face: Face, oval: LivenessOvalDetails): BoundingBox;
57
+ export declare function getFaceMatchStateInLivenessOval(face: Face, ovalDetails: LivenessOvalDetails, initialFaceIntersection: number, sessionInformation: SessionInformation): {
58
+ faceMatchState: FaceMatchState;
59
+ faceMatchPercentage: number;
60
+ };
62
61
  /**
63
62
  * Returns the illumination state in the provided video frame.
64
63
  */
@@ -79,7 +78,6 @@ export declare const LivenessErrorStateStringMap: {
79
78
  MOBILE_LANDSCAPE_ERROR: string;
80
79
  FRESHNESS_TIMEOUT: string;
81
80
  };
82
- export declare const MOCK_COLOR_SEQUENCES: ColorSequence[];
83
81
  interface FillOverlayCanvasFractionalInput {
84
82
  overlayCanvas: HTMLCanvasElement;
85
83
  prevColor: string;
@@ -4,24 +4,16 @@ import { AwsCredentialProvider } from '../types';
4
4
  export interface StartLivenessStreamInput {
5
5
  sessionId: string;
6
6
  }
7
- export interface StartLivenessStreamOutput {
8
- sessionId: string;
7
+ export interface StartLivenessStreamOutput extends StartLivenessStreamInput {
9
8
  stream: WebSocket;
10
9
  }
11
- export interface Credentials {
12
- accessKeyId: string;
13
- secretAccessKey: string;
14
- sessionToken: string;
15
- }
16
- export interface StreamProviderArgs {
17
- sessionId: string;
10
+ interface StreamProviderArgs extends StartLivenessStreamInput {
18
11
  region: string;
19
12
  stream: MediaStream;
20
13
  videoEl: HTMLVideoElement;
21
14
  credentialProvider?: AwsCredentialProvider;
22
15
  endpointOverride?: string;
23
16
  }
24
- export declare const TIME_SLICE = 1000;
25
17
  export declare class LivenessStreamProvider {
26
18
  sessionId: string;
27
19
  region: string;
@@ -45,3 +37,4 @@ export declare class LivenessStreamProvider {
45
37
  private getAsyncGeneratorFromReadableStream;
46
38
  private startLivenessVideoConnection;
47
39
  }
40
+ export {};
@@ -1,8 +1,3 @@
1
- /**
2
- * The options for the video recorder.
3
- */
4
- export interface VideoRecorderOptions {
5
- }
6
1
  /**
7
2
  * Helper wrapper class over the native MediaRecorder.
8
3
  */
@@ -18,10 +13,9 @@ export declare class VideoRecorder {
18
13
  recorderStarted: Promise<void>;
19
14
  private _recorder;
20
15
  private _stream;
21
- private _options;
22
16
  private _chunks;
23
17
  private _recorderStopped;
24
- constructor(stream: MediaStream, options?: VideoRecorderOptions);
18
+ constructor(stream: MediaStream);
25
19
  getState(): string | undefined;
26
20
  start(timeSlice?: number): void;
27
21
  stop(): Promise<void>;
@@ -3,6 +3,3 @@ export * from './Hint';
3
3
  export * from './MatchIndicator';
4
4
  export * from './Overlay';
5
5
  export * from './RecordingIcon';
6
- export * from './StartScreenFigure';
7
- export * from './GoodFitIllustration';
8
- export * from './TooFarIllustration';
@@ -13,11 +13,6 @@ export declare enum LivenessClassNames {
13
13
  FreshnessCanvas = "amplify-liveness-freshness-canvas",
14
14
  InstructionList = "amplify-liveness-instruction-list",
15
15
  InstructionOverlay = "amplify-liveness-instruction-overlay",
16
- Figure = "amplify-liveness-figure",
17
- FigureCaption = "amplify-liveness-figure__caption",
18
- FigureIcon = "amplify-liveness-figure__icon",
19
- FigureImage = "amplify-liveness-figure__image",
20
- Figures = "amplify-liveness-figures",
21
16
  Hint = "amplify-liveness-hint",
22
17
  HintText = "amplify-liveness-hint__text",
23
18
  LandscapeErrorModal = "amplify-liveness-landscape-error-modal",
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.13";
1
+ export declare const VERSION = "3.0.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-liveness",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -47,13 +47,14 @@
47
47
  "react-dom": "^16.14.0 || ^17.0 || ^18.0"
48
48
  },
49
49
  "dependencies": {
50
- "@aws-amplify/ui": "6.0.11",
51
- "@aws-amplify/ui-react": "6.1.5",
50
+ "@aws-amplify/ui": "6.0.12",
51
+ "@aws-amplify/ui-react": "6.1.6",
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",
55
55
  "@smithy/fetch-http-handler": "^2.1.3",
56
56
  "@smithy/protocol-http": "^3.0.3",
57
+ "@smithy/signature-v4": "2.1.4",
57
58
  "@mediapipe/face_detection": "~0.4.0",
58
59
  "@tensorflow-models/face-detection": "1.0.2",
59
60
  "@tensorflow/tfjs-backend-cpu": "4.11.0",
@@ -80,7 +81,7 @@
80
81
  "name": "FaceLivenessDetector",
81
82
  "path": "dist/esm/index.mjs",
82
83
  "import": "{ FaceLivenessDetector }",
83
- "limit": "275 kB"
84
+ "limit": "280 kB"
84
85
  }
85
86
  ]
86
87
  }
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface GoodFitIllustrationProps {
3
- title: string;
4
- testId?: string;
5
- }
6
- export declare const GoodFitIllustration: React.FC<GoodFitIllustrationProps>;
7
- export {};
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { FlexProps } from '@aws-amplify/ui-react';
3
- interface StartScreenFigureProps extends FlexProps {
4
- caption: string;
5
- variation?: 'defaut' | 'error' | 'success';
6
- }
7
- export declare const StartScreenFigure: React.FC<StartScreenFigureProps>;
8
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface TooFarIllustrationProps {
3
- title: string;
4
- testId?: string;
5
- }
6
- export declare const TooFarIllustration: React.FC<TooFarIllustrationProps>;
7
- export {};