@zoreal/oauth2-react 0.2.23 → 0.2.25
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 +1 -1
- package/dist/index.cjs +25 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -228,7 +228,8 @@ interface ZorealOAuthProviderProps {
|
|
|
228
228
|
pairingUI?: PairingUI;
|
|
229
229
|
/**
|
|
230
230
|
* How long the modal stays open before giving up and cancelling, in ms.
|
|
231
|
-
* Defaults to
|
|
231
|
+
* Defaults to the provider's own expiry (five minutes today), or 300000
|
|
232
|
+
* when it states none; a shorter value of yours wins.
|
|
232
233
|
*/
|
|
233
234
|
pairingTimeoutMs?: number;
|
|
234
235
|
children: ReactNode;
|
|
@@ -270,8 +271,12 @@ declare function ZorealMark({ size, brand, className, }: {
|
|
|
270
271
|
* the rest of a sign-in form for the person's attention at the one moment they
|
|
271
272
|
* need to look at their phone.
|
|
272
273
|
*/
|
|
273
|
-
/**
|
|
274
|
-
|
|
274
|
+
/**
|
|
275
|
+
* How long a pairing sits on screen when the provider states no expiry of
|
|
276
|
+
* its own. The provider does state one (`expires_in`, five minutes today),
|
|
277
|
+
* and that is the deadline unless the site sets a shorter `pairingTimeoutMs`.
|
|
278
|
+
*/
|
|
279
|
+
declare const DEFAULT_PAIRING_TIMEOUT_MS = 300000;
|
|
275
280
|
interface PairingModalProps {
|
|
276
281
|
state: PairingState;
|
|
277
282
|
qrUrl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -228,7 +228,8 @@ interface ZorealOAuthProviderProps {
|
|
|
228
228
|
pairingUI?: PairingUI;
|
|
229
229
|
/**
|
|
230
230
|
* How long the modal stays open before giving up and cancelling, in ms.
|
|
231
|
-
* Defaults to
|
|
231
|
+
* Defaults to the provider's own expiry (five minutes today), or 300000
|
|
232
|
+
* when it states none; a shorter value of yours wins.
|
|
232
233
|
*/
|
|
233
234
|
pairingTimeoutMs?: number;
|
|
234
235
|
children: ReactNode;
|
|
@@ -270,8 +271,12 @@ declare function ZorealMark({ size, brand, className, }: {
|
|
|
270
271
|
* the rest of a sign-in form for the person's attention at the one moment they
|
|
271
272
|
* need to look at their phone.
|
|
272
273
|
*/
|
|
273
|
-
/**
|
|
274
|
-
|
|
274
|
+
/**
|
|
275
|
+
* How long a pairing sits on screen when the provider states no expiry of
|
|
276
|
+
* its own. The provider does state one (`expires_in`, five minutes today),
|
|
277
|
+
* and that is the deadline unless the site sets a shorter `pairingTimeoutMs`.
|
|
278
|
+
*/
|
|
279
|
+
declare const DEFAULT_PAIRING_TIMEOUT_MS = 300000;
|
|
275
280
|
interface PairingModalProps {
|
|
276
281
|
state: PairingState;
|
|
277
282
|
qrUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createContext, useContext, useMemo, useState as useState2 } from "react
|
|
|
5
5
|
|
|
6
6
|
// src/wire.ts
|
|
7
7
|
var WIRE_VERSION = 1;
|
|
8
|
-
var SDK_VERSION = "0.2.
|
|
8
|
+
var SDK_VERSION = "0.2.25";
|
|
9
9
|
var DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
10
10
|
var POLL_INTERVAL_MS = 2e3;
|
|
11
11
|
var POLL_INTERVAL_ENROLLING_MS = 5e3;
|
|
@@ -1425,7 +1425,7 @@ function ensureStyles() {
|
|
|
1425
1425
|
|
|
1426
1426
|
// src/PairingModal.tsx
|
|
1427
1427
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1428
|
-
var DEFAULT_PAIRING_TIMEOUT_MS =
|
|
1428
|
+
var DEFAULT_PAIRING_TIMEOUT_MS = 3e5;
|
|
1429
1429
|
var URGENT_SECONDS = 20;
|
|
1430
1430
|
function mmss(totalSeconds) {
|
|
1431
1431
|
const m = Math.floor(totalSeconds / 60);
|
|
@@ -1447,14 +1447,14 @@ function PairingModal({
|
|
|
1447
1447
|
onCancel,
|
|
1448
1448
|
locale,
|
|
1449
1449
|
theme = "auto",
|
|
1450
|
-
timeoutMs
|
|
1450
|
+
timeoutMs,
|
|
1451
1451
|
intent = "sign-in"
|
|
1452
1452
|
}) {
|
|
1453
1453
|
const t = strings(locale);
|
|
1454
1454
|
const titleId = useId();
|
|
1455
1455
|
const closeRef = useRef(null);
|
|
1456
1456
|
const deadlineRef = useRef(0);
|
|
1457
|
-
const [remaining, setRemaining] = useState(Math.round(timeoutMs / 1e3));
|
|
1457
|
+
const [remaining, setRemaining] = useState(Math.round((timeoutMs ?? DEFAULT_PAIRING_TIMEOUT_MS) / 1e3));
|
|
1458
1458
|
const settled = state.status === "claimed" || state.status === "enrolling";
|
|
1459
1459
|
const [frameUrl, setFrameUrl] = useState(qrUrl);
|
|
1460
1460
|
useEffect(() => {
|
|
@@ -1480,8 +1480,10 @@ function PairingModal({
|
|
|
1480
1480
|
}, []);
|
|
1481
1481
|
useEffect(() => {
|
|
1482
1482
|
const serverMs = typeof state.expiresIn === "number" ? state.expiresIn * 1e3 : Infinity;
|
|
1483
|
-
|
|
1484
|
-
|
|
1483
|
+
const capMs = timeoutMs ?? (Number.isFinite(serverMs) ? serverMs : DEFAULT_PAIRING_TIMEOUT_MS);
|
|
1484
|
+
const ms = Math.min(capMs, serverMs);
|
|
1485
|
+
deadlineRef.current = Date.now() + ms;
|
|
1486
|
+
setRemaining(Math.round(ms / 1e3));
|
|
1485
1487
|
const id = setInterval(() => {
|
|
1486
1488
|
const left = Math.max(0, Math.ceil((deadlineRef.current - Date.now()) / 1e3));
|
|
1487
1489
|
setRemaining(left);
|
|
@@ -1615,9 +1617,16 @@ var SVG_NS = "http://www.w3.org/2000/svg";
|
|
|
1615
1617
|
var TAIL = 0.3;
|
|
1616
1618
|
var STACK = Array.from({ length: 12 }, (_, i) => 12 - i);
|
|
1617
1619
|
var HALO = [3, 2, 1];
|
|
1618
|
-
function
|
|
1619
|
-
const
|
|
1620
|
-
|
|
1620
|
+
function cornerOf(radius, width, height) {
|
|
1621
|
+
const raw = radius.trim();
|
|
1622
|
+
const value = parseFloat(raw);
|
|
1623
|
+
const offset = 2;
|
|
1624
|
+
if (raw.endsWith("%") && Number.isFinite(value)) {
|
|
1625
|
+
return [width * value / 100 + offset, height * value / 100 + offset];
|
|
1626
|
+
}
|
|
1627
|
+
const px = Number.isFinite(value) ? value : /infinity/i.test(raw) ? Infinity : 8;
|
|
1628
|
+
const r = Math.min(px, width / 2, height / 2) + offset;
|
|
1629
|
+
return [r, r];
|
|
1621
1630
|
}
|
|
1622
1631
|
function holdBusy(control) {
|
|
1623
1632
|
if (typeof document === "undefined") return () => {
|
|
@@ -1638,12 +1647,11 @@ function holdBusy(control) {
|
|
|
1638
1647
|
overlay.setAttribute("aria-hidden", "true");
|
|
1639
1648
|
const svg = document.createElementNS(SVG_NS, "svg");
|
|
1640
1649
|
svg.setAttribute("class", cx("ring-svg"));
|
|
1641
|
-
const
|
|
1650
|
+
const rects = [];
|
|
1642
1651
|
const layer = (name, len, alpha) => {
|
|
1643
1652
|
const rect = document.createElementNS(SVG_NS, "rect");
|
|
1644
1653
|
rect.setAttribute("class", cx(name));
|
|
1645
|
-
|
|
1646
|
-
rect.setAttribute("ry", String(rx));
|
|
1654
|
+
rects.push(rect);
|
|
1647
1655
|
rect.style.strokeDasharray = `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`;
|
|
1648
1656
|
rect.style.setProperty("--zrl-s", `calc(var(--zrl-l) * ${-(TAIL - len)})`);
|
|
1649
1657
|
rect.style.opacity = alpha;
|
|
@@ -1666,6 +1674,11 @@ function holdBusy(control) {
|
|
|
1666
1674
|
overlay.style.top = `${box.top}px`;
|
|
1667
1675
|
overlay.style.width = `${box.width}px`;
|
|
1668
1676
|
overlay.style.height = `${box.height}px`;
|
|
1677
|
+
const [rx, ry] = cornerOf(getComputedStyle(control).borderTopLeftRadius, box.width, box.height);
|
|
1678
|
+
for (const rect of rects) {
|
|
1679
|
+
rect.setAttribute("rx", String(rx));
|
|
1680
|
+
rect.setAttribute("ry", String(ry));
|
|
1681
|
+
}
|
|
1669
1682
|
const length = typeof measured?.getTotalLength === "function" ? measured.getTotalLength() : 0;
|
|
1670
1683
|
if (length > 0) overlay.style.setProperty("--zrl-ring-len", `${length}px`);
|
|
1671
1684
|
};
|