@zoreal/oauth2-js 0.1.22 → 0.1.24

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
@@ -159,7 +159,8 @@ interface StartLoginOptions {
159
159
  theme?: ZorealTheme;
160
160
  /**
161
161
  * How long the modal stays open before giving up and cancelling, in ms.
162
- * Defaults to 120000. The provider's own expiry wins when it is shorter.
162
+ * Defaults to the provider's own expiry (five minutes today), or 300000
163
+ * when it states none; a shorter value of yours wins.
163
164
  */
164
165
  pairingTimeoutMs?: number;
165
166
  }
@@ -243,8 +244,12 @@ declare function resumeLogin(options: Pick<StartLoginOptions, 'clientId' | 'issu
243
244
  * settles. Callers who want their own UI pass `pairingUI: 'none'`.
244
245
  */
245
246
 
246
- /** Our own cap on how long a pairing sits on screen. See `pairingTimeoutMs`. */
247
- declare const DEFAULT_PAIRING_TIMEOUT_MS = 120000;
247
+ /**
248
+ * How long a pairing sits on screen when the provider states no expiry of
249
+ * its own. The provider does state one (`expires_in`, five minutes today),
250
+ * and that is the deadline unless the site sets a shorter `pairingTimeoutMs`.
251
+ */
252
+ declare const DEFAULT_PAIRING_TIMEOUT_MS = 300000;
248
253
  interface PairingModalOptions {
249
254
  onCancel: () => void;
250
255
  locale?: string;
@@ -328,7 +333,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
328
333
  * auth-code mode leaves it to the RP backend.
329
334
  */
330
335
  declare const WIRE_VERSION = 1;
331
- declare const SDK_VERSION = "0.1.22";
336
+ declare const SDK_VERSION = "0.1.24";
332
337
  declare const SDK_NAME = "@zoreal/oauth2-js";
333
338
  declare const DEFAULT_ISSUER = "https://id.zoreal.com";
334
339
  /** Pending TTL is short. Poll gently; over-polling cancels the request. */
package/dist/index.d.ts CHANGED
@@ -159,7 +159,8 @@ interface StartLoginOptions {
159
159
  theme?: ZorealTheme;
160
160
  /**
161
161
  * How long the modal stays open before giving up and cancelling, in ms.
162
- * Defaults to 120000. The provider's own expiry wins when it is shorter.
162
+ * Defaults to the provider's own expiry (five minutes today), or 300000
163
+ * when it states none; a shorter value of yours wins.
163
164
  */
164
165
  pairingTimeoutMs?: number;
165
166
  }
@@ -243,8 +244,12 @@ declare function resumeLogin(options: Pick<StartLoginOptions, 'clientId' | 'issu
243
244
  * settles. Callers who want their own UI pass `pairingUI: 'none'`.
244
245
  */
245
246
 
246
- /** Our own cap on how long a pairing sits on screen. See `pairingTimeoutMs`. */
247
- declare const DEFAULT_PAIRING_TIMEOUT_MS = 120000;
247
+ /**
248
+ * How long a pairing sits on screen when the provider states no expiry of
249
+ * its own. The provider does state one (`expires_in`, five minutes today),
250
+ * and that is the deadline unless the site sets a shorter `pairingTimeoutMs`.
251
+ */
252
+ declare const DEFAULT_PAIRING_TIMEOUT_MS = 300000;
248
253
  interface PairingModalOptions {
249
254
  onCancel: () => void;
250
255
  locale?: string;
@@ -328,7 +333,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
328
333
  * auth-code mode leaves it to the RP backend.
329
334
  */
330
335
  declare const WIRE_VERSION = 1;
331
- declare const SDK_VERSION = "0.1.22";
336
+ declare const SDK_VERSION = "0.1.24";
332
337
  declare const SDK_NAME = "@zoreal/oauth2-js";
333
338
  declare const DEFAULT_ISSUER = "https://id.zoreal.com";
334
339
  /** 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.22";
17
+ var SDK_VERSION = "0.1.24";
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
  };
@@ -1704,7 +1715,7 @@ function interpolate(template, time) {
1704
1715
  }
1705
1716
 
1706
1717
  // src/modal.ts
1707
- var DEFAULT_PAIRING_TIMEOUT_MS = 12e4;
1718
+ var DEFAULT_PAIRING_TIMEOUT_MS = 3e5;
1708
1719
  var URGENT_SECONDS = 20;
1709
1720
  function mmss(totalSeconds) {
1710
1721
  const m = Math.floor(totalSeconds / 60);
@@ -1776,7 +1787,7 @@ function mountPairingModal(state, options) {
1776
1787
  if (typeof document === "undefined") return null;
1777
1788
  ensureStyles();
1778
1789
  const t = strings(options.locale);
1779
- const timeoutMs = options.timeoutMs ?? DEFAULT_PAIRING_TIMEOUT_MS;
1790
+ const timeoutMs = options.timeoutMs;
1780
1791
  let closed = false;
1781
1792
  const scrim = el("div", `${cx("root")} ${cx("scrim")}`);
1782
1793
  scrim.dataset.theme = options.theme ?? "auto";
@@ -1834,7 +1845,8 @@ function mountPairingModal(state, options) {
1834
1845
  card.append(closeBtn, body, help, footer);
1835
1846
  scrim.appendChild(card);
1836
1847
  const serverMs = typeof state.expiresIn === "number" ? state.expiresIn * 1e3 : Infinity;
1837
- const deadline = Date.now() + Math.min(timeoutMs, serverMs);
1848
+ const capMs = timeoutMs ?? (Number.isFinite(serverMs) ? serverMs : DEFAULT_PAIRING_TIMEOUT_MS);
1849
+ const deadline = Date.now() + Math.min(capMs, serverMs);
1838
1850
  let shown = state.qrUrl;
1839
1851
  let loading = null;
1840
1852
  const spent = () => qr.dataset.spent === "true";