New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(liveness/nolight): pass in multiple challenges #5047
Conversation
|
@@ -1289,7 +1301,15 @@ const responseStreamActor = async (callback: StreamActorCallback) => { | |||
try { | |||
const stream = await responseStream; | |||
for await (const event of stream) { | |||
if (isServerSesssionInformationEvent(event)) { | |||
if (isChallengeEvent(event)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New SDK has new ChallengeEvent
on the liveness stream where we can retrieve the challenge type.
@@ -20,13 +20,21 @@ import { | |||
RequestHandler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is copied (and refactored slightly for our tsconfig) from the updated sdk found here under SDK Previews / Javascript V3.
@@ -20,6 +20,25 @@ import { | |||
REDUCED_THRESHOLD_MOBILE, | |||
} from './constants'; | |||
|
|||
/* Returns the current challenge from the session */ | |||
function getChallengeFromSessionInformation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used alongside functions like getOvalDetailsFromSessionInformation
which need to check the challenge type before getting information from the session.
(As opposed to getColorsSequencesFromSessionInformation
which is only used for lights flow)
Description of changes
Updates the sdk to the newer version which accepts multiple challenge types, and pass in multiple challenges in the StartFaceLivenessSession API call.
In the state machine, retrieves the selected challenge type from the websocket and event and adds it to the context. Add some utils related to this.
Update the
CustomWebSocketFetchHandler
to the later version included with the new sdk. (The current version of this handler on main is copied directly from the sdk; it was updated in the later version so re-copied it over.)Refactor
liveness.ts
to work with multiple challenge types.*This code won't work on it's own. It sends + receives the challenge type, checks for the challenge type, and gets the session information and oval details, but will need the no-light state machine to prevent it from entering the light flashing stage (where it errors out currently).
Issue #, if available
Description of how you validated changes
Checklist
yarn test
passes and tests are updated/addedsideEffects
field updatedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.