smartcomply-web-sdk 1.0.94 → 1.0.96
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 +6 -2
- 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 +6 -2
- package/dist/esm/client/Smartcomply.js.map +1 -1
- package/dist/esm/flow/SmartComplyFlow.d.ts +18 -1
- package/dist/esm/flow/SmartComplyFlow.d.ts.map +1 -1
- package/dist/esm/flow/SmartComplyFlow.js +38 -12
- package/dist/esm/flow/SmartComplyFlow.js.map +1 -1
- package/dist/esm/types/onboarding.d.ts +5 -1
- package/dist/esm/types/onboarding.d.ts.map +1 -1
- package/dist/esm/utils/channels.d.ts +16 -0
- package/dist/esm/utils/channels.d.ts.map +1 -0
- package/dist/esm/utils/channels.js +48 -0
- package/dist/esm/utils/channels.js.map +1 -0
- package/dist/flow/SmartComplyFlow.d.ts +18 -1
- package/dist/flow/SmartComplyFlow.d.ts.map +1 -1
- package/dist/flow/SmartComplyFlow.js +42 -15
- package/dist/flow/SmartComplyFlow.js.map +1 -1
- package/dist/smartcomply.browser.js +43 -9
- package/dist/smartcomply.browser.js.map +4 -4
- package/dist/types/onboarding.d.ts +5 -1
- package/dist/types/onboarding.d.ts.map +1 -1
- package/dist/utils/channels.d.ts +16 -0
- package/dist/utils/channels.d.ts.map +1 -0
- package/dist/utils/channels.js +52 -0
- package/dist/utils/channels.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SDKChannel, VerifyIdentityResponse } from "../types/onboarding";
|
|
1
|
+
import { SDKChannel, ChannelsByCategory, VerifyIdentityResponse } from "../types/onboarding";
|
|
2
2
|
import { Environment } from "../client/Config";
|
|
3
3
|
import { BackSideMode } from "../utils/documentRules";
|
|
4
4
|
export interface FlowOptions {
|
|
@@ -58,6 +58,23 @@ export interface FlowResult {
|
|
|
58
58
|
* so that's the only case the global flow mode is still used for.
|
|
59
59
|
*/
|
|
60
60
|
export declare function isChannelDocumentFlow(idType: string | SDKChannel, globalDocFlow: boolean): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Picks the channel list for the "Select document type" / "Select ID type"
|
|
63
|
+
* screen — the one list that actually matches this screen's mode, not a
|
|
64
|
+
* flat list mixing both categories.
|
|
65
|
+
*
|
|
66
|
+
* Reported live: the deployed widget's document-scan screen showed a bare
|
|
67
|
+
* "Passport" (data_verification, number-entry) right next to "Document
|
|
68
|
+
* Verification - Passport" (document_verification, scan) as if they were
|
|
69
|
+
* the same kind of option — because channels[country] used to be one flat
|
|
70
|
+
* list with no category split at all. Splitting the backend response
|
|
71
|
+
* (SDKSecureLoaderView, adhere-backend) into {data_verification,
|
|
72
|
+
* document_verification} only helps if this screen then reads the ONE
|
|
73
|
+
* list matching globalDocFlow, instead of still flattening both — that's
|
|
74
|
+
* what actually removes the duplicate, not just how each entry displays
|
|
75
|
+
* (see isChannelDocumentFlow above, which only decides that).
|
|
76
|
+
*/
|
|
77
|
+
export declare function selectIdTypesForScreen(byCategory: ChannelsByCategory | undefined, globalDocFlow: boolean): (string | SDKChannel)[];
|
|
61
78
|
/**
|
|
62
79
|
* Whether a showErrorStep() message is about an expired/invalid resume or
|
|
63
80
|
* resubmit link (RESUME_TARGET_UNAVAILABLE / NOT_A_RESUME_TOKEN — see
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartComplyFlow.d.ts","sourceRoot":"","sources":["../../src/flow/SmartComplyFlow.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,UAAU,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SmartComplyFlow.d.ts","sourceRoot":"","sources":["../../src/flow/Sm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kBAAkB;IAmF1B,OAAO,CAAC,aAAa;IAuWrB,OAAO,CAAC,qBAAqB;IAqD7B,OAAO,CAAC,qBAAqB;IA+E7B,OAAO,CAAC,qBAAqB;IAuI7B,OAAO,CAAC,aAAa;IA6HrB,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,qBAAqB;IA0C7B;;;;;;;;OAQG;IACH,OAAO,CAAC,iCAAiC;IA6BzC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,UAAU;IA+ClB,OAAO,CAAC,wBAAwB;IAqBhC,OAAO,CAAC,cAAc;IAUtB;;OAEG;YACW,4BAA4B;IAiB1C;;OAEG;YACW,mBAAmB;IA4HjC,OAAO,CAAC,6BAA6B;IA8DrC,OAAO,CAAC,cAAc;IA4HtB,OAAO,CAAC,aAAa;IAiHrB,OAAO,CAAC,YAAY;IAqHpB,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,gBAAgB;IAmDxB,OAAO,CAAC,mBAAmB;IAsB3B,OAAO,CAAC,qBAAqB;IAmB7B,sGAAsG;IACtG,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,cAAc;IAsBtB;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,cAAc;IAmFtB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,YAAY;CAiCrB"}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SmartComplyFlow = void 0;
|
|
4
4
|
exports.isChannelDocumentFlow = isChannelDocumentFlow;
|
|
5
|
+
exports.selectIdTypesForScreen = selectIdTypesForScreen;
|
|
5
6
|
exports.isResumeLinkErrorMessage = isResumeLinkErrorMessage;
|
|
6
7
|
exports.resolveIdTypeInfo = resolveIdTypeInfo;
|
|
7
8
|
const Smartcomply_1 = require("../client/Smartcomply");
|
|
8
9
|
const theme_1 = require("./theme");
|
|
9
10
|
const DocumentCapture_1 = require("./DocumentCapture");
|
|
11
|
+
const channels_1 = require("../utils/channels");
|
|
10
12
|
const device_1 = require("../utils/device");
|
|
11
13
|
const documentRules_1 = require("../utils/documentRules");
|
|
12
14
|
const constants_1 = require("../utils/constants");
|
|
@@ -66,13 +68,6 @@ const COUNTRY_LABELS = {
|
|
|
66
68
|
united_states: "🇺🇸 United States",
|
|
67
69
|
united_kingdom: "🇬🇧 United Kingdom",
|
|
68
70
|
};
|
|
69
|
-
// Backend/admin data tags document-capture fields inconsistently — the field
|
|
70
|
-
// renderer (below) already treats "image" and "file" as file inputs alongside
|
|
71
|
-
// "upload", so flow-routing decisions must recognize the same set or a channel
|
|
72
|
-
// tagged "image"/"file" silently falls back to the number-entry screen.
|
|
73
|
-
function isUploadFieldType(type) {
|
|
74
|
-
return type === "upload" || type === "image" || type === "file";
|
|
75
|
-
}
|
|
76
71
|
/**
|
|
77
72
|
* Whether a SPECIFIC channel is a document-scan item, vs. a plain
|
|
78
73
|
* number-entry one. channels[country] is a flat list that can mix
|
|
@@ -93,7 +88,28 @@ function isUploadFieldType(type) {
|
|
|
93
88
|
function isChannelDocumentFlow(idType, globalDocFlow) {
|
|
94
89
|
if (typeof idType === "string")
|
|
95
90
|
return globalDocFlow;
|
|
96
|
-
return (idType.fields || []).some((f) => isUploadFieldType(f.type));
|
|
91
|
+
return (idType.fields || []).some((f) => (0, channels_1.isUploadFieldType)(f.type));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Picks the channel list for the "Select document type" / "Select ID type"
|
|
95
|
+
* screen — the one list that actually matches this screen's mode, not a
|
|
96
|
+
* flat list mixing both categories.
|
|
97
|
+
*
|
|
98
|
+
* Reported live: the deployed widget's document-scan screen showed a bare
|
|
99
|
+
* "Passport" (data_verification, number-entry) right next to "Document
|
|
100
|
+
* Verification - Passport" (document_verification, scan) as if they were
|
|
101
|
+
* the same kind of option — because channels[country] used to be one flat
|
|
102
|
+
* list with no category split at all. Splitting the backend response
|
|
103
|
+
* (SDKSecureLoaderView, adhere-backend) into {data_verification,
|
|
104
|
+
* document_verification} only helps if this screen then reads the ONE
|
|
105
|
+
* list matching globalDocFlow, instead of still flattening both — that's
|
|
106
|
+
* what actually removes the duplicate, not just how each entry displays
|
|
107
|
+
* (see isChannelDocumentFlow above, which only decides that).
|
|
108
|
+
*/
|
|
109
|
+
function selectIdTypesForScreen(byCategory, globalDocFlow) {
|
|
110
|
+
if (!byCategory)
|
|
111
|
+
return [];
|
|
112
|
+
return (globalDocFlow ? byCategory.document_verification : byCategory.data_verification) || [];
|
|
97
113
|
}
|
|
98
114
|
/**
|
|
99
115
|
* Whether a showErrorStep() message is about an expired/invalid resume or
|
|
@@ -763,8 +779,11 @@ class SmartComplyFlow {
|
|
|
763
779
|
return "liveness";
|
|
764
780
|
}
|
|
765
781
|
if (info.failure_stage === "document" && info.country && info.identifier_type) {
|
|
782
|
+
// A document-stage resume always references a document_verification
|
|
783
|
+
// channel by its doc code — channels[country] is now split by
|
|
784
|
+
// category (see ChannelsByCategory), so search that list directly.
|
|
766
785
|
const channels = this.sdkConfig?.channels || {};
|
|
767
|
-
const idTypes = channels[info.country] || [];
|
|
786
|
+
const idTypes = channels[info.country]?.document_verification || [];
|
|
768
787
|
const match = idTypes.find((idType) => {
|
|
769
788
|
const code = typeof idType === "string" ? idType : (idType.code || idType.name);
|
|
770
789
|
return code === info.identifier_type;
|
|
@@ -773,7 +792,7 @@ class SmartComplyFlow {
|
|
|
773
792
|
const typeName = typeof match === "string" ? match : match.name;
|
|
774
793
|
const typeCode = typeof match === "string" ? match : (match.code || match.name);
|
|
775
794
|
const channelFields = typeof match !== "string" ? (match.fields || []) : [];
|
|
776
|
-
const isDocFlow = channelFields.some((f) => isUploadFieldType(f.type)) || this.isDocumentFlow();
|
|
795
|
+
const isDocFlow = channelFields.some((f) => (0, channels_1.isUploadFieldType)(f.type)) || this.isDocumentFlow();
|
|
777
796
|
const info2 = resolveIdTypeInfo(typeName, isDocFlow);
|
|
778
797
|
const requiresBackFromBackend = typeof match !== "string" ? match.requires_back_side : undefined;
|
|
779
798
|
this.selectedCountry = info.country;
|
|
@@ -1140,7 +1159,9 @@ class SmartComplyFlow {
|
|
|
1140
1159
|
subtitle.textContent = "Choose the country that issued your ID";
|
|
1141
1160
|
container.appendChild(subtitle);
|
|
1142
1161
|
for (const country of countries) {
|
|
1143
|
-
const
|
|
1162
|
+
const count = channels[country].data_verification.length
|
|
1163
|
+
+ channels[country].document_verification.length;
|
|
1164
|
+
const card = this.createOptionCard(COUNTRY_LABELS[country] || country, `${count} ID type${count > 1 ? "s" : ""} available`, () => {
|
|
1144
1165
|
this.selectedCountry = country;
|
|
1145
1166
|
this.showStep("id_type");
|
|
1146
1167
|
});
|
|
@@ -1160,7 +1181,7 @@ class SmartComplyFlow {
|
|
|
1160
1181
|
: "Choose the ID you want to verify";
|
|
1161
1182
|
container.appendChild(subtitle);
|
|
1162
1183
|
const channels = this.sdkConfig?.channels || {};
|
|
1163
|
-
const idTypes = channels[this.selectedCountry]
|
|
1184
|
+
const idTypes = selectIdTypesForScreen(channels[this.selectedCountry], globalDocFlow);
|
|
1164
1185
|
for (const idType of idTypes) {
|
|
1165
1186
|
const typeName = typeof idType === "string" ? idType : idType.name;
|
|
1166
1187
|
// Use code (canonical) for API calls, fallback to name for backward compatibility
|
|
@@ -2753,12 +2774,18 @@ class SmartComplyFlow {
|
|
|
2753
2774
|
if (types.includes("data_verification"))
|
|
2754
2775
|
return false;
|
|
2755
2776
|
}
|
|
2756
|
-
// 2. Fallback: inspect channel fields — any upload field = document flow
|
|
2777
|
+
// 2. Fallback: inspect channel fields — any upload field = document flow.
|
|
2778
|
+
// channels[country] is now split {data_verification, document_verification}
|
|
2779
|
+
// (see ChannelsByCategory) — flatten both sub-lists per country, not the
|
|
2780
|
+
// per-country objects themselves.
|
|
2757
2781
|
const channels = this.sdkConfig?.channels || {};
|
|
2758
2782
|
const allFields = Object.values(channels)
|
|
2759
|
-
.
|
|
2783
|
+
.flatMap((byCategory) => [
|
|
2784
|
+
...(byCategory.data_verification || []),
|
|
2785
|
+
...(byCategory.document_verification || []),
|
|
2786
|
+
])
|
|
2760
2787
|
.flatMap((ch) => ch.fields || []);
|
|
2761
|
-
return allFields.some((f) => isUploadFieldType(f.type));
|
|
2788
|
+
return allFields.some((f) => (0, channels_1.isUploadFieldType)(f.type));
|
|
2762
2789
|
}
|
|
2763
2790
|
/**
|
|
2764
2791
|
* True when the SDK Config is set to skip data/document verification
|