@zoreal/oauth2-js 0.1.21 → 0.1.23

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/dist/index.d.cts CHANGED
@@ -328,7 +328,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
328
328
  * auth-code mode leaves it to the RP backend.
329
329
  */
330
330
  declare const WIRE_VERSION = 1;
331
- declare const SDK_VERSION = "0.1.21";
331
+ declare const SDK_VERSION = "0.1.23";
332
332
  declare const SDK_NAME = "@zoreal/oauth2-js";
333
333
  declare const DEFAULT_ISSUER = "https://id.zoreal.com";
334
334
  /** Pending TTL is short. Poll gently; over-polling cancels the request. */
package/dist/index.d.ts CHANGED
@@ -328,7 +328,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
328
328
  * auth-code mode leaves it to the RP backend.
329
329
  */
330
330
  declare const WIRE_VERSION = 1;
331
- declare const SDK_VERSION = "0.1.21";
331
+ declare const SDK_VERSION = "0.1.23";
332
332
  declare const SDK_NAME = "@zoreal/oauth2-js";
333
333
  declare const DEFAULT_ISSUER = "https://id.zoreal.com";
334
334
  /** Pending TTL is short. Poll gently; over-polling cancels the request. */
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ function unsafeClaims(idToken) {
14
14
 
15
15
  // src/wire.ts
16
16
  var WIRE_VERSION = 1;
17
- var SDK_VERSION = "0.1.21";
17
+ var SDK_VERSION = "0.1.23";
18
18
  var SDK_NAME = "@zoreal/oauth2-js";
19
19
  var DEFAULT_ISSUER = "https://id.zoreal.com";
20
20
  var POLL_INTERVAL_MS = 2e3;
@@ -670,9 +670,16 @@ var SVG_NS = "http://www.w3.org/2000/svg";
670
670
  var TAIL = 0.3;
671
671
  var STACK = Array.from({ length: 12 }, (_, i) => 12 - i);
672
672
  var HALO = [3, 2, 1];
673
- function radiusOf(control) {
674
- const value = parseFloat(getComputedStyle(control).borderTopLeftRadius);
675
- return Number.isFinite(value) ? value : 8;
673
+ function cornerOf(radius, width, height) {
674
+ const raw = radius.trim();
675
+ const value = parseFloat(raw);
676
+ const offset = 2;
677
+ if (raw.endsWith("%") && Number.isFinite(value)) {
678
+ return [width * value / 100 + offset, height * value / 100 + offset];
679
+ }
680
+ const px = Number.isFinite(value) ? value : /infinity/i.test(raw) ? Infinity : 8;
681
+ const r = Math.min(px, width / 2, height / 2) + offset;
682
+ return [r, r];
676
683
  }
677
684
  function holdBusy(control) {
678
685
  if (typeof document === "undefined") return () => {
@@ -693,12 +700,11 @@ function holdBusy(control) {
693
700
  overlay.setAttribute("aria-hidden", "true");
694
701
  const svg2 = document.createElementNS(SVG_NS, "svg");
695
702
  svg2.setAttribute("class", cx("ring-svg"));
696
- const rx = radiusOf(control) + 2;
703
+ const rects = [];
697
704
  const layer = (name, len, alpha) => {
698
705
  const rect = document.createElementNS(SVG_NS, "rect");
699
706
  rect.setAttribute("class", cx(name));
700
- rect.setAttribute("rx", String(rx));
701
- rect.setAttribute("ry", String(rx));
707
+ rects.push(rect);
702
708
  rect.style.strokeDasharray = `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`;
703
709
  rect.style.setProperty("--zrl-s", `calc(var(--zrl-l) * ${-(TAIL - len)})`);
704
710
  rect.style.opacity = alpha;
@@ -721,6 +727,11 @@ function holdBusy(control) {
721
727
  overlay.style.top = `${box.top}px`;
722
728
  overlay.style.width = `${box.width}px`;
723
729
  overlay.style.height = `${box.height}px`;
730
+ const [rx, ry] = cornerOf(getComputedStyle(control).borderTopLeftRadius, box.width, box.height);
731
+ for (const rect of rects) {
732
+ rect.setAttribute("rx", String(rx));
733
+ rect.setAttribute("ry", String(ry));
734
+ }
724
735
  const length = typeof measured?.getTotalLength === "function" ? measured.getTotalLength() : 0;
725
736
  if (length > 0) overlay.style.setProperty("--zrl-ring-len", `${length}px`);
726
737
  };
@@ -816,6 +827,30 @@ function markReturnDone(requestId) {
816
827
  function isReturnDone(requestId) {
817
828
  return storage()?.getItem(DONE + requestId) !== null && storage()?.getItem(DONE + requestId) !== void 0;
818
829
  }
830
+ function visibleOrDone(requestId, signal) {
831
+ if (typeof document === "undefined" || document.visibilityState !== "hidden") {
832
+ return Promise.resolve(!isReturnDone(requestId));
833
+ }
834
+ return new Promise((resolve) => {
835
+ const finish = (value) => {
836
+ document.removeEventListener("visibilitychange", onVisible);
837
+ window.removeEventListener("storage", onStorage);
838
+ signal?.removeEventListener("abort", onAbort);
839
+ resolve(value);
840
+ };
841
+ const onVisible = () => {
842
+ if (document.visibilityState !== "hidden") finish(!isReturnDone(requestId));
843
+ };
844
+ const onStorage = () => {
845
+ if (isReturnDone(requestId)) finish(false);
846
+ };
847
+ const onAbort = () => finish(false);
848
+ document.addEventListener("visibilitychange", onVisible);
849
+ window.addEventListener("storage", onStorage);
850
+ signal?.addEventListener("abort", onAbort, { once: true });
851
+ if (isReturnDone(requestId)) finish(false);
852
+ });
853
+ }
819
854
  function returnToUrl() {
820
855
  if (typeof window === "undefined") return void 0;
821
856
  const { href } = window.location;
@@ -2127,7 +2162,7 @@ function startLogin(options) {
2127
2162
  controller.signal,
2128
2163
  { tolerateUnknownUntil: Date.now() + 15e3 }
2129
2164
  );
2130
- if (isReturnDone(requestId)) {
2165
+ if (!await visibleOrDone(requestId, controller.signal)) {
2131
2166
  throw new DOMException("aborted", "AbortError");
2132
2167
  }
2133
2168
  } else {