@zoreal/oauth2-react 0.2.21 → 0.2.22
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.cjs +85 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -101
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.22";
|
|
9
9
|
var DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
10
10
|
var POLL_INTERVAL_MS = 2e3;
|
|
11
11
|
var POLL_INTERVAL_ENROLLING_MS = 5e3;
|
|
@@ -1605,7 +1605,7 @@ function useZorealOAuth() {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
|
|
1607
1607
|
// src/ZorealLogin.tsx
|
|
1608
|
-
import { useMemo as useMemo2
|
|
1608
|
+
import { useMemo as useMemo2 } from "react";
|
|
1609
1609
|
|
|
1610
1610
|
// src/useZorealLogin.ts
|
|
1611
1611
|
import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
@@ -2457,79 +2457,8 @@ function useZorealLogin(options) {
|
|
|
2457
2457
|
}).login;
|
|
2458
2458
|
}
|
|
2459
2459
|
|
|
2460
|
-
// src/ring.tsx
|
|
2461
|
-
import { useEffect as useEffect3, useLayoutEffect, useRef as useRef3 } from "react";
|
|
2462
|
-
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2463
|
-
var TAIL2 = 0.3;
|
|
2464
|
-
var STACK2 = Array.from({ length: 12 }, (_, i) => 12 - i);
|
|
2465
|
-
var HALO2 = [3, 2, 1];
|
|
2466
|
-
function ZorealBusyRing({
|
|
2467
|
-
busy,
|
|
2468
|
-
radius = 8,
|
|
2469
|
-
theme = "auto",
|
|
2470
|
-
block = false,
|
|
2471
|
-
className,
|
|
2472
|
-
style,
|
|
2473
|
-
children
|
|
2474
|
-
}) {
|
|
2475
|
-
useEffect3(() => {
|
|
2476
|
-
ensureStyles();
|
|
2477
|
-
}, []);
|
|
2478
|
-
const wrapRef = useRef3(null);
|
|
2479
|
-
const measureRef = useRef3(null);
|
|
2480
|
-
useLayoutEffect(() => {
|
|
2481
|
-
const wrap = wrapRef.current;
|
|
2482
|
-
const rect = measureRef.current;
|
|
2483
|
-
if (!wrap || !rect) return;
|
|
2484
|
-
const measure = () => {
|
|
2485
|
-
const length = rect.getTotalLength();
|
|
2486
|
-
if (length > 0) wrap.style.setProperty("--zrl-ring-len", `${length}px`);
|
|
2487
|
-
};
|
|
2488
|
-
measure();
|
|
2489
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
2490
|
-
const observer = new ResizeObserver(measure);
|
|
2491
|
-
observer.observe(wrap);
|
|
2492
|
-
return () => observer.disconnect();
|
|
2493
|
-
}, [radius]);
|
|
2494
|
-
const rx = radius + 2;
|
|
2495
|
-
const layer = (key, name, len, alpha, ref) => /* @__PURE__ */ jsx5(
|
|
2496
|
-
"rect",
|
|
2497
|
-
{
|
|
2498
|
-
ref,
|
|
2499
|
-
className: cx(name),
|
|
2500
|
-
rx,
|
|
2501
|
-
ry: rx,
|
|
2502
|
-
style: {
|
|
2503
|
-
strokeDasharray: `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`,
|
|
2504
|
-
"--zrl-s": `calc(var(--zrl-l) * ${-(TAIL2 - len)})`,
|
|
2505
|
-
opacity: alpha
|
|
2506
|
-
}
|
|
2507
|
-
},
|
|
2508
|
-
key
|
|
2509
|
-
);
|
|
2510
|
-
return /* @__PURE__ */ jsxs5(
|
|
2511
|
-
"span",
|
|
2512
|
-
{
|
|
2513
|
-
ref: wrapRef,
|
|
2514
|
-
className: className ? `${cx("root")} ${cx("ring")} ${className}` : `${cx("root")} ${cx("ring")}`,
|
|
2515
|
-
"data-theme": theme,
|
|
2516
|
-
"data-busy": busy,
|
|
2517
|
-
style: block ? { display: "flex", ...style } : style,
|
|
2518
|
-
children: [
|
|
2519
|
-
children,
|
|
2520
|
-
/* @__PURE__ */ jsxs5("svg", { className: cx("ring-svg"), "aria-hidden": "true", children: [
|
|
2521
|
-
HALO2.map(
|
|
2522
|
-
(n, i) => layer(`h${n}`, "ring-halo", TAIL2 * n / HALO2.length, `calc(var(--zrl-glow-opacity) * 0.6 / ${n})`, i === 0 ? measureRef : void 0)
|
|
2523
|
-
),
|
|
2524
|
-
STACK2.map((n) => layer(`t${n}`, n <= 2 ? "ring-head" : "ring-tail", TAIL2 * n / STACK2.length, String(1 / n)))
|
|
2525
|
-
] })
|
|
2526
|
-
]
|
|
2527
|
-
}
|
|
2528
|
-
);
|
|
2529
|
-
}
|
|
2530
|
-
|
|
2531
2460
|
// src/ZorealLogin.tsx
|
|
2532
|
-
import { jsx as
|
|
2461
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2533
2462
|
var TEXTS = {
|
|
2534
2463
|
continue_with: null,
|
|
2535
2464
|
signin_with: "Sign in with ZOREAL",
|
|
@@ -2560,26 +2489,13 @@ function ZorealLogin(props) {
|
|
|
2560
2489
|
} = props;
|
|
2561
2490
|
const { locale } = useZorealOAuth();
|
|
2562
2491
|
const label = TEXTS[text] ?? strings(locale).buttonContinue;
|
|
2563
|
-
const [busy, setBusy] = useState4(false);
|
|
2564
2492
|
const { login } = useZorealFlow({
|
|
2565
2493
|
...request,
|
|
2566
2494
|
flow,
|
|
2567
|
-
onCredential: flow === "browser-direct" ?
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
onCode: flow === "auth-code" ? (r) => {
|
|
2572
|
-
setBusy(false);
|
|
2573
|
-
onSuccess(r);
|
|
2574
|
-
} : void 0,
|
|
2575
|
-
onError: (e) => {
|
|
2576
|
-
setBusy(false);
|
|
2577
|
-
onError?.({ type: "unknown", description: e.description ?? e.error });
|
|
2578
|
-
},
|
|
2579
|
-
onNonOAuthError: (e) => {
|
|
2580
|
-
setBusy(false);
|
|
2581
|
-
onError?.(e);
|
|
2582
|
-
}
|
|
2495
|
+
onCredential: flow === "browser-direct" ? onSuccess : void 0,
|
|
2496
|
+
onCode: flow === "auth-code" ? onSuccess : void 0,
|
|
2497
|
+
onError: (e) => onError?.({ type: "unknown", description: e.description ?? e.error }),
|
|
2498
|
+
onNonOAuthError: (e) => onError?.(e)
|
|
2583
2499
|
});
|
|
2584
2500
|
const s = SIZES[size];
|
|
2585
2501
|
const radius = shape === "pill" ? s.height / 2 : shape === "square" ? 4 : s.radius;
|
|
@@ -2602,25 +2518,92 @@ function ZorealLogin(props) {
|
|
|
2602
2518
|
}),
|
|
2603
2519
|
[logo_alignment, s, radius, theme, width]
|
|
2604
2520
|
);
|
|
2605
|
-
return /* @__PURE__ */
|
|
2521
|
+
return /* @__PURE__ */ jsx5("div", { ...containerProps, children: /* @__PURE__ */ jsxs5(
|
|
2606
2522
|
"button",
|
|
2607
2523
|
{
|
|
2608
2524
|
type: "button",
|
|
2609
|
-
style
|
|
2610
|
-
|
|
2611
|
-
"aria-busy": busy,
|
|
2612
|
-
onClick: () => {
|
|
2613
|
-
if (busy) return;
|
|
2525
|
+
style,
|
|
2526
|
+
onClick: (event) => {
|
|
2614
2527
|
click_listener?.();
|
|
2615
|
-
|
|
2616
|
-
login();
|
|
2528
|
+
login(event);
|
|
2617
2529
|
},
|
|
2618
2530
|
children: [
|
|
2619
|
-
/* @__PURE__ */
|
|
2531
|
+
/* @__PURE__ */ jsx5(ZorealMark, { size: s.mark, brand: brandMark }),
|
|
2620
2532
|
type === "standard" && label
|
|
2621
2533
|
]
|
|
2622
2534
|
}
|
|
2623
|
-
) })
|
|
2535
|
+
) });
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
// src/ring.tsx
|
|
2539
|
+
import { useEffect as useEffect3, useLayoutEffect, useRef as useRef3 } from "react";
|
|
2540
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2541
|
+
var TAIL2 = 0.3;
|
|
2542
|
+
var STACK2 = Array.from({ length: 12 }, (_, i) => 12 - i);
|
|
2543
|
+
var HALO2 = [3, 2, 1];
|
|
2544
|
+
function ZorealBusyRing({
|
|
2545
|
+
busy,
|
|
2546
|
+
radius = 8,
|
|
2547
|
+
theme = "auto",
|
|
2548
|
+
block = false,
|
|
2549
|
+
className,
|
|
2550
|
+
style,
|
|
2551
|
+
children
|
|
2552
|
+
}) {
|
|
2553
|
+
useEffect3(() => {
|
|
2554
|
+
ensureStyles();
|
|
2555
|
+
}, []);
|
|
2556
|
+
const wrapRef = useRef3(null);
|
|
2557
|
+
const measureRef = useRef3(null);
|
|
2558
|
+
useLayoutEffect(() => {
|
|
2559
|
+
const wrap = wrapRef.current;
|
|
2560
|
+
const rect = measureRef.current;
|
|
2561
|
+
if (!wrap || !rect) return;
|
|
2562
|
+
const measure = () => {
|
|
2563
|
+
const length = rect.getTotalLength();
|
|
2564
|
+
if (length > 0) wrap.style.setProperty("--zrl-ring-len", `${length}px`);
|
|
2565
|
+
};
|
|
2566
|
+
measure();
|
|
2567
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
2568
|
+
const observer = new ResizeObserver(measure);
|
|
2569
|
+
observer.observe(wrap);
|
|
2570
|
+
return () => observer.disconnect();
|
|
2571
|
+
}, [radius]);
|
|
2572
|
+
const rx = radius + 2;
|
|
2573
|
+
const layer = (key, name, len, alpha, ref) => /* @__PURE__ */ jsx6(
|
|
2574
|
+
"rect",
|
|
2575
|
+
{
|
|
2576
|
+
ref,
|
|
2577
|
+
className: cx(name),
|
|
2578
|
+
rx,
|
|
2579
|
+
ry: rx,
|
|
2580
|
+
style: {
|
|
2581
|
+
strokeDasharray: `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`,
|
|
2582
|
+
"--zrl-s": `calc(var(--zrl-l) * ${-(TAIL2 - len)})`,
|
|
2583
|
+
opacity: alpha
|
|
2584
|
+
}
|
|
2585
|
+
},
|
|
2586
|
+
key
|
|
2587
|
+
);
|
|
2588
|
+
return /* @__PURE__ */ jsxs6(
|
|
2589
|
+
"span",
|
|
2590
|
+
{
|
|
2591
|
+
ref: wrapRef,
|
|
2592
|
+
className: className ? `${cx("root")} ${cx("ring")} ${className}` : `${cx("root")} ${cx("ring")}`,
|
|
2593
|
+
"data-theme": theme,
|
|
2594
|
+
"data-busy": busy,
|
|
2595
|
+
style: block ? { display: "flex", ...style } : style,
|
|
2596
|
+
children: [
|
|
2597
|
+
children,
|
|
2598
|
+
/* @__PURE__ */ jsxs6("svg", { className: cx("ring-svg"), "aria-hidden": "true", children: [
|
|
2599
|
+
HALO2.map(
|
|
2600
|
+
(n, i) => layer(`h${n}`, "ring-halo", TAIL2 * n / HALO2.length, `calc(var(--zrl-glow-opacity) * 0.6 / ${n})`, i === 0 ? measureRef : void 0)
|
|
2601
|
+
),
|
|
2602
|
+
STACK2.map((n) => layer(`t${n}`, n <= 2 ? "ring-head" : "ring-tail", TAIL2 * n / STACK2.length, String(1 / n)))
|
|
2603
|
+
] })
|
|
2604
|
+
]
|
|
2605
|
+
}
|
|
2606
|
+
);
|
|
2624
2607
|
}
|
|
2625
2608
|
|
|
2626
2609
|
// src/useZorealAutoLogin.ts
|