bry-biometric-collector 2.0.3

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.
@@ -0,0 +1,146 @@
1
+ import { u as D, $ as C, n as y, g, i as b, a as M, s as l, b as h, c as U, F, d as x, e as c, v, f as P, A as B, h as S, j as E, k as W, l as k, m as X, o as w, p as $, q as G } from "./main_4a3321b2_2.0.3.js";
2
+ const d = D(C);
3
+ var V = /* @__PURE__ */ ((n) => (n.EXTENSION_MISSING = "EXTENSION_MISSING", n.USER_CANCELLED = "USER_CANCELLED", n.UNAUTHORIZED_EXTENSION = "UNAUTHORIZED_EXTENSION", n.SCANNER_NOT_FOUND = "SCANNER_NOT_FOUND", n.EXTENSION_MODULE_NOT_INSTALLED = "EXTENSION_MODULE_NOT_INSTALLED", n.FINGER_NOT_REMOVED = "FINGER_NOT_REMOVED", n.UNKNOWN_ERROR = "UNKNOWN_ERROR", n.EVALUATE_BIOMETRICS_TIMEOUT = "EVALUATE_BIOMETRICS_TIMEOUT", n.EVALUATE_BIOMETRICS_NETWORK_ISSUE = "EVALUATE_BIOMETRICS_NETWORK_ISSUE", n))(V || {});
4
+ class s extends Error {
5
+ constructor(a, T) {
6
+ super(a), this.status = T;
7
+ }
8
+ }
9
+ async function K(n, a) {
10
+ const T = y([n])[0], I = g();
11
+ if (b(I))
12
+ throw new s(
13
+ "Attempting to capture finger but the extension apparently hasn't been properly injected. Received: " + I,
14
+ "EXTENSION_MISSING"
15
+ /* EXTENSION_MISSING */
16
+ );
17
+ if (g()) {
18
+ if ("isExtensionInstalled" in g() && !await g().isExtensionInstalled())
19
+ throw console.error("The extension isn't installed!"), new s(
20
+ "The extension isn't installed!",
21
+ "EXTENSION_MISSING"
22
+ /* EXTENSION_MISSING */
23
+ );
24
+ M() || await g().installComponents?.([{ type: "fingerPrint" }]);
25
+ } else
26
+ throw new s(
27
+ `The extension variable received is empty: ${g()}!`,
28
+ "EXTENSION_MISSING"
29
+ /* EXTENSION_MISSING */
30
+ );
31
+ if (l(!0), h())
32
+ throw l(!1), U(!1), new s(
33
+ "User cancelled",
34
+ "USER_CANCELLED"
35
+ /* USER_CANCELLED */
36
+ );
37
+ let N = null;
38
+ try {
39
+ N = await I.getFingerprint(
40
+ // @ts-ignore TODO: Alex has to fix this functions signature to accept pojo
41
+ JSON.stringify(
42
+ a ?? { outputFormat: "BASE64", imageFormat: "BMP", nonce: "webCollector", timeout: 3 }
43
+ )
44
+ );
45
+ } catch (e) {
46
+ console.error(e);
47
+ const t = e;
48
+ throw l(!1), t.key === "fingerprint.scanner.timeout" ? new s(
49
+ "Fingerprint scan timed out (didn't read a finger.)",
50
+ "USER_CANCELLED"
51
+ /* USER_CANCELLED */
52
+ ) : t.key === "extension.authorization.canceled" ? new s(
53
+ "Extension wasn't given authorization.",
54
+ "UNAUTHORIZED_EXTENSION"
55
+ /* UNAUTHORIZED_EXTENSION */
56
+ ) : t.key === "fingerprint.scanner.not.found" ? new s(
57
+ "Couldn't find fingerprint scanner.",
58
+ "SCANNER_NOT_FOUND"
59
+ /* SCANNER_NOT_FOUND */
60
+ ) : t.key === "signer.not.installed" ? new s(
61
+ "The extension module isn't installed.",
62
+ "EXTENSION_MODULE_NOT_INSTALLED"
63
+ /* EXTENSION_MODULE_NOT_INSTALLED */
64
+ ) : new s(
65
+ "Unknown error while capturing fingerprint.",
66
+ "UNKNOWN_ERROR"
67
+ /* UNKNOWN_ERROR */
68
+ );
69
+ }
70
+ if (h())
71
+ throw l(!1), U(!1), new s(
72
+ "User cancelled",
73
+ "USER_CANCELLED"
74
+ /* USER_CANCELLED */
75
+ );
76
+ const i = q(T);
77
+ i.image = N?.content.image?.data, i.base64WSQ = N?.content.fingerprint.data, i.nfiqRating = (N?.content.score || 0) + 98, i.status = F.AVAILABLE;
78
+ const L = x(c());
79
+ let r, _ = !1;
80
+ try {
81
+ r = await v(L, i);
82
+ } catch (e) {
83
+ if (i.nfiqRating = -1, i.base64WSQ = "", i.image = "", console.log("caught while validating fingerprint: ", e), P(e) && "message" in e && e.message === "error.template.extraction")
84
+ _ = !0;
85
+ else if (e instanceof XMLHttpRequest) {
86
+ const t = e;
87
+ "response" in t && "data" in t.response.data && t.response.data.message === "error.template.extraction" && (_ = !0);
88
+ } else
89
+ throw e instanceof B ? e.code === "ECONNABORTED" ? (console.log("The evaluate biometrics request took too long to answer!"), new s(
90
+ "Evaluate biometrics took too long to reply",
91
+ "EVALUATE_BIOMETRICS_TIMEOUT"
92
+ /* EVALUATE_BIOMETRICS_TIMEOUT */
93
+ )) : (console.error("Error evaluating biometrics!", e), S(c()), l(!1), new s(
94
+ "Network issue while validating biometrics, check logs",
95
+ "EVALUATE_BIOMETRICS_NETWORK_ISSUE"
96
+ /* EVALUATE_BIOMETRICS_NETWORK_ISSUE */
97
+ )) : (S(c()), l(!1), new s(
98
+ "Network issue while validating biometrics, check logs",
99
+ "EVALUATE_BIOMETRICS_NETWORK_ISSUE"
100
+ /* EVALUATE_BIOMETRICS_NETWORK_ISSUE */
101
+ ));
102
+ }
103
+ let R, f, O, A, u, o = E.LOW_QUALITY;
104
+ if (r) {
105
+ const e = r.bodyParts.find(
106
+ (t) => t.bodyPart === i.bodyPart
107
+ );
108
+ i.nfiqRating = e.quality, (e.quality > W() || e.status === "LOW_QUALITY") && (R = !0, o = E.LOW_QUALITY), r.bodyParts.find((t) => t.status === "DUPLICATE") && (f = !0, o = E.DUPLICATE), r.bodyParts.find((t) => t.status === "FORBIDDEN") && (O = !0, o = E.FORBIDDEN), r.bodyParts.find((t) => t.status === "AGR") && (A = !0, o = E.AGR_DETECTED), r.bodyParts.find((t) => t.status === "AGR_NOT_MATCH") && (u = !0, o = E.AGR_NO_MATCH);
109
+ }
110
+ if (f || R || O || u || A || _) {
111
+ i.nfiqRating = -1, i.base64WSQ = "", i.image = "", i.status = F.AVAILABLE;
112
+ let e = "badFingerQualitySwal";
113
+ f ? e = "unknownDuplicateFingerSwal" : O ? e = "forbiddenFingerSwal" : A ? e = "agrFinger" : u && (e = "agrFingerNotMatched");
114
+ let t = d(`${e}.text`);
115
+ if (k(X) && f) {
116
+ e = "duplicateFingerSwal", t = d(`${e}.text`, {
117
+ values: {
118
+ finger1: d(`${e}.${r.matchingFingers?.[0]}`),
119
+ finger2: d(`${e}.${r.matchingFingers?.[1]}`)
120
+ }
121
+ });
122
+ const m = w();
123
+ return {
124
+ returnCode: o,
125
+ bodyParts: m,
126
+ matchingFingers: r.matchingFingers,
127
+ message: t
128
+ };
129
+ }
130
+ const p = w();
131
+ return { returnCode: o, bodyParts: p, message: t };
132
+ }
133
+ return S(c()), l(!1), $(), { returnCode: E.CAPTURED, bodyParts: w() };
134
+ }
135
+ function q(n) {
136
+ G();
137
+ for (const a of c())
138
+ if (a.index === n)
139
+ return a.selected = !0, a;
140
+ throw new Error(`Finger ${n} not found`);
141
+ }
142
+ export {
143
+ s as CaptureApiError,
144
+ V as CaptureErrorStatusEnum,
145
+ K as captureSingleFinger
146
+ };