smartcomply-web-sdk 1.0.99 → 1.0.100
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/client/Smartcomply.d.ts +1 -1
- package/dist/client/Smartcomply.d.ts.map +1 -1
- package/dist/client/Smartcomply.js +1 -1
- package/dist/client/Smartcomply.js.map +1 -1
- package/dist/esm/client/Smartcomply.d.ts +1 -1
- package/dist/esm/client/Smartcomply.d.ts.map +1 -1
- package/dist/esm/client/Smartcomply.js +1 -1
- package/dist/esm/client/Smartcomply.js.map +1 -1
- package/dist/esm/flow/DocumentCapture.d.ts +3 -19
- package/dist/esm/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/esm/flow/DocumentCapture.js +22 -170
- package/dist/esm/flow/DocumentCapture.js.map +1 -1
- package/dist/esm/flow/SmartComplyFlow.d.ts.map +1 -1
- package/dist/esm/flow/SmartComplyFlow.js +8 -32
- package/dist/esm/flow/SmartComplyFlow.js.map +1 -1
- package/dist/esm/utils/constants.d.ts +9 -8
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +10 -9
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/documentRules.d.ts +1 -2
- package/dist/esm/utils/documentRules.d.ts.map +1 -1
- package/dist/esm/utils/documentRules.js +1 -2
- package/dist/esm/utils/documentRules.js.map +1 -1
- package/dist/flow/DocumentCapture.d.ts +3 -19
- package/dist/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/flow/DocumentCapture.js +22 -170
- package/dist/flow/DocumentCapture.js.map +1 -1
- package/dist/flow/SmartComplyFlow.d.ts.map +1 -1
- package/dist/flow/SmartComplyFlow.js +7 -31
- package/dist/flow/SmartComplyFlow.js.map +1 -1
- package/dist/smartcomply.browser.js +22 -181
- package/dist/smartcomply.browser.js.map +3 -3
- package/dist/utils/constants.d.ts +9 -8
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +10 -9
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/documentRules.d.ts +1 -2
- package/dist/utils/documentRules.d.ts.map +1 -1
- package/dist/utils/documentRules.js +1 -2
- package/dist/utils/documentRules.js.map +1 -1
- package/package.json +1 -1
|
@@ -293,7 +293,7 @@ var SmartComplySDK = (() => {
|
|
|
293
293
|
var SESSION_WARN_BEFORE_MS = 2 * 60 * 1e3;
|
|
294
294
|
var MAX_RETRIES = 2;
|
|
295
295
|
var RETRY_DELAY_MS = 1e3;
|
|
296
|
-
var MAX_DOCUMENT_BYTES =
|
|
296
|
+
var MAX_DOCUMENT_BYTES = 10 * 1024 * 1024;
|
|
297
297
|
var MAX_VIDEO_BYTES = 50 * 1024 * 1024;
|
|
298
298
|
var MAX_SNAPSHOT_BYTES = 2 * 1024 * 1024;
|
|
299
299
|
var DEFAULT_CHALLENGE_ACTIONS = ["BLINK", "TURN_HEAD"];
|
|
@@ -5886,7 +5886,7 @@ var SmartComplySDK = (() => {
|
|
|
5886
5886
|
* CDN tag they installed with (e.g. @1, which floats to the latest
|
|
5887
5887
|
* matching release) actually resolved to the version they expect.
|
|
5888
5888
|
*/
|
|
5889
|
-
_SmartComply.VERSION = "1.0.
|
|
5889
|
+
_SmartComply.VERSION = "1.0.100";
|
|
5890
5890
|
var SmartComply = _SmartComply;
|
|
5891
5891
|
|
|
5892
5892
|
// src/flow/theme.ts
|
|
@@ -6566,7 +6566,7 @@ var SmartComplySDK = (() => {
|
|
|
6566
6566
|
this.showPdfPreview(container, theme, file, documentType);
|
|
6567
6567
|
return;
|
|
6568
6568
|
}
|
|
6569
|
-
this.
|
|
6569
|
+
this.handleFileUploadComplete(file, container, theme, documentType);
|
|
6570
6570
|
}
|
|
6571
6571
|
});
|
|
6572
6572
|
this.root.appendChild(fileInput);
|
|
@@ -6980,7 +6980,14 @@ var SmartComplySDK = (() => {
|
|
|
6980
6980
|
useBtn.textContent = "Confirming photo…";
|
|
6981
6981
|
useBtn.disabled = true;
|
|
6982
6982
|
rotateBtn.disabled = true;
|
|
6983
|
-
|
|
6983
|
+
if (currentBlob.size > MAX_DOCUMENT_BYTES) {
|
|
6984
|
+
useBtn.textContent = "Use Photo ✓";
|
|
6985
|
+
useBtn.disabled = false;
|
|
6986
|
+
rotateBtn.disabled = false;
|
|
6987
|
+
this.showError(this.tooLargeMessage());
|
|
6988
|
+
return;
|
|
6989
|
+
}
|
|
6990
|
+
this.handleCaptureComplete(currentBlob, container, theme, documentType, viaCamera);
|
|
6984
6991
|
});
|
|
6985
6992
|
btnRow.appendChild(retakeBtn);
|
|
6986
6993
|
btnRow.appendChild(useBtn);
|
|
@@ -7063,9 +7070,8 @@ var SmartComplySDK = (() => {
|
|
|
7063
7070
|
/**
|
|
7064
7071
|
* Rotate an image blob by a multiple of 90° and re-encode it — used by the
|
|
7065
7072
|
* preview screen's rotate control for a document photographed or uploaded
|
|
7066
|
-
* sideways/upside-down.
|
|
7067
|
-
*
|
|
7068
|
-
* document whose actual pixel content is sideways (e.g. the phone itself
|
|
7073
|
+
* sideways/upside-down. Orientation metadata can't help a document
|
|
7074
|
+
* whose actual pixel content is sideways (e.g. the phone itself
|
|
7069
7075
|
* was held rotated relative to the document, or a pre-cropped/scanned
|
|
7070
7076
|
* upload with no EXIF at all) — that needs the user to say so directly.
|
|
7071
7077
|
*/
|
|
@@ -7199,29 +7205,15 @@ var SmartComplySDK = (() => {
|
|
|
7199
7205
|
return "Invalid file type. Please upload a JPEG or PNG photo, or a PDF.";
|
|
7200
7206
|
}
|
|
7201
7207
|
if (file.size > MAX_DOCUMENT_BYTES) {
|
|
7202
|
-
return
|
|
7208
|
+
return this.tooLargeMessage();
|
|
7203
7209
|
}
|
|
7204
7210
|
if (file.size < 1024) {
|
|
7205
7211
|
return "File is too small. Please upload a valid photo or PDF.";
|
|
7206
7212
|
}
|
|
7207
7213
|
return null;
|
|
7208
7214
|
}
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
* ceiling — otherwise returns the original bytes completely untouched.
|
|
7212
|
-
* Document photos become the face-comparison reference image later
|
|
7213
|
-
* (see backend _crop_and_save_face), so any avoidable re-encode is a
|
|
7214
|
-
* quality loss with no upside; compression here exists solely to keep
|
|
7215
|
-
* oversized captures under MAX_DOCUMENT_BYTES, not to "optimize" images
|
|
7216
|
-
* that already fit.
|
|
7217
|
-
*/
|
|
7218
|
-
async ensureUnderUploadLimit(source) {
|
|
7219
|
-
if (source.size <= MAX_DOCUMENT_BYTES) return source;
|
|
7220
|
-
try {
|
|
7221
|
-
return await this.compressImage(source, DOC_CAMERA_IDEAL_WIDTH, DOC_CAMERA_IDEAL_HEIGHT, 0.92);
|
|
7222
|
-
} catch {
|
|
7223
|
-
return source;
|
|
7224
|
-
}
|
|
7215
|
+
tooLargeMessage() {
|
|
7216
|
+
return `File is too large. Please upload a file smaller than ${Math.round(MAX_DOCUMENT_BYTES / (1024 * 1024))}MB.`;
|
|
7225
7217
|
}
|
|
7226
7218
|
handleFileUpload(container, theme) {
|
|
7227
7219
|
const input = this.root?.querySelector("#sc-doc-file-input");
|
|
@@ -7299,141 +7291,6 @@ var SmartComplySDK = (() => {
|
|
|
7299
7291
|
});
|
|
7300
7292
|
return btn;
|
|
7301
7293
|
}
|
|
7302
|
-
compressImage(source, maxWidth, maxHeight, quality) {
|
|
7303
|
-
return new Promise((resolve, reject) => {
|
|
7304
|
-
this._readExifOrientation(source).then((orientation) => {
|
|
7305
|
-
const url = URL.createObjectURL(source);
|
|
7306
|
-
const imgEl = document.createElement("img");
|
|
7307
|
-
imgEl.onload = () => {
|
|
7308
|
-
URL.revokeObjectURL(url);
|
|
7309
|
-
let { naturalWidth: w2, naturalHeight: h2 } = imgEl;
|
|
7310
|
-
const swapped = orientation >= 5 && orientation <= 8;
|
|
7311
|
-
const srcW = swapped ? h2 : w2;
|
|
7312
|
-
const srcH = swapped ? w2 : h2;
|
|
7313
|
-
const ratio = computeScaleRatio(srcW, srcH, maxWidth, maxHeight);
|
|
7314
|
-
const outW = Math.round(srcW * ratio);
|
|
7315
|
-
const outH = Math.round(srcH * ratio);
|
|
7316
|
-
const canvas = document.createElement("canvas");
|
|
7317
|
-
canvas.width = outW;
|
|
7318
|
-
canvas.height = outH;
|
|
7319
|
-
const ctx = canvas.getContext("2d");
|
|
7320
|
-
if (!ctx) {
|
|
7321
|
-
reject(new Error("Canvas unavailable"));
|
|
7322
|
-
return;
|
|
7323
|
-
}
|
|
7324
|
-
ctx.save();
|
|
7325
|
-
if (orientation === 2) {
|
|
7326
|
-
ctx.transform(-1, 0, 0, 1, outW, 0);
|
|
7327
|
-
} else if (orientation === 3) {
|
|
7328
|
-
ctx.transform(-1, 0, 0, -1, outW, outH);
|
|
7329
|
-
} else if (orientation === 4) {
|
|
7330
|
-
ctx.transform(1, 0, 0, -1, 0, outH);
|
|
7331
|
-
} else if (orientation === 5) {
|
|
7332
|
-
ctx.transform(0, 1, 1, 0, 0, 0);
|
|
7333
|
-
} else if (orientation === 6) {
|
|
7334
|
-
ctx.transform(0, 1, -1, 0, outH, 0);
|
|
7335
|
-
} else if (orientation === 7) {
|
|
7336
|
-
ctx.transform(0, -1, -1, 0, outH, outW);
|
|
7337
|
-
} else if (orientation === 8) {
|
|
7338
|
-
ctx.transform(0, -1, 1, 0, 0, outW);
|
|
7339
|
-
}
|
|
7340
|
-
ctx.drawImage(imgEl, 0, 0, swapped ? outH : outW, swapped ? outW : outH);
|
|
7341
|
-
ctx.restore();
|
|
7342
|
-
canvas.toBlob(
|
|
7343
|
-
(blob) => {
|
|
7344
|
-
blob ? resolve(blob) : reject(new Error("Compression failed"));
|
|
7345
|
-
},
|
|
7346
|
-
"image/jpeg",
|
|
7347
|
-
quality
|
|
7348
|
-
);
|
|
7349
|
-
};
|
|
7350
|
-
imgEl.onerror = () => {
|
|
7351
|
-
URL.revokeObjectURL(url);
|
|
7352
|
-
reject(new Error("Image load failed"));
|
|
7353
|
-
};
|
|
7354
|
-
imgEl.src = url;
|
|
7355
|
-
}).catch(() => {
|
|
7356
|
-
const url = URL.createObjectURL(source);
|
|
7357
|
-
const imgEl = document.createElement("img");
|
|
7358
|
-
imgEl.onload = () => {
|
|
7359
|
-
URL.revokeObjectURL(url);
|
|
7360
|
-
let { naturalWidth: w2, naturalHeight: h2 } = imgEl;
|
|
7361
|
-
const ratio = computeScaleRatio(w2, h2, maxWidth, maxHeight);
|
|
7362
|
-
const canvas = document.createElement("canvas");
|
|
7363
|
-
canvas.width = Math.round(w2 * ratio);
|
|
7364
|
-
canvas.height = Math.round(h2 * ratio);
|
|
7365
|
-
const ctx = canvas.getContext("2d");
|
|
7366
|
-
if (!ctx) {
|
|
7367
|
-
reject(new Error("Canvas unavailable"));
|
|
7368
|
-
return;
|
|
7369
|
-
}
|
|
7370
|
-
ctx.drawImage(imgEl, 0, 0, canvas.width, canvas.height);
|
|
7371
|
-
canvas.toBlob(
|
|
7372
|
-
(blob) => {
|
|
7373
|
-
blob ? resolve(blob) : reject(new Error("Compression failed"));
|
|
7374
|
-
},
|
|
7375
|
-
"image/jpeg",
|
|
7376
|
-
quality
|
|
7377
|
-
);
|
|
7378
|
-
};
|
|
7379
|
-
imgEl.onerror = () => {
|
|
7380
|
-
URL.revokeObjectURL(url);
|
|
7381
|
-
reject(new Error("Image load failed"));
|
|
7382
|
-
};
|
|
7383
|
-
imgEl.src = url;
|
|
7384
|
-
});
|
|
7385
|
-
});
|
|
7386
|
-
}
|
|
7387
|
-
/**
|
|
7388
|
-
* Read JPEG EXIF orientation tag (1–8) from a Blob/File.
|
|
7389
|
-
* Returns 1 (no rotation) if EXIF is absent or unreadable.
|
|
7390
|
-
*/
|
|
7391
|
-
_readExifOrientation(source) {
|
|
7392
|
-
return new Promise((resolve) => {
|
|
7393
|
-
const reader = new FileReader();
|
|
7394
|
-
reader.onload = (e2) => {
|
|
7395
|
-
try {
|
|
7396
|
-
const buf = e2.target?.result;
|
|
7397
|
-
const view = new DataView(buf);
|
|
7398
|
-
if (view.getUint16(0, false) !== 65496) {
|
|
7399
|
-
resolve(1);
|
|
7400
|
-
return;
|
|
7401
|
-
}
|
|
7402
|
-
let offset = 2;
|
|
7403
|
-
while (offset < view.byteLength) {
|
|
7404
|
-
const marker = view.getUint16(offset, false);
|
|
7405
|
-
offset += 2;
|
|
7406
|
-
if (marker === 65505) {
|
|
7407
|
-
if (view.getUint32(offset + 2, false) !== 1165519206) {
|
|
7408
|
-
resolve(1);
|
|
7409
|
-
return;
|
|
7410
|
-
}
|
|
7411
|
-
const little = view.getUint16(offset + 8, false) === 18761;
|
|
7412
|
-
const ifdOff = offset + 8 + view.getUint32(offset + 12, little);
|
|
7413
|
-
const tags = view.getUint16(ifdOff, little);
|
|
7414
|
-
for (let i2 = 0; i2 < tags; i2++) {
|
|
7415
|
-
if (view.getUint16(ifdOff + 2 + 12 * i2, little) === 274) {
|
|
7416
|
-
resolve(view.getUint16(ifdOff + 2 + 12 * i2 + 8, little));
|
|
7417
|
-
return;
|
|
7418
|
-
}
|
|
7419
|
-
}
|
|
7420
|
-
resolve(1);
|
|
7421
|
-
return;
|
|
7422
|
-
} else if ((marker & 65280) !== 65280) {
|
|
7423
|
-
break;
|
|
7424
|
-
} else {
|
|
7425
|
-
offset += view.getUint16(offset, false);
|
|
7426
|
-
}
|
|
7427
|
-
}
|
|
7428
|
-
resolve(1);
|
|
7429
|
-
} catch {
|
|
7430
|
-
resolve(1);
|
|
7431
|
-
}
|
|
7432
|
-
};
|
|
7433
|
-
reader.onerror = () => resolve(1);
|
|
7434
|
-
reader.readAsArrayBuffer(source.slice(0, 65536));
|
|
7435
|
-
});
|
|
7436
|
-
}
|
|
7437
7294
|
getDocumentLabel(type) {
|
|
7438
7295
|
const t2 = type.toLowerCase();
|
|
7439
7296
|
if (t2.includes("passport")) return "passport";
|
|
@@ -7618,24 +7475,6 @@ var SmartComplySDK = (() => {
|
|
|
7618
7475
|
const d2 = new Date(s2);
|
|
7619
7476
|
return isNaN(d2.getTime()) ? null : d2;
|
|
7620
7477
|
}
|
|
7621
|
-
async function _compressImage(blob, maxWidth = 1600, quality = 0.85) {
|
|
7622
|
-
try {
|
|
7623
|
-
const bmp = await createImageBitmap(blob);
|
|
7624
|
-
const scale = Math.min(1, maxWidth / bmp.width);
|
|
7625
|
-
const w2 = Math.round(bmp.width * scale);
|
|
7626
|
-
const h2 = Math.round(bmp.height * scale);
|
|
7627
|
-
const canvas = document.createElement("canvas");
|
|
7628
|
-
canvas.width = w2;
|
|
7629
|
-
canvas.height = h2;
|
|
7630
|
-
canvas.getContext("2d").drawImage(bmp, 0, 0, w2, h2);
|
|
7631
|
-
bmp.close();
|
|
7632
|
-
return await new Promise(
|
|
7633
|
-
(res, rej) => canvas.toBlob((b2) => b2 ? res(b2) : rej(new Error("Compression failed")), "image/jpeg", quality)
|
|
7634
|
-
);
|
|
7635
|
-
} catch {
|
|
7636
|
-
return blob;
|
|
7637
|
-
}
|
|
7638
|
-
}
|
|
7639
7478
|
function _formatDocType(code) {
|
|
7640
7479
|
const map = {
|
|
7641
7480
|
passport: "Passport",
|
|
@@ -9148,8 +8987,8 @@ var SmartComplySDK = (() => {
|
|
|
9148
8987
|
* Process document capture result with front/back support
|
|
9149
8988
|
*/
|
|
9150
8989
|
async processDocumentCaptureResult(result, captureContainer, container) {
|
|
9151
|
-
this.documentBlob =
|
|
9152
|
-
this.documentBackBlob =
|
|
8990
|
+
this.documentBlob = result.front;
|
|
8991
|
+
this.documentBackBlob = result.back || null;
|
|
9153
8992
|
this._documentViaCamera = result.viaCamera;
|
|
9154
8993
|
await this.processDocumentBlob(this.documentBlob, captureContainer, container);
|
|
9155
8994
|
}
|
|
@@ -9164,8 +9003,10 @@ var SmartComplySDK = (() => {
|
|
|
9164
9003
|
if (!blob || blob.size === 0) {
|
|
9165
9004
|
throw new Error("Failed to capture document. Please try again.");
|
|
9166
9005
|
}
|
|
9167
|
-
if (blob.size >
|
|
9168
|
-
throw new Error(
|
|
9006
|
+
if (blob.size > MAX_DOCUMENT_BYTES) {
|
|
9007
|
+
throw new Error(
|
|
9008
|
+
`Document is too large. Please use a file smaller than ${Math.round(MAX_DOCUMENT_BYTES / (1024 * 1024))}MB.`
|
|
9009
|
+
);
|
|
9169
9010
|
}
|
|
9170
9011
|
this.documentBlob = blob;
|
|
9171
9012
|
captureContainer.innerHTML = "";
|