@huaweidevtools/aishell-dsh-client-credentials 0.0.1-beta.5 → 0.0.1-beta.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/lib/client.js +92 -30
- package/lib/index.js +101 -4
- package/lib/types/client/CredentialRequestForm.d.ts +9 -0
- package/lib/types/client/locales.d.ts +2 -0
- package/lib/types/prefill.d.ts +78 -0
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -477,6 +477,28 @@ function CredentialRequestForm(props) {
|
|
|
477
477
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
478
478
|
const [clearing, setClearing] = (0, react.useState)(false);
|
|
479
479
|
const [error, setError] = (0, react.useState)(void 0);
|
|
480
|
+
/**
|
|
481
|
+
* Whether the fields were seeded from the environment.
|
|
482
|
+
*
|
|
483
|
+
* Shown so the person knows where the values came from — a credential that
|
|
484
|
+
* silently appeared in a field is worse than an empty one, because they
|
|
485
|
+
* cannot tell whether to trust it.
|
|
486
|
+
*/
|
|
487
|
+
const [prefilled, setPrefilled] = (0, react.useState)(false);
|
|
488
|
+
(0, react.useEffect)(() => {
|
|
489
|
+
let live = true;
|
|
490
|
+
props.readPrefill().then((prefill) => {
|
|
491
|
+
const { accessKeyId, secretAccessKey } = prefill;
|
|
492
|
+
if (!live || accessKeyId === void 0 || secretAccessKey === void 0) return;
|
|
493
|
+
setAk((current) => current === "" ? accessKeyId : current);
|
|
494
|
+
setSk((current) => current === "" ? secretAccessKey : current);
|
|
495
|
+
setToken((current) => current === "" ? prefill.securityToken ?? "" : current);
|
|
496
|
+
setPrefilled(true);
|
|
497
|
+
}).catch(() => {});
|
|
498
|
+
return () => {
|
|
499
|
+
live = false;
|
|
500
|
+
};
|
|
501
|
+
}, []);
|
|
480
502
|
const onSubmit = async (event) => {
|
|
481
503
|
event.preventDefault();
|
|
482
504
|
setSaving(true);
|
|
@@ -581,36 +603,48 @@ function CredentialRequestForm(props) {
|
|
|
581
603
|
flexDirection: "column",
|
|
582
604
|
gap: 4
|
|
583
605
|
},
|
|
584
|
-
children: [
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
606
|
+
children: [
|
|
607
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
608
|
+
style: {
|
|
609
|
+
fontSize: 14,
|
|
610
|
+
fontWeight: 500,
|
|
611
|
+
lineHeight: "22px"
|
|
612
|
+
},
|
|
613
|
+
children: t("form.title.manual")
|
|
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
|
+
]
|
|
646
|
+
})
|
|
647
|
+
]
|
|
614
648
|
}),
|
|
615
649
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
616
650
|
style: fieldStyle,
|
|
@@ -846,6 +880,7 @@ const zh = {
|
|
|
846
880
|
"section.credentials.saving": "保存中…",
|
|
847
881
|
"form.title": "需要华为云凭据",
|
|
848
882
|
"form.title.manual": "配置华为云凭据",
|
|
883
|
+
"form.prefilledFromEnv": "检测到环境变量,已填入表单",
|
|
849
884
|
"form.submit": "提交",
|
|
850
885
|
"form.dismiss": "取消",
|
|
851
886
|
"form.failed": "保存凭据失败",
|
|
@@ -880,6 +915,7 @@ const en = {
|
|
|
880
915
|
"section.credentials.saving": "Saving…",
|
|
881
916
|
"form.title": "Huawei Cloud credentials required",
|
|
882
917
|
"form.title.manual": "Configure Huawei Cloud credentials",
|
|
918
|
+
"form.prefilledFromEnv": "Detected environment variables — filled in from them",
|
|
883
919
|
"form.submit": "Submit",
|
|
884
920
|
"form.dismiss": "Cancel",
|
|
885
921
|
"form.failed": "Could not save credentials",
|
|
@@ -913,6 +949,8 @@ const CREDENTIALS_ROUTE = "api/aishell/credentials";
|
|
|
913
949
|
const CLEAR_ROUTE = "api/aishell/credentials/clear";
|
|
914
950
|
/** Cancel route; names the request token the person declined. */
|
|
915
951
|
const CANCEL_ROUTE = "api/aishell/credentials/cancel";
|
|
952
|
+
/** Prefill route; returns the values the host's environment already holds. */
|
|
953
|
+
const PREFILL_ROUTE = "api/aishell/credentials/prefill";
|
|
916
954
|
/**
|
|
917
955
|
* POST one JSON body to a Host credential route and read back its verdict.
|
|
918
956
|
* A non-JSON or unreadable body is reported as a transport failure rather than
|
|
@@ -969,6 +1007,29 @@ function saveCredential(t, accessKeyId, secretAccessKey, securityToken, requestT
|
|
|
969
1007
|
async function clearBothStores(t) {
|
|
970
1008
|
return postJson(CLEAR_ROUTE, t);
|
|
971
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Read the credential prefills the host has in its environment.
|
|
1012
|
+
*
|
|
1013
|
+
* Failure is not an event: a host with nothing in its environment answers an
|
|
1014
|
+
* empty object, and a route that cannot be reached answers `{}` too, because a
|
|
1015
|
+
* form that starts empty is exactly the behaviour before this existed.
|
|
1016
|
+
*
|
|
1017
|
+
* @returns the prefills, or an empty object.
|
|
1018
|
+
*/
|
|
1019
|
+
async function readPrefill() {
|
|
1020
|
+
try {
|
|
1021
|
+
const response = await fetch(PREFILL_ROUTE, { headers: { accept: "application/json" } });
|
|
1022
|
+
if (!response.ok) return {};
|
|
1023
|
+
const body = await response.json();
|
|
1024
|
+
return typeof body.accessKeyId === "string" && body.accessKeyId !== "" && typeof body.secretAccessKey === "string" && body.secretAccessKey !== "" ? {
|
|
1025
|
+
accessKeyId: body.accessKeyId,
|
|
1026
|
+
secretAccessKey: body.secretAccessKey,
|
|
1027
|
+
...typeof body.securityToken === "string" && body.securityToken !== "" ? { securityToken: body.securityToken } : {}
|
|
1028
|
+
} : {};
|
|
1029
|
+
} catch {
|
|
1030
|
+
return {};
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
972
1033
|
/** Required services. */
|
|
973
1034
|
const inject = [
|
|
974
1035
|
"slots",
|
|
@@ -1080,6 +1141,7 @@ function apply(ctx) {
|
|
|
1080
1141
|
inject: () => ({
|
|
1081
1142
|
hooks: { credentials: status },
|
|
1082
1143
|
save: (ak, sk, token) => saveCredential(t, ak, sk, token, pendingRequestToken),
|
|
1144
|
+
readPrefill: () => readPrefill(),
|
|
1083
1145
|
clear: () => clearBothStores(t),
|
|
1084
1146
|
close: () => {
|
|
1085
1147
|
visibility.close();
|
package/lib/index.js
CHANGED
|
@@ -900,8 +900,6 @@ defineMethod("transform", [
|
|
|
900
900
|
const AUTH_TOOL_NAME = "aishell__auth";
|
|
901
901
|
/** Region used to route the verification call; IAM is global, see the module note. */
|
|
902
902
|
const VERIFY_REGION$1 = "cn-north-4";
|
|
903
|
-
/** Per-call budget. IAM answers in well under a second when healthy. */
|
|
904
|
-
const AUTH_TIMEOUT_MS = 3e4;
|
|
905
903
|
/**
|
|
906
904
|
* The JSON Schema for `auth`'s parameters: none.
|
|
907
905
|
*
|
|
@@ -923,7 +921,7 @@ function registerAuthTool(ctx, store, deps) {
|
|
|
923
921
|
ctx.inject(["tools"], (scope) => {
|
|
924
922
|
const dispose = scope.tools.register({
|
|
925
923
|
name: AUTH_TOOL_NAME,
|
|
926
|
-
description: "
|
|
924
|
+
description: "Authenticate with Huawei Cloud IAM, then report the account: its id and name, and every project visible to it (a project's name is a region; its id is what a region-scoped API needs). Opens the credential form and waits for the user to finish — it does not return until they have authenticated or cancelled.",
|
|
927
925
|
parameters: AUTH_PARAMETERS,
|
|
928
926
|
output: {
|
|
929
927
|
schema: {
|
|
@@ -961,7 +959,6 @@ function registerAuthTool(ctx, store, deps) {
|
|
|
961
959
|
},
|
|
962
960
|
render: (_args, value) => renderAuth(value)
|
|
963
961
|
},
|
|
964
|
-
timeoutMs: AUTH_TIMEOUT_MS,
|
|
965
962
|
async execute(_args, exec) {
|
|
966
963
|
return await runAuth(store, deps, sessionOf(exec), exec.signal);
|
|
967
964
|
}
|
|
@@ -1179,6 +1176,86 @@ function encodeRequest(request) {
|
|
|
1179
1176
|
return JSON.stringify(request);
|
|
1180
1177
|
}
|
|
1181
1178
|
|
|
1179
|
+
//#endregion
|
|
1180
|
+
//#region src/prefill.ts
|
|
1181
|
+
/**
|
|
1182
|
+
* Credential prefill from the environment.
|
|
1183
|
+
*
|
|
1184
|
+
* ## What this is for
|
|
1185
|
+
*
|
|
1186
|
+
* A machine that already carries `HW_ACCESS_KEY`, `HW_SECRET_KEY` and
|
|
1187
|
+
* `HW_SECURITY_TOKEN` in its environment has the credentials; the person just
|
|
1188
|
+
* has to move them into the store. Typing three values that are already on the
|
|
1189
|
+
* machine is work nobody should do, so the form opens with them filled in.
|
|
1190
|
+
*
|
|
1191
|
+
* ## Why the values come from the host
|
|
1192
|
+
*
|
|
1193
|
+
* The browser half cannot read `process.env` — it is browser code, and the
|
|
1194
|
+
* environment it would see is not the host's. So the host reads the variables
|
|
1195
|
+
* and serves them over a route the form calls before it renders its fields.
|
|
1196
|
+
*
|
|
1197
|
+
* ## Why that is acceptable here
|
|
1198
|
+
*
|
|
1199
|
+
* The values travel from the host to the page it is serving, over the same
|
|
1200
|
+
* authenticated channel and the same origin as the credential route the form
|
|
1201
|
+
* already posts to. Nothing new is exposed: a page that could read this route
|
|
1202
|
+
* could also submit that form.
|
|
1203
|
+
*
|
|
1204
|
+
* They are **not** written to the settings document, the session, or a log —
|
|
1205
|
+
* the route is the whole journey, and it is called once per form open.
|
|
1206
|
+
*
|
|
1207
|
+
* ## Why it returns nothing rather than a partial set
|
|
1208
|
+
*
|
|
1209
|
+
* A form filled with an access key and no secret key looks broken. Either the
|
|
1210
|
+
* environment carries a usable pair, or the form starts empty and the person
|
|
1211
|
+
* enters what they have. The token is separate: it is optional, and a lone
|
|
1212
|
+
* token with no pair is dropped for the same reason.
|
|
1213
|
+
*
|
|
1214
|
+
* ## Why the form says so
|
|
1215
|
+
*
|
|
1216
|
+
* The person did not type these values. Saying where they came from is what
|
|
1217
|
+
* lets them decide whether to trust them — a credential silently appearing in
|
|
1218
|
+
* a field is worse than an empty one.
|
|
1219
|
+
*
|
|
1220
|
+
* @module @huaweidevtools/aishell-dsh-client-credentials/prefill
|
|
1221
|
+
*/
|
|
1222
|
+
/** Route the form reads prefills from. */
|
|
1223
|
+
const PREFILL_PATH = "/api/aishell/credentials/prefill";
|
|
1224
|
+
/** Variables read, in the order the form's fields appear. */
|
|
1225
|
+
const ACCESS_KEY_ENV = "HW_ACCESS_KEY";
|
|
1226
|
+
const SECRET_KEY_ENV = "HW_SECRET_KEY";
|
|
1227
|
+
const SECURITY_TOKEN_ENV = "HW_SECURITY_TOKEN";
|
|
1228
|
+
/**
|
|
1229
|
+
* Read an environment for a usable credential set.
|
|
1230
|
+
*
|
|
1231
|
+
* Pure, and the environment is a parameter: this package compiles without Node
|
|
1232
|
+
* type definitions (the browser half is most of it), so `process` is not in
|
|
1233
|
+
* scope and the caller supplies what to read.
|
|
1234
|
+
*
|
|
1235
|
+
* ## What these values do, and do not, do
|
|
1236
|
+
*
|
|
1237
|
+
* They fill the form's fields. The form still opens, every field is still
|
|
1238
|
+
* editable, and submitting or cancelling still works the way it always did —
|
|
1239
|
+
* the person saves the step of copying three values out of their shell, and
|
|
1240
|
+
* nothing else. In particular nothing is stored on their behalf: a prefill is a
|
|
1241
|
+
* starting point, not a credential.
|
|
1242
|
+
*
|
|
1243
|
+
* @param env - the environment to read.
|
|
1244
|
+
* @returns the pair (and token, when present), or `undefined` when either half
|
|
1245
|
+
* of the pair is missing.
|
|
1246
|
+
*/
|
|
1247
|
+
function readEnvPrefill(env) {
|
|
1248
|
+
const ak = env[ACCESS_KEY_ENV];
|
|
1249
|
+
const sk = env[SECRET_KEY_ENV];
|
|
1250
|
+
if (ak === void 0 || ak === "" || sk === void 0 || sk === "") return void 0;
|
|
1251
|
+
const token = env[SECURITY_TOKEN_ENV];
|
|
1252
|
+
return {
|
|
1253
|
+
accessKeyId: ak,
|
|
1254
|
+
secretAccessKey: sk,
|
|
1255
|
+
...token === void 0 || token === "" ? {} : { securityToken: token }
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1182
1259
|
//#endregion
|
|
1183
1260
|
//#region src/reconcile.ts
|
|
1184
1261
|
/**
|
|
@@ -1265,6 +1342,20 @@ function readRequestToken(body) {
|
|
|
1265
1342
|
}
|
|
1266
1343
|
}
|
|
1267
1344
|
/**
|
|
1345
|
+
* The host process's environment.
|
|
1346
|
+
*
|
|
1347
|
+
* Reached through a narrow cast rather than a typed `process`: this package
|
|
1348
|
+
* compiles without Node type definitions, so `process` is not in scope. The
|
|
1349
|
+
* host always has it; `{}` is the shape a build without one falls back to, and
|
|
1350
|
+
* an empty environment simply yields no prefill.
|
|
1351
|
+
*
|
|
1352
|
+
* @returns the environment, or an empty object when there is none.
|
|
1353
|
+
*/
|
|
1354
|
+
function runtimeEnv() {
|
|
1355
|
+
const holder = globalThis;
|
|
1356
|
+
return holder.process?.env ?? {};
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1268
1359
|
* Settings schema for this entry. Secrets are deliberately absent: they travel
|
|
1269
1360
|
* over the credential route into the credential store, never through a
|
|
1270
1361
|
* settings document.
|
|
@@ -1566,6 +1657,12 @@ function apply(ctx, config) {
|
|
|
1566
1657
|
return Response.json({ ok: true });
|
|
1567
1658
|
}
|
|
1568
1659
|
}), "aishell-credentials: cancel route");
|
|
1660
|
+
ctx.effect(() => ctx.connection.fetch.register({
|
|
1661
|
+
path: PREFILL_PATH,
|
|
1662
|
+
methods: ["GET"],
|
|
1663
|
+
requestBody: "buffered",
|
|
1664
|
+
fetch: () => Promise.resolve(Response.json(readEnvPrefill(runtimeEnv()) ?? {}, { headers: { "cache-control": "no-store" } }))
|
|
1665
|
+
}), "aishell-credentials: prefill route");
|
|
1569
1666
|
ctx.effect(() => ctx.connection.fetch.register({
|
|
1570
1667
|
path: CLEAR_PATH,
|
|
1571
1668
|
methods: ["POST"],
|
|
@@ -34,6 +34,7 @@ import { type ReactNode } from 'react';
|
|
|
34
34
|
import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
35
35
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
36
36
|
import { type CredentialStatus, type SaveVerdict } from './credential-status.ts';
|
|
37
|
+
import type { CredentialPrefill } from '../prefill.ts';
|
|
37
38
|
import type { CredentialFormInteraction } from './CredentialFormInteraction.ts';
|
|
38
39
|
declare module '@deepseek-ai/dsh-client-ui-session/client' {
|
|
39
40
|
interface SessionPendingInteractionMap {
|
|
@@ -48,6 +49,14 @@ export interface CredentialRequestFormInjected {
|
|
|
48
49
|
};
|
|
49
50
|
/** Store AK/SK/SecurityToken through the Host credential route. */
|
|
50
51
|
save: (accessKeyId: string, secretAccessKey: string, securityToken?: string) => Promise<SaveVerdict>;
|
|
52
|
+
/**
|
|
53
|
+
* Values the host already has, to start the fields with.
|
|
54
|
+
*
|
|
55
|
+
* Fills the inputs; it does not submit, does not hide the form, and every
|
|
56
|
+
* field stays editable. The point is to save the person copying three values
|
|
57
|
+
* out of their shell — not to skip the form.
|
|
58
|
+
*/
|
|
59
|
+
readPrefill: () => Promise<CredentialPrefill>;
|
|
51
60
|
/**
|
|
52
61
|
* Clear the stored credentials.
|
|
53
62
|
*
|
|
@@ -22,6 +22,7 @@ export declare const zh: {
|
|
|
22
22
|
readonly 'section.credentials.saving': "保存中…";
|
|
23
23
|
readonly 'form.title': "需要华为云凭据";
|
|
24
24
|
readonly 'form.title.manual': "配置华为云凭据";
|
|
25
|
+
readonly 'form.prefilledFromEnv': "检测到环境变量,已填入表单";
|
|
25
26
|
readonly 'form.submit': "提交";
|
|
26
27
|
readonly 'form.dismiss': "取消";
|
|
27
28
|
readonly 'form.failed': "保存凭据失败";
|
|
@@ -56,6 +57,7 @@ export declare const en: {
|
|
|
56
57
|
readonly 'section.credentials.saving': "Saving…";
|
|
57
58
|
readonly 'form.title': "Huawei Cloud credentials required";
|
|
58
59
|
readonly 'form.title.manual': "Configure Huawei Cloud credentials";
|
|
60
|
+
readonly 'form.prefilledFromEnv': "Detected environment variables — filled in from them";
|
|
59
61
|
readonly 'form.submit': "Submit";
|
|
60
62
|
readonly 'form.dismiss': "Cancel";
|
|
61
63
|
readonly 'form.failed': "Could not save credentials";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential prefill from the environment.
|
|
3
|
+
*
|
|
4
|
+
* ## What this is for
|
|
5
|
+
*
|
|
6
|
+
* A machine that already carries `HW_ACCESS_KEY`, `HW_SECRET_KEY` and
|
|
7
|
+
* `HW_SECURITY_TOKEN` in its environment has the credentials; the person just
|
|
8
|
+
* has to move them into the store. Typing three values that are already on the
|
|
9
|
+
* machine is work nobody should do, so the form opens with them filled in.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the values come from the host
|
|
12
|
+
*
|
|
13
|
+
* The browser half cannot read `process.env` — it is browser code, and the
|
|
14
|
+
* environment it would see is not the host's. So the host reads the variables
|
|
15
|
+
* and serves them over a route the form calls before it renders its fields.
|
|
16
|
+
*
|
|
17
|
+
* ## Why that is acceptable here
|
|
18
|
+
*
|
|
19
|
+
* The values travel from the host to the page it is serving, over the same
|
|
20
|
+
* authenticated channel and the same origin as the credential route the form
|
|
21
|
+
* already posts to. Nothing new is exposed: a page that could read this route
|
|
22
|
+
* could also submit that form.
|
|
23
|
+
*
|
|
24
|
+
* They are **not** written to the settings document, the session, or a log —
|
|
25
|
+
* the route is the whole journey, and it is called once per form open.
|
|
26
|
+
*
|
|
27
|
+
* ## Why it returns nothing rather than a partial set
|
|
28
|
+
*
|
|
29
|
+
* A form filled with an access key and no secret key looks broken. Either the
|
|
30
|
+
* environment carries a usable pair, or the form starts empty and the person
|
|
31
|
+
* enters what they have. The token is separate: it is optional, and a lone
|
|
32
|
+
* token with no pair is dropped for the same reason.
|
|
33
|
+
*
|
|
34
|
+
* ## Why the form says so
|
|
35
|
+
*
|
|
36
|
+
* The person did not type these values. Saying where they came from is what
|
|
37
|
+
* lets them decide whether to trust them — a credential silently appearing in
|
|
38
|
+
* a field is worse than an empty one.
|
|
39
|
+
*
|
|
40
|
+
* @module @huaweidevtools/aishell-dsh-client-credentials/prefill
|
|
41
|
+
*/
|
|
42
|
+
/** Route the form reads prefills from. */
|
|
43
|
+
export declare const PREFILL_PATH = "/api/aishell/credentials/prefill";
|
|
44
|
+
/**
|
|
45
|
+
* A credential set read out of the environment.
|
|
46
|
+
*
|
|
47
|
+
* All fields optional, because "nothing to prefill" is the ordinary answer —
|
|
48
|
+
* most machines have no credential in their environment. The form treats an
|
|
49
|
+
* empty object as empty fields, which is exactly its behaviour without this
|
|
50
|
+
* feature at all.
|
|
51
|
+
*/
|
|
52
|
+
export interface CredentialPrefill {
|
|
53
|
+
readonly accessKeyId?: string;
|
|
54
|
+
readonly secretAccessKey?: string;
|
|
55
|
+
/** Present only when the environment carries one. */
|
|
56
|
+
readonly securityToken?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read an environment for a usable credential set.
|
|
60
|
+
*
|
|
61
|
+
* Pure, and the environment is a parameter: this package compiles without Node
|
|
62
|
+
* type definitions (the browser half is most of it), so `process` is not in
|
|
63
|
+
* scope and the caller supplies what to read.
|
|
64
|
+
*
|
|
65
|
+
* ## What these values do, and do not, do
|
|
66
|
+
*
|
|
67
|
+
* They fill the form's fields. The form still opens, every field is still
|
|
68
|
+
* editable, and submitting or cancelling still works the way it always did —
|
|
69
|
+
* the person saves the step of copying three values out of their shell, and
|
|
70
|
+
* nothing else. In particular nothing is stored on their behalf: a prefill is a
|
|
71
|
+
* starting point, not a credential.
|
|
72
|
+
*
|
|
73
|
+
* @param env - the environment to read.
|
|
74
|
+
* @returns the pair (and token, when present), or `undefined` when either half
|
|
75
|
+
* of the pair is missing.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readEnvPrefill(env: Record<string, string | undefined>): CredentialPrefill | undefined;
|
|
78
|
+
//# sourceMappingURL=prefill.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaweidevtools/aishell-dsh-client-credentials",
|
|
3
3
|
"description": "AI Shell credentials — chip-opened web form for storing Huawei Cloud AK/SK in the credential store",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.6",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.1-beta.
|
|
44
|
+
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.1-beta.6"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@deepseek-ai/cordis": "^4.0.4",
|