aws-amplify / amplify-ui-swift-liveness

This repository offers a UI component for Amazon Rekognition Face Liveness, enabling developers to ensure that only authentic users, and not bad actors using spoofs, can access their services.
https://ui.docs.amplify.aws/swift/connected-components/liveness
Apache License 2.0
8 stars 18 forks source link

Receiving FaceLiveness.FaceLivenessDetectionError Code 1 #151

Open haarj opened 1 week ago

haarj commented 1 week ago

Describe the bug

Some of my users are receiving FaceLiveness.FaceLivenessDetectionError Code 1, which in the iOS SDK is a session not found error in FaceLivenessDetectionError.swift file, public static let sessionNotFound = FaceLivenessDetectionError( code: 1, message: "Session not found.", recoverySuggestion: "Enter a valid session ID." )

We are creating a sessionID server side, passing the session ID to the FaceLivenessDetectorView constructor and receive the above error.

Steps To Reproduce

Follow steps above

Expected behavior

Faceliveness Detector view sequence starts and accepts valid sessionID.

Swift Liveness Version

1.2.14

Xcode version

15.4

Relevant log output

No response

Is this a regression?

No

Regression additional context

No response

OS Version

17.5.1

Device

iPhone 11 Pro

Specific to simulators

No

Additional context

This is intermittent. This happens to some users and we are not sure why.

ruisebas commented 6 days ago

Hi @haarj, thanks for opening this issue!

Would you mind telling us how you are triggering the creation of the session id on the server side? Also, do you have any relevant logs that you can share?

Thanks!

haarj commented 6 days ago

Hey @ruisebas sure thing. I can't reproduce it on my side. It happens to my users sometimes and it's hard to know why or acquire logs.

Here is how I am calling it server side.

const rekClient = new Rekognition({
      region: "us-east-1",
      credentials: {
            accessKeyId: rekAccessKeyID,    
            secretAccessKey: process.env.AMAZON_REKOGNITION_SECRET_KEY
        }
    });
const response = await rekClient.createFaceLivenessSession().promise();
const sessionId = response.SessionId;
console.log("SessionId:", sessionId);
ruisebas commented 1 day ago

Thanks for providing the code. I assume you are triggering this server code in your app, for example with a Amplify.API.post call, right?

Are you certain that you are receiving a valid response from the service before attempting to show FaceLivenessDetectorView? Or putting it in another way, are you handling error responses so that FaceLivenessDetectorView is not being invoked with an old or default sessionId?

haarj commented 1 day ago

Hey @ruisebas my server side code is always returning a "valid" session Id, which is then passed back to the app and then passed to the FaceLivenessDetectorView immediately. What makes this a valid or invalid session ID I'm not sure. Is there a race condition happening where the sessionID I am creating server-side is not recognized by the detector view yet, maybe?