@didit-protocol/sdk-web 0.5.3 → 0.6.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 +7 -0
- package/dist/didit-sdk.cjs +210 -38
- package/dist/didit-sdk.cjs.js +210 -38
- package/dist/didit-sdk.cjs.js.map +1 -1
- package/dist/didit-sdk.cjs.map +1 -1
- package/dist/didit-sdk.esm.js +688 -262
- package/dist/didit-sdk.esm.js.map +1 -1
- package/dist/didit-sdk.module.js +211 -39
- package/dist/didit-sdk.module.js.map +1 -1
- package/dist/didit-sdk.umd.js +689 -261
- 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 +1 -1
- package/package.json +7 -2
package/dist/didit-sdk.module.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Didit SDK for Web v0.
|
|
2
|
+
* Didit SDK for Web v0.6.0
|
|
3
3
|
* (c) 2026 Didit
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import { getDeviceFingerprintPayload, buildFingerprintHeaders, submitEvent } from '@didit-protocol/signals';
|
|
6
|
+
import { getDeviceFingerprintPayload, buildFingerprintHeaders, submitEvent, getStoredDeviceId } from '@didit-protocol/signals';
|
|
7
7
|
export * from '@didit-protocol/signals';
|
|
8
8
|
|
|
9
9
|
const DEFAULT_CONFIG = {
|
|
@@ -23,9 +23,10 @@ const CSS_CLASSES = {
|
|
|
23
23
|
loading: "didit-loading",
|
|
24
24
|
confirmOverlay: "didit-confirm-overlay",
|
|
25
25
|
confirmBox: "didit-confirm-box",
|
|
26
|
-
embedded: "didit-embedded"
|
|
26
|
+
embedded: "didit-embedded",
|
|
27
|
+
curtain: "didit-modal-curtain"
|
|
27
28
|
};
|
|
28
|
-
const SDK_VERSION = "0.
|
|
29
|
+
const SDK_VERSION = "0.6.0";
|
|
29
30
|
/**
|
|
30
31
|
* The permissions the verification iframe gets, in a modal and embedded:
|
|
31
32
|
* camera and microphone for capture, clipboard-write for the flow's copy
|
|
@@ -51,6 +52,13 @@ const PRESENTATION_QUERY_PARAMS = {
|
|
|
51
52
|
presentation: "sdk_presentation",
|
|
52
53
|
closeButton: "sdk_close_button"
|
|
53
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* The verification-URL query parameter that carries the device id this page
|
|
57
|
+
* already keeps for Didit, when it keeps one. A browser gives the flow in the
|
|
58
|
+
* frame storage of its own, apart from this page's, so without it a
|
|
59
|
+
* verification and this site's events never share a device id.
|
|
60
|
+
*/
|
|
61
|
+
const DEVICE_ID_QUERY_PARAM = "sdk_device_id";
|
|
54
62
|
/**
|
|
55
63
|
* Posted by the hosted flow when it lays itself out for the modal, with
|
|
56
64
|
* `data: { contentHeight, colorScheme?, dir?, kind? }` (`kind` is `handoff` or `step`, `step` when missing). The modal then grows to the
|
|
@@ -177,15 +185,21 @@ const CAMERA_SWITCH_OPTIONS = ["showDocumentCameraSwitchButton", "showLivenessCa
|
|
|
177
185
|
* `showDocumentCameraSwitchButton` -> `document_camera_switch=true|false`,
|
|
178
186
|
* `showLivenessCameraSwitchButton` -> `liveness_camera_switch=true|false`.
|
|
179
187
|
* How the SDK presents the flow is always added: `sdk_presentation=modal|embedded`
|
|
180
|
-
* and, in a modal, `sdk_close_button=true|false`.
|
|
188
|
+
* and, in a modal, `sdk_close_button=true|false`. `storedDeviceId`, when the
|
|
189
|
+
* page has one, is added as `sdk_device_id`.
|
|
181
190
|
* Each parameter is set (not appended) so the configuration wins over a value
|
|
182
191
|
* already on the URL; existing query parameters and the hash are kept. A
|
|
183
192
|
* value of the wrong shape is ignored with a warning rather than forwarded,
|
|
184
193
|
* and a URL the browser cannot parse is returned as it came (the modal
|
|
185
194
|
* reports it when it loads).
|
|
186
195
|
*/
|
|
187
|
-
function buildVerificationUrl(url, configuration = {}) {
|
|
196
|
+
function buildVerificationUrl(url, configuration = {}, storedDeviceId = null) {
|
|
188
197
|
const params = presentationParams(configuration);
|
|
198
|
+
// The id this page already keeps for Didit (see getStoredDeviceId): the flow in the frame, whose
|
|
199
|
+
// own storage the browser keeps apart from this page's, can then be told apart as the same
|
|
200
|
+
// device as this site's events. Absent when the page keeps none; nothing is created for it.
|
|
201
|
+
if (storedDeviceId)
|
|
202
|
+
params.push([DEVICE_ID_QUERY_PARAM, storedDeviceId]);
|
|
189
203
|
for (const option of CAMERA_LENS_OPTIONS) {
|
|
190
204
|
const value = configuration[option];
|
|
191
205
|
if (value === undefined)
|
|
@@ -691,6 +705,8 @@ function getTranslations(language) {
|
|
|
691
705
|
const SIZE_ANIMATION_MS = 300;
|
|
692
706
|
/** How long the modal waits for the first layout before it shows at step size, so it can never hang. */
|
|
693
707
|
const FIRST_LAYOUT_TIMEOUT_MS = 3000;
|
|
708
|
+
/** The flow's ground (site-ground in the design system), which a full-screen modal paints the page with. */
|
|
709
|
+
const FLOW_GROUND = { light: "#ffffff", dark: "#0b0b0d" };
|
|
694
710
|
class VerificationModal {
|
|
695
711
|
constructor(configuration, callbacks) {
|
|
696
712
|
this.state = {
|
|
@@ -713,10 +729,9 @@ class VerificationModal {
|
|
|
713
729
|
this.embedded = false;
|
|
714
730
|
this.embeddedContainer = null;
|
|
715
731
|
this.language = "en";
|
|
716
|
-
/** The
|
|
717
|
-
this.
|
|
718
|
-
|
|
719
|
-
this.previousBodyOverflow = null;
|
|
732
|
+
/** The ground below the layout viewport (see showCurtain), while this modal is open. */
|
|
733
|
+
this.curtain = null;
|
|
734
|
+
this.boundPlaceCurtain = null;
|
|
720
735
|
this.modalId = generateModalId();
|
|
721
736
|
this.config = {
|
|
722
737
|
zIndex: configuration?.zIndex ?? DEFAULT_CONFIG.zIndex,
|
|
@@ -810,13 +825,14 @@ class VerificationModal {
|
|
|
810
825
|
display: flex;
|
|
811
826
|
align-items: center;
|
|
812
827
|
justify-content: center;
|
|
813
|
-
|
|
828
|
+
/* The flow's ground, so a phone's loader meets the ground below the viewport without a seam. */
|
|
829
|
+
background: ${FLOW_GROUND.light};
|
|
814
830
|
z-index: 5;
|
|
815
831
|
}
|
|
816
832
|
|
|
817
833
|
@media (prefers-color-scheme: dark) {
|
|
818
834
|
.${CSS_CLASSES.loading} {
|
|
819
|
-
background:
|
|
835
|
+
background: ${FLOW_GROUND.dark};
|
|
820
836
|
}
|
|
821
837
|
}
|
|
822
838
|
|
|
@@ -1006,6 +1022,40 @@ class VerificationModal {
|
|
|
1006
1022
|
}
|
|
1007
1023
|
}
|
|
1008
1024
|
|
|
1025
|
+
/*
|
|
1026
|
+
* The flow's ground right below the layout viewport, in the page itself (see showCurtain):
|
|
1027
|
+
* on a phone, iOS browsers with their toolbars collapsed show a band of the page there,
|
|
1028
|
+
* below every fixed element, the full-screen modal included.
|
|
1029
|
+
*/
|
|
1030
|
+
.${CSS_CLASSES.curtain} {
|
|
1031
|
+
display: none;
|
|
1032
|
+
position: absolute;
|
|
1033
|
+
top: 0;
|
|
1034
|
+
left: 0;
|
|
1035
|
+
width: 100vw;
|
|
1036
|
+
height: 100vh;
|
|
1037
|
+
margin: 0;
|
|
1038
|
+
pointer-events: none;
|
|
1039
|
+
/* Under the modal where they meet for a frame while the toolbars move, above the page. */
|
|
1040
|
+
z-index: ${this.config.zIndex - 1};
|
|
1041
|
+
background: ${FLOW_GROUND.light};
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.${CSS_CLASSES.curtain}[data-didit-theme="dark"] {
|
|
1045
|
+
background: ${FLOW_GROUND.dark};
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/* The exit confirmation's dimming continues over the ground below the viewport. */
|
|
1049
|
+
.${CSS_CLASSES.curtain}[data-didit-dimmed] {
|
|
1050
|
+
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
@media (max-width: 540px) {
|
|
1054
|
+
.${CSS_CLASSES.curtain} {
|
|
1055
|
+
display: block;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1009
1059
|
/*
|
|
1010
1060
|
* The hosted flow's layout message (didit:layout) brings the modal's size
|
|
1011
1061
|
* (see above), theme and direction. Colours are the design system tokens
|
|
@@ -1367,6 +1417,8 @@ class VerificationModal {
|
|
|
1367
1417
|
const shownHeight = this.container.offsetHeight;
|
|
1368
1418
|
this.container.style.setProperty("--didit-content-height", `${layout.contentHeight}px`);
|
|
1369
1419
|
this.matchPageBackground(layout.colorScheme);
|
|
1420
|
+
if (this.curtain)
|
|
1421
|
+
this.curtain.dataset.diditTheme = layout.colorScheme;
|
|
1370
1422
|
this.setModalKind(layout.kind, layout.kind === "handoff" && this.handoffHeight(layout) === shownHeight);
|
|
1371
1423
|
}
|
|
1372
1424
|
/** Whether the window is a computer-sized one: a phone is full screen and never waits for a layout. */
|
|
@@ -1437,18 +1489,125 @@ class VerificationModal {
|
|
|
1437
1489
|
matchPageBackground(colorScheme) {
|
|
1438
1490
|
if (!window.matchMedia?.("(max-width: 540px)").matches)
|
|
1439
1491
|
return;
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1492
|
+
VerificationModal.pageBackground ?? (VerificationModal.pageBackground = {
|
|
1493
|
+
saved: { root: document.documentElement.style.backgroundColor, body: document.body.style.backgroundColor },
|
|
1494
|
+
grounds: new Map()
|
|
1495
|
+
});
|
|
1496
|
+
VerificationModal.pageBackground.grounds.set(this, colorScheme);
|
|
1497
|
+
VerificationModal.paintPageBackground();
|
|
1445
1498
|
}
|
|
1446
1499
|
restorePageBackground() {
|
|
1447
|
-
|
|
1500
|
+
const background = VerificationModal.pageBackground;
|
|
1501
|
+
if (!background?.grounds.delete(this))
|
|
1502
|
+
return;
|
|
1503
|
+
if (background.grounds.size > 0) {
|
|
1504
|
+
VerificationModal.paintPageBackground();
|
|
1448
1505
|
return;
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1506
|
+
}
|
|
1507
|
+
VerificationModal.pageBackground = null;
|
|
1508
|
+
document.documentElement.style.backgroundColor = background.saved.root;
|
|
1509
|
+
document.body.style.backgroundColor = background.saved.body;
|
|
1510
|
+
}
|
|
1511
|
+
/** The page shows the ground of the topmost open modal that lends one. */
|
|
1512
|
+
static paintPageBackground() {
|
|
1513
|
+
const background = VerificationModal.pageBackground;
|
|
1514
|
+
if (!background)
|
|
1515
|
+
return;
|
|
1516
|
+
const lender = [...VerificationModal.openModals].reverse().find((modal) => background.grounds.has(modal));
|
|
1517
|
+
const colorScheme = lender ? background.grounds.get(lender) : [...background.grounds.values()].pop();
|
|
1518
|
+
if (!colorScheme)
|
|
1519
|
+
return;
|
|
1520
|
+
document.documentElement.style.backgroundColor = FLOW_GROUND[colorScheme];
|
|
1521
|
+
document.body.style.backgroundColor = FLOW_GROUND[colorScheme];
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Stops the page scrolling under the modal. The lock is on the root element: Chrome for iOS keeps
|
|
1525
|
+
* scrolling a page whose body alone is `overflow: hidden` (a swipe over the modal scrolls the page
|
|
1526
|
+
* and toggles the browser's toolbars), and stops only when the root element is. A page that
|
|
1527
|
+
* scrolls its body instead of the window has its body locked too. The first modal to open keeps
|
|
1528
|
+
* the page's own values and the last one to close gives them back.
|
|
1529
|
+
*/
|
|
1530
|
+
lockPageScroll() {
|
|
1531
|
+
const lock = VerificationModal.pageScrollLock;
|
|
1532
|
+
if (lock) {
|
|
1533
|
+
lock.holders.add(this);
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
const root = document.documentElement;
|
|
1537
|
+
const body = document.body;
|
|
1538
|
+
// The body's overflow is the viewport's only while the root's is visible; otherwise a body with
|
|
1539
|
+
// an overflow of its own is a scroll container. Locking a body that is not one would clip the page
|
|
1540
|
+
// to the body's box.
|
|
1541
|
+
const clips = (overflow) => overflow !== "" && overflow !== "visible";
|
|
1542
|
+
const bodyScrollsItself = clips(window.getComputedStyle(root).overflowY) && clips(window.getComputedStyle(body).overflowY);
|
|
1543
|
+
VerificationModal.pageScrollLock = {
|
|
1544
|
+
holders: new Set([this]),
|
|
1545
|
+
root: { overflow: root.style.overflow, overscrollBehavior: root.style.overscrollBehavior },
|
|
1546
|
+
body: bodyScrollsItself ? { overflow: body.style.overflow } : null
|
|
1547
|
+
};
|
|
1548
|
+
root.style.overflow = "hidden";
|
|
1549
|
+
root.style.overscrollBehavior = "none";
|
|
1550
|
+
if (bodyScrollsItself)
|
|
1551
|
+
body.style.overflow = "hidden";
|
|
1552
|
+
}
|
|
1553
|
+
unlockPageScroll() {
|
|
1554
|
+
const lock = VerificationModal.pageScrollLock;
|
|
1555
|
+
if (!lock || !lock.holders.delete(this) || lock.holders.size > 0)
|
|
1556
|
+
return;
|
|
1557
|
+
VerificationModal.pageScrollLock = null;
|
|
1558
|
+
const root = document.documentElement;
|
|
1559
|
+
root.style.overflow = lock.root.overflow;
|
|
1560
|
+
root.style.overscrollBehavior = lock.root.overscrollBehavior;
|
|
1561
|
+
if (lock.body)
|
|
1562
|
+
document.body.style.overflow = lock.body.overflow;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* On a phone, Chrome for iOS (and the other iOS browsers built on WebKit's web view) shows a band
|
|
1566
|
+
* of the page below the layout viewport while its toolbars are collapsed: the home indicator's
|
|
1567
|
+
* area, and more while the toolbars move. Fixed elements end at the layout viewport, so the
|
|
1568
|
+
* full-screen modal cannot cover it and the host page's own content showed under the flow. The
|
|
1569
|
+
* curtain is part of the page instead: right below the viewport, in the flow's ground, so that band
|
|
1570
|
+
* shows the modal's ground. The page cannot scroll while the modal is open (lockPageScroll), and the
|
|
1571
|
+
* curtain follows the viewport when it resizes. Only phone-sized windows draw it (see the styles).
|
|
1572
|
+
*/
|
|
1573
|
+
showCurtain() {
|
|
1574
|
+
if (!this.curtain) {
|
|
1575
|
+
const curtain = document.createElement("div");
|
|
1576
|
+
curtain.className = CSS_CLASSES.curtain;
|
|
1577
|
+
curtain.setAttribute("aria-hidden", "true");
|
|
1578
|
+
document.body.appendChild(curtain);
|
|
1579
|
+
this.curtain = curtain;
|
|
1580
|
+
this.boundPlaceCurtain = () => this.placeCurtain();
|
|
1581
|
+
window.addEventListener("resize", this.boundPlaceCurtain);
|
|
1582
|
+
window.addEventListener("scroll", this.boundPlaceCurtain);
|
|
1583
|
+
window.visualViewport?.addEventListener("resize", this.boundPlaceCurtain);
|
|
1584
|
+
}
|
|
1585
|
+
// The device's theme until the newly loaded flow reports its own (applyFlowLayout).
|
|
1586
|
+
this.curtain.dataset.diditTheme = window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1587
|
+
this.placeCurtain();
|
|
1588
|
+
}
|
|
1589
|
+
/** Puts the curtain's top at the bottom of the layout viewport, whatever its containing block is. */
|
|
1590
|
+
placeCurtain() {
|
|
1591
|
+
const curtain = this.curtain;
|
|
1592
|
+
if (!curtain)
|
|
1593
|
+
return;
|
|
1594
|
+
curtain.style.top = "0px";
|
|
1595
|
+
curtain.style.left = "0px";
|
|
1596
|
+
// At 0, 0 the curtain's box starts at its containing block's corner (the page's, or a positioned
|
|
1597
|
+
// body's), in viewport coordinates: the offset that brings its top to the viewport's bottom edge.
|
|
1598
|
+
const origin = curtain.getBoundingClientRect();
|
|
1599
|
+
curtain.style.top = `${window.innerHeight - origin.top}px`;
|
|
1600
|
+
curtain.style.left = `${-origin.left}px`;
|
|
1601
|
+
}
|
|
1602
|
+
removeCurtain() {
|
|
1603
|
+
if (this.boundPlaceCurtain) {
|
|
1604
|
+
window.removeEventListener("resize", this.boundPlaceCurtain);
|
|
1605
|
+
window.removeEventListener("scroll", this.boundPlaceCurtain);
|
|
1606
|
+
window.visualViewport?.removeEventListener("resize", this.boundPlaceCurtain);
|
|
1607
|
+
this.boundPlaceCurtain = null;
|
|
1608
|
+
}
|
|
1609
|
+
this.curtain?.remove();
|
|
1610
|
+
this.curtain = null;
|
|
1452
1611
|
}
|
|
1453
1612
|
/** Back to the neutral look until the newly loaded flow reports its theme and direction. */
|
|
1454
1613
|
resetFlowLayout() {
|
|
@@ -1526,6 +1685,7 @@ class VerificationModal {
|
|
|
1526
1685
|
: this.container?.querySelector(`.${CSS_CLASSES.closeButton}`) ?? this.iframe);
|
|
1527
1686
|
this.state.showConfirmation = true;
|
|
1528
1687
|
this.confirmOverlay.classList.add("active");
|
|
1688
|
+
this.curtain?.setAttribute("data-didit-dimmed", "");
|
|
1529
1689
|
if (this.iframe)
|
|
1530
1690
|
this.iframe.inert = true;
|
|
1531
1691
|
const close = this.container?.querySelector(`.${CSS_CLASSES.closeButton}`);
|
|
@@ -1549,6 +1709,7 @@ class VerificationModal {
|
|
|
1549
1709
|
return;
|
|
1550
1710
|
this.state.showConfirmation = false;
|
|
1551
1711
|
this.confirmOverlay?.classList.remove("active");
|
|
1712
|
+
this.curtain?.removeAttribute("data-didit-dimmed");
|
|
1552
1713
|
if (this.iframe)
|
|
1553
1714
|
this.iframe.inert = false;
|
|
1554
1715
|
const close = this.container?.querySelector(`.${CSS_CLASSES.closeButton}`);
|
|
@@ -1576,11 +1737,6 @@ class VerificationModal {
|
|
|
1576
1737
|
this.callbacks.onCloseConfirmed();
|
|
1577
1738
|
}
|
|
1578
1739
|
open(verificationUrl) {
|
|
1579
|
-
// Whether this modal already held its scroll lock before this call. Re-opening
|
|
1580
|
-
// an already-open instance must not re-capture previousBodyOverflow, or it
|
|
1581
|
-
// would record this modal's own "hidden" lock and close() could never restore
|
|
1582
|
-
// the real pre-lock value.
|
|
1583
|
-
const wasAlreadyOpen = this.state.isOpen;
|
|
1584
1740
|
this.language = detectLanguageFromUrl(verificationUrl);
|
|
1585
1741
|
if (!this.overlay && !this.container) {
|
|
1586
1742
|
this.createDOM();
|
|
@@ -1605,16 +1761,10 @@ class VerificationModal {
|
|
|
1605
1761
|
return;
|
|
1606
1762
|
}
|
|
1607
1763
|
this.overlay?.classList.add("active");
|
|
1608
|
-
//
|
|
1609
|
-
//
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
// in effect is this modal's own lock, and previousBodyOverflow already
|
|
1613
|
-
// holds the correct pre-lock value.
|
|
1614
|
-
if (!wasAlreadyOpen) {
|
|
1615
|
-
this.previousBodyOverflow = document.body.style.overflow;
|
|
1616
|
-
}
|
|
1617
|
-
document.body.style.overflow = "hidden";
|
|
1764
|
+
// Idempotent: a re-open of a modal that is still open keeps its one hold on the lock, so
|
|
1765
|
+
// close() still gives the page back the values it had before any modal opened.
|
|
1766
|
+
this.lockPageScroll();
|
|
1767
|
+
this.showCurtain();
|
|
1618
1768
|
}
|
|
1619
1769
|
close() {
|
|
1620
1770
|
SDKLogger.log("Closing");
|
|
@@ -1632,8 +1782,8 @@ class VerificationModal {
|
|
|
1632
1782
|
return;
|
|
1633
1783
|
}
|
|
1634
1784
|
this.overlay?.classList.remove("active");
|
|
1635
|
-
|
|
1636
|
-
this.
|
|
1785
|
+
this.removeCurtain();
|
|
1786
|
+
this.unlockPageScroll();
|
|
1637
1787
|
}
|
|
1638
1788
|
destroy() {
|
|
1639
1789
|
SDKLogger.log("Destroying");
|
|
@@ -1665,6 +1815,16 @@ class VerificationModal {
|
|
|
1665
1815
|
* a transaction action modal stacked over the verification modal).
|
|
1666
1816
|
*/
|
|
1667
1817
|
VerificationModal.openModals = [];
|
|
1818
|
+
/**
|
|
1819
|
+
* The page's own background colours, kept while full-screen modals lend it their ground, shared by
|
|
1820
|
+
* every open modal: the topmost one's ground shows and the last one to give it back restores them.
|
|
1821
|
+
*/
|
|
1822
|
+
VerificationModal.pageBackground = null;
|
|
1823
|
+
/**
|
|
1824
|
+
* The page's scroll styles from before the first open modal locked them, shared by every open
|
|
1825
|
+
* modal: the last one to close gives them back.
|
|
1826
|
+
*/
|
|
1827
|
+
VerificationModal.pageScrollLock = null;
|
|
1668
1828
|
|
|
1669
1829
|
const DEFAULT_TRANSACTION_BASE_URL = "https://verification.didit.me";
|
|
1670
1830
|
const ACTION_POLL_INTERVAL_MS = 1500;
|
|
@@ -1984,6 +2144,18 @@ function assertEmbeddedHostExists(configuration) {
|
|
|
1984
2144
|
throw new Error(`Embedded container "#${containerId}" was not found in the page.`);
|
|
1985
2145
|
}
|
|
1986
2146
|
}
|
|
2147
|
+
/**
|
|
2148
|
+
* The device id this page already keeps for Didit (it has sent events, transactions or sign-ins),
|
|
2149
|
+
* or null. Reading it never creates one, and a browser that refuses the read is not an error.
|
|
2150
|
+
*/
|
|
2151
|
+
function storedDeviceId() {
|
|
2152
|
+
try {
|
|
2153
|
+
return getStoredDeviceId();
|
|
2154
|
+
}
|
|
2155
|
+
catch {
|
|
2156
|
+
return null;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
1987
2159
|
class DiditSdk {
|
|
1988
2160
|
static get shared() {
|
|
1989
2161
|
if (!DiditSdk._instance) {
|
|
@@ -2057,7 +2229,7 @@ class DiditSdk {
|
|
|
2057
2229
|
onMessage: (event) => this.handleVerificationEvent(event),
|
|
2058
2230
|
onIframeLoad: () => this.handleIframeLoad()
|
|
2059
2231
|
});
|
|
2060
|
-
this._url = buildVerificationUrl(url, config);
|
|
2232
|
+
this._url = buildVerificationUrl(url, config, storedDeviceId());
|
|
2061
2233
|
this.setState("loading");
|
|
2062
2234
|
this.emitInternalEvent("didit:started", {});
|
|
2063
2235
|
this._modal?.open(this._url);
|