@aws-amplify/ui-react-liveness 3.0.14 → 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.
- package/dist/esm/components/FaceLivenessDetector/FaceLivenessDetectorCore.mjs +1 -5
- package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCameraModule.mjs +1 -5
- package/dist/esm/components/FaceLivenessDetector/LivenessCheck/LivenessCheck.mjs +1 -5
- package/dist/esm/components/FaceLivenessDetector/service/utils/{CustomWebSocketFetchHandler.mjs → createStreamingClient/CustomWebSocketFetchHandler.mjs} +1 -1
- package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.mjs +18 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/createStreamingClient.mjs +27 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/resolveCredentials.mjs +38 -0
- package/dist/esm/components/FaceLivenessDetector/service/utils/streamProvider.mjs +8 -30
- package/dist/esm/components/FaceLivenessDetector/shared/DefaultStartScreenComponents.mjs +1 -5
- package/dist/esm/components/FaceLivenessDetector/shared/FaceLivenessErrorModal.mjs +1 -5
- package/dist/esm/components/FaceLivenessDetector/shared/Hint.mjs +1 -5
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +77 -26
- package/dist/types/components/FaceLivenessDetector/service/types/credentials.d.ts +9 -10
- package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.d.ts +6 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/createStreamingClient.d.ts +9 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/index.d.ts +1 -0
- package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/resolveCredentials.d.ts +10 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
- /package/dist/types/components/FaceLivenessDetector/service/utils/{CustomWebSocketFetchHandler.d.ts → createStreamingClient/CustomWebSocketFetchHandler.d.ts} +0 -0
|
@@ -7,12 +7,8 @@ import '@tensorflow-models/face-detection';
|
|
|
7
7
|
import '@tensorflow/tfjs-backend-wasm';
|
|
8
8
|
import '@tensorflow/tfjs-backend-cpu';
|
|
9
9
|
import '@aws-amplify/core/internals/utils';
|
|
10
|
-
import 'aws-amplify/auth';
|
|
11
10
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
12
|
-
import '
|
|
13
|
-
import '@smithy/eventstream-serde-browser';
|
|
14
|
-
import '@smithy/fetch-http-handler';
|
|
15
|
-
import '@smithy/protocol-http';
|
|
11
|
+
import './service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
16
12
|
import './service/utils/freshnessColorDisplay.mjs';
|
|
17
13
|
import { View, Flex } from '@aws-amplify/ui-react';
|
|
18
14
|
import { FaceLivenessDetectorProvider } from './providers/FaceLivenessDetectorProvider.mjs';
|
|
@@ -10,12 +10,8 @@ import '@tensorflow/tfjs-backend-wasm';
|
|
|
10
10
|
import '@tensorflow/tfjs-backend-cpu';
|
|
11
11
|
import '@aws-amplify/core/internals/utils';
|
|
12
12
|
import { drawStaticOval, clearOvalCanvas } from '../service/utils/liveness.mjs';
|
|
13
|
-
import 'aws-amplify/auth';
|
|
14
13
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
15
|
-
import '
|
|
16
|
-
import '@smithy/eventstream-serde-browser';
|
|
17
|
-
import '@smithy/fetch-http-handler';
|
|
18
|
-
import '@smithy/protocol-http';
|
|
14
|
+
import '../service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
19
15
|
import '../service/utils/freshnessColorDisplay.mjs';
|
|
20
16
|
import { useLivenessActor } from '../hooks/useLivenessActor.mjs';
|
|
21
17
|
import { useLivenessSelector, createLivenessSelector } from '../hooks/useLivenessSelector.mjs';
|
|
@@ -8,12 +8,8 @@ import '@tensorflow-models/face-detection';
|
|
|
8
8
|
import '@tensorflow/tfjs-backend-wasm';
|
|
9
9
|
import '@tensorflow/tfjs-backend-cpu';
|
|
10
10
|
import '@aws-amplify/core/internals/utils';
|
|
11
|
-
import 'aws-amplify/auth';
|
|
12
11
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
13
|
-
import '
|
|
14
|
-
import '@smithy/eventstream-serde-browser';
|
|
15
|
-
import '@smithy/fetch-http-handler';
|
|
16
|
-
import '@smithy/protocol-http';
|
|
12
|
+
import '../service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
17
13
|
import '../service/utils/freshnessColorDisplay.mjs';
|
|
18
14
|
import { LivenessCameraModule } from './LivenessCameraModule.mjs';
|
|
19
15
|
import { useLivenessActor } from '../hooks/useLivenessActor.mjs';
|
|
@@ -2,7 +2,7 @@ import { formatUrl } from '@aws-sdk/util-format-url';
|
|
|
2
2
|
import { readableStreamtoIterable, iterableToReadableStream } from '@smithy/eventstream-serde-browser';
|
|
3
3
|
import { FetchHttpHandler } from '@smithy/fetch-http-handler';
|
|
4
4
|
import { HttpResponse } from '@smithy/protocol-http';
|
|
5
|
-
import { WS_CLOSURE_CODE } from '
|
|
5
|
+
import { WS_CLOSURE_CODE } from '../constants.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Note: This file was copied from https://github.com/aws/aws-sdk-js-v3/blob/main/packages/middleware-websocket/src/websocket-fetch-handler.ts#L176
|
package/dist/esm/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SignatureV4 } from '@smithy/signature-v4';
|
|
2
|
+
|
|
3
|
+
// override aws sdk default value of 60
|
|
4
|
+
const REQUEST_EXPIRY = 299;
|
|
5
|
+
class Signer extends SignatureV4 {
|
|
6
|
+
presign(request, options) {
|
|
7
|
+
return super.presign(request, {
|
|
8
|
+
...options,
|
|
9
|
+
expiresIn: REQUEST_EXPIRY,
|
|
10
|
+
// `headers` that should not be signed. Liveness WebSocket
|
|
11
|
+
// request omits `headers` except for required `host` header. Signature
|
|
12
|
+
// could be a mismatch if other `headers` are signed
|
|
13
|
+
unsignableHeaders: new Set(Object.keys(request.headers).filter((header) => header !== 'host')),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { REQUEST_EXPIRY, Signer };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RekognitionStreamingClient } from '@aws-sdk/client-rekognitionstreaming';
|
|
2
|
+
import { getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { getLivenessUserAgent } from '../../../utils/platform.mjs';
|
|
4
|
+
import { CustomWebSocketFetchHandler } from './CustomWebSocketFetchHandler.mjs';
|
|
5
|
+
import { resolveCredentials } from './resolveCredentials.mjs';
|
|
6
|
+
import { Signer } from './Signer.mjs';
|
|
7
|
+
|
|
8
|
+
const CONNECTION_TIMEOUT = 10000;
|
|
9
|
+
const CUSTOM_USER_AGENT = `${getAmplifyUserAgent()} ${getLivenessUserAgent()}`;
|
|
10
|
+
async function createStreamingClient({ credentialsProvider, endpointOverride, region, }) {
|
|
11
|
+
const credentials = await resolveCredentials(credentialsProvider);
|
|
12
|
+
const clientconfig = {
|
|
13
|
+
credentials,
|
|
14
|
+
customUserAgent: CUSTOM_USER_AGENT,
|
|
15
|
+
region,
|
|
16
|
+
requestHandler: new CustomWebSocketFetchHandler({
|
|
17
|
+
connectionTimeout: CONNECTION_TIMEOUT,
|
|
18
|
+
}),
|
|
19
|
+
signerConstructor: Signer,
|
|
20
|
+
};
|
|
21
|
+
if (endpointOverride) {
|
|
22
|
+
clientconfig.endpointProvider = () => ({ url: new URL(endpointOverride) });
|
|
23
|
+
}
|
|
24
|
+
return new RekognitionStreamingClient(clientconfig);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { createStreamingClient };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { fetchAuthSession } from 'aws-amplify/auth';
|
|
2
|
+
|
|
3
|
+
const isCredentialsProvider = (credentialsProvider) => typeof credentialsProvider === 'function';
|
|
4
|
+
// the return interface of `fetchAuthSession` includes `credentials` as
|
|
5
|
+
// optional, but `credentials` is always returned. If `fetchAuthSession`
|
|
6
|
+
// is called for an unauthenticated end user, values of `accessKeyId`
|
|
7
|
+
// and `secretAccessKey` are `undefined`
|
|
8
|
+
const isCredentials = (credentials) => !!(credentials?.accessKeyId && credentials?.secretAccessKey);
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the `credentials` param to be passed to `RekognitionStreamingClient` which accepts either:
|
|
11
|
+
* - a `credentials` object
|
|
12
|
+
* - a `credentialsProvider` callback
|
|
13
|
+
*
|
|
14
|
+
* @param credentialsProvider optional `credentialsProvider` callback
|
|
15
|
+
* @returns {Promise<AwsCredentials | AwsCredentialProvider>} `credentials` object or valid `credentialsProvider` callback
|
|
16
|
+
*/
|
|
17
|
+
async function resolveCredentials(credentialsProvider) {
|
|
18
|
+
const hasCredentialsProvider = isCredentialsProvider(credentialsProvider);
|
|
19
|
+
if (hasCredentialsProvider) {
|
|
20
|
+
return credentialsProvider;
|
|
21
|
+
}
|
|
22
|
+
if (credentialsProvider && !hasCredentialsProvider) {
|
|
23
|
+
throw new Error('Invalid credentialsProvider');
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const result = (await fetchAuthSession()).credentials;
|
|
27
|
+
if (isCredentials(result)) {
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
throw new Error('Missing credentials');
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
const { message } = e;
|
|
34
|
+
throw new Error(`Invalid credentials: ${message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { resolveCredentials };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchAuthSession } from 'aws-amplify/auth';
|
|
3
|
-
import { RekognitionStreamingClient, StartFaceLivenessSessionCommand } from '@aws-sdk/client-rekognitionstreaming';
|
|
1
|
+
import { StartFaceLivenessSessionCommand } from '@aws-sdk/client-rekognitionstreaming';
|
|
4
2
|
import { VideoRecorder } from './videoRecorder.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import { CustomWebSocketFetchHandler } from './CustomWebSocketFetchHandler.mjs';
|
|
3
|
+
import { createStreamingClient } from './createStreamingClient/createStreamingClient.mjs';
|
|
7
4
|
|
|
8
5
|
const TIME_SLICE = 1000;
|
|
9
6
|
function isBlob(obj) {
|
|
@@ -34,9 +31,7 @@ class LivenessStreamProvider {
|
|
|
34
31
|
this.videoRecorder.start(TIME_SLICE);
|
|
35
32
|
}
|
|
36
33
|
sendClientInfo(clientInfo) {
|
|
37
|
-
this.videoRecorder.dispatch(new MessageEvent('clientSesssionInfo', {
|
|
38
|
-
data: { clientInfo },
|
|
39
|
-
}));
|
|
34
|
+
this.videoRecorder.dispatch(new MessageEvent('clientSesssionInfo', { data: { clientInfo } }));
|
|
40
35
|
}
|
|
41
36
|
async stopVideo() {
|
|
42
37
|
await this.videoRecorder.stop();
|
|
@@ -48,32 +43,15 @@ class LivenessStreamProvider {
|
|
|
48
43
|
if (this.videoRecorder.getState() === 'recording') {
|
|
49
44
|
await this.stopVideo();
|
|
50
45
|
}
|
|
51
|
-
this.videoRecorder.dispatch(new MessageEvent('endStreamWithCode', {
|
|
52
|
-
data: { code: code },
|
|
53
|
-
}));
|
|
46
|
+
this.videoRecorder.dispatch(new MessageEvent('endStreamWithCode', { data: { code } }));
|
|
54
47
|
return;
|
|
55
48
|
}
|
|
56
49
|
async init() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
const clientconfig = {
|
|
62
|
-
credentials,
|
|
50
|
+
this._client = await createStreamingClient({
|
|
51
|
+
credentialsProvider: this.credentialProvider,
|
|
52
|
+
endpointOverride: this.endpointOverride,
|
|
63
53
|
region: this.region,
|
|
64
|
-
|
|
65
|
-
requestHandler: new CustomWebSocketFetchHandler({
|
|
66
|
-
connectionTimeout: 10000,
|
|
67
|
-
}),
|
|
68
|
-
};
|
|
69
|
-
if (this.endpointOverride) {
|
|
70
|
-
const override = this.endpointOverride;
|
|
71
|
-
clientconfig.endpointProvider = () => {
|
|
72
|
-
const url = new URL(override);
|
|
73
|
-
return { url };
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
this._client = new RekognitionStreamingClient(clientconfig);
|
|
54
|
+
});
|
|
77
55
|
this.responseStream = await this.startLivenessVideoConnection();
|
|
78
56
|
}
|
|
79
57
|
// Creates a generator from a stream of video chunks and livenessActionDocuments and yields VideoEvent and ClientEvents
|
|
@@ -9,12 +9,8 @@ import '@tensorflow-models/face-detection';
|
|
|
9
9
|
import '@tensorflow/tfjs-backend-wasm';
|
|
10
10
|
import '@tensorflow/tfjs-backend-cpu';
|
|
11
11
|
import '@aws-amplify/core/internals/utils';
|
|
12
|
-
import 'aws-amplify/auth';
|
|
13
12
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
14
|
-
import '
|
|
15
|
-
import '@smithy/eventstream-serde-browser';
|
|
16
|
-
import '@smithy/fetch-http-handler';
|
|
17
|
-
import '@smithy/protocol-http';
|
|
13
|
+
import '../service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
18
14
|
import '../service/utils/freshnessColorDisplay.mjs';
|
|
19
15
|
import '@xstate/react';
|
|
20
16
|
import '../providers/FaceLivenessDetectorProvider.mjs';
|
|
@@ -9,12 +9,8 @@ import '@tensorflow-models/face-detection';
|
|
|
9
9
|
import '@tensorflow/tfjs-backend-wasm';
|
|
10
10
|
import '@tensorflow/tfjs-backend-cpu';
|
|
11
11
|
import '@aws-amplify/core/internals/utils';
|
|
12
|
-
import 'aws-amplify/auth';
|
|
13
12
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
14
|
-
import '
|
|
15
|
-
import '@smithy/eventstream-serde-browser';
|
|
16
|
-
import '@smithy/fetch-http-handler';
|
|
17
|
-
import '@smithy/protocol-http';
|
|
13
|
+
import '../service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
18
14
|
import '../service/utils/freshnessColorDisplay.mjs';
|
|
19
15
|
import { Toast } from './Toast.mjs';
|
|
20
16
|
import { Overlay } from './Overlay.mjs';
|
|
@@ -7,12 +7,8 @@ import '@tensorflow-models/face-detection';
|
|
|
7
7
|
import '@tensorflow/tfjs-backend-wasm';
|
|
8
8
|
import '@tensorflow/tfjs-backend-cpu';
|
|
9
9
|
import '@aws-amplify/core/internals/utils';
|
|
10
|
-
import 'aws-amplify/auth';
|
|
11
10
|
import '@aws-sdk/client-rekognitionstreaming';
|
|
12
|
-
import '
|
|
13
|
-
import '@smithy/eventstream-serde-browser';
|
|
14
|
-
import '@smithy/fetch-http-handler';
|
|
15
|
-
import '@smithy/protocol-http';
|
|
11
|
+
import '../service/utils/createStreamingClient/createStreamingClient.mjs';
|
|
16
12
|
import '../service/utils/freshnessColorDisplay.mjs';
|
|
17
13
|
import { useLivenessActor } from '../hooks/useLivenessActor.mjs';
|
|
18
14
|
import { createLivenessSelector, useLivenessSelector } from '../hooks/useLivenessSelector.mjs';
|
package/dist/esm/version.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var utilFormatUrl = require('@aws-sdk/util-format-url');
|
|
|
17
17
|
var eventstreamSerdeBrowser = require('@smithy/eventstream-serde-browser');
|
|
18
18
|
var fetchHttpHandler = require('@smithy/fetch-http-handler');
|
|
19
19
|
var protocolHttp = require('@smithy/protocol-http');
|
|
20
|
+
var signatureV4 = require('@smithy/signature-v4');
|
|
20
21
|
var uiReact = require('@aws-amplify/ui-react');
|
|
21
22
|
var ui = require('@aws-amplify/ui');
|
|
22
23
|
var internal = require('@aws-amplify/ui-react/internal');
|
|
@@ -781,7 +782,7 @@ class VideoRecorder {
|
|
|
781
782
|
}
|
|
782
783
|
}
|
|
783
784
|
|
|
784
|
-
const VERSION = '3.0.
|
|
785
|
+
const VERSION = '3.0.15';
|
|
785
786
|
|
|
786
787
|
const BASE_USER_AGENT = `ui-react-liveness/${VERSION}`;
|
|
787
788
|
const getLivenessUserAgent = () => {
|
|
@@ -980,6 +981,75 @@ class CustomWebSocketFetchHandler {
|
|
|
980
981
|
}
|
|
981
982
|
}
|
|
982
983
|
|
|
984
|
+
const isCredentialsProvider = (credentialsProvider) => typeof credentialsProvider === 'function';
|
|
985
|
+
// the return interface of `fetchAuthSession` includes `credentials` as
|
|
986
|
+
// optional, but `credentials` is always returned. If `fetchAuthSession`
|
|
987
|
+
// is called for an unauthenticated end user, values of `accessKeyId`
|
|
988
|
+
// and `secretAccessKey` are `undefined`
|
|
989
|
+
const isCredentials = (credentials) => !!(credentials?.accessKeyId && credentials?.secretAccessKey);
|
|
990
|
+
/**
|
|
991
|
+
* Resolves the `credentials` param to be passed to `RekognitionStreamingClient` which accepts either:
|
|
992
|
+
* - a `credentials` object
|
|
993
|
+
* - a `credentialsProvider` callback
|
|
994
|
+
*
|
|
995
|
+
* @param credentialsProvider optional `credentialsProvider` callback
|
|
996
|
+
* @returns {Promise<AwsCredentials | AwsCredentialProvider>} `credentials` object or valid `credentialsProvider` callback
|
|
997
|
+
*/
|
|
998
|
+
async function resolveCredentials(credentialsProvider) {
|
|
999
|
+
const hasCredentialsProvider = isCredentialsProvider(credentialsProvider);
|
|
1000
|
+
if (hasCredentialsProvider) {
|
|
1001
|
+
return credentialsProvider;
|
|
1002
|
+
}
|
|
1003
|
+
if (credentialsProvider && !hasCredentialsProvider) {
|
|
1004
|
+
throw new Error('Invalid credentialsProvider');
|
|
1005
|
+
}
|
|
1006
|
+
try {
|
|
1007
|
+
const result = (await auth.fetchAuthSession()).credentials;
|
|
1008
|
+
if (isCredentials(result)) {
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
1011
|
+
throw new Error('Missing credentials');
|
|
1012
|
+
}
|
|
1013
|
+
catch (e) {
|
|
1014
|
+
const { message } = e;
|
|
1015
|
+
throw new Error(`Invalid credentials: ${message}`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// override aws sdk default value of 60
|
|
1020
|
+
const REQUEST_EXPIRY = 299;
|
|
1021
|
+
class Signer extends signatureV4.SignatureV4 {
|
|
1022
|
+
presign(request, options) {
|
|
1023
|
+
return super.presign(request, {
|
|
1024
|
+
...options,
|
|
1025
|
+
expiresIn: REQUEST_EXPIRY,
|
|
1026
|
+
// `headers` that should not be signed. Liveness WebSocket
|
|
1027
|
+
// request omits `headers` except for required `host` header. Signature
|
|
1028
|
+
// could be a mismatch if other `headers` are signed
|
|
1029
|
+
unsignableHeaders: new Set(Object.keys(request.headers).filter((header) => header !== 'host')),
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
const CONNECTION_TIMEOUT = 10000;
|
|
1035
|
+
const CUSTOM_USER_AGENT = `${utils.getAmplifyUserAgent()} ${getLivenessUserAgent()}`;
|
|
1036
|
+
async function createStreamingClient({ credentialsProvider, endpointOverride, region, }) {
|
|
1037
|
+
const credentials = await resolveCredentials(credentialsProvider);
|
|
1038
|
+
const clientconfig = {
|
|
1039
|
+
credentials,
|
|
1040
|
+
customUserAgent: CUSTOM_USER_AGENT,
|
|
1041
|
+
region,
|
|
1042
|
+
requestHandler: new CustomWebSocketFetchHandler({
|
|
1043
|
+
connectionTimeout: CONNECTION_TIMEOUT,
|
|
1044
|
+
}),
|
|
1045
|
+
signerConstructor: Signer,
|
|
1046
|
+
};
|
|
1047
|
+
if (endpointOverride) {
|
|
1048
|
+
clientconfig.endpointProvider = () => ({ url: new URL(endpointOverride) });
|
|
1049
|
+
}
|
|
1050
|
+
return new clientRekognitionstreaming.RekognitionStreamingClient(clientconfig);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
983
1053
|
const TIME_SLICE = 1000;
|
|
984
1054
|
function isBlob(obj) {
|
|
985
1055
|
return obj.arrayBuffer !== undefined;
|
|
@@ -1009,9 +1079,7 @@ class LivenessStreamProvider {
|
|
|
1009
1079
|
this.videoRecorder.start(TIME_SLICE);
|
|
1010
1080
|
}
|
|
1011
1081
|
sendClientInfo(clientInfo) {
|
|
1012
|
-
this.videoRecorder.dispatch(new MessageEvent('clientSesssionInfo', {
|
|
1013
|
-
data: { clientInfo },
|
|
1014
|
-
}));
|
|
1082
|
+
this.videoRecorder.dispatch(new MessageEvent('clientSesssionInfo', { data: { clientInfo } }));
|
|
1015
1083
|
}
|
|
1016
1084
|
async stopVideo() {
|
|
1017
1085
|
await this.videoRecorder.stop();
|
|
@@ -1023,32 +1091,15 @@ class LivenessStreamProvider {
|
|
|
1023
1091
|
if (this.videoRecorder.getState() === 'recording') {
|
|
1024
1092
|
await this.stopVideo();
|
|
1025
1093
|
}
|
|
1026
|
-
this.videoRecorder.dispatch(new MessageEvent('endStreamWithCode', {
|
|
1027
|
-
data: { code: code },
|
|
1028
|
-
}));
|
|
1094
|
+
this.videoRecorder.dispatch(new MessageEvent('endStreamWithCode', { data: { code } }));
|
|
1029
1095
|
return;
|
|
1030
1096
|
}
|
|
1031
1097
|
async init() {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
}
|
|
1036
|
-
const clientconfig = {
|
|
1037
|
-
credentials,
|
|
1098
|
+
this._client = await createStreamingClient({
|
|
1099
|
+
credentialsProvider: this.credentialProvider,
|
|
1100
|
+
endpointOverride: this.endpointOverride,
|
|
1038
1101
|
region: this.region,
|
|
1039
|
-
|
|
1040
|
-
requestHandler: new CustomWebSocketFetchHandler({
|
|
1041
|
-
connectionTimeout: 10000,
|
|
1042
|
-
}),
|
|
1043
|
-
};
|
|
1044
|
-
if (this.endpointOverride) {
|
|
1045
|
-
const override = this.endpointOverride;
|
|
1046
|
-
clientconfig.endpointProvider = () => {
|
|
1047
|
-
const url = new URL(override);
|
|
1048
|
-
return { url };
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
this._client = new clientRekognitionstreaming.RekognitionStreamingClient(clientconfig);
|
|
1102
|
+
});
|
|
1052
1103
|
this.responseStream = await this.startLivenessVideoConnection();
|
|
1053
1104
|
}
|
|
1054
1105
|
// Creates a generator from a stream of video chunks and livenessActionDocuments and yields VideoEvent and ClientEvents
|
|
@@ -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
|
-
*
|
|
3
|
-
*
|
|
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
|
|
14
|
-
(identityProperties?: Record<string, any>): Promise<IdentityT>;
|
|
15
|
-
}
|
|
16
|
-
export type AwsCredentialProvider = IdentityProvider<AwsTemporaryCredentials>;
|
|
15
|
+
export type AwsCredentialProvider = IdentityProvider<AwsCredentials>;
|
package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/Signer.d.ts
ADDED
|
@@ -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 {};
|
package/dist/types/components/FaceLivenessDetector/service/utils/createStreamingClient/index.d.ts
ADDED
|
@@ -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>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.
|
|
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.
|
|
3
|
+
"version": "3.0.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -54,6 +54,7 @@
|
|
|
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": "
|
|
84
|
+
"limit": "280 kB"
|
|
84
85
|
}
|
|
85
86
|
]
|
|
86
87
|
}
|