@auth-link/web 1.1.0 → 2.0.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.
- package/CHANGELOG.md +7 -0
- package/README.md +33 -21
- package/dist/index.js +6 -32
- package/dist/index.js.map +2 -2
- package/dist/react.js +6 -38
- package/dist/react.js.map +2 -2
- package/dist/styles.css +5 -49
- package/dist/types/modal.d.ts +1 -3
- package/dist/types/passcode.d.ts +1 -2
- package/dist/types/react.d.ts +1 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types/view.d.ts +1 -4
- package/dist/types/vue.d.ts +1 -1
- package/dist/vue.js +7 -37
- package/dist/vue.js.map +2 -2
- package/docs/README.en.md +12 -8
- package/docs/README.ja.md +12 -8
- package/docs/README.zh-CN.md +12 -8
- package/examples/react-client.tsx +1 -1
- package/examples/vue-client.vue +1 -1
- package/package.json +2 -2
package/dist/react.js
CHANGED
|
@@ -2259,12 +2259,9 @@ function getMessages(locale) {
|
|
|
2259
2259
|
|
|
2260
2260
|
// src/view.ts
|
|
2261
2261
|
var node = (tag, props, ...children) => ({ tag, props, children });
|
|
2262
|
-
function resolveVariant(variant) {
|
|
2263
|
-
return variant === "B" || variant === "C" ? variant : "A";
|
|
2264
|
-
}
|
|
2265
2262
|
function widgetView(options) {
|
|
2266
2263
|
const { snapshot: s, mode, retry, refresh } = options;
|
|
2267
|
-
const locale = resolveLocale(options.locale)
|
|
2264
|
+
const locale = resolveLocale(options.locale);
|
|
2268
2265
|
const l = getMessages(locale);
|
|
2269
2266
|
const pending = s.status === "pending", hasQr = pending && (mode === "bind" || Boolean(options.showQr)) && Boolean(options.qr);
|
|
2270
2267
|
const status = { idle: l.loading, pending: options.passcodeMode ? l.otpWaiting : l.waiting, confirmed: l.confirmed, rejected: l.rejected, expired: l.expired, error: l.error }[s.status];
|
|
@@ -2281,12 +2278,6 @@ function widgetView(options) {
|
|
|
2281
2278
|
expiring ? l.expiring : status,
|
|
2282
2279
|
...expiring ? [node("span", { class: "authlink-expiry", "aria-hidden": "true" }, ` \xB7 ${expiryTime}`)] : []
|
|
2283
2280
|
);
|
|
2284
|
-
const cancel = () => options.close ? [node("button", {
|
|
2285
|
-
type: "button",
|
|
2286
|
-
class: "authlink-cancel",
|
|
2287
|
-
"data-authlink-focus": "cancel",
|
|
2288
|
-
onClick: options.close
|
|
2289
|
-
}, l.cancel)] : [];
|
|
2290
2281
|
const children = [node("h3", { class: "authlink-title" }, l[mode])];
|
|
2291
2282
|
if (hasQr) children.push(node("p", { class: "authlink-subtitle" }, l.scan));
|
|
2292
2283
|
if (pending) {
|
|
@@ -2329,9 +2320,7 @@ function widgetView(options) {
|
|
|
2329
2320
|
...s.error ? [node("p", { class: "authlink-input-error", role: "alert" }, options.passcodeMode ? s.error.message === "OTP_NOT_CONFIGURED" ? l.otpSetup : l.otpError : l.codeError)] : []
|
|
2330
2321
|
];
|
|
2331
2322
|
children.push(node("div", { class: "authlink-body" }, ...qr, node("div", { class: "authlink-details" }, ...detail)));
|
|
2332
|
-
|
|
2333
|
-
if (variant === "B") children.push(node("div", { class: "authlink-footer" }, statusNode(), ...cancel()));
|
|
2334
|
-
if (variant === "C") children.push(node("div", { class: "authlink-footer" }, statusNode(), ...cancel()));
|
|
2323
|
+
children.push(node("div", { class: "authlink-footer" }, statusNode()));
|
|
2335
2324
|
} else {
|
|
2336
2325
|
children.push(statusNode());
|
|
2337
2326
|
if (s.error?.message === "CONFIRMATION_CODE_LOCKED") children.push(node("p", { class: "authlink-input-error", role: "alert" }, l.codeLocked));
|
|
@@ -2352,7 +2341,6 @@ function widgetView(options) {
|
|
|
2352
2341
|
lang: locale,
|
|
2353
2342
|
class: `authlink-widget ${options.className ?? ""}`.trim(),
|
|
2354
2343
|
"data-status": s.status,
|
|
2355
|
-
"data-variant": variant,
|
|
2356
2344
|
"data-has-qr": String(hasQr),
|
|
2357
2345
|
"aria-label": l[mode]
|
|
2358
2346
|
}, ...children);
|
|
@@ -2396,7 +2384,7 @@ function openAuthLink(options) {
|
|
|
2396
2384
|
content.className = "authlink-modal-content";
|
|
2397
2385
|
header.append(brand, closeButton);
|
|
2398
2386
|
dialog.append(header, content);
|
|
2399
|
-
let locale = options.locale,
|
|
2387
|
+
let locale = options.locale, snapshot = initialSnapshot(), closed = false;
|
|
2400
2388
|
let abort;
|
|
2401
2389
|
let inputCode = "";
|
|
2402
2390
|
let submitCode;
|
|
@@ -2426,7 +2414,6 @@ function openAuthLink(options) {
|
|
|
2426
2414
|
const language = resolveLocale(locale), messages2 = getMessages(language);
|
|
2427
2415
|
dialog.lang = language;
|
|
2428
2416
|
dialog.setAttribute("aria-label", messages2[mode]);
|
|
2429
|
-
dialog.dataset.variant = variant;
|
|
2430
2417
|
dialog.dataset.mode = mode;
|
|
2431
2418
|
dialog.dataset.hasQr = String(snapshot.status === "pending" && (mode === "bind" || Boolean(options.showQr)));
|
|
2432
2419
|
closeButton.setAttribute("aria-label", messages2.close);
|
|
@@ -2435,7 +2422,6 @@ function openAuthLink(options) {
|
|
|
2435
2422
|
const next = element(widgetView({
|
|
2436
2423
|
mode,
|
|
2437
2424
|
locale,
|
|
2438
|
-
variant,
|
|
2439
2425
|
snapshot,
|
|
2440
2426
|
qr: image,
|
|
2441
2427
|
showQr: options.showQr,
|
|
@@ -2445,8 +2431,7 @@ function openAuthLink(options) {
|
|
|
2445
2431
|
},
|
|
2446
2432
|
submitCode: (code) => submitCode?.(code) ?? Promise.resolve(),
|
|
2447
2433
|
retry,
|
|
2448
|
-
refresh: options.onRefresh
|
|
2449
|
-
close: () => dispose(true)
|
|
2434
|
+
refresh: options.onRefresh
|
|
2450
2435
|
}));
|
|
2451
2436
|
const oldCode = content.querySelector(".authlink-code");
|
|
2452
2437
|
const nextCode = next.querySelector(".authlink-code");
|
|
@@ -2559,10 +2544,6 @@ function openAuthLink(options) {
|
|
|
2559
2544
|
locale = value;
|
|
2560
2545
|
render();
|
|
2561
2546
|
},
|
|
2562
|
-
setVariant: (value) => {
|
|
2563
|
-
variant = resolveVariant(value);
|
|
2564
|
-
render();
|
|
2565
|
-
},
|
|
2566
2547
|
retry
|
|
2567
2548
|
};
|
|
2568
2549
|
}
|
|
@@ -2600,7 +2581,7 @@ function openPasscode(options) {
|
|
|
2600
2581
|
content.className = "authlink-modal-content";
|
|
2601
2582
|
header.append(brand, close);
|
|
2602
2583
|
dialog.append(header, content);
|
|
2603
|
-
let locale = options.locale,
|
|
2584
|
+
let locale = options.locale, closed = false, busy = false, code = "", error;
|
|
2604
2585
|
const mode = options.bindingQr ? "bind" : "confirm";
|
|
2605
2586
|
let image;
|
|
2606
2587
|
if (options.bindingQr) {
|
|
@@ -2627,7 +2608,6 @@ function openPasscode(options) {
|
|
|
2627
2608
|
if (closed) return;
|
|
2628
2609
|
const l = getMessages(locale);
|
|
2629
2610
|
dialog.lang = resolveLocale(locale);
|
|
2630
|
-
dialog.dataset.variant = variant;
|
|
2631
2611
|
dialog.dataset.mode = mode;
|
|
2632
2612
|
dialog.dataset.hasQr = String(Boolean(image));
|
|
2633
2613
|
dialog.setAttribute("aria-label", l[mode]);
|
|
@@ -2638,7 +2618,6 @@ function openPasscode(options) {
|
|
|
2638
2618
|
content.replaceChildren(element(widgetView({
|
|
2639
2619
|
mode,
|
|
2640
2620
|
locale,
|
|
2641
|
-
variant,
|
|
2642
2621
|
passcodeMode: true,
|
|
2643
2622
|
snapshot,
|
|
2644
2623
|
qr: image,
|
|
@@ -2651,8 +2630,7 @@ function openPasscode(options) {
|
|
|
2651
2630
|
retry: () => {
|
|
2652
2631
|
error = void 0;
|
|
2653
2632
|
render();
|
|
2654
|
-
}
|
|
2655
|
-
close: () => dispose(true)
|
|
2633
|
+
}
|
|
2656
2634
|
})));
|
|
2657
2635
|
if (focused) content.querySelector("input")?.focus();
|
|
2658
2636
|
};
|
|
@@ -2714,10 +2692,6 @@ function openPasscode(options) {
|
|
|
2714
2692
|
locale = value;
|
|
2715
2693
|
render();
|
|
2716
2694
|
},
|
|
2717
|
-
setVariant: (value) => {
|
|
2718
|
-
variant = resolveVariant(value);
|
|
2719
|
-
render();
|
|
2720
|
-
},
|
|
2721
2695
|
retry: () => {
|
|
2722
2696
|
error = void 0;
|
|
2723
2697
|
render();
|
|
@@ -2748,9 +2722,6 @@ function AuthLinkPasscode(props) {
|
|
|
2748
2722
|
useEffect(() => {
|
|
2749
2723
|
modal.current?.setLocale(props.locale);
|
|
2750
2724
|
}, [props.locale]);
|
|
2751
|
-
useEffect(() => {
|
|
2752
|
-
modal.current?.setVariant(props.variant);
|
|
2753
|
-
}, [props.variant]);
|
|
2754
2725
|
return null;
|
|
2755
2726
|
}
|
|
2756
2727
|
function useAuthLink(options) {
|
|
@@ -2820,9 +2791,6 @@ function Widget(props) {
|
|
|
2820
2791
|
useEffect(() => {
|
|
2821
2792
|
modal.current?.setLocale(props.locale);
|
|
2822
2793
|
}, [props.locale]);
|
|
2823
|
-
useEffect(() => {
|
|
2824
|
-
modal.current?.setVariant(props.variant);
|
|
2825
|
-
}, [props.variant]);
|
|
2826
2794
|
return null;
|
|
2827
2795
|
}
|
|
2828
2796
|
function AuthLinkBind(props) {
|