I am doing the sdk implementation, the idea is not to use a front-end but to use only the back-end and send the videos from a s3 bucket, but I have a lot of problems trying to implement the "startFaceLivenessSession", this is what I have:
createFaceLivenessSession:
async function createFaceLivenessSession(): Promise<any> {
const client = new RekognitionClient({ region: 'us-east-1' });
const command = new CreateFaceLivenessSessionCommand({});
const response = await client.send(command);
return response.SessionId
}
that works very well and returns the session, and now I am trying to log in with StarFaceLivenessSession like this:
async function startFaceLivenessSessionWithLocalVideo() {
try {
const client = new RekognitionStreamingClient({ region: 'us-east-1' });
const videoFilePath = "/Users/karenortiz/Downloads/video1.mp4"; // Reemplaza con la ruta de tu video
const videoBuffer = readFileSync(videoFilePath);
const videoArray = new Uint8Array(videoBuffer);
const sessionId = await createFaceLivenessSession();
const input = {
SessionId: sessionId,
VideoWidth: "1920", // Ancho del video
VideoHeight: "1080", // Alto del video
ChallengeVersions: "v1", // Versión del desafío
Video: {
Bytes: videoArray,
},
};
const command = new StartFaceLivenessSessionCommand(input);
const response = await client.send(command);
console.log('Respuesta de StartFaceLivenessSession:', response);
} catch (error) {
console.error('Error al iniciar la sesión de liveness:', error);
}
}
it's something very simple because I don't know much about the subject but I have this error:
TypeError: headers[headerName].trim is not a function
at getCanonicalHeaders (/Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@smithy/signature-v4/dist-cjs/getCanonicalHeaders.js:20:62)
at SignatureV4.signRequest (/Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@smithy/signature-v4/dist-cjs/SignatureV4.js:120:80)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:16:18
at async /Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46
at async /Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@aws-sdk/middleware-websocket/dist-cjs/middleware-session-id.js:8:22
at async /Users/karenortiz/Desktop/Karen/LivenessSpike/puebaLiveness/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26 {
and then I used python and changed my AWS account in case it was a credentials issue but when I use boto3 I can't create a client with start_face_liveness_session().
def start_face_liveness_session():
"""method for create a liveness session"""
LOGGER.info('START SPIKE FACIAL LIVENESS')
try:
video_bytes = download_video_from_s3(bucket_name, object_key)
if video_bytes is not None:
session_id = create_face_liveness_session()
LOGGER.info("session_id:", session_id)
input_params = {
'SessionId': session_id,
'VideoWidth': '1920',
'VideoHeight': '1080',
'ChallengeVersions': 'v1',
'Video': {
'Bytes': video_bytes,
},
}
response = client_streaming.start_face_liveness_session(**input_params)
LOGGER.info("Respuesta de StartFaceLivenessSession:", response)
return 'OK'
except ClientError as e:
LOGGER.info("Error en startFaceLivenessSession:", e)
return None
so please I need help, I don't know if I'm missing something or if I just can't use only the backend.