@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.
@@ -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
  */
@@ -1054,7 +1054,7 @@
1054
1054
  embedded: "didit-embedded",
1055
1055
  curtain: "didit-modal-curtain"
1056
1056
  };
1057
- const SDK_VERSION = "0.6.0";
1057
+ const SDK_VERSION = "0.7.0";
1058
1058
  /**
1059
1059
  * The permissions the verification iframe gets, in a modal and embedded:
1060
1060
  * camera and microphone for capture, clipboard-write for the flow's copy
@@ -1733,6 +1733,8 @@
1733
1733
  const SIZE_ANIMATION_MS = 300;
1734
1734
  /** How long the modal waits for the first layout before it shows at step size, so it can never hang. */
1735
1735
  const FIRST_LAYOUT_TIMEOUT_MS = 3000;
1736
+ /** A strip is a line or two of text: a taller value is not one, and would push the close button out of reach. */
1737
+ const MAX_TOP_INSET = 160;
1736
1738
  /** The flow's ground (site-ground in the design system), which a full-screen modal paints the page with. */
1737
1739
  const FLOW_GROUND = { light: "#ffffff", dark: "#0b0b0d" };
1738
1740
  class VerificationModal {
@@ -2116,7 +2118,7 @@
2116
2118
  }
2117
2119
 
2118
2120
  .${CSS_CLASSES.flowSized} .${CSS_CLASSES.closeButton} {
2119
- top: 8px;
2121
+ top: calc(8px + var(--didit-top-inset, 0px));
2120
2122
  right: 8px;
2121
2123
  width: 44px;
2122
2124
  height: 44px;
@@ -2417,11 +2419,12 @@
2417
2419
  /**
2418
2420
  * Reads a didit:layout message's data. Without a positive contentHeight the
2419
2421
  * message is ignored; a missing or unknown colorScheme follows the device,
2420
- * and a missing or unknown dir follows the verification URL's language.
2422
+ * a missing or unknown dir follows the verification URL's language, and the
2423
+ * close button keeps its place without a plausible topInset.
2421
2424
  */
2422
2425
  readFlowLayout(data) {
2423
2426
  const fields = typeof data === "object" && data !== null ? data : {};
2424
- const { contentHeight, colorScheme, dir, kind } = fields;
2427
+ const { contentHeight, colorScheme, dir, kind, topInset } = fields;
2425
2428
  if (typeof contentHeight !== "number" || !Number.isFinite(contentHeight) || contentHeight <= 0) {
2426
2429
  return null;
2427
2430
  }
@@ -2430,7 +2433,8 @@
2430
2433
  kind: kind === "handoff" ? "handoff" : "step",
2431
2434
  contentHeight: Math.ceil(contentHeight),
2432
2435
  colorScheme: colorScheme === "light" || colorScheme === "dark" ? colorScheme : prefersDark ? "dark" : "light",
2433
- dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr"
2436
+ dir: dir === "ltr" || dir === "rtl" ? dir : isRtlLanguage(this.language) ? "rtl" : "ltr",
2437
+ topInset: typeof topInset === "number" && topInset > 0 && topInset <= MAX_TOP_INSET ? Math.ceil(topInset) : 0
2434
2438
  };
2435
2439
  }
2436
2440
  /** Embedded mode keeps filling the integrator's host element, whatever the flow reports. */
@@ -2444,6 +2448,8 @@
2444
2448
  // The height the person sees now, before the reported content height can change it.
2445
2449
  const shownHeight = this.container.offsetHeight;
2446
2450
  this.container.style.setProperty("--didit-content-height", `${layout.contentHeight}px`);
2451
+ // The close button sits under the flow's strip, over its top bar.
2452
+ this.container.style.setProperty("--didit-top-inset", `${layout.topInset}px`);
2447
2453
  this.matchPageBackground(layout.colorScheme);
2448
2454
  if (this.curtain)
2449
2455
  this.curtain.dataset.diditTheme = layout.colorScheme;
@@ -2647,6 +2653,7 @@
2647
2653
  delete this.container.dataset.diditDir;
2648
2654
  delete this.container.dataset.diditKind;
2649
2655
  this.container.style.removeProperty("--didit-content-height");
2656
+ this.container.style.removeProperty("--didit-top-inset");
2650
2657
  if (this.firstLayoutTimeout !== null) {
2651
2658
  window.clearTimeout(this.firstLayoutTimeout);
2652
2659
  this.firstLayoutTimeout = null;