cordova-plugin-scanbot-sdk
Advanced tools
Comparing version 4.14.2-beta6 to 4.14.2-beta7
@@ -7,3 +7,3 @@ | ||
const version = "1.28.0"; | ||
const version = "1.28.1"; | ||
const url = `https://download.scanbot.io/sdk/ios/scanbot-ios-sdk${version}.zip`; | ||
@@ -10,0 +10,0 @@ const zipFile = "sdk-ios.zip"; |
{ | ||
"name": "cordova-plugin-scanbot-sdk", | ||
"title": "Scanbot Document and Barcode Scanner SDK for Cordova", | ||
"version": "4.14.2-beta6", | ||
"version": "4.14.2-beta7", | ||
"description": "Cordova Plugin for the Scanbot Document and Barcode Scanner SDK", | ||
@@ -6,0 +6,0 @@ "cordova": { |
@@ -10,3 +10,3 @@ const validLicense = "<VALID_LICENSE>"; | ||
const github_token = '<GITHUB_TOKEN>'; | ||
const assets_url = '<ASSETS_URL>'; | ||
const assets_url = 'https://raw.githubusercontent.com/doo/scanbot-test-assets/master/images/docdetector'; | ||
@@ -16,3 +16,2 @@ const config = { | ||
okay: { | ||
config: { licenseKey: validLicense }, | ||
message: "Scanbot SDK initialized.", | ||
@@ -24,3 +23,2 @@ isLicenseValid: true, | ||
trial: { | ||
config: { licenseKey: trialLicense }, | ||
message: "Scanbot SDK initialized. Trial mode activated. You can now test all features for 60 seconds.", | ||
@@ -32,3 +30,2 @@ isLicenseValid: true, | ||
expired: { | ||
config: { licenseKey: expiredLicense }, | ||
isLicenseValid: false, | ||
@@ -38,4 +35,3 @@ licenseStatus: "Expired", | ||
}, | ||
correctOsIos: { | ||
config: { licenseKey: iosLicense }, | ||
correctOs: { | ||
isLicenseValid: true, | ||
@@ -45,4 +41,3 @@ licenseStatus: "Okay", | ||
}, | ||
wrongOsIos: { | ||
config: { licenseKey: androidLicense }, | ||
wrongOs: { | ||
isLicenseValid: false, | ||
@@ -52,16 +47,3 @@ licenseStatus: "WrongOS", | ||
}, | ||
correctOsAndroid: { | ||
config: { licenseKey: androidLicense }, | ||
isLicenseValid: true, | ||
licenseStatus: "Okay", | ||
licenseExpirationDate: Date.now() | ||
}, | ||
wrongOsAndroid: { | ||
config: { licenseKey: iosLicense }, | ||
isLicenseValid: false, | ||
licenseStatus: "WrongOS", | ||
licenseExpirationDate: Date.now() | ||
}, | ||
corrupted: { | ||
config: { licenseKey: corruptedLicense }, | ||
isLicenseValid: false, | ||
@@ -72,3 +54,2 @@ licenseStatus: "Corrupted", | ||
appIdMismatch: { | ||
config: { licenseKey: appIdMismatchLicense }, | ||
isLicenseValid: false, | ||
@@ -84,3 +65,2 @@ licenseStatus: "AppIDMismatch", | ||
// unknown: { | ||
// config: { licenseKey: unknownLicense }, | ||
// isLicenseValid: false, | ||
@@ -199,5 +179,13 @@ // licenseStatus: "Unknown", | ||
module.exports = { | ||
validLicense, | ||
trialLicense, | ||
expiredLicense, | ||
iosLicense, | ||
androidLicense, | ||
appIdMismatchLicense, | ||
corruptedLicense, | ||
github_token, | ||
assets_url, | ||
config, | ||
images | ||
} |
const constants = require('./constants') | ||
const SDK = ScanbotSdk.promisify(); | ||
async function initializeSdk(config, algorithm) { | ||
return SDK.initializeSdk(config, algorithm); | ||
async function initializeSdk(licenseKey, documentDetectorMode = 'ML_BASED') { | ||
const config = { | ||
loggingEnabled: true, | ||
licenseKey: licenseKey, | ||
documentDetectorMode: documentDetectorMode | ||
} | ||
return SDK.initializeSdk(config); | ||
} | ||
@@ -36,7 +41,10 @@ | ||
async function saveFile(url, algorithm) { | ||
await initializeSdk(algorithm); | ||
const saveResult = await SDK.Test.saveFile({url: url, token: constants.github_token}); | ||
console.log("save result", saveResult); | ||
return saveResult; | ||
async function saveFile(url) { | ||
try { | ||
const saveResult = await SDK.Test.saveFile({url: url, token: constants.github_token}); | ||
return await saveResult; | ||
} | ||
catch (error) { | ||
console.log('error', error); | ||
} | ||
} | ||
@@ -55,9 +63,22 @@ | ||
const imagePath = await saveImagePath(object); | ||
const detectionResult = await SDK.detectDocument({ | ||
imageFileUri: imagePath, | ||
quality: quality | ||
}); | ||
console.log("detection result", detectionResult); | ||
try { | ||
const detectionResult = await SDK.detectDocument({ | ||
imageFileUri: imagePath, | ||
quality: quality | ||
}); | ||
return await detectionResult; | ||
} | ||
catch (error) { | ||
console.log("error", error); | ||
} | ||
} | ||
return detectionResult.detectionResult; | ||
async function createPage(originalImageFileUri) { | ||
try { | ||
const page = await SDK.createPage({originalImageFileUri: originalImageFileUri}); | ||
return await page; | ||
} | ||
catch (error) { | ||
console.log('error', error); | ||
} | ||
} | ||
@@ -67,9 +88,10 @@ | ||
const imagePath = await saveImagePath(object); | ||
const createResult = await SDK.createPage({originalImageFileUri: imagePath}); | ||
console.log("create result", createResult); | ||
const detectionResult = await SDK.detectDocumentOnPage({page: createResult.page}); | ||
console.log("detection result", detectionResult); | ||
return detectionResult.page.detectionResult; | ||
const createResult = await createPage(imagePath); | ||
try { | ||
const detectionResult = await SDK.detectDocumentOnPage({page: createResult.page}); | ||
return await detectionResult.page.detectionResult; | ||
} | ||
catch (error) { | ||
console.log('error', error); | ||
} | ||
} | ||
@@ -79,8 +101,9 @@ | ||
const savedImage = await saveFile(object.img) | ||
console.log('savedImage', savedImage); | ||
const createPdf = await SDK.createPdf({images: [savedImage.path], pageSize: pageSize}) | ||
console.log('createPdf', createPdf) | ||
return createPdf; | ||
try { | ||
const createPdf = await SDK.createPdf({images: [savedImage.path], pageSize: pageSize}) | ||
return await createPdf; | ||
} | ||
catch (error) { | ||
console.log('error', error); | ||
} | ||
} | ||
@@ -104,13 +127,14 @@ | ||
const savedImage = await saveFile(object.img) | ||
console.log('savedImage', savedImage); | ||
const writeTiff = await SDK.writeTiff({ | ||
images: [savedImage.path], | ||
oneBitEncoded: oneBitEncoded, | ||
dpi: dpi, | ||
compression: compression | ||
}); | ||
console.log('writeTiff', writeTiff) | ||
return writeTiff; | ||
try { | ||
const writeTiff = await SDK.writeTiff({ | ||
images: [savedImage.path], | ||
oneBitEncoded: oneBitEncoded, | ||
dpi: dpi, | ||
compression: compression | ||
}); | ||
return await writeTiff; | ||
} | ||
catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
@@ -136,6 +160,3 @@ | ||
const imagePath = await saveImagePath(object); | ||
const detectionResult = await SDK.detectDocument({ | ||
imageFileUri: imagePath, | ||
quality: quality | ||
}); | ||
const detectionResult = await detectDocument(object, quality); | ||
@@ -142,0 +163,0 @@ var expectedPolygon = object.polygon; |
const constants = require('./constants') | ||
const helpers = require('./helpers') | ||
var config; | ||
exports.defineAutoTests = function () { | ||
beforeAll(function() { | ||
@@ -11,9 +9,76 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 65000; | ||
describe('Initialize SDK Scenarios', function () { | ||
it ('SDK Initialized with Trial License, verify license info is Trial', async () => { | ||
await helpers.initializeSdk(constants.trialLicense); | ||
await helpers.validateLicense(constants.config.license.trial, 1000); | ||
}); | ||
it ('SDK Initialized with Trial License, verify Trial license expires after 60 seconds', async () => { | ||
function sleep(milliseconds) { | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
} | ||
// start app with trial license and validate trial license info is correct | ||
await helpers.initializeSdk(constants.trialLicense); | ||
await helpers.validateLicense(constants.config.license.trial, 1000); | ||
// wait 61 seconds so that trial license is expired | ||
await sleep(61000) | ||
// validate that license is not set | ||
await helpers.validateLicense(constants.config.license.notSet, 15000); | ||
}); | ||
it ('SDK Initialized with Expired License', async () => { | ||
await helpers.initializeSdk(constants.expiredLicense); | ||
await helpers.validateLicense(constants.config.license.expired, 15000); | ||
}); | ||
if (device.platform == "Android") { | ||
it ('SDK Initialized with Android only license for Android device', async () => { | ||
await helpers.initializeSdk(constants.androidLicense); | ||
await helpers.validateLicense(constants.config.license.correctOs, 15000); | ||
}); | ||
it ('SDK Initialization with iOS only license on Android device fails', async () => { | ||
await helpers.initializeSdk(constants.iosLicense); | ||
await helpers.validateLicense(constants.config.license.wrongOs, 15000); | ||
}); | ||
} | ||
if (device.platform == "iOS") { | ||
it ('SDK Initialized with iOS only license for iOS device', async () => { | ||
await helpers.initializeSdk(constants.iosLicense); | ||
await helpers.validateLicense(constants.config.license.correctOs, 15000); | ||
}); | ||
it ('SDK Initialization with Android only license on iOS device fails', async () => { | ||
await helpers.initializeSdk(constants.androidLicense); | ||
await helpers.validateLicense(constants.config.license.wrongOs, 15000); | ||
}); | ||
} | ||
it ('SDK Initialization with a license that has an App ID that does not match the App fails', async () => { | ||
await helpers.initializeSdk(constants.appIdMismatchLicense); | ||
await helpers.validateLicense(constants.config.license.appIdMismatch, 15000); | ||
}); | ||
it ('SDK Initialization with a corrupted license fails', async () => { | ||
await helpers.initializeSdk(constants.corruptedLicense); | ||
await helpers.validateLicense(constants.config.license.corrupted, 15000); | ||
}); | ||
it ('SDK Initialized with Valid License', async () => { | ||
await helpers.initializeSdk(constants.validLicense); | ||
await helpers.validateLicense(constants.config.license.okay, 0); | ||
}); | ||
}); | ||
describe('Document Detection Scenarios:', function () { | ||
beforeAll(async function() { | ||
await helpers.initializeSdk(constants.validLicense); | ||
}); | ||
// TODO: add OK_BARCODE, OK_OFF_CENTER, ERROR_NOTHING_DETECTED, ERROR_TOO_NOISY scenarios | ||
it ('detection result OK, but bad aspect ratio', async () => { | ||
expect(await helpers.detectDocument( | ||
constants.images.image.aspect_ratio, | ||
1000 | ||
)) | ||
expect((await helpers.detectDocument(constants.images.image.aspect_ratio, 1000)).detectionResult) | ||
.toBe(constants.images.image.aspect_ratio.result); | ||
@@ -23,6 +88,3 @@ }); | ||
it ('detection result OK, but bad angles', async () => { | ||
expect(await helpers.detectDocument( | ||
constants.images.image.bad_angles, | ||
1000 | ||
)) | ||
expect((await helpers.detectDocument(constants.images.image.bad_angles, 1000)).detectionResult) | ||
.toBe(constants.images.image.bad_angles.result); | ||
@@ -32,6 +94,3 @@ }); | ||
// it ('detection result Error, too dark', async () => { | ||
// expect(await helpers.detectDocument( | ||
// constants.images.image.dark, | ||
// 1000 | ||
// )) | ||
// expect((await helpers.detectDocument(constants.images.image.dark, 1000)).detectionResult) | ||
// .toBe(constants.images.image.dark.result); | ||
@@ -41,7 +100,3 @@ // }); | ||
// it ('detection result Error, too dark, ML_BASED', async () => { | ||
// expect(await helpers.detectDocument( | ||
// constants.images.image.dark, | ||
// 1000, | ||
// "ML_BASED" | ||
// )) | ||
// expect((await helpers.detectDocument(constants.images.image.dark, 1000, "ML_BASED")).detectionResult) | ||
// .toBe(constants.images.image.dark.result); | ||
@@ -51,6 +106,3 @@ // }); | ||
// it ('detection result OK', async () => { | ||
// expect(await helpers.detectDocument( | ||
// constants.images.image.ok, | ||
// 1000 | ||
// )) | ||
// expect((await helpers.detectDocument(constants.images.image.ok, 1000)).detectionResult) | ||
// .toBe(constants.images.image.ok.result); | ||
@@ -60,6 +112,3 @@ // }); | ||
it ('detection result OK, but too small', async () => { | ||
expect(await helpers.detectDocument( | ||
constants.images.image.small, | ||
1000 | ||
)) | ||
expect((await helpers.detectDocument(constants.images.image.small, 1000)).detectionResult) | ||
.toBe(constants.images.image.small.result); | ||
@@ -70,2 +119,6 @@ }); | ||
describe('Document Detection On Page Scenarios:', function () { | ||
beforeAll(async function() { | ||
await helpers.initializeSdk(constants.validLicense); | ||
}); | ||
// TODO: add OK_BARCODE, OK_OFF_CENTER, ERROR_NOTHING_DETECTED, ERROR_TOO_NOISY scenarios | ||
@@ -99,2 +152,5 @@ it ('detection result OK, but bad aspect ratio', async () => { | ||
describe('Save PDF Scenarios:', function () { | ||
beforeAll(async function() { | ||
await helpers.initializeSdk(constants.validLicense); | ||
}); | ||
@@ -145,2 +201,5 @@ it ('file saved as PDF using FROM_IMAGE size', async () => { | ||
describe('TIFF Scenarios:', function () { | ||
beforeAll(async function() { | ||
await helpers.initializeSdk(constants.validLicense); | ||
}); | ||
@@ -248,2 +307,5 @@ it ('file written as TIFF using NONE compression, encoded, dpi=300', async () => { | ||
describe('Polygon Detection Scenarios:', function () { | ||
beforeAll(async function() { | ||
await helpers.initializeSdk(constants.validLicense); | ||
}); | ||
@@ -284,80 +346,2 @@ it ('Polygon values are valid, OK scenario, ML_BASED', async () => { | ||
}); | ||
describe('Initialize SDK Scenarios', function () { | ||
it ('SDK Initialized with Trial License, verify license info is Trial', async () => { | ||
config = constants.config.license.trial; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 1000); | ||
}); | ||
it ('SDK Initialized with Trial License, verify Trial license expires after 60 seconds', async () => { | ||
function sleep(milliseconds) { | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)) | ||
} | ||
// start app with trial license and validate trial license info is correct | ||
config = constants.config.license.trial; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 1000); | ||
// wait 61 seconds so that trial license is expired | ||
await sleep(61000) | ||
// validate that license is not set | ||
config = constants.config.license.notSet; | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
it ('SDK Initialized with Expired License', async () => { | ||
config = constants.config.license.expired; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
if (device.platform == "Android") { | ||
it ('SDK Initialized with Android only license for Android device', async () => { | ||
config = constants.config.license.correctOsAndroid; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
it ('SDK Initialization with iOS only license on Android device fails', async () => { | ||
config = constants.config.license.wrongOsAndroid; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
} | ||
if (device.platform == "iOS") { | ||
it ('SDK Initialized with iOS only license for iOS device', async () => { | ||
config = constants.config.license.correctOsIos; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
it ('SDK Initialization with Android only license on iOS device fails', async () => { | ||
config = constants.config.license.wrongOsIos; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
} | ||
it ('SDK Initialization with a license that has an App ID that does not match the App fails', async () => { | ||
config = constants.config.license.appIdMismatch; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
it ('SDK Initialization with a corrupted license fails', async () => { | ||
config = constants.config.license.corrupted; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 15000); | ||
}); | ||
it ('SDK Initialized with Valid License', async () => { | ||
config = constants.config.license.okay; | ||
await helpers.initializeSdk(config.config); | ||
await helpers.validateLicense(config, 0); | ||
}); | ||
}); | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
728593
75
3117