veryfi-lens-wasm 2.0.4 → 2.0.5-beta.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/components/blurModal.js +10 -4
- package/components/documentModal.js +13 -4
- package/package.json +1 -1
- package/utils/parser-wrapper.js +30 -1
- package/veryfi-lens.js +30 -5
package/components/blurModal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const createBlurModal = (container, croppedImage, onRetake, onSubmit) => {
|
|
1
|
+
export const createBlurModal = (container, croppedImage, onRetake, onSubmit, options = {}) => {
|
|
2
2
|
const modal = document.createElement('div');
|
|
3
3
|
modal.id = 'veryfi-blur-modal';
|
|
4
4
|
modal.style.display = 'none';
|
|
@@ -31,6 +31,12 @@ export const createBlurModal = (container, croppedImage, onRetake, onSubmit) =>
|
|
|
31
31
|
secondaryButtonColor: '#1e293b'
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
const defaultOptions = {
|
|
35
|
+
blurModalMessage: 'Oops, The image is too blurry to process'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Merge provided options with defaults
|
|
39
|
+
const modalOptions = { ...defaultOptions, ...options };
|
|
34
40
|
// Apply styles with fallback to default values
|
|
35
41
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
36
42
|
const cssVar = `--blur-modal-${key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)}`;
|
|
@@ -50,7 +56,7 @@ export const createBlurModal = (container, croppedImage, onRetake, onSubmit) =>
|
|
|
50
56
|
font-size: var(--blur-modal-text-font-size, ${defaultStyles.textFontSize});
|
|
51
57
|
font-family: var(--blur-modal-text-font-family, ${defaultStyles.textFontFamily});
|
|
52
58
|
">
|
|
53
|
-
|
|
59
|
+
${modalOptions.blurModalMessage.replace(/</g, '<').replace(/>/g, '>')}
|
|
54
60
|
</p>
|
|
55
61
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">
|
|
56
62
|
<button id="veryfi-retake-blur" style="
|
|
@@ -69,7 +75,7 @@ export const createBlurModal = (container, croppedImage, onRetake, onSubmit) =>
|
|
|
69
75
|
font-family: var(--blur-modal-button-font-family, ${defaultStyles.buttonFontFamily});
|
|
70
76
|
text-transform: var(--blur-modal-button-text-transform, ${defaultStyles.buttonTextTransform});
|
|
71
77
|
">
|
|
72
|
-
|
|
78
|
+
${modalOptions.retakeButtonText.replace(/</g, '<').replace(/>/g, '>')}
|
|
73
79
|
</p>
|
|
74
80
|
</button>
|
|
75
81
|
<button id="veryfi-submit-blur" style="
|
|
@@ -88,7 +94,7 @@ export const createBlurModal = (container, croppedImage, onRetake, onSubmit) =>
|
|
|
88
94
|
font-family: var(--blur-modal-button-font-family, ${defaultStyles.buttonFontFamily});
|
|
89
95
|
text-transform: var(--blur-modal-button-text-transform, ${defaultStyles.buttonTextTransform});
|
|
90
96
|
">
|
|
91
|
-
|
|
97
|
+
${modalOptions.submitButtonText.replace(/</g, '<').replace(/>/g, '>')}
|
|
92
98
|
</p>
|
|
93
99
|
</button>
|
|
94
100
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const createDocumentModal = (container, croppedImage, onRetake, onSubmit) => {
|
|
1
|
+
export const createDocumentModal = (container, croppedImage, onRetake, onSubmit, options = {}) => {
|
|
2
2
|
const modal = document.createElement('div');
|
|
3
3
|
modal.id = 'veryfi-document-modal';
|
|
4
4
|
modal.style.display = 'none';
|
|
@@ -32,6 +32,15 @@ export const createDocumentModal = (container, croppedImage, onRetake, onSubmit)
|
|
|
32
32
|
secondaryButtonColor: '#1e293b'
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const defaultOptions = {
|
|
36
|
+
noDocumentMessage: 'Oops, There appears to be no document on your image',
|
|
37
|
+
retakeButtonText: 'Retake a picture',
|
|
38
|
+
submitButtonText: 'Submit Anyway'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Merge provided options with defaults
|
|
42
|
+
const modalOptions = { ...defaultOptions, ...options };
|
|
43
|
+
|
|
35
44
|
// Apply styles with fallback to default values
|
|
36
45
|
Object.entries(defaultStyles).forEach(([key, value]) => {
|
|
37
46
|
const cssVar = `--modal-${key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)}`;
|
|
@@ -52,7 +61,7 @@ export const createDocumentModal = (container, croppedImage, onRetake, onSubmit)
|
|
|
52
61
|
font-size: var(--modal-text-font-size, ${defaultStyles.textFontSize});
|
|
53
62
|
font-family: var(--modal-text-font-family, ${defaultStyles.textFontFamily});
|
|
54
63
|
">
|
|
55
|
-
|
|
64
|
+
${modalOptions.noDocumentMessage.replace(/</g, '<').replace(/>/g, '>')}
|
|
56
65
|
</p>
|
|
57
66
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">
|
|
58
67
|
<button id="veryfi-retake-document" style="
|
|
@@ -71,7 +80,7 @@ export const createDocumentModal = (container, croppedImage, onRetake, onSubmit)
|
|
|
71
80
|
font-family: var(--modal-button-font-family, ${defaultStyles.buttonFontFamily});
|
|
72
81
|
text-transform: var(--modal-button-text-transform, ${defaultStyles.buttonTextTransform});
|
|
73
82
|
">
|
|
74
|
-
|
|
83
|
+
${modalOptions.retakeButtonText.replace(/</g, '<').replace(/>/g, '>')}
|
|
75
84
|
</p>
|
|
76
85
|
</button>
|
|
77
86
|
<button id="veryfi-submit-document" style="
|
|
@@ -90,7 +99,7 @@ export const createDocumentModal = (container, croppedImage, onRetake, onSubmit)
|
|
|
90
99
|
font-family: var(--modal-button-font-family, ${defaultStyles.buttonFontFamily});
|
|
91
100
|
text-transform: var(--modal-button-text-transform, ${defaultStyles.buttonTextTransform});
|
|
92
101
|
">
|
|
93
|
-
|
|
102
|
+
${modalOptions.submitButtonText.replace(/</g, '<').replace(/>/g, '>')}
|
|
94
103
|
</p>
|
|
95
104
|
</button>
|
|
96
105
|
</div>
|
package/package.json
CHANGED
package/utils/parser-wrapper.js
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
1
|
import './ua-parser.js';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// Create a wrapper that ensures we always have something to export
|
|
4
|
+
const UAParserWrapper = function(ua, extensions) {
|
|
5
|
+
if (typeof window !== 'undefined' && window.UAParser) {
|
|
6
|
+
return new window.UAParser(ua, extensions);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Fallback implementation that won't crash
|
|
10
|
+
return {
|
|
11
|
+
getResult: function() {
|
|
12
|
+
return {
|
|
13
|
+
ua: ua || navigator?.userAgent || '',
|
|
14
|
+
browser: { name: 'unknown', version: 'unknown' },
|
|
15
|
+
engine: { name: 'unknown', version: 'unknown' },
|
|
16
|
+
os: { name: 'unknown', version: 'unknown' },
|
|
17
|
+
device: { model: 'unknown', type: 'unknown', vendor: 'unknown' },
|
|
18
|
+
cpu: { architecture: 'unknown' }
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
getBrowser: function() { return { name: 'unknown', version: 'unknown' }; },
|
|
22
|
+
getEngine: function() { return { name: 'unknown', version: 'unknown' }; },
|
|
23
|
+
getOS: function() { return { name: 'unknown', version: 'unknown' }; },
|
|
24
|
+
getDevice: function() { return { model: 'unknown', type: 'unknown', vendor: 'unknown' }; },
|
|
25
|
+
getCPU: function() { return { architecture: 'unknown' }; },
|
|
26
|
+
getUA: function() { return ua || navigator?.userAgent || ''; },
|
|
27
|
+
setUA: function() { return this; }
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default UAParserWrapper;
|
package/veryfi-lens.js
CHANGED
|
@@ -138,6 +138,10 @@ const VeryfiLens = (function () {
|
|
|
138
138
|
submitButtonShown: false,
|
|
139
139
|
backScanningStartTime: null,
|
|
140
140
|
sdkVersion: "2.0.0",
|
|
141
|
+
documentModalMessage: 'Oops, There appears to be no document on your image',
|
|
142
|
+
blurModalMessage: 'Oops, The image is too blurry to process',
|
|
143
|
+
submitButtonText: 'Submit Anyway',
|
|
144
|
+
retakeButtonText: 'Retake a picture',
|
|
141
145
|
};
|
|
142
146
|
|
|
143
147
|
|
|
@@ -858,11 +862,22 @@ const VeryfiLens = (function () {
|
|
|
858
862
|
};
|
|
859
863
|
|
|
860
864
|
const parseUA = () => {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
865
|
+
try {
|
|
866
|
+
const userAgentString = navigator.userAgent;
|
|
867
|
+
const parser = UAParser(userAgentString); // Note: no 'new' keyword needed now
|
|
868
|
+
let parserResults = parser.getResult();
|
|
869
|
+
if (parserResults) {
|
|
870
|
+
return parserResults;
|
|
871
|
+
}
|
|
872
|
+
// ...
|
|
873
|
+
} catch (error) {
|
|
874
|
+
console.error('Error parsing user agent:', error);
|
|
875
|
+
// Return fallback object
|
|
876
|
+
return {
|
|
877
|
+
browser: { name: 'unknown', version: 'unknown' },
|
|
878
|
+
os: { name: 'unknown', version: 'unknown' },
|
|
879
|
+
device: { model: 'unknown', type: 'unknown', vendor: 'unknown' }
|
|
880
|
+
};
|
|
866
881
|
}
|
|
867
882
|
};
|
|
868
883
|
|
|
@@ -933,6 +948,11 @@ const VeryfiLens = (function () {
|
|
|
933
948
|
state.debug_mode && console.log("Submitting anyway");
|
|
934
949
|
hideVideoOverlay();
|
|
935
950
|
state.submitHandler && state.submitHandler(state.finalImage);
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
blurModalMessage: state.blurModalMessage,
|
|
954
|
+
retakeButtonText: state.retakeButtonText,
|
|
955
|
+
submitButtonText: state.submitButtonText
|
|
936
956
|
}
|
|
937
957
|
);
|
|
938
958
|
}
|
|
@@ -950,6 +970,11 @@ const VeryfiLens = (function () {
|
|
|
950
970
|
state.debug_mode && console.log("Submitting anyway");
|
|
951
971
|
hideVideoOverlay();
|
|
952
972
|
state.submitHandler && state.submitHandler(state.finalImage);
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
noDocumentMessage: state.documentModalMessage,
|
|
976
|
+
retakeButtonText: state.retakeButtonText,
|
|
977
|
+
submitButtonText: state.submitButtonText
|
|
953
978
|
}
|
|
954
979
|
);
|
|
955
980
|
}
|