@capturebridge/sdk 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Camera.js +68 -68
- package/CanonCamera.js +25 -25
- package/CaptureBridge.js +162 -162
- package/CapturePlugin.js +79 -79
- package/Common.js +98 -98
- package/Device.js +451 -451
- package/ICAO.js +70 -70
- package/IFace.js +274 -274
- package/Logs.js +129 -129
- package/MockCamera.js +10 -10
- package/Plugin.js +298 -298
- package/Scanner.js +64 -64
- package/SignatureTablet.js +109 -109
- package/SignatureTabletWidgets.js +153 -153
- package/StreamingCapturePlugin.js +121 -121
- package/TopazSigGem.js +25 -25
- package/package.json +1 -1
package/ICAO.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import Plugin from './Plugin.js'
|
|
2
|
-
import { BASE_URL } from './Common.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ICAO
|
|
6
|
-
* @classdesc Class for invoking ICAO checks on an image
|
|
7
|
-
*
|
|
8
|
-
* @see {@link CanonScanner}
|
|
9
|
-
*/
|
|
10
|
-
class ICAO extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* Instantiate an ICAO plugin
|
|
13
|
-
* @constructor
|
|
14
|
-
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
15
|
-
* @param {string|object} plugin - The ID of the desired plugin to use for
|
|
16
|
-
* this instance or an existing Plugin object. The plugin must support the
|
|
17
|
-
* "icao" method.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const icao = new ICAO('capture_verify_iface')
|
|
21
|
-
*/
|
|
22
|
-
constructor (plugin, baseUrl = BASE_URL) {
|
|
23
|
-
super(plugin, baseUrl)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Check the ICAO compliance of an image
|
|
28
|
-
* @param {string} image - A base64 encoded image.
|
|
29
|
-
*
|
|
30
|
-
* @param {string|bool} [crop] - If falsy image will not be cropped, otherwise
|
|
31
|
-
* the value will be interpreted as the preferred crop method which will vary
|
|
32
|
-
* by plugin implementation.
|
|
33
|
-
*
|
|
34
|
-
* @returns {object} Results of the ICAO check, this may vary by plugin
|
|
35
|
-
* implementation.
|
|
36
|
-
*
|
|
37
|
-
* @async
|
|
38
|
-
* @example
|
|
39
|
-
* // Take a photo with a Canon Camera and perform ICAO checks on the
|
|
40
|
-
* // returned image
|
|
41
|
-
* const camera = new CanonCamera()
|
|
42
|
-
* const photo = await camera.takePhoto('base64')
|
|
43
|
-
* const icao = new ICAO('capture_verify_iface')
|
|
44
|
-
* const results = await icao.check(photo)
|
|
45
|
-
* const img = document.createElement('img')
|
|
46
|
-
* img.src = 'data:image/jpeg;base64,' + results.cropped
|
|
47
|
-
* console.log(`found ${result.faces_found} faces in the image`)
|
|
48
|
-
* document.body.appendChild(img)
|
|
49
|
-
*/
|
|
50
|
-
async check (image, cropMethod = false) {
|
|
51
|
-
const body = {
|
|
52
|
-
base64: image,
|
|
53
|
-
crop: Boolean(cropMethod),
|
|
54
|
-
crop_method: cropMethod || undefined
|
|
55
|
-
}
|
|
56
|
-
const options = {
|
|
57
|
-
method: 'POST',
|
|
58
|
-
mode: 'cors',
|
|
59
|
-
headers: {
|
|
60
|
-
'Content-Type': 'application/json'
|
|
61
|
-
},
|
|
62
|
-
body: JSON.stringify(body)
|
|
63
|
-
}
|
|
64
|
-
const url = `${this.baseUrl}/plugin/${this.id}/icao`
|
|
65
|
-
const response = await fetch(url, options)
|
|
66
|
-
return await response.json()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default ICAO
|
|
1
|
+
import Plugin from './Plugin.js'
|
|
2
|
+
import { BASE_URL } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ICAO
|
|
6
|
+
* @classdesc Class for invoking ICAO checks on an image
|
|
7
|
+
*
|
|
8
|
+
* @see {@link CanonScanner}
|
|
9
|
+
*/
|
|
10
|
+
class ICAO extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* Instantiate an ICAO plugin
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
15
|
+
* @param {string|object} plugin - The ID of the desired plugin to use for
|
|
16
|
+
* this instance or an existing Plugin object. The plugin must support the
|
|
17
|
+
* "icao" method.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const icao = new ICAO('capture_verify_iface')
|
|
21
|
+
*/
|
|
22
|
+
constructor (plugin, baseUrl = BASE_URL) {
|
|
23
|
+
super(plugin, baseUrl)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Check the ICAO compliance of an image
|
|
28
|
+
* @param {string} image - A base64 encoded image.
|
|
29
|
+
*
|
|
30
|
+
* @param {string|bool} [crop] - If falsy image will not be cropped, otherwise
|
|
31
|
+
* the value will be interpreted as the preferred crop method which will vary
|
|
32
|
+
* by plugin implementation.
|
|
33
|
+
*
|
|
34
|
+
* @returns {object} Results of the ICAO check, this may vary by plugin
|
|
35
|
+
* implementation.
|
|
36
|
+
*
|
|
37
|
+
* @async
|
|
38
|
+
* @example
|
|
39
|
+
* // Take a photo with a Canon Camera and perform ICAO checks on the
|
|
40
|
+
* // returned image
|
|
41
|
+
* const camera = new CanonCamera()
|
|
42
|
+
* const photo = await camera.takePhoto('base64')
|
|
43
|
+
* const icao = new ICAO('capture_verify_iface')
|
|
44
|
+
* const results = await icao.check(photo)
|
|
45
|
+
* const img = document.createElement('img')
|
|
46
|
+
* img.src = 'data:image/jpeg;base64,' + results.cropped
|
|
47
|
+
* console.log(`found ${result.faces_found} faces in the image`)
|
|
48
|
+
* document.body.appendChild(img)
|
|
49
|
+
*/
|
|
50
|
+
async check (image, cropMethod = false) {
|
|
51
|
+
const body = {
|
|
52
|
+
base64: image,
|
|
53
|
+
crop: Boolean(cropMethod),
|
|
54
|
+
crop_method: cropMethod || undefined
|
|
55
|
+
}
|
|
56
|
+
const options = {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
mode: 'cors',
|
|
59
|
+
headers: {
|
|
60
|
+
'Content-Type': 'application/json'
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify(body)
|
|
63
|
+
}
|
|
64
|
+
const url = `${this.baseUrl}/plugin/${this.id}/icao`
|
|
65
|
+
const response = await fetch(url, options)
|
|
66
|
+
return await response.json()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default ICAO
|