-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-2152 Support liveness check (#354)
Added `static` liveness check support in request builder. Added `static` liveness check support in response handler. Updated the IDV example to display the Zoom liveness frames or the Static liveness image as per user's choice.
- Loading branch information
1 parent
47f7274
commit 95ced2a
Showing
9 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/idv_service/session/retrieve/static.liveness.resource.response.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const LivenessResourceResponse = require('./liveness.resource.response'); | ||
const Validation = require('../../../yoti_common/validation'); | ||
const MediaResponse = require('./media.response'); | ||
|
||
class StaticLivenessResourceResponse extends LivenessResourceResponse { | ||
constructor(resource) { | ||
super(resource); | ||
|
||
const { image } = resource; | ||
|
||
if (image) { | ||
const { media } = image; | ||
|
||
Validation.isPlainObject(media, 'media'); | ||
|
||
this.image = new MediaResponse(media); | ||
} | ||
} | ||
|
||
/** | ||
* @returns {MediaResponse} | ||
*/ | ||
getImage() { | ||
return this.image; | ||
} | ||
} | ||
|
||
module.exports = StaticLivenessResourceResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/idv_service/session/retrieve/static.liveness.resource.response.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const StaticLivenessResourceResponse = require('../../../../src/idv_service/session/retrieve/static.liveness.resource.response'); | ||
const MediaResponse = require('../../../../src/idv_service/session/retrieve/media.response'); | ||
|
||
describe('StaticLivenessResourceResponse', () => { | ||
let staticLivenessResourceResponse; | ||
|
||
beforeEach(() => { | ||
staticLivenessResourceResponse = new StaticLivenessResourceResponse({ | ||
liveness_type: 'some-liveness-type', | ||
id: 'some-id', | ||
image: { | ||
media: {}, | ||
}, | ||
}); | ||
}); | ||
|
||
describe('#getId', () => { | ||
it('should return ID', () => { | ||
expect(staticLivenessResourceResponse.getId()).toBe('some-id'); | ||
}); | ||
}); | ||
|
||
describe('#getLivenessType', () => { | ||
it('should return liveness type', () => { | ||
expect(staticLivenessResourceResponse.getLivenessType()).toBe('some-liveness-type'); | ||
}); | ||
}); | ||
|
||
describe('#getImage', () => { | ||
it('should return media', () => { | ||
expect(staticLivenessResourceResponse.getImage()).toBeInstanceOf(MediaResponse); | ||
}); | ||
}); | ||
}); |