@didit-protocol/sdk-web 0.3.0 → 0.4.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/README.md +77 -1
- package/dist/didit-sdk.cjs.js +74 -4
- package/dist/didit-sdk.cjs.js.map +1 -1
- package/dist/didit-sdk.esm.js +74 -4
- package/dist/didit-sdk.esm.js.map +1 -1
- package/dist/didit-sdk.umd.js +74 -4
- package/dist/didit-sdk.umd.js.map +1 -1
- package/dist/didit-sdk.umd.min.js +2 -2
- package/dist/didit-sdk.umd.min.js.map +1 -1
- package/dist/index.d.ts +41 -2
- package/package.json +5 -1
package/dist/didit-sdk.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Didit SDK for Web v0.
|
|
2
|
+
* Didit SDK for Web v0.4.0
|
|
3
3
|
* (c) 2026 Didit
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -24,7 +24,15 @@
|
|
|
24
24
|
confirmBox: "didit-confirm-box",
|
|
25
25
|
embedded: "didit-embedded"
|
|
26
26
|
};
|
|
27
|
-
const SDK_VERSION = "0.
|
|
27
|
+
const SDK_VERSION = "0.4.0";
|
|
28
|
+
/** The verification-URL query parameter each camera option is forwarded as. */
|
|
29
|
+
const CAMERA_QUERY_PARAMS = {
|
|
30
|
+
defaultDocumentCamera: "document_camera",
|
|
31
|
+
defaultLivenessCamera: "liveness_camera",
|
|
32
|
+
showDocumentCameraSwitchButton: "document_camera_switch",
|
|
33
|
+
showLivenessCameraSwitchButton: "liveness_camera_switch"
|
|
34
|
+
};
|
|
35
|
+
const CAMERA_LENSES = ["front", "back"];
|
|
28
36
|
const languages = [
|
|
29
37
|
"ar",
|
|
30
38
|
"bg",
|
|
@@ -127,6 +135,61 @@
|
|
|
127
135
|
message: customMessage || messages[type]
|
|
128
136
|
};
|
|
129
137
|
}
|
|
138
|
+
function isCameraLens(value) {
|
|
139
|
+
return CAMERA_LENSES.includes(value);
|
|
140
|
+
}
|
|
141
|
+
const CAMERA_LENS_OPTIONS = ["defaultDocumentCamera", "defaultLivenessCamera"];
|
|
142
|
+
const CAMERA_SWITCH_OPTIONS = ["showDocumentCameraSwitchButton", "showLivenessCameraSwitchButton"];
|
|
143
|
+
/**
|
|
144
|
+
* The URL the verification iframe loads: the integrator's URL with the
|
|
145
|
+
* configuration options the hosted page reads from its query string.
|
|
146
|
+
*
|
|
147
|
+
* The camera options (the same four the native SDKs expose) become query
|
|
148
|
+
* parameters: `defaultDocumentCamera` -> `document_camera=<lens>`,
|
|
149
|
+
* `defaultLivenessCamera` -> `liveness_camera=<lens>`,
|
|
150
|
+
* `showDocumentCameraSwitchButton` -> `document_camera_switch=true|false`,
|
|
151
|
+
* `showLivenessCameraSwitchButton` -> `liveness_camera_switch=true|false`.
|
|
152
|
+
* Each parameter is set (not appended) so the configuration wins over a value
|
|
153
|
+
* already on the URL; existing query parameters and the hash are kept. A
|
|
154
|
+
* value of the wrong shape is ignored with a warning rather than forwarded,
|
|
155
|
+
* and a URL the browser cannot parse is returned as it came (the modal
|
|
156
|
+
* reports it when it loads).
|
|
157
|
+
*/
|
|
158
|
+
function buildVerificationUrl(url, configuration) {
|
|
159
|
+
if (!configuration)
|
|
160
|
+
return url;
|
|
161
|
+
const params = [];
|
|
162
|
+
for (const option of CAMERA_LENS_OPTIONS) {
|
|
163
|
+
const value = configuration[option];
|
|
164
|
+
if (value === undefined)
|
|
165
|
+
continue;
|
|
166
|
+
if (!isCameraLens(value)) {
|
|
167
|
+
SDKLogger.warn(`Ignoring ${option}: expected "front" or "back", got`, value);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
params.push([CAMERA_QUERY_PARAMS[option], value]);
|
|
171
|
+
}
|
|
172
|
+
for (const option of CAMERA_SWITCH_OPTIONS) {
|
|
173
|
+
const value = configuration[option];
|
|
174
|
+
if (value === undefined)
|
|
175
|
+
continue;
|
|
176
|
+
if (typeof value !== "boolean") {
|
|
177
|
+
SDKLogger.warn(`Ignoring ${option}: expected a boolean, got`, value);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
params.push([CAMERA_QUERY_PARAMS[option], value ? "true" : "false"]);
|
|
181
|
+
}
|
|
182
|
+
if (params.length === 0)
|
|
183
|
+
return url;
|
|
184
|
+
try {
|
|
185
|
+
const parsed = new URL(url);
|
|
186
|
+
params.forEach(([name, value]) => parsed.searchParams.set(name, value));
|
|
187
|
+
return parsed.toString();
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return url;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
130
193
|
function detectLanguageFromUrl(url) {
|
|
131
194
|
try {
|
|
132
195
|
const { pathname } = new URL(url);
|
|
@@ -648,6 +711,7 @@
|
|
|
648
711
|
position: relative;
|
|
649
712
|
width: 100%;
|
|
650
713
|
max-width: 500px;
|
|
714
|
+
max-height: 90vh;
|
|
651
715
|
max-height: 90dvh;
|
|
652
716
|
border-radius: 16px;
|
|
653
717
|
overflow: hidden;
|
|
@@ -660,7 +724,9 @@
|
|
|
660
724
|
|
|
661
725
|
.${CSS_CLASSES.iframe} {
|
|
662
726
|
width: 100%;
|
|
663
|
-
height:
|
|
727
|
+
height: 90vh;
|
|
728
|
+
height: 90dvh;
|
|
729
|
+
max-height: 700px;
|
|
664
730
|
border: none;
|
|
665
731
|
display: block;
|
|
666
732
|
}
|
|
@@ -818,12 +884,15 @@
|
|
|
818
884
|
|
|
819
885
|
.${CSS_CLASSES.container} {
|
|
820
886
|
max-width: 100%;
|
|
887
|
+
max-height: 100vh;
|
|
821
888
|
max-height: 100dvh;
|
|
822
889
|
border-radius: 0;
|
|
823
890
|
}
|
|
824
891
|
|
|
825
892
|
.${CSS_CLASSES.iframe} {
|
|
893
|
+
height: 100vh;
|
|
826
894
|
height: 100dvh;
|
|
895
|
+
max-height: none;
|
|
827
896
|
}
|
|
828
897
|
}
|
|
829
898
|
|
|
@@ -836,6 +905,7 @@
|
|
|
836
905
|
.${CSS_CLASSES.embedded} .${CSS_CLASSES.iframe} {
|
|
837
906
|
width: 100%;
|
|
838
907
|
height: 100%;
|
|
908
|
+
max-height: none;
|
|
839
909
|
}
|
|
840
910
|
|
|
841
911
|
.${CSS_CLASSES.embedded} .${CSS_CLASSES.loading} {
|
|
@@ -1854,7 +1924,7 @@
|
|
|
1854
1924
|
if (!url || typeof url !== "string") {
|
|
1855
1925
|
throw new Error("Invalid options: url is required");
|
|
1856
1926
|
}
|
|
1857
|
-
this._url = url;
|
|
1927
|
+
this._url = buildVerificationUrl(url, config);
|
|
1858
1928
|
this.setState("loading");
|
|
1859
1929
|
this.emitInternalEvent("didit:started", {});
|
|
1860
1930
|
this._modal?.open(this._url);
|