@huaweidevtools/aishell-dsh-client-credentials 0.0.1-beta.6 → 0.0.1-beta.7
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/lib/client.js +660 -145
- package/lib/index.js +876 -1
- package/lib/types/client/CredentialRequestForm.d.ts +17 -0
- package/lib/types/client/locales.d.ts +20 -2
- package/lib/types/client/login-flow.d.ts +98 -0
- package/lib/types/client/spinner.d.ts +32 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/login-status.d.ts +62 -0
- package/lib/types/out-of-band/contract.d.ts +199 -0
- package/lib/types/out-of-band/flow.d.ts +82 -0
- package/lib/types/out-of-band/listener.d.ts +156 -0
- package/lib/types/out-of-band/login.d.ts +144 -0
- package/lib/types/out-of-band/routes.d.ts +108 -0
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -143,9 +143,9 @@ const CHIP_CLASS = "aishell-account-hint";
|
|
|
143
143
|
* `style[data-plugin="<id>"]` on module teardown, so a tag written here is
|
|
144
144
|
* reachable by the same mechanism as the generated ones.
|
|
145
145
|
*/
|
|
146
|
-
const PLUGIN_ID = "@huaweidevtools/aishell-dsh-client-credentials";
|
|
146
|
+
const PLUGIN_ID$1 = "@huaweidevtools/aishell-dsh-client-credentials";
|
|
147
147
|
/** Dedupe key for the one sheet this module owns. */
|
|
148
|
-
const CHIP_STYLE_KEY = `${PLUGIN_ID}/chip-hover`;
|
|
148
|
+
const CHIP_STYLE_KEY = `${PLUGIN_ID$1}/chip-hover`;
|
|
149
149
|
/**
|
|
150
150
|
* Mount the chips' hover/focus rule for the owning plugin's lifetime.
|
|
151
151
|
*
|
|
@@ -169,7 +169,7 @@ function installChipStyles(ctx) {
|
|
|
169
169
|
if (typeof document === "undefined") return;
|
|
170
170
|
ctx.effect(() => {
|
|
171
171
|
const tag = document.createElement("style");
|
|
172
|
-
tag.dataset.plugin = PLUGIN_ID;
|
|
172
|
+
tag.dataset.plugin = PLUGIN_ID$1;
|
|
173
173
|
tag.dataset.pluginCss = CHIP_STYLE_KEY;
|
|
174
174
|
tag.textContent = `.${CHIP_CLASS}:hover{background:var(--dsw-alias-interactive-bg-hover)}.${CHIP_CLASS}:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}`;
|
|
175
175
|
document.head.appendChild(tag);
|
|
@@ -457,6 +457,184 @@ function AishellHeroChip(props) {
|
|
|
457
457
|
*/
|
|
458
458
|
const CREDENTIAL_URL = "https://console.huaweicloud.com/apiexplorer/#/openapi/IAM/doc?version=v3&api=CreateTemporaryAccessKeyByToken";
|
|
459
459
|
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/login-status.ts
|
|
462
|
+
/**
|
|
463
|
+
* Header the reachability probe sends, to force a CORS preflight.
|
|
464
|
+
*
|
|
465
|
+
* Any non-safelisted header would do it; this one names why. Declared here
|
|
466
|
+
* because both halves need the same string and neither owns it: the browser
|
|
467
|
+
* half sends it, the host's listener must allow it in its preflight answer,
|
|
468
|
+
* and a mismatch between the two is a probe that fails on a deployment that
|
|
469
|
+
* would actually work — the entry hidden for no reason.
|
|
470
|
+
*/
|
|
471
|
+
const PROBE_HEADER = "x-aishell-probe";
|
|
472
|
+
/**
|
|
473
|
+
* Read an outcome back out of the document.
|
|
474
|
+
*
|
|
475
|
+
* Anything unreadable reads as no outcome: a corrupt field should show
|
|
476
|
+
* nothing, not a spurious success.
|
|
477
|
+
*
|
|
478
|
+
* @param raw - the stored string, if any.
|
|
479
|
+
* @returns the outcome, or `undefined` when there is none usable.
|
|
480
|
+
*/
|
|
481
|
+
function decodeOutcome(raw) {
|
|
482
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
483
|
+
let parsed;
|
|
484
|
+
try {
|
|
485
|
+
parsed = JSON.parse(raw);
|
|
486
|
+
} catch {
|
|
487
|
+
return void 0;
|
|
488
|
+
}
|
|
489
|
+
if (parsed === null || typeof parsed !== "object") return void 0;
|
|
490
|
+
const candidate = parsed;
|
|
491
|
+
if (candidate.kind === "succeeded" && typeof candidate.accountName === "string") return {
|
|
492
|
+
kind: "succeeded",
|
|
493
|
+
accountName: candidate.accountName
|
|
494
|
+
};
|
|
495
|
+
if (candidate.kind === "failed" && typeof candidate.error === "string") return {
|
|
496
|
+
kind: "failed",
|
|
497
|
+
error: candidate.error
|
|
498
|
+
};
|
|
499
|
+
return void 0;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/client/login-flow.ts
|
|
504
|
+
/**
|
|
505
|
+
* How long either half of the capability check may take.
|
|
506
|
+
*
|
|
507
|
+
* Short, because both are expected to be immediate: a loopback request that
|
|
508
|
+
* works answers in well under a millisecond. The bound exists so a deployment
|
|
509
|
+
* that cannot do this says so by falling through to the manual form rather
|
|
510
|
+
* than by leaving the card blank.
|
|
511
|
+
*/
|
|
512
|
+
const PROBE_TIMEOUT_MS = 3e3;
|
|
513
|
+
/** Routes the browser half drives a login through. */
|
|
514
|
+
const LOGIN_START_ROUTE = "api/aishell/credentials/login/start";
|
|
515
|
+
const LOGIN_CANCEL_ROUTE = "api/aishell/credentials/login/cancel";
|
|
516
|
+
/**
|
|
517
|
+
* Reachability check, then login.
|
|
518
|
+
*
|
|
519
|
+
* Starts a login on the host and then proves this page can reach the listener
|
|
520
|
+
* it bound. The probe request goes from this browser to loopback, which is the
|
|
521
|
+
* same journey the cloud's callback will make.
|
|
522
|
+
*
|
|
523
|
+
* ## Why the probe is not a plain GET
|
|
524
|
+
*
|
|
525
|
+
* It carries a custom header, which makes it a non-simple request: the browser
|
|
526
|
+
* must send a CORS preflight first, and only proceeds if the answer is right.
|
|
527
|
+
* The cloud's callback is a JSON POST and therefore *always* preflights, so a
|
|
528
|
+
* plain GET would test a path the callback never takes — and could pass on a
|
|
529
|
+
* deployment where the real preflight fails (a missing Private Network Access
|
|
530
|
+
* allow header, say), which is the one wrong answer this check must not give.
|
|
531
|
+
*
|
|
532
|
+
* @returns a handle when the login is reachable, or `undefined` when it is
|
|
533
|
+
* not — the ordinary outcome on a deployment where the browser is elsewhere.
|
|
534
|
+
*/
|
|
535
|
+
async function startBrowserLogin() {
|
|
536
|
+
let started;
|
|
537
|
+
try {
|
|
538
|
+
const response = await fetch(LOGIN_START_ROUTE, {
|
|
539
|
+
method: "POST",
|
|
540
|
+
headers: { "content-type": "application/json" },
|
|
541
|
+
body: JSON.stringify({}),
|
|
542
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
|
|
543
|
+
});
|
|
544
|
+
started = await response.json();
|
|
545
|
+
} catch {
|
|
546
|
+
return void 0;
|
|
547
|
+
}
|
|
548
|
+
if (started.ok !== true || started.loginUrl === void 0) return void 0;
|
|
549
|
+
const loginUrl = started.loginUrl;
|
|
550
|
+
const providerName = started.providerName ?? "";
|
|
551
|
+
const expiresInSeconds = started.expiresInSeconds ?? 0;
|
|
552
|
+
const cancel = () => {
|
|
553
|
+
fetch(LOGIN_CANCEL_ROUTE, { method: "POST" }).catch(() => {});
|
|
554
|
+
};
|
|
555
|
+
if (started.probeUrl === void 0 || started.probeUrl === "") {
|
|
556
|
+
cancel();
|
|
557
|
+
return void 0;
|
|
558
|
+
}
|
|
559
|
+
try {
|
|
560
|
+
const probe = await fetch(started.probeUrl, {
|
|
561
|
+
method: "GET",
|
|
562
|
+
headers: { [PROBE_HEADER]: "1" },
|
|
563
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
|
|
564
|
+
});
|
|
565
|
+
if (!probe.ok) {
|
|
566
|
+
cancel();
|
|
567
|
+
return void 0;
|
|
568
|
+
}
|
|
569
|
+
} catch (error) {
|
|
570
|
+
cancel();
|
|
571
|
+
return void 0;
|
|
572
|
+
}
|
|
573
|
+
return {
|
|
574
|
+
loginUrl,
|
|
575
|
+
providerName,
|
|
576
|
+
expiresInSeconds,
|
|
577
|
+
cancel
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Open a login URL in a new tab.
|
|
582
|
+
*
|
|
583
|
+
* A separate tab rather than a redirect: the form has unsaved state and the
|
|
584
|
+
* person may come back to paste a key instead, and a login that navigated away
|
|
585
|
+
* from the conversation would lose it.
|
|
586
|
+
*
|
|
587
|
+
* ## Why `noopener` is set after opening, not passed in
|
|
588
|
+
*
|
|
589
|
+
* `window.open` returns `null` whenever `noopener` appears in its features
|
|
590
|
+
* string — by specification, not as a failure. Passing it there would make
|
|
591
|
+
* every successful open look blocked, so the tab is opened plainly and the
|
|
592
|
+
* opener reference is severed immediately afterwards, which is the same
|
|
593
|
+
* protection without losing the success signal.
|
|
594
|
+
*
|
|
595
|
+
* @param url - the URL the host returned.
|
|
596
|
+
* @returns whether the browser opened it; a popup blocker says no.
|
|
597
|
+
*/
|
|
598
|
+
function openLoginWindow(url) {
|
|
599
|
+
const opened = window.open(url, "_blank");
|
|
600
|
+
if (opened === null) return false;
|
|
601
|
+
try {
|
|
602
|
+
opened.opener = null;
|
|
603
|
+
} catch {}
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/client/spinner.ts
|
|
609
|
+
/** Class the waiting spinner carries. */
|
|
610
|
+
const SPINNER_CLASS = "aishell-spinner";
|
|
611
|
+
/** Marker identifying this sheet, so teardown sweeps exactly it. */
|
|
612
|
+
const SPINNER_STYLE_KEY = "aishell-credentials:spinner";
|
|
613
|
+
/** Plugin id the loader attributes the tag to. */
|
|
614
|
+
const PLUGIN_ID = "@huaweidevtools/aishell-dsh-client-credentials";
|
|
615
|
+
/**
|
|
616
|
+
* Install the spinner keyframes for the lifetime of the plugin fiber.
|
|
617
|
+
*
|
|
618
|
+
* Respects `prefers-reduced-motion`: a continuous rotation is exactly the kind
|
|
619
|
+
* of motion that setting exists to suppress, and the countdown beside it still
|
|
620
|
+
* conveys that work is in progress.
|
|
621
|
+
*
|
|
622
|
+
* @param ctx - the client context, for `ctx.effect`.
|
|
623
|
+
*/
|
|
624
|
+
function installSpinnerStyles(ctx) {
|
|
625
|
+
if (typeof document === "undefined") return;
|
|
626
|
+
ctx.effect(() => {
|
|
627
|
+
const tag = document.createElement("style");
|
|
628
|
+
tag.dataset.plugin = PLUGIN_ID;
|
|
629
|
+
tag.dataset.pluginCss = SPINNER_STYLE_KEY;
|
|
630
|
+
tag.textContent = `@keyframes ${SPINNER_CLASS}-rotate{to{transform:rotate(360deg)}}.${SPINNER_CLASS}{display:inline-block;border-radius:50%;border:2px solid var(--dsw-alias-border-l4);border-top-color:var(--dsw-alias-label-secondary);animation:${SPINNER_CLASS}-rotate .8s linear infinite}@media (prefers-reduced-motion:reduce){.${SPINNER_CLASS}{animation:none}}`;
|
|
631
|
+
document.head.appendChild(tag);
|
|
632
|
+
return () => {
|
|
633
|
+
tag.remove();
|
|
634
|
+
};
|
|
635
|
+
}, "aishell-credentials: spinner styles");
|
|
636
|
+
}
|
|
637
|
+
|
|
460
638
|
//#endregion
|
|
461
639
|
//#region src/client/CredentialRequestForm.tsx
|
|
462
640
|
/**
|
|
@@ -485,6 +663,40 @@ function CredentialRequestForm(props) {
|
|
|
485
663
|
* cannot tell whether to trust it.
|
|
486
664
|
*/
|
|
487
665
|
const [prefilled, setPrefilled] = (0, react.useState)(false);
|
|
666
|
+
/**
|
|
667
|
+
* The browser-login entry, once the host has started one and this page has
|
|
668
|
+
* proved it can reach the listener.
|
|
669
|
+
*
|
|
670
|
+
* `undefined` while that is still being decided, and `null` once it is
|
|
671
|
+
* decided against — the distinction matters, because "still checking" must
|
|
672
|
+
* not render the entry and "cannot" must not either, but only one of them
|
|
673
|
+
* resolves into it appearing.
|
|
674
|
+
*/
|
|
675
|
+
const [browserLogin, setBrowserLogin] = (0, react.useState)(void 0);
|
|
676
|
+
/**
|
|
677
|
+
* Which page the card is on.
|
|
678
|
+
*
|
|
679
|
+
* `choose` is the first page: the browser entry, if this deployment has one,
|
|
680
|
+
* and the way to the manual form. `manual` is the AK/SK form — what the card
|
|
681
|
+
* has always been. `waiting` is a browser login in flight.
|
|
682
|
+
*
|
|
683
|
+
* Starts on `manual`, which is what the card has always been, and moves to
|
|
684
|
+
* `choose` only once the probe has proved a browser login is possible here.
|
|
685
|
+
* The other order — opening on `choose` and falling back — would show a
|
|
686
|
+
* browser button that does nothing while the probe is in flight, and would
|
|
687
|
+
* land a deployment that cannot do this on a page it has no use for.
|
|
688
|
+
*/
|
|
689
|
+
const [page, setPage] = (0, react.useState)("manual");
|
|
690
|
+
/** Seconds left before the login can no longer complete; `undefined` when idle. */
|
|
691
|
+
const [secondsLeft, setSecondsLeft] = (0, react.useState)(void 0);
|
|
692
|
+
/**
|
|
693
|
+
* Whether the person has started filling the manual form.
|
|
694
|
+
*
|
|
695
|
+
* The probe is fast on the deployments this works on and slow on the ones it
|
|
696
|
+
* does not, so its answer can arrive after someone has begun typing. When it
|
|
697
|
+
* does, the choice page must not replace the form under their cursor.
|
|
698
|
+
*/
|
|
699
|
+
const interacted = (0, react.useRef)(false);
|
|
488
700
|
(0, react.useEffect)(() => {
|
|
489
701
|
let live = true;
|
|
490
702
|
props.readPrefill().then((prefill) => {
|
|
@@ -499,6 +711,91 @@ function CredentialRequestForm(props) {
|
|
|
499
711
|
live = false;
|
|
500
712
|
};
|
|
501
713
|
}, []);
|
|
714
|
+
(0, react.useEffect)(() => {
|
|
715
|
+
let live = true;
|
|
716
|
+
props.startBrowserLogin().then((handle) => {
|
|
717
|
+
if (!live) {
|
|
718
|
+
handle?.cancel();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
setBrowserLogin(handle ?? null);
|
|
722
|
+
if (handle !== null && !interacted.current) setPage("choose");
|
|
723
|
+
}).catch(() => {
|
|
724
|
+
if (!live) return;
|
|
725
|
+
setBrowserLogin(null);
|
|
726
|
+
});
|
|
727
|
+
return () => {
|
|
728
|
+
live = false;
|
|
729
|
+
};
|
|
730
|
+
}, []);
|
|
731
|
+
(0, react.useEffect)(() => () => {
|
|
732
|
+
browserLogin?.cancel();
|
|
733
|
+
}, [browserLogin]);
|
|
734
|
+
(0, react.useEffect)(() => {
|
|
735
|
+
if (page !== "waiting" || secondsLeft === void 0) return;
|
|
736
|
+
const deadline = Date.now() + secondsLeft * 1e3;
|
|
737
|
+
const timer = window.setInterval(() => {
|
|
738
|
+
setSecondsLeft(Math.max(0, Math.round((deadline - Date.now()) / 1e3)));
|
|
739
|
+
}, 1e3);
|
|
740
|
+
return () => {
|
|
741
|
+
window.clearInterval(timer);
|
|
742
|
+
};
|
|
743
|
+
}, [page]);
|
|
744
|
+
const outcomeRaw = props.useLoginOutcome((snapshot) => snapshot);
|
|
745
|
+
/**
|
|
746
|
+
* The outcome already recorded when this form opened.
|
|
747
|
+
*
|
|
748
|
+
* The document keeps the last login's outcome, so a form opened later would
|
|
749
|
+
* otherwise react to a result that has nothing to do with it: after a
|
|
750
|
+
* successful login the next open would close itself on the spot, and after a
|
|
751
|
+
* failed one it would show that error before the person typed anything.
|
|
752
|
+
* Baselines are per mount, which is per open — the interaction's key changes
|
|
753
|
+
* on reopen, so the component remounts.
|
|
754
|
+
*/
|
|
755
|
+
const outcomeAtMount = (0, react.useRef)(null);
|
|
756
|
+
if (outcomeAtMount.current === null) outcomeAtMount.current = outcomeRaw;
|
|
757
|
+
(0, react.useEffect)(() => {
|
|
758
|
+
if (outcomeRaw === outcomeAtMount.current) return;
|
|
759
|
+
const outcome = decodeOutcome(outcomeRaw);
|
|
760
|
+
if (outcome === void 0) return;
|
|
761
|
+
if (outcome.kind === "succeeded") {
|
|
762
|
+
setAk("");
|
|
763
|
+
setSk("");
|
|
764
|
+
setToken("");
|
|
765
|
+
close();
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
setPage(browserLogin ? "choose" : "manual");
|
|
769
|
+
setSecondsLeft(void 0);
|
|
770
|
+
setError(outcome.kind === "failed" && outcome.error !== "" ? t("form.browser.failed") + outcome.error : void 0);
|
|
771
|
+
}, [outcomeRaw]);
|
|
772
|
+
const onBrowserLogin = () => {
|
|
773
|
+
if (browserLogin === null || browserLogin === void 0) return;
|
|
774
|
+
setError(void 0);
|
|
775
|
+
if (!openLoginWindow(browserLogin.loginUrl)) {
|
|
776
|
+
setError(t("form.browser.blocked"));
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
setPage("waiting");
|
|
780
|
+
setSecondsLeft(browserLogin.expiresInSeconds);
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* Abandon the browser login.
|
|
784
|
+
*
|
|
785
|
+
* This is a cancel, not a dismissal: the card is up because a tool call is
|
|
786
|
+
* blocked on it, so closing it has to answer that call. `cancel` does both —
|
|
787
|
+
* it records the refusal against the request token (so the tool stops
|
|
788
|
+
* asking) and withdraws the interaction — and it releases the host's
|
|
789
|
+
* listener, whose URL is dead the moment this card goes away.
|
|
790
|
+
*/
|
|
791
|
+
const onCancelWaiting = () => {
|
|
792
|
+
onCancel();
|
|
793
|
+
};
|
|
794
|
+
/** Reopen the sign-in tab after the person closed it by accident. */
|
|
795
|
+
const onReopen = () => {
|
|
796
|
+
if (browserLogin === null || browserLogin === void 0) return;
|
|
797
|
+
if (!openLoginWindow(browserLogin.loginUrl)) setError(t("form.browser.blocked"));
|
|
798
|
+
};
|
|
502
799
|
const onSubmit = async (event) => {
|
|
503
800
|
event.preventDefault();
|
|
504
801
|
setSaving(true);
|
|
@@ -532,6 +829,7 @@ function CredentialRequestForm(props) {
|
|
|
532
829
|
}
|
|
533
830
|
};
|
|
534
831
|
const onCancel = () => {
|
|
832
|
+
browserLogin?.cancel();
|
|
535
833
|
cancel();
|
|
536
834
|
};
|
|
537
835
|
const fieldStyle = {
|
|
@@ -597,169 +895,359 @@ function CredentialRequestForm(props) {
|
|
|
597
895
|
gap: 12
|
|
598
896
|
},
|
|
599
897
|
children: [
|
|
600
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
898
|
+
page === "choose" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
899
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
900
|
+
style: {
|
|
901
|
+
display: "flex",
|
|
902
|
+
flexDirection: "column",
|
|
903
|
+
gap: 4
|
|
904
|
+
},
|
|
905
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
608
906
|
style: {
|
|
609
907
|
fontSize: 14,
|
|
610
908
|
fontWeight: 500,
|
|
611
909
|
lineHeight: "22px"
|
|
612
910
|
},
|
|
613
|
-
children: t("form.
|
|
614
|
-
}),
|
|
615
|
-
prefilled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
616
|
-
role: "note",
|
|
617
|
-
style: {
|
|
618
|
-
fontSize: 12,
|
|
619
|
-
lineHeight: "18px",
|
|
620
|
-
color: "var(--dsw-alias-state-warn-label)"
|
|
621
|
-
},
|
|
622
|
-
children: t("form.prefilledFromEnv")
|
|
623
|
-
}),
|
|
624
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
625
|
-
style: {
|
|
626
|
-
fontSize: 12,
|
|
627
|
-
lineHeight: "18px",
|
|
628
|
-
color: "var(--dsw-alias-label-tertiary)"
|
|
629
|
-
},
|
|
630
|
-
children: [
|
|
631
|
-
t("section.credentials.hint.prefix"),
|
|
632
|
-
" ",
|
|
633
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
634
|
-
href: CREDENTIAL_URL,
|
|
635
|
-
target: "_blank",
|
|
636
|
-
rel: "noreferrer noopener",
|
|
637
|
-
style: {
|
|
638
|
-
color: "var(--dsw-alias-button-primary-fill)",
|
|
639
|
-
textDecoration: "underline"
|
|
640
|
-
},
|
|
641
|
-
children: t("section.credentials.hint.link")
|
|
642
|
-
}),
|
|
643
|
-
" ",
|
|
644
|
-
t("section.credentials.hint.suffix")
|
|
645
|
-
]
|
|
911
|
+
children: t("form.intro")
|
|
646
912
|
})
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
913
|
+
}),
|
|
914
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
915
|
+
style: {
|
|
916
|
+
margin: 0,
|
|
917
|
+
fontSize: 12,
|
|
918
|
+
lineHeight: "18px",
|
|
919
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
920
|
+
},
|
|
921
|
+
children: error
|
|
922
|
+
}),
|
|
923
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
924
|
+
style: {
|
|
925
|
+
display: "flex",
|
|
926
|
+
gap: 8
|
|
927
|
+
},
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
930
|
+
type: "button",
|
|
931
|
+
onClick: () => {
|
|
932
|
+
onBrowserLogin();
|
|
933
|
+
},
|
|
934
|
+
style: {
|
|
935
|
+
...buttonStyle(false),
|
|
936
|
+
background: "var(--dsw-alias-button-primary-fill)",
|
|
937
|
+
color: "var(--dsw-alias-label-primary-foreground)"
|
|
938
|
+
},
|
|
939
|
+
children: t("form.browser.action")
|
|
940
|
+
}),
|
|
941
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
942
|
+
type: "button",
|
|
943
|
+
onClick: () => {
|
|
944
|
+
setPage("manual");
|
|
945
|
+
setError(void 0);
|
|
946
|
+
},
|
|
947
|
+
style: {
|
|
948
|
+
...buttonStyle(false),
|
|
949
|
+
background: "transparent",
|
|
950
|
+
color: "var(--dsw-alias-label-primary)",
|
|
951
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
952
|
+
},
|
|
953
|
+
children: t("form.browser.aksk")
|
|
954
|
+
}),
|
|
955
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
956
|
+
type: "button",
|
|
957
|
+
onClick: onCancel,
|
|
958
|
+
style: {
|
|
959
|
+
...buttonStyle(false),
|
|
960
|
+
background: "transparent",
|
|
961
|
+
color: "var(--dsw-alias-label-primary)",
|
|
962
|
+
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
963
|
+
marginLeft: "auto"
|
|
964
|
+
},
|
|
965
|
+
children: t("form.browser.decline")
|
|
966
|
+
})
|
|
967
|
+
]
|
|
968
|
+
})
|
|
969
|
+
] }),
|
|
970
|
+
page === "waiting" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
971
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
972
|
+
style: {
|
|
973
|
+
display: "flex",
|
|
974
|
+
flexDirection: "column",
|
|
975
|
+
alignItems: "center",
|
|
976
|
+
gap: 12,
|
|
977
|
+
padding: "8px 0"
|
|
978
|
+
},
|
|
979
|
+
children: [
|
|
980
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
981
|
+
role: "status",
|
|
982
|
+
style: {
|
|
983
|
+
fontSize: 14,
|
|
984
|
+
fontWeight: 500,
|
|
985
|
+
lineHeight: "22px"
|
|
986
|
+
},
|
|
987
|
+
children: t("form.browser.waiting")
|
|
988
|
+
}),
|
|
989
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
990
|
+
className: SPINNER_CLASS,
|
|
991
|
+
style: {
|
|
992
|
+
width: 28,
|
|
993
|
+
height: 28
|
|
994
|
+
},
|
|
995
|
+
"aria-hidden": true
|
|
996
|
+
}),
|
|
997
|
+
secondsLeft !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
998
|
+
style: {
|
|
999
|
+
fontSize: 13,
|
|
1000
|
+
fontVariantNumeric: "tabular-nums",
|
|
1001
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1002
|
+
},
|
|
1003
|
+
children: t("form.browser.countdown", { time: formatCountdown(secondsLeft) })
|
|
1004
|
+
})
|
|
1005
|
+
]
|
|
1006
|
+
}),
|
|
1007
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1008
|
+
style: {
|
|
1009
|
+
margin: 0,
|
|
1010
|
+
fontSize: 12,
|
|
1011
|
+
lineHeight: "18px",
|
|
1012
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1013
|
+
},
|
|
1014
|
+
children: error
|
|
1015
|
+
}),
|
|
1016
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1017
|
+
style: {
|
|
1018
|
+
display: "flex",
|
|
1019
|
+
gap: 8
|
|
1020
|
+
},
|
|
1021
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
731
1022
|
type: "button",
|
|
732
|
-
onClick:
|
|
733
|
-
disabled: busy,
|
|
1023
|
+
onClick: onCancelWaiting,
|
|
734
1024
|
style: {
|
|
735
|
-
...buttonStyle(
|
|
1025
|
+
...buttonStyle(false),
|
|
736
1026
|
background: "transparent",
|
|
737
1027
|
color: "var(--dsw-alias-label-primary)",
|
|
738
1028
|
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
739
1029
|
},
|
|
740
1030
|
children: t("form.dismiss")
|
|
741
|
-
}),
|
|
742
|
-
hasCredentials && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1031
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
743
1032
|
type: "button",
|
|
744
|
-
onClick:
|
|
745
|
-
onClear();
|
|
746
|
-
},
|
|
747
|
-
disabled: busy,
|
|
1033
|
+
onClick: onReopen,
|
|
748
1034
|
style: {
|
|
749
|
-
...buttonStyle(
|
|
1035
|
+
...buttonStyle(false),
|
|
750
1036
|
background: "transparent",
|
|
751
1037
|
color: "var(--dsw-alias-label-primary)",
|
|
752
1038
|
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
753
1039
|
marginLeft: "auto"
|
|
754
1040
|
},
|
|
755
|
-
children:
|
|
756
|
-
})
|
|
757
|
-
|
|
758
|
-
})
|
|
1041
|
+
children: t("form.browser.reopen")
|
|
1042
|
+
})]
|
|
1043
|
+
})
|
|
1044
|
+
] }),
|
|
1045
|
+
page === "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1046
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1047
|
+
style: {
|
|
1048
|
+
display: "flex",
|
|
1049
|
+
flexDirection: "column",
|
|
1050
|
+
gap: 4
|
|
1051
|
+
},
|
|
1052
|
+
children: [
|
|
1053
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1054
|
+
style: {
|
|
1055
|
+
fontSize: 14,
|
|
1056
|
+
fontWeight: 500,
|
|
1057
|
+
lineHeight: "22px"
|
|
1058
|
+
},
|
|
1059
|
+
children: t("form.title.manual")
|
|
1060
|
+
}),
|
|
1061
|
+
prefilled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1062
|
+
role: "note",
|
|
1063
|
+
style: {
|
|
1064
|
+
fontSize: 12,
|
|
1065
|
+
lineHeight: "18px",
|
|
1066
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1067
|
+
},
|
|
1068
|
+
children: t("form.prefilledFromEnv")
|
|
1069
|
+
}),
|
|
1070
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1071
|
+
style: {
|
|
1072
|
+
fontSize: 12,
|
|
1073
|
+
lineHeight: "18px",
|
|
1074
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1075
|
+
},
|
|
1076
|
+
children: [
|
|
1077
|
+
t("section.credentials.hint.prefix"),
|
|
1078
|
+
" ",
|
|
1079
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
1080
|
+
href: CREDENTIAL_URL,
|
|
1081
|
+
target: "_blank",
|
|
1082
|
+
rel: "noreferrer noopener",
|
|
1083
|
+
style: {
|
|
1084
|
+
color: "var(--dsw-alias-button-primary-fill)",
|
|
1085
|
+
textDecoration: "underline"
|
|
1086
|
+
},
|
|
1087
|
+
children: t("section.credentials.hint.link")
|
|
1088
|
+
}),
|
|
1089
|
+
" ",
|
|
1090
|
+
t("section.credentials.hint.suffix")
|
|
1091
|
+
]
|
|
1092
|
+
})
|
|
1093
|
+
]
|
|
1094
|
+
}),
|
|
1095
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1096
|
+
style: fieldStyle,
|
|
1097
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1098
|
+
style: labelStyle,
|
|
1099
|
+
children: [t("section.field.accessKey"), status.accessKeyIdHint && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1100
|
+
style: {
|
|
1101
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
1102
|
+
fontWeight: 400
|
|
1103
|
+
},
|
|
1104
|
+
children: [
|
|
1105
|
+
"(",
|
|
1106
|
+
status.accessKeyIdHint,
|
|
1107
|
+
")"
|
|
1108
|
+
]
|
|
1109
|
+
})]
|
|
1110
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1111
|
+
type: "password",
|
|
1112
|
+
value: ak,
|
|
1113
|
+
onChange: (e) => {
|
|
1114
|
+
interacted.current = true;
|
|
1115
|
+
setAk(e.target.value);
|
|
1116
|
+
},
|
|
1117
|
+
style: inputStyle,
|
|
1118
|
+
placeholder: t("section.field.accessKey.placeholder"),
|
|
1119
|
+
"aria-label": t("section.field.accessKey"),
|
|
1120
|
+
autoComplete: "off",
|
|
1121
|
+
autoFocus: true
|
|
1122
|
+
})]
|
|
1123
|
+
}),
|
|
1124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1125
|
+
style: fieldStyle,
|
|
1126
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1127
|
+
style: labelStyle,
|
|
1128
|
+
children: t("section.field.secretKey")
|
|
1129
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1130
|
+
type: "password",
|
|
1131
|
+
value: sk,
|
|
1132
|
+
onChange: (e) => {
|
|
1133
|
+
interacted.current = true;
|
|
1134
|
+
setSk(e.target.value);
|
|
1135
|
+
},
|
|
1136
|
+
style: inputStyle,
|
|
1137
|
+
placeholder: t("section.field.secretKey.placeholder"),
|
|
1138
|
+
"aria-label": t("section.field.secretKey"),
|
|
1139
|
+
autoComplete: "off"
|
|
1140
|
+
})]
|
|
1141
|
+
}),
|
|
1142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1143
|
+
style: fieldStyle,
|
|
1144
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1145
|
+
style: labelStyle,
|
|
1146
|
+
children: t("section.field.token")
|
|
1147
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1148
|
+
type: "password",
|
|
1149
|
+
value: token,
|
|
1150
|
+
onChange: (e) => {
|
|
1151
|
+
interacted.current = true;
|
|
1152
|
+
setToken(e.target.value);
|
|
1153
|
+
},
|
|
1154
|
+
style: inputStyle,
|
|
1155
|
+
placeholder: t("section.field.token.placeholder"),
|
|
1156
|
+
"aria-label": t("section.field.token"),
|
|
1157
|
+
autoComplete: "off"
|
|
1158
|
+
})]
|
|
1159
|
+
}),
|
|
1160
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1161
|
+
style: {
|
|
1162
|
+
margin: 0,
|
|
1163
|
+
fontSize: 12,
|
|
1164
|
+
lineHeight: "18px",
|
|
1165
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1166
|
+
},
|
|
1167
|
+
children: error
|
|
1168
|
+
}),
|
|
1169
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1170
|
+
style: {
|
|
1171
|
+
display: "flex",
|
|
1172
|
+
gap: 8
|
|
1173
|
+
},
|
|
1174
|
+
children: [
|
|
1175
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1176
|
+
type: "submit",
|
|
1177
|
+
disabled,
|
|
1178
|
+
style: {
|
|
1179
|
+
...buttonStyle(disabled),
|
|
1180
|
+
background: "var(--dsw-alias-button-primary-fill)",
|
|
1181
|
+
color: "var(--dsw-alias-label-primary-foreground)"
|
|
1182
|
+
},
|
|
1183
|
+
children: saving ? t("section.credentials.saving") : t("form.submit")
|
|
1184
|
+
}),
|
|
1185
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1186
|
+
type: "button",
|
|
1187
|
+
onClick: onCancel,
|
|
1188
|
+
disabled: busy,
|
|
1189
|
+
style: {
|
|
1190
|
+
...buttonStyle(busy),
|
|
1191
|
+
background: "transparent",
|
|
1192
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1193
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
1194
|
+
},
|
|
1195
|
+
children: t("form.dismiss")
|
|
1196
|
+
}),
|
|
1197
|
+
browserLogin !== null && browserLogin !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1198
|
+
type: "button",
|
|
1199
|
+
onClick: () => {
|
|
1200
|
+
setPage("choose");
|
|
1201
|
+
setError(void 0);
|
|
1202
|
+
},
|
|
1203
|
+
disabled: busy,
|
|
1204
|
+
style: {
|
|
1205
|
+
...buttonStyle(busy),
|
|
1206
|
+
background: "transparent",
|
|
1207
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1208
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
1209
|
+
},
|
|
1210
|
+
children: t("form.back")
|
|
1211
|
+
}),
|
|
1212
|
+
hasCredentials && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1213
|
+
type: "button",
|
|
1214
|
+
onClick: () => {
|
|
1215
|
+
onClear();
|
|
1216
|
+
},
|
|
1217
|
+
disabled: busy,
|
|
1218
|
+
style: {
|
|
1219
|
+
...buttonStyle(busy),
|
|
1220
|
+
background: "transparent",
|
|
1221
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1222
|
+
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
1223
|
+
marginLeft: "auto"
|
|
1224
|
+
},
|
|
1225
|
+
children: clearing ? t("form.clearing") : t("form.clear")
|
|
1226
|
+
})
|
|
1227
|
+
]
|
|
1228
|
+
})
|
|
1229
|
+
] })
|
|
759
1230
|
]
|
|
760
1231
|
})
|
|
761
1232
|
});
|
|
762
1233
|
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Render a countdown as `m:ss`.
|
|
1236
|
+
*
|
|
1237
|
+
* Language-neutral on purpose: the surrounding sentence is localised, and a
|
|
1238
|
+
* number plus a unit needs no translation to read — whereas spelling out
|
|
1239
|
+
* "minutes"/"分" would put a second copy of the same unit in both dictionaries
|
|
1240
|
+
* for no gain. Tabular figures are applied at the call site so the digits do
|
|
1241
|
+
* not jitter as they change.
|
|
1242
|
+
*
|
|
1243
|
+
* @param seconds - seconds remaining.
|
|
1244
|
+
*/
|
|
1245
|
+
function formatCountdown(seconds) {
|
|
1246
|
+
const whole = Math.max(0, Math.floor(seconds));
|
|
1247
|
+
const minutes = Math.floor(whole / 60);
|
|
1248
|
+
const rest = whole % 60;
|
|
1249
|
+
return `${String(minutes)}:${String(rest).padStart(2, "0")}`;
|
|
1250
|
+
}
|
|
763
1251
|
|
|
764
1252
|
//#endregion
|
|
765
1253
|
//#region src/client/CredentialFormInteraction.ts
|
|
@@ -878,7 +1366,6 @@ const zh = {
|
|
|
878
1366
|
"section.credentials.hint.link": "API Explorer",
|
|
879
1367
|
"section.credentials.hint.suffix": "获取临时凭据,避免使用永久凭据。",
|
|
880
1368
|
"section.credentials.saving": "保存中…",
|
|
881
|
-
"form.title": "需要华为云凭据",
|
|
882
1369
|
"form.title.manual": "配置华为云凭据",
|
|
883
1370
|
"form.prefilledFromEnv": "检测到环境变量,已填入表单",
|
|
884
1371
|
"form.submit": "提交",
|
|
@@ -888,6 +1375,16 @@ const zh = {
|
|
|
888
1375
|
"form.clearing": "清除中…",
|
|
889
1376
|
"form.clear.failed": "清除凭据失败",
|
|
890
1377
|
"error.unreachable": "无法连接宿主凭据服务:",
|
|
1378
|
+
"form.intro": "需要进行华为云 IAM 认证",
|
|
1379
|
+
"form.browser.action": "浏览器登录",
|
|
1380
|
+
"form.browser.aksk": "我有AK/SK",
|
|
1381
|
+
"form.browser.decline": "暂不认证",
|
|
1382
|
+
"form.browser.waiting": "正在等待浏览器完成登录…",
|
|
1383
|
+
"form.browser.countdown": "剩余 {time}",
|
|
1384
|
+
"form.browser.reopen": "重新打开",
|
|
1385
|
+
"form.back": "返回",
|
|
1386
|
+
"form.browser.blocked": "浏览器拦截了新标签页,请允许弹出窗口后重试。",
|
|
1387
|
+
"form.browser.failed": "浏览器登录未完成:",
|
|
891
1388
|
"section.field.accessKey": "Access Key",
|
|
892
1389
|
"section.field.accessKey.placeholder": "华为云 Access Key",
|
|
893
1390
|
"section.field.accessKey.hint": "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。",
|
|
@@ -913,7 +1410,6 @@ const en = {
|
|
|
913
1410
|
"section.credentials.hint.link": "API Explorer",
|
|
914
1411
|
"section.credentials.hint.suffix": "and avoid permanent ones.",
|
|
915
1412
|
"section.credentials.saving": "Saving…",
|
|
916
|
-
"form.title": "Huawei Cloud credentials required",
|
|
917
1413
|
"form.title.manual": "Configure Huawei Cloud credentials",
|
|
918
1414
|
"form.prefilledFromEnv": "Detected environment variables — filled in from them",
|
|
919
1415
|
"form.submit": "Submit",
|
|
@@ -923,6 +1419,16 @@ const en = {
|
|
|
923
1419
|
"form.clearing": "Clearing…",
|
|
924
1420
|
"form.clear.failed": "Could not clear credentials",
|
|
925
1421
|
"error.unreachable": "Could not reach the host credential service: ",
|
|
1422
|
+
"form.intro": "Huawei Cloud IAM authentication is required",
|
|
1423
|
+
"form.browser.action": "Sign in with a browser",
|
|
1424
|
+
"form.browser.aksk": "I have one",
|
|
1425
|
+
"form.browser.decline": "Not now",
|
|
1426
|
+
"form.browser.waiting": "Waiting for the browser sign-in to finish…",
|
|
1427
|
+
"form.browser.countdown": "{time} left",
|
|
1428
|
+
"form.browser.reopen": "Reopen",
|
|
1429
|
+
"form.back": "Back",
|
|
1430
|
+
"form.browser.blocked": "The browser blocked the new tab. Allow pop-ups for this page, then try again.",
|
|
1431
|
+
"form.browser.failed": "The browser sign-in did not complete: ",
|
|
926
1432
|
"section.field.accessKey": "Access Key",
|
|
927
1433
|
"section.field.accessKey.placeholder": "Huawei Access Key",
|
|
928
1434
|
"section.field.accessKey.hint": "Access Key and Secret Key are stored as a pair; one without the other is not saved.",
|
|
@@ -1044,6 +1550,7 @@ function apply(ctx) {
|
|
|
1044
1550
|
}), "aishell-credentials: dictionaries");
|
|
1045
1551
|
const t = ctx.locale.bind(NS);
|
|
1046
1552
|
installChipStyles(ctx);
|
|
1553
|
+
installSpinnerStyles(ctx);
|
|
1047
1554
|
const form = ctx.configForms.get(AISHELL_CREDENTIALS_NS);
|
|
1048
1555
|
const status = (0, __deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
1049
1556
|
hasAccessKey: false,
|
|
@@ -1065,6 +1572,10 @@ function apply(ctx) {
|
|
|
1065
1572
|
};
|
|
1066
1573
|
ctx.effect(() => form.subscribe(derive), "aishell-credentials: credential presence");
|
|
1067
1574
|
derive();
|
|
1575
|
+
const loginOutcome = (0, __deepseek_ai_dsh_client_store.createSnapshotStore)(form.getSnapshot().value?.loginOutcome ?? "");
|
|
1576
|
+
ctx.effect(() => form.subscribe(() => {
|
|
1577
|
+
loginOutcome.set(form.getSnapshot().value?.loginOutcome ?? "");
|
|
1578
|
+
}), "aishell-credentials: login outcome");
|
|
1068
1579
|
const publishCredentialForm = ctx.uiSession.registerPendingInteraction(() => 0);
|
|
1069
1580
|
const visibility = createCredentialFormVisibility((interaction) => publishCredentialForm(interaction, () => Promise.resolve()));
|
|
1070
1581
|
/** The last request the browser acted on, so a re-read is not a re-open. */
|
|
@@ -1139,9 +1650,13 @@ function apply(ctx) {
|
|
|
1139
1650
|
select: ({ pendingInteraction }) => isCredentialForm(pendingInteraction) ? pendingInteraction : null,
|
|
1140
1651
|
locale: NS,
|
|
1141
1652
|
inject: () => ({
|
|
1142
|
-
hooks: {
|
|
1653
|
+
hooks: {
|
|
1654
|
+
credentials: status,
|
|
1655
|
+
loginOutcome
|
|
1656
|
+
},
|
|
1143
1657
|
save: (ak, sk, token) => saveCredential(t, ak, sk, token, pendingRequestToken),
|
|
1144
1658
|
readPrefill: () => readPrefill(),
|
|
1659
|
+
startBrowserLogin: () => startBrowserLogin(),
|
|
1145
1660
|
clear: () => clearBothStores(t),
|
|
1146
1661
|
close: () => {
|
|
1147
1662
|
visibility.close();
|