@abpjs/ui 0.2.0-next.5 → 0.2.0-next.6
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 +9 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +50 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0-next.6
|
|
4
|
+
|
|
5
|
+
A prerelease under npm's `next` tag.
|
|
6
|
+
|
|
7
|
+
- `StepUpDialog`: an authenticator code alone where the server lets one pass (`appCodeAlone` in `step_up_required`'s
|
|
8
|
+
data, the operator's setting): the strong level asks for the code alone (a passkey still first when the person has
|
|
9
|
+
one), and the password level offers it instead of the password. Without the field, a code goes with the password, as
|
|
10
|
+
before. `StepUpNeed.appCodeAlone`.
|
|
11
|
+
|
|
3
12
|
## 0.2.0-next.5
|
|
4
13
|
|
|
5
14
|
A prerelease under npm's `next` tag: the step-up dialog for AbpGuard 0.7.0's strong step-up and passkeys. Against an
|
package/dist/index.d.ts
CHANGED
|
@@ -235,6 +235,8 @@ interface StepUpNeed {
|
|
|
235
235
|
category: string | null;
|
|
236
236
|
/** The person's ways at that level, best first: `passkey`, `app`, `password`, `email`… Empty when the server doesn't say. */
|
|
237
237
|
methods: string[];
|
|
238
|
+
/** An authenticator code alone passes (the operator's setting, AbpGuard's `appCodeAlone`); else it goes with the password. */
|
|
239
|
+
appCodeAlone: boolean;
|
|
238
240
|
}
|
|
239
241
|
/** What asks the person to confirm who they are: true once confirmed (or a strong factor set up), false if they gave up. */
|
|
240
242
|
type StepUpHandler = (need: StepUpNeed) => Promise<boolean>;
|
|
@@ -1559,8 +1561,9 @@ declare function looksLikeCode(value: string, recovery: boolean): boolean;
|
|
|
1559
1561
|
*
|
|
1560
1562
|
* - At the password level: the password, and a code of their second factor when they have one (their app, a recovery
|
|
1561
1563
|
* code, or one the site sends).
|
|
1562
|
-
* - At the strong level (AbpGuard 0.7.0): a passkey first when they have one, or
|
|
1563
|
-
* code
|
|
1564
|
+
* - At the strong level (AbpGuard 0.7.0): a passkey first when they have one, or an authenticator code: alone where the
|
|
1565
|
+
* server says one passes alone (`appCodeAlone`, the operator's setting), else with the password. Where a code passes
|
|
1566
|
+
* alone it's offered at the password level too.
|
|
1564
1567
|
* - Asked for a strong step-up with no strong factor (`strong_factor_required`): the password, then setting up a passkey
|
|
1565
1568
|
* or the app here (with recovery codes, shown once, for a first factor); the call then asks again, and they confirm
|
|
1566
1569
|
* with what they set up.
|
package/dist/index.js
CHANGED
|
@@ -1560,7 +1560,7 @@ function useTokenVar() {
|
|
|
1560
1560
|
}
|
|
1561
1561
|
|
|
1562
1562
|
// src/version.ts
|
|
1563
|
-
var ABP_UI_VERSION = true ? "0.2.0-next.
|
|
1563
|
+
var ABP_UI_VERSION = true ? "0.2.0-next.6" : "0.0.0-dev";
|
|
1564
1564
|
|
|
1565
1565
|
// src/provider/time-zone.tsx
|
|
1566
1566
|
import { createContext, useContext } from "react";
|
|
@@ -2596,9 +2596,9 @@ function setStepUpHandler(next) {
|
|
|
2596
2596
|
function stepUpNeedOf(code, data) {
|
|
2597
2597
|
const level = code === "strong_factor_required" || data?.level === "strong" ? "strong" : "password";
|
|
2598
2598
|
const methods = Array.isArray(data?.methods) ? data.methods.filter((m4) => typeof m4 === "string") : [];
|
|
2599
|
-
return { code, level, category: typeof data?.category === "string" ? data.category : null, methods };
|
|
2599
|
+
return { code, level, category: typeof data?.category === "string" ? data.category : null, methods, appCodeAlone: data?.appCodeAlone === true };
|
|
2600
2600
|
}
|
|
2601
|
-
function requestStepUp(need = { code: "step_up_required", level: "password", category: null, methods: [] }) {
|
|
2601
|
+
function requestStepUp(need = { code: "step_up_required", level: "password", category: null, methods: [], appCodeAlone: false }) {
|
|
2602
2602
|
if (!handler) return Promise.resolve(false);
|
|
2603
2603
|
pending ??= handler(need).finally(() => {
|
|
2604
2604
|
pending = null;
|
|
@@ -2659,7 +2659,10 @@ var ar_default = {
|
|
|
2659
2659
|
recoverySaved: "\u062D\u0641\u0638\u062A\u0647\u0627",
|
|
2660
2660
|
continue: "\u0645\u062A\u0627\u0628\u0639\u0629",
|
|
2661
2661
|
back: "\u0631\u062C\u0648\u0639",
|
|
2662
|
-
strongWhyApp: "\u064A\u062A\u0637\u0644\u0628 \u0647\u0630\u0627 \u0627\u0644\u0625\u062C\u0631\u0627\u0621 \u0623\u0643\u062B\u0631 \u0645\u0646 \u0643\u0644\u0645\u0629 \u0627\u0644\u0645\u0631\u0648\u0631: \u0623\u062F\u062E\u0644\u0647\u0627 \u0645\u0639 \u0631\u0645\u0632 \u0645\u0646 \u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0635\u0627\u062F\u0642\u0629."
|
|
2662
|
+
strongWhyApp: "\u064A\u062A\u0637\u0644\u0628 \u0647\u0630\u0627 \u0627\u0644\u0625\u062C\u0631\u0627\u0621 \u0623\u0643\u062B\u0631 \u0645\u0646 \u0643\u0644\u0645\u0629 \u0627\u0644\u0645\u0631\u0648\u0631: \u0623\u062F\u062E\u0644\u0647\u0627 \u0645\u0639 \u0631\u0645\u0632 \u0645\u0646 \u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0635\u0627\u062F\u0642\u0629.",
|
|
2663
|
+
appCodeWhy: "\u0623\u062F\u062E\u0644 \u0631\u0645\u0632\u064B\u0627 \u0645\u0646 \u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0635\u0627\u062F\u0642\u0629.",
|
|
2664
|
+
useAppCode: "\u0627\u0633\u062A\u062E\u062F\u0645 \u0631\u0645\u0632\u064B\u0627 \u0645\u0646 \u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0635\u0627\u062F\u0642\u0629 \u0628\u062F\u0644\u064B\u0627 \u0645\u0646 \u0630\u0644\u0643",
|
|
2665
|
+
usePassword: "\u0627\u0633\u062A\u062E\u062F\u0645 \u0643\u0644\u0645\u0629 \u0627\u0644\u0645\u0631\u0648\u0631 \u0628\u062F\u0644\u064B\u0627 \u0645\u0646 \u0630\u0644\u0643"
|
|
2663
2666
|
};
|
|
2664
2667
|
|
|
2665
2668
|
// src/host/step-up-texts/en.json
|
|
@@ -2715,7 +2718,10 @@ var en_default = {
|
|
|
2715
2718
|
recoverySaved: "I've saved them",
|
|
2716
2719
|
continue: "Continue",
|
|
2717
2720
|
back: "Back",
|
|
2718
|
-
strongWhyApp: "This action needs more than your password: enter it with a code from your authenticator app."
|
|
2721
|
+
strongWhyApp: "This action needs more than your password: enter it with a code from your authenticator app.",
|
|
2722
|
+
appCodeWhy: "Enter a code from your authenticator app.",
|
|
2723
|
+
useAppCode: "Use a code from your authenticator app instead",
|
|
2724
|
+
usePassword: "Use your password instead"
|
|
2719
2725
|
};
|
|
2720
2726
|
|
|
2721
2727
|
// src/host/webauthn.ts
|
|
@@ -2843,7 +2849,8 @@ function StepUpDialog() {
|
|
|
2843
2849
|
setRecoveryCodes([]);
|
|
2844
2850
|
setCopied(false);
|
|
2845
2851
|
const passkeyFirst = asked.code !== "strong_factor_required" && asked.level === "strong" && asked.methods.includes("passkey") && passkeysSupported();
|
|
2846
|
-
|
|
2852
|
+
const codeFirst = asked.code !== "strong_factor_required" && asked.level === "strong" && asked.appCodeAlone && asked.methods.includes("app");
|
|
2853
|
+
setStage(passkeyFirst ? "passkey" : codeFirst ? "code" : "confirm");
|
|
2847
2854
|
setMethod("app");
|
|
2848
2855
|
setOpen(true);
|
|
2849
2856
|
})
|
|
@@ -2916,6 +2923,27 @@ function StepUpDialog() {
|
|
|
2916
2923
|
setBusy(false);
|
|
2917
2924
|
}
|
|
2918
2925
|
}
|
|
2926
|
+
async function confirmCode(e) {
|
|
2927
|
+
e.preventDefault();
|
|
2928
|
+
setBusy(true);
|
|
2929
|
+
setError(null);
|
|
2930
|
+
try {
|
|
2931
|
+
await call("/session/step-up", { method: "POST", body: { method: "app", code: code.replace(/\D/g, "") } });
|
|
2932
|
+
close(true);
|
|
2933
|
+
} catch (e2) {
|
|
2934
|
+
if (ended(e2)) return;
|
|
2935
|
+
setError(e2 instanceof AbpApiError && e2.message ? e2.message : t("failed"));
|
|
2936
|
+
setCode("");
|
|
2937
|
+
} finally {
|
|
2938
|
+
setBusy(false);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
const codeAlone = !!need?.appCodeAlone && !!need.methods.includes("app") && !settingUp;
|
|
2942
|
+
const toStage = (next) => {
|
|
2943
|
+
setStage(next);
|
|
2944
|
+
setCode("");
|
|
2945
|
+
setError(null);
|
|
2946
|
+
};
|
|
2919
2947
|
async function withPasskey() {
|
|
2920
2948
|
setBusy(true);
|
|
2921
2949
|
setError(null);
|
|
@@ -3033,13 +3061,23 @@ function StepUpDialog() {
|
|
|
3033
3061
|
/* @__PURE__ */ jsx15(Button, { variant: "primary", onClick: () => void withPasskey(), loading: busy, "data-testid": "use-passkey", children: t("usePasskey") }),
|
|
3034
3062
|
busy && /* @__PURE__ */ jsx15(Text, { textStyle: "sm", color: "fg.muted", children: t("passkeyPrompt") }),
|
|
3035
3063
|
/* @__PURE__ */ jsx15(InlineAlert, { tone: "danger", children: error }),
|
|
3036
|
-
need?.methods.includes("app") && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", onClick: () =>
|
|
3037
|
-
setStage("confirm");
|
|
3038
|
-
setError(null);
|
|
3039
|
-
}, "data-testid": "use-password-and-app", children: t("usePasswordAndApp") })
|
|
3064
|
+
need?.methods.includes("app") && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", onClick: () => toStage(codeAlone ? "code" : "confirm"), "data-testid": "use-password-and-app", children: codeAlone ? t("useAppCode") : t("usePasswordAndApp") })
|
|
3040
3065
|
] }) }),
|
|
3041
3066
|
footer(null)
|
|
3042
3067
|
] });
|
|
3068
|
+
} else if (stage === "code") {
|
|
3069
|
+
body = /* @__PURE__ */ jsxs7("form", { onSubmit: (e) => void confirmCode(e), children: [
|
|
3070
|
+
/* @__PURE__ */ jsx15(Dialog2.Body, { children: /* @__PURE__ */ jsxs7(Stack2, { gap: "field", children: [
|
|
3071
|
+
/* @__PURE__ */ jsx15(Text, { color: "fg.muted", children: t("appCodeWhy") }),
|
|
3072
|
+
codeInput(t("code")),
|
|
3073
|
+
/* @__PURE__ */ jsx15(InlineAlert, { tone: "danger", children: error }),
|
|
3074
|
+
/* @__PURE__ */ jsxs7(Stack2, { gap: "0.5", align: "start", children: [
|
|
3075
|
+
need?.methods.includes("passkey") && canPasskey && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", onClick: () => toStage("passkey"), children: t("usePasskey") }),
|
|
3076
|
+
!strong && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", onClick: () => toStage("confirm"), "data-testid": "use-password", children: t("usePassword") })
|
|
3077
|
+
] })
|
|
3078
|
+
] }) }),
|
|
3079
|
+
footer(t("confirm"), !looksLikeCode(code, false))
|
|
3080
|
+
] });
|
|
3043
3081
|
} else if (stage === "confirm" && strong && !settingUp) {
|
|
3044
3082
|
body = /* @__PURE__ */ jsxs7("form", { onSubmit: (e) => void confirm(e), children: [
|
|
3045
3083
|
/* @__PURE__ */ jsx15(Dialog2.Body, { children: /* @__PURE__ */ jsxs7(Stack2, { gap: "field", children: [
|
|
@@ -3074,7 +3112,8 @@ function StepUpDialog() {
|
|
|
3074
3112
|
ways.hasApp && !recovery && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", onClick: () => switchTo("recovery"), children: t("useRecovery") })
|
|
3075
3113
|
] })
|
|
3076
3114
|
] }),
|
|
3077
|
-
/* @__PURE__ */ jsx15(InlineAlert, { tone: "danger", children: error })
|
|
3115
|
+
/* @__PURE__ */ jsx15(InlineAlert, { tone: "danger", children: error }),
|
|
3116
|
+
codeAlone && !ways && /* @__PURE__ */ jsx15(Button, { variant: "link", size: "sm", alignSelf: "start", onClick: () => toStage("code"), "data-testid": "use-app-code", children: t("useAppCode") })
|
|
3078
3117
|
] }) }),
|
|
3079
3118
|
footer(settingUp ? t("continue") : t("confirm"), !password || !!ways && !looksLikeCode(code, recovery))
|
|
3080
3119
|
] });
|