@idscan/onboarding 2.7.5 → 2.9.0
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/Wrapper.css +1 -0
- package/dist/custom_types/custom.d.ts +20 -0
- package/dist/networks/Blur-chunk.js +1 -1
- package/dist/networks/Bubble-chunk.js +1 -1
- package/dist/networks/Face-chunk.js +1 -1
- package/dist/networks/GeneralTypeDetectionYolo-chunk.js +1 -1
- package/dist/networks/MRZ-chunk.js +1 -1
- package/dist/networks/PDF-chunk.js +1 -1
- package/dist/networks/ZXing-chunk.js +1 -1
- package/dist/{@types/src → src}/@types/Api/Requests.d.ts +1 -1
- package/dist/{@types/src → src}/@types/Api/Responses.d.ts +2 -2
- package/dist/{@types/src → src}/@types/Data.d.ts +6 -4
- package/dist/{@types/src → src}/@types/Step.d.ts +1 -1
- package/dist/{@types/src → src}/Wrapper.d.ts +0 -2
- package/dist/{@types/src → src}/config.d.ts +6 -4
- package/dist/{@types/src → src}/errors/ConfigError.d.ts +1 -1
- package/dist/{@types/src → src}/errors/FaceAuthorizationError.d.ts +1 -1
- package/dist/{@types/src → src}/errors/HttpError.d.ts +1 -1
- package/dist/{@types/src → src}/errors/NotValidApplicant.d.ts +1 -1
- package/dist/{@types/src → src}/errors/RequestTimeoutError.d.ts +1 -1
- package/dist/{@types/src → src}/errors/ValidationError.d.ts +1 -1
- package/dist/{@types/src → src}/helpers/fingerPrint.d.ts +1 -1
- package/dist/{@types/src → src}/helpers/requestModelCheckers.d.ts +2 -2
- package/dist/{@types/src → src}/helpers/utils.d.ts +1 -1
- package/dist/src/mocks/validation.json.d.ts +9 -0
- package/dist/{@types/src → src}/modules/Lib.d.ts +3 -3
- package/dist/{@types/src → src}/modules/QRCodeModal.d.ts +1 -1
- package/dist/{@types/src → src}/modules/Validation.d.ts +1 -1
- package/dist/{@types/src → src}/modules/ValidationModal.d.ts +1 -1
- package/dist/vite.config.d.ts +2 -0
- package/dist/wrapper.es.js +4376 -0
- package/dist/wrapper.es.js.map +1 -0
- package/dist/wrapper.umd.js +2 -0
- package/dist/wrapper.umd.js.map +1 -0
- package/package.json +15 -35
- package/readme.md +7 -0
- package/dist/@types/Fingerprinting/src/@types/Data.d.ts +0 -10
- package/dist/@types/Fingerprinting/src/main.d.ts +0 -29
- package/dist/@types/Fingerprinting/src/modules/batteryInfo.d.ts +0 -7
- package/dist/@types/Fingerprinting/src/modules/browserInfo.d.ts +0 -20
- package/dist/@types/Fingerprinting/src/modules/canvasInfo.d.ts +0 -1
- package/dist/@types/Fingerprinting/src/modules/connectionInfo.d.ts +0 -9
- package/dist/@types/Fingerprinting/src/modules/fontsInfo.d.ts +0 -3
- package/dist/@types/Fingerprinting/src/modules/html5Info.d.ts +0 -8
- package/dist/@types/Fingerprinting/src/modules/ipWebRTCInfo.d.ts +0 -1
- package/dist/@types/Fingerprinting/src/modules/screenInfo.d.ts +0 -14
- package/dist/@types/Fingerprinting/src/modules/timeZoneInfo.d.ts +0 -1
- package/dist/@types/Fingerprinting/src/modules/videoCodecsInfo.d.ts +0 -1
- package/dist/@types/Fingerprinting/src/modules/webGLInfo.d.ts +0 -10
- package/dist/@types/Fingerprinting/src/utils/sha256.d.ts +0 -2
- package/dist/@types/src/helpers/styleInject.d.ts +0 -1
- package/dist/js/wrapper.js +0 -1
- /package/dist/{@types/src → src}/@types/IDVCTypes.d.ts +0 -0
- /package/dist/{@types/src → src}/@types/enums.d.ts +0 -0
- /package/dist/{@types/src → src}/entry.d.ts +0 -0
- /package/dist/{@types/src → src}/errors/WrapperError.d.ts +0 -0
- /package/dist/{@types/src → src}/helpers/mobileChecker.d.ts +0 -0
- /package/dist/{@types/src → src}/helpers/typeGuard.d.ts +0 -0
- /package/dist/{@types/src → src}/helpers/validators.d.ts +0 -0
- /package/dist/{@types/src → src}/mocks/defaultValues.d.ts +0 -0
- /package/dist/{@types/src → src}/modules/Api.d.ts +0 -0
- /package/dist/{@types/src → src}/modules/ConsentForm.d.ts +0 -0
- /package/dist/{@types/src → src}/modules/Modal.d.ts +0 -0
|
@@ -0,0 +1,4376 @@
|
|
|
1
|
+
import './Wrapper.css';var global = void 0;
|
|
2
|
+
function getDefaultExportFromCjs(x) {
|
|
3
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
4
|
+
}
|
|
5
|
+
var runtime = { exports: {} };
|
|
6
|
+
var hasRequiredRuntime;
|
|
7
|
+
function requireRuntime() {
|
|
8
|
+
if (hasRequiredRuntime) return runtime.exports;
|
|
9
|
+
hasRequiredRuntime = 1;
|
|
10
|
+
(function(module) {
|
|
11
|
+
var runtime2 = (function(exports$1) {
|
|
12
|
+
var Op = Object.prototype;
|
|
13
|
+
var hasOwn = Op.hasOwnProperty;
|
|
14
|
+
var defineProperty = Object.defineProperty || function(obj, key, desc) {
|
|
15
|
+
obj[key] = desc.value;
|
|
16
|
+
};
|
|
17
|
+
var undefined$1;
|
|
18
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
19
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
20
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
21
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
22
|
+
function define(obj, key, value) {
|
|
23
|
+
Object.defineProperty(obj, key, {
|
|
24
|
+
value,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true
|
|
28
|
+
});
|
|
29
|
+
return obj[key];
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
define({}, "");
|
|
33
|
+
} catch (err) {
|
|
34
|
+
define = function(obj, key, value) {
|
|
35
|
+
return obj[key] = value;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
39
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
40
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
41
|
+
var context = new Context(tryLocsList || []);
|
|
42
|
+
defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) });
|
|
43
|
+
return generator;
|
|
44
|
+
}
|
|
45
|
+
exports$1.wrap = wrap;
|
|
46
|
+
function tryCatch(fn, obj, arg) {
|
|
47
|
+
try {
|
|
48
|
+
return { type: "normal", arg: fn.call(obj, arg) };
|
|
49
|
+
} catch (err) {
|
|
50
|
+
return { type: "throw", arg: err };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
54
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
55
|
+
var GenStateExecuting = "executing";
|
|
56
|
+
var GenStateCompleted = "completed";
|
|
57
|
+
var ContinueSentinel = {};
|
|
58
|
+
function Generator() {
|
|
59
|
+
}
|
|
60
|
+
function GeneratorFunction() {
|
|
61
|
+
}
|
|
62
|
+
function GeneratorFunctionPrototype() {
|
|
63
|
+
}
|
|
64
|
+
var IteratorPrototype = {};
|
|
65
|
+
define(IteratorPrototype, iteratorSymbol, function() {
|
|
66
|
+
return this;
|
|
67
|
+
});
|
|
68
|
+
var getProto = Object.getPrototypeOf;
|
|
69
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
70
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
71
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
72
|
+
}
|
|
73
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
74
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
75
|
+
defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
|
|
76
|
+
defineProperty(
|
|
77
|
+
GeneratorFunctionPrototype,
|
|
78
|
+
"constructor",
|
|
79
|
+
{ value: GeneratorFunction, configurable: true }
|
|
80
|
+
);
|
|
81
|
+
GeneratorFunction.displayName = define(
|
|
82
|
+
GeneratorFunctionPrototype,
|
|
83
|
+
toStringTagSymbol,
|
|
84
|
+
"GeneratorFunction"
|
|
85
|
+
);
|
|
86
|
+
function defineIteratorMethods(prototype) {
|
|
87
|
+
["next", "throw", "return"].forEach(function(method) {
|
|
88
|
+
define(prototype, method, function(arg) {
|
|
89
|
+
return this._invoke(method, arg);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports$1.isGeneratorFunction = function(genFun) {
|
|
94
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
95
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
96
|
+
// do is to check its .name property.
|
|
97
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
98
|
+
};
|
|
99
|
+
exports$1.mark = function(genFun) {
|
|
100
|
+
if (Object.setPrototypeOf) {
|
|
101
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
102
|
+
} else {
|
|
103
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
104
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
105
|
+
}
|
|
106
|
+
genFun.prototype = Object.create(Gp);
|
|
107
|
+
return genFun;
|
|
108
|
+
};
|
|
109
|
+
exports$1.awrap = function(arg) {
|
|
110
|
+
return { __await: arg };
|
|
111
|
+
};
|
|
112
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
113
|
+
function invoke(method, arg, resolve, reject) {
|
|
114
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
115
|
+
if (record.type === "throw") {
|
|
116
|
+
reject(record.arg);
|
|
117
|
+
} else {
|
|
118
|
+
var result = record.arg;
|
|
119
|
+
var value = result.value;
|
|
120
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
121
|
+
return PromiseImpl.resolve(value.__await).then(function(value2) {
|
|
122
|
+
invoke("next", value2, resolve, reject);
|
|
123
|
+
}, function(err) {
|
|
124
|
+
invoke("throw", err, resolve, reject);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
128
|
+
result.value = unwrapped;
|
|
129
|
+
resolve(result);
|
|
130
|
+
}, function(error) {
|
|
131
|
+
return invoke("throw", error, resolve, reject);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var previousPromise;
|
|
136
|
+
function enqueue(method, arg) {
|
|
137
|
+
function callInvokeWithMethodAndArg() {
|
|
138
|
+
return new PromiseImpl(function(resolve, reject) {
|
|
139
|
+
invoke(method, arg, resolve, reject);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
143
|
+
// all previous Promises have been resolved before calling invoke,
|
|
144
|
+
// so that results are always delivered in the correct order. If
|
|
145
|
+
// enqueue has not been called before, then it is important to
|
|
146
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
147
|
+
// so that the async generator function has the opportunity to do
|
|
148
|
+
// any necessary setup in a predictable way. This predictability
|
|
149
|
+
// is why the Promise constructor synchronously invokes its
|
|
150
|
+
// executor callback, and why async functions synchronously
|
|
151
|
+
// execute code before the first await. Since we implement simple
|
|
152
|
+
// async functions in terms of async generators, it is especially
|
|
153
|
+
// important to get this right, even though it requires care.
|
|
154
|
+
previousPromise ? previousPromise.then(
|
|
155
|
+
callInvokeWithMethodAndArg,
|
|
156
|
+
// Avoid propagating failures to Promises returned by later
|
|
157
|
+
// invocations of the iterator.
|
|
158
|
+
callInvokeWithMethodAndArg
|
|
159
|
+
) : callInvokeWithMethodAndArg();
|
|
160
|
+
}
|
|
161
|
+
defineProperty(this, "_invoke", { value: enqueue });
|
|
162
|
+
}
|
|
163
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
164
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
|
|
165
|
+
return this;
|
|
166
|
+
});
|
|
167
|
+
exports$1.AsyncIterator = AsyncIterator;
|
|
168
|
+
exports$1.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
169
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
170
|
+
var iter = new AsyncIterator(
|
|
171
|
+
wrap(innerFn, outerFn, self, tryLocsList),
|
|
172
|
+
PromiseImpl
|
|
173
|
+
);
|
|
174
|
+
return exports$1.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
|
|
175
|
+
return result.done ? result.value : iter.next();
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
179
|
+
var state = GenStateSuspendedStart;
|
|
180
|
+
return function invoke(method, arg) {
|
|
181
|
+
if (state === GenStateExecuting) {
|
|
182
|
+
throw new Error("Generator is already running");
|
|
183
|
+
}
|
|
184
|
+
if (state === GenStateCompleted) {
|
|
185
|
+
if (method === "throw") {
|
|
186
|
+
throw arg;
|
|
187
|
+
}
|
|
188
|
+
return doneResult();
|
|
189
|
+
}
|
|
190
|
+
context.method = method;
|
|
191
|
+
context.arg = arg;
|
|
192
|
+
while (true) {
|
|
193
|
+
var delegate = context.delegate;
|
|
194
|
+
if (delegate) {
|
|
195
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
196
|
+
if (delegateResult) {
|
|
197
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
198
|
+
return delegateResult;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (context.method === "next") {
|
|
202
|
+
context.sent = context._sent = context.arg;
|
|
203
|
+
} else if (context.method === "throw") {
|
|
204
|
+
if (state === GenStateSuspendedStart) {
|
|
205
|
+
state = GenStateCompleted;
|
|
206
|
+
throw context.arg;
|
|
207
|
+
}
|
|
208
|
+
context.dispatchException(context.arg);
|
|
209
|
+
} else if (context.method === "return") {
|
|
210
|
+
context.abrupt("return", context.arg);
|
|
211
|
+
}
|
|
212
|
+
state = GenStateExecuting;
|
|
213
|
+
var record = tryCatch(innerFn, self, context);
|
|
214
|
+
if (record.type === "normal") {
|
|
215
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
216
|
+
if (record.arg === ContinueSentinel) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
value: record.arg,
|
|
221
|
+
done: context.done
|
|
222
|
+
};
|
|
223
|
+
} else if (record.type === "throw") {
|
|
224
|
+
state = GenStateCompleted;
|
|
225
|
+
context.method = "throw";
|
|
226
|
+
context.arg = record.arg;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
232
|
+
var methodName = context.method;
|
|
233
|
+
var method = delegate.iterator[methodName];
|
|
234
|
+
if (method === undefined$1) {
|
|
235
|
+
context.delegate = null;
|
|
236
|
+
if (methodName === "throw" && delegate.iterator["return"]) {
|
|
237
|
+
context.method = "return";
|
|
238
|
+
context.arg = undefined$1;
|
|
239
|
+
maybeInvokeDelegate(delegate, context);
|
|
240
|
+
if (context.method === "throw") {
|
|
241
|
+
return ContinueSentinel;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (methodName !== "return") {
|
|
245
|
+
context.method = "throw";
|
|
246
|
+
context.arg = new TypeError(
|
|
247
|
+
"The iterator does not provide a '" + methodName + "' method"
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return ContinueSentinel;
|
|
251
|
+
}
|
|
252
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
253
|
+
if (record.type === "throw") {
|
|
254
|
+
context.method = "throw";
|
|
255
|
+
context.arg = record.arg;
|
|
256
|
+
context.delegate = null;
|
|
257
|
+
return ContinueSentinel;
|
|
258
|
+
}
|
|
259
|
+
var info = record.arg;
|
|
260
|
+
if (!info) {
|
|
261
|
+
context.method = "throw";
|
|
262
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
263
|
+
context.delegate = null;
|
|
264
|
+
return ContinueSentinel;
|
|
265
|
+
}
|
|
266
|
+
if (info.done) {
|
|
267
|
+
context[delegate.resultName] = info.value;
|
|
268
|
+
context.next = delegate.nextLoc;
|
|
269
|
+
if (context.method !== "return") {
|
|
270
|
+
context.method = "next";
|
|
271
|
+
context.arg = undefined$1;
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
return info;
|
|
275
|
+
}
|
|
276
|
+
context.delegate = null;
|
|
277
|
+
return ContinueSentinel;
|
|
278
|
+
}
|
|
279
|
+
defineIteratorMethods(Gp);
|
|
280
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
281
|
+
define(Gp, iteratorSymbol, function() {
|
|
282
|
+
return this;
|
|
283
|
+
});
|
|
284
|
+
define(Gp, "toString", function() {
|
|
285
|
+
return "[object Generator]";
|
|
286
|
+
});
|
|
287
|
+
function pushTryEntry(locs) {
|
|
288
|
+
var entry = { tryLoc: locs[0] };
|
|
289
|
+
if (1 in locs) {
|
|
290
|
+
entry.catchLoc = locs[1];
|
|
291
|
+
}
|
|
292
|
+
if (2 in locs) {
|
|
293
|
+
entry.finallyLoc = locs[2];
|
|
294
|
+
entry.afterLoc = locs[3];
|
|
295
|
+
}
|
|
296
|
+
this.tryEntries.push(entry);
|
|
297
|
+
}
|
|
298
|
+
function resetTryEntry(entry) {
|
|
299
|
+
var record = entry.completion || {};
|
|
300
|
+
record.type = "normal";
|
|
301
|
+
delete record.arg;
|
|
302
|
+
entry.completion = record;
|
|
303
|
+
}
|
|
304
|
+
function Context(tryLocsList) {
|
|
305
|
+
this.tryEntries = [{ tryLoc: "root" }];
|
|
306
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
307
|
+
this.reset(true);
|
|
308
|
+
}
|
|
309
|
+
exports$1.keys = function(val) {
|
|
310
|
+
var object = Object(val);
|
|
311
|
+
var keys = [];
|
|
312
|
+
for (var key in object) {
|
|
313
|
+
keys.push(key);
|
|
314
|
+
}
|
|
315
|
+
keys.reverse();
|
|
316
|
+
return function next() {
|
|
317
|
+
while (keys.length) {
|
|
318
|
+
var key2 = keys.pop();
|
|
319
|
+
if (key2 in object) {
|
|
320
|
+
next.value = key2;
|
|
321
|
+
next.done = false;
|
|
322
|
+
return next;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
next.done = true;
|
|
326
|
+
return next;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
function values(iterable) {
|
|
330
|
+
if (iterable) {
|
|
331
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
332
|
+
if (iteratorMethod) {
|
|
333
|
+
return iteratorMethod.call(iterable);
|
|
334
|
+
}
|
|
335
|
+
if (typeof iterable.next === "function") {
|
|
336
|
+
return iterable;
|
|
337
|
+
}
|
|
338
|
+
if (!isNaN(iterable.length)) {
|
|
339
|
+
var i = -1, next = function next2() {
|
|
340
|
+
while (++i < iterable.length) {
|
|
341
|
+
if (hasOwn.call(iterable, i)) {
|
|
342
|
+
next2.value = iterable[i];
|
|
343
|
+
next2.done = false;
|
|
344
|
+
return next2;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
next2.value = undefined$1;
|
|
348
|
+
next2.done = true;
|
|
349
|
+
return next2;
|
|
350
|
+
};
|
|
351
|
+
return next.next = next;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return { next: doneResult };
|
|
355
|
+
}
|
|
356
|
+
exports$1.values = values;
|
|
357
|
+
function doneResult() {
|
|
358
|
+
return { value: undefined$1, done: true };
|
|
359
|
+
}
|
|
360
|
+
Context.prototype = {
|
|
361
|
+
constructor: Context,
|
|
362
|
+
reset: function(skipTempReset) {
|
|
363
|
+
this.prev = 0;
|
|
364
|
+
this.next = 0;
|
|
365
|
+
this.sent = this._sent = undefined$1;
|
|
366
|
+
this.done = false;
|
|
367
|
+
this.delegate = null;
|
|
368
|
+
this.method = "next";
|
|
369
|
+
this.arg = undefined$1;
|
|
370
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
371
|
+
if (!skipTempReset) {
|
|
372
|
+
for (var name in this) {
|
|
373
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
374
|
+
this[name] = undefined$1;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
stop: function() {
|
|
380
|
+
this.done = true;
|
|
381
|
+
var rootEntry = this.tryEntries[0];
|
|
382
|
+
var rootRecord = rootEntry.completion;
|
|
383
|
+
if (rootRecord.type === "throw") {
|
|
384
|
+
throw rootRecord.arg;
|
|
385
|
+
}
|
|
386
|
+
return this.rval;
|
|
387
|
+
},
|
|
388
|
+
dispatchException: function(exception) {
|
|
389
|
+
if (this.done) {
|
|
390
|
+
throw exception;
|
|
391
|
+
}
|
|
392
|
+
var context = this;
|
|
393
|
+
function handle(loc, caught) {
|
|
394
|
+
record.type = "throw";
|
|
395
|
+
record.arg = exception;
|
|
396
|
+
context.next = loc;
|
|
397
|
+
if (caught) {
|
|
398
|
+
context.method = "next";
|
|
399
|
+
context.arg = undefined$1;
|
|
400
|
+
}
|
|
401
|
+
return !!caught;
|
|
402
|
+
}
|
|
403
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
404
|
+
var entry = this.tryEntries[i];
|
|
405
|
+
var record = entry.completion;
|
|
406
|
+
if (entry.tryLoc === "root") {
|
|
407
|
+
return handle("end");
|
|
408
|
+
}
|
|
409
|
+
if (entry.tryLoc <= this.prev) {
|
|
410
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
411
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
412
|
+
if (hasCatch && hasFinally) {
|
|
413
|
+
if (this.prev < entry.catchLoc) {
|
|
414
|
+
return handle(entry.catchLoc, true);
|
|
415
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
416
|
+
return handle(entry.finallyLoc);
|
|
417
|
+
}
|
|
418
|
+
} else if (hasCatch) {
|
|
419
|
+
if (this.prev < entry.catchLoc) {
|
|
420
|
+
return handle(entry.catchLoc, true);
|
|
421
|
+
}
|
|
422
|
+
} else if (hasFinally) {
|
|
423
|
+
if (this.prev < entry.finallyLoc) {
|
|
424
|
+
return handle(entry.finallyLoc);
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
throw new Error("try statement without catch or finally");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
abrupt: function(type, arg) {
|
|
433
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
434
|
+
var entry = this.tryEntries[i];
|
|
435
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
436
|
+
var finallyEntry = entry;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
441
|
+
finallyEntry = null;
|
|
442
|
+
}
|
|
443
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
444
|
+
record.type = type;
|
|
445
|
+
record.arg = arg;
|
|
446
|
+
if (finallyEntry) {
|
|
447
|
+
this.method = "next";
|
|
448
|
+
this.next = finallyEntry.finallyLoc;
|
|
449
|
+
return ContinueSentinel;
|
|
450
|
+
}
|
|
451
|
+
return this.complete(record);
|
|
452
|
+
},
|
|
453
|
+
complete: function(record, afterLoc) {
|
|
454
|
+
if (record.type === "throw") {
|
|
455
|
+
throw record.arg;
|
|
456
|
+
}
|
|
457
|
+
if (record.type === "break" || record.type === "continue") {
|
|
458
|
+
this.next = record.arg;
|
|
459
|
+
} else if (record.type === "return") {
|
|
460
|
+
this.rval = this.arg = record.arg;
|
|
461
|
+
this.method = "return";
|
|
462
|
+
this.next = "end";
|
|
463
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
464
|
+
this.next = afterLoc;
|
|
465
|
+
}
|
|
466
|
+
return ContinueSentinel;
|
|
467
|
+
},
|
|
468
|
+
finish: function(finallyLoc) {
|
|
469
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
470
|
+
var entry = this.tryEntries[i];
|
|
471
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
472
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
473
|
+
resetTryEntry(entry);
|
|
474
|
+
return ContinueSentinel;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
"catch": function(tryLoc) {
|
|
479
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
480
|
+
var entry = this.tryEntries[i];
|
|
481
|
+
if (entry.tryLoc === tryLoc) {
|
|
482
|
+
var record = entry.completion;
|
|
483
|
+
if (record.type === "throw") {
|
|
484
|
+
var thrown = record.arg;
|
|
485
|
+
resetTryEntry(entry);
|
|
486
|
+
}
|
|
487
|
+
return thrown;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
throw new Error("illegal catch attempt");
|
|
491
|
+
},
|
|
492
|
+
delegateYield: function(iterable, resultName, nextLoc) {
|
|
493
|
+
this.delegate = {
|
|
494
|
+
iterator: values(iterable),
|
|
495
|
+
resultName,
|
|
496
|
+
nextLoc
|
|
497
|
+
};
|
|
498
|
+
if (this.method === "next") {
|
|
499
|
+
this.arg = undefined$1;
|
|
500
|
+
}
|
|
501
|
+
return ContinueSentinel;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
return exports$1;
|
|
505
|
+
})(
|
|
506
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
507
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
508
|
+
// object. Either way, the resulting object will be used to initialize
|
|
509
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
510
|
+
module.exports
|
|
511
|
+
);
|
|
512
|
+
try {
|
|
513
|
+
regeneratorRuntime = runtime2;
|
|
514
|
+
} catch (accidentalStrictMode) {
|
|
515
|
+
if (typeof globalThis === "object") {
|
|
516
|
+
globalThis.regeneratorRuntime = runtime2;
|
|
517
|
+
} else {
|
|
518
|
+
Function("r", "regeneratorRuntime = r")(runtime2);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
})(runtime);
|
|
522
|
+
return runtime.exports;
|
|
523
|
+
}
|
|
524
|
+
requireRuntime();
|
|
525
|
+
const notEmptyString = (val) => !!val;
|
|
526
|
+
const isUUID = (str) => !!str.match(/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);
|
|
527
|
+
const isPublicKey = (str) => str.toLowerCase().startsWith("pk_") && isUUID(str);
|
|
528
|
+
const isElExist = (str) => !!document.getElementById(str);
|
|
529
|
+
const isPackageVersionNumber = (input) => {
|
|
530
|
+
const regex2 = /^([1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
531
|
+
return regex2.test(input);
|
|
532
|
+
};
|
|
533
|
+
class WrapperError extends Error {
|
|
534
|
+
}
|
|
535
|
+
class ConfigError extends WrapperError {
|
|
536
|
+
constructor(name) {
|
|
537
|
+
super(name);
|
|
538
|
+
this.message = `Configuration parameter error: ${name}`;
|
|
539
|
+
this.name = "ConfigError";
|
|
540
|
+
this.header = "Configuration Error!";
|
|
541
|
+
this.content = name || "";
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const defaultDocumentTypes = [
|
|
545
|
+
{
|
|
546
|
+
type: "DL",
|
|
547
|
+
steps: [
|
|
548
|
+
{
|
|
549
|
+
type: "front",
|
|
550
|
+
name: "Document Front",
|
|
551
|
+
mode: { uploader: true, video: true },
|
|
552
|
+
autocaptureDelay: 0,
|
|
553
|
+
enableDesktopNotification: false
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
type: "pdf",
|
|
557
|
+
name: "Document Back",
|
|
558
|
+
mode: { uploader: true, video: true },
|
|
559
|
+
autocaptureDelay: 0,
|
|
560
|
+
enableDesktopNotification: false,
|
|
561
|
+
enableFourCornerCapture: false
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
type: "face",
|
|
565
|
+
name: "Face",
|
|
566
|
+
mode: { uploader: true, video: true },
|
|
567
|
+
autocaptureDelay: 0,
|
|
568
|
+
enableDesktopNotification: false
|
|
569
|
+
}
|
|
570
|
+
]
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
type: "IC",
|
|
574
|
+
steps: [
|
|
575
|
+
{
|
|
576
|
+
type: "front",
|
|
577
|
+
name: "Document Front",
|
|
578
|
+
mode: { uploader: true, video: true },
|
|
579
|
+
autocaptureDelay: 0,
|
|
580
|
+
enableDesktopNotification: false
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
type: "pdf",
|
|
584
|
+
name: "Document Back",
|
|
585
|
+
mode: { uploader: true, video: true },
|
|
586
|
+
autocaptureDelay: 0,
|
|
587
|
+
enableDesktopNotification: false,
|
|
588
|
+
enableFourCornerCapture: true
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
type: "face",
|
|
592
|
+
name: "Face",
|
|
593
|
+
mode: { uploader: true, video: true },
|
|
594
|
+
autocaptureDelay: 0,
|
|
595
|
+
enableDesktopNotification: false
|
|
596
|
+
}
|
|
597
|
+
]
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
type: "Passport",
|
|
601
|
+
steps: [
|
|
602
|
+
// { type: 'front', name: 'Document Front', mode: { uploader: true, video: true } },
|
|
603
|
+
{
|
|
604
|
+
type: "mrz",
|
|
605
|
+
name: "Document Front",
|
|
606
|
+
mode: { uploader: true, video: true },
|
|
607
|
+
autocaptureDelay: 0,
|
|
608
|
+
enableDesktopNotification: false
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
type: "face",
|
|
612
|
+
name: "Face",
|
|
613
|
+
mode: { uploader: true, video: true },
|
|
614
|
+
autocaptureDelay: 0,
|
|
615
|
+
enableDesktopNotification: false
|
|
616
|
+
}
|
|
617
|
+
]
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
type: "PassportCard",
|
|
621
|
+
steps: [
|
|
622
|
+
{
|
|
623
|
+
type: "front",
|
|
624
|
+
name: "Document Front",
|
|
625
|
+
mode: { uploader: true, video: true },
|
|
626
|
+
autocaptureDelay: 0,
|
|
627
|
+
enableDesktopNotification: false
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
type: "mrz",
|
|
631
|
+
name: "Document Back",
|
|
632
|
+
mode: { uploader: true, video: true },
|
|
633
|
+
autocaptureDelay: 0,
|
|
634
|
+
enableDesktopNotification: false
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
type: "face",
|
|
638
|
+
name: "Face",
|
|
639
|
+
mode: { uploader: true, video: true },
|
|
640
|
+
autocaptureDelay: 0,
|
|
641
|
+
enableDesktopNotification: false
|
|
642
|
+
}
|
|
643
|
+
]
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
type: "GreenCard",
|
|
647
|
+
steps: [
|
|
648
|
+
{
|
|
649
|
+
type: "front",
|
|
650
|
+
name: "Document Front",
|
|
651
|
+
mode: { uploader: true, video: true },
|
|
652
|
+
autocaptureDelay: 0,
|
|
653
|
+
enableDesktopNotification: false
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
type: "mrz",
|
|
657
|
+
name: "Document Back",
|
|
658
|
+
mode: { uploader: true, video: true },
|
|
659
|
+
autocaptureDelay: 0,
|
|
660
|
+
enableDesktopNotification: false
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
type: "face",
|
|
664
|
+
name: "Face",
|
|
665
|
+
mode: { uploader: true, video: true },
|
|
666
|
+
autocaptureDelay: 0,
|
|
667
|
+
enableDesktopNotification: false
|
|
668
|
+
}
|
|
669
|
+
]
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
type: "EmploymentAuthorization",
|
|
673
|
+
steps: [
|
|
674
|
+
{ type: "front", name: "Document Front", mode: { uploader: true, video: true } },
|
|
675
|
+
{ type: "mrz", name: "Document Back", mode: { uploader: true, video: true } },
|
|
676
|
+
{ type: "face", name: "Face", mode: { uploader: true, video: true } }
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
];
|
|
680
|
+
const createGuid = () => {
|
|
681
|
+
const s4 = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
682
|
+
return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
|
|
683
|
+
};
|
|
684
|
+
const getFilteredDocumentTypes = (documentTypes) => {
|
|
685
|
+
if (!documentTypes) {
|
|
686
|
+
return [];
|
|
687
|
+
}
|
|
688
|
+
return documentTypes.map((document2) => ({
|
|
689
|
+
...document2,
|
|
690
|
+
steps: document2.steps.filter((step) => step.mode ? Object.values(step.mode).some(Boolean) : true)
|
|
691
|
+
})).filter((document2) => document2.steps.length).map((document2) => ({
|
|
692
|
+
type: document2.type,
|
|
693
|
+
steps: document2.steps
|
|
694
|
+
}));
|
|
695
|
+
};
|
|
696
|
+
const prepareDocumentTypes = (config) => {
|
|
697
|
+
let result;
|
|
698
|
+
const filteredDocuments = getFilteredDocumentTypes(config.documentTypes);
|
|
699
|
+
const passportDocument = filteredDocuments.find((document2) => document2.type === "Passport");
|
|
700
|
+
if (passportDocument) {
|
|
701
|
+
const mrzPassport = { type: "mrz", name: "Passport MRZ", mode: { uploader: true, video: true } };
|
|
702
|
+
const frontStepIndex = passportDocument.steps.findIndex((step) => step.type === "front");
|
|
703
|
+
if (frontStepIndex !== -1) {
|
|
704
|
+
passportDocument.steps.splice(frontStepIndex, 1, mrzPassport);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if (filteredDocuments.length === 0) {
|
|
708
|
+
result = defaultDocumentTypes;
|
|
709
|
+
} else {
|
|
710
|
+
result = filteredDocuments;
|
|
711
|
+
}
|
|
712
|
+
return result;
|
|
713
|
+
};
|
|
714
|
+
const getQueryParam = (param) => {
|
|
715
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
716
|
+
return urlParams.get(param);
|
|
717
|
+
};
|
|
718
|
+
const validateHOF = ({ name, value, validationFunctions }) => {
|
|
719
|
+
const res = validationFunctions.reduce((acc, validationFn) => acc && validationFn(value), true);
|
|
720
|
+
if (!res) {
|
|
721
|
+
throw new ConfigError(name);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
const validateApplicantId = (applicantId) => {
|
|
725
|
+
const uuidValidationFunctions = [notEmptyString, isUUID];
|
|
726
|
+
const validateConfig = {
|
|
727
|
+
name: "applicantId",
|
|
728
|
+
value: applicantId,
|
|
729
|
+
validationFunctions: uuidValidationFunctions
|
|
730
|
+
};
|
|
731
|
+
validateHOF(validateConfig);
|
|
732
|
+
};
|
|
733
|
+
const validateWrapperConfig = ({
|
|
734
|
+
demoMode,
|
|
735
|
+
applicantId,
|
|
736
|
+
domainId,
|
|
737
|
+
domainApi,
|
|
738
|
+
publicKey,
|
|
739
|
+
el = "videoCapturingEl"
|
|
740
|
+
}) => {
|
|
741
|
+
const uuidValidationFunctions = [notEmptyString, isUUID];
|
|
742
|
+
const pkValidationFunctions = [notEmptyString, isPublicKey];
|
|
743
|
+
const elValidationFunctions = [notEmptyString, isElExist];
|
|
744
|
+
[
|
|
745
|
+
demoMode ? null : {
|
|
746
|
+
name: "applicantId",
|
|
747
|
+
value: applicantId,
|
|
748
|
+
validationFunctions: uuidValidationFunctions
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: "domainId",
|
|
752
|
+
value: domainId,
|
|
753
|
+
validationFunctions: uuidValidationFunctions
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "publicKey",
|
|
757
|
+
value: publicKey,
|
|
758
|
+
validationFunctions: pkValidationFunctions
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
name: "el",
|
|
762
|
+
value: el,
|
|
763
|
+
validationFunctions: elValidationFunctions
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
name: "domainApi should not be empty",
|
|
767
|
+
value: domainApi,
|
|
768
|
+
validationFunctions: [notEmptyString]
|
|
769
|
+
}
|
|
770
|
+
].filter(Boolean).forEach((e) => validateHOF(e));
|
|
771
|
+
};
|
|
772
|
+
class Configs {
|
|
773
|
+
constructor(config) {
|
|
774
|
+
this.validate = () => {
|
|
775
|
+
validateWrapperConfig(this.wrapper);
|
|
776
|
+
};
|
|
777
|
+
this.wrapper = { ...config };
|
|
778
|
+
if (config.getApplicantIdFromURL) {
|
|
779
|
+
this.wrapper.applicantId = getQueryParam("requestId") || config.applicantId;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
parseFromWeb(options) {
|
|
783
|
+
const parsedIDVCConfig = JSON.parse(options == null ? void 0 : options.jsonSettings);
|
|
784
|
+
if (this.isAuth || this.faceOnly) {
|
|
785
|
+
this.libConfig = this.faceAuthorizationConfig(parsedIDVCConfig);
|
|
786
|
+
} else {
|
|
787
|
+
parsedIDVCConfig.documentTypes = prepareDocumentTypes(parsedIDVCConfig);
|
|
788
|
+
this.libConfig = parsedIDVCConfig;
|
|
789
|
+
}
|
|
790
|
+
this.cssStyles = options == null ? void 0 : options.cssStyles;
|
|
791
|
+
this.cssVariables = options == null ? void 0 : options.cssVariables;
|
|
792
|
+
}
|
|
793
|
+
faceAuthorizationConfig(jsonSettings) {
|
|
794
|
+
jsonSettings.isShowDocumentTypeSelect = false;
|
|
795
|
+
jsonSettings.documentTypes = [
|
|
796
|
+
{
|
|
797
|
+
type: "DL",
|
|
798
|
+
steps: [
|
|
799
|
+
{ type: "face", name: "Face", mode: { uploader: true, video: true } }
|
|
800
|
+
]
|
|
801
|
+
}
|
|
802
|
+
];
|
|
803
|
+
return jsonSettings;
|
|
804
|
+
}
|
|
805
|
+
getFirstStepModeState() {
|
|
806
|
+
const firstStepMode = structuredClone(this.firstStepMode);
|
|
807
|
+
return () => firstStepMode;
|
|
808
|
+
}
|
|
809
|
+
get firstStepMode() {
|
|
810
|
+
var _a, _b, _c;
|
|
811
|
+
return (_c = (_b = (_a = this.libConfig) == null ? void 0 : _a.documentTypes[0]) == null ? void 0 : _b.steps[0]) == null ? void 0 : _c.mode;
|
|
812
|
+
}
|
|
813
|
+
set applicantId(applicantId) {
|
|
814
|
+
validateApplicantId(applicantId);
|
|
815
|
+
this.wrapper.applicantId = applicantId;
|
|
816
|
+
}
|
|
817
|
+
get applicantId() {
|
|
818
|
+
return this.wrapper.applicantId;
|
|
819
|
+
}
|
|
820
|
+
get domainId() {
|
|
821
|
+
return this.wrapper.domainId;
|
|
822
|
+
}
|
|
823
|
+
get publicKey() {
|
|
824
|
+
return this.wrapper.publicKey;
|
|
825
|
+
}
|
|
826
|
+
get domainApi() {
|
|
827
|
+
return this.wrapper.domainApi;
|
|
828
|
+
}
|
|
829
|
+
get onValidate() {
|
|
830
|
+
var _a, _b;
|
|
831
|
+
if ((_b = (_a = this.wrapper) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onValidate) {
|
|
832
|
+
return this.wrapper.callbacks.onValidate;
|
|
833
|
+
}
|
|
834
|
+
return () => {
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
get onError() {
|
|
838
|
+
var _a, _b;
|
|
839
|
+
if ((_b = (_a = this.wrapper) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onError) {
|
|
840
|
+
return this.wrapper.callbacks.onError;
|
|
841
|
+
}
|
|
842
|
+
return () => {
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
get onGetOptionsStart() {
|
|
846
|
+
var _a, _b;
|
|
847
|
+
if ((_b = (_a = this.wrapper) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onGetOptionsStart) {
|
|
848
|
+
return this.wrapper.callbacks.onGetOptionsStart;
|
|
849
|
+
}
|
|
850
|
+
return () => {
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
get onGetOptionsComplete() {
|
|
854
|
+
var _a, _b;
|
|
855
|
+
if ((_b = (_a = this.wrapper) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onGetOptionsComplete) {
|
|
856
|
+
return this.wrapper.callbacks.onGetOptionsComplete;
|
|
857
|
+
}
|
|
858
|
+
return () => {
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
set libConfig(config) {
|
|
862
|
+
var _a;
|
|
863
|
+
const prevLC = (_a = this.IDVCConfig) == null ? void 0 : _a.licenseKey;
|
|
864
|
+
if (this.wrapper.preferApiConfig) {
|
|
865
|
+
this.IDVCConfig = {
|
|
866
|
+
...this.IDVCConfig,
|
|
867
|
+
...config,
|
|
868
|
+
...this.wrapper.callbacks
|
|
869
|
+
};
|
|
870
|
+
} else {
|
|
871
|
+
this.IDVCConfig = {
|
|
872
|
+
...this.IDVCConfig,
|
|
873
|
+
...config,
|
|
874
|
+
...this.wrapper,
|
|
875
|
+
...this.wrapper.callbacks
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
if (prevLC) {
|
|
879
|
+
this.IDVCConfig.licenseKey = prevLC;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
get libConfig() {
|
|
883
|
+
return this.IDVCConfig || {};
|
|
884
|
+
}
|
|
885
|
+
get cssStylesConfig() {
|
|
886
|
+
return this.cssStyles;
|
|
887
|
+
}
|
|
888
|
+
get cssVariablesConfig() {
|
|
889
|
+
return this.cssVariables;
|
|
890
|
+
}
|
|
891
|
+
get mountElement() {
|
|
892
|
+
return this.wrapper.el || "videoCapturingEl";
|
|
893
|
+
}
|
|
894
|
+
get demoMode() {
|
|
895
|
+
return this.wrapper.demoMode || false;
|
|
896
|
+
}
|
|
897
|
+
get isAuth() {
|
|
898
|
+
return this.wrapper.isAuth || false;
|
|
899
|
+
}
|
|
900
|
+
get faceOnly() {
|
|
901
|
+
return this.wrapper.faceOnly || false;
|
|
902
|
+
}
|
|
903
|
+
get qrCodeLinkOrigin() {
|
|
904
|
+
return this.wrapper.qrCodeLinkOrigin || "https://diveonline.idscan.net";
|
|
905
|
+
}
|
|
906
|
+
get IDVCDownloadVersion() {
|
|
907
|
+
if (isPackageVersionNumber(this.wrapper.IDVCDownloadVersion || "")) {
|
|
908
|
+
return this.wrapper.IDVCDownloadVersion;
|
|
909
|
+
}
|
|
910
|
+
return "latest";
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
class NotValidApplicant extends WrapperError {
|
|
914
|
+
constructor(name) {
|
|
915
|
+
super(name);
|
|
916
|
+
this.message = "This application is closed";
|
|
917
|
+
this.name = "NotValidApplicant";
|
|
918
|
+
this.header = "Request Closed";
|
|
919
|
+
this.content = "This application is closed";
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
class ValidationError extends WrapperError {
|
|
923
|
+
constructor(error) {
|
|
924
|
+
super("ValidationError");
|
|
925
|
+
this.message = error.message || "Try again later";
|
|
926
|
+
this.name = "ValidationError";
|
|
927
|
+
this.setHeader(error);
|
|
928
|
+
this.content = error.message || "Try again later";
|
|
929
|
+
if (error == null ? void 0 : error.propertyErrors) {
|
|
930
|
+
const errorList = Object.values(error.propertyErrors).reduce((acc, errorText) => `${acc}<li class="idvc-modal__body__list__item">${errorText}</li>`, "");
|
|
931
|
+
this.content = `<ol class="idvc-modal__body__list">${errorList}</ol>`;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
setHeader({ code = "" }) {
|
|
935
|
+
if (code && ["ApiError", "ValidationError", "MultipleErrors", "BadRequest"].includes(code)) {
|
|
936
|
+
this.header = "Something Went Wrong!";
|
|
937
|
+
} else {
|
|
938
|
+
this.header = "Data invalid";
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
class HttpError extends WrapperError {
|
|
943
|
+
constructor(response) {
|
|
944
|
+
super(response.status.toString());
|
|
945
|
+
const { status } = response;
|
|
946
|
+
let message;
|
|
947
|
+
switch (status) {
|
|
948
|
+
case 400:
|
|
949
|
+
message = "Bad Request";
|
|
950
|
+
break;
|
|
951
|
+
case 401:
|
|
952
|
+
message = "Unauthorized";
|
|
953
|
+
break;
|
|
954
|
+
case 403:
|
|
955
|
+
message = "Forbidden";
|
|
956
|
+
break;
|
|
957
|
+
case 404:
|
|
958
|
+
message = "Not Found";
|
|
959
|
+
break;
|
|
960
|
+
case 500:
|
|
961
|
+
message = "Server Error";
|
|
962
|
+
break;
|
|
963
|
+
default:
|
|
964
|
+
message = "Something Went Wrong!";
|
|
965
|
+
}
|
|
966
|
+
this.message = `Status code: ${status}. ${message}`;
|
|
967
|
+
this.name = "HttpError";
|
|
968
|
+
this.statusCode = status;
|
|
969
|
+
this.header = "Server Side Problems";
|
|
970
|
+
this.content = "Please try again later";
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
class RequestTimeoutError extends WrapperError {
|
|
974
|
+
constructor(name) {
|
|
975
|
+
super(name);
|
|
976
|
+
this.message = "This application is closed";
|
|
977
|
+
this.name = "RequestTimeoutError";
|
|
978
|
+
this.header = "Request Timeout";
|
|
979
|
+
this.content = "This application is closed";
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
const success = { "validationResponseId": 6223, "validationRequestId": "8151f48d-bab1-4491-037d-08d9b3c5cfec", "documentType": 1, "document": { "abbr3Country": "USA", "abbrCountry": "US", "address": "25805 VAN LEUVEN ST 136", "city": "LOMA LINDA", "class": "C", "country": "United States of America", "dob": "1961-01-07", "expires": "2024-01-07", "eyes": "Brown", "familyName": "GILMER", "firstName": "DARIENNE", "fullName": "DARIENNE ELIZABETH GILMER", "gender": "Female", "hair": "Black", "height": "064 IN", "id": "C3568758", "idType": "DL", "issued": "2019-01-07", "middleName": "ELIZABETH", "postalBox": null, "privateName": "ELIZABETH", "state": "CA", "template": "09", "weight": "77", "zip": "92354-0000" }, "attemptsLeft": 0, "status": 0, "validationStatus": { "expired": false, "documentIsValid": true, "faceIsValid": true }, "invalidDataErrors": null, "faceSuccess": null, "documentSuccess": null, "documentHasNotExpired": null, "documentValidationTests": [{ "displayName": "DMV", "name": "DMVValidation", "status": 0, "statusString": "Failed", "reason": "Internal Server Error" }, { "displayName": "IdentiFraud", "name": "IdentiFraudValidation", "status": -1, "statusString": "Disabled", "reason": "Integration was turned off" }] };
|
|
983
|
+
const json = {
|
|
984
|
+
success
|
|
985
|
+
};
|
|
986
|
+
class FaceAuthorizationError extends WrapperError {
|
|
987
|
+
constructor(error) {
|
|
988
|
+
super("FaceAuthorizationError");
|
|
989
|
+
this.message = error.message || "Try again later";
|
|
990
|
+
this.name = "FaceAuthorizationError";
|
|
991
|
+
this.setHeader(error);
|
|
992
|
+
this.content = error.message || "Try again later";
|
|
993
|
+
if (error == null ? void 0 : error.propertyErrors) {
|
|
994
|
+
const errorList = Object.values(error.propertyErrors).reduce((acc, errorText) => `${acc}<li class="idvc-modal__body__list__item">${errorText}</li>`, "");
|
|
995
|
+
this.content = `<ol class="idvc-modal__body__list">${errorList}</ol>`;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
setHeader({ code = "" }) {
|
|
999
|
+
if (code && ["ApiError", "ValidationError", "MultipleErrors", "BadRequest"].includes(code)) {
|
|
1000
|
+
this.header = "Something Went Wrong!";
|
|
1001
|
+
} else {
|
|
1002
|
+
this.header = "Data invalid";
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
var ValidationStatus = /* @__PURE__ */ ((ValidationStatus2) => {
|
|
1007
|
+
ValidationStatus2["DANGER"] = "danger";
|
|
1008
|
+
ValidationStatus2["SUCCESS"] = "success";
|
|
1009
|
+
ValidationStatus2["PRIMARY"] = "primary";
|
|
1010
|
+
return ValidationStatus2;
|
|
1011
|
+
})(ValidationStatus || {});
|
|
1012
|
+
var ResponseStatus = /* @__PURE__ */ ((ResponseStatus2) => {
|
|
1013
|
+
ResponseStatus2[ResponseStatus2["SUCCESS"] = 0] = "SUCCESS";
|
|
1014
|
+
ResponseStatus2[ResponseStatus2["FAIL"] = 1] = "FAIL";
|
|
1015
|
+
ResponseStatus2[ResponseStatus2["INVALID_DATA"] = 2] = "INVALID_DATA";
|
|
1016
|
+
ResponseStatus2[ResponseStatus2["ERROR"] = 3] = "ERROR";
|
|
1017
|
+
ResponseStatus2[ResponseStatus2["COMPLETE"] = 4] = "COMPLETE";
|
|
1018
|
+
return ResponseStatus2;
|
|
1019
|
+
})(ResponseStatus || {});
|
|
1020
|
+
var QRCodeModalState = /* @__PURE__ */ ((QRCodeModalState2) => {
|
|
1021
|
+
QRCodeModalState2["READY"] = "ready";
|
|
1022
|
+
QRCodeModalState2["VALIDATING"] = "validating";
|
|
1023
|
+
QRCodeModalState2["DONE_WITH_SUCCESS"] = "doneWithSuccess";
|
|
1024
|
+
QRCodeModalState2["DONE_WITH_ERROR"] = "doneWithError";
|
|
1025
|
+
return QRCodeModalState2;
|
|
1026
|
+
})(QRCodeModalState || {});
|
|
1027
|
+
var EmbeddedStatus = /* @__PURE__ */ ((EmbeddedStatus2) => {
|
|
1028
|
+
EmbeddedStatus2[EmbeddedStatus2["NEVER_OPEN"] = 0] = "NEVER_OPEN";
|
|
1029
|
+
EmbeddedStatus2[EmbeddedStatus2["OPEN"] = 1] = "OPEN";
|
|
1030
|
+
EmbeddedStatus2[EmbeddedStatus2["CLOSED"] = 2] = "CLOSED";
|
|
1031
|
+
EmbeddedStatus2[EmbeddedStatus2["CLOSED_FOREVER"] = 3] = "CLOSED_FOREVER";
|
|
1032
|
+
return EmbeddedStatus2;
|
|
1033
|
+
})(EmbeddedStatus || {});
|
|
1034
|
+
var ClientType = /* @__PURE__ */ ((ClientType2) => {
|
|
1035
|
+
ClientType2[ClientType2["WebLibStandalone"] = 0] = "WebLibStandalone";
|
|
1036
|
+
ClientType2[ClientType2["WebLibDashboard"] = 1] = "WebLibDashboard";
|
|
1037
|
+
ClientType2[ClientType2["Android"] = 2] = "Android";
|
|
1038
|
+
ClientType2[ClientType2["Ios"] = 3] = "Ios";
|
|
1039
|
+
return ClientType2;
|
|
1040
|
+
})(ClientType || {});
|
|
1041
|
+
var NotificationText = /* @__PURE__ */ ((NotificationText2) => {
|
|
1042
|
+
NotificationText2[NotificationText2[""] = 0] = "";
|
|
1043
|
+
NotificationText2[NotificationText2["sent via SMS"] = 1] = "sent via SMS";
|
|
1044
|
+
NotificationText2[NotificationText2["sent via email"] = 2] = "sent via email";
|
|
1045
|
+
NotificationText2[NotificationText2["sent via SMS or email"] = 3] = "sent via SMS or email";
|
|
1046
|
+
return NotificationText2;
|
|
1047
|
+
})(NotificationText || {});
|
|
1048
|
+
var DocumentTypeIDs = /* @__PURE__ */ ((DocumentTypeIDs2) => {
|
|
1049
|
+
DocumentTypeIDs2[DocumentTypeIDs2["DL"] = 1] = "DL";
|
|
1050
|
+
DocumentTypeIDs2[DocumentTypeIDs2["Passport"] = 2] = "Passport";
|
|
1051
|
+
DocumentTypeIDs2[DocumentTypeIDs2["PassportCard"] = 3] = "PassportCard";
|
|
1052
|
+
DocumentTypeIDs2[DocumentTypeIDs2["CommonAccessCardOld"] = 4] = "CommonAccessCardOld";
|
|
1053
|
+
DocumentTypeIDs2[DocumentTypeIDs2["CommonAccessCard"] = 5] = "CommonAccessCard";
|
|
1054
|
+
DocumentTypeIDs2[DocumentTypeIDs2["GreenCard"] = 6] = "GreenCard";
|
|
1055
|
+
DocumentTypeIDs2[DocumentTypeIDs2["InternationalId"] = 7] = "InternationalId";
|
|
1056
|
+
DocumentTypeIDs2[DocumentTypeIDs2["VIN"] = 8] = "VIN";
|
|
1057
|
+
DocumentTypeIDs2[DocumentTypeIDs2["Barcode"] = 11] = "Barcode";
|
|
1058
|
+
DocumentTypeIDs2[DocumentTypeIDs2["FaceAuthorization"] = 10] = "FaceAuthorization";
|
|
1059
|
+
DocumentTypeIDs2[DocumentTypeIDs2["EmploymentAuthorization"] = 9] = "EmploymentAuthorization";
|
|
1060
|
+
return DocumentTypeIDs2;
|
|
1061
|
+
})(DocumentTypeIDs || {});
|
|
1062
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
1063
|
+
HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
|
|
1064
|
+
HttpStatus2[HttpStatus2["Created"] = 201] = "Created";
|
|
1065
|
+
HttpStatus2[HttpStatus2["Accepted"] = 202] = "Accepted";
|
|
1066
|
+
HttpStatus2[HttpStatus2["NoContent"] = 204] = "NoContent";
|
|
1067
|
+
HttpStatus2[HttpStatus2["BadRequest"] = 400] = "BadRequest";
|
|
1068
|
+
HttpStatus2[HttpStatus2["Unauthorized"] = 401] = "Unauthorized";
|
|
1069
|
+
HttpStatus2[HttpStatus2["PaymentRequired"] = 402] = "PaymentRequired";
|
|
1070
|
+
HttpStatus2[HttpStatus2["Forbidden"] = 403] = "Forbidden";
|
|
1071
|
+
HttpStatus2[HttpStatus2["NotFound"] = 404] = "NotFound";
|
|
1072
|
+
HttpStatus2[HttpStatus2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
1073
|
+
HttpStatus2[HttpStatus2["Gone"] = 410] = "Gone";
|
|
1074
|
+
HttpStatus2[HttpStatus2["RequestTimeout"] = 408] = "RequestTimeout";
|
|
1075
|
+
HttpStatus2[HttpStatus2["Conflict"] = 409] = "Conflict";
|
|
1076
|
+
HttpStatus2[HttpStatus2["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
1077
|
+
HttpStatus2[HttpStatus2["LengthRequired"] = 411] = "LengthRequired";
|
|
1078
|
+
HttpStatus2[HttpStatus2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
1079
|
+
HttpStatus2[HttpStatus2["RequestEntityTooLarge"] = 413] = "RequestEntityTooLarge";
|
|
1080
|
+
HttpStatus2[HttpStatus2["RequestURITooLong"] = 414] = "RequestURITooLong";
|
|
1081
|
+
HttpStatus2[HttpStatus2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
1082
|
+
HttpStatus2[HttpStatus2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
1083
|
+
HttpStatus2[HttpStatus2["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
1084
|
+
HttpStatus2[HttpStatus2["ImATextDocument"] = 423] = "ImATextDocument";
|
|
1085
|
+
HttpStatus2[HttpStatus2["Locked"] = 423] = "Locked";
|
|
1086
|
+
HttpStatus2[HttpStatus2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
1087
|
+
HttpStatus2[HttpStatus2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
1088
|
+
HttpStatus2[HttpStatus2["InternalServerError"] = 500] = "InternalServerError";
|
|
1089
|
+
HttpStatus2[HttpStatus2["NotImplemented"] = 501] = "NotImplemented";
|
|
1090
|
+
HttpStatus2[HttpStatus2["BadGateway"] = 502] = "BadGateway";
|
|
1091
|
+
HttpStatus2[HttpStatus2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
1092
|
+
HttpStatus2[HttpStatus2["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
1093
|
+
HttpStatus2[HttpStatus2["HTTPVersionNotSupported"] = 505] = "HTTPVersionNotSupported";
|
|
1094
|
+
HttpStatus2[HttpStatus2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
1095
|
+
HttpStatus2[HttpStatus2["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
1096
|
+
HttpStatus2[HttpStatus2["NetworkConnectTimeoutError"] = 524] = "NetworkConnectTimeoutError";
|
|
1097
|
+
return HttpStatus2;
|
|
1098
|
+
})(HttpStatus || {});
|
|
1099
|
+
class Api {
|
|
1100
|
+
constructor(publicKey, domainApi = "https://api-dvsonline.idscan.net") {
|
|
1101
|
+
this.idvcManifestUrl = "https://neurons.cdn.idscan.net/manifest.json";
|
|
1102
|
+
this.HEADERS = {
|
|
1103
|
+
"Content-Type": "application/json"
|
|
1104
|
+
};
|
|
1105
|
+
const baseUrl = `${domainApi}/api/v2/`;
|
|
1106
|
+
this.baseUrl = `${baseUrl}public/`;
|
|
1107
|
+
this.baseEmbeddedUrl = `${baseUrl}EmbeddedApp/`;
|
|
1108
|
+
this.HEADERS.Authorization = `Bearer ${publicKey}`;
|
|
1109
|
+
}
|
|
1110
|
+
async checkApplicantIdIsNotClosed({
|
|
1111
|
+
applicantId = "",
|
|
1112
|
+
demoMode = false,
|
|
1113
|
+
faceAuth = false,
|
|
1114
|
+
faceOnly = false
|
|
1115
|
+
}) {
|
|
1116
|
+
if (demoMode) {
|
|
1117
|
+
return true;
|
|
1118
|
+
}
|
|
1119
|
+
const url = `${this.baseUrl}Applicants/${applicantId}/Completed`;
|
|
1120
|
+
const response = await fetch(url, {
|
|
1121
|
+
method: "GET",
|
|
1122
|
+
headers: this.HEADERS
|
|
1123
|
+
});
|
|
1124
|
+
if (response.ok && !faceAuth) {
|
|
1125
|
+
throw new NotValidApplicant("request closed");
|
|
1126
|
+
} else if (response.ok && faceAuth) {
|
|
1127
|
+
return true;
|
|
1128
|
+
} else if (HttpStatus.NotFound === response.status && faceAuth) {
|
|
1129
|
+
throw new NotValidApplicant("validation not completed");
|
|
1130
|
+
} else if (HttpStatus.NotFound === response.status && (!faceAuth || faceOnly)) {
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
if (HttpStatus.BadRequest === response.status) {
|
|
1134
|
+
const responseData = await response.json();
|
|
1135
|
+
throw new ValidationError(responseData);
|
|
1136
|
+
} else {
|
|
1137
|
+
throw new HttpError(response);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
async getCurrentIdvcVersion() {
|
|
1141
|
+
try {
|
|
1142
|
+
const response = await fetch(this.idvcManifestUrl);
|
|
1143
|
+
if (!response.ok) {
|
|
1144
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1145
|
+
}
|
|
1146
|
+
const jsonData = await response.json();
|
|
1147
|
+
return jsonData.latestVersion;
|
|
1148
|
+
} catch (error) {
|
|
1149
|
+
console.error("Error fetching data:", error);
|
|
1150
|
+
throw error;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
async getOptions(integrationId) {
|
|
1154
|
+
const url = `${this.baseUrl}Integrations/${integrationId}/Configuration`;
|
|
1155
|
+
try {
|
|
1156
|
+
const response = await fetch(url, {
|
|
1157
|
+
method: "GET",
|
|
1158
|
+
headers: this.HEADERS
|
|
1159
|
+
});
|
|
1160
|
+
if (response.ok) {
|
|
1161
|
+
return await response.json();
|
|
1162
|
+
}
|
|
1163
|
+
throw new HttpError(response);
|
|
1164
|
+
} catch (e) {
|
|
1165
|
+
if (e instanceof HttpError) {
|
|
1166
|
+
throw e;
|
|
1167
|
+
} else {
|
|
1168
|
+
throw new HttpError(e);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
async validateApplicant(data, demoMode = false, isFaceAuth = false) {
|
|
1173
|
+
if (demoMode) {
|
|
1174
|
+
return json.success;
|
|
1175
|
+
}
|
|
1176
|
+
const url = `${this.baseUrl}Validation`;
|
|
1177
|
+
const response = await fetch(url, {
|
|
1178
|
+
method: "POST",
|
|
1179
|
+
headers: this.HEADERS,
|
|
1180
|
+
body: JSON.stringify(data)
|
|
1181
|
+
});
|
|
1182
|
+
if (response.ok) {
|
|
1183
|
+
return response.json();
|
|
1184
|
+
}
|
|
1185
|
+
if (HttpStatus.BadRequest === response.status) {
|
|
1186
|
+
const responseData = await response.json();
|
|
1187
|
+
if (isFaceAuth) {
|
|
1188
|
+
throw new FaceAuthorizationError(responseData);
|
|
1189
|
+
}
|
|
1190
|
+
throw new ValidationError(responseData);
|
|
1191
|
+
} else if (HttpStatus.NotFound === response.status) {
|
|
1192
|
+
const responseData = await response.json();
|
|
1193
|
+
throw new FaceAuthorizationError(responseData);
|
|
1194
|
+
} else {
|
|
1195
|
+
throw new HttpError(response);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
async forceClose(applicantId) {
|
|
1199
|
+
const url = `${this.baseUrl}Applicants/${applicantId}/Complete`;
|
|
1200
|
+
const response = await fetch(url, {
|
|
1201
|
+
method: "POST",
|
|
1202
|
+
headers: this.HEADERS
|
|
1203
|
+
});
|
|
1204
|
+
if (response.ok) {
|
|
1205
|
+
return response.json();
|
|
1206
|
+
}
|
|
1207
|
+
if (HttpStatus.BadRequest === response.status) {
|
|
1208
|
+
const responseData = await response.json();
|
|
1209
|
+
throw new ValidationError(responseData);
|
|
1210
|
+
} else {
|
|
1211
|
+
throw new HttpError(response);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
async closeEmbeddedApplication(applicantId, callback) {
|
|
1215
|
+
let response;
|
|
1216
|
+
try {
|
|
1217
|
+
const embeddedUrl = `${this.baseEmbeddedUrl}Close/${applicantId}`;
|
|
1218
|
+
response = await fetch(embeddedUrl, {
|
|
1219
|
+
method: "POST",
|
|
1220
|
+
headers: this.HEADERS
|
|
1221
|
+
});
|
|
1222
|
+
if (!response.ok) {
|
|
1223
|
+
throw new Error(`Request Error: ${response.status}`);
|
|
1224
|
+
} else {
|
|
1225
|
+
callback();
|
|
1226
|
+
}
|
|
1227
|
+
} catch (e) {
|
|
1228
|
+
if (e instanceof HttpError) {
|
|
1229
|
+
throw e;
|
|
1230
|
+
} else {
|
|
1231
|
+
throw new HttpError(response);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
async longPollingRequest(url, init, callback) {
|
|
1236
|
+
try {
|
|
1237
|
+
const embeddedUrl = `${this.baseEmbeddedUrl}${url}`;
|
|
1238
|
+
const response = await fetch(embeddedUrl, init);
|
|
1239
|
+
if (HttpStatus.RequestTimeout === response.status || HttpStatus.NetworkConnectTimeoutError === response.status) {
|
|
1240
|
+
throw new RequestTimeoutError("Request Timeout");
|
|
1241
|
+
}
|
|
1242
|
+
if (!response.ok) {
|
|
1243
|
+
throw new Error(`Request Error: ${response.status}`);
|
|
1244
|
+
}
|
|
1245
|
+
const data = await response.json();
|
|
1246
|
+
callback(data);
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
if (error instanceof RequestTimeoutError) {
|
|
1249
|
+
await this.longPollingRequest(url, init, callback);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const isString = (val) => typeof val === "string";
|
|
1255
|
+
const processingCheckMap = {
|
|
1256
|
+
back: [DocumentTypeIDs.DL, DocumentTypeIDs.InternationalId],
|
|
1257
|
+
mrz: [
|
|
1258
|
+
DocumentTypeIDs.PassportCard,
|
|
1259
|
+
DocumentTypeIDs.GreenCard,
|
|
1260
|
+
DocumentTypeIDs.Passport,
|
|
1261
|
+
DocumentTypeIDs.EmploymentAuthorization
|
|
1262
|
+
],
|
|
1263
|
+
pdf: [DocumentTypeIDs.DL, DocumentTypeIDs.InternationalId]
|
|
1264
|
+
};
|
|
1265
|
+
const checkBackOrSecondImageProcessing = (documentType, steps) => {
|
|
1266
|
+
var _a;
|
|
1267
|
+
const backStep = steps.find((step) => Object.keys(processingCheckMap).includes(step.type));
|
|
1268
|
+
if (!backStep) {
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
const allowedDocumentTypeIDs = (_a = processingCheckMap[backStep.type]) == null ? void 0 : _a.includes(documentType);
|
|
1272
|
+
return allowedDocumentTypeIDs ?? false;
|
|
1273
|
+
};
|
|
1274
|
+
const checkOcrEnabled = (documentType, steps) => {
|
|
1275
|
+
const isPassportFront = !!steps.find((step) => step.type === "mrz");
|
|
1276
|
+
if (documentType === DocumentTypeIDs.Passport && isPassportFront) {
|
|
1277
|
+
return true;
|
|
1278
|
+
}
|
|
1279
|
+
const hasFrontStep = steps.find((step) => step.type === "front");
|
|
1280
|
+
return !!hasFrontStep;
|
|
1281
|
+
};
|
|
1282
|
+
class Lib {
|
|
1283
|
+
constructor() {
|
|
1284
|
+
this.cleanBase64 = (base64EncodedImage) => {
|
|
1285
|
+
if (!base64EncodedImage || !isString(base64EncodedImage)) return "";
|
|
1286
|
+
const splitPattern = /:image\/\w+;base64,/;
|
|
1287
|
+
const parts = base64EncodedImage.split(splitPattern);
|
|
1288
|
+
if (parts.length) {
|
|
1289
|
+
return parts[parts.length - 1];
|
|
1290
|
+
}
|
|
1291
|
+
return "";
|
|
1292
|
+
};
|
|
1293
|
+
this.validationModel = (data) => {
|
|
1294
|
+
var _a;
|
|
1295
|
+
const isPassportDocument = data.documentType === DocumentTypeIDs.Passport;
|
|
1296
|
+
const getBackData = () => {
|
|
1297
|
+
const step = data.steps.find((item) => item.type === "pdf" || item.type === "mrz" || item.type === "back");
|
|
1298
|
+
const trackString = (step == null ? void 0 : step.mrzText) || (step == null ? void 0 : step.trackString) || "";
|
|
1299
|
+
if (isPassportDocument) {
|
|
1300
|
+
return {
|
|
1301
|
+
img: "",
|
|
1302
|
+
trackString
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
return {
|
|
1306
|
+
img: (step == null ? void 0 : step.img) || "",
|
|
1307
|
+
trackString
|
|
1308
|
+
};
|
|
1309
|
+
};
|
|
1310
|
+
const getFrontData = () => {
|
|
1311
|
+
var _a2;
|
|
1312
|
+
if (isPassportDocument) {
|
|
1313
|
+
const frontPassportStep = data.steps.find((el) => el.type === "mrz");
|
|
1314
|
+
if (frontPassportStep) {
|
|
1315
|
+
return frontPassportStep.img;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return (_a2 = data.steps.find((el) => el.type === "front")) == null ? void 0 : _a2.img;
|
|
1319
|
+
};
|
|
1320
|
+
const back = getBackData();
|
|
1321
|
+
return {
|
|
1322
|
+
frontImageBase64: this.cleanBase64(getFrontData()),
|
|
1323
|
+
backOrSecondImageBase64: this.cleanBase64(back == null ? void 0 : back.img),
|
|
1324
|
+
faceImageBase64: this.cleanBase64((_a = data.steps.find((item) => item.type === "face")) == null ? void 0 : _a.img),
|
|
1325
|
+
trackString: back.trackString,
|
|
1326
|
+
ssn: "",
|
|
1327
|
+
verifyFace: !!data.steps.find((item) => item.type === "face"),
|
|
1328
|
+
documentType: data.documentType,
|
|
1329
|
+
captureMethod: data.steps.reduce((acc, step) => `${acc}${+step.isAuto}`, ""),
|
|
1330
|
+
userAgent: window.navigator.userAgent,
|
|
1331
|
+
frontEndMetadata: data.metaData,
|
|
1332
|
+
isBackOrSecondImageProcessingEnabled: checkBackOrSecondImageProcessing(
|
|
1333
|
+
data.documentType,
|
|
1334
|
+
data.steps
|
|
1335
|
+
),
|
|
1336
|
+
isOcrEnabled: checkOcrEnabled(data.documentType, data.steps)
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
async initializeLibrary(loadIDVCFromCDN, idvcVersion, IDVCModule) {
|
|
1341
|
+
if (!this.library) {
|
|
1342
|
+
if (loadIDVCFromCDN) {
|
|
1343
|
+
await this.loadFromCDN(idvcVersion);
|
|
1344
|
+
} else {
|
|
1345
|
+
this.loadFromNodeModules(IDVCModule);
|
|
1346
|
+
}
|
|
1347
|
+
this.postInitialize();
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
loadFromNodeModules(IDVCModule) {
|
|
1351
|
+
this.library = new IDVCModule(this.IdvcConfig);
|
|
1352
|
+
}
|
|
1353
|
+
async loadFromCDN(idvcVersion) {
|
|
1354
|
+
return new Promise((resolve, reject) => {
|
|
1355
|
+
const script = document.createElement("script");
|
|
1356
|
+
script.src = `https://neurons.cdn.idscan.net/${idvcVersion}-next/idvc.js`;
|
|
1357
|
+
script.async = true;
|
|
1358
|
+
script.onload = () => resolve(window.IDVC);
|
|
1359
|
+
script.onerror = reject;
|
|
1360
|
+
document.body.appendChild(script);
|
|
1361
|
+
}).then((IDVCFromCDN) => {
|
|
1362
|
+
this.library = new IDVCFromCDN(this.IdvcConfig);
|
|
1363
|
+
}).catch((err) => {
|
|
1364
|
+
console.log(err);
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
get initialized() {
|
|
1368
|
+
return !!this.library;
|
|
1369
|
+
}
|
|
1370
|
+
get version() {
|
|
1371
|
+
return this.library.version;
|
|
1372
|
+
}
|
|
1373
|
+
set configs({ IdvcConfig, CSSStylesConfig, CSSVariablesConfig }) {
|
|
1374
|
+
this.IdvcConfig = IdvcConfig;
|
|
1375
|
+
this.CSSStylesConfig = CSSStylesConfig;
|
|
1376
|
+
this.CSSVariablesConfig = CSSVariablesConfig;
|
|
1377
|
+
}
|
|
1378
|
+
set loading(val) {
|
|
1379
|
+
if (this.library) {
|
|
1380
|
+
this.library.showSpinner(val);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
postInitialize() {
|
|
1384
|
+
document.head.insertAdjacentHTML("beforeend", `
|
|
1385
|
+
<style id="onboarding-css-variables">${this.CSSVariablesConfig ? this.CSSVariablesConfig : ""}</style>
|
|
1386
|
+
<style id="onboarding-css-config">${this.CSSStylesConfig ? this.CSSStylesConfig : ""}</style>
|
|
1387
|
+
`);
|
|
1388
|
+
}
|
|
1389
|
+
reloadComponent(newConfig) {
|
|
1390
|
+
this.library.reloadComponent(newConfig);
|
|
1391
|
+
}
|
|
1392
|
+
updateDocumentTypes(docTypes) {
|
|
1393
|
+
this.library.updateDocumentTypes(docTypes);
|
|
1394
|
+
}
|
|
1395
|
+
restart() {
|
|
1396
|
+
this.library.resetAllSteps();
|
|
1397
|
+
}
|
|
1398
|
+
showLoader(val, bottomText, topText) {
|
|
1399
|
+
this.library.showLoader(val, bottomText, topText);
|
|
1400
|
+
}
|
|
1401
|
+
mixSubmit(name, fn) {
|
|
1402
|
+
const prevCallback = this.IdvcConfig[name];
|
|
1403
|
+
this.IdvcConfig[name] = (data) => {
|
|
1404
|
+
if (prevCallback) {
|
|
1405
|
+
const result = Promise.resolve(prevCallback(data));
|
|
1406
|
+
result.then(() => {
|
|
1407
|
+
fn(this.validationModel(data));
|
|
1408
|
+
}).catch(() => {
|
|
1409
|
+
fn(this.validationModel(data));
|
|
1410
|
+
});
|
|
1411
|
+
} else {
|
|
1412
|
+
fn(this.validationModel(data));
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
const validationModalHTML = '<div class="idvc-modal-background" id="idvc-modal-background">\n <div class="el-loading-spinner" id="idvc-loading-spinner">\n <svg viewBox="25 25 50 50" class="circular">\n <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>\n </svg>\n </div>\n</div>\n<div class="idvc-modal idvc-modal_validation d-none" id="idvc-modal">\n <div class="idvc-modal__header">\n <svg width="20" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M8 1C9.97933 1.052 11.6278 1.73683 12.9455 3.0545C14.2632 4.37217 14.948 6.02067 15 8C14.948 9.97933 14.2632 11.6278 12.9455 12.9455C11.6278 14.2632 9.97933 14.948 8 15C6.02067 14.948 4.37217 14.2632 3.0545 12.9455C1.73683 11.6278 1.052 9.97933 1 8C1.052 6.02067 1.73683 4.37217 3.0545 3.0545C4.37217 1.73683 6.02067 1.052 8 1ZM8 4C7.729 4 7.505 4.099 7.328 4.297C7.151 4.495 7.07283 4.72933 7.0935 5L7.453 9C7.474 9.146 7.53383 9.26317 7.6325 9.3515C7.73117 9.43983 7.8535 9.48417 7.9995 9.4845C8.1455 9.48483 8.26783 9.4405 8.3665 9.3515C8.46517 9.2625 8.525 9.14533 8.546 9L8.9055 5C8.9265 4.729 8.84833 4.49467 8.671 4.297C8.49367 4.09933 8.27067 4.00033 8 4ZM8 12C8.22933 11.9897 8.4195 11.9115 8.5705 11.7655C8.7215 11.6195 8.797 11.432 8.797 11.203C8.797 10.974 8.7215 10.7838 8.5705 10.6325C8.4195 10.4812 8.22933 10.4057 8 10.406C7.77067 10.4063 7.5805 10.4818 7.4295 10.6325C7.2785 10.7832 7.203 10.9733 7.203 11.203C7.203 11.4327 7.2785 11.6202 7.4295 11.7655C7.5805 11.9108 7.77067 11.989 8 12Z" fill="#1C1C1C"/>\n </svg>\n <h2 class="idvc-modal__header__content">\n Header\n </h2>\n <div class="idvc-modal__close-btn" id="idvc-close-modal-btn">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path></svg>\n </div>\n </div>\n <div class="idvc-modal__body">\n Please try again\n </div>\n <div class="idvc-modal__footer">\n <button type="button" class="btn btn--primary" id="idvc-modal-try-again-btn"><span>Try again</span></button>\n <button type="button" class="btn btn--default" id="idvc-modal-complete-btn"><span>Complete </span></button>\n </div>\n</div>\n';
|
|
1418
|
+
const modalHTML = '<div class="idvc-modal d-none" id="idvc-modal">\n <div class="idvc-modal__close-btn" id="idvc-close-modal-btn"></div>\n <div class="idvc-modal__header">\n <h2 class="idvc-modal__header__content"></h2>\n </div>\n <div class="idvc-modal__body"></div>\n <div class="idvc-modal__footer"></div>\n</div>\n<div class="idvc-modal-background" id="idvc-modal-background">\n <div class="el-loading-spinner" id="idvc-loading-spinner">\n <svg viewBox="25 25 50 50" class="circular">\n <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>\n </svg>\n </div>\n</div>\n';
|
|
1419
|
+
class Modal {
|
|
1420
|
+
constructor(mountEl) {
|
|
1421
|
+
this._closable = true;
|
|
1422
|
+
if (typeof mountEl === "string") {
|
|
1423
|
+
this.mountEl = document.getElementById(mountEl);
|
|
1424
|
+
} else {
|
|
1425
|
+
this.mountEl = mountEl;
|
|
1426
|
+
}
|
|
1427
|
+
this.init();
|
|
1428
|
+
}
|
|
1429
|
+
init(html2 = modalHTML) {
|
|
1430
|
+
this.modalContainer = document.createElement("div");
|
|
1431
|
+
this.mountEl.append(this.modalContainer);
|
|
1432
|
+
this.modalContainer.insertAdjacentHTML("beforeend", html2);
|
|
1433
|
+
this.container = this.modalContainer.querySelector("#idvc-modal");
|
|
1434
|
+
this.headerContainer = this.container.querySelector(".idvc-modal__header");
|
|
1435
|
+
this.headerText = this.headerContainer.querySelector(".idvc-modal__header__content");
|
|
1436
|
+
this.background = this.modalContainer.querySelector("#idvc-modal-background");
|
|
1437
|
+
this.spinner = this.modalContainer.querySelector("#idvc-loading-spinner");
|
|
1438
|
+
this.closeBtn = this.modalContainer.querySelector("#idvc-close-modal-btn");
|
|
1439
|
+
this.mountEl.classList.add("pos-relative");
|
|
1440
|
+
this.body = this.container.querySelector(".idvc-modal__body");
|
|
1441
|
+
this.footer = this.container.querySelector(".idvc-modal__footer");
|
|
1442
|
+
this.closeHandler();
|
|
1443
|
+
this.background.classList.add("idvc-preload-element");
|
|
1444
|
+
}
|
|
1445
|
+
set closable(val) {
|
|
1446
|
+
this._closable = val;
|
|
1447
|
+
this.toggleCloseBtn();
|
|
1448
|
+
}
|
|
1449
|
+
set header(val) {
|
|
1450
|
+
if (val) {
|
|
1451
|
+
this.headerText.textContent = val.toString();
|
|
1452
|
+
this.headerContainer.classList.remove("d-none");
|
|
1453
|
+
} else {
|
|
1454
|
+
this.headerContainer.classList.add("d-none");
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
set showBackground(val) {
|
|
1458
|
+
if (val) {
|
|
1459
|
+
this.background.classList.remove("d-none");
|
|
1460
|
+
} else {
|
|
1461
|
+
this.background.classList.add("d-none");
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
set content(val) {
|
|
1465
|
+
if (val) {
|
|
1466
|
+
this.body.innerHTML = val.toString();
|
|
1467
|
+
this.body.classList.remove("d-none");
|
|
1468
|
+
} else {
|
|
1469
|
+
this.body.classList.add("d-none");
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
toggleCloseBtn() {
|
|
1473
|
+
if (this._closable) {
|
|
1474
|
+
this.closeBtn.classList.remove("d-none");
|
|
1475
|
+
} else {
|
|
1476
|
+
this.closeBtn.classList.add("d-none");
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
closeHandler() {
|
|
1480
|
+
this.background.addEventListener("click", (event) => {
|
|
1481
|
+
const target = event.target;
|
|
1482
|
+
if (this._closable && target.classList.contains("idvc-modal-background")) {
|
|
1483
|
+
this.hide();
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
this.closeBtn.addEventListener("click", () => {
|
|
1487
|
+
this.hide();
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
hideSpinner() {
|
|
1491
|
+
this.hide();
|
|
1492
|
+
this.spinner.classList.add("d-none");
|
|
1493
|
+
}
|
|
1494
|
+
hide() {
|
|
1495
|
+
this.showBackground = false;
|
|
1496
|
+
this.container.classList.add("d-none");
|
|
1497
|
+
this.background.classList.remove("idvc-preload-element");
|
|
1498
|
+
}
|
|
1499
|
+
show() {
|
|
1500
|
+
const circular = this.modalContainer.querySelector(".circular");
|
|
1501
|
+
circular.classList.add("d-none");
|
|
1502
|
+
this.showBackground = true;
|
|
1503
|
+
this.container.classList.remove("d-none");
|
|
1504
|
+
}
|
|
1505
|
+
showSpinner(val) {
|
|
1506
|
+
if (val) {
|
|
1507
|
+
this.spinner.classList.remove("d-none");
|
|
1508
|
+
} else {
|
|
1509
|
+
this.spinner.classList.add("d-none");
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
prepareBackgroundStyles() {
|
|
1513
|
+
this.background.classList.add("idvc-after-submit");
|
|
1514
|
+
this.mountEl.classList.add("pos-relative");
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
class ValidationModal extends Modal {
|
|
1518
|
+
init(html2 = validationModalHTML) {
|
|
1519
|
+
super.init(html2);
|
|
1520
|
+
this.headerSign = this.headerContainer.querySelector("path");
|
|
1521
|
+
this.tryAgainBtn = this.container.querySelector("#idvc-modal-try-again-btn");
|
|
1522
|
+
this.completeBtn = this.container.querySelector("#idvc-modal-complete-btn");
|
|
1523
|
+
this.addTryAgainHandler();
|
|
1524
|
+
this.addCompleteHandler();
|
|
1525
|
+
}
|
|
1526
|
+
set type(rawType) {
|
|
1527
|
+
if (rawType === ValidationStatus.SUCCESS) {
|
|
1528
|
+
this.applySuccessValidationStyles();
|
|
1529
|
+
}
|
|
1530
|
+
this.headerSign.setAttribute("class", `color-${rawType}`);
|
|
1531
|
+
}
|
|
1532
|
+
set buttons({ tryAgain = false, complete = false }) {
|
|
1533
|
+
const width = 100 / (+tryAgain + +complete);
|
|
1534
|
+
const btnWidth = Number.isFinite(width) ? width : 0;
|
|
1535
|
+
const widthClassName = `w-${btnWidth === 50 ? 45 : btnWidth}`;
|
|
1536
|
+
this.setBtnVisible("tryAgain", tryAgain);
|
|
1537
|
+
this.setBtnVisible("complete", complete);
|
|
1538
|
+
if (!tryAgain && !complete) {
|
|
1539
|
+
this.footer.classList.add("d-none");
|
|
1540
|
+
this.footer.classList.remove("d-flex");
|
|
1541
|
+
} else {
|
|
1542
|
+
this.footer.classList.remove("d-none");
|
|
1543
|
+
this.footer.classList.add("d-flex");
|
|
1544
|
+
}
|
|
1545
|
+
[this.tryAgainBtn, this.completeBtn].forEach((btn) => {
|
|
1546
|
+
Array.from(btn.classList).forEach((className) => {
|
|
1547
|
+
if (className.startsWith("w-")) {
|
|
1548
|
+
btn.classList.remove(className);
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
btn.classList.add(widthClassName);
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
applySuccessValidationStyles() {
|
|
1555
|
+
this.container.classList.add("center");
|
|
1556
|
+
this.headerContainer.classList.add("center");
|
|
1557
|
+
}
|
|
1558
|
+
setBtnVisible(btnName, visible) {
|
|
1559
|
+
const btn = btnName === "tryAgain" ? this.tryAgainBtn : this.completeBtn;
|
|
1560
|
+
if (visible) {
|
|
1561
|
+
btn.classList.remove("d-none");
|
|
1562
|
+
} else {
|
|
1563
|
+
btn.classList.add("d-none");
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
addTryAgainHandler() {
|
|
1567
|
+
this.tryAgainBtn.onclick = () => this.hide();
|
|
1568
|
+
}
|
|
1569
|
+
addCompleteHandler(handler = () => {
|
|
1570
|
+
}) {
|
|
1571
|
+
this.completeBtn.onclick = () => {
|
|
1572
|
+
this.hide();
|
|
1573
|
+
handler();
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
const html$1 = '<div class="idvc-consent-form" id="idvc-consent-form">\n <div class="idvc-consent-form__header">\n <h2 class="idvc-consent-form__header__content">\n Consent Agreement\n </h2>\n </div>\n <div class="idvc-consent-form__body" id="idvc-consent-form-body">\n <p id="idvc-consent-form-text">\n </p>\n <div class="input-wrapper">\n <label for="idvc-full-name-input">\n <span>\n <sup class="color-red">*</sup>\n Full Name\n </span>\n </label>\n <input\n type="text"\n name="fullName"\n id="idvc-full-name-input"\n >\n </div>\n <div class="checkbox-wrapper">\n <label class="checkbox-wrapper__star" for="idvc-consent">\n <span>\n <sup class="color-red">*</sup>\n </span>\n </label>\n <input type="checkbox" id="idvc-consent">\n <span class="checkbox-wrapper__text" id="checkbox-wrapper__text"></span>\n </div>\n </div>\n <div class="idvc-consent-form__footer">\n <button type="button" class="btn btn--info" id="idvc-consent-form-cancel-btn">\n <span>Cancel</span>\n </button>\n <button type="button" class="btn btn--primary btn--disabled" id="idvc-consent-form-proceed-btn">\n <span>Proceed</span>\n </button>\n </div>\n</div>\n\n';
|
|
1578
|
+
class ConsentForm {
|
|
1579
|
+
constructor({
|
|
1580
|
+
mountElementID,
|
|
1581
|
+
consentBodyText,
|
|
1582
|
+
consentCheckboxText
|
|
1583
|
+
}) {
|
|
1584
|
+
this.target = {
|
|
1585
|
+
inputState: "",
|
|
1586
|
+
checkboxState: false
|
|
1587
|
+
};
|
|
1588
|
+
const target = document.getElementById(mountElementID);
|
|
1589
|
+
target.insertAdjacentHTML("afterbegin", html$1);
|
|
1590
|
+
const bodyTextContainer = document.getElementById("idvc-consent-form-text");
|
|
1591
|
+
bodyTextContainer.innerHTML = consentBodyText;
|
|
1592
|
+
const checkBoxTextContainer = document.getElementById("checkbox-wrapper__text");
|
|
1593
|
+
checkBoxTextContainer.innerHTML = consentCheckboxText;
|
|
1594
|
+
this.init();
|
|
1595
|
+
}
|
|
1596
|
+
init() {
|
|
1597
|
+
this.el = document.getElementById("idvc-consent-form");
|
|
1598
|
+
this.proceedBtn = document.getElementById("idvc-consent-form-proceed-btn");
|
|
1599
|
+
this.cancelBtn = document.getElementById("idvc-consent-form-cancel-btn");
|
|
1600
|
+
this.inputEl = document.getElementById("idvc-full-name-input");
|
|
1601
|
+
this.checkboxEl = document.getElementById("idvc-consent");
|
|
1602
|
+
const self = this;
|
|
1603
|
+
const handler = {
|
|
1604
|
+
set(obj, prop, value, receiver) {
|
|
1605
|
+
Reflect.set(obj, prop, value, receiver);
|
|
1606
|
+
if (self.isValidInput() && self.target.checkboxState) {
|
|
1607
|
+
self.proceedBtn.disabled = false;
|
|
1608
|
+
self.proceedBtn.classList.remove("btn--disabled");
|
|
1609
|
+
} else {
|
|
1610
|
+
self.proceedBtn.disabled = true;
|
|
1611
|
+
self.proceedBtn.classList.add("btn--disabled");
|
|
1612
|
+
}
|
|
1613
|
+
return true;
|
|
1614
|
+
},
|
|
1615
|
+
get(obj, prop) {
|
|
1616
|
+
return obj[prop];
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
this.state = new Proxy(this.target, handler);
|
|
1620
|
+
this.proceedBtn.disabled = true;
|
|
1621
|
+
this.proceedBtn.addEventListener("click", () => {
|
|
1622
|
+
const proceedEvent = new Event("proceedEvent", { bubbles: true });
|
|
1623
|
+
this.el.remove();
|
|
1624
|
+
this.proceedBtn.dispatchEvent(proceedEvent);
|
|
1625
|
+
}, { once: true });
|
|
1626
|
+
this.cancelBtn.addEventListener("click", () => {
|
|
1627
|
+
this.inputEl.value = "";
|
|
1628
|
+
this.checkboxEl.checked = false;
|
|
1629
|
+
});
|
|
1630
|
+
this.inputEl.addEventListener("input", (e) => {
|
|
1631
|
+
const target = e.target;
|
|
1632
|
+
this.state.inputState = target.value;
|
|
1633
|
+
});
|
|
1634
|
+
this.checkboxEl.addEventListener("click", (e) => {
|
|
1635
|
+
const target = e.target;
|
|
1636
|
+
this.state.checkboxState = target.checked;
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
get form() {
|
|
1640
|
+
return this.el;
|
|
1641
|
+
}
|
|
1642
|
+
isValidInput() {
|
|
1643
|
+
return this.state.inputState.trim().length >= 3 && this.state.inputState.trim().length < 100;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
class Validation {
|
|
1647
|
+
constructor(response, modal) {
|
|
1648
|
+
this.statuses = {
|
|
1649
|
+
[ResponseStatus.SUCCESS]: "Verification complete!",
|
|
1650
|
+
[ResponseStatus.FAIL]: "Validation failed!",
|
|
1651
|
+
[ResponseStatus.INVALID_DATA]: "Data invalid!",
|
|
1652
|
+
[ResponseStatus.ERROR]: "Something went wrong",
|
|
1653
|
+
4: "Request closed"
|
|
1654
|
+
};
|
|
1655
|
+
this.result = {
|
|
1656
|
+
type: ValidationStatus.PRIMARY,
|
|
1657
|
+
header: "",
|
|
1658
|
+
content: "",
|
|
1659
|
+
buttons: {
|
|
1660
|
+
tryAgain: false,
|
|
1661
|
+
complete: false
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
this.modal = modal;
|
|
1665
|
+
this.parseResponse(response);
|
|
1666
|
+
}
|
|
1667
|
+
parseResponse(response) {
|
|
1668
|
+
const {
|
|
1669
|
+
code = "",
|
|
1670
|
+
message = "",
|
|
1671
|
+
status = -1,
|
|
1672
|
+
attemptsLeft = -1,
|
|
1673
|
+
attemptsCount = -1,
|
|
1674
|
+
invalidDataErrors = [],
|
|
1675
|
+
notificationType = 0
|
|
1676
|
+
} = response;
|
|
1677
|
+
this.code = code;
|
|
1678
|
+
this.message = message;
|
|
1679
|
+
this.status = status;
|
|
1680
|
+
this.attemptsLeft = attemptsLeft;
|
|
1681
|
+
this.attemptsCount = attemptsCount;
|
|
1682
|
+
this.invalidDataErrors = invalidDataErrors || [];
|
|
1683
|
+
this.notificationType = notificationType;
|
|
1684
|
+
}
|
|
1685
|
+
calculateType() {
|
|
1686
|
+
let type;
|
|
1687
|
+
if (this.status === ResponseStatus.SUCCESS) {
|
|
1688
|
+
type = ValidationStatus.SUCCESS;
|
|
1689
|
+
} else if (this.status === ResponseStatus.ERROR) {
|
|
1690
|
+
type = ValidationStatus.PRIMARY;
|
|
1691
|
+
} else {
|
|
1692
|
+
type = ValidationStatus.DANGER;
|
|
1693
|
+
}
|
|
1694
|
+
this.result.type = type;
|
|
1695
|
+
}
|
|
1696
|
+
calculateHeader() {
|
|
1697
|
+
this.result.header = this.statuses[this.status] || this.statuses[3];
|
|
1698
|
+
}
|
|
1699
|
+
calculateContent() {
|
|
1700
|
+
const isFakeDocWithAttempts = this.status === ResponseStatus.FAIL && this.attemptsLeft > 0;
|
|
1701
|
+
if (isFakeDocWithAttempts || this.status === ResponseStatus.ERROR) {
|
|
1702
|
+
this.result.content = "Please try again";
|
|
1703
|
+
}
|
|
1704
|
+
if (this.status === ResponseStatus.INVALID_DATA) {
|
|
1705
|
+
const ocrMessage = "Image may be blurry. Please try taking photo again in a different room or with different lighting.";
|
|
1706
|
+
const errorList = this.invalidDataErrors.reduce((acc, { code, message }) => `${acc}<li class="idvc-modal__body__list__item">${code === "OCRError" ? ocrMessage : message}</li>`, "");
|
|
1707
|
+
const noNumbersClass = this.invalidDataErrors.length === 1 ? "idvc-modal__body__list--no-numbers" : "";
|
|
1708
|
+
this.result.content = `<ol class="idvc-modal__body__list ${noNumbersClass}">${errorList}</ol>`;
|
|
1709
|
+
}
|
|
1710
|
+
if (this.status === ResponseStatus.FAIL && this.attemptsLeft === 0 && this.attemptsCount > 0) {
|
|
1711
|
+
this.result.content = `No more attempts can be made.<br>You have made all ${this.attemptsCount}<br>of the allowed submissions.<br>Please have a new request link<br>${NotificationText[this.notificationType]}`;
|
|
1712
|
+
}
|
|
1713
|
+
if (this.code && this.message) {
|
|
1714
|
+
this.result.content = this.message;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
calculateFooter() {
|
|
1718
|
+
const isFakeDocWithAttempts = this.status !== ResponseStatus.SUCCESS && this.attemptsLeft > 0;
|
|
1719
|
+
if (this.status === 4) {
|
|
1720
|
+
this.result.buttons.tryAgain = false;
|
|
1721
|
+
this.result.buttons.complete = false;
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
if (isFakeDocWithAttempts) {
|
|
1725
|
+
this.result.buttons.tryAgain = true;
|
|
1726
|
+
this.result.buttons.complete = true;
|
|
1727
|
+
}
|
|
1728
|
+
if ([ResponseStatus.FAIL, ResponseStatus.INVALID_DATA].includes(this.status)) {
|
|
1729
|
+
this.result.buttons.tryAgain = true;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
prepareModal() {
|
|
1733
|
+
this.calculateType();
|
|
1734
|
+
this.calculateHeader();
|
|
1735
|
+
this.calculateContent();
|
|
1736
|
+
this.calculateFooter();
|
|
1737
|
+
}
|
|
1738
|
+
showModal() {
|
|
1739
|
+
this.modal.type = this.result.type;
|
|
1740
|
+
this.modal.header = this.result.header;
|
|
1741
|
+
this.modal.content = this.result.content;
|
|
1742
|
+
this.modal.buttons = this.result.buttons;
|
|
1743
|
+
this.modal.prepareBackgroundStyles();
|
|
1744
|
+
this.modal.show();
|
|
1745
|
+
}
|
|
1746
|
+
hideModal() {
|
|
1747
|
+
this.modal.hide();
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
const html = '<div class="qr-code-wrap">\n <button class="qr-code-wrap__button" id="qr-code-wrap__button"><span class="qr-code-wrap__content">Verify Documents by Phone<svg class="qr-code-svg" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0 8V0H8V8H0ZM2 6H6V2H2V6ZM0 18V10H8V18H0ZM2 16H6V12H2V16ZM10 8V0H18V8H10ZM12 6H16V2H12V6ZM16 18V16H18V18H16ZM10 12V10H12V12H10ZM12 14V12H14V14H12ZM10 16V14H12V16H10ZM12 18V16H14V18H12ZM14 16V14H16V16H14ZM14 12V10H16V12H14ZM16 14V12H18V14H16Z" fill="white"/>\n </svg></span></button>\n</div>\n';
|
|
1751
|
+
var browser = {};
|
|
1752
|
+
var canPromise;
|
|
1753
|
+
var hasRequiredCanPromise;
|
|
1754
|
+
function requireCanPromise() {
|
|
1755
|
+
if (hasRequiredCanPromise) return canPromise;
|
|
1756
|
+
hasRequiredCanPromise = 1;
|
|
1757
|
+
canPromise = function() {
|
|
1758
|
+
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
1759
|
+
};
|
|
1760
|
+
return canPromise;
|
|
1761
|
+
}
|
|
1762
|
+
var qrcode = {};
|
|
1763
|
+
var utils$1 = {};
|
|
1764
|
+
var hasRequiredUtils$1;
|
|
1765
|
+
function requireUtils$1() {
|
|
1766
|
+
if (hasRequiredUtils$1) return utils$1;
|
|
1767
|
+
hasRequiredUtils$1 = 1;
|
|
1768
|
+
let toSJISFunction;
|
|
1769
|
+
const CODEWORDS_COUNT = [
|
|
1770
|
+
0,
|
|
1771
|
+
// Not used
|
|
1772
|
+
26,
|
|
1773
|
+
44,
|
|
1774
|
+
70,
|
|
1775
|
+
100,
|
|
1776
|
+
134,
|
|
1777
|
+
172,
|
|
1778
|
+
196,
|
|
1779
|
+
242,
|
|
1780
|
+
292,
|
|
1781
|
+
346,
|
|
1782
|
+
404,
|
|
1783
|
+
466,
|
|
1784
|
+
532,
|
|
1785
|
+
581,
|
|
1786
|
+
655,
|
|
1787
|
+
733,
|
|
1788
|
+
815,
|
|
1789
|
+
901,
|
|
1790
|
+
991,
|
|
1791
|
+
1085,
|
|
1792
|
+
1156,
|
|
1793
|
+
1258,
|
|
1794
|
+
1364,
|
|
1795
|
+
1474,
|
|
1796
|
+
1588,
|
|
1797
|
+
1706,
|
|
1798
|
+
1828,
|
|
1799
|
+
1921,
|
|
1800
|
+
2051,
|
|
1801
|
+
2185,
|
|
1802
|
+
2323,
|
|
1803
|
+
2465,
|
|
1804
|
+
2611,
|
|
1805
|
+
2761,
|
|
1806
|
+
2876,
|
|
1807
|
+
3034,
|
|
1808
|
+
3196,
|
|
1809
|
+
3362,
|
|
1810
|
+
3532,
|
|
1811
|
+
3706
|
|
1812
|
+
];
|
|
1813
|
+
utils$1.getSymbolSize = function getSymbolSize(version2) {
|
|
1814
|
+
if (!version2) throw new Error('"version" cannot be null or undefined');
|
|
1815
|
+
if (version2 < 1 || version2 > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
1816
|
+
return version2 * 4 + 17;
|
|
1817
|
+
};
|
|
1818
|
+
utils$1.getSymbolTotalCodewords = function getSymbolTotalCodewords(version2) {
|
|
1819
|
+
return CODEWORDS_COUNT[version2];
|
|
1820
|
+
};
|
|
1821
|
+
utils$1.getBCHDigit = function(data) {
|
|
1822
|
+
let digit = 0;
|
|
1823
|
+
while (data !== 0) {
|
|
1824
|
+
digit++;
|
|
1825
|
+
data >>>= 1;
|
|
1826
|
+
}
|
|
1827
|
+
return digit;
|
|
1828
|
+
};
|
|
1829
|
+
utils$1.setToSJISFunction = function setToSJISFunction(f) {
|
|
1830
|
+
if (typeof f !== "function") {
|
|
1831
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
1832
|
+
}
|
|
1833
|
+
toSJISFunction = f;
|
|
1834
|
+
};
|
|
1835
|
+
utils$1.isKanjiModeEnabled = function() {
|
|
1836
|
+
return typeof toSJISFunction !== "undefined";
|
|
1837
|
+
};
|
|
1838
|
+
utils$1.toSJIS = function toSJIS(kanji) {
|
|
1839
|
+
return toSJISFunction(kanji);
|
|
1840
|
+
};
|
|
1841
|
+
return utils$1;
|
|
1842
|
+
}
|
|
1843
|
+
var errorCorrectionLevel = {};
|
|
1844
|
+
var hasRequiredErrorCorrectionLevel;
|
|
1845
|
+
function requireErrorCorrectionLevel() {
|
|
1846
|
+
if (hasRequiredErrorCorrectionLevel) return errorCorrectionLevel;
|
|
1847
|
+
hasRequiredErrorCorrectionLevel = 1;
|
|
1848
|
+
(function(exports$1) {
|
|
1849
|
+
exports$1.L = { bit: 1 };
|
|
1850
|
+
exports$1.M = { bit: 0 };
|
|
1851
|
+
exports$1.Q = { bit: 3 };
|
|
1852
|
+
exports$1.H = { bit: 2 };
|
|
1853
|
+
function fromString(string) {
|
|
1854
|
+
if (typeof string !== "string") {
|
|
1855
|
+
throw new Error("Param is not a string");
|
|
1856
|
+
}
|
|
1857
|
+
const lcStr = string.toLowerCase();
|
|
1858
|
+
switch (lcStr) {
|
|
1859
|
+
case "l":
|
|
1860
|
+
case "low":
|
|
1861
|
+
return exports$1.L;
|
|
1862
|
+
case "m":
|
|
1863
|
+
case "medium":
|
|
1864
|
+
return exports$1.M;
|
|
1865
|
+
case "q":
|
|
1866
|
+
case "quartile":
|
|
1867
|
+
return exports$1.Q;
|
|
1868
|
+
case "h":
|
|
1869
|
+
case "high":
|
|
1870
|
+
return exports$1.H;
|
|
1871
|
+
default:
|
|
1872
|
+
throw new Error("Unknown EC Level: " + string);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
exports$1.isValid = function isValid(level) {
|
|
1876
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
1877
|
+
};
|
|
1878
|
+
exports$1.from = function from(value, defaultValue) {
|
|
1879
|
+
if (exports$1.isValid(value)) {
|
|
1880
|
+
return value;
|
|
1881
|
+
}
|
|
1882
|
+
try {
|
|
1883
|
+
return fromString(value);
|
|
1884
|
+
} catch (e) {
|
|
1885
|
+
return defaultValue;
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
})(errorCorrectionLevel);
|
|
1889
|
+
return errorCorrectionLevel;
|
|
1890
|
+
}
|
|
1891
|
+
var bitBuffer;
|
|
1892
|
+
var hasRequiredBitBuffer;
|
|
1893
|
+
function requireBitBuffer() {
|
|
1894
|
+
if (hasRequiredBitBuffer) return bitBuffer;
|
|
1895
|
+
hasRequiredBitBuffer = 1;
|
|
1896
|
+
function BitBuffer() {
|
|
1897
|
+
this.buffer = [];
|
|
1898
|
+
this.length = 0;
|
|
1899
|
+
}
|
|
1900
|
+
BitBuffer.prototype = {
|
|
1901
|
+
get: function(index) {
|
|
1902
|
+
const bufIndex = Math.floor(index / 8);
|
|
1903
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
1904
|
+
},
|
|
1905
|
+
put: function(num, length) {
|
|
1906
|
+
for (let i = 0; i < length; i++) {
|
|
1907
|
+
this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
1908
|
+
}
|
|
1909
|
+
},
|
|
1910
|
+
getLengthInBits: function() {
|
|
1911
|
+
return this.length;
|
|
1912
|
+
},
|
|
1913
|
+
putBit: function(bit) {
|
|
1914
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
1915
|
+
if (this.buffer.length <= bufIndex) {
|
|
1916
|
+
this.buffer.push(0);
|
|
1917
|
+
}
|
|
1918
|
+
if (bit) {
|
|
1919
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
1920
|
+
}
|
|
1921
|
+
this.length++;
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
bitBuffer = BitBuffer;
|
|
1925
|
+
return bitBuffer;
|
|
1926
|
+
}
|
|
1927
|
+
var bitMatrix;
|
|
1928
|
+
var hasRequiredBitMatrix;
|
|
1929
|
+
function requireBitMatrix() {
|
|
1930
|
+
if (hasRequiredBitMatrix) return bitMatrix;
|
|
1931
|
+
hasRequiredBitMatrix = 1;
|
|
1932
|
+
function BitMatrix(size) {
|
|
1933
|
+
if (!size || size < 1) {
|
|
1934
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
1935
|
+
}
|
|
1936
|
+
this.size = size;
|
|
1937
|
+
this.data = new Uint8Array(size * size);
|
|
1938
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
1939
|
+
}
|
|
1940
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
1941
|
+
const index = row * this.size + col;
|
|
1942
|
+
this.data[index] = value;
|
|
1943
|
+
if (reserved) this.reservedBit[index] = true;
|
|
1944
|
+
};
|
|
1945
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
1946
|
+
return this.data[row * this.size + col];
|
|
1947
|
+
};
|
|
1948
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
1949
|
+
this.data[row * this.size + col] ^= value;
|
|
1950
|
+
};
|
|
1951
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
1952
|
+
return this.reservedBit[row * this.size + col];
|
|
1953
|
+
};
|
|
1954
|
+
bitMatrix = BitMatrix;
|
|
1955
|
+
return bitMatrix;
|
|
1956
|
+
}
|
|
1957
|
+
var alignmentPattern = {};
|
|
1958
|
+
var hasRequiredAlignmentPattern;
|
|
1959
|
+
function requireAlignmentPattern() {
|
|
1960
|
+
if (hasRequiredAlignmentPattern) return alignmentPattern;
|
|
1961
|
+
hasRequiredAlignmentPattern = 1;
|
|
1962
|
+
(function(exports$1) {
|
|
1963
|
+
const getSymbolSize = requireUtils$1().getSymbolSize;
|
|
1964
|
+
exports$1.getRowColCoords = function getRowColCoords(version2) {
|
|
1965
|
+
if (version2 === 1) return [];
|
|
1966
|
+
const posCount = Math.floor(version2 / 7) + 2;
|
|
1967
|
+
const size = getSymbolSize(version2);
|
|
1968
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
1969
|
+
const positions = [size - 7];
|
|
1970
|
+
for (let i = 1; i < posCount - 1; i++) {
|
|
1971
|
+
positions[i] = positions[i - 1] - intervals;
|
|
1972
|
+
}
|
|
1973
|
+
positions.push(6);
|
|
1974
|
+
return positions.reverse();
|
|
1975
|
+
};
|
|
1976
|
+
exports$1.getPositions = function getPositions(version2) {
|
|
1977
|
+
const coords = [];
|
|
1978
|
+
const pos = exports$1.getRowColCoords(version2);
|
|
1979
|
+
const posLength = pos.length;
|
|
1980
|
+
for (let i = 0; i < posLength; i++) {
|
|
1981
|
+
for (let j = 0; j < posLength; j++) {
|
|
1982
|
+
if (i === 0 && j === 0 || // top-left
|
|
1983
|
+
i === 0 && j === posLength - 1 || // bottom-left
|
|
1984
|
+
i === posLength - 1 && j === 0) {
|
|
1985
|
+
continue;
|
|
1986
|
+
}
|
|
1987
|
+
coords.push([pos[i], pos[j]]);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
return coords;
|
|
1991
|
+
};
|
|
1992
|
+
})(alignmentPattern);
|
|
1993
|
+
return alignmentPattern;
|
|
1994
|
+
}
|
|
1995
|
+
var finderPattern = {};
|
|
1996
|
+
var hasRequiredFinderPattern;
|
|
1997
|
+
function requireFinderPattern() {
|
|
1998
|
+
if (hasRequiredFinderPattern) return finderPattern;
|
|
1999
|
+
hasRequiredFinderPattern = 1;
|
|
2000
|
+
const getSymbolSize = requireUtils$1().getSymbolSize;
|
|
2001
|
+
const FINDER_PATTERN_SIZE = 7;
|
|
2002
|
+
finderPattern.getPositions = function getPositions(version2) {
|
|
2003
|
+
const size = getSymbolSize(version2);
|
|
2004
|
+
return [
|
|
2005
|
+
// top-left
|
|
2006
|
+
[0, 0],
|
|
2007
|
+
// top-right
|
|
2008
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
2009
|
+
// bottom-left
|
|
2010
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
2011
|
+
];
|
|
2012
|
+
};
|
|
2013
|
+
return finderPattern;
|
|
2014
|
+
}
|
|
2015
|
+
var maskPattern = {};
|
|
2016
|
+
var hasRequiredMaskPattern;
|
|
2017
|
+
function requireMaskPattern() {
|
|
2018
|
+
if (hasRequiredMaskPattern) return maskPattern;
|
|
2019
|
+
hasRequiredMaskPattern = 1;
|
|
2020
|
+
(function(exports$1) {
|
|
2021
|
+
exports$1.Patterns = {
|
|
2022
|
+
PATTERN000: 0,
|
|
2023
|
+
PATTERN001: 1,
|
|
2024
|
+
PATTERN010: 2,
|
|
2025
|
+
PATTERN011: 3,
|
|
2026
|
+
PATTERN100: 4,
|
|
2027
|
+
PATTERN101: 5,
|
|
2028
|
+
PATTERN110: 6,
|
|
2029
|
+
PATTERN111: 7
|
|
2030
|
+
};
|
|
2031
|
+
const PenaltyScores = {
|
|
2032
|
+
N1: 3,
|
|
2033
|
+
N2: 3,
|
|
2034
|
+
N3: 40,
|
|
2035
|
+
N4: 10
|
|
2036
|
+
};
|
|
2037
|
+
exports$1.isValid = function isValid(mask) {
|
|
2038
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
2039
|
+
};
|
|
2040
|
+
exports$1.from = function from(value) {
|
|
2041
|
+
return exports$1.isValid(value) ? parseInt(value, 10) : void 0;
|
|
2042
|
+
};
|
|
2043
|
+
exports$1.getPenaltyN1 = function getPenaltyN1(data) {
|
|
2044
|
+
const size = data.size;
|
|
2045
|
+
let points = 0;
|
|
2046
|
+
let sameCountCol = 0;
|
|
2047
|
+
let sameCountRow = 0;
|
|
2048
|
+
let lastCol = null;
|
|
2049
|
+
let lastRow = null;
|
|
2050
|
+
for (let row = 0; row < size; row++) {
|
|
2051
|
+
sameCountCol = sameCountRow = 0;
|
|
2052
|
+
lastCol = lastRow = null;
|
|
2053
|
+
for (let col = 0; col < size; col++) {
|
|
2054
|
+
let module = data.get(row, col);
|
|
2055
|
+
if (module === lastCol) {
|
|
2056
|
+
sameCountCol++;
|
|
2057
|
+
} else {
|
|
2058
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
2059
|
+
lastCol = module;
|
|
2060
|
+
sameCountCol = 1;
|
|
2061
|
+
}
|
|
2062
|
+
module = data.get(col, row);
|
|
2063
|
+
if (module === lastRow) {
|
|
2064
|
+
sameCountRow++;
|
|
2065
|
+
} else {
|
|
2066
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
2067
|
+
lastRow = module;
|
|
2068
|
+
sameCountRow = 1;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
2072
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
2073
|
+
}
|
|
2074
|
+
return points;
|
|
2075
|
+
};
|
|
2076
|
+
exports$1.getPenaltyN2 = function getPenaltyN2(data) {
|
|
2077
|
+
const size = data.size;
|
|
2078
|
+
let points = 0;
|
|
2079
|
+
for (let row = 0; row < size - 1; row++) {
|
|
2080
|
+
for (let col = 0; col < size - 1; col++) {
|
|
2081
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
2082
|
+
if (last === 4 || last === 0) points++;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
return points * PenaltyScores.N2;
|
|
2086
|
+
};
|
|
2087
|
+
exports$1.getPenaltyN3 = function getPenaltyN3(data) {
|
|
2088
|
+
const size = data.size;
|
|
2089
|
+
let points = 0;
|
|
2090
|
+
let bitsCol = 0;
|
|
2091
|
+
let bitsRow = 0;
|
|
2092
|
+
for (let row = 0; row < size; row++) {
|
|
2093
|
+
bitsCol = bitsRow = 0;
|
|
2094
|
+
for (let col = 0; col < size; col++) {
|
|
2095
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
2096
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
2097
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
2098
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
return points * PenaltyScores.N3;
|
|
2102
|
+
};
|
|
2103
|
+
exports$1.getPenaltyN4 = function getPenaltyN4(data) {
|
|
2104
|
+
let darkCount = 0;
|
|
2105
|
+
const modulesCount = data.data.length;
|
|
2106
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
2107
|
+
const k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
|
|
2108
|
+
return k * PenaltyScores.N4;
|
|
2109
|
+
};
|
|
2110
|
+
function getMaskAt(maskPattern2, i, j) {
|
|
2111
|
+
switch (maskPattern2) {
|
|
2112
|
+
case exports$1.Patterns.PATTERN000:
|
|
2113
|
+
return (i + j) % 2 === 0;
|
|
2114
|
+
case exports$1.Patterns.PATTERN001:
|
|
2115
|
+
return i % 2 === 0;
|
|
2116
|
+
case exports$1.Patterns.PATTERN010:
|
|
2117
|
+
return j % 3 === 0;
|
|
2118
|
+
case exports$1.Patterns.PATTERN011:
|
|
2119
|
+
return (i + j) % 3 === 0;
|
|
2120
|
+
case exports$1.Patterns.PATTERN100:
|
|
2121
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
2122
|
+
case exports$1.Patterns.PATTERN101:
|
|
2123
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
2124
|
+
case exports$1.Patterns.PATTERN110:
|
|
2125
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
2126
|
+
case exports$1.Patterns.PATTERN111:
|
|
2127
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
2128
|
+
default:
|
|
2129
|
+
throw new Error("bad maskPattern:" + maskPattern2);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
exports$1.applyMask = function applyMask(pattern, data) {
|
|
2133
|
+
const size = data.size;
|
|
2134
|
+
for (let col = 0; col < size; col++) {
|
|
2135
|
+
for (let row = 0; row < size; row++) {
|
|
2136
|
+
if (data.isReserved(row, col)) continue;
|
|
2137
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
exports$1.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
2142
|
+
const numPatterns = Object.keys(exports$1.Patterns).length;
|
|
2143
|
+
let bestPattern = 0;
|
|
2144
|
+
let lowerPenalty = Infinity;
|
|
2145
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
2146
|
+
setupFormatFunc(p);
|
|
2147
|
+
exports$1.applyMask(p, data);
|
|
2148
|
+
const penalty = exports$1.getPenaltyN1(data) + exports$1.getPenaltyN2(data) + exports$1.getPenaltyN3(data) + exports$1.getPenaltyN4(data);
|
|
2149
|
+
exports$1.applyMask(p, data);
|
|
2150
|
+
if (penalty < lowerPenalty) {
|
|
2151
|
+
lowerPenalty = penalty;
|
|
2152
|
+
bestPattern = p;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
return bestPattern;
|
|
2156
|
+
};
|
|
2157
|
+
})(maskPattern);
|
|
2158
|
+
return maskPattern;
|
|
2159
|
+
}
|
|
2160
|
+
var errorCorrectionCode = {};
|
|
2161
|
+
var hasRequiredErrorCorrectionCode;
|
|
2162
|
+
function requireErrorCorrectionCode() {
|
|
2163
|
+
if (hasRequiredErrorCorrectionCode) return errorCorrectionCode;
|
|
2164
|
+
hasRequiredErrorCorrectionCode = 1;
|
|
2165
|
+
const ECLevel = requireErrorCorrectionLevel();
|
|
2166
|
+
const EC_BLOCKS_TABLE = [
|
|
2167
|
+
// L M Q H
|
|
2168
|
+
1,
|
|
2169
|
+
1,
|
|
2170
|
+
1,
|
|
2171
|
+
1,
|
|
2172
|
+
1,
|
|
2173
|
+
1,
|
|
2174
|
+
1,
|
|
2175
|
+
1,
|
|
2176
|
+
1,
|
|
2177
|
+
1,
|
|
2178
|
+
2,
|
|
2179
|
+
2,
|
|
2180
|
+
1,
|
|
2181
|
+
2,
|
|
2182
|
+
2,
|
|
2183
|
+
4,
|
|
2184
|
+
1,
|
|
2185
|
+
2,
|
|
2186
|
+
4,
|
|
2187
|
+
4,
|
|
2188
|
+
2,
|
|
2189
|
+
4,
|
|
2190
|
+
4,
|
|
2191
|
+
4,
|
|
2192
|
+
2,
|
|
2193
|
+
4,
|
|
2194
|
+
6,
|
|
2195
|
+
5,
|
|
2196
|
+
2,
|
|
2197
|
+
4,
|
|
2198
|
+
6,
|
|
2199
|
+
6,
|
|
2200
|
+
2,
|
|
2201
|
+
5,
|
|
2202
|
+
8,
|
|
2203
|
+
8,
|
|
2204
|
+
4,
|
|
2205
|
+
5,
|
|
2206
|
+
8,
|
|
2207
|
+
8,
|
|
2208
|
+
4,
|
|
2209
|
+
5,
|
|
2210
|
+
8,
|
|
2211
|
+
11,
|
|
2212
|
+
4,
|
|
2213
|
+
8,
|
|
2214
|
+
10,
|
|
2215
|
+
11,
|
|
2216
|
+
4,
|
|
2217
|
+
9,
|
|
2218
|
+
12,
|
|
2219
|
+
16,
|
|
2220
|
+
4,
|
|
2221
|
+
9,
|
|
2222
|
+
16,
|
|
2223
|
+
16,
|
|
2224
|
+
6,
|
|
2225
|
+
10,
|
|
2226
|
+
12,
|
|
2227
|
+
18,
|
|
2228
|
+
6,
|
|
2229
|
+
10,
|
|
2230
|
+
17,
|
|
2231
|
+
16,
|
|
2232
|
+
6,
|
|
2233
|
+
11,
|
|
2234
|
+
16,
|
|
2235
|
+
19,
|
|
2236
|
+
6,
|
|
2237
|
+
13,
|
|
2238
|
+
18,
|
|
2239
|
+
21,
|
|
2240
|
+
7,
|
|
2241
|
+
14,
|
|
2242
|
+
21,
|
|
2243
|
+
25,
|
|
2244
|
+
8,
|
|
2245
|
+
16,
|
|
2246
|
+
20,
|
|
2247
|
+
25,
|
|
2248
|
+
8,
|
|
2249
|
+
17,
|
|
2250
|
+
23,
|
|
2251
|
+
25,
|
|
2252
|
+
9,
|
|
2253
|
+
17,
|
|
2254
|
+
23,
|
|
2255
|
+
34,
|
|
2256
|
+
9,
|
|
2257
|
+
18,
|
|
2258
|
+
25,
|
|
2259
|
+
30,
|
|
2260
|
+
10,
|
|
2261
|
+
20,
|
|
2262
|
+
27,
|
|
2263
|
+
32,
|
|
2264
|
+
12,
|
|
2265
|
+
21,
|
|
2266
|
+
29,
|
|
2267
|
+
35,
|
|
2268
|
+
12,
|
|
2269
|
+
23,
|
|
2270
|
+
34,
|
|
2271
|
+
37,
|
|
2272
|
+
12,
|
|
2273
|
+
25,
|
|
2274
|
+
34,
|
|
2275
|
+
40,
|
|
2276
|
+
13,
|
|
2277
|
+
26,
|
|
2278
|
+
35,
|
|
2279
|
+
42,
|
|
2280
|
+
14,
|
|
2281
|
+
28,
|
|
2282
|
+
38,
|
|
2283
|
+
45,
|
|
2284
|
+
15,
|
|
2285
|
+
29,
|
|
2286
|
+
40,
|
|
2287
|
+
48,
|
|
2288
|
+
16,
|
|
2289
|
+
31,
|
|
2290
|
+
43,
|
|
2291
|
+
51,
|
|
2292
|
+
17,
|
|
2293
|
+
33,
|
|
2294
|
+
45,
|
|
2295
|
+
54,
|
|
2296
|
+
18,
|
|
2297
|
+
35,
|
|
2298
|
+
48,
|
|
2299
|
+
57,
|
|
2300
|
+
19,
|
|
2301
|
+
37,
|
|
2302
|
+
51,
|
|
2303
|
+
60,
|
|
2304
|
+
19,
|
|
2305
|
+
38,
|
|
2306
|
+
53,
|
|
2307
|
+
63,
|
|
2308
|
+
20,
|
|
2309
|
+
40,
|
|
2310
|
+
56,
|
|
2311
|
+
66,
|
|
2312
|
+
21,
|
|
2313
|
+
43,
|
|
2314
|
+
59,
|
|
2315
|
+
70,
|
|
2316
|
+
22,
|
|
2317
|
+
45,
|
|
2318
|
+
62,
|
|
2319
|
+
74,
|
|
2320
|
+
24,
|
|
2321
|
+
47,
|
|
2322
|
+
65,
|
|
2323
|
+
77,
|
|
2324
|
+
25,
|
|
2325
|
+
49,
|
|
2326
|
+
68,
|
|
2327
|
+
81
|
|
2328
|
+
];
|
|
2329
|
+
const EC_CODEWORDS_TABLE = [
|
|
2330
|
+
// L M Q H
|
|
2331
|
+
7,
|
|
2332
|
+
10,
|
|
2333
|
+
13,
|
|
2334
|
+
17,
|
|
2335
|
+
10,
|
|
2336
|
+
16,
|
|
2337
|
+
22,
|
|
2338
|
+
28,
|
|
2339
|
+
15,
|
|
2340
|
+
26,
|
|
2341
|
+
36,
|
|
2342
|
+
44,
|
|
2343
|
+
20,
|
|
2344
|
+
36,
|
|
2345
|
+
52,
|
|
2346
|
+
64,
|
|
2347
|
+
26,
|
|
2348
|
+
48,
|
|
2349
|
+
72,
|
|
2350
|
+
88,
|
|
2351
|
+
36,
|
|
2352
|
+
64,
|
|
2353
|
+
96,
|
|
2354
|
+
112,
|
|
2355
|
+
40,
|
|
2356
|
+
72,
|
|
2357
|
+
108,
|
|
2358
|
+
130,
|
|
2359
|
+
48,
|
|
2360
|
+
88,
|
|
2361
|
+
132,
|
|
2362
|
+
156,
|
|
2363
|
+
60,
|
|
2364
|
+
110,
|
|
2365
|
+
160,
|
|
2366
|
+
192,
|
|
2367
|
+
72,
|
|
2368
|
+
130,
|
|
2369
|
+
192,
|
|
2370
|
+
224,
|
|
2371
|
+
80,
|
|
2372
|
+
150,
|
|
2373
|
+
224,
|
|
2374
|
+
264,
|
|
2375
|
+
96,
|
|
2376
|
+
176,
|
|
2377
|
+
260,
|
|
2378
|
+
308,
|
|
2379
|
+
104,
|
|
2380
|
+
198,
|
|
2381
|
+
288,
|
|
2382
|
+
352,
|
|
2383
|
+
120,
|
|
2384
|
+
216,
|
|
2385
|
+
320,
|
|
2386
|
+
384,
|
|
2387
|
+
132,
|
|
2388
|
+
240,
|
|
2389
|
+
360,
|
|
2390
|
+
432,
|
|
2391
|
+
144,
|
|
2392
|
+
280,
|
|
2393
|
+
408,
|
|
2394
|
+
480,
|
|
2395
|
+
168,
|
|
2396
|
+
308,
|
|
2397
|
+
448,
|
|
2398
|
+
532,
|
|
2399
|
+
180,
|
|
2400
|
+
338,
|
|
2401
|
+
504,
|
|
2402
|
+
588,
|
|
2403
|
+
196,
|
|
2404
|
+
364,
|
|
2405
|
+
546,
|
|
2406
|
+
650,
|
|
2407
|
+
224,
|
|
2408
|
+
416,
|
|
2409
|
+
600,
|
|
2410
|
+
700,
|
|
2411
|
+
224,
|
|
2412
|
+
442,
|
|
2413
|
+
644,
|
|
2414
|
+
750,
|
|
2415
|
+
252,
|
|
2416
|
+
476,
|
|
2417
|
+
690,
|
|
2418
|
+
816,
|
|
2419
|
+
270,
|
|
2420
|
+
504,
|
|
2421
|
+
750,
|
|
2422
|
+
900,
|
|
2423
|
+
300,
|
|
2424
|
+
560,
|
|
2425
|
+
810,
|
|
2426
|
+
960,
|
|
2427
|
+
312,
|
|
2428
|
+
588,
|
|
2429
|
+
870,
|
|
2430
|
+
1050,
|
|
2431
|
+
336,
|
|
2432
|
+
644,
|
|
2433
|
+
952,
|
|
2434
|
+
1110,
|
|
2435
|
+
360,
|
|
2436
|
+
700,
|
|
2437
|
+
1020,
|
|
2438
|
+
1200,
|
|
2439
|
+
390,
|
|
2440
|
+
728,
|
|
2441
|
+
1050,
|
|
2442
|
+
1260,
|
|
2443
|
+
420,
|
|
2444
|
+
784,
|
|
2445
|
+
1140,
|
|
2446
|
+
1350,
|
|
2447
|
+
450,
|
|
2448
|
+
812,
|
|
2449
|
+
1200,
|
|
2450
|
+
1440,
|
|
2451
|
+
480,
|
|
2452
|
+
868,
|
|
2453
|
+
1290,
|
|
2454
|
+
1530,
|
|
2455
|
+
510,
|
|
2456
|
+
924,
|
|
2457
|
+
1350,
|
|
2458
|
+
1620,
|
|
2459
|
+
540,
|
|
2460
|
+
980,
|
|
2461
|
+
1440,
|
|
2462
|
+
1710,
|
|
2463
|
+
570,
|
|
2464
|
+
1036,
|
|
2465
|
+
1530,
|
|
2466
|
+
1800,
|
|
2467
|
+
570,
|
|
2468
|
+
1064,
|
|
2469
|
+
1590,
|
|
2470
|
+
1890,
|
|
2471
|
+
600,
|
|
2472
|
+
1120,
|
|
2473
|
+
1680,
|
|
2474
|
+
1980,
|
|
2475
|
+
630,
|
|
2476
|
+
1204,
|
|
2477
|
+
1770,
|
|
2478
|
+
2100,
|
|
2479
|
+
660,
|
|
2480
|
+
1260,
|
|
2481
|
+
1860,
|
|
2482
|
+
2220,
|
|
2483
|
+
720,
|
|
2484
|
+
1316,
|
|
2485
|
+
1950,
|
|
2486
|
+
2310,
|
|
2487
|
+
750,
|
|
2488
|
+
1372,
|
|
2489
|
+
2040,
|
|
2490
|
+
2430
|
|
2491
|
+
];
|
|
2492
|
+
errorCorrectionCode.getBlocksCount = function getBlocksCount(version2, errorCorrectionLevel2) {
|
|
2493
|
+
switch (errorCorrectionLevel2) {
|
|
2494
|
+
case ECLevel.L:
|
|
2495
|
+
return EC_BLOCKS_TABLE[(version2 - 1) * 4 + 0];
|
|
2496
|
+
case ECLevel.M:
|
|
2497
|
+
return EC_BLOCKS_TABLE[(version2 - 1) * 4 + 1];
|
|
2498
|
+
case ECLevel.Q:
|
|
2499
|
+
return EC_BLOCKS_TABLE[(version2 - 1) * 4 + 2];
|
|
2500
|
+
case ECLevel.H:
|
|
2501
|
+
return EC_BLOCKS_TABLE[(version2 - 1) * 4 + 3];
|
|
2502
|
+
default:
|
|
2503
|
+
return void 0;
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
errorCorrectionCode.getTotalCodewordsCount = function getTotalCodewordsCount(version2, errorCorrectionLevel2) {
|
|
2507
|
+
switch (errorCorrectionLevel2) {
|
|
2508
|
+
case ECLevel.L:
|
|
2509
|
+
return EC_CODEWORDS_TABLE[(version2 - 1) * 4 + 0];
|
|
2510
|
+
case ECLevel.M:
|
|
2511
|
+
return EC_CODEWORDS_TABLE[(version2 - 1) * 4 + 1];
|
|
2512
|
+
case ECLevel.Q:
|
|
2513
|
+
return EC_CODEWORDS_TABLE[(version2 - 1) * 4 + 2];
|
|
2514
|
+
case ECLevel.H:
|
|
2515
|
+
return EC_CODEWORDS_TABLE[(version2 - 1) * 4 + 3];
|
|
2516
|
+
default:
|
|
2517
|
+
return void 0;
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
return errorCorrectionCode;
|
|
2521
|
+
}
|
|
2522
|
+
var polynomial = {};
|
|
2523
|
+
var galoisField = {};
|
|
2524
|
+
var hasRequiredGaloisField;
|
|
2525
|
+
function requireGaloisField() {
|
|
2526
|
+
if (hasRequiredGaloisField) return galoisField;
|
|
2527
|
+
hasRequiredGaloisField = 1;
|
|
2528
|
+
const EXP_TABLE = new Uint8Array(512);
|
|
2529
|
+
const LOG_TABLE = new Uint8Array(256);
|
|
2530
|
+
(function initTables() {
|
|
2531
|
+
let x = 1;
|
|
2532
|
+
for (let i = 0; i < 255; i++) {
|
|
2533
|
+
EXP_TABLE[i] = x;
|
|
2534
|
+
LOG_TABLE[x] = i;
|
|
2535
|
+
x <<= 1;
|
|
2536
|
+
if (x & 256) {
|
|
2537
|
+
x ^= 285;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
for (let i = 255; i < 512; i++) {
|
|
2541
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
2542
|
+
}
|
|
2543
|
+
})();
|
|
2544
|
+
galoisField.log = function log(n) {
|
|
2545
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
2546
|
+
return LOG_TABLE[n];
|
|
2547
|
+
};
|
|
2548
|
+
galoisField.exp = function exp(n) {
|
|
2549
|
+
return EXP_TABLE[n];
|
|
2550
|
+
};
|
|
2551
|
+
galoisField.mul = function mul(x, y) {
|
|
2552
|
+
if (x === 0 || y === 0) return 0;
|
|
2553
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
2554
|
+
};
|
|
2555
|
+
return galoisField;
|
|
2556
|
+
}
|
|
2557
|
+
var hasRequiredPolynomial;
|
|
2558
|
+
function requirePolynomial() {
|
|
2559
|
+
if (hasRequiredPolynomial) return polynomial;
|
|
2560
|
+
hasRequiredPolynomial = 1;
|
|
2561
|
+
(function(exports$1) {
|
|
2562
|
+
const GF = requireGaloisField();
|
|
2563
|
+
exports$1.mul = function mul(p1, p2) {
|
|
2564
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
2565
|
+
for (let i = 0; i < p1.length; i++) {
|
|
2566
|
+
for (let j = 0; j < p2.length; j++) {
|
|
2567
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return coeff;
|
|
2571
|
+
};
|
|
2572
|
+
exports$1.mod = function mod(divident, divisor) {
|
|
2573
|
+
let result = new Uint8Array(divident);
|
|
2574
|
+
while (result.length - divisor.length >= 0) {
|
|
2575
|
+
const coeff = result[0];
|
|
2576
|
+
for (let i = 0; i < divisor.length; i++) {
|
|
2577
|
+
result[i] ^= GF.mul(divisor[i], coeff);
|
|
2578
|
+
}
|
|
2579
|
+
let offset = 0;
|
|
2580
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
2581
|
+
result = result.slice(offset);
|
|
2582
|
+
}
|
|
2583
|
+
return result;
|
|
2584
|
+
};
|
|
2585
|
+
exports$1.generateECPolynomial = function generateECPolynomial(degree) {
|
|
2586
|
+
let poly = new Uint8Array([1]);
|
|
2587
|
+
for (let i = 0; i < degree; i++) {
|
|
2588
|
+
poly = exports$1.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
2589
|
+
}
|
|
2590
|
+
return poly;
|
|
2591
|
+
};
|
|
2592
|
+
})(polynomial);
|
|
2593
|
+
return polynomial;
|
|
2594
|
+
}
|
|
2595
|
+
var reedSolomonEncoder;
|
|
2596
|
+
var hasRequiredReedSolomonEncoder;
|
|
2597
|
+
function requireReedSolomonEncoder() {
|
|
2598
|
+
if (hasRequiredReedSolomonEncoder) return reedSolomonEncoder;
|
|
2599
|
+
hasRequiredReedSolomonEncoder = 1;
|
|
2600
|
+
const Polynomial = requirePolynomial();
|
|
2601
|
+
function ReedSolomonEncoder(degree) {
|
|
2602
|
+
this.genPoly = void 0;
|
|
2603
|
+
this.degree = degree;
|
|
2604
|
+
if (this.degree) this.initialize(this.degree);
|
|
2605
|
+
}
|
|
2606
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
2607
|
+
this.degree = degree;
|
|
2608
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
2609
|
+
};
|
|
2610
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
2611
|
+
if (!this.genPoly) {
|
|
2612
|
+
throw new Error("Encoder not initialized");
|
|
2613
|
+
}
|
|
2614
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
2615
|
+
paddedData.set(data);
|
|
2616
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
2617
|
+
const start = this.degree - remainder.length;
|
|
2618
|
+
if (start > 0) {
|
|
2619
|
+
const buff = new Uint8Array(this.degree);
|
|
2620
|
+
buff.set(remainder, start);
|
|
2621
|
+
return buff;
|
|
2622
|
+
}
|
|
2623
|
+
return remainder;
|
|
2624
|
+
};
|
|
2625
|
+
reedSolomonEncoder = ReedSolomonEncoder;
|
|
2626
|
+
return reedSolomonEncoder;
|
|
2627
|
+
}
|
|
2628
|
+
var version$1 = {};
|
|
2629
|
+
var mode = {};
|
|
2630
|
+
var versionCheck = {};
|
|
2631
|
+
var hasRequiredVersionCheck;
|
|
2632
|
+
function requireVersionCheck() {
|
|
2633
|
+
if (hasRequiredVersionCheck) return versionCheck;
|
|
2634
|
+
hasRequiredVersionCheck = 1;
|
|
2635
|
+
versionCheck.isValid = function isValid(version2) {
|
|
2636
|
+
return !isNaN(version2) && version2 >= 1 && version2 <= 40;
|
|
2637
|
+
};
|
|
2638
|
+
return versionCheck;
|
|
2639
|
+
}
|
|
2640
|
+
var regex = {};
|
|
2641
|
+
var hasRequiredRegex;
|
|
2642
|
+
function requireRegex() {
|
|
2643
|
+
if (hasRequiredRegex) return regex;
|
|
2644
|
+
hasRequiredRegex = 1;
|
|
2645
|
+
const numeric = "[0-9]+";
|
|
2646
|
+
const alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
2647
|
+
let kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
2648
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
2649
|
+
const byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
2650
|
+
regex.KANJI = new RegExp(kanji, "g");
|
|
2651
|
+
regex.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
2652
|
+
regex.BYTE = new RegExp(byte, "g");
|
|
2653
|
+
regex.NUMERIC = new RegExp(numeric, "g");
|
|
2654
|
+
regex.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
2655
|
+
const TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
2656
|
+
const TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
2657
|
+
const TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
2658
|
+
regex.testKanji = function testKanji(str) {
|
|
2659
|
+
return TEST_KANJI.test(str);
|
|
2660
|
+
};
|
|
2661
|
+
regex.testNumeric = function testNumeric(str) {
|
|
2662
|
+
return TEST_NUMERIC.test(str);
|
|
2663
|
+
};
|
|
2664
|
+
regex.testAlphanumeric = function testAlphanumeric(str) {
|
|
2665
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
2666
|
+
};
|
|
2667
|
+
return regex;
|
|
2668
|
+
}
|
|
2669
|
+
var hasRequiredMode;
|
|
2670
|
+
function requireMode() {
|
|
2671
|
+
if (hasRequiredMode) return mode;
|
|
2672
|
+
hasRequiredMode = 1;
|
|
2673
|
+
(function(exports$1) {
|
|
2674
|
+
const VersionCheck = requireVersionCheck();
|
|
2675
|
+
const Regex = requireRegex();
|
|
2676
|
+
exports$1.NUMERIC = {
|
|
2677
|
+
id: "Numeric",
|
|
2678
|
+
bit: 1 << 0,
|
|
2679
|
+
ccBits: [10, 12, 14]
|
|
2680
|
+
};
|
|
2681
|
+
exports$1.ALPHANUMERIC = {
|
|
2682
|
+
id: "Alphanumeric",
|
|
2683
|
+
bit: 1 << 1,
|
|
2684
|
+
ccBits: [9, 11, 13]
|
|
2685
|
+
};
|
|
2686
|
+
exports$1.BYTE = {
|
|
2687
|
+
id: "Byte",
|
|
2688
|
+
bit: 1 << 2,
|
|
2689
|
+
ccBits: [8, 16, 16]
|
|
2690
|
+
};
|
|
2691
|
+
exports$1.KANJI = {
|
|
2692
|
+
id: "Kanji",
|
|
2693
|
+
bit: 1 << 3,
|
|
2694
|
+
ccBits: [8, 10, 12]
|
|
2695
|
+
};
|
|
2696
|
+
exports$1.MIXED = {
|
|
2697
|
+
bit: -1
|
|
2698
|
+
};
|
|
2699
|
+
exports$1.getCharCountIndicator = function getCharCountIndicator(mode2, version2) {
|
|
2700
|
+
if (!mode2.ccBits) throw new Error("Invalid mode: " + mode2);
|
|
2701
|
+
if (!VersionCheck.isValid(version2)) {
|
|
2702
|
+
throw new Error("Invalid version: " + version2);
|
|
2703
|
+
}
|
|
2704
|
+
if (version2 >= 1 && version2 < 10) return mode2.ccBits[0];
|
|
2705
|
+
else if (version2 < 27) return mode2.ccBits[1];
|
|
2706
|
+
return mode2.ccBits[2];
|
|
2707
|
+
};
|
|
2708
|
+
exports$1.getBestModeForData = function getBestModeForData(dataStr) {
|
|
2709
|
+
if (Regex.testNumeric(dataStr)) return exports$1.NUMERIC;
|
|
2710
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports$1.ALPHANUMERIC;
|
|
2711
|
+
else if (Regex.testKanji(dataStr)) return exports$1.KANJI;
|
|
2712
|
+
else return exports$1.BYTE;
|
|
2713
|
+
};
|
|
2714
|
+
exports$1.toString = function toString(mode2) {
|
|
2715
|
+
if (mode2 && mode2.id) return mode2.id;
|
|
2716
|
+
throw new Error("Invalid mode");
|
|
2717
|
+
};
|
|
2718
|
+
exports$1.isValid = function isValid(mode2) {
|
|
2719
|
+
return mode2 && mode2.bit && mode2.ccBits;
|
|
2720
|
+
};
|
|
2721
|
+
function fromString(string) {
|
|
2722
|
+
if (typeof string !== "string") {
|
|
2723
|
+
throw new Error("Param is not a string");
|
|
2724
|
+
}
|
|
2725
|
+
const lcStr = string.toLowerCase();
|
|
2726
|
+
switch (lcStr) {
|
|
2727
|
+
case "numeric":
|
|
2728
|
+
return exports$1.NUMERIC;
|
|
2729
|
+
case "alphanumeric":
|
|
2730
|
+
return exports$1.ALPHANUMERIC;
|
|
2731
|
+
case "kanji":
|
|
2732
|
+
return exports$1.KANJI;
|
|
2733
|
+
case "byte":
|
|
2734
|
+
return exports$1.BYTE;
|
|
2735
|
+
default:
|
|
2736
|
+
throw new Error("Unknown mode: " + string);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
exports$1.from = function from(value, defaultValue) {
|
|
2740
|
+
if (exports$1.isValid(value)) {
|
|
2741
|
+
return value;
|
|
2742
|
+
}
|
|
2743
|
+
try {
|
|
2744
|
+
return fromString(value);
|
|
2745
|
+
} catch (e) {
|
|
2746
|
+
return defaultValue;
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2749
|
+
})(mode);
|
|
2750
|
+
return mode;
|
|
2751
|
+
}
|
|
2752
|
+
var hasRequiredVersion;
|
|
2753
|
+
function requireVersion() {
|
|
2754
|
+
if (hasRequiredVersion) return version$1;
|
|
2755
|
+
hasRequiredVersion = 1;
|
|
2756
|
+
(function(exports$1) {
|
|
2757
|
+
const Utils = requireUtils$1();
|
|
2758
|
+
const ECCode = requireErrorCorrectionCode();
|
|
2759
|
+
const ECLevel = requireErrorCorrectionLevel();
|
|
2760
|
+
const Mode = requireMode();
|
|
2761
|
+
const VersionCheck = requireVersionCheck();
|
|
2762
|
+
const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
2763
|
+
const G18_BCH = Utils.getBCHDigit(G18);
|
|
2764
|
+
function getBestVersionForDataLength(mode2, length, errorCorrectionLevel2) {
|
|
2765
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
2766
|
+
if (length <= exports$1.getCapacity(currentVersion, errorCorrectionLevel2, mode2)) {
|
|
2767
|
+
return currentVersion;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
return void 0;
|
|
2771
|
+
}
|
|
2772
|
+
function getReservedBitsCount(mode2, version2) {
|
|
2773
|
+
return Mode.getCharCountIndicator(mode2, version2) + 4;
|
|
2774
|
+
}
|
|
2775
|
+
function getTotalBitsFromDataArray(segments2, version2) {
|
|
2776
|
+
let totalBits = 0;
|
|
2777
|
+
segments2.forEach(function(data) {
|
|
2778
|
+
const reservedBits = getReservedBitsCount(data.mode, version2);
|
|
2779
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
2780
|
+
});
|
|
2781
|
+
return totalBits;
|
|
2782
|
+
}
|
|
2783
|
+
function getBestVersionForMixedData(segments2, errorCorrectionLevel2) {
|
|
2784
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
2785
|
+
const length = getTotalBitsFromDataArray(segments2, currentVersion);
|
|
2786
|
+
if (length <= exports$1.getCapacity(currentVersion, errorCorrectionLevel2, Mode.MIXED)) {
|
|
2787
|
+
return currentVersion;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
return void 0;
|
|
2791
|
+
}
|
|
2792
|
+
exports$1.from = function from(value, defaultValue) {
|
|
2793
|
+
if (VersionCheck.isValid(value)) {
|
|
2794
|
+
return parseInt(value, 10);
|
|
2795
|
+
}
|
|
2796
|
+
return defaultValue;
|
|
2797
|
+
};
|
|
2798
|
+
exports$1.getCapacity = function getCapacity(version2, errorCorrectionLevel2, mode2) {
|
|
2799
|
+
if (!VersionCheck.isValid(version2)) {
|
|
2800
|
+
throw new Error("Invalid QR Code version");
|
|
2801
|
+
}
|
|
2802
|
+
if (typeof mode2 === "undefined") mode2 = Mode.BYTE;
|
|
2803
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version2);
|
|
2804
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version2, errorCorrectionLevel2);
|
|
2805
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
2806
|
+
if (mode2 === Mode.MIXED) return dataTotalCodewordsBits;
|
|
2807
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode2, version2);
|
|
2808
|
+
switch (mode2) {
|
|
2809
|
+
case Mode.NUMERIC:
|
|
2810
|
+
return Math.floor(usableBits / 10 * 3);
|
|
2811
|
+
case Mode.ALPHANUMERIC:
|
|
2812
|
+
return Math.floor(usableBits / 11 * 2);
|
|
2813
|
+
case Mode.KANJI:
|
|
2814
|
+
return Math.floor(usableBits / 13);
|
|
2815
|
+
case Mode.BYTE:
|
|
2816
|
+
default:
|
|
2817
|
+
return Math.floor(usableBits / 8);
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
exports$1.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel2) {
|
|
2821
|
+
let seg;
|
|
2822
|
+
const ecl = ECLevel.from(errorCorrectionLevel2, ECLevel.M);
|
|
2823
|
+
if (Array.isArray(data)) {
|
|
2824
|
+
if (data.length > 1) {
|
|
2825
|
+
return getBestVersionForMixedData(data, ecl);
|
|
2826
|
+
}
|
|
2827
|
+
if (data.length === 0) {
|
|
2828
|
+
return 1;
|
|
2829
|
+
}
|
|
2830
|
+
seg = data[0];
|
|
2831
|
+
} else {
|
|
2832
|
+
seg = data;
|
|
2833
|
+
}
|
|
2834
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
2835
|
+
};
|
|
2836
|
+
exports$1.getEncodedBits = function getEncodedBits(version2) {
|
|
2837
|
+
if (!VersionCheck.isValid(version2) || version2 < 7) {
|
|
2838
|
+
throw new Error("Invalid QR Code version");
|
|
2839
|
+
}
|
|
2840
|
+
let d = version2 << 12;
|
|
2841
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
2842
|
+
d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
2843
|
+
}
|
|
2844
|
+
return version2 << 12 | d;
|
|
2845
|
+
};
|
|
2846
|
+
})(version$1);
|
|
2847
|
+
return version$1;
|
|
2848
|
+
}
|
|
2849
|
+
var formatInfo = {};
|
|
2850
|
+
var hasRequiredFormatInfo;
|
|
2851
|
+
function requireFormatInfo() {
|
|
2852
|
+
if (hasRequiredFormatInfo) return formatInfo;
|
|
2853
|
+
hasRequiredFormatInfo = 1;
|
|
2854
|
+
const Utils = requireUtils$1();
|
|
2855
|
+
const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
2856
|
+
const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
2857
|
+
const G15_BCH = Utils.getBCHDigit(G15);
|
|
2858
|
+
formatInfo.getEncodedBits = function getEncodedBits(errorCorrectionLevel2, mask) {
|
|
2859
|
+
const data = errorCorrectionLevel2.bit << 3 | mask;
|
|
2860
|
+
let d = data << 10;
|
|
2861
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
2862
|
+
d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
2863
|
+
}
|
|
2864
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
2865
|
+
};
|
|
2866
|
+
return formatInfo;
|
|
2867
|
+
}
|
|
2868
|
+
var segments = {};
|
|
2869
|
+
var numericData;
|
|
2870
|
+
var hasRequiredNumericData;
|
|
2871
|
+
function requireNumericData() {
|
|
2872
|
+
if (hasRequiredNumericData) return numericData;
|
|
2873
|
+
hasRequiredNumericData = 1;
|
|
2874
|
+
const Mode = requireMode();
|
|
2875
|
+
function NumericData(data) {
|
|
2876
|
+
this.mode = Mode.NUMERIC;
|
|
2877
|
+
this.data = data.toString();
|
|
2878
|
+
}
|
|
2879
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
2880
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
2881
|
+
};
|
|
2882
|
+
NumericData.prototype.getLength = function getLength() {
|
|
2883
|
+
return this.data.length;
|
|
2884
|
+
};
|
|
2885
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
2886
|
+
return NumericData.getBitsLength(this.data.length);
|
|
2887
|
+
};
|
|
2888
|
+
NumericData.prototype.write = function write(bitBuffer2) {
|
|
2889
|
+
let i, group, value;
|
|
2890
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
2891
|
+
group = this.data.substr(i, 3);
|
|
2892
|
+
value = parseInt(group, 10);
|
|
2893
|
+
bitBuffer2.put(value, 10);
|
|
2894
|
+
}
|
|
2895
|
+
const remainingNum = this.data.length - i;
|
|
2896
|
+
if (remainingNum > 0) {
|
|
2897
|
+
group = this.data.substr(i);
|
|
2898
|
+
value = parseInt(group, 10);
|
|
2899
|
+
bitBuffer2.put(value, remainingNum * 3 + 1);
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
numericData = NumericData;
|
|
2903
|
+
return numericData;
|
|
2904
|
+
}
|
|
2905
|
+
var alphanumericData;
|
|
2906
|
+
var hasRequiredAlphanumericData;
|
|
2907
|
+
function requireAlphanumericData() {
|
|
2908
|
+
if (hasRequiredAlphanumericData) return alphanumericData;
|
|
2909
|
+
hasRequiredAlphanumericData = 1;
|
|
2910
|
+
const Mode = requireMode();
|
|
2911
|
+
const ALPHA_NUM_CHARS = [
|
|
2912
|
+
"0",
|
|
2913
|
+
"1",
|
|
2914
|
+
"2",
|
|
2915
|
+
"3",
|
|
2916
|
+
"4",
|
|
2917
|
+
"5",
|
|
2918
|
+
"6",
|
|
2919
|
+
"7",
|
|
2920
|
+
"8",
|
|
2921
|
+
"9",
|
|
2922
|
+
"A",
|
|
2923
|
+
"B",
|
|
2924
|
+
"C",
|
|
2925
|
+
"D",
|
|
2926
|
+
"E",
|
|
2927
|
+
"F",
|
|
2928
|
+
"G",
|
|
2929
|
+
"H",
|
|
2930
|
+
"I",
|
|
2931
|
+
"J",
|
|
2932
|
+
"K",
|
|
2933
|
+
"L",
|
|
2934
|
+
"M",
|
|
2935
|
+
"N",
|
|
2936
|
+
"O",
|
|
2937
|
+
"P",
|
|
2938
|
+
"Q",
|
|
2939
|
+
"R",
|
|
2940
|
+
"S",
|
|
2941
|
+
"T",
|
|
2942
|
+
"U",
|
|
2943
|
+
"V",
|
|
2944
|
+
"W",
|
|
2945
|
+
"X",
|
|
2946
|
+
"Y",
|
|
2947
|
+
"Z",
|
|
2948
|
+
" ",
|
|
2949
|
+
"$",
|
|
2950
|
+
"%",
|
|
2951
|
+
"*",
|
|
2952
|
+
"+",
|
|
2953
|
+
"-",
|
|
2954
|
+
".",
|
|
2955
|
+
"/",
|
|
2956
|
+
":"
|
|
2957
|
+
];
|
|
2958
|
+
function AlphanumericData(data) {
|
|
2959
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
2960
|
+
this.data = data;
|
|
2961
|
+
}
|
|
2962
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
2963
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
2964
|
+
};
|
|
2965
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
2966
|
+
return this.data.length;
|
|
2967
|
+
};
|
|
2968
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
2969
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
2970
|
+
};
|
|
2971
|
+
AlphanumericData.prototype.write = function write(bitBuffer2) {
|
|
2972
|
+
let i;
|
|
2973
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
2974
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
2975
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
2976
|
+
bitBuffer2.put(value, 11);
|
|
2977
|
+
}
|
|
2978
|
+
if (this.data.length % 2) {
|
|
2979
|
+
bitBuffer2.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
alphanumericData = AlphanumericData;
|
|
2983
|
+
return alphanumericData;
|
|
2984
|
+
}
|
|
2985
|
+
var byteData;
|
|
2986
|
+
var hasRequiredByteData;
|
|
2987
|
+
function requireByteData() {
|
|
2988
|
+
if (hasRequiredByteData) return byteData;
|
|
2989
|
+
hasRequiredByteData = 1;
|
|
2990
|
+
const Mode = requireMode();
|
|
2991
|
+
function ByteData(data) {
|
|
2992
|
+
this.mode = Mode.BYTE;
|
|
2993
|
+
if (typeof data === "string") {
|
|
2994
|
+
this.data = new TextEncoder().encode(data);
|
|
2995
|
+
} else {
|
|
2996
|
+
this.data = new Uint8Array(data);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
3000
|
+
return length * 8;
|
|
3001
|
+
};
|
|
3002
|
+
ByteData.prototype.getLength = function getLength() {
|
|
3003
|
+
return this.data.length;
|
|
3004
|
+
};
|
|
3005
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
3006
|
+
return ByteData.getBitsLength(this.data.length);
|
|
3007
|
+
};
|
|
3008
|
+
ByteData.prototype.write = function(bitBuffer2) {
|
|
3009
|
+
for (let i = 0, l = this.data.length; i < l; i++) {
|
|
3010
|
+
bitBuffer2.put(this.data[i], 8);
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
byteData = ByteData;
|
|
3014
|
+
return byteData;
|
|
3015
|
+
}
|
|
3016
|
+
var kanjiData;
|
|
3017
|
+
var hasRequiredKanjiData;
|
|
3018
|
+
function requireKanjiData() {
|
|
3019
|
+
if (hasRequiredKanjiData) return kanjiData;
|
|
3020
|
+
hasRequiredKanjiData = 1;
|
|
3021
|
+
const Mode = requireMode();
|
|
3022
|
+
const Utils = requireUtils$1();
|
|
3023
|
+
function KanjiData(data) {
|
|
3024
|
+
this.mode = Mode.KANJI;
|
|
3025
|
+
this.data = data;
|
|
3026
|
+
}
|
|
3027
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
3028
|
+
return length * 13;
|
|
3029
|
+
};
|
|
3030
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
3031
|
+
return this.data.length;
|
|
3032
|
+
};
|
|
3033
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
3034
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
3035
|
+
};
|
|
3036
|
+
KanjiData.prototype.write = function(bitBuffer2) {
|
|
3037
|
+
let i;
|
|
3038
|
+
for (i = 0; i < this.data.length; i++) {
|
|
3039
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
3040
|
+
if (value >= 33088 && value <= 40956) {
|
|
3041
|
+
value -= 33088;
|
|
3042
|
+
} else if (value >= 57408 && value <= 60351) {
|
|
3043
|
+
value -= 49472;
|
|
3044
|
+
} else {
|
|
3045
|
+
throw new Error(
|
|
3046
|
+
"Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8"
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
3050
|
+
bitBuffer2.put(value, 13);
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
kanjiData = KanjiData;
|
|
3054
|
+
return kanjiData;
|
|
3055
|
+
}
|
|
3056
|
+
var dijkstra = { exports: {} };
|
|
3057
|
+
var hasRequiredDijkstra;
|
|
3058
|
+
function requireDijkstra() {
|
|
3059
|
+
if (hasRequiredDijkstra) return dijkstra.exports;
|
|
3060
|
+
hasRequiredDijkstra = 1;
|
|
3061
|
+
(function(module) {
|
|
3062
|
+
var dijkstra2 = {
|
|
3063
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
3064
|
+
var predecessors = {};
|
|
3065
|
+
var costs = {};
|
|
3066
|
+
costs[s] = 0;
|
|
3067
|
+
var open = dijkstra2.PriorityQueue.make();
|
|
3068
|
+
open.push(s, 0);
|
|
3069
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
3070
|
+
while (!open.empty()) {
|
|
3071
|
+
closest = open.pop();
|
|
3072
|
+
u = closest.value;
|
|
3073
|
+
cost_of_s_to_u = closest.cost;
|
|
3074
|
+
adjacent_nodes = graph[u] || {};
|
|
3075
|
+
for (v in adjacent_nodes) {
|
|
3076
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
3077
|
+
cost_of_e = adjacent_nodes[v];
|
|
3078
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
3079
|
+
cost_of_s_to_v = costs[v];
|
|
3080
|
+
first_visit = typeof costs[v] === "undefined";
|
|
3081
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
3082
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
3083
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
3084
|
+
predecessors[v] = u;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
3090
|
+
var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
|
|
3091
|
+
throw new Error(msg);
|
|
3092
|
+
}
|
|
3093
|
+
return predecessors;
|
|
3094
|
+
},
|
|
3095
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
3096
|
+
var nodes = [];
|
|
3097
|
+
var u = d;
|
|
3098
|
+
while (u) {
|
|
3099
|
+
nodes.push(u);
|
|
3100
|
+
predecessors[u];
|
|
3101
|
+
u = predecessors[u];
|
|
3102
|
+
}
|
|
3103
|
+
nodes.reverse();
|
|
3104
|
+
return nodes;
|
|
3105
|
+
},
|
|
3106
|
+
find_path: function(graph, s, d) {
|
|
3107
|
+
var predecessors = dijkstra2.single_source_shortest_paths(graph, s, d);
|
|
3108
|
+
return dijkstra2.extract_shortest_path_from_predecessor_list(
|
|
3109
|
+
predecessors,
|
|
3110
|
+
d
|
|
3111
|
+
);
|
|
3112
|
+
},
|
|
3113
|
+
/**
|
|
3114
|
+
* A very naive priority queue implementation.
|
|
3115
|
+
*/
|
|
3116
|
+
PriorityQueue: {
|
|
3117
|
+
make: function(opts) {
|
|
3118
|
+
var T = dijkstra2.PriorityQueue, t = {}, key;
|
|
3119
|
+
opts = opts || {};
|
|
3120
|
+
for (key in T) {
|
|
3121
|
+
if (T.hasOwnProperty(key)) {
|
|
3122
|
+
t[key] = T[key];
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
t.queue = [];
|
|
3126
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
3127
|
+
return t;
|
|
3128
|
+
},
|
|
3129
|
+
default_sorter: function(a, b) {
|
|
3130
|
+
return a.cost - b.cost;
|
|
3131
|
+
},
|
|
3132
|
+
/**
|
|
3133
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
3134
|
+
* is at the front of the queue.
|
|
3135
|
+
*/
|
|
3136
|
+
push: function(value, cost) {
|
|
3137
|
+
var item = { value, cost };
|
|
3138
|
+
this.queue.push(item);
|
|
3139
|
+
this.queue.sort(this.sorter);
|
|
3140
|
+
},
|
|
3141
|
+
/**
|
|
3142
|
+
* Return the highest priority element in the queue.
|
|
3143
|
+
*/
|
|
3144
|
+
pop: function() {
|
|
3145
|
+
return this.queue.shift();
|
|
3146
|
+
},
|
|
3147
|
+
empty: function() {
|
|
3148
|
+
return this.queue.length === 0;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
};
|
|
3152
|
+
{
|
|
3153
|
+
module.exports = dijkstra2;
|
|
3154
|
+
}
|
|
3155
|
+
})(dijkstra);
|
|
3156
|
+
return dijkstra.exports;
|
|
3157
|
+
}
|
|
3158
|
+
var hasRequiredSegments;
|
|
3159
|
+
function requireSegments() {
|
|
3160
|
+
if (hasRequiredSegments) return segments;
|
|
3161
|
+
hasRequiredSegments = 1;
|
|
3162
|
+
(function(exports$1) {
|
|
3163
|
+
const Mode = requireMode();
|
|
3164
|
+
const NumericData = requireNumericData();
|
|
3165
|
+
const AlphanumericData = requireAlphanumericData();
|
|
3166
|
+
const ByteData = requireByteData();
|
|
3167
|
+
const KanjiData = requireKanjiData();
|
|
3168
|
+
const Regex = requireRegex();
|
|
3169
|
+
const Utils = requireUtils$1();
|
|
3170
|
+
const dijkstra2 = requireDijkstra();
|
|
3171
|
+
function getStringByteLength(str) {
|
|
3172
|
+
return unescape(encodeURIComponent(str)).length;
|
|
3173
|
+
}
|
|
3174
|
+
function getSegments(regex2, mode2, str) {
|
|
3175
|
+
const segments2 = [];
|
|
3176
|
+
let result;
|
|
3177
|
+
while ((result = regex2.exec(str)) !== null) {
|
|
3178
|
+
segments2.push({
|
|
3179
|
+
data: result[0],
|
|
3180
|
+
index: result.index,
|
|
3181
|
+
mode: mode2,
|
|
3182
|
+
length: result[0].length
|
|
3183
|
+
});
|
|
3184
|
+
}
|
|
3185
|
+
return segments2;
|
|
3186
|
+
}
|
|
3187
|
+
function getSegmentsFromString(dataStr) {
|
|
3188
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
3189
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
3190
|
+
let byteSegs;
|
|
3191
|
+
let kanjiSegs;
|
|
3192
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
3193
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
3194
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
3195
|
+
} else {
|
|
3196
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
3197
|
+
kanjiSegs = [];
|
|
3198
|
+
}
|
|
3199
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
|
|
3200
|
+
return segs.sort(function(s1, s2) {
|
|
3201
|
+
return s1.index - s2.index;
|
|
3202
|
+
}).map(function(obj) {
|
|
3203
|
+
return {
|
|
3204
|
+
data: obj.data,
|
|
3205
|
+
mode: obj.mode,
|
|
3206
|
+
length: obj.length
|
|
3207
|
+
};
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
function getSegmentBitsLength(length, mode2) {
|
|
3211
|
+
switch (mode2) {
|
|
3212
|
+
case Mode.NUMERIC:
|
|
3213
|
+
return NumericData.getBitsLength(length);
|
|
3214
|
+
case Mode.ALPHANUMERIC:
|
|
3215
|
+
return AlphanumericData.getBitsLength(length);
|
|
3216
|
+
case Mode.KANJI:
|
|
3217
|
+
return KanjiData.getBitsLength(length);
|
|
3218
|
+
case Mode.BYTE:
|
|
3219
|
+
return ByteData.getBitsLength(length);
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
function mergeSegments(segs) {
|
|
3223
|
+
return segs.reduce(function(acc, curr) {
|
|
3224
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
3225
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
3226
|
+
acc[acc.length - 1].data += curr.data;
|
|
3227
|
+
return acc;
|
|
3228
|
+
}
|
|
3229
|
+
acc.push(curr);
|
|
3230
|
+
return acc;
|
|
3231
|
+
}, []);
|
|
3232
|
+
}
|
|
3233
|
+
function buildNodes(segs) {
|
|
3234
|
+
const nodes = [];
|
|
3235
|
+
for (let i = 0; i < segs.length; i++) {
|
|
3236
|
+
const seg = segs[i];
|
|
3237
|
+
switch (seg.mode) {
|
|
3238
|
+
case Mode.NUMERIC:
|
|
3239
|
+
nodes.push([
|
|
3240
|
+
seg,
|
|
3241
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
3242
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
3243
|
+
]);
|
|
3244
|
+
break;
|
|
3245
|
+
case Mode.ALPHANUMERIC:
|
|
3246
|
+
nodes.push([
|
|
3247
|
+
seg,
|
|
3248
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
3249
|
+
]);
|
|
3250
|
+
break;
|
|
3251
|
+
case Mode.KANJI:
|
|
3252
|
+
nodes.push([
|
|
3253
|
+
seg,
|
|
3254
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
3255
|
+
]);
|
|
3256
|
+
break;
|
|
3257
|
+
case Mode.BYTE:
|
|
3258
|
+
nodes.push([
|
|
3259
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
3260
|
+
]);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
return nodes;
|
|
3264
|
+
}
|
|
3265
|
+
function buildGraph(nodes, version2) {
|
|
3266
|
+
const table = {};
|
|
3267
|
+
const graph = { start: {} };
|
|
3268
|
+
let prevNodeIds = ["start"];
|
|
3269
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
3270
|
+
const nodeGroup = nodes[i];
|
|
3271
|
+
const currentNodeIds = [];
|
|
3272
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
3273
|
+
const node = nodeGroup[j];
|
|
3274
|
+
const key = "" + i + j;
|
|
3275
|
+
currentNodeIds.push(key);
|
|
3276
|
+
table[key] = { node, lastCount: 0 };
|
|
3277
|
+
graph[key] = {};
|
|
3278
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
3279
|
+
const prevNodeId = prevNodeIds[n];
|
|
3280
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
3281
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
3282
|
+
table[prevNodeId].lastCount += node.length;
|
|
3283
|
+
} else {
|
|
3284
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
3285
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version2);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
prevNodeIds = currentNodeIds;
|
|
3290
|
+
}
|
|
3291
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
3292
|
+
graph[prevNodeIds[n]].end = 0;
|
|
3293
|
+
}
|
|
3294
|
+
return { map: graph, table };
|
|
3295
|
+
}
|
|
3296
|
+
function buildSingleSegment(data, modesHint) {
|
|
3297
|
+
let mode2;
|
|
3298
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
3299
|
+
mode2 = Mode.from(modesHint, bestMode);
|
|
3300
|
+
if (mode2 !== Mode.BYTE && mode2.bit < bestMode.bit) {
|
|
3301
|
+
throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode2) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
3302
|
+
}
|
|
3303
|
+
if (mode2 === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
3304
|
+
mode2 = Mode.BYTE;
|
|
3305
|
+
}
|
|
3306
|
+
switch (mode2) {
|
|
3307
|
+
case Mode.NUMERIC:
|
|
3308
|
+
return new NumericData(data);
|
|
3309
|
+
case Mode.ALPHANUMERIC:
|
|
3310
|
+
return new AlphanumericData(data);
|
|
3311
|
+
case Mode.KANJI:
|
|
3312
|
+
return new KanjiData(data);
|
|
3313
|
+
case Mode.BYTE:
|
|
3314
|
+
return new ByteData(data);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
exports$1.fromArray = function fromArray(array) {
|
|
3318
|
+
return array.reduce(function(acc, seg) {
|
|
3319
|
+
if (typeof seg === "string") {
|
|
3320
|
+
acc.push(buildSingleSegment(seg, null));
|
|
3321
|
+
} else if (seg.data) {
|
|
3322
|
+
acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
3323
|
+
}
|
|
3324
|
+
return acc;
|
|
3325
|
+
}, []);
|
|
3326
|
+
};
|
|
3327
|
+
exports$1.fromString = function fromString(data, version2) {
|
|
3328
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
3329
|
+
const nodes = buildNodes(segs);
|
|
3330
|
+
const graph = buildGraph(nodes, version2);
|
|
3331
|
+
const path = dijkstra2.find_path(graph.map, "start", "end");
|
|
3332
|
+
const optimizedSegs = [];
|
|
3333
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
3334
|
+
optimizedSegs.push(graph.table[path[i]].node);
|
|
3335
|
+
}
|
|
3336
|
+
return exports$1.fromArray(mergeSegments(optimizedSegs));
|
|
3337
|
+
};
|
|
3338
|
+
exports$1.rawSplit = function rawSplit(data) {
|
|
3339
|
+
return exports$1.fromArray(
|
|
3340
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
3341
|
+
);
|
|
3342
|
+
};
|
|
3343
|
+
})(segments);
|
|
3344
|
+
return segments;
|
|
3345
|
+
}
|
|
3346
|
+
var hasRequiredQrcode;
|
|
3347
|
+
function requireQrcode() {
|
|
3348
|
+
if (hasRequiredQrcode) return qrcode;
|
|
3349
|
+
hasRequiredQrcode = 1;
|
|
3350
|
+
const Utils = requireUtils$1();
|
|
3351
|
+
const ECLevel = requireErrorCorrectionLevel();
|
|
3352
|
+
const BitBuffer = requireBitBuffer();
|
|
3353
|
+
const BitMatrix = requireBitMatrix();
|
|
3354
|
+
const AlignmentPattern = requireAlignmentPattern();
|
|
3355
|
+
const FinderPattern = requireFinderPattern();
|
|
3356
|
+
const MaskPattern = requireMaskPattern();
|
|
3357
|
+
const ECCode = requireErrorCorrectionCode();
|
|
3358
|
+
const ReedSolomonEncoder = requireReedSolomonEncoder();
|
|
3359
|
+
const Version = requireVersion();
|
|
3360
|
+
const FormatInfo = requireFormatInfo();
|
|
3361
|
+
const Mode = requireMode();
|
|
3362
|
+
const Segments = requireSegments();
|
|
3363
|
+
function setupFinderPattern(matrix, version2) {
|
|
3364
|
+
const size = matrix.size;
|
|
3365
|
+
const pos = FinderPattern.getPositions(version2);
|
|
3366
|
+
for (let i = 0; i < pos.length; i++) {
|
|
3367
|
+
const row = pos[i][0];
|
|
3368
|
+
const col = pos[i][1];
|
|
3369
|
+
for (let r = -1; r <= 7; r++) {
|
|
3370
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
3371
|
+
for (let c = -1; c <= 7; c++) {
|
|
3372
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
3373
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
3374
|
+
matrix.set(row + r, col + c, true, true);
|
|
3375
|
+
} else {
|
|
3376
|
+
matrix.set(row + r, col + c, false, true);
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
function setupTimingPattern(matrix) {
|
|
3383
|
+
const size = matrix.size;
|
|
3384
|
+
for (let r = 8; r < size - 8; r++) {
|
|
3385
|
+
const value = r % 2 === 0;
|
|
3386
|
+
matrix.set(r, 6, value, true);
|
|
3387
|
+
matrix.set(6, r, value, true);
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
function setupAlignmentPattern(matrix, version2) {
|
|
3391
|
+
const pos = AlignmentPattern.getPositions(version2);
|
|
3392
|
+
for (let i = 0; i < pos.length; i++) {
|
|
3393
|
+
const row = pos[i][0];
|
|
3394
|
+
const col = pos[i][1];
|
|
3395
|
+
for (let r = -2; r <= 2; r++) {
|
|
3396
|
+
for (let c = -2; c <= 2; c++) {
|
|
3397
|
+
if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
|
|
3398
|
+
matrix.set(row + r, col + c, true, true);
|
|
3399
|
+
} else {
|
|
3400
|
+
matrix.set(row + r, col + c, false, true);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
function setupVersionInfo(matrix, version2) {
|
|
3407
|
+
const size = matrix.size;
|
|
3408
|
+
const bits = Version.getEncodedBits(version2);
|
|
3409
|
+
let row, col, mod;
|
|
3410
|
+
for (let i = 0; i < 18; i++) {
|
|
3411
|
+
row = Math.floor(i / 3);
|
|
3412
|
+
col = i % 3 + size - 8 - 3;
|
|
3413
|
+
mod = (bits >> i & 1) === 1;
|
|
3414
|
+
matrix.set(row, col, mod, true);
|
|
3415
|
+
matrix.set(col, row, mod, true);
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
function setupFormatInfo(matrix, errorCorrectionLevel2, maskPattern2) {
|
|
3419
|
+
const size = matrix.size;
|
|
3420
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel2, maskPattern2);
|
|
3421
|
+
let i, mod;
|
|
3422
|
+
for (i = 0; i < 15; i++) {
|
|
3423
|
+
mod = (bits >> i & 1) === 1;
|
|
3424
|
+
if (i < 6) {
|
|
3425
|
+
matrix.set(i, 8, mod, true);
|
|
3426
|
+
} else if (i < 8) {
|
|
3427
|
+
matrix.set(i + 1, 8, mod, true);
|
|
3428
|
+
} else {
|
|
3429
|
+
matrix.set(size - 15 + i, 8, mod, true);
|
|
3430
|
+
}
|
|
3431
|
+
if (i < 8) {
|
|
3432
|
+
matrix.set(8, size - i - 1, mod, true);
|
|
3433
|
+
} else if (i < 9) {
|
|
3434
|
+
matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
3435
|
+
} else {
|
|
3436
|
+
matrix.set(8, 15 - i - 1, mod, true);
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
matrix.set(size - 8, 8, 1, true);
|
|
3440
|
+
}
|
|
3441
|
+
function setupData(matrix, data) {
|
|
3442
|
+
const size = matrix.size;
|
|
3443
|
+
let inc = -1;
|
|
3444
|
+
let row = size - 1;
|
|
3445
|
+
let bitIndex = 7;
|
|
3446
|
+
let byteIndex = 0;
|
|
3447
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
3448
|
+
if (col === 6) col--;
|
|
3449
|
+
while (true) {
|
|
3450
|
+
for (let c = 0; c < 2; c++) {
|
|
3451
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
3452
|
+
let dark = false;
|
|
3453
|
+
if (byteIndex < data.length) {
|
|
3454
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
3455
|
+
}
|
|
3456
|
+
matrix.set(row, col - c, dark);
|
|
3457
|
+
bitIndex--;
|
|
3458
|
+
if (bitIndex === -1) {
|
|
3459
|
+
byteIndex++;
|
|
3460
|
+
bitIndex = 7;
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
row += inc;
|
|
3465
|
+
if (row < 0 || size <= row) {
|
|
3466
|
+
row -= inc;
|
|
3467
|
+
inc = -inc;
|
|
3468
|
+
break;
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
function createData(version2, errorCorrectionLevel2, segments2) {
|
|
3474
|
+
const buffer = new BitBuffer();
|
|
3475
|
+
segments2.forEach(function(data) {
|
|
3476
|
+
buffer.put(data.mode.bit, 4);
|
|
3477
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version2));
|
|
3478
|
+
data.write(buffer);
|
|
3479
|
+
});
|
|
3480
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version2);
|
|
3481
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version2, errorCorrectionLevel2);
|
|
3482
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
3483
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
3484
|
+
buffer.put(0, 4);
|
|
3485
|
+
}
|
|
3486
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
3487
|
+
buffer.putBit(0);
|
|
3488
|
+
}
|
|
3489
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
3490
|
+
for (let i = 0; i < remainingByte; i++) {
|
|
3491
|
+
buffer.put(i % 2 ? 17 : 236, 8);
|
|
3492
|
+
}
|
|
3493
|
+
return createCodewords(buffer, version2, errorCorrectionLevel2);
|
|
3494
|
+
}
|
|
3495
|
+
function createCodewords(bitBuffer2, version2, errorCorrectionLevel2) {
|
|
3496
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version2);
|
|
3497
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version2, errorCorrectionLevel2);
|
|
3498
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords;
|
|
3499
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version2, errorCorrectionLevel2);
|
|
3500
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks;
|
|
3501
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
|
|
3502
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
3503
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
3504
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
3505
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
3506
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
3507
|
+
let offset = 0;
|
|
3508
|
+
const dcData = new Array(ecTotalBlocks);
|
|
3509
|
+
const ecData = new Array(ecTotalBlocks);
|
|
3510
|
+
let maxDataSize = 0;
|
|
3511
|
+
const buffer = new Uint8Array(bitBuffer2.buffer);
|
|
3512
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
3513
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
3514
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
3515
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
3516
|
+
offset += dataSize;
|
|
3517
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
3518
|
+
}
|
|
3519
|
+
const data = new Uint8Array(totalCodewords);
|
|
3520
|
+
let index = 0;
|
|
3521
|
+
let i, r;
|
|
3522
|
+
for (i = 0; i < maxDataSize; i++) {
|
|
3523
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
3524
|
+
if (i < dcData[r].length) {
|
|
3525
|
+
data[index++] = dcData[r][i];
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
for (i = 0; i < ecCount; i++) {
|
|
3530
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
3531
|
+
data[index++] = ecData[r][i];
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
return data;
|
|
3535
|
+
}
|
|
3536
|
+
function createSymbol(data, version2, errorCorrectionLevel2, maskPattern2) {
|
|
3537
|
+
let segments2;
|
|
3538
|
+
if (Array.isArray(data)) {
|
|
3539
|
+
segments2 = Segments.fromArray(data);
|
|
3540
|
+
} else if (typeof data === "string") {
|
|
3541
|
+
let estimatedVersion = version2;
|
|
3542
|
+
if (!estimatedVersion) {
|
|
3543
|
+
const rawSegments = Segments.rawSplit(data);
|
|
3544
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel2);
|
|
3545
|
+
}
|
|
3546
|
+
segments2 = Segments.fromString(data, estimatedVersion || 40);
|
|
3547
|
+
} else {
|
|
3548
|
+
throw new Error("Invalid data");
|
|
3549
|
+
}
|
|
3550
|
+
const bestVersion = Version.getBestVersionForData(segments2, errorCorrectionLevel2);
|
|
3551
|
+
if (!bestVersion) {
|
|
3552
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
3553
|
+
}
|
|
3554
|
+
if (!version2) {
|
|
3555
|
+
version2 = bestVersion;
|
|
3556
|
+
} else if (version2 < bestVersion) {
|
|
3557
|
+
throw new Error(
|
|
3558
|
+
"\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n"
|
|
3559
|
+
);
|
|
3560
|
+
}
|
|
3561
|
+
const dataBits = createData(version2, errorCorrectionLevel2, segments2);
|
|
3562
|
+
const moduleCount = Utils.getSymbolSize(version2);
|
|
3563
|
+
const modules = new BitMatrix(moduleCount);
|
|
3564
|
+
setupFinderPattern(modules, version2);
|
|
3565
|
+
setupTimingPattern(modules);
|
|
3566
|
+
setupAlignmentPattern(modules, version2);
|
|
3567
|
+
setupFormatInfo(modules, errorCorrectionLevel2, 0);
|
|
3568
|
+
if (version2 >= 7) {
|
|
3569
|
+
setupVersionInfo(modules, version2);
|
|
3570
|
+
}
|
|
3571
|
+
setupData(modules, dataBits);
|
|
3572
|
+
if (isNaN(maskPattern2)) {
|
|
3573
|
+
maskPattern2 = MaskPattern.getBestMask(
|
|
3574
|
+
modules,
|
|
3575
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel2)
|
|
3576
|
+
);
|
|
3577
|
+
}
|
|
3578
|
+
MaskPattern.applyMask(maskPattern2, modules);
|
|
3579
|
+
setupFormatInfo(modules, errorCorrectionLevel2, maskPattern2);
|
|
3580
|
+
return {
|
|
3581
|
+
modules,
|
|
3582
|
+
version: version2,
|
|
3583
|
+
errorCorrectionLevel: errorCorrectionLevel2,
|
|
3584
|
+
maskPattern: maskPattern2,
|
|
3585
|
+
segments: segments2
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
qrcode.create = function create(data, options) {
|
|
3589
|
+
if (typeof data === "undefined" || data === "") {
|
|
3590
|
+
throw new Error("No input text");
|
|
3591
|
+
}
|
|
3592
|
+
let errorCorrectionLevel2 = ECLevel.M;
|
|
3593
|
+
let version2;
|
|
3594
|
+
let mask;
|
|
3595
|
+
if (typeof options !== "undefined") {
|
|
3596
|
+
errorCorrectionLevel2 = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
3597
|
+
version2 = Version.from(options.version);
|
|
3598
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
3599
|
+
if (options.toSJISFunc) {
|
|
3600
|
+
Utils.setToSJISFunction(options.toSJISFunc);
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
return createSymbol(data, version2, errorCorrectionLevel2, mask);
|
|
3604
|
+
};
|
|
3605
|
+
return qrcode;
|
|
3606
|
+
}
|
|
3607
|
+
var canvas = {};
|
|
3608
|
+
var utils = {};
|
|
3609
|
+
var hasRequiredUtils;
|
|
3610
|
+
function requireUtils() {
|
|
3611
|
+
if (hasRequiredUtils) return utils;
|
|
3612
|
+
hasRequiredUtils = 1;
|
|
3613
|
+
(function(exports$1) {
|
|
3614
|
+
function hex2rgba(hex) {
|
|
3615
|
+
if (typeof hex === "number") {
|
|
3616
|
+
hex = hex.toString();
|
|
3617
|
+
}
|
|
3618
|
+
if (typeof hex !== "string") {
|
|
3619
|
+
throw new Error("Color should be defined as hex string");
|
|
3620
|
+
}
|
|
3621
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
3622
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
|
|
3623
|
+
throw new Error("Invalid hex color: " + hex);
|
|
3624
|
+
}
|
|
3625
|
+
if (hexCode.length === 3 || hexCode.length === 4) {
|
|
3626
|
+
hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
3627
|
+
return [c, c];
|
|
3628
|
+
}));
|
|
3629
|
+
}
|
|
3630
|
+
if (hexCode.length === 6) hexCode.push("F", "F");
|
|
3631
|
+
const hexValue = parseInt(hexCode.join(""), 16);
|
|
3632
|
+
return {
|
|
3633
|
+
r: hexValue >> 24 & 255,
|
|
3634
|
+
g: hexValue >> 16 & 255,
|
|
3635
|
+
b: hexValue >> 8 & 255,
|
|
3636
|
+
a: hexValue & 255,
|
|
3637
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
3638
|
+
};
|
|
3639
|
+
}
|
|
3640
|
+
exports$1.getOptions = function getOptions(options) {
|
|
3641
|
+
if (!options) options = {};
|
|
3642
|
+
if (!options.color) options.color = {};
|
|
3643
|
+
const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
|
|
3644
|
+
const width = options.width && options.width >= 21 ? options.width : void 0;
|
|
3645
|
+
const scale = options.scale || 4;
|
|
3646
|
+
return {
|
|
3647
|
+
width,
|
|
3648
|
+
scale: width ? 4 : scale,
|
|
3649
|
+
margin,
|
|
3650
|
+
color: {
|
|
3651
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
3652
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
3653
|
+
},
|
|
3654
|
+
type: options.type,
|
|
3655
|
+
rendererOpts: options.rendererOpts || {}
|
|
3656
|
+
};
|
|
3657
|
+
};
|
|
3658
|
+
exports$1.getScale = function getScale(qrSize, opts) {
|
|
3659
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
3660
|
+
};
|
|
3661
|
+
exports$1.getImageWidth = function getImageWidth(qrSize, opts) {
|
|
3662
|
+
const scale = exports$1.getScale(qrSize, opts);
|
|
3663
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
3664
|
+
};
|
|
3665
|
+
exports$1.qrToImageData = function qrToImageData(imgData, qr, opts) {
|
|
3666
|
+
const size = qr.modules.size;
|
|
3667
|
+
const data = qr.modules.data;
|
|
3668
|
+
const scale = exports$1.getScale(size, opts);
|
|
3669
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale);
|
|
3670
|
+
const scaledMargin = opts.margin * scale;
|
|
3671
|
+
const palette = [opts.color.light, opts.color.dark];
|
|
3672
|
+
for (let i = 0; i < symbolSize; i++) {
|
|
3673
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
3674
|
+
let posDst = (i * symbolSize + j) * 4;
|
|
3675
|
+
let pxColor = opts.color.light;
|
|
3676
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
3677
|
+
const iSrc = Math.floor((i - scaledMargin) / scale);
|
|
3678
|
+
const jSrc = Math.floor((j - scaledMargin) / scale);
|
|
3679
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
3680
|
+
}
|
|
3681
|
+
imgData[posDst++] = pxColor.r;
|
|
3682
|
+
imgData[posDst++] = pxColor.g;
|
|
3683
|
+
imgData[posDst++] = pxColor.b;
|
|
3684
|
+
imgData[posDst] = pxColor.a;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3688
|
+
})(utils);
|
|
3689
|
+
return utils;
|
|
3690
|
+
}
|
|
3691
|
+
var hasRequiredCanvas;
|
|
3692
|
+
function requireCanvas() {
|
|
3693
|
+
if (hasRequiredCanvas) return canvas;
|
|
3694
|
+
hasRequiredCanvas = 1;
|
|
3695
|
+
(function(exports$1) {
|
|
3696
|
+
const Utils = requireUtils();
|
|
3697
|
+
function clearCanvas(ctx, canvas2, size) {
|
|
3698
|
+
ctx.clearRect(0, 0, canvas2.width, canvas2.height);
|
|
3699
|
+
if (!canvas2.style) canvas2.style = {};
|
|
3700
|
+
canvas2.height = size;
|
|
3701
|
+
canvas2.width = size;
|
|
3702
|
+
canvas2.style.height = size + "px";
|
|
3703
|
+
canvas2.style.width = size + "px";
|
|
3704
|
+
}
|
|
3705
|
+
function getCanvasElement() {
|
|
3706
|
+
try {
|
|
3707
|
+
return document.createElement("canvas");
|
|
3708
|
+
} catch (e) {
|
|
3709
|
+
throw new Error("You need to specify a canvas element");
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
exports$1.render = function render(qrData, canvas2, options) {
|
|
3713
|
+
let opts = options;
|
|
3714
|
+
let canvasEl = canvas2;
|
|
3715
|
+
if (typeof opts === "undefined" && (!canvas2 || !canvas2.getContext)) {
|
|
3716
|
+
opts = canvas2;
|
|
3717
|
+
canvas2 = void 0;
|
|
3718
|
+
}
|
|
3719
|
+
if (!canvas2) {
|
|
3720
|
+
canvasEl = getCanvasElement();
|
|
3721
|
+
}
|
|
3722
|
+
opts = Utils.getOptions(opts);
|
|
3723
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts);
|
|
3724
|
+
const ctx = canvasEl.getContext("2d");
|
|
3725
|
+
const image = ctx.createImageData(size, size);
|
|
3726
|
+
Utils.qrToImageData(image.data, qrData, opts);
|
|
3727
|
+
clearCanvas(ctx, canvasEl, size);
|
|
3728
|
+
ctx.putImageData(image, 0, 0);
|
|
3729
|
+
return canvasEl;
|
|
3730
|
+
};
|
|
3731
|
+
exports$1.renderToDataURL = function renderToDataURL(qrData, canvas2, options) {
|
|
3732
|
+
let opts = options;
|
|
3733
|
+
if (typeof opts === "undefined" && (!canvas2 || !canvas2.getContext)) {
|
|
3734
|
+
opts = canvas2;
|
|
3735
|
+
canvas2 = void 0;
|
|
3736
|
+
}
|
|
3737
|
+
if (!opts) opts = {};
|
|
3738
|
+
const canvasEl = exports$1.render(qrData, canvas2, opts);
|
|
3739
|
+
const type = opts.type || "image/png";
|
|
3740
|
+
const rendererOpts = opts.rendererOpts || {};
|
|
3741
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
3742
|
+
};
|
|
3743
|
+
})(canvas);
|
|
3744
|
+
return canvas;
|
|
3745
|
+
}
|
|
3746
|
+
var svgTag = {};
|
|
3747
|
+
var hasRequiredSvgTag;
|
|
3748
|
+
function requireSvgTag() {
|
|
3749
|
+
if (hasRequiredSvgTag) return svgTag;
|
|
3750
|
+
hasRequiredSvgTag = 1;
|
|
3751
|
+
const Utils = requireUtils();
|
|
3752
|
+
function getColorAttrib(color, attrib) {
|
|
3753
|
+
const alpha = color.a / 255;
|
|
3754
|
+
const str = attrib + '="' + color.hex + '"';
|
|
3755
|
+
return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
|
|
3756
|
+
}
|
|
3757
|
+
function svgCmd(cmd, x, y) {
|
|
3758
|
+
let str = cmd + x;
|
|
3759
|
+
if (typeof y !== "undefined") str += " " + y;
|
|
3760
|
+
return str;
|
|
3761
|
+
}
|
|
3762
|
+
function qrToPath(data, size, margin) {
|
|
3763
|
+
let path = "";
|
|
3764
|
+
let moveBy = 0;
|
|
3765
|
+
let newRow = false;
|
|
3766
|
+
let lineLength = 0;
|
|
3767
|
+
for (let i = 0; i < data.length; i++) {
|
|
3768
|
+
const col = Math.floor(i % size);
|
|
3769
|
+
const row = Math.floor(i / size);
|
|
3770
|
+
if (!col && !newRow) newRow = true;
|
|
3771
|
+
if (data[i]) {
|
|
3772
|
+
lineLength++;
|
|
3773
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
3774
|
+
path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
3775
|
+
moveBy = 0;
|
|
3776
|
+
newRow = false;
|
|
3777
|
+
}
|
|
3778
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
3779
|
+
path += svgCmd("h", lineLength);
|
|
3780
|
+
lineLength = 0;
|
|
3781
|
+
}
|
|
3782
|
+
} else {
|
|
3783
|
+
moveBy++;
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
return path;
|
|
3787
|
+
}
|
|
3788
|
+
svgTag.render = function render(qrData, options, cb) {
|
|
3789
|
+
const opts = Utils.getOptions(options);
|
|
3790
|
+
const size = qrData.modules.size;
|
|
3791
|
+
const data = qrData.modules.data;
|
|
3792
|
+
const qrcodesize = size + opts.margin * 2;
|
|
3793
|
+
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
3794
|
+
const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
3795
|
+
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
3796
|
+
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
3797
|
+
const svgTag2 = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + "</svg>\n";
|
|
3798
|
+
if (typeof cb === "function") {
|
|
3799
|
+
cb(null, svgTag2);
|
|
3800
|
+
}
|
|
3801
|
+
return svgTag2;
|
|
3802
|
+
};
|
|
3803
|
+
return svgTag;
|
|
3804
|
+
}
|
|
3805
|
+
var hasRequiredBrowser;
|
|
3806
|
+
function requireBrowser() {
|
|
3807
|
+
if (hasRequiredBrowser) return browser;
|
|
3808
|
+
hasRequiredBrowser = 1;
|
|
3809
|
+
const canPromise2 = requireCanPromise();
|
|
3810
|
+
const QRCode2 = requireQrcode();
|
|
3811
|
+
const CanvasRenderer = requireCanvas();
|
|
3812
|
+
const SvgRenderer = requireSvgTag();
|
|
3813
|
+
function renderCanvas(renderFunc, canvas2, text, opts, cb) {
|
|
3814
|
+
const args = [].slice.call(arguments, 1);
|
|
3815
|
+
const argsNum = args.length;
|
|
3816
|
+
const isLastArgCb = typeof args[argsNum - 1] === "function";
|
|
3817
|
+
if (!isLastArgCb && !canPromise2()) {
|
|
3818
|
+
throw new Error("Callback required as last argument");
|
|
3819
|
+
}
|
|
3820
|
+
if (isLastArgCb) {
|
|
3821
|
+
if (argsNum < 2) {
|
|
3822
|
+
throw new Error("Too few arguments provided");
|
|
3823
|
+
}
|
|
3824
|
+
if (argsNum === 2) {
|
|
3825
|
+
cb = text;
|
|
3826
|
+
text = canvas2;
|
|
3827
|
+
canvas2 = opts = void 0;
|
|
3828
|
+
} else if (argsNum === 3) {
|
|
3829
|
+
if (canvas2.getContext && typeof cb === "undefined") {
|
|
3830
|
+
cb = opts;
|
|
3831
|
+
opts = void 0;
|
|
3832
|
+
} else {
|
|
3833
|
+
cb = opts;
|
|
3834
|
+
opts = text;
|
|
3835
|
+
text = canvas2;
|
|
3836
|
+
canvas2 = void 0;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
} else {
|
|
3840
|
+
if (argsNum < 1) {
|
|
3841
|
+
throw new Error("Too few arguments provided");
|
|
3842
|
+
}
|
|
3843
|
+
if (argsNum === 1) {
|
|
3844
|
+
text = canvas2;
|
|
3845
|
+
canvas2 = opts = void 0;
|
|
3846
|
+
} else if (argsNum === 2 && !canvas2.getContext) {
|
|
3847
|
+
opts = text;
|
|
3848
|
+
text = canvas2;
|
|
3849
|
+
canvas2 = void 0;
|
|
3850
|
+
}
|
|
3851
|
+
return new Promise(function(resolve, reject) {
|
|
3852
|
+
try {
|
|
3853
|
+
const data = QRCode2.create(text, opts);
|
|
3854
|
+
resolve(renderFunc(data, canvas2, opts));
|
|
3855
|
+
} catch (e) {
|
|
3856
|
+
reject(e);
|
|
3857
|
+
}
|
|
3858
|
+
});
|
|
3859
|
+
}
|
|
3860
|
+
try {
|
|
3861
|
+
const data = QRCode2.create(text, opts);
|
|
3862
|
+
cb(null, renderFunc(data, canvas2, opts));
|
|
3863
|
+
} catch (e) {
|
|
3864
|
+
cb(e);
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
browser.create = QRCode2.create;
|
|
3868
|
+
browser.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
3869
|
+
browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
3870
|
+
browser.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
3871
|
+
return SvgRenderer.render(data, opts);
|
|
3872
|
+
});
|
|
3873
|
+
return browser;
|
|
3874
|
+
}
|
|
3875
|
+
var browserExports = requireBrowser();
|
|
3876
|
+
const QRCode = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
|
|
3877
|
+
const qrCodeModalHTML = '<div class="idvc-modal-background" id="idvc-modal-background">\n <div class="el-loading-spinner" id="idvc-loading-spinner">\n <svg viewBox="25 25 50 50" class="circular">\n <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>\n </svg>\n </div>\n</div>\n<div class="idvc-modal idvc-modal_qr-code" id="idvc-modal">\n <div class="idvc-modal__header-wrap qr-code__header">\n <div class="idvc-modal__close-btn" id="idvc-close-modal-btn"></div>\n <div class="idvc-modal__header">\n <h2 class="idvc-modal__header__content idvc-modal__header__content_qr-code">\n Verify Documents by Phone\n </h2>\n </div>\n </div>\n <div class="idvc-modal__body idvc-modal__body_qr-code">\n <div class="idvc-modal__body_process_ready" id="idvc-modal__body_process_ready">\n <h3 class="idvc-modal__body_process_ready-header">Scan the QR Сode below to continue on your mobile device</h3>\n <div class="idvc-modal__body_process_ready__canvas-container">\n <canvas class="idvc-modal__body_process_ready-canvas" id="idvc-modal__body_process_ready-canvas"></canvas>\n </div>\n <div class="idvc-modal__body_process_ready-info qr-code__header">\n <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M7 0C8.97933 0.052 10.6278 0.736833 11.9455 2.0545C13.2632 3.37217 13.948 5.02067 14 7C13.948 8.97933 13.2632 10.6278 11.9455 11.9455C10.6278 13.2632 8.97933 13.948 7 14C5.02067 13.948 3.37217 13.2632 2.0545 11.9455C0.736833 10.6278 0.052 8.97933 0 7C0.052 5.02067 0.736833 3.37217 2.0545 2.0545C3.37217 0.736833 5.02067 0.052 7 0ZM7 3C6.729 3 6.505 3.099 6.328 3.297C6.151 3.495 6.07283 3.72933 6.0935 4L6.453 8C6.474 8.146 6.53383 8.26317 6.6325 8.3515C6.73117 8.43983 6.8535 8.48417 6.9995 8.4845C7.1455 8.48483 7.26783 8.4405 7.3665 8.3515C7.46517 8.2625 7.525 8.14533 7.546 8L7.9055 4C7.9265 3.729 7.84833 3.49467 7.671 3.297C7.49367 3.09933 7.26967 3.00033 6.999 3H7ZM7 11C7.22933 10.9897 7.4195 10.9115 7.5705 10.7655C7.7215 10.6195 7.797 10.432 7.797 10.203C7.797 9.974 7.7215 9.78383 7.5705 9.6325C7.4195 9.48117 7.22933 9.40567 7 9.406C6.77067 9.40633 6.5805 9.48183 6.4295 9.6325C6.2785 9.78317 6.203 9.97333 6.203 10.203C6.203 10.4327 6.2785 10.6202 6.4295 10.7655C6.5805 10.9108 6.77067 10.989 7 11Z" fill="#F7BA2A"/>\n </svg>\n <span class="idvc-modal__body_process_ready-info__text">Any images you have uploaded will be lost if you scan the QR code and continue the process on your mobile device</span>\n </div>\n </div>\n\n <div class="idvc-modal__body_process_validating d-none" id="idvc-modal__body_process_validating">\n <div class="el-loading-spinner el-loading-spinner_qr-code" id="idvc-validating-spinner">\n <svg viewBox="25 25 50 50" class="circular circular__background">\n <circle cx="50" cy="50" r="20" fill="none" class="path path__background"></circle>\n </svg>\n <svg viewBox="25 25 50 50" class="circular">\n <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>\n </svg>\n <span class="idvc-modal__body_process_validating-info__text">The verification process is currently being completed using a mobile device ...</span>\n </div>\n </div>\n\n <div class="idvc-modal__body_process_done d-none" id="result-success">\n <div class="idvc-modal__body_process_done-container">\n <svg\n width="64"\n height="64"\n viewBox="0 0 64 64"\n fill="none"\n xmlns="http://www.w3.org/2000/svg">\n <path d="M31.5 0.5C40.407 0.734 47.8253 3.81575 53.7548 9.74525C59.6842 15.6748 62.766 23.093 63 32C62.766 40.907 59.6842 48.3253 53.7548 54.2548C47.8253 60.1842 40.407 63.266 31.5 63.5C22.593 63.266 15.1748 60.1842 9.24525 54.2548C3.31575 48.3253 0.234 40.907 0 32C0.234 23.093 3.31575 15.6748 9.24525 9.74525C15.1748 3.81575 22.593 0.734 31.5 0.5ZM27.5625 38.1875L20.601 31.226C20.0385 30.71 19.3942 30.452 18.6682 30.452C17.9422 30.452 17.3092 30.7212 16.7693 31.2597C16.2292 31.7982 15.96 32.4193 15.9615 33.1227C15.963 33.8263 16.221 34.4593 16.7355 35.0218L25.6657 43.952C26.1817 44.468 26.8148 44.726 27.5648 44.726C28.3148 44.726 28.9478 44.468 29.4638 43.952L47.9565 25.4593C48.66 24.7558 48.8828 23.9 48.6247 22.892C48.3667 21.884 47.7337 21.251 46.7257 20.993C45.7178 20.735 44.862 20.9578 44.1585 21.6612L27.5625 38.1875Z" fill="#5FCA71"/>\n </svg>\n <div class="idvc-modal__body_process_done__text" id="result__text-success">\n Success\n </div>\n </div>\n </div>\n\n <div class="idvc-modal__body_process_done d-none" id="result-error">\n <div class="idvc-modal__body_process_done-container">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="64"\n height="64"\n fill="#ff0000"\n viewBox="0 0 512 512">\n <path d="M502.876 379.713l-189.486-316.329c-6.088-9.895-14.349-17.903-24.154-23.52l-0.329-0.174c-20.048-11.267-45.677-11.292-65.788 0.022-10.123 5.785-18.372 13.786-24.282 23.381l-0.167 0.291c-0.022 0.045-0.042 0.066-0.064 0.109l-189.619 316.546c-18.512 32.098-7.501 73.127 24.596 91.642 9.476 5.56 20.852 8.88 32.997 8.972h379.12c37.046-0.406 66.736-30.765 66.347-67.804-0.137-12.231-3.526-23.642-9.34-33.446l0.171 0.31zM233.656 189.931c0.138-12.246 10.097-22.12 22.363-22.12s22.225 9.874 22.363 22.107v89.466c0 0.002 0 0.003 0 0.005 0 12.347-10.010 22.356-22.356 22.356-0.002 0-0.004 0-0.005 0h0c-0.002 0-0.005 0-0.008 0-12.345 0-22.352-10.005-22.357-22.348v-0zM278.413 368.985c0 12.368-10.026 22.394-22.394 22.394s-22.394-10.026-22.394-22.394c0-12.367 10.024-22.392 22.391-22.394v0c0.001 0 0.002 0 0.002 0 12.368 0 22.394 10.026 22.394 22.394v0z"/>\n </svg>\n <div class="idvc-modal__body_process_done__text" id="result__text-error">\n Validation Failed\n </div>\n </div>\n </div>\n <div class="idvc-modal__footer_qr-code">\n <button type="button" class="btn btn--primary" id="idvc-qr-code-terminate-process-btn">\n <span>Done</span>\n </button>\n </div>\n </div>\n</div>\n';
|
|
3878
|
+
class QRCodeModal extends Modal {
|
|
3879
|
+
constructor(mountEl, applicantId, domainApi, embeddedAppConnectionId, qrCodeLinkOrigin, state = QRCodeModalState.READY) {
|
|
3880
|
+
super(mountEl);
|
|
3881
|
+
this.applicantId = applicantId;
|
|
3882
|
+
this.state = state;
|
|
3883
|
+
this.domainApi = domainApi;
|
|
3884
|
+
this.embeddedAppConnectionId = embeddedAppConnectionId;
|
|
3885
|
+
this.qrCodeLinkOrigin = qrCodeLinkOrigin;
|
|
3886
|
+
this.initQRCodeURL();
|
|
3887
|
+
if (state === QRCodeModalState.READY) {
|
|
3888
|
+
this.generateQR(this.QRCodeURL);
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
init(html2 = qrCodeModalHTML) {
|
|
3892
|
+
super.init(html2);
|
|
3893
|
+
this.qrCodeCanvas = this.container.querySelector("#idvc-modal__body_process_ready-canvas");
|
|
3894
|
+
this.successResultContainer = this.container.querySelector("#result-success");
|
|
3895
|
+
this.errorResultContainer = this.container.querySelector("#result-error");
|
|
3896
|
+
this.processReadyContainer = this.container.querySelector("#idvc-modal__body_process_ready");
|
|
3897
|
+
this.processValidatingContainer = this.container.querySelector("#idvc-modal__body_process_validating");
|
|
3898
|
+
this.terminateProcessingButton = this.container.querySelector("#idvc-qr-code-terminate-process-btn");
|
|
3899
|
+
this.mappedState = {
|
|
3900
|
+
ready: this.processReadyContainer,
|
|
3901
|
+
validating: this.processValidatingContainer,
|
|
3902
|
+
doneWithSuccess: this.successResultContainer,
|
|
3903
|
+
doneWithError: this.errorResultContainer
|
|
3904
|
+
};
|
|
3905
|
+
this.terminateProcessHandler();
|
|
3906
|
+
}
|
|
3907
|
+
initQRCodeURL() {
|
|
3908
|
+
this.QRCodeURL = `${this.qrCodeLinkOrigin}/embedded?requestId=${this.applicantId}&embeddedAppConnectionId=${this.embeddedAppConnectionId}&qrCode=true`;
|
|
3909
|
+
}
|
|
3910
|
+
set state(newState) {
|
|
3911
|
+
this.modalState = newState;
|
|
3912
|
+
try {
|
|
3913
|
+
this.changeModalBodyView(this.modalState);
|
|
3914
|
+
} catch (e) {
|
|
3915
|
+
throw new Error(`Wrong modal state, error: ${e}`);
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
terminateProcessHandler() {
|
|
3919
|
+
this.terminateProcessingButton.addEventListener("click", () => {
|
|
3920
|
+
const terminateEmbeddedEvent = new CustomEvent("terminateEmbedded", { bubbles: true });
|
|
3921
|
+
this.terminateProcessingButton.dispatchEvent(terminateEmbeddedEvent);
|
|
3922
|
+
});
|
|
3923
|
+
}
|
|
3924
|
+
changeModalBodyView(modalState) {
|
|
3925
|
+
Object.entries(this.mappedState).forEach(([state, container]) => {
|
|
3926
|
+
if (state === modalState) {
|
|
3927
|
+
container.classList.remove("d-none");
|
|
3928
|
+
} else {
|
|
3929
|
+
container.classList.add("d-none");
|
|
3930
|
+
}
|
|
3931
|
+
});
|
|
3932
|
+
modalState === QRCodeModalState.VALIDATING ? this.terminateProcessingButton.classList.remove("d-none") : this.terminateProcessingButton.classList.add("d-none");
|
|
3933
|
+
}
|
|
3934
|
+
async generateQR(url) {
|
|
3935
|
+
try {
|
|
3936
|
+
await QRCode.toCanvas(this.qrCodeCanvas, url, {
|
|
3937
|
+
width: this.qrCodeCanvas.width
|
|
3938
|
+
});
|
|
3939
|
+
} catch (e) {
|
|
3940
|
+
throw new Error(`generate qr code error: ${e}`);
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
show() {
|
|
3944
|
+
this.prepareBackgroundStyles();
|
|
3945
|
+
super.show();
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
const browserRE = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i;
|
|
3949
|
+
const browserREAlt = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
|
|
3950
|
+
const isiOS = () => [
|
|
3951
|
+
"iPad Simulator",
|
|
3952
|
+
"iPhone Simulator",
|
|
3953
|
+
"iPad",
|
|
3954
|
+
"iPhone"
|
|
3955
|
+
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
3956
|
+
const checkTouchPoints = () => navigator.maxTouchPoints > 0;
|
|
3957
|
+
const isMobile = () => {
|
|
3958
|
+
const { userAgent } = navigator;
|
|
3959
|
+
const mediaQueryCoarse = window.matchMedia("(any-pointer: coarse)");
|
|
3960
|
+
const hasTouches = checkTouchPoints();
|
|
3961
|
+
const isMobileUserAgent = () => browserRE.test(userAgent) || browserREAlt.test(userAgent.substring(0, 4)) || isiOS();
|
|
3962
|
+
const isTouchable = () => window.PointerEvent && hasTouches;
|
|
3963
|
+
const isTouchScreen = () => mediaQueryCoarse.matches;
|
|
3964
|
+
const isSurface = () => userAgent.indexOf("Windows") !== -1 && isTouchable();
|
|
3965
|
+
return {
|
|
3966
|
+
isMobileUserAgent,
|
|
3967
|
+
isTouchable,
|
|
3968
|
+
isTouchScreen,
|
|
3969
|
+
isSurface
|
|
3970
|
+
};
|
|
3971
|
+
};
|
|
3972
|
+
const checkIfMobile = () => {
|
|
3973
|
+
const mc = isMobile();
|
|
3974
|
+
const isMobileUserAgent = mc.isMobileUserAgent();
|
|
3975
|
+
const isTouchable = mc.isTouchable();
|
|
3976
|
+
const isTouchScreen = mc.isTouchScreen();
|
|
3977
|
+
const isSurface = mc.isSurface();
|
|
3978
|
+
return isMobileUserAgent && isTouchable && isTouchScreen || isSurface;
|
|
3979
|
+
};
|
|
3980
|
+
const version = "2.9.0";
|
|
3981
|
+
const packageJson = {
|
|
3982
|
+
version
|
|
3983
|
+
};
|
|
3984
|
+
class Wrapper {
|
|
3985
|
+
constructor(config, IDVCModule) {
|
|
3986
|
+
this.wrapperContainerId = "idvc-wrapper-container";
|
|
3987
|
+
console.info(`%cIDVCO version: ${packageJson.version}`, "background-color:#f48020; color:#fff; padding: 4px 8px");
|
|
3988
|
+
if (window.location.hostname === "localhost") {
|
|
3989
|
+
console.info("%c You can pass DVS Online domainApi in config. Ex: {domainApi: 'https://localhost:8000'}", "background: #FFCC00; color: #000");
|
|
3990
|
+
}
|
|
3991
|
+
this.config = config;
|
|
3992
|
+
this.IDVCModule = IDVCModule;
|
|
3993
|
+
this.beforeMount(config);
|
|
3994
|
+
}
|
|
3995
|
+
get isEmbeddedFromQR() {
|
|
3996
|
+
return getQueryParam("qrCode") === "true";
|
|
3997
|
+
}
|
|
3998
|
+
get QRCodeIsAvailable() {
|
|
3999
|
+
return !this.isEmbeddedFromQR && !this.config.demoMode && this.options.showQrCode && !checkIfMobile();
|
|
4000
|
+
}
|
|
4001
|
+
updateConfig(newConfig) {
|
|
4002
|
+
this.configs.libConfig = this.prepareConfig(newConfig);
|
|
4003
|
+
this.lib.reloadComponent(this.configs.libConfig);
|
|
4004
|
+
}
|
|
4005
|
+
/**
|
|
4006
|
+
* reinitialize the library with new applicant id
|
|
4007
|
+
*/
|
|
4008
|
+
async setApplicant(applicantId) {
|
|
4009
|
+
this.lib.loading = true;
|
|
4010
|
+
try {
|
|
4011
|
+
this.configs.applicantId = applicantId;
|
|
4012
|
+
this.validationModal.hide();
|
|
4013
|
+
const isValidApplicant = await this.checkApplicantIsValid();
|
|
4014
|
+
if (isValidApplicant) {
|
|
4015
|
+
await this.restart();
|
|
4016
|
+
this.lib.loading = false;
|
|
4017
|
+
} else {
|
|
4018
|
+
this.lib.loading = false;
|
|
4019
|
+
throw new Error();
|
|
4020
|
+
}
|
|
4021
|
+
} catch (e) {
|
|
4022
|
+
this.lib.loading = false;
|
|
4023
|
+
this.onError(e);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
async restart() {
|
|
4027
|
+
if (this.lib.initialized) {
|
|
4028
|
+
this.lib.restart();
|
|
4029
|
+
} else {
|
|
4030
|
+
await this.start();
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
showLoader(val, bottomText, topText) {
|
|
4034
|
+
if (this.lib) {
|
|
4035
|
+
this.lib.showLoader(val, bottomText, topText);
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
wrapIDVCComponent() {
|
|
4039
|
+
const idvcContainer = document.getElementById(this.configs.mountElement);
|
|
4040
|
+
if (idvcContainer) {
|
|
4041
|
+
idvcContainer.classList.add("hidden-element");
|
|
4042
|
+
idvcContainer.outerHTML = `<div id="${this.wrapperContainerId}">${idvcContainer.outerHTML}</div>`;
|
|
4043
|
+
} else {
|
|
4044
|
+
throw new Error("Mount element isn't found");
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
async beforeMount(config) {
|
|
4048
|
+
try {
|
|
4049
|
+
this.configs = new Configs(config);
|
|
4050
|
+
this.api = new Api(this.configs.publicKey, this.configs.domainApi);
|
|
4051
|
+
this.lib = new Lib();
|
|
4052
|
+
this.embeddedAppConnectionId = getQueryParam("embeddedAppConnectionId") || createGuid();
|
|
4053
|
+
this.mountValidationModal();
|
|
4054
|
+
this.configs.validate();
|
|
4055
|
+
this.configs.onGetOptionsStart();
|
|
4056
|
+
this.options = await this.api.getOptions(this.configs.domainId);
|
|
4057
|
+
this.configs.onGetOptionsComplete(this.options);
|
|
4058
|
+
if (!this.config.preferApiConfig) {
|
|
4059
|
+
this.options = this.applyWrapperConfigSettings(this.options);
|
|
4060
|
+
}
|
|
4061
|
+
await this.mount();
|
|
4062
|
+
} catch (e) {
|
|
4063
|
+
this.onError(e);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
applyWrapperConfigSettings(wrapperSettingsFromApi) {
|
|
4067
|
+
var _a, _b;
|
|
4068
|
+
if ((_a = this.config) == null ? void 0 : _a.wrapperSettings) {
|
|
4069
|
+
const copy = structuredClone(wrapperSettingsFromApi);
|
|
4070
|
+
const wrapperSettings = ((_b = this.config) == null ? void 0 : _b.wrapperSettings) || {};
|
|
4071
|
+
const keys = Object.keys(wrapperSettings);
|
|
4072
|
+
keys.forEach((key) => {
|
|
4073
|
+
const value = wrapperSettings[key];
|
|
4074
|
+
if (typeof value !== "undefined") {
|
|
4075
|
+
copy[key] = value;
|
|
4076
|
+
}
|
|
4077
|
+
});
|
|
4078
|
+
return copy;
|
|
4079
|
+
}
|
|
4080
|
+
return wrapperSettingsFromApi;
|
|
4081
|
+
}
|
|
4082
|
+
mountQRCodeButton() {
|
|
4083
|
+
var _a;
|
|
4084
|
+
const mountElementBtns = document.getElementById("card-steps");
|
|
4085
|
+
if (mountElementBtns) {
|
|
4086
|
+
mountElementBtns.insertAdjacentHTML("afterend", html);
|
|
4087
|
+
}
|
|
4088
|
+
this.qrCodeBtn = document.getElementById("qr-code-wrap__button");
|
|
4089
|
+
(_a = this.qrCodeBtn) == null ? void 0 : _a.addEventListener("click", () => {
|
|
4090
|
+
this.QRCodeModal.show();
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
async mount() {
|
|
4094
|
+
try {
|
|
4095
|
+
const isValidApplicant = await this.checkApplicantIsValid();
|
|
4096
|
+
if (isValidApplicant && this.options.showConsentForm) {
|
|
4097
|
+
this.wrapIDVCComponent();
|
|
4098
|
+
this.form = new ConsentForm({
|
|
4099
|
+
mountElementID: this.wrapperContainerId,
|
|
4100
|
+
consentBodyText: this.options.consentText,
|
|
4101
|
+
consentCheckboxText: this.options.checkboxText
|
|
4102
|
+
});
|
|
4103
|
+
this.form.form.addEventListener("proceedEvent", async () => {
|
|
4104
|
+
var _a;
|
|
4105
|
+
(_a = document.getElementById(this.configs.mountElement)) == null ? void 0 : _a.classList.remove("hidden-element");
|
|
4106
|
+
}, { once: true });
|
|
4107
|
+
}
|
|
4108
|
+
if (isValidApplicant) {
|
|
4109
|
+
await this.start();
|
|
4110
|
+
this.showSpinner();
|
|
4111
|
+
if (this.QRCodeIsAvailable) {
|
|
4112
|
+
this.mountQR();
|
|
4113
|
+
}
|
|
4114
|
+
if (this.isEmbeddedFromQR) {
|
|
4115
|
+
this.api.longPollingRequest(
|
|
4116
|
+
`IsClosed/${this.configs.applicantId}`,
|
|
4117
|
+
{ method: "GET" },
|
|
4118
|
+
() => {
|
|
4119
|
+
this.unmount();
|
|
4120
|
+
}
|
|
4121
|
+
);
|
|
4122
|
+
this.api.longPollingRequest(
|
|
4123
|
+
`Open/${this.configs.applicantId}`,
|
|
4124
|
+
{ method: "POST" },
|
|
4125
|
+
() => {
|
|
4126
|
+
}
|
|
4127
|
+
);
|
|
4128
|
+
}
|
|
4129
|
+
} else {
|
|
4130
|
+
throw new Error();
|
|
4131
|
+
}
|
|
4132
|
+
} catch (e) {
|
|
4133
|
+
this.onError(e);
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
unmount() {
|
|
4137
|
+
const target = document.getElementById(this.configs.libConfig.el);
|
|
4138
|
+
target.remove();
|
|
4139
|
+
}
|
|
4140
|
+
async checkApplicantIsValid() {
|
|
4141
|
+
return this.api.checkApplicantIdIsNotClosed({
|
|
4142
|
+
applicantId: this.configs.applicantId,
|
|
4143
|
+
demoMode: this.configs.demoMode,
|
|
4144
|
+
faceAuth: this.configs.isAuth,
|
|
4145
|
+
faceOnly: this.configs.faceOnly
|
|
4146
|
+
});
|
|
4147
|
+
}
|
|
4148
|
+
prepareConfig(options) {
|
|
4149
|
+
const libSettings = JSON.parse(options);
|
|
4150
|
+
libSettings.documentTypes = prepareDocumentTypes(libSettings);
|
|
4151
|
+
return libSettings;
|
|
4152
|
+
}
|
|
4153
|
+
showSpinner() {
|
|
4154
|
+
this.validationModal.hideSpinner();
|
|
4155
|
+
this.validationModal.closable = false;
|
|
4156
|
+
}
|
|
4157
|
+
async submit(model) {
|
|
4158
|
+
try {
|
|
4159
|
+
const submitProcessSpinner = {
|
|
4160
|
+
top: "Document has been submitted for processing",
|
|
4161
|
+
bottom: "Please wait for the response"
|
|
4162
|
+
};
|
|
4163
|
+
this.lib.showLoader(true, submitProcessSpinner.bottom, submitProcessSpinner.top);
|
|
4164
|
+
const postModel = await this.createPostModel(
|
|
4165
|
+
model,
|
|
4166
|
+
this.configs.isAuth || this.configs.faceOnly
|
|
4167
|
+
);
|
|
4168
|
+
const postData = {
|
|
4169
|
+
applicantId: postModel.applicantId,
|
|
4170
|
+
model: postModel,
|
|
4171
|
+
embeddedAppConnectionId: this.embeddedAppConnectionId
|
|
4172
|
+
};
|
|
4173
|
+
this.validationOutput = await this.api.validateApplicant(
|
|
4174
|
+
postData,
|
|
4175
|
+
this.configs.demoMode,
|
|
4176
|
+
this.configs.isAuth
|
|
4177
|
+
);
|
|
4178
|
+
this.lib.showLoader(false);
|
|
4179
|
+
this.configs.onValidate(this.validationOutput);
|
|
4180
|
+
this.showSpinner();
|
|
4181
|
+
this.showValidationSuccess();
|
|
4182
|
+
} catch (e) {
|
|
4183
|
+
this.lib.loading = false;
|
|
4184
|
+
this.onError(e);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
showValidationSuccess() {
|
|
4188
|
+
const validation = new Validation(this.validationOutput, this.validationModal);
|
|
4189
|
+
validation.prepareModal();
|
|
4190
|
+
validation.showModal();
|
|
4191
|
+
}
|
|
4192
|
+
async createPostModel(model, isFaceAuth) {
|
|
4193
|
+
return {
|
|
4194
|
+
applicantId: this.configs.applicantId,
|
|
4195
|
+
...model,
|
|
4196
|
+
...{ documentType: isFaceAuth ? 10 : model.documentType },
|
|
4197
|
+
clientVersion: this.lib.version,
|
|
4198
|
+
clientType: ClientType.WebLibStandalone
|
|
4199
|
+
};
|
|
4200
|
+
}
|
|
4201
|
+
async start() {
|
|
4202
|
+
await this.loadOptions();
|
|
4203
|
+
this.lib.configs = {
|
|
4204
|
+
IdvcConfig: this.configs.libConfig,
|
|
4205
|
+
CSSStylesConfig: this.configs.cssStylesConfig,
|
|
4206
|
+
CSSVariablesConfig: this.configs.cssVariablesConfig
|
|
4207
|
+
};
|
|
4208
|
+
this.lib.mixSubmit("submit", this.submit.bind(this));
|
|
4209
|
+
if (this.configs.IDVCDownloadVersion === "latest" && this.configs.libConfig.useCDN) {
|
|
4210
|
+
const currentProductionIdvcVersion = await this.api.getCurrentIdvcVersion();
|
|
4211
|
+
await this.lib.initializeLibrary(
|
|
4212
|
+
!!this.configs.libConfig.useCDN,
|
|
4213
|
+
currentProductionIdvcVersion
|
|
4214
|
+
);
|
|
4215
|
+
} else {
|
|
4216
|
+
await this.lib.initializeLibrary(
|
|
4217
|
+
!!this.configs.libConfig.useCDN,
|
|
4218
|
+
this.configs.IDVCDownloadVersion,
|
|
4219
|
+
this.IDVCModule
|
|
4220
|
+
);
|
|
4221
|
+
}
|
|
4222
|
+
this.mountValidationModal();
|
|
4223
|
+
}
|
|
4224
|
+
mountQR() {
|
|
4225
|
+
this.mountQRCodeModal();
|
|
4226
|
+
this.mountQRCodeButton();
|
|
4227
|
+
}
|
|
4228
|
+
async loadOptions() {
|
|
4229
|
+
this.configs.parseFromWeb(this.options);
|
|
4230
|
+
}
|
|
4231
|
+
async forceClose() {
|
|
4232
|
+
try {
|
|
4233
|
+
this.lib.loading = true;
|
|
4234
|
+
const res = await this.api.forceClose(this.configs.applicantId);
|
|
4235
|
+
if (res) {
|
|
4236
|
+
this.configs.onValidate({
|
|
4237
|
+
...this.validationOutput,
|
|
4238
|
+
forceComplete: true
|
|
4239
|
+
});
|
|
4240
|
+
this.validationOutput.status = ResponseStatus.COMPLETE;
|
|
4241
|
+
this.showValidationSuccess();
|
|
4242
|
+
} else {
|
|
4243
|
+
throw new Error();
|
|
4244
|
+
}
|
|
4245
|
+
} catch (e) {
|
|
4246
|
+
this.onError(e);
|
|
4247
|
+
} finally {
|
|
4248
|
+
this.lib.loading = false;
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
mountValidationModal() {
|
|
4252
|
+
this.validationModal = new ValidationModal(this.configs.mountElement);
|
|
4253
|
+
this.validationModal.addCompleteHandler(this.forceClose.bind(this));
|
|
4254
|
+
}
|
|
4255
|
+
mountQRCodeModal() {
|
|
4256
|
+
this.QRCodeModal = new QRCodeModal(
|
|
4257
|
+
this.configs.mountElement,
|
|
4258
|
+
this.configs.applicantId,
|
|
4259
|
+
this.configs.domainApi,
|
|
4260
|
+
this.embeddedAppConnectionId,
|
|
4261
|
+
this.configs.qrCodeLinkOrigin
|
|
4262
|
+
);
|
|
4263
|
+
this.QRCodeModal.hide();
|
|
4264
|
+
this.api.longPollingRequest(
|
|
4265
|
+
`Status/${this.configs.applicantId}`,
|
|
4266
|
+
{ method: "GET" },
|
|
4267
|
+
(status) => {
|
|
4268
|
+
this.processEmbeddedAppStart(status);
|
|
4269
|
+
}
|
|
4270
|
+
);
|
|
4271
|
+
this.QRCodeModal.modalContainer.addEventListener("terminateEmbedded", () => {
|
|
4272
|
+
this.api.closeEmbeddedApplication(
|
|
4273
|
+
this.configs.applicantId,
|
|
4274
|
+
() => {
|
|
4275
|
+
this.QRCodeModal.hide();
|
|
4276
|
+
this.qrCodeBtn.disabled = true;
|
|
4277
|
+
this.api.longPollingRequest(
|
|
4278
|
+
`Status/${this.configs.applicantId}`,
|
|
4279
|
+
{ method: "GET" },
|
|
4280
|
+
(status) => {
|
|
4281
|
+
this.processEmbeddedAppStart(status);
|
|
4282
|
+
this.qrCodeBtn.disabled = false;
|
|
4283
|
+
}
|
|
4284
|
+
);
|
|
4285
|
+
}
|
|
4286
|
+
);
|
|
4287
|
+
});
|
|
4288
|
+
}
|
|
4289
|
+
processEmbeddedAppStart(status) {
|
|
4290
|
+
const getFirstStepModeState = this.configs.getFirstStepModeState();
|
|
4291
|
+
if (status === EmbeddedStatus.OPEN) {
|
|
4292
|
+
this.QRCodeModal.state = QRCodeModalState.VALIDATING;
|
|
4293
|
+
this.QRCodeModal.closable = false;
|
|
4294
|
+
this.QRCodeModal.show();
|
|
4295
|
+
this.api.longPollingRequest(
|
|
4296
|
+
`ValidationResponse/${this.configs.applicantId}/${this.embeddedAppConnectionId}`,
|
|
4297
|
+
{ method: "GET" },
|
|
4298
|
+
(data) => {
|
|
4299
|
+
this.processEmbeddedAppEnd(data);
|
|
4300
|
+
}
|
|
4301
|
+
);
|
|
4302
|
+
if (this.configs.firstStepMode) {
|
|
4303
|
+
this.configs.firstStepMode.video = false;
|
|
4304
|
+
this.configs.firstStepMode.uploader = true;
|
|
4305
|
+
}
|
|
4306
|
+
this.lib.updateDocumentTypes(this.configs.libConfig.documentTypes);
|
|
4307
|
+
} else if (status === EmbeddedStatus.CLOSED || status === EmbeddedStatus.NEVER_OPEN) {
|
|
4308
|
+
const firstStepMode = getFirstStepModeState();
|
|
4309
|
+
if (firstStepMode && this.configs.firstStepMode) {
|
|
4310
|
+
[this.configs.firstStepMode.video, this.configs.firstStepMode.uploader] = [
|
|
4311
|
+
firstStepMode.video,
|
|
4312
|
+
firstStepMode.uploader
|
|
4313
|
+
];
|
|
4314
|
+
}
|
|
4315
|
+
this.QRCodeModal.state = QRCodeModalState.READY;
|
|
4316
|
+
this.QRCodeModal.closable = true;
|
|
4317
|
+
this.api.longPollingRequest(
|
|
4318
|
+
`IsOpen/${this.configs.applicantId}`,
|
|
4319
|
+
{ method: "GET" },
|
|
4320
|
+
(isOpen) => {
|
|
4321
|
+
if (isOpen) {
|
|
4322
|
+
this.processEmbeddedAppStart(EmbeddedStatus.OPEN);
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
);
|
|
4326
|
+
} else if (status === EmbeddedStatus.CLOSED_FOREVER) {
|
|
4327
|
+
this.QRCodeModal.state = QRCodeModalState.DONE_WITH_ERROR;
|
|
4328
|
+
this.QRCodeModal.closable = false;
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
processEmbeddedAppEnd(data) {
|
|
4332
|
+
if ((data == null ? void 0 : data.status) === ResponseStatus.SUCCESS) {
|
|
4333
|
+
this.QRCodeModal.state = QRCodeModalState.DONE_WITH_SUCCESS;
|
|
4334
|
+
} else {
|
|
4335
|
+
this.api.longPollingRequest(
|
|
4336
|
+
`Status/${this.configs.applicantId}`,
|
|
4337
|
+
{ method: "GET" },
|
|
4338
|
+
(status) => {
|
|
4339
|
+
this.processEmbeddedAppStart(status);
|
|
4340
|
+
this.qrCodeBtn.disabled = false;
|
|
4341
|
+
}
|
|
4342
|
+
);
|
|
4343
|
+
}
|
|
4344
|
+
this.QRCodeModal.closable = false;
|
|
4345
|
+
this.validationOutput = data;
|
|
4346
|
+
this.configs.onValidate(this.validationOutput);
|
|
4347
|
+
}
|
|
4348
|
+
onError(e) {
|
|
4349
|
+
var _a, _b;
|
|
4350
|
+
if ((_a = this.configs) == null ? void 0 : _a.onError) {
|
|
4351
|
+
this.configs.onError(e);
|
|
4352
|
+
const buttons = {
|
|
4353
|
+
tryAgain: false,
|
|
4354
|
+
complete: false
|
|
4355
|
+
};
|
|
4356
|
+
this.validationModal.type = ValidationStatus.DANGER;
|
|
4357
|
+
this.validationModal.header = e.header || "Something Went Wrong";
|
|
4358
|
+
this.validationModal.content = e.content || "Try again later";
|
|
4359
|
+
if (["HttpError", "ValidationError", "FaceAuthorizationError"].includes(e.name)) {
|
|
4360
|
+
buttons.tryAgain = true;
|
|
4361
|
+
}
|
|
4362
|
+
this.validationModal.buttons = buttons;
|
|
4363
|
+
this.validationModal.showSpinner(false);
|
|
4364
|
+
if (this.form) {
|
|
4365
|
+
this.form.form.remove();
|
|
4366
|
+
}
|
|
4367
|
+
(_b = document.getElementById(this.configs.mountElement)) == null ? void 0 : _b.classList.remove("hidden-element");
|
|
4368
|
+
this.validationModal.show();
|
|
4369
|
+
}
|
|
4370
|
+
return e;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
export {
|
|
4374
|
+
Wrapper as default
|
|
4375
|
+
};
|
|
4376
|
+
//# sourceMappingURL=wrapper.es.js.map
|