@regulaforensics/document-reader 8.2.186-beta → 8.3.242-beta
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/RNDocumentReader.podspec +2 -2
- package/android/build.gradle +1 -1
- package/android/cordova.gradle +1 -1
- package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +4 -0
- package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +6 -0
- package/examples/capacitor/README.md +10 -0
- package/examples/capacitor/index.html +2 -7
- package/examples/capacitor/index.tsx +39 -0
- package/examples/capacitor/package.json +3 -3
- package/examples/capacitor/scripts/setup.sh +4 -0
- package/examples/capacitor/src/extra/bt_device.tsx +7 -6
- package/examples/capacitor/src/extra/custom_rfid.tsx +29 -42
- package/examples/capacitor/src/main.css +4 -1
- package/examples/capacitor/src/main.html +1 -4
- package/examples/capacitor/src/main.tsx +85 -86
- package/examples/cordova/README.md +10 -0
- package/examples/cordova/config.xml +6 -2
- package/examples/cordova/package-lock.json +459 -1
- package/examples/cordova/package.json +5 -4
- package/examples/cordova/scripts/bundle.sh +4 -0
- package/examples/cordova/www/bootstrap.js +30 -0
- package/examples/cordova/www/images/portrait.png +0 -0
- package/examples/cordova/www/index.html +2 -17
- package/examples/cordova/www/index.js +30 -0
- package/examples/cordova/www/src/extra/bt_device.js +32 -0
- package/examples/cordova/www/src/extra/custom_rfid.js +60 -0
- package/examples/cordova/www/src/main.css +11 -7
- package/examples/cordova/www/src/main.html +7 -32
- package/examples/cordova/www/src/main.js +154 -31
- package/examples/ionic/README.md +10 -0
- package/examples/ionic/config.xml +11 -4
- package/examples/ionic/index.ts +41 -4
- package/examples/ionic/package-lock.json +1862 -1638
- package/examples/ionic/package.json +3 -6
- package/examples/ionic/src/extra/bt_device.ts +33 -0
- package/examples/ionic/src/extra/custom_rfid.ts +61 -0
- package/examples/ionic/src/images/portrait.png +0 -0
- package/examples/ionic/src/main.css +11 -7
- package/examples/ionic/src/main.html +36 -61
- package/examples/ionic/src/main.ts +158 -50
- package/examples/react_native/README.md +10 -0
- package/examples/react_native/app.config.ts +3 -1
- package/examples/react_native/images/portrait.png +0 -0
- package/examples/react_native/index.tsx +34 -6
- package/examples/react_native/package-lock.json +476 -421
- package/examples/react_native/package.json +10 -10
- package/examples/react_native/src/extra/bt_device.tsx +34 -0
- package/examples/react_native/src/extra/custom_rfid.tsx +62 -0
- package/examples/react_native/src/main.css +11 -7
- package/examples/react_native/src/main.html +7 -32
- package/examples/react_native/src/main.tsx +152 -27
- package/ios/RGLWConfig.m +4 -0
- package/ios/RGLWMain.m +10 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/www/capacitor/index.js +32 -16
- package/www/capacitor/params/customization/Customization.js +7 -0
- package/www/capacitor/params/process_params/ProcessParams.js +7 -0
- package/www/capacitor/results/visual_results/FieldType.js +3 -1
- package/www/cordova.js +49 -17
- package/www/react-native/index.js +32 -16
- package/www/react-native/internal/bridge.js +1 -1
- package/www/react-native/params/customization/Customization.js +7 -0
- package/www/react-native/params/process_params/ProcessParams.js +7 -0
- package/www/react-native/results/visual_results/FieldType.js +3 -1
- package/www/types/index.d.ts +14 -8
- package/www/types/params/customization/Customization.d.ts +5 -0
- package/www/types/params/process_params/ProcessParams.d.ts +4 -0
- package/www/types/results/visual_results/FieldType.d.ts +5 -1
package/RNDocumentReader.podspec
CHANGED
|
@@ -5,7 +5,7 @@ source = File.join(__dir__, 'ios')
|
|
|
5
5
|
|
|
6
6
|
Pod::Spec.new do |s|
|
|
7
7
|
s.name = 'RNDocumentReader'
|
|
8
|
-
s.version = '8.
|
|
8
|
+
s.version = '8.3.242-beta'
|
|
9
9
|
s.summary = package['description']
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
|
|
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.ios.deployment_target = '13.0'
|
|
17
17
|
s.source_files = 'ios/**/*.{h,m}'
|
|
18
18
|
s.exclude_files = [ 'ios/CVDDocumentReader.h', 'ios/CVDDocumentReader.m' ]
|
|
19
|
-
s.dependency 'DocumentReader', '8.
|
|
19
|
+
s.dependency 'DocumentReader', '8.2.4934'
|
|
20
20
|
s.dependency 'React'
|
|
21
21
|
end
|
package/android/build.gradle
CHANGED
|
@@ -29,7 +29,7 @@ dependencies {
|
|
|
29
29
|
//noinspection GradleDynamicVersion
|
|
30
30
|
implementation 'com.facebook.react:react-native:+'
|
|
31
31
|
//noinspection GradleDependency
|
|
32
|
-
implementation('com.regula.documentreader:api:8.
|
|
32
|
+
implementation('com.regula.documentreader:api:8.2.11679'){
|
|
33
33
|
transitive = true
|
|
34
34
|
}
|
|
35
35
|
}
|
package/android/cordova.gradle
CHANGED
|
@@ -137,6 +137,7 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
|
|
|
137
137
|
"generateDTCVC" -> processParams.generateDTCVC = v as Boolean
|
|
138
138
|
"strictDLCategoryExpiry" -> processParams.strictDLCategoryExpiry = v as Boolean
|
|
139
139
|
"generateAlpha2Codes" -> processParams.generateAlpha2Codes = v as Boolean
|
|
140
|
+
"disableAuthResolutionFilter" -> processParams.disableAuthResolutionFilter = v as Boolean
|
|
140
141
|
"measureSystem" -> processParams.measureSystem = v.toInt()
|
|
141
142
|
"barcodeParserType" -> processParams.barcodeParserType = v.toInt()
|
|
142
143
|
"perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
|
|
@@ -221,6 +222,7 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
|
|
|
221
222
|
"generateDTCVC" to processParams.generateDTCVC,
|
|
222
223
|
"strictDLCategoryExpiry" to processParams.strictDLCategoryExpiry,
|
|
223
224
|
"generateAlpha2Codes" to processParams.generateAlpha2Codes,
|
|
225
|
+
"disableAuthResolutionFilter" to processParams.disableAuthResolutionFilter,
|
|
224
226
|
"measureSystem" to processParams.measureSystem,
|
|
225
227
|
"barcodeParserType" to processParams.barcodeParserType,
|
|
226
228
|
"perspectiveAngle" to processParams.perspectiveAngle,
|
|
@@ -316,6 +318,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject) = opt
|
|
|
316
318
|
"torchButtonOnImage" -> editor.setTorchImageOn(v.toDrawable())
|
|
317
319
|
"torchButtonOffImage" -> editor.setTorchImageOff(v.toDrawable())
|
|
318
320
|
"livenessAnimationImage" -> editor.setLivenessAnimationImage(v.toDrawable())
|
|
321
|
+
"multipageButtonImage" -> editor.setMultipageButtonImage(v.toDrawable())
|
|
319
322
|
"helpAnimationImageMatrix" -> editor.setHelpAnimationImageMatrix(matrixFromJSON(v as JSONArray?)).setHelpAnimationImageScaleType(ImageView.ScaleType.MATRIX)
|
|
320
323
|
"multipageAnimationFrontImageMatrix" -> editor.setMultipageAnimationFrontImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationFrontImageScaleType(ImageView.ScaleType.MATRIX)
|
|
321
324
|
"multipageAnimationBackImageMatrix" -> editor.setMultipageAnimationBackImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationBackImageScaleType(ImageView.ScaleType.MATRIX)
|
|
@@ -401,6 +404,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
|
|
|
401
404
|
"torchButtonOnImage" to customization.torchImageOnDrawable.toBase64(),
|
|
402
405
|
"torchButtonOffImage" to customization.torchImageOffDrawable.toBase64(),
|
|
403
406
|
"livenessAnimationImage" to customization.livenessAnimationImage.toBase64(),
|
|
407
|
+
"multipageButtonImage" to customization.multipageButtonDrawable.toBase64(),
|
|
404
408
|
"helpAnimationImageMatrix" to generateMatrix(customization.helpAnimationImageMatrix),
|
|
405
409
|
"multipageAnimationFrontImageMatrix" to generateMatrix(customization.multipageAnimationFrontImageMatrix),
|
|
406
410
|
"multipageAnimationBackImageMatrix" to generateMatrix(customization.multipageAnimationBackImageMatrix),
|
|
@@ -55,6 +55,8 @@ fun methodCall(method: String, callback: (Any?) -> Unit): Any = when (method) {
|
|
|
55
55
|
"setTenant" -> setTenant(argsNullable(0))
|
|
56
56
|
"getEnv" -> getEnv(callback)
|
|
57
57
|
"setEnv" -> setEnv(argsNullable(0))
|
|
58
|
+
"getLocale" -> getLocale(callback)
|
|
59
|
+
"setLocale" -> setLocale(argsNullable(0))
|
|
58
60
|
"getFunctionality" -> getFunctionality(callback)
|
|
59
61
|
"setFunctionality" -> setFunctionality(args(0))
|
|
60
62
|
"getProcessParams" -> getProcessParams(callback)
|
|
@@ -160,6 +162,10 @@ fun getEnv(callback: Callback) = callback(Instance().env)
|
|
|
160
162
|
|
|
161
163
|
fun setEnv(tag: String?) = tag.let { Instance().env = it }
|
|
162
164
|
|
|
165
|
+
fun getLocale(callback: Callback) = callback(Instance().locale)
|
|
166
|
+
|
|
167
|
+
fun setLocale(locale: String?) = locale.let { Instance().locale = it }
|
|
168
|
+
|
|
163
169
|
fun getFunctionality(callback: Callback) = callback(getFunctionality(Instance().functionality()))
|
|
164
170
|
|
|
165
171
|
fun setFunctionality(functionality: JSONObject) = setFunctionality(Instance().functionality(), functionality)
|
|
@@ -10,3 +10,13 @@
|
|
|
10
10
|
* Android: `npm run android`.
|
|
11
11
|
|
|
12
12
|
**Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
|
|
13
|
+
|
|
14
|
+
## Additional examples
|
|
15
|
+
|
|
16
|
+
### Bluetooth device
|
|
17
|
+
|
|
18
|
+
In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of you device. After running the app, click `Connect`.
|
|
19
|
+
|
|
20
|
+
### RFID self hosted UI
|
|
21
|
+
|
|
22
|
+
This app also demonstraits how you can implement you own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
2
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
3
|
-
|
|
4
2
|
<div id="content" style="height: 100%"></div>
|
|
5
3
|
|
|
6
|
-
<script>
|
|
7
|
-
|
|
8
|
-
.then(response => response.text())
|
|
9
|
-
.then(html => document.getElementById("content").innerHTML = html)
|
|
10
|
-
</script>
|
|
4
|
+
<script type="module" src="./index.tsx"></script>
|
|
5
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import '@ionic/react/css/core.css'
|
|
2
|
+
import '/src/main.css'
|
|
3
|
+
import { setupIonicReact } from '@ionic/react'
|
|
4
|
+
import { StatusBar, Style } from '@capacitor/status-bar'
|
|
5
|
+
import { File } from '@awesome-cordova-plugins/file'
|
|
6
|
+
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera'
|
|
7
|
+
import { main } from './src/main'
|
|
8
|
+
|
|
9
|
+
document.addEventListener('deviceready', () => fetch("main.html")
|
|
10
|
+
.then(response => response.text())
|
|
11
|
+
.then(html => document.getElementById("content").innerHTML = html)
|
|
12
|
+
.then(_ => document.dispatchEvent(new Event('ready')))
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export async function loadAsset(path: string): Promise<string> {
|
|
16
|
+
var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "public/assets")
|
|
17
|
+
var fileEntry = await File.getFile(dir, path, {})
|
|
18
|
+
var result = await new Promise<string>((resolve, _) => {
|
|
19
|
+
fileEntry.file(file => {
|
|
20
|
+
var reader = new FileReader()
|
|
21
|
+
reader.onloadend = (_) => resolve(reader.result as string)
|
|
22
|
+
reader.readAsDataURL(file)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function pickImage(): Promise<string | null> {
|
|
29
|
+
return await Camera.getPicture({
|
|
30
|
+
destinationType: DestinationType.DATA_URL,
|
|
31
|
+
mediaType: MediaType.PICTURE,
|
|
32
|
+
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
document.addEventListener('ready', main)
|
|
37
|
+
|
|
38
|
+
setupIonicReact()
|
|
39
|
+
StatusBar.setStyle({ style: Style.Light })
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"android": "scripts/android.sh"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@regulaforensics/document-reader": "8.
|
|
10
|
-
"@regulaforensics/document-reader-core-fullauthrfid": "8.
|
|
11
|
-
"@regulaforensics/document-reader-btdevice": "8.
|
|
9
|
+
"@regulaforensics/document-reader": "8.3.242-beta",
|
|
10
|
+
"@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
|
|
11
|
+
"@regulaforensics/document-reader-btdevice": "8.3.10-beta",
|
|
12
12
|
"@awesome-cordova-plugins/file": "6.6.0",
|
|
13
13
|
"@awesome-cordova-plugins/camera": "6.6.0",
|
|
14
14
|
"@awesome-cordova-plugins/dialogs": "6.6.0",
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { DocumentReader, InitConfig } from "@regulaforensics/document-reader"
|
|
2
|
-
import { handleException, setStatus } from "../main"
|
|
2
|
+
import { handleException, init, setStatus } from "../main"
|
|
3
3
|
|
|
4
4
|
export const useBtDevice = false
|
|
5
|
-
const btDeviceName = "Regula 0000"
|
|
5
|
+
export const btDeviceName = "Regula 0000"
|
|
6
6
|
|
|
7
7
|
export function setupBTDevice() {
|
|
8
|
-
document.getElementById("
|
|
9
|
-
|
|
8
|
+
var connectButton = document.getElementById("connect")
|
|
9
|
+
connectButton.style.display = "flex"
|
|
10
|
+
connectButton.onclick = () => connect()
|
|
10
11
|
setStatus("Connect to a bluetooth device")
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
async function connect() {
|
|
14
15
|
setStatus("Searching for devices...")
|
|
15
16
|
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
16
|
-
await
|
|
17
|
+
await init()
|
|
17
18
|
DocumentReader.instance.functionality.useAuthenticator = true
|
|
18
19
|
document.getElementById("bt-device").style.display = "none"
|
|
19
20
|
} else
|
|
20
21
|
setStatus("Failed to connect")
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
async function
|
|
24
|
+
export async function initializeWithBTDevice() {
|
|
24
25
|
setStatus("Initializing...")
|
|
25
26
|
|
|
26
27
|
var initConfig = InitConfig.withBleDevice()
|
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
import { DocReaderAction, DocumentReader,
|
|
2
|
-
import { displayResults,
|
|
1
|
+
import { DocReaderAction, DocumentReader, RFIDConfig, RFIDDataFileType, RFIDNotificationCodes } from "@regulaforensics/document-reader"
|
|
2
|
+
import { displayResults, setStatus } from "../main"
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
Basic,
|
|
6
|
-
Advanced,
|
|
7
|
-
SelfHostedUI
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const rfidOption: RfidOption = RfidOption.Basic
|
|
11
|
-
|
|
12
|
-
export function advancedRfid() {
|
|
13
|
-
var config = new RFIDConfig(handleCompletion)
|
|
14
|
-
|
|
15
|
-
config.onChipDetected = () => console.log("Chip detected, reading rfid.")
|
|
16
|
-
config.onRetryReadChip = async (error) => console.log(await RFIDErrorCodes.getTranslation(error.code) + ". Retrying...")
|
|
17
|
-
|
|
18
|
-
DocumentReader.instance.rfid(config)
|
|
19
|
-
}
|
|
4
|
+
export const useRfidSelfHostedUI = false
|
|
20
5
|
|
|
21
|
-
export function
|
|
22
|
-
var config = RFIDConfig.withoutUI((action, results,
|
|
23
|
-
if (DocReaderAction.stopped(action))
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
setDescription("Error" + error.message)
|
|
27
|
-
console.log(error.code + ": " + error.message)
|
|
28
|
-
}
|
|
6
|
+
export function rfidSelfHostedUI() {
|
|
7
|
+
var config = RFIDConfig.withoutUI((action, results, _) => {
|
|
8
|
+
if (DocReaderAction.stopped(action)) stop()
|
|
9
|
+
if (DocReaderAction.finished(action)) displayResults(results)
|
|
10
|
+
if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
|
|
29
11
|
})
|
|
30
12
|
|
|
31
13
|
config.onProgress = async (notification) => {
|
|
@@ -40,35 +22,40 @@ export function selfHostedUIRfid() {
|
|
|
40
22
|
DocumentReader.instance.rfid(config)
|
|
41
23
|
}
|
|
42
24
|
|
|
43
|
-
function finish(results: Results) {
|
|
44
|
-
DocumentReader.instance.stopRFIDReader()
|
|
45
|
-
setShowing(false)
|
|
46
|
-
displayResults(results)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
25
|
function setup() {
|
|
50
|
-
document.getElementById("cancel-rfid").onclick = () => finish(null)
|
|
51
|
-
|
|
52
26
|
setStatus("Reading RFID")
|
|
53
27
|
setDescription("Place your phone on top of the NFC tag")
|
|
54
|
-
setProgress(
|
|
28
|
+
setProgress(-1)
|
|
29
|
+
currentProgress = -1
|
|
55
30
|
setShowing(true)
|
|
31
|
+
document.getElementById("cancel-rfid").onclick = () => stop()
|
|
56
32
|
}
|
|
57
33
|
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
function stop() {
|
|
35
|
+
DocumentReader.instance.stopRFIDReader()
|
|
36
|
+
displayResults(null)
|
|
37
|
+
setShowing(false)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setDescription(data) {
|
|
41
|
+
document.getElementById("rfid-description").innerHTML = data
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var currentProgress = -1
|
|
45
|
+
function setProgress(next) {
|
|
60
46
|
var progress = document.getElementById("progress")
|
|
61
|
-
var previous = parseInt(progress.style.width.substring(0, progress.style.width.length - 1))
|
|
62
47
|
// make progress bar look better
|
|
63
|
-
if (next
|
|
64
|
-
if (next <
|
|
48
|
+
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
49
|
+
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
65
50
|
if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
|
|
66
|
-
if (next <
|
|
51
|
+
if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
|
|
67
52
|
else progress.style.transition = 'width 0.5s' // smoothly increase progress
|
|
68
53
|
|
|
69
54
|
progress.style.width = next + "%"
|
|
55
|
+
currentProgress = next
|
|
70
56
|
}
|
|
71
|
-
|
|
57
|
+
|
|
58
|
+
function setShowing(data) {
|
|
72
59
|
document.getElementById("main").style.display = data ? "none" : "flex"
|
|
73
60
|
document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
|
|
74
61
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
html,
|
|
2
2
|
body {
|
|
3
|
-
|
|
3
|
+
margin: 0;
|
|
4
|
+
width: 100%;
|
|
4
5
|
height: 99vh;
|
|
5
6
|
display: flex;
|
|
7
|
+
overflow: hidden;
|
|
6
8
|
flex-direction: column;
|
|
7
9
|
}
|
|
8
10
|
|
|
@@ -59,6 +61,7 @@ body {
|
|
|
59
61
|
color: white;
|
|
60
62
|
border: none;
|
|
61
63
|
padding: 10px 20px;
|
|
64
|
+
justify-content: center;
|
|
62
65
|
font-size: 16px;
|
|
63
66
|
border-radius: 100px;
|
|
64
67
|
cursor: pointer;
|
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
<div id="bt-device" class="row" style="display: none;">
|
|
18
|
-
<input type="text" placeholder="Regula 0000" />
|
|
19
|
-
<button id="connect" class="button">Connect</button>
|
|
20
|
-
</div>
|
|
21
17
|
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
22
18
|
<div id="scenarios" class="scroll"></div>
|
|
23
19
|
</div>
|
|
@@ -29,6 +25,7 @@
|
|
|
29
25
|
<button id="scan" class="button">Scan document</button>
|
|
30
26
|
<button id="recognize" class="button">Scan image</button>
|
|
31
27
|
</div>
|
|
28
|
+
<button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
|
|
32
29
|
<div style="padding-top: 20px;"></div>
|
|
33
30
|
</div>
|
|
34
31
|
<div id="custom-rfid" class="column no-scroll" style="display: none;">
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
3
|
-
import './
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { advancedRfid, rfidOption, RfidOption, selfHostedUIRfid } from './extra/custom_rfid'
|
|
9
|
-
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera'
|
|
10
|
-
|
|
11
|
-
const documentReader = DocumentReader.instance
|
|
12
|
-
var selectedScenario = Scenario.MRZ
|
|
1
|
+
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
|
|
2
|
+
import { loadAsset, pickImage } from '../index'
|
|
3
|
+
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
4
|
+
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
5
|
+
|
|
6
|
+
var documentReader = DocumentReader.instance
|
|
7
|
+
var selectedScenario
|
|
13
8
|
var doRfid = false
|
|
14
9
|
var isReadingRfid = false
|
|
15
10
|
|
|
16
|
-
async function init() {
|
|
17
|
-
if (!await
|
|
11
|
+
export async function init() {
|
|
12
|
+
if (!await initialize()) return
|
|
18
13
|
setScenarios(documentReader.availableScenarios)
|
|
19
14
|
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
20
15
|
setStatus("Ready")
|
|
@@ -31,11 +26,9 @@ async function scan() {
|
|
|
31
26
|
|
|
32
27
|
async function recognize() {
|
|
33
28
|
if (!await documentReader.isReady()) return
|
|
34
|
-
var image = await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
38
|
-
})
|
|
29
|
+
var image = await pickImage()
|
|
30
|
+
if (image == null) return
|
|
31
|
+
|
|
39
32
|
clearResults()
|
|
40
33
|
documentReader.recognize(
|
|
41
34
|
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
@@ -43,7 +36,7 @@ async function recognize() {
|
|
|
43
36
|
)
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
export function handleCompletion(action
|
|
39
|
+
export function handleCompletion(action, results, error) {
|
|
47
40
|
handleException(error)
|
|
48
41
|
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
49
42
|
displayResults(results)
|
|
@@ -53,7 +46,7 @@ export function handleCompletion(action: DocReaderAction, results?: Results, err
|
|
|
53
46
|
}
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
export async function displayResults(results
|
|
49
|
+
export async function displayResults(results) {
|
|
57
50
|
isReadingRfid = false
|
|
58
51
|
clearResults()
|
|
59
52
|
if (results == null) return
|
|
@@ -68,11 +61,17 @@ export async function displayResults(results?: Results) {
|
|
|
68
61
|
setDocImage(docImage)
|
|
69
62
|
}
|
|
70
63
|
|
|
71
|
-
var readRfid = () =>
|
|
64
|
+
var readRfid = () => {
|
|
65
|
+
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
66
|
+
}
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
function shouldRfid(results) {
|
|
69
|
+
return doRfid &&
|
|
70
|
+
!isReadingRfid &&
|
|
71
|
+
results != null && results.chipPage != 0
|
|
72
|
+
}
|
|
74
73
|
|
|
75
|
-
async
|
|
74
|
+
var initialize = async () => {
|
|
76
75
|
setStatus("Initializing...")
|
|
77
76
|
|
|
78
77
|
var license = await loadAsset("regula.license")
|
|
@@ -83,7 +82,7 @@ async function initializeReader() {
|
|
|
83
82
|
return success
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export function handleException(error
|
|
85
|
+
export function handleException(error) {
|
|
87
86
|
if (error != null) {
|
|
88
87
|
setStatus(error.message)
|
|
89
88
|
console.log(error.code + ": " + error.message)
|
|
@@ -92,84 +91,84 @@ export function handleException(error: DocReaderException) {
|
|
|
92
91
|
|
|
93
92
|
// --------------------------------------------------------------------------------------------------------------------
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var reader = new FileReader()
|
|
101
|
-
reader.onloadend = (_) => resolve(reader.result as string)
|
|
102
|
-
reader.readAsDataURL(file)
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
return result
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var documentUIImage: HTMLImageElement
|
|
109
|
-
var portraitUIImage: HTMLImageElement
|
|
110
|
-
document.addEventListener('deviceready', () => {
|
|
111
|
-
documentUIImage = document.getElementById("document-image") as HTMLImageElement
|
|
112
|
-
portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
|
|
94
|
+
var documentUIImage
|
|
95
|
+
var portraitUIImage
|
|
96
|
+
export function main() {
|
|
97
|
+
documentUIImage = document.getElementById("document-image")
|
|
98
|
+
portraitUIImage = document.getElementById("portrait-image")
|
|
113
99
|
document.getElementById("scan").onclick = () => scan()
|
|
114
100
|
document.getElementById("recognize").onclick = () => recognize()
|
|
115
101
|
|
|
116
|
-
//
|
|
102
|
+
// custom rfid
|
|
103
|
+
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
104
|
+
|
|
105
|
+
// bt device
|
|
117
106
|
if (!useBtDevice) init()
|
|
118
|
-
else
|
|
107
|
+
else {
|
|
108
|
+
setupBTDevice()
|
|
109
|
+
initialize = initializeWithBTDevice
|
|
110
|
+
}
|
|
111
|
+
}
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
}
|
|
113
|
+
export function setStatus(data) {
|
|
114
|
+
if (data != null)
|
|
115
|
+
document.getElementById("status").innerHTML = data
|
|
116
|
+
}
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
function setPortrait(data) {
|
|
119
|
+
if (data != null)
|
|
120
|
+
portraitUIImage.src = "data:image/png;base64," + data
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function setDocImage(data) {
|
|
124
|
+
if (data != null)
|
|
125
|
+
documentUIImage.src = "data:image/png;base64," + data
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function clearResults() {
|
|
129
129
|
setStatus("Ready")
|
|
130
130
|
portraitUIImage.src = "images/portrait.png"
|
|
131
131
|
documentUIImage.src = "images/document.png"
|
|
132
132
|
}
|
|
133
|
-
var setScenarios = (data: DocReaderScenario[]) => {
|
|
134
|
-
const scenariosContainer = document.getElementById("scenarios")
|
|
135
|
-
data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
|
|
136
|
-
}
|
|
137
|
-
var createScenarioElement = (scenario: DocReaderScenario) => {
|
|
138
|
-
const div = document.createElement('div')
|
|
139
|
-
div.className = 'row radio'
|
|
140
|
-
|
|
141
|
-
const input = document.createElement('input')
|
|
142
|
-
input.type = 'radio'
|
|
143
|
-
input.name = 'scenario'
|
|
144
|
-
input.value = scenario.name
|
|
145
|
-
input.checked = scenario.name === selectedScenario
|
|
146
|
-
|
|
147
|
-
const span = document.createElement('span')
|
|
148
|
-
span.style.width = '200px'
|
|
149
|
-
span.style.paddingLeft = '5px'
|
|
150
|
-
span.textContent = scenario.caption
|
|
151
133
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
div.appendChild(input)
|
|
156
|
-
div.appendChild(span)
|
|
157
|
-
|
|
158
|
-
return div
|
|
159
|
-
}
|
|
160
|
-
var setCanRfid = (data: boolean) => {
|
|
161
|
-
var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
|
|
134
|
+
function setCanRfid(data) {
|
|
135
|
+
var checkbox // implicitly any, since cordova sample is pure js
|
|
136
|
+
checkbox = document.getElementById('rfid-checkbox')
|
|
162
137
|
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
163
138
|
if (data) {
|
|
164
139
|
checkbox.disabled = false
|
|
165
|
-
|
|
140
|
+
checkboxDescription.innerHTML = "Process rfid reading"
|
|
141
|
+
var onclick = () => {
|
|
166
142
|
doRfid = !doRfid
|
|
167
143
|
checkbox.checked = doRfid
|
|
168
144
|
}
|
|
169
|
-
|
|
170
|
-
checkboxDescription.onclick =
|
|
145
|
+
checkbox.onclick = onclick
|
|
146
|
+
checkboxDescription.onclick = onclick
|
|
171
147
|
}
|
|
172
148
|
}
|
|
173
149
|
|
|
174
|
-
|
|
175
|
-
|
|
150
|
+
function setScenarios(data) {
|
|
151
|
+
selectedScenario = Scenario.MRZ
|
|
152
|
+
var scenariosContainer = document.getElementById("scenarios")
|
|
153
|
+
|
|
154
|
+
data.forEach(scenario => {
|
|
155
|
+
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
156
|
+
var scenarioElement = `<div class="row radio">
|
|
157
|
+
<input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
|
|
158
|
+
<span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
|
|
159
|
+
</div>`
|
|
160
|
+
scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
data.forEach(scenario => {
|
|
164
|
+
var element
|
|
165
|
+
element = document.getElementById(scenario.name)
|
|
166
|
+
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
167
|
+
var onclick = () => {
|
|
168
|
+
selectedScenario = scenario.name
|
|
169
|
+
element.checked = true
|
|
170
|
+
}
|
|
171
|
+
element.onclick = onclick
|
|
172
|
+
elementCaption.onclick = onclick
|
|
173
|
+
})
|
|
174
|
+
}
|
|
@@ -10,3 +10,13 @@
|
|
|
10
10
|
* Android: `npm run android`.
|
|
11
11
|
|
|
12
12
|
**Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
|
|
13
|
+
|
|
14
|
+
## Additional examples
|
|
15
|
+
|
|
16
|
+
### Bluetooth device
|
|
17
|
+
|
|
18
|
+
In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of you device. After running the app, click `Connect`.
|
|
19
|
+
|
|
20
|
+
### RFID self hosted UI
|
|
21
|
+
|
|
22
|
+
This app also demonstraits how you can implement you own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
<widget android-packageName="com.regula.dr.fullauthrfid" ios-CFBundleIdentifier="regula.DocumentReader" version="1.0.0"
|
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
3
|
<name>DocumentReader</name>
|
|
4
|
+
<hook type="before_prepare" src="scripts/bundle.sh" />
|
|
4
5
|
<platform name="android">
|
|
6
|
+
<resource-file src="www/db.dat" target="app/src/main/assets/Regula/db.dat" />
|
|
5
7
|
<preference name="orientation" value="portrait" />
|
|
6
|
-
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
7
8
|
<preference name="android-minSdkVersion" value="24" />
|
|
8
9
|
<preference name="android-targetSdkVersion" value="35" />
|
|
10
|
+
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
9
11
|
<config-file parent="/*" target="AndroidManifest.xml">
|
|
10
|
-
<uses-permission android:name="android.permission.
|
|
12
|
+
<uses-permission android:name="android.permission.NFC" />
|
|
13
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
11
14
|
</config-file>
|
|
12
15
|
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
13
16
|
<application android:usesCleartextTraffic="true" />
|
|
14
17
|
</edit-config>
|
|
15
18
|
</platform>
|
|
16
19
|
<platform name="ios">
|
|
20
|
+
<resource-file src="www/db.dat" />
|
|
17
21
|
<preference name="orientation" value="portrait" />
|
|
18
22
|
<preference name="DisallowOverscroll" value="true" />
|
|
19
23
|
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
|