@huaweidevtools/aishell-dsh-client-credentials 0.0.1-beta.6 → 0.0.1-beta.8
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 +687 -145
- package/lib/index.js +933 -24
- package/lib/types/auth-tool.d.ts +14 -0
- package/lib/types/client/CredentialRequestForm.d.ts +17 -0
- package/lib/types/client/locales.d.ts +22 -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,41 @@ 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. `waiting` is a
|
|
681
|
+
* browser login in flight.
|
|
682
|
+
*
|
|
683
|
+
* The card opens on `choose` and settles on `manual` if the probe comes back
|
|
684
|
+
* negative, which is what the probe decides. Opening on `manual` and jumping
|
|
685
|
+
* to `choose` was worse in a way that is visible: the person saw the AK/SK
|
|
686
|
+
* fields, started reading them, and had them replaced underfoot a moment
|
|
687
|
+
* later. `undefined` is "not decided yet", and renders the card's frame with
|
|
688
|
+
* neither page's body — see `page === undefined` below.
|
|
689
|
+
*/
|
|
690
|
+
const [page, setPage] = (0, react.useState)(void 0);
|
|
691
|
+
/** Seconds left before the login can no longer complete; `undefined` when idle. */
|
|
692
|
+
const [secondsLeft, setSecondsLeft] = (0, react.useState)(void 0);
|
|
693
|
+
/**
|
|
694
|
+
* Whether the person has started filling the manual form.
|
|
695
|
+
*
|
|
696
|
+
* The probe is fast on the deployments this works on and slow on the ones it
|
|
697
|
+
* does not, so its answer can arrive after someone has begun typing. When it
|
|
698
|
+
* does, the choice page must not replace the form under their cursor.
|
|
699
|
+
*/
|
|
700
|
+
const interacted = (0, react.useRef)(false);
|
|
488
701
|
(0, react.useEffect)(() => {
|
|
489
702
|
let live = true;
|
|
490
703
|
props.readPrefill().then((prefill) => {
|
|
@@ -499,6 +712,92 @@ function CredentialRequestForm(props) {
|
|
|
499
712
|
live = false;
|
|
500
713
|
};
|
|
501
714
|
}, []);
|
|
715
|
+
(0, react.useEffect)(() => {
|
|
716
|
+
let live = true;
|
|
717
|
+
props.startBrowserLogin().then((handle) => {
|
|
718
|
+
if (!live) {
|
|
719
|
+
handle?.cancel();
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
setBrowserLogin(handle ?? null);
|
|
723
|
+
if (!interacted.current) setPage(handle === null ? "manual" : "choose");
|
|
724
|
+
}).catch(() => {
|
|
725
|
+
if (!live) return;
|
|
726
|
+
setBrowserLogin(null);
|
|
727
|
+
if (!interacted.current) setPage("manual");
|
|
728
|
+
});
|
|
729
|
+
return () => {
|
|
730
|
+
live = false;
|
|
731
|
+
};
|
|
732
|
+
}, []);
|
|
733
|
+
(0, react.useEffect)(() => () => {
|
|
734
|
+
browserLogin?.cancel();
|
|
735
|
+
}, [browserLogin]);
|
|
736
|
+
(0, react.useEffect)(() => {
|
|
737
|
+
if (page !== "waiting" || secondsLeft === void 0) return;
|
|
738
|
+
const deadline = Date.now() + secondsLeft * 1e3;
|
|
739
|
+
const timer = window.setInterval(() => {
|
|
740
|
+
setSecondsLeft(Math.max(0, Math.round((deadline - Date.now()) / 1e3)));
|
|
741
|
+
}, 1e3);
|
|
742
|
+
return () => {
|
|
743
|
+
window.clearInterval(timer);
|
|
744
|
+
};
|
|
745
|
+
}, [page]);
|
|
746
|
+
const outcomeRaw = props.useLoginOutcome((snapshot) => snapshot);
|
|
747
|
+
/**
|
|
748
|
+
* The outcome already recorded when this form opened.
|
|
749
|
+
*
|
|
750
|
+
* The document keeps the last login's outcome, so a form opened later would
|
|
751
|
+
* otherwise react to a result that has nothing to do with it: after a
|
|
752
|
+
* successful login the next open would close itself on the spot, and after a
|
|
753
|
+
* failed one it would show that error before the person typed anything.
|
|
754
|
+
* Baselines are per mount, which is per open — the interaction's key changes
|
|
755
|
+
* on reopen, so the component remounts.
|
|
756
|
+
*/
|
|
757
|
+
const outcomeAtMount = (0, react.useRef)(null);
|
|
758
|
+
if (outcomeAtMount.current === null) outcomeAtMount.current = outcomeRaw;
|
|
759
|
+
(0, react.useEffect)(() => {
|
|
760
|
+
if (outcomeRaw === outcomeAtMount.current) return;
|
|
761
|
+
const outcome = decodeOutcome(outcomeRaw);
|
|
762
|
+
if (outcome === void 0) return;
|
|
763
|
+
if (outcome.kind === "succeeded") {
|
|
764
|
+
setAk("");
|
|
765
|
+
setSk("");
|
|
766
|
+
setToken("");
|
|
767
|
+
close();
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
setPage(browserLogin ? "choose" : "manual");
|
|
771
|
+
setSecondsLeft(void 0);
|
|
772
|
+
setError(outcome.kind === "failed" && outcome.error !== "" ? t("form.browser.failed") + outcome.error : void 0);
|
|
773
|
+
}, [outcomeRaw]);
|
|
774
|
+
const onBrowserLogin = () => {
|
|
775
|
+
if (browserLogin === null || browserLogin === void 0) return;
|
|
776
|
+
setError(void 0);
|
|
777
|
+
if (!openLoginWindow(browserLogin.loginUrl)) {
|
|
778
|
+
setError(t("form.browser.blocked"));
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
setPage("waiting");
|
|
782
|
+
setSecondsLeft(browserLogin.expiresInSeconds);
|
|
783
|
+
};
|
|
784
|
+
/**
|
|
785
|
+
* Abandon the browser login.
|
|
786
|
+
*
|
|
787
|
+
* This is a cancel, not a dismissal: the card is up because a tool call is
|
|
788
|
+
* blocked on it, so closing it has to answer that call. `cancel` does both —
|
|
789
|
+
* it records the refusal against the request token (so the tool stops
|
|
790
|
+
* asking) and withdraws the interaction — and it releases the host's
|
|
791
|
+
* listener, whose URL is dead the moment this card goes away.
|
|
792
|
+
*/
|
|
793
|
+
const onCancelWaiting = () => {
|
|
794
|
+
onCancel();
|
|
795
|
+
};
|
|
796
|
+
/** Reopen the sign-in tab after the person closed it by accident. */
|
|
797
|
+
const onReopen = () => {
|
|
798
|
+
if (browserLogin === null || browserLogin === void 0) return;
|
|
799
|
+
if (!openLoginWindow(browserLogin.loginUrl)) setError(t("form.browser.blocked"));
|
|
800
|
+
};
|
|
502
801
|
const onSubmit = async (event) => {
|
|
503
802
|
event.preventDefault();
|
|
504
803
|
setSaving(true);
|
|
@@ -532,6 +831,7 @@ function CredentialRequestForm(props) {
|
|
|
532
831
|
}
|
|
533
832
|
};
|
|
534
833
|
const onCancel = () => {
|
|
834
|
+
browserLogin?.cancel();
|
|
535
835
|
cancel();
|
|
536
836
|
};
|
|
537
837
|
const fieldStyle = {
|
|
@@ -597,169 +897,382 @@ function CredentialRequestForm(props) {
|
|
|
597
897
|
gap: 12
|
|
598
898
|
},
|
|
599
899
|
children: [
|
|
600
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
900
|
+
page === "choose" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
901
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
902
|
+
style: {
|
|
903
|
+
display: "flex",
|
|
904
|
+
flexDirection: "column",
|
|
905
|
+
gap: 4
|
|
906
|
+
},
|
|
907
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
608
908
|
style: {
|
|
609
909
|
fontSize: 14,
|
|
610
910
|
fontWeight: 500,
|
|
611
911
|
lineHeight: "22px"
|
|
612
912
|
},
|
|
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
|
-
]
|
|
913
|
+
children: t("form.intro")
|
|
646
914
|
})
|
|
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
|
-
|
|
915
|
+
}),
|
|
916
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
917
|
+
style: {
|
|
918
|
+
margin: 0,
|
|
919
|
+
fontSize: 12,
|
|
920
|
+
lineHeight: "18px",
|
|
921
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
922
|
+
},
|
|
923
|
+
children: error
|
|
924
|
+
}),
|
|
925
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
926
|
+
style: {
|
|
927
|
+
display: "flex",
|
|
928
|
+
gap: 8
|
|
929
|
+
},
|
|
930
|
+
children: [
|
|
931
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
932
|
+
type: "button",
|
|
933
|
+
onClick: () => {
|
|
934
|
+
onBrowserLogin();
|
|
935
|
+
},
|
|
936
|
+
style: {
|
|
937
|
+
...buttonStyle(false),
|
|
938
|
+
background: "var(--dsw-alias-button-primary-fill)",
|
|
939
|
+
color: "var(--dsw-alias-label-primary-foreground)"
|
|
940
|
+
},
|
|
941
|
+
children: t("form.browser.action")
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
944
|
+
type: "button",
|
|
945
|
+
onClick: () => {
|
|
946
|
+
setPage("manual");
|
|
947
|
+
setError(void 0);
|
|
948
|
+
},
|
|
949
|
+
style: {
|
|
950
|
+
...buttonStyle(false),
|
|
951
|
+
background: "transparent",
|
|
952
|
+
color: "var(--dsw-alias-label-primary)",
|
|
953
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
954
|
+
},
|
|
955
|
+
children: t("form.browser.aksk")
|
|
956
|
+
}),
|
|
957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
958
|
+
type: "button",
|
|
959
|
+
onClick: onCancel,
|
|
960
|
+
style: {
|
|
961
|
+
...buttonStyle(false),
|
|
962
|
+
background: "transparent",
|
|
963
|
+
color: "var(--dsw-alias-label-primary)",
|
|
964
|
+
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
965
|
+
marginLeft: "auto"
|
|
966
|
+
},
|
|
967
|
+
children: t("form.browser.decline")
|
|
968
|
+
})
|
|
969
|
+
]
|
|
970
|
+
})
|
|
971
|
+
] }),
|
|
972
|
+
page === "waiting" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
973
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
974
|
+
style: {
|
|
975
|
+
display: "flex",
|
|
976
|
+
flexDirection: "column",
|
|
977
|
+
alignItems: "center",
|
|
978
|
+
gap: 12,
|
|
979
|
+
padding: "8px 0"
|
|
980
|
+
},
|
|
981
|
+
children: [
|
|
982
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
983
|
+
role: "status",
|
|
984
|
+
style: {
|
|
985
|
+
fontSize: 14,
|
|
986
|
+
fontWeight: 500,
|
|
987
|
+
lineHeight: "22px"
|
|
988
|
+
},
|
|
989
|
+
children: t("form.browser.waiting")
|
|
990
|
+
}),
|
|
991
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
992
|
+
className: SPINNER_CLASS,
|
|
993
|
+
style: {
|
|
994
|
+
width: 28,
|
|
995
|
+
height: 28
|
|
996
|
+
},
|
|
997
|
+
"aria-hidden": true
|
|
998
|
+
}),
|
|
999
|
+
secondsLeft !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1000
|
+
style: {
|
|
1001
|
+
fontSize: 13,
|
|
1002
|
+
fontVariantNumeric: "tabular-nums",
|
|
1003
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1004
|
+
},
|
|
1005
|
+
children: t("form.browser.countdown", { time: formatCountdown(secondsLeft) })
|
|
1006
|
+
})
|
|
1007
|
+
]
|
|
1008
|
+
}),
|
|
1009
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1010
|
+
style: {
|
|
1011
|
+
margin: 0,
|
|
1012
|
+
fontSize: 12,
|
|
1013
|
+
lineHeight: "18px",
|
|
1014
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1015
|
+
},
|
|
1016
|
+
children: error
|
|
1017
|
+
}),
|
|
1018
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1019
|
+
style: {
|
|
1020
|
+
display: "flex",
|
|
1021
|
+
gap: 8
|
|
1022
|
+
},
|
|
1023
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
731
1024
|
type: "button",
|
|
732
|
-
onClick:
|
|
733
|
-
disabled: busy,
|
|
1025
|
+
onClick: onCancelWaiting,
|
|
734
1026
|
style: {
|
|
735
|
-
...buttonStyle(
|
|
1027
|
+
...buttonStyle(false),
|
|
736
1028
|
background: "transparent",
|
|
737
1029
|
color: "var(--dsw-alias-label-primary)",
|
|
738
1030
|
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
739
1031
|
},
|
|
740
1032
|
children: t("form.dismiss")
|
|
741
|
-
}),
|
|
742
|
-
hasCredentials && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1033
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
743
1034
|
type: "button",
|
|
744
|
-
onClick:
|
|
745
|
-
onClear();
|
|
746
|
-
},
|
|
747
|
-
disabled: busy,
|
|
1035
|
+
onClick: onReopen,
|
|
748
1036
|
style: {
|
|
749
|
-
...buttonStyle(
|
|
1037
|
+
...buttonStyle(false),
|
|
750
1038
|
background: "transparent",
|
|
751
1039
|
color: "var(--dsw-alias-label-primary)",
|
|
752
1040
|
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
753
1041
|
marginLeft: "auto"
|
|
754
1042
|
},
|
|
755
|
-
children:
|
|
756
|
-
})
|
|
757
|
-
|
|
758
|
-
})
|
|
1043
|
+
children: t("form.browser.reopen")
|
|
1044
|
+
})]
|
|
1045
|
+
})
|
|
1046
|
+
] }),
|
|
1047
|
+
page === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1048
|
+
style: {
|
|
1049
|
+
display: "flex",
|
|
1050
|
+
alignItems: "center",
|
|
1051
|
+
gap: 10
|
|
1052
|
+
},
|
|
1053
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1054
|
+
className: SPINNER_CLASS,
|
|
1055
|
+
style: {
|
|
1056
|
+
width: 16,
|
|
1057
|
+
height: 16
|
|
1058
|
+
},
|
|
1059
|
+
"aria-hidden": true
|
|
1060
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1061
|
+
role: "status",
|
|
1062
|
+
style: {
|
|
1063
|
+
fontSize: 14,
|
|
1064
|
+
lineHeight: "22px",
|
|
1065
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
1066
|
+
},
|
|
1067
|
+
children: t("form.checking")
|
|
1068
|
+
})]
|
|
1069
|
+
}),
|
|
1070
|
+
page === "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1071
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1072
|
+
style: {
|
|
1073
|
+
display: "flex",
|
|
1074
|
+
flexDirection: "column",
|
|
1075
|
+
gap: 4
|
|
1076
|
+
},
|
|
1077
|
+
children: [
|
|
1078
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1079
|
+
style: {
|
|
1080
|
+
fontSize: 14,
|
|
1081
|
+
fontWeight: 500,
|
|
1082
|
+
lineHeight: "22px"
|
|
1083
|
+
},
|
|
1084
|
+
children: t("form.title.manual")
|
|
1085
|
+
}),
|
|
1086
|
+
prefilled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1087
|
+
role: "note",
|
|
1088
|
+
style: {
|
|
1089
|
+
fontSize: 12,
|
|
1090
|
+
lineHeight: "18px",
|
|
1091
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1092
|
+
},
|
|
1093
|
+
children: t("form.prefilledFromEnv")
|
|
1094
|
+
}),
|
|
1095
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1096
|
+
style: {
|
|
1097
|
+
fontSize: 12,
|
|
1098
|
+
lineHeight: "18px",
|
|
1099
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1100
|
+
},
|
|
1101
|
+
children: [
|
|
1102
|
+
t("section.credentials.hint.prefix"),
|
|
1103
|
+
" ",
|
|
1104
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
1105
|
+
href: CREDENTIAL_URL,
|
|
1106
|
+
target: "_blank",
|
|
1107
|
+
rel: "noreferrer noopener",
|
|
1108
|
+
style: {
|
|
1109
|
+
color: "var(--dsw-alias-button-primary-fill)",
|
|
1110
|
+
textDecoration: "underline"
|
|
1111
|
+
},
|
|
1112
|
+
children: t("section.credentials.hint.link")
|
|
1113
|
+
}),
|
|
1114
|
+
" ",
|
|
1115
|
+
t("section.credentials.hint.suffix")
|
|
1116
|
+
]
|
|
1117
|
+
})
|
|
1118
|
+
]
|
|
1119
|
+
}),
|
|
1120
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1121
|
+
style: fieldStyle,
|
|
1122
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1123
|
+
style: labelStyle,
|
|
1124
|
+
children: [t("section.field.accessKey"), status.accessKeyIdHint && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1125
|
+
style: {
|
|
1126
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
1127
|
+
fontWeight: 400
|
|
1128
|
+
},
|
|
1129
|
+
children: [
|
|
1130
|
+
"(",
|
|
1131
|
+
status.accessKeyIdHint,
|
|
1132
|
+
")"
|
|
1133
|
+
]
|
|
1134
|
+
})]
|
|
1135
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1136
|
+
type: "password",
|
|
1137
|
+
value: ak,
|
|
1138
|
+
onChange: (e) => {
|
|
1139
|
+
interacted.current = true;
|
|
1140
|
+
setAk(e.target.value);
|
|
1141
|
+
},
|
|
1142
|
+
style: inputStyle,
|
|
1143
|
+
placeholder: t("section.field.accessKey.placeholder"),
|
|
1144
|
+
"aria-label": t("section.field.accessKey"),
|
|
1145
|
+
autoComplete: "off",
|
|
1146
|
+
autoFocus: true
|
|
1147
|
+
})]
|
|
1148
|
+
}),
|
|
1149
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1150
|
+
style: fieldStyle,
|
|
1151
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1152
|
+
style: labelStyle,
|
|
1153
|
+
children: t("section.field.secretKey")
|
|
1154
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1155
|
+
type: "password",
|
|
1156
|
+
value: sk,
|
|
1157
|
+
onChange: (e) => {
|
|
1158
|
+
interacted.current = true;
|
|
1159
|
+
setSk(e.target.value);
|
|
1160
|
+
},
|
|
1161
|
+
style: inputStyle,
|
|
1162
|
+
placeholder: t("section.field.secretKey.placeholder"),
|
|
1163
|
+
"aria-label": t("section.field.secretKey"),
|
|
1164
|
+
autoComplete: "off"
|
|
1165
|
+
})]
|
|
1166
|
+
}),
|
|
1167
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1168
|
+
style: fieldStyle,
|
|
1169
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1170
|
+
style: labelStyle,
|
|
1171
|
+
children: t("section.field.token")
|
|
1172
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1173
|
+
type: "password",
|
|
1174
|
+
value: token,
|
|
1175
|
+
onChange: (e) => {
|
|
1176
|
+
interacted.current = true;
|
|
1177
|
+
setToken(e.target.value);
|
|
1178
|
+
},
|
|
1179
|
+
style: inputStyle,
|
|
1180
|
+
placeholder: t("section.field.token.placeholder"),
|
|
1181
|
+
"aria-label": t("section.field.token"),
|
|
1182
|
+
autoComplete: "off"
|
|
1183
|
+
})]
|
|
1184
|
+
}),
|
|
1185
|
+
error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1186
|
+
style: {
|
|
1187
|
+
margin: 0,
|
|
1188
|
+
fontSize: 12,
|
|
1189
|
+
lineHeight: "18px",
|
|
1190
|
+
color: "var(--dsw-alias-state-warn-label)"
|
|
1191
|
+
},
|
|
1192
|
+
children: error
|
|
1193
|
+
}),
|
|
1194
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1195
|
+
style: {
|
|
1196
|
+
display: "flex",
|
|
1197
|
+
gap: 8
|
|
1198
|
+
},
|
|
1199
|
+
children: [
|
|
1200
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1201
|
+
type: "submit",
|
|
1202
|
+
disabled,
|
|
1203
|
+
style: {
|
|
1204
|
+
...buttonStyle(disabled),
|
|
1205
|
+
background: "var(--dsw-alias-button-primary-fill)",
|
|
1206
|
+
color: "var(--dsw-alias-label-primary-foreground)"
|
|
1207
|
+
},
|
|
1208
|
+
children: saving ? t("section.credentials.saving") : t("form.submit")
|
|
1209
|
+
}),
|
|
1210
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1211
|
+
type: "button",
|
|
1212
|
+
onClick: onCancel,
|
|
1213
|
+
disabled: busy,
|
|
1214
|
+
style: {
|
|
1215
|
+
...buttonStyle(busy),
|
|
1216
|
+
background: "transparent",
|
|
1217
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1218
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
1219
|
+
},
|
|
1220
|
+
children: t("form.dismiss")
|
|
1221
|
+
}),
|
|
1222
|
+
browserLogin !== null && browserLogin !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1223
|
+
type: "button",
|
|
1224
|
+
onClick: () => {
|
|
1225
|
+
setPage("choose");
|
|
1226
|
+
setError(void 0);
|
|
1227
|
+
},
|
|
1228
|
+
disabled: busy,
|
|
1229
|
+
style: {
|
|
1230
|
+
...buttonStyle(busy),
|
|
1231
|
+
background: "transparent",
|
|
1232
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1233
|
+
border: "0.5px solid var(--dsw-alias-border-l4)"
|
|
1234
|
+
},
|
|
1235
|
+
children: t("form.back")
|
|
1236
|
+
}),
|
|
1237
|
+
hasCredentials && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1238
|
+
type: "button",
|
|
1239
|
+
onClick: () => {
|
|
1240
|
+
onClear();
|
|
1241
|
+
},
|
|
1242
|
+
disabled: busy,
|
|
1243
|
+
style: {
|
|
1244
|
+
...buttonStyle(busy),
|
|
1245
|
+
background: "transparent",
|
|
1246
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1247
|
+
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
1248
|
+
marginLeft: "auto"
|
|
1249
|
+
},
|
|
1250
|
+
children: clearing ? t("form.clearing") : t("form.clear")
|
|
1251
|
+
})
|
|
1252
|
+
]
|
|
1253
|
+
})
|
|
1254
|
+
] })
|
|
759
1255
|
]
|
|
760
1256
|
})
|
|
761
1257
|
});
|
|
762
1258
|
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Render a countdown as `m:ss`.
|
|
1261
|
+
*
|
|
1262
|
+
* Language-neutral on purpose: the surrounding sentence is localised, and a
|
|
1263
|
+
* number plus a unit needs no translation to read — whereas spelling out
|
|
1264
|
+
* "minutes"/"分" would put a second copy of the same unit in both dictionaries
|
|
1265
|
+
* for no gain. Tabular figures are applied at the call site so the digits do
|
|
1266
|
+
* not jitter as they change.
|
|
1267
|
+
*
|
|
1268
|
+
* @param seconds - seconds remaining.
|
|
1269
|
+
*/
|
|
1270
|
+
function formatCountdown(seconds) {
|
|
1271
|
+
const whole = Math.max(0, Math.floor(seconds));
|
|
1272
|
+
const minutes = Math.floor(whole / 60);
|
|
1273
|
+
const rest = whole % 60;
|
|
1274
|
+
return `${String(minutes)}:${String(rest).padStart(2, "0")}`;
|
|
1275
|
+
}
|
|
763
1276
|
|
|
764
1277
|
//#endregion
|
|
765
1278
|
//#region src/client/CredentialFormInteraction.ts
|
|
@@ -878,7 +1391,6 @@ const zh = {
|
|
|
878
1391
|
"section.credentials.hint.link": "API Explorer",
|
|
879
1392
|
"section.credentials.hint.suffix": "获取临时凭据,避免使用永久凭据。",
|
|
880
1393
|
"section.credentials.saving": "保存中…",
|
|
881
|
-
"form.title": "需要华为云凭据",
|
|
882
1394
|
"form.title.manual": "配置华为云凭据",
|
|
883
1395
|
"form.prefilledFromEnv": "检测到环境变量,已填入表单",
|
|
884
1396
|
"form.submit": "提交",
|
|
@@ -888,6 +1400,17 @@ const zh = {
|
|
|
888
1400
|
"form.clearing": "清除中…",
|
|
889
1401
|
"form.clear.failed": "清除凭据失败",
|
|
890
1402
|
"error.unreachable": "无法连接宿主凭据服务:",
|
|
1403
|
+
"form.intro": "需要进行华为云 IAM 认证",
|
|
1404
|
+
"form.checking": "正在检查登录方式…",
|
|
1405
|
+
"form.browser.action": "浏览器登录",
|
|
1406
|
+
"form.browser.aksk": "我有AK/SK",
|
|
1407
|
+
"form.browser.decline": "暂不认证",
|
|
1408
|
+
"form.browser.waiting": "正在等待浏览器完成登录…",
|
|
1409
|
+
"form.browser.countdown": "剩余 {time}",
|
|
1410
|
+
"form.browser.reopen": "重新打开",
|
|
1411
|
+
"form.back": "返回",
|
|
1412
|
+
"form.browser.blocked": "浏览器拦截了新标签页,请允许弹出窗口后重试。",
|
|
1413
|
+
"form.browser.failed": "浏览器登录未完成:",
|
|
891
1414
|
"section.field.accessKey": "Access Key",
|
|
892
1415
|
"section.field.accessKey.placeholder": "华为云 Access Key",
|
|
893
1416
|
"section.field.accessKey.hint": "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。",
|
|
@@ -913,7 +1436,6 @@ const en = {
|
|
|
913
1436
|
"section.credentials.hint.link": "API Explorer",
|
|
914
1437
|
"section.credentials.hint.suffix": "and avoid permanent ones.",
|
|
915
1438
|
"section.credentials.saving": "Saving…",
|
|
916
|
-
"form.title": "Huawei Cloud credentials required",
|
|
917
1439
|
"form.title.manual": "Configure Huawei Cloud credentials",
|
|
918
1440
|
"form.prefilledFromEnv": "Detected environment variables — filled in from them",
|
|
919
1441
|
"form.submit": "Submit",
|
|
@@ -923,6 +1445,17 @@ const en = {
|
|
|
923
1445
|
"form.clearing": "Clearing…",
|
|
924
1446
|
"form.clear.failed": "Could not clear credentials",
|
|
925
1447
|
"error.unreachable": "Could not reach the host credential service: ",
|
|
1448
|
+
"form.intro": "Huawei Cloud IAM authentication is required",
|
|
1449
|
+
"form.checking": "Checking sign-in options…",
|
|
1450
|
+
"form.browser.action": "Sign in with a browser",
|
|
1451
|
+
"form.browser.aksk": "I have one",
|
|
1452
|
+
"form.browser.decline": "Not now",
|
|
1453
|
+
"form.browser.waiting": "Waiting for the browser sign-in to finish…",
|
|
1454
|
+
"form.browser.countdown": "{time} left",
|
|
1455
|
+
"form.browser.reopen": "Reopen",
|
|
1456
|
+
"form.back": "Back",
|
|
1457
|
+
"form.browser.blocked": "The browser blocked the new tab. Allow pop-ups for this page, then try again.",
|
|
1458
|
+
"form.browser.failed": "The browser sign-in did not complete: ",
|
|
926
1459
|
"section.field.accessKey": "Access Key",
|
|
927
1460
|
"section.field.accessKey.placeholder": "Huawei Access Key",
|
|
928
1461
|
"section.field.accessKey.hint": "Access Key and Secret Key are stored as a pair; one without the other is not saved.",
|
|
@@ -1044,6 +1577,7 @@ function apply(ctx) {
|
|
|
1044
1577
|
}), "aishell-credentials: dictionaries");
|
|
1045
1578
|
const t = ctx.locale.bind(NS);
|
|
1046
1579
|
installChipStyles(ctx);
|
|
1580
|
+
installSpinnerStyles(ctx);
|
|
1047
1581
|
const form = ctx.configForms.get(AISHELL_CREDENTIALS_NS);
|
|
1048
1582
|
const status = (0, __deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
1049
1583
|
hasAccessKey: false,
|
|
@@ -1065,6 +1599,10 @@ function apply(ctx) {
|
|
|
1065
1599
|
};
|
|
1066
1600
|
ctx.effect(() => form.subscribe(derive), "aishell-credentials: credential presence");
|
|
1067
1601
|
derive();
|
|
1602
|
+
const loginOutcome = (0, __deepseek_ai_dsh_client_store.createSnapshotStore)(form.getSnapshot().value?.loginOutcome ?? "");
|
|
1603
|
+
ctx.effect(() => form.subscribe(() => {
|
|
1604
|
+
loginOutcome.set(form.getSnapshot().value?.loginOutcome ?? "");
|
|
1605
|
+
}), "aishell-credentials: login outcome");
|
|
1068
1606
|
const publishCredentialForm = ctx.uiSession.registerPendingInteraction(() => 0);
|
|
1069
1607
|
const visibility = createCredentialFormVisibility((interaction) => publishCredentialForm(interaction, () => Promise.resolve()));
|
|
1070
1608
|
/** The last request the browser acted on, so a re-read is not a re-open. */
|
|
@@ -1139,9 +1677,13 @@ function apply(ctx) {
|
|
|
1139
1677
|
select: ({ pendingInteraction }) => isCredentialForm(pendingInteraction) ? pendingInteraction : null,
|
|
1140
1678
|
locale: NS,
|
|
1141
1679
|
inject: () => ({
|
|
1142
|
-
hooks: {
|
|
1680
|
+
hooks: {
|
|
1681
|
+
credentials: status,
|
|
1682
|
+
loginOutcome
|
|
1683
|
+
},
|
|
1143
1684
|
save: (ak, sk, token) => saveCredential(t, ak, sk, token, pendingRequestToken),
|
|
1144
1685
|
readPrefill: () => readPrefill(),
|
|
1686
|
+
startBrowserLogin: () => startBrowserLogin(),
|
|
1145
1687
|
clear: () => clearBothStores(t),
|
|
1146
1688
|
close: () => {
|
|
1147
1689
|
visibility.close();
|