@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.esm.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
|
*/
|
|
@@ -18,7 +18,15 @@ const CSS_CLASSES = {
|
|
|
18
18
|
confirmBox: "didit-confirm-box",
|
|
19
19
|
embedded: "didit-embedded"
|
|
20
20
|
};
|
|
21
|
-
const SDK_VERSION = "0.
|
|
21
|
+
const SDK_VERSION = "0.4.0";
|
|
22
|
+
/** The verification-URL query parameter each camera option is forwarded as. */
|
|
23
|
+
const CAMERA_QUERY_PARAMS = {
|
|
24
|
+
defaultDocumentCamera: "document_camera",
|
|
25
|
+
defaultLivenessCamera: "liveness_camera",
|
|
26
|
+
showDocumentCameraSwitchButton: "document_camera_switch",
|
|
27
|
+
showLivenessCameraSwitchButton: "liveness_camera_switch"
|
|
28
|
+
};
|
|
29
|
+
const CAMERA_LENSES = ["front", "back"];
|
|
22
30
|
const languages = [
|
|
23
31
|
"ar",
|
|
24
32
|
"bg",
|
|
@@ -121,6 +129,61 @@ function createVerificationError(type, customMessage) {
|
|
|
121
129
|
message: customMessage || messages[type]
|
|
122
130
|
};
|
|
123
131
|
}
|
|
132
|
+
function isCameraLens(value) {
|
|
133
|
+
return CAMERA_LENSES.includes(value);
|
|
134
|
+
}
|
|
135
|
+
const CAMERA_LENS_OPTIONS = ["defaultDocumentCamera", "defaultLivenessCamera"];
|
|
136
|
+
const CAMERA_SWITCH_OPTIONS = ["showDocumentCameraSwitchButton", "showLivenessCameraSwitchButton"];
|
|
137
|
+
/**
|
|
138
|
+
* The URL the verification iframe loads: the integrator's URL with the
|
|
139
|
+
* configuration options the hosted page reads from its query string.
|
|
140
|
+
*
|
|
141
|
+
* The camera options (the same four the native SDKs expose) become query
|
|
142
|
+
* parameters: `defaultDocumentCamera` -> `document_camera=<lens>`,
|
|
143
|
+
* `defaultLivenessCamera` -> `liveness_camera=<lens>`,
|
|
144
|
+
* `showDocumentCameraSwitchButton` -> `document_camera_switch=true|false`,
|
|
145
|
+
* `showLivenessCameraSwitchButton` -> `liveness_camera_switch=true|false`.
|
|
146
|
+
* Each parameter is set (not appended) so the configuration wins over a value
|
|
147
|
+
* already on the URL; existing query parameters and the hash are kept. A
|
|
148
|
+
* value of the wrong shape is ignored with a warning rather than forwarded,
|
|
149
|
+
* and a URL the browser cannot parse is returned as it came (the modal
|
|
150
|
+
* reports it when it loads).
|
|
151
|
+
*/
|
|
152
|
+
function buildVerificationUrl(url, configuration) {
|
|
153
|
+
if (!configuration)
|
|
154
|
+
return url;
|
|
155
|
+
const params = [];
|
|
156
|
+
for (const option of CAMERA_LENS_OPTIONS) {
|
|
157
|
+
const value = configuration[option];
|
|
158
|
+
if (value === undefined)
|
|
159
|
+
continue;
|
|
160
|
+
if (!isCameraLens(value)) {
|
|
161
|
+
SDKLogger.warn(`Ignoring ${option}: expected "front" or "back", got`, value);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
params.push([CAMERA_QUERY_PARAMS[option], value]);
|
|
165
|
+
}
|
|
166
|
+
for (const option of CAMERA_SWITCH_OPTIONS) {
|
|
167
|
+
const value = configuration[option];
|
|
168
|
+
if (value === undefined)
|
|
169
|
+
continue;
|
|
170
|
+
if (typeof value !== "boolean") {
|
|
171
|
+
SDKLogger.warn(`Ignoring ${option}: expected a boolean, got`, value);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
params.push([CAMERA_QUERY_PARAMS[option], value ? "true" : "false"]);
|
|
175
|
+
}
|
|
176
|
+
if (params.length === 0)
|
|
177
|
+
return url;
|
|
178
|
+
try {
|
|
179
|
+
const parsed = new URL(url);
|
|
180
|
+
params.forEach(([name, value]) => parsed.searchParams.set(name, value));
|
|
181
|
+
return parsed.toString();
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return url;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
124
187
|
function detectLanguageFromUrl(url) {
|
|
125
188
|
try {
|
|
126
189
|
const { pathname } = new URL(url);
|
|
@@ -642,6 +705,7 @@ class VerificationModal {
|
|
|
642
705
|
position: relative;
|
|
643
706
|
width: 100%;
|
|
644
707
|
max-width: 500px;
|
|
708
|
+
max-height: 90vh;
|
|
645
709
|
max-height: 90dvh;
|
|
646
710
|
border-radius: 16px;
|
|
647
711
|
overflow: hidden;
|
|
@@ -654,7 +718,9 @@ class VerificationModal {
|
|
|
654
718
|
|
|
655
719
|
.${CSS_CLASSES.iframe} {
|
|
656
720
|
width: 100%;
|
|
657
|
-
height:
|
|
721
|
+
height: 90vh;
|
|
722
|
+
height: 90dvh;
|
|
723
|
+
max-height: 700px;
|
|
658
724
|
border: none;
|
|
659
725
|
display: block;
|
|
660
726
|
}
|
|
@@ -812,12 +878,15 @@ class VerificationModal {
|
|
|
812
878
|
|
|
813
879
|
.${CSS_CLASSES.container} {
|
|
814
880
|
max-width: 100%;
|
|
881
|
+
max-height: 100vh;
|
|
815
882
|
max-height: 100dvh;
|
|
816
883
|
border-radius: 0;
|
|
817
884
|
}
|
|
818
885
|
|
|
819
886
|
.${CSS_CLASSES.iframe} {
|
|
887
|
+
height: 100vh;
|
|
820
888
|
height: 100dvh;
|
|
889
|
+
max-height: none;
|
|
821
890
|
}
|
|
822
891
|
}
|
|
823
892
|
|
|
@@ -830,6 +899,7 @@ class VerificationModal {
|
|
|
830
899
|
.${CSS_CLASSES.embedded} .${CSS_CLASSES.iframe} {
|
|
831
900
|
width: 100%;
|
|
832
901
|
height: 100%;
|
|
902
|
+
max-height: none;
|
|
833
903
|
}
|
|
834
904
|
|
|
835
905
|
.${CSS_CLASSES.embedded} .${CSS_CLASSES.loading} {
|
|
@@ -1848,7 +1918,7 @@ class DiditSdk {
|
|
|
1848
1918
|
if (!url || typeof url !== "string") {
|
|
1849
1919
|
throw new Error("Invalid options: url is required");
|
|
1850
1920
|
}
|
|
1851
|
-
this._url = url;
|
|
1921
|
+
this._url = buildVerificationUrl(url, config);
|
|
1852
1922
|
this.setState("loading");
|
|
1853
1923
|
this.emitInternalEvent("didit:started", {});
|
|
1854
1924
|
this._modal?.open(this._url);
|