@didit-protocol/sdk-web 0.6.0 → 0.7.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 CHANGED
@@ -267,7 +267,7 @@ Browsers that support dynamic viewport units use `dvh`, while older supported br
267
267
 
268
268
  When the hosted verification page reports its layout with a `didit:layout` message, the modal takes the page's light or dark theme and its text direction. Its `kind` field (`handoff` or `step`, `step` when missing) sets the modal's size as described above.
269
269
 
270
- The close button becomes a 44px circle over the page's top bar. It follows the page's light or dark theme and moves to the left for right-to-left languages. If a large text size makes the exit confirmation taller than a short page, the confirmation scrolls inside the modal. Pages that never report a layout get the phone-shaped size. Embedded mode keeps filling its host element. There is nothing to configure, and every existing option keeps working.
270
+ The close button becomes a 44px circle over the page's top bar. It follows the page's light or dark theme, moves to the left for right-to-left languages, and sits under the strip a sandbox session shows above its top bar (the message's `topInset`). If a large text size makes the exit confirmation taller than a short page, the confirmation scrolls inside the modal. Pages that never report a layout get the phone-shaped size. Embedded mode keeps filling its host element. There is nothing to configure, and every existing option keeps working.
271
271
 
272
272
  The SDK tells the page how it is shown with two query parameters on the verification URL: `sdk_presentation` (`modal` or `embedded`) and, in a modal, `sdk_close_button` (`true` or `false`, following `showCloseButton`). The SDK handles the `didit:layout` message itself and does not pass it to `onEvent`.
273
273
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Didit SDK for Web v0.6.0
2
+ * Didit SDK for Web v0.7.0
3
3
  * (c) 2026 Didit
4
4
  * @license MIT
5
5
  */
@@ -29,7 +29,7 @@ const CSS_CLASSES = {
29
29
  embedded: "didit-embedded",
30
30
  curtain: "didit-modal-curtain"
31
31
  };
32
- const SDK_VERSION = "0.6.0";
32
+ const SDK_VERSION = "0.7.0";
33
33
  /**
34
34
  * The permissions the verification iframe gets, in a modal and embedded:
35
35
  * camera and microphone for capture, clipboard-write for the flow's copy
@@ -708,6 +708,8 @@ function getTranslations(language) {
708
708
  const SIZE_ANIMATION_MS = 300;
709
709
  /** How long the modal waits for the first layout before it shows at step size, so it can never hang. */
710
710
  const FIRST_LAYOUT_TIMEOUT_MS = 3000;
711
+ /** A strip is a line or two of text: a taller value is not one, and would push the close button out of reach. */
712
+ const MAX_TOP_INSET = 160;
711
713
  /** The flow's ground (site-ground in the design system), which a full-screen modal paints the page with. */
712
714
  const FLOW_GROUND = { light: "#ffffff", dark: "#0b0b0d" };
713
715
  class VerificationModal {
@@ -1091,7 +1093,7 @@ class VerificationModal {
1091
1093
  }
1092
1094
 
1093
1095
  .${CSS_CLASSES.flowSized} .${CSS_CLASSES.closeButton} {
1094
- top: 8px;
1096
+ top: calc(8px + var(--didit-top-inset, 0px));
1095
1097
  right: 8px;
1096
1098
  width: 44px;
1097
1099
  height: 44px;
@@ -1392,11 +1394,12 @@ class VerificationModal {
1392
1394
  /**
1393
1395
  * Reads a didit:layout message's data. Without a positive contentHeight the
1394
1396
  * message is ignored; a missing or unknown colorScheme follows the device,
1395
- * and a missing or unknown dir follows the verification URL's language.
1397
+ * a missing or unknown dir follows the verification URL's language, and the
1398
+ * close button keeps its place without a plausible topInset.
1396
1399
  */
1397
1400
  readFlowLayout(data) {
1398
1401
  const fields = typeof data === "object" && data !== null ? data : {};
1399
- const { contentHeight, colorScheme, dir, kind } = fields;
1402
+ const { contentHeight, colorScheme, dir, kind, topInset } = fields;
1400
1403
  if (typeof contentHeight !== "number" || !Number.isFinite(contentHeight) || contentHeight <= 0) {
1401
1404
  return null;
1402
1405
  }
@@ -1405,7 +1408,8 @@ class VerificationModal {
1405
1408
  kind: kind === "handoff" ? "handoff" : "step",
1406
1409
  contentHeight: Math.ceil(contentHeight),
1407
1410
  colorScheme: colorScheme === "light" || colorScheme === "dark" ? colorScheme : prefersDark ? "dark" : "light",
1408
- dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr"
1411
+ dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr",
1412
+ topInset: typeof topInset === "number" && topInset > 0 && topInset <= MAX_TOP_INSET ? Math.ceil(topInset) : 0
1409
1413
  };
1410
1414
  }
1411
1415
  /** Embedded mode keeps filling the integrator's host element, whatever the flow reports. */
@@ -1419,6 +1423,8 @@ class VerificationModal {
1419
1423
  // The height the person sees now, before the reported content height can change it.
1420
1424
  const shownHeight = this.container.offsetHeight;
1421
1425
  this.container.style.setProperty("--didit-content-height", `${layout.contentHeight}px`);
1426
+ // The close button sits under the flow's strip, over its top bar.
1427
+ this.container.style.setProperty("--didit-top-inset", `${layout.topInset}px`);
1422
1428
  this.matchPageBackground(layout.colorScheme);
1423
1429
  if (this.curtain)
1424
1430
  this.curtain.dataset.diditTheme = layout.colorScheme;
@@ -1622,6 +1628,7 @@ class VerificationModal {
1622
1628
  delete this.container.dataset.diditDir;
1623
1629
  delete this.container.dataset.diditKind;
1624
1630
  this.container.style.removeProperty("--didit-content-height");
1631
+ this.container.style.removeProperty("--didit-top-inset");
1625
1632
  if (this.firstLayoutTimeout !== null) {
1626
1633
  window.clearTimeout(this.firstLayoutTimeout);
1627
1634
  this.firstLayoutTimeout = null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Didit SDK for Web v0.6.0
2
+ * Didit SDK for Web v0.7.0
3
3
  * (c) 2026 Didit
4
4
  * @license MIT
5
5
  */
@@ -29,7 +29,7 @@ const CSS_CLASSES = {
29
29
  embedded: "didit-embedded",
30
30
  curtain: "didit-modal-curtain"
31
31
  };
32
- const SDK_VERSION = "0.6.0";
32
+ const SDK_VERSION = "0.7.0";
33
33
  /**
34
34
  * The permissions the verification iframe gets, in a modal and embedded:
35
35
  * camera and microphone for capture, clipboard-write for the flow's copy
@@ -708,6 +708,8 @@ function getTranslations(language) {
708
708
  const SIZE_ANIMATION_MS = 300;
709
709
  /** How long the modal waits for the first layout before it shows at step size, so it can never hang. */
710
710
  const FIRST_LAYOUT_TIMEOUT_MS = 3000;
711
+ /** A strip is a line or two of text: a taller value is not one, and would push the close button out of reach. */
712
+ const MAX_TOP_INSET = 160;
711
713
  /** The flow's ground (site-ground in the design system), which a full-screen modal paints the page with. */
712
714
  const FLOW_GROUND = { light: "#ffffff", dark: "#0b0b0d" };
713
715
  class VerificationModal {
@@ -1091,7 +1093,7 @@ class VerificationModal {
1091
1093
  }
1092
1094
 
1093
1095
  .${CSS_CLASSES.flowSized} .${CSS_CLASSES.closeButton} {
1094
- top: 8px;
1096
+ top: calc(8px + var(--didit-top-inset, 0px));
1095
1097
  right: 8px;
1096
1098
  width: 44px;
1097
1099
  height: 44px;
@@ -1392,11 +1394,12 @@ class VerificationModal {
1392
1394
  /**
1393
1395
  * Reads a didit:layout message's data. Without a positive contentHeight the
1394
1396
  * message is ignored; a missing or unknown colorScheme follows the device,
1395
- * and a missing or unknown dir follows the verification URL's language.
1397
+ * a missing or unknown dir follows the verification URL's language, and the
1398
+ * close button keeps its place without a plausible topInset.
1396
1399
  */
1397
1400
  readFlowLayout(data) {
1398
1401
  const fields = typeof data === "object" && data !== null ? data : {};
1399
- const { contentHeight, colorScheme, dir, kind } = fields;
1402
+ const { contentHeight, colorScheme, dir, kind, topInset } = fields;
1400
1403
  if (typeof contentHeight !== "number" || !Number.isFinite(contentHeight) || contentHeight <= 0) {
1401
1404
  return null;
1402
1405
  }
@@ -1405,7 +1408,8 @@ class VerificationModal {
1405
1408
  kind: kind === "handoff" ? "handoff" : "step",
1406
1409
  contentHeight: Math.ceil(contentHeight),
1407
1410
  colorScheme: colorScheme === "light" || colorScheme === "dark" ? colorScheme : prefersDark ? "dark" : "light",
1408
- dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr"
1411
+ dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr",
1412
+ topInset: typeof topInset === "number" && topInset > 0 && topInset <= MAX_TOP_INSET ? Math.ceil(topInset) : 0
1409
1413
  };
1410
1414
  }
1411
1415
  /** Embedded mode keeps filling the integrator's host element, whatever the flow reports. */
@@ -1419,6 +1423,8 @@ class VerificationModal {
1419
1423
  // The height the person sees now, before the reported content height can change it.
1420
1424
  const shownHeight = this.container.offsetHeight;
1421
1425
  this.container.style.setProperty("--didit-content-height", `${layout.contentHeight}px`);
1426
+ // The close button sits under the flow's strip, over its top bar.
1427
+ this.container.style.setProperty("--didit-top-inset", `${layout.topInset}px`);
1422
1428
  this.matchPageBackground(layout.colorScheme);
1423
1429
  if (this.curtain)
1424
1430
  this.curtain.dataset.diditTheme = layout.colorScheme;
@@ -1622,6 +1628,7 @@ class VerificationModal {
1622
1628
  delete this.container.dataset.diditDir;
1623
1629
  delete this.container.dataset.diditKind;
1624
1630
  this.container.style.removeProperty("--didit-content-height");
1631
+ this.container.style.removeProperty("--didit-top-inset");
1625
1632
  if (this.firstLayoutTimeout !== null) {
1626
1633
  window.clearTimeout(this.firstLayoutTimeout);
1627
1634
  this.firstLayoutTimeout = null;