@exige/web-scanner-sdk 0.2.31 → 0.2.33
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/dist/{driver-license-yM6pBkNk.js → driver-license-DBrWpI9w.js} +70 -38
- package/dist/driver-license-DBrWpI9w.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/react.js +374 -307
- package/dist/react.js.map +1 -1
- package/dist/scanner-sdk.js +17 -17
- package/dist/scanner-sdk.js.map +1 -1
- package/dist/sdk/driver-license.d.ts +16 -3
- package/dist/sdk/finder.d.ts +2 -1
- package/package.json +1 -1
- package/dist/driver-license-yM6pBkNk.js.map +0 -1
|
@@ -2604,7 +2604,7 @@ function Nr(e, t, n, r) {
|
|
|
2604
2604
|
confidence: 1
|
|
2605
2605
|
};
|
|
2606
2606
|
}
|
|
2607
|
-
function
|
|
2607
|
+
function Pr(e, t) {
|
|
2608
2608
|
let n = t.imageWidth ?? e?.imageWidth ?? 0, r = t.imageHeight ?? e?.imageHeight ?? 0, i = e?.words ?? [], a = hr(i), o = [], s = [];
|
|
2609
2609
|
for (let e of t.rules) {
|
|
2610
2610
|
let c = e.strategy === "string" ? gr(e, a) : e.strategy === "label" ? yr(e, i, a, n, r) : Mr(e, i, a, r, t.semanticDetections, t.modelRequested === !0);
|
|
@@ -2634,16 +2634,16 @@ function $(e, t) {
|
|
|
2634
2634
|
confidence: u
|
|
2635
2635
|
};
|
|
2636
2636
|
}
|
|
2637
|
-
function
|
|
2637
|
+
function Fr(e) {
|
|
2638
2638
|
return e.rules.length > 0 || e.template?.fields.some((e) => e.strategy === "anchor") === !0;
|
|
2639
2639
|
}
|
|
2640
|
-
function
|
|
2640
|
+
function Ir(e, t = !1) {
|
|
2641
2641
|
return t && !e.complete ? "unmatched" : e.complete ? "success" : "partial";
|
|
2642
2642
|
}
|
|
2643
|
-
async function
|
|
2643
|
+
async function Lr(e, t) {
|
|
2644
2644
|
await x("redaction");
|
|
2645
2645
|
let n = await P(e, { cloneCanvas: !1 }), r = t.ocr;
|
|
2646
|
-
|
|
2646
|
+
Fr(t) && !r && (r = await H(n, { includeWords: !0 }));
|
|
2647
2647
|
let i = t.semanticDetections, a = t.modelRequested === !0, o = "not-requested", s;
|
|
2648
2648
|
if (t.models?.fields) try {
|
|
2649
2649
|
i = await pr(n, t.models.fields, t.models.fieldClasses, t.models.confidence, t.models.fieldLayout), a = !0, o = "loaded";
|
|
@@ -2652,14 +2652,14 @@ async function Ir(e, t) {
|
|
|
2652
2652
|
let n = t.models.allowHeuristicFallback !== !1;
|
|
2653
2653
|
a = !n, o = n ? "fallback" : "failed";
|
|
2654
2654
|
}
|
|
2655
|
-
let c =
|
|
2655
|
+
let c = Pr(r, {
|
|
2656
2656
|
rules: t.rules,
|
|
2657
2657
|
template: t.template,
|
|
2658
2658
|
imageWidth: n.width,
|
|
2659
2659
|
imageHeight: n.height,
|
|
2660
2660
|
semanticDetections: i,
|
|
2661
2661
|
modelRequested: a
|
|
2662
|
-
}), l =
|
|
2662
|
+
}), l = Ir(c, t.requireAll), u = [], d = "not-requested", f;
|
|
2663
2663
|
if (t.models?.face) try {
|
|
2664
2664
|
u = await $n(n, t.models.face, t.models.faceConfidence), d = "loaded";
|
|
2665
2665
|
} catch (e) {
|
|
@@ -2697,7 +2697,7 @@ async function Ir(e, t) {
|
|
|
2697
2697
|
}
|
|
2698
2698
|
//#endregion
|
|
2699
2699
|
//#region src/sdk/driver-license.ts
|
|
2700
|
-
var
|
|
2700
|
+
var Rr = [
|
|
2701
2701
|
{
|
|
2702
2702
|
id: "issuerJurisdiction",
|
|
2703
2703
|
strategy: "semantic",
|
|
@@ -2734,7 +2734,7 @@ var Lr = [
|
|
|
2734
2734
|
field: "person_name"
|
|
2735
2735
|
}
|
|
2736
2736
|
];
|
|
2737
|
-
function
|
|
2737
|
+
function zr(e, t, n) {
|
|
2738
2738
|
let r = n.trim();
|
|
2739
2739
|
if (r) {
|
|
2740
2740
|
if (t === "expirationDate" || t === "dateOfBirth" || t === "issueDate") {
|
|
@@ -2748,8 +2748,8 @@ function Rr(e, t, n) {
|
|
|
2748
2748
|
e[t] = r;
|
|
2749
2749
|
}
|
|
2750
2750
|
}
|
|
2751
|
-
function
|
|
2752
|
-
let t = {}, n =
|
|
2751
|
+
function Br(e) {
|
|
2752
|
+
let t = {}, n = Pr(e, { rules: Rr });
|
|
2753
2753
|
for (let e of n.matches) {
|
|
2754
2754
|
let n = e.text?.trim();
|
|
2755
2755
|
if (n) {
|
|
@@ -2758,12 +2758,12 @@ function zr(e) {
|
|
|
2758
2758
|
!t.firstName && e[0] && (t.firstName = e[0]), !t.lastName && e.length > 1 && (t.lastName = e[e.length - 1]), !t.middleName && e.length > 2 && (t.middleName = e.slice(1, -1).join(" "));
|
|
2759
2759
|
continue;
|
|
2760
2760
|
}
|
|
2761
|
-
|
|
2761
|
+
zr(t, e.ruleId, n);
|
|
2762
2762
|
}
|
|
2763
2763
|
}
|
|
2764
2764
|
return t;
|
|
2765
2765
|
}
|
|
2766
|
-
function
|
|
2766
|
+
function Vr(e, t) {
|
|
2767
2767
|
let n = { ...e }, r = qn(Kn(), e, "barcode");
|
|
2768
2768
|
for (let [e, i] of Object.entries(t)) i && (n[e] || (n[e] = i, r[e] = "ocr"));
|
|
2769
2769
|
return {
|
|
@@ -2771,16 +2771,16 @@ function Br(e, t) {
|
|
|
2771
2771
|
sources: r
|
|
2772
2772
|
};
|
|
2773
2773
|
}
|
|
2774
|
-
async function
|
|
2774
|
+
async function Hr(e, t, n) {
|
|
2775
2775
|
return t?.status === "success" && t.corners ? ct(e, t.corners, { maxOutputDimension: n?.maxOutputDimension }) : R(e, n);
|
|
2776
2776
|
}
|
|
2777
|
-
async function
|
|
2777
|
+
async function Ur(e, t, n) {
|
|
2778
2778
|
if (!e.width || !e.height) return {
|
|
2779
2779
|
kind: "retry",
|
|
2780
2780
|
status: "frontFailed",
|
|
2781
2781
|
message: "The front photo was empty. Try again."
|
|
2782
2782
|
};
|
|
2783
|
-
let r = await
|
|
2783
|
+
let r = await Hr(e, t, n);
|
|
2784
2784
|
if (r.status !== "success" || !r.canvas) return {
|
|
2785
2785
|
kind: "retry",
|
|
2786
2786
|
status: "frontFailed",
|
|
@@ -2801,7 +2801,38 @@ async function Hr(e, t, n) {
|
|
|
2801
2801
|
}
|
|
2802
2802
|
};
|
|
2803
2803
|
}
|
|
2804
|
-
|
|
2804
|
+
function $() {
|
|
2805
|
+
return new DOMException("The barcode scan was cancelled.", "AbortError");
|
|
2806
|
+
}
|
|
2807
|
+
function Wr(e, t) {
|
|
2808
|
+
return new Promise((n, r) => {
|
|
2809
|
+
if (t?.aborted) {
|
|
2810
|
+
r($());
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
let i = setTimeout(() => {
|
|
2814
|
+
t?.removeEventListener("abort", a), n();
|
|
2815
|
+
}, e), a = () => {
|
|
2816
|
+
clearTimeout(i), r($());
|
|
2817
|
+
};
|
|
2818
|
+
t?.addEventListener("abort", a, { once: !0 });
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
async function Gr(e, t = {}) {
|
|
2822
|
+
let n = t.intervalMs ?? 140;
|
|
2823
|
+
for (;;) {
|
|
2824
|
+
if (t.signal?.aborted) throw $();
|
|
2825
|
+
try {
|
|
2826
|
+
let t = await e();
|
|
2827
|
+
if (t?.width && t.height && (await U(t))?.text) return t;
|
|
2828
|
+
} catch (e) {
|
|
2829
|
+
if (t.signal?.aborted) throw $();
|
|
2830
|
+
if (e instanceof DOMException && e.name === "AbortError") throw e;
|
|
2831
|
+
}
|
|
2832
|
+
await Wr(n, t.signal);
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
async function Kr(e, t) {
|
|
2805
2836
|
if (!e.width || !e.height) return {
|
|
2806
2837
|
status: "backFailed",
|
|
2807
2838
|
fields: {},
|
|
@@ -2811,46 +2842,47 @@ async function Ur(e, t, n) {
|
|
|
2811
2842
|
back: {},
|
|
2812
2843
|
message: "The back photo was empty. Try again."
|
|
2813
2844
|
};
|
|
2814
|
-
let
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
canvas: i ?? e,
|
|
2818
|
-
barcodeText: a
|
|
2845
|
+
let n = (await U(e))?.text, r = {
|
|
2846
|
+
canvas: e,
|
|
2847
|
+
barcodeText: n
|
|
2819
2848
|
};
|
|
2820
|
-
if (!
|
|
2821
|
-
let e = t.ocr ?
|
|
2849
|
+
if (!n) {
|
|
2850
|
+
let e = t.ocr ? Br(t.ocr) : {};
|
|
2822
2851
|
return {
|
|
2823
2852
|
status: "barcodeUnreadable",
|
|
2824
2853
|
fields: e,
|
|
2825
2854
|
rawElements: {},
|
|
2826
2855
|
sources: qn(Kn(), e, "ocr"),
|
|
2827
2856
|
front: t,
|
|
2828
|
-
back:
|
|
2857
|
+
back: r,
|
|
2829
2858
|
message: "The PDF417 barcode on the back could not be read. Try again."
|
|
2830
2859
|
};
|
|
2831
2860
|
}
|
|
2832
|
-
let
|
|
2861
|
+
let i = Gn(n), a = t.ocr ? Br(t.ocr) : {}, o = Vr(i.fields, a);
|
|
2833
2862
|
return {
|
|
2834
2863
|
status: "success",
|
|
2835
|
-
fields:
|
|
2836
|
-
rawElements:
|
|
2837
|
-
sources:
|
|
2864
|
+
fields: o.fields,
|
|
2865
|
+
rawElements: i.rawElements,
|
|
2866
|
+
sources: o.sources,
|
|
2838
2867
|
front: t,
|
|
2839
|
-
back:
|
|
2868
|
+
back: r
|
|
2840
2869
|
};
|
|
2841
2870
|
}
|
|
2842
|
-
function
|
|
2871
|
+
function qr(e) {
|
|
2872
|
+
return e === "back" ? 0 : void 0;
|
|
2873
|
+
}
|
|
2874
|
+
function Jr(e, t) {
|
|
2843
2875
|
return e === "front" ? {
|
|
2844
2876
|
title: "Scan a driver’s license",
|
|
2845
2877
|
headline: "Show the front of the license.",
|
|
2846
2878
|
detail: t ? "Take a photo of the front. There is no live document guide." : "Place the front of the license in the frame."
|
|
2847
2879
|
} : {
|
|
2848
2880
|
title: "Scan a driver’s license",
|
|
2849
|
-
headline: "
|
|
2850
|
-
detail: t ? "Take a photo of the
|
|
2881
|
+
headline: "Show the barcode on the back",
|
|
2882
|
+
detail: t ? "Take a photo of the PDF417 barcode on the back. There is no document outline." : "Hold the barcode in the preview. There is no document outline."
|
|
2851
2883
|
};
|
|
2852
2884
|
}
|
|
2853
|
-
async function
|
|
2885
|
+
async function Yr(e = {}) {
|
|
2854
2886
|
await x("scan"), await x("ocr");
|
|
2855
2887
|
let t = "front", n, r = !1;
|
|
2856
2888
|
return {
|
|
@@ -2864,10 +2896,10 @@ async function Gr(e = {}) {
|
|
|
2864
2896
|
message: "This license scan was cancelled."
|
|
2865
2897
|
};
|
|
2866
2898
|
if (t === "front") {
|
|
2867
|
-
let r = await
|
|
2899
|
+
let r = await Ur(i, a, e.scan);
|
|
2868
2900
|
return r.kind === "need-back" && (n = r.front, t = "back"), r;
|
|
2869
2901
|
}
|
|
2870
|
-
let o = await
|
|
2902
|
+
let o = await Kr(i, n ?? {});
|
|
2871
2903
|
return o.status === "backFailed" ? {
|
|
2872
2904
|
kind: "retry",
|
|
2873
2905
|
status: "backFailed",
|
|
@@ -2883,6 +2915,6 @@ async function Gr(e = {}) {
|
|
|
2883
2915
|
};
|
|
2884
2916
|
}
|
|
2885
2917
|
//#endregion
|
|
2886
|
-
export {
|
|
2918
|
+
export { y as $, ut as A, ve as B, yt as C, st as D, ct as E, N as F, le as G, M as H, k as I, re as J, Ne as K, se as L, ge as M, he as N, Xe as O, Te as P, b as Q, Pe as R, jt as S, qe as T, Fe as U, j as V, ce as W, o as X, a as Y, x as Z, Ct as _, Yr as a, At as b, Lr as c, Gn as d, e as et, U as f, Mt as g, wt as h, Vr as i, lt as j, R as k, mr as l, H as m, qr as n, Gr as o, kn as p, _e as q, Jr as r, Pr as s, Br as t, t as tt, K as u, xt as v, It as w, kt as x, bt as y, A as z };
|
|
2887
2919
|
|
|
2888
|
-
//# sourceMappingURL=driver-license-
|
|
2920
|
+
//# sourceMappingURL=driver-license-DBrWpI9w.js.map
|