Skip to content

Commit

Permalink
Merge pull request #248 from getyoti/release/3.13.1
Browse files Browse the repository at this point in the history
Release 3.13.1
  • Loading branch information
davidgrayston authored Nov 5, 2020
2 parents b55a6bb + fd01cef commit ddd9410
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
8 changes: 1 addition & 7 deletions examples/doc-scan/src/controllers/index.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@ async function createSession() {
.build()
)
.withRequiredDocument(
(new RequiredIdDocumentBuilder())
.withFilter(
(new OrthogonalRestrictionsFilterBuilder())
.withWhitelistedDocumentTypes(['DRIVING_LICENCE'])
.build()
)
.build()
(new RequiredIdDocumentBuilder()).build()
)
.withRequiredDocument(
(new RequiredSupplementaryDocumentBuilder())
Expand Down
10 changes: 8 additions & 2 deletions examples/doc-scan/src/controllers/media.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ module.exports = async (req, res) => {
req.query.mediaId
);

res.set('Content-Type', media.getMimeType());
res.status(200).end(media.getContent().toBuffer());
const { buffer } = media.getContent();

if (buffer.length === 0) {
res.status(204).end(buffer);
} else {
res.set('Content-Type', media.getMimeType());
res.status(200).end(buffer);
}
} catch (error) {
res.render('pages/error', { error });
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yoti",
"version": "3.13.0",
"version": "3.13.1",
"description": "Yoti NodeJS SDK for back-end integration",
"author": "Yoti LTD <[email protected]> (https://www.yoti.com/developers)",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sonar.organization = getyoti

sonar.projectKey = getyoti:node
sonar.projectName = Node SDK
sonar.projectVersion = 3.13.0
sonar.projectVersion = 3.13.1
sonar.exclusions=tests/**,examples/**,node_modules/**,coverage/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.verbose = true
sonar.cpd.exclusions=**/supplementary.document.resource.response.js
sonar.cpd.exclusions=**/supplementary.document.resource.response.js
2 changes: 1 addition & 1 deletion src/doc_scan_service/doc.scan.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class DocScanService {
.then((response) => {
try {
const contentType = response.getHeaders()['content-type'];
const mimeType = contentType ? contentType.split(';')[0] : null;
const mimeType = contentType ? contentType.split(';')[0] : '';

let content = response.getBody();
if (!Buffer.isBuffer(content)) {
Expand Down
12 changes: 7 additions & 5 deletions tests/doc_scan_service/doc.scan.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,18 @@ describe('DocScanService', () => {
});
});

describe('when content type is not available', () => {
it('should reject', (done) => {
describe('when response has no content', () => {
it('should return empty media', (done) => {
nock(config.yoti.docScanApi)
.get(MEDIA_URI)
.reply(200, '');
.reply(204, '');

docScanService
.getMediaContent(SESSION_ID, MEDIA_ID)
.catch((err) => {
expect(err.message).toBe('mimeType must be a string');
.then((result) => {
expect(result).toBeInstanceOf(Media);
expect(result.getContent().buffer).toHaveLength(0);
expect(result.getMimeType()).toBe('');
done();
})
.catch(done);
Expand Down

0 comments on commit ddd9410

Please sign in to comment.