smartcomply-web-sdk 1.0.65 → 1.0.66
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/esm/flow/DocumentCapture.d.ts +6 -1
- package/dist/esm/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/esm/flow/DocumentCapture.js +34 -6
- 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 +16 -4
- package/dist/esm/flow/SmartComplyFlow.js.map +1 -1
- package/dist/esm/utils/documentRules.d.ts +9 -2
- package/dist/esm/utils/documentRules.d.ts.map +1 -1
- package/dist/esm/utils/documentRules.js +7 -2
- package/dist/esm/utils/documentRules.js.map +1 -1
- package/dist/flow/DocumentCapture.d.ts +6 -1
- package/dist/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/flow/DocumentCapture.js +34 -6
- package/dist/flow/DocumentCapture.js.map +1 -1
- package/dist/flow/SmartComplyFlow.d.ts.map +1 -1
- package/dist/flow/SmartComplyFlow.js +16 -4
- package/dist/flow/SmartComplyFlow.js.map +1 -1
- package/dist/smartcomply.browser.js +37 -7
- package/dist/smartcomply.browser.js.map +2 -2
- package/dist/utils/documentRules.d.ts +9 -2
- package/dist/utils/documentRules.d.ts.map +1 -1
- package/dist/utils/documentRules.js +7 -2
- package/dist/utils/documentRules.js.map +1 -1
- package/package.json +1 -1
|
@@ -5848,6 +5848,9 @@ var SmartComplySDK = (() => {
|
|
|
5848
5848
|
// src/utils/documentRules.ts
|
|
5849
5849
|
function requiresBackSide(documentType) {
|
|
5850
5850
|
const type = documentType.toLowerCase();
|
|
5851
|
+
if (type.includes("nin")) {
|
|
5852
|
+
return "optional";
|
|
5853
|
+
}
|
|
5851
5854
|
return type.includes("voter") || type.includes("driver") || type.includes("license") || type.includes("national id") || type.includes("national id card") || type.includes("ghana");
|
|
5852
5855
|
}
|
|
5853
5856
|
function computeScaleRatio(srcWidth, srcHeight, maxWidth, maxHeight) {
|
|
@@ -5990,9 +5993,17 @@ var SmartComplySDK = (() => {
|
|
|
5990
5993
|
this.backBlob = null;
|
|
5991
5994
|
this.currentSide = "front";
|
|
5992
5995
|
}
|
|
5993
|
-
|
|
5996
|
+
getBackSideMode(documentType) {
|
|
5994
5997
|
return this.requiresBackOverride !== void 0 ? this.requiresBackOverride : requiresBackSide(documentType);
|
|
5995
5998
|
}
|
|
5999
|
+
/** Whether a back-side step should be shown at all (required OR optional). */
|
|
6000
|
+
shouldCaptureBackSide(documentType) {
|
|
6001
|
+
return this.getBackSideMode(documentType) !== false;
|
|
6002
|
+
}
|
|
6003
|
+
/** Whether the back-side step, once shown, can be skipped by the user. */
|
|
6004
|
+
isBackSideOptional(documentType) {
|
|
6005
|
+
return this.getBackSideMode(documentType) === "optional";
|
|
6006
|
+
}
|
|
5996
6007
|
renderChoiceScreen(container, theme, documentType) {
|
|
5997
6008
|
this.root = document.createElement("div");
|
|
5998
6009
|
this.root.style.cssText = `
|
|
@@ -6001,6 +6012,7 @@ var SmartComplySDK = (() => {
|
|
|
6001
6012
|
`;
|
|
6002
6013
|
const docLabel = this.getDocumentLabel(documentType);
|
|
6003
6014
|
const requiresBack = this.shouldCaptureBackSide(documentType);
|
|
6015
|
+
const backOptional = this.isBackSideOptional(documentType);
|
|
6004
6016
|
const isCapturingFront = this.currentSide === "front";
|
|
6005
6017
|
const sideLabel = requiresBack ? isCapturingFront ? " — Front side" : " — Back side" : "";
|
|
6006
6018
|
const headerRow = document.createElement("div");
|
|
@@ -6023,7 +6035,7 @@ var SmartComplySDK = (() => {
|
|
|
6023
6035
|
titleEl.textContent = `Capture your ${docLabel}`;
|
|
6024
6036
|
const subEl = document.createElement("div");
|
|
6025
6037
|
subEl.style.cssText = `color:${theme.textSecondary};font-size:12px;margin-top:2px;`;
|
|
6026
|
-
subEl.textContent = requiresBack ? isCapturingFront ? "Step 1 of 2 — front side" : "Step 2 of 2 — back side" : "Choose how to provide your document";
|
|
6038
|
+
subEl.textContent = requiresBack ? isCapturingFront ? "Step 1 of 2 — front side" : backOptional ? "Step 2 of 2 — back side (optional)" : "Step 2 of 2 — back side" : "Choose how to provide your document";
|
|
6027
6039
|
titleBlock.appendChild(titleEl);
|
|
6028
6040
|
titleBlock.appendChild(subEl);
|
|
6029
6041
|
headerRow.appendChild(iconBox);
|
|
@@ -6114,9 +6126,23 @@ var SmartComplySDK = (() => {
|
|
|
6114
6126
|
display:flex;align-items:center;gap:8px;
|
|
6115
6127
|
font-size:12px;color:${theme.textSecondary};line-height:1.5;
|
|
6116
6128
|
`;
|
|
6117
|
-
notice.innerHTML = `<span style="font-size:16px;flex-shrink:0;">ℹ️</span><span>You'll capture both the <strong style="color:${theme.text}">front</strong> and <strong style="color:${theme.text}">back</strong> of this document.</span>`;
|
|
6129
|
+
notice.innerHTML = backOptional ? `<span style="font-size:16px;flex-shrink:0;">ℹ️</span><span>After the <strong style="color:${theme.text}">front</strong>, you can optionally add the <strong style="color:${theme.text}">back</strong> if your card has one.</span>` : `<span style="font-size:16px;flex-shrink:0;">ℹ️</span><span>You'll capture both the <strong style="color:${theme.text}">front</strong> and <strong style="color:${theme.text}">back</strong> of this document.</span>`;
|
|
6118
6130
|
this.root.appendChild(notice);
|
|
6119
6131
|
}
|
|
6132
|
+
if (requiresBack && !isCapturingFront && backOptional) {
|
|
6133
|
+
const skipBtn = document.createElement("button");
|
|
6134
|
+
skipBtn.style.cssText = `
|
|
6135
|
+
display:block;margin:0 20px 16px;width:calc(100% - 40px);
|
|
6136
|
+
padding:10px 12px;background:transparent;color:${theme.textSecondary};
|
|
6137
|
+
border:1.5px dashed ${theme.border};border-radius:10px;cursor:pointer;
|
|
6138
|
+
font-size:12.5px;font-weight:600;font-family:inherit;
|
|
6139
|
+
`;
|
|
6140
|
+
skipBtn.textContent = "Skip — this card has no back side";
|
|
6141
|
+
skipBtn.addEventListener("click", () => {
|
|
6142
|
+
this.handleCaptureComplete(null, container, theme, documentType, false, true);
|
|
6143
|
+
});
|
|
6144
|
+
this.root.appendChild(skipBtn);
|
|
6145
|
+
}
|
|
6120
6146
|
const fileInput = document.createElement("input");
|
|
6121
6147
|
fileInput.type = "file";
|
|
6122
6148
|
fileInput.accept = "image/jpeg,image/png";
|
|
@@ -6399,13 +6425,13 @@ var SmartComplySDK = (() => {
|
|
|
6399
6425
|
btnRow.appendChild(useBtn);
|
|
6400
6426
|
this.root.appendChild(btnRow);
|
|
6401
6427
|
}
|
|
6402
|
-
handleCaptureComplete(imageData, container, theme, documentType, viaCamera) {
|
|
6428
|
+
handleCaptureComplete(imageData, container, theme, documentType, viaCamera, skipped = false) {
|
|
6403
6429
|
const requiresBack = this.shouldCaptureBackSide(documentType);
|
|
6404
6430
|
const wasCapturingFront = this.currentSide === "front";
|
|
6405
6431
|
if (wasCapturingFront) {
|
|
6406
6432
|
this.frontBlob = imageData;
|
|
6407
6433
|
this.frontViaCamera = viaCamera;
|
|
6408
|
-
} else {
|
|
6434
|
+
} else if (!skipped) {
|
|
6409
6435
|
this.backBlob = imageData;
|
|
6410
6436
|
}
|
|
6411
6437
|
if (requiresBack && wasCapturingFront) {
|
|
@@ -6694,7 +6720,11 @@ var SmartComplySDK = (() => {
|
|
|
6694
6720
|
return { icon: "🏦", desc: "Enter your 11-digit Bank Verification Number (BVN)", requiresBack: false };
|
|
6695
6721
|
}
|
|
6696
6722
|
if (u2.includes("NIN") || u2.includes("NATIONAL IDENTITY NUMBER")) {
|
|
6697
|
-
return {
|
|
6723
|
+
return {
|
|
6724
|
+
icon: "🆔",
|
|
6725
|
+
desc: isDocumentFlow ? "Capture or upload your NIN card (back optional)" : "Enter your 11-digit National Identification Number (NIN)",
|
|
6726
|
+
requiresBack: isDocumentFlow ? "optional" : false
|
|
6727
|
+
};
|
|
6698
6728
|
}
|
|
6699
6729
|
if (u2.includes("GHANA")) {
|
|
6700
6730
|
if (isDocumentFlow) return { icon: "🪪", desc: "Capture or upload your Ghana Card", requiresBack: requiresBackSide(typeName) };
|
|
@@ -7349,7 +7379,7 @@ var SmartComplySDK = (() => {
|
|
|
7349
7379
|
const requiresBackFromBackend = typeof idType !== "string" ? idType.requires_back_side : void 0;
|
|
7350
7380
|
const requiresBack = requiresBackFromBackend ?? info.requiresBack;
|
|
7351
7381
|
let subtitle2 = info.desc;
|
|
7352
|
-
if (requiresBack && isThisDocFlow) {
|
|
7382
|
+
if (requiresBack === true && isThisDocFlow) {
|
|
7353
7383
|
subtitle2 += " ⚠️ Both sides required";
|
|
7354
7384
|
}
|
|
7355
7385
|
const displayName = typeName.replace(/\s*with\s+face\s*/gi, " ").replace(/\s*\(NIN\)\s*/gi, " ").replace(/\s*\(BVN\)\s*/gi, " ").replace(/\s{2,}/g, " ").trim();
|