@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/README.md
CHANGED
|
@@ -482,6 +482,13 @@ Delivery is best effort: the queue is in memory, and browsers can terminate pend
|
|
|
482
482
|
|
|
483
483
|
Full guide: [SDK Event Submission](https://docs.didit.me/transaction-monitoring/sdk-event-submission).
|
|
484
484
|
|
|
485
|
+
### One device across your site and the verification
|
|
486
|
+
|
|
487
|
+
A browser keeps the storage of the verification's frame apart from your page's, so the two would never share a device id.
|
|
488
|
+
When your page already keeps one for Didit (it has sent events, transactions or sign-ins), `startVerification` passes it to the verification as the `sdk_device_id` query parameter.
|
|
489
|
+
The verification then reports it next to its own signals, and goes by it where the browser gives the frame no storage that lasts.
|
|
490
|
+
A page that keeps no id gets none created: opening a verification adds no cookie and no storage entry to your site.
|
|
491
|
+
|
|
485
492
|
## API Reference
|
|
486
493
|
|
|
487
494
|
### DiditSdk.shared
|
package/dist/didit-sdk.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
*/
|
|
@@ -26,9 +26,10 @@ const CSS_CLASSES = {
|
|
|
26
26
|
loading: "didit-loading",
|
|
27
27
|
confirmOverlay: "didit-confirm-overlay",
|
|
28
28
|
confirmBox: "didit-confirm-box",
|
|
29
|
-
embedded: "didit-embedded"
|
|
29
|
+
embedded: "didit-embedded",
|
|
30
|
+
curtain: "didit-modal-curtain"
|
|
30
31
|
};
|
|
31
|
-
const SDK_VERSION = "0.
|
|
32
|
+
const SDK_VERSION = "0.6.0";
|
|
32
33
|
/**
|
|
33
34
|
* The permissions the verification iframe gets, in a modal and embedded:
|
|
34
35
|
* camera and microphone for capture, clipboard-write for the flow's copy
|
|
@@ -54,6 +55,13 @@ const PRESENTATION_QUERY_PARAMS = {
|
|
|
54
55
|
presentation: "sdk_presentation",
|
|
55
56
|
closeButton: "sdk_close_button"
|
|
56
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* The verification-URL query parameter that carries the device id this page
|
|
60
|
+
* already keeps for Didit, when it keeps one. A browser gives the flow in the
|
|
61
|
+
* frame storage of its own, apart from this page's, so without it a
|
|
62
|
+
* verification and this site's events never share a device id.
|
|
63
|
+
*/
|
|
64
|
+
const DEVICE_ID_QUERY_PARAM = "sdk_device_id";
|
|
57
65
|
/**
|
|
58
66
|
* Posted by the hosted flow when it lays itself out for the modal, with
|
|
59
67
|
* `data: { contentHeight, colorScheme?, dir?, kind? }` (`kind` is `handoff` or `step`, `step` when missing). The modal then grows to the
|
|
@@ -180,15 +188,21 @@ const CAMERA_SWITCH_OPTIONS = ["showDocumentCameraSwitchButton", "showLivenessCa
|
|
|
180
188
|
* `showDocumentCameraSwitchButton` -> `document_camera_switch=true|false`,
|
|
181
189
|
* `showLivenessCameraSwitchButton` -> `liveness_camera_switch=true|false`.
|
|
182
190
|
* How the SDK presents the flow is always added: `sdk_presentation=modal|embedded`
|
|
183
|
-
* and, in a modal, `sdk_close_button=true|false`.
|
|
191
|
+
* and, in a modal, `sdk_close_button=true|false`. `storedDeviceId`, when the
|
|
192
|
+
* page has one, is added as `sdk_device_id`.
|
|
184
193
|
* Each parameter is set (not appended) so the configuration wins over a value
|
|
185
194
|
* already on the URL; existing query parameters and the hash are kept. A
|
|
186
195
|
* value of the wrong shape is ignored with a warning rather than forwarded,
|
|
187
196
|
* and a URL the browser cannot parse is returned as it came (the modal
|
|
188
197
|
* reports it when it loads).
|
|
189
198
|
*/
|
|
190
|
-
function buildVerificationUrl(url, configuration = {}) {
|
|
199
|
+
function buildVerificationUrl(url, configuration = {}, storedDeviceId = null) {
|
|
191
200
|
const params = presentationParams(configuration);
|
|
201
|
+
// The id this page already keeps for Didit (see getStoredDeviceId): the flow in the frame, whose
|
|
202
|
+
// own storage the browser keeps apart from this page's, can then be told apart as the same
|
|
203
|
+
// device as this site's events. Absent when the page keeps none; nothing is created for it.
|
|
204
|
+
if (storedDeviceId)
|
|
205
|
+
params.push([DEVICE_ID_QUERY_PARAM, storedDeviceId]);
|
|
192
206
|
for (const option of CAMERA_LENS_OPTIONS) {
|
|
193
207
|
const value = configuration[option];
|
|
194
208
|
if (value === undefined)
|
|
@@ -694,6 +708,8 @@ function getTranslations(language) {
|
|
|
694
708
|
const SIZE_ANIMATION_MS = 300;
|
|
695
709
|
/** How long the modal waits for the first layout before it shows at step size, so it can never hang. */
|
|
696
710
|
const FIRST_LAYOUT_TIMEOUT_MS = 3000;
|
|
711
|
+
/** The flow's ground (site-ground in the design system), which a full-screen modal paints the page with. */
|
|
712
|
+
const FLOW_GROUND = { light: "#ffffff", dark: "#0b0b0d" };
|
|
697
713
|
class VerificationModal {
|
|
698
714
|
constructor(configuration, callbacks) {
|
|
699
715
|
this.state = {
|
|
@@ -716,10 +732,9 @@ class VerificationModal {
|
|
|
716
732
|
this.embedded = false;
|
|
717
733
|
this.embeddedContainer = null;
|
|
718
734
|
this.language = "en";
|
|
719
|
-
/** The
|
|
720
|
-
this.
|
|
721
|
-
|
|
722
|
-
this.previousBodyOverflow = null;
|
|
735
|
+
/** The ground below the layout viewport (see showCurtain), while this modal is open. */
|
|
736
|
+
this.curtain = null;
|
|
737
|
+
this.boundPlaceCurtain = null;
|
|
723
738
|
this.modalId = generateModalId();
|
|
724
739
|
this.config = {
|
|
725
740
|
zIndex: configuration?.zIndex ?? DEFAULT_CONFIG.zIndex,
|
|
@@ -813,13 +828,14 @@ class VerificationModal {
|
|
|
813
828
|
display: flex;
|
|
814
829
|
align-items: center;
|
|
815
830
|
justify-content: center;
|
|
816
|
-
|
|
831
|
+
/* The flow's ground, so a phone's loader meets the ground below the viewport without a seam. */
|
|
832
|
+
background: ${FLOW_GROUND.light};
|
|
817
833
|
z-index: 5;
|
|
818
834
|
}
|
|
819
835
|
|
|
820
836
|
@media (prefers-color-scheme: dark) {
|
|
821
837
|
.${CSS_CLASSES.loading} {
|
|
822
|
-
background:
|
|
838
|
+
background: ${FLOW_GROUND.dark};
|
|
823
839
|
}
|
|
824
840
|
}
|
|
825
841
|
|
|
@@ -1009,6 +1025,40 @@ class VerificationModal {
|
|
|
1009
1025
|
}
|
|
1010
1026
|
}
|
|
1011
1027
|
|
|
1028
|
+
/*
|
|
1029
|
+
* The flow's ground right below the layout viewport, in the page itself (see showCurtain):
|
|
1030
|
+
* on a phone, iOS browsers with their toolbars collapsed show a band of the page there,
|
|
1031
|
+
* below every fixed element, the full-screen modal included.
|
|
1032
|
+
*/
|
|
1033
|
+
.${CSS_CLASSES.curtain} {
|
|
1034
|
+
display: none;
|
|
1035
|
+
position: absolute;
|
|
1036
|
+
top: 0;
|
|
1037
|
+
left: 0;
|
|
1038
|
+
width: 100vw;
|
|
1039
|
+
height: 100vh;
|
|
1040
|
+
margin: 0;
|
|
1041
|
+
pointer-events: none;
|
|
1042
|
+
/* Under the modal where they meet for a frame while the toolbars move, above the page. */
|
|
1043
|
+
z-index: ${this.config.zIndex - 1};
|
|
1044
|
+
background: ${FLOW_GROUND.light};
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
.${CSS_CLASSES.curtain}[data-didit-theme="dark"] {
|
|
1048
|
+
background: ${FLOW_GROUND.dark};
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/* The exit confirmation's dimming continues over the ground below the viewport. */
|
|
1052
|
+
.${CSS_CLASSES.curtain}[data-didit-dimmed] {
|
|
1053
|
+
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
@media (max-width: 540px) {
|
|
1057
|
+
.${CSS_CLASSES.curtain} {
|
|
1058
|
+
display: block;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1012
1062
|
/*
|
|
1013
1063
|
* The hosted flow's layout message (didit:layout) brings the modal's size
|
|
1014
1064
|
* (see above), theme and direction. Colours are the design system tokens
|
|
@@ -1370,6 +1420,8 @@ class VerificationModal {
|
|
|
1370
1420
|
const shownHeight = this.container.offsetHeight;
|
|
1371
1421
|
this.container.style.setProperty("--didit-content-height", `${layout.contentHeight}px`);
|
|
1372
1422
|
this.matchPageBackground(layout.colorScheme);
|
|
1423
|
+
if (this.curtain)
|
|
1424
|
+
this.curtain.dataset.diditTheme = layout.colorScheme;
|
|
1373
1425
|
this.setModalKind(layout.kind, layout.kind === "handoff" && this.handoffHeight(layout) === shownHeight);
|
|
1374
1426
|
}
|
|
1375
1427
|
/** Whether the window is a computer-sized one: a phone is full screen and never waits for a layout. */
|
|
@@ -1440,18 +1492,125 @@ class VerificationModal {
|
|
|
1440
1492
|
matchPageBackground(colorScheme) {
|
|
1441
1493
|
if (!window.matchMedia?.("(max-width: 540px)").matches)
|
|
1442
1494
|
return;
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1495
|
+
VerificationModal.pageBackground ?? (VerificationModal.pageBackground = {
|
|
1496
|
+
saved: { root: document.documentElement.style.backgroundColor, body: document.body.style.backgroundColor },
|
|
1497
|
+
grounds: new Map()
|
|
1498
|
+
});
|
|
1499
|
+
VerificationModal.pageBackground.grounds.set(this, colorScheme);
|
|
1500
|
+
VerificationModal.paintPageBackground();
|
|
1448
1501
|
}
|
|
1449
1502
|
restorePageBackground() {
|
|
1450
|
-
|
|
1503
|
+
const background = VerificationModal.pageBackground;
|
|
1504
|
+
if (!background?.grounds.delete(this))
|
|
1505
|
+
return;
|
|
1506
|
+
if (background.grounds.size > 0) {
|
|
1507
|
+
VerificationModal.paintPageBackground();
|
|
1451
1508
|
return;
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1509
|
+
}
|
|
1510
|
+
VerificationModal.pageBackground = null;
|
|
1511
|
+
document.documentElement.style.backgroundColor = background.saved.root;
|
|
1512
|
+
document.body.style.backgroundColor = background.saved.body;
|
|
1513
|
+
}
|
|
1514
|
+
/** The page shows the ground of the topmost open modal that lends one. */
|
|
1515
|
+
static paintPageBackground() {
|
|
1516
|
+
const background = VerificationModal.pageBackground;
|
|
1517
|
+
if (!background)
|
|
1518
|
+
return;
|
|
1519
|
+
const lender = [...VerificationModal.openModals].reverse().find((modal) => background.grounds.has(modal));
|
|
1520
|
+
const colorScheme = lender ? background.grounds.get(lender) : [...background.grounds.values()].pop();
|
|
1521
|
+
if (!colorScheme)
|
|
1522
|
+
return;
|
|
1523
|
+
document.documentElement.style.backgroundColor = FLOW_GROUND[colorScheme];
|
|
1524
|
+
document.body.style.backgroundColor = FLOW_GROUND[colorScheme];
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Stops the page scrolling under the modal. The lock is on the root element: Chrome for iOS keeps
|
|
1528
|
+
* scrolling a page whose body alone is `overflow: hidden` (a swipe over the modal scrolls the page
|
|
1529
|
+
* and toggles the browser's toolbars), and stops only when the root element is. A page that
|
|
1530
|
+
* scrolls its body instead of the window has its body locked too. The first modal to open keeps
|
|
1531
|
+
* the page's own values and the last one to close gives them back.
|
|
1532
|
+
*/
|
|
1533
|
+
lockPageScroll() {
|
|
1534
|
+
const lock = VerificationModal.pageScrollLock;
|
|
1535
|
+
if (lock) {
|
|
1536
|
+
lock.holders.add(this);
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
const root = document.documentElement;
|
|
1540
|
+
const body = document.body;
|
|
1541
|
+
// The body's overflow is the viewport's only while the root's is visible; otherwise a body with
|
|
1542
|
+
// an overflow of its own is a scroll container. Locking a body that is not one would clip the page
|
|
1543
|
+
// to the body's box.
|
|
1544
|
+
const clips = (overflow) => overflow !== "" && overflow !== "visible";
|
|
1545
|
+
const bodyScrollsItself = clips(window.getComputedStyle(root).overflowY) && clips(window.getComputedStyle(body).overflowY);
|
|
1546
|
+
VerificationModal.pageScrollLock = {
|
|
1547
|
+
holders: new Set([this]),
|
|
1548
|
+
root: { overflow: root.style.overflow, overscrollBehavior: root.style.overscrollBehavior },
|
|
1549
|
+
body: bodyScrollsItself ? { overflow: body.style.overflow } : null
|
|
1550
|
+
};
|
|
1551
|
+
root.style.overflow = "hidden";
|
|
1552
|
+
root.style.overscrollBehavior = "none";
|
|
1553
|
+
if (bodyScrollsItself)
|
|
1554
|
+
body.style.overflow = "hidden";
|
|
1555
|
+
}
|
|
1556
|
+
unlockPageScroll() {
|
|
1557
|
+
const lock = VerificationModal.pageScrollLock;
|
|
1558
|
+
if (!lock || !lock.holders.delete(this) || lock.holders.size > 0)
|
|
1559
|
+
return;
|
|
1560
|
+
VerificationModal.pageScrollLock = null;
|
|
1561
|
+
const root = document.documentElement;
|
|
1562
|
+
root.style.overflow = lock.root.overflow;
|
|
1563
|
+
root.style.overscrollBehavior = lock.root.overscrollBehavior;
|
|
1564
|
+
if (lock.body)
|
|
1565
|
+
document.body.style.overflow = lock.body.overflow;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* On a phone, Chrome for iOS (and the other iOS browsers built on WebKit's web view) shows a band
|
|
1569
|
+
* of the page below the layout viewport while its toolbars are collapsed: the home indicator's
|
|
1570
|
+
* area, and more while the toolbars move. Fixed elements end at the layout viewport, so the
|
|
1571
|
+
* full-screen modal cannot cover it and the host page's own content showed under the flow. The
|
|
1572
|
+
* curtain is part of the page instead: right below the viewport, in the flow's ground, so that band
|
|
1573
|
+
* shows the modal's ground. The page cannot scroll while the modal is open (lockPageScroll), and the
|
|
1574
|
+
* curtain follows the viewport when it resizes. Only phone-sized windows draw it (see the styles).
|
|
1575
|
+
*/
|
|
1576
|
+
showCurtain() {
|
|
1577
|
+
if (!this.curtain) {
|
|
1578
|
+
const curtain = document.createElement("div");
|
|
1579
|
+
curtain.className = CSS_CLASSES.curtain;
|
|
1580
|
+
curtain.setAttribute("aria-hidden", "true");
|
|
1581
|
+
document.body.appendChild(curtain);
|
|
1582
|
+
this.curtain = curtain;
|
|
1583
|
+
this.boundPlaceCurtain = () => this.placeCurtain();
|
|
1584
|
+
window.addEventListener("resize", this.boundPlaceCurtain);
|
|
1585
|
+
window.addEventListener("scroll", this.boundPlaceCurtain);
|
|
1586
|
+
window.visualViewport?.addEventListener("resize", this.boundPlaceCurtain);
|
|
1587
|
+
}
|
|
1588
|
+
// The device's theme until the newly loaded flow reports its own (applyFlowLayout).
|
|
1589
|
+
this.curtain.dataset.diditTheme = window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1590
|
+
this.placeCurtain();
|
|
1591
|
+
}
|
|
1592
|
+
/** Puts the curtain's top at the bottom of the layout viewport, whatever its containing block is. */
|
|
1593
|
+
placeCurtain() {
|
|
1594
|
+
const curtain = this.curtain;
|
|
1595
|
+
if (!curtain)
|
|
1596
|
+
return;
|
|
1597
|
+
curtain.style.top = "0px";
|
|
1598
|
+
curtain.style.left = "0px";
|
|
1599
|
+
// At 0, 0 the curtain's box starts at its containing block's corner (the page's, or a positioned
|
|
1600
|
+
// body's), in viewport coordinates: the offset that brings its top to the viewport's bottom edge.
|
|
1601
|
+
const origin = curtain.getBoundingClientRect();
|
|
1602
|
+
curtain.style.top = `${window.innerHeight - origin.top}px`;
|
|
1603
|
+
curtain.style.left = `${-origin.left}px`;
|
|
1604
|
+
}
|
|
1605
|
+
removeCurtain() {
|
|
1606
|
+
if (this.boundPlaceCurtain) {
|
|
1607
|
+
window.removeEventListener("resize", this.boundPlaceCurtain);
|
|
1608
|
+
window.removeEventListener("scroll", this.boundPlaceCurtain);
|
|
1609
|
+
window.visualViewport?.removeEventListener("resize", this.boundPlaceCurtain);
|
|
1610
|
+
this.boundPlaceCurtain = null;
|
|
1611
|
+
}
|
|
1612
|
+
this.curtain?.remove();
|
|
1613
|
+
this.curtain = null;
|
|
1455
1614
|
}
|
|
1456
1615
|
/** Back to the neutral look until the newly loaded flow reports its theme and direction. */
|
|
1457
1616
|
resetFlowLayout() {
|
|
@@ -1529,6 +1688,7 @@ class VerificationModal {
|
|
|
1529
1688
|
: this.container?.querySelector(`.${CSS_CLASSES.closeButton}`) ?? this.iframe);
|
|
1530
1689
|
this.state.showConfirmation = true;
|
|
1531
1690
|
this.confirmOverlay.classList.add("active");
|
|
1691
|
+
this.curtain?.setAttribute("data-didit-dimmed", "");
|
|
1532
1692
|
if (this.iframe)
|
|
1533
1693
|
this.iframe.inert = true;
|
|
1534
1694
|
const close = this.container?.querySelector(`.${CSS_CLASSES.closeButton}`);
|
|
@@ -1552,6 +1712,7 @@ class VerificationModal {
|
|
|
1552
1712
|
return;
|
|
1553
1713
|
this.state.showConfirmation = false;
|
|
1554
1714
|
this.confirmOverlay?.classList.remove("active");
|
|
1715
|
+
this.curtain?.removeAttribute("data-didit-dimmed");
|
|
1555
1716
|
if (this.iframe)
|
|
1556
1717
|
this.iframe.inert = false;
|
|
1557
1718
|
const close = this.container?.querySelector(`.${CSS_CLASSES.closeButton}`);
|
|
@@ -1579,11 +1740,6 @@ class VerificationModal {
|
|
|
1579
1740
|
this.callbacks.onCloseConfirmed();
|
|
1580
1741
|
}
|
|
1581
1742
|
open(verificationUrl) {
|
|
1582
|
-
// Whether this modal already held its scroll lock before this call. Re-opening
|
|
1583
|
-
// an already-open instance must not re-capture previousBodyOverflow, or it
|
|
1584
|
-
// would record this modal's own "hidden" lock and close() could never restore
|
|
1585
|
-
// the real pre-lock value.
|
|
1586
|
-
const wasAlreadyOpen = this.state.isOpen;
|
|
1587
1743
|
this.language = detectLanguageFromUrl(verificationUrl);
|
|
1588
1744
|
if (!this.overlay && !this.container) {
|
|
1589
1745
|
this.createDOM();
|
|
@@ -1608,16 +1764,10 @@ class VerificationModal {
|
|
|
1608
1764
|
return;
|
|
1609
1765
|
}
|
|
1610
1766
|
this.overlay?.classList.add("active");
|
|
1611
|
-
//
|
|
1612
|
-
//
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
// in effect is this modal's own lock, and previousBodyOverflow already
|
|
1616
|
-
// holds the correct pre-lock value.
|
|
1617
|
-
if (!wasAlreadyOpen) {
|
|
1618
|
-
this.previousBodyOverflow = document.body.style.overflow;
|
|
1619
|
-
}
|
|
1620
|
-
document.body.style.overflow = "hidden";
|
|
1767
|
+
// Idempotent: a re-open of a modal that is still open keeps its one hold on the lock, so
|
|
1768
|
+
// close() still gives the page back the values it had before any modal opened.
|
|
1769
|
+
this.lockPageScroll();
|
|
1770
|
+
this.showCurtain();
|
|
1621
1771
|
}
|
|
1622
1772
|
close() {
|
|
1623
1773
|
SDKLogger.log("Closing");
|
|
@@ -1635,8 +1785,8 @@ class VerificationModal {
|
|
|
1635
1785
|
return;
|
|
1636
1786
|
}
|
|
1637
1787
|
this.overlay?.classList.remove("active");
|
|
1638
|
-
|
|
1639
|
-
this.
|
|
1788
|
+
this.removeCurtain();
|
|
1789
|
+
this.unlockPageScroll();
|
|
1640
1790
|
}
|
|
1641
1791
|
destroy() {
|
|
1642
1792
|
SDKLogger.log("Destroying");
|
|
@@ -1668,6 +1818,16 @@ class VerificationModal {
|
|
|
1668
1818
|
* a transaction action modal stacked over the verification modal).
|
|
1669
1819
|
*/
|
|
1670
1820
|
VerificationModal.openModals = [];
|
|
1821
|
+
/**
|
|
1822
|
+
* The page's own background colours, kept while full-screen modals lend it their ground, shared by
|
|
1823
|
+
* every open modal: the topmost one's ground shows and the last one to give it back restores them.
|
|
1824
|
+
*/
|
|
1825
|
+
VerificationModal.pageBackground = null;
|
|
1826
|
+
/**
|
|
1827
|
+
* The page's scroll styles from before the first open modal locked them, shared by every open
|
|
1828
|
+
* modal: the last one to close gives them back.
|
|
1829
|
+
*/
|
|
1830
|
+
VerificationModal.pageScrollLock = null;
|
|
1671
1831
|
|
|
1672
1832
|
const DEFAULT_TRANSACTION_BASE_URL = "https://verification.didit.me";
|
|
1673
1833
|
const ACTION_POLL_INTERVAL_MS = 1500;
|
|
@@ -1987,6 +2147,18 @@ function assertEmbeddedHostExists(configuration) {
|
|
|
1987
2147
|
throw new Error(`Embedded container "#${containerId}" was not found in the page.`);
|
|
1988
2148
|
}
|
|
1989
2149
|
}
|
|
2150
|
+
/**
|
|
2151
|
+
* The device id this page already keeps for Didit (it has sent events, transactions or sign-ins),
|
|
2152
|
+
* or null. Reading it never creates one, and a browser that refuses the read is not an error.
|
|
2153
|
+
*/
|
|
2154
|
+
function storedDeviceId() {
|
|
2155
|
+
try {
|
|
2156
|
+
return signals.getStoredDeviceId();
|
|
2157
|
+
}
|
|
2158
|
+
catch {
|
|
2159
|
+
return null;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
1990
2162
|
class DiditSdk {
|
|
1991
2163
|
static get shared() {
|
|
1992
2164
|
if (!DiditSdk._instance) {
|
|
@@ -2060,7 +2232,7 @@ class DiditSdk {
|
|
|
2060
2232
|
onMessage: (event) => this.handleVerificationEvent(event),
|
|
2061
2233
|
onIframeLoad: () => this.handleIframeLoad()
|
|
2062
2234
|
});
|
|
2063
|
-
this._url = buildVerificationUrl(url, config);
|
|
2235
|
+
this._url = buildVerificationUrl(url, config, storedDeviceId());
|
|
2064
2236
|
this.setState("loading");
|
|
2065
2237
|
this.emitInternalEvent("didit:started", {});
|
|
2066
2238
|
this._modal?.open(this._url);
|