@huaweidevtools/aishell-dsh-client-credentials 0.0.5 → 0.0.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/index.js +9 -9
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1014,12 +1014,12 @@ async function verifyCredentials(ak, sk, securityToken) {
|
|
|
1014
1014
|
...securityToken ? { securityToken } : {}
|
|
1015
1015
|
});
|
|
1016
1016
|
const resp = await fetch(`https://${IAM_HOST}${path}`, { headers: { ...signed } });
|
|
1017
|
-
if (resp.status === 401) throw new Error("
|
|
1018
|
-
if (resp.status === 403) throw new Error("
|
|
1019
|
-
if (!resp.ok) throw new Error(
|
|
1017
|
+
if (resp.status === 401) throw new Error("Credential verification failed: Huawei Cloud returned 401. Check the Access Key, Secret Key, and Security Token.");
|
|
1018
|
+
if (resp.status === 403) throw new Error("Credential verification failed: this credential cannot read IAM (403).");
|
|
1019
|
+
if (!resp.ok) throw new Error(`Credential verification failed: Huawei Cloud returned ${resp.status}.`);
|
|
1020
1020
|
const body = await resp.json();
|
|
1021
1021
|
const name$1 = body.domains?.[0]?.name;
|
|
1022
|
-
if (!name$1) throw new Error("
|
|
1022
|
+
if (!name$1) throw new Error("Credential verified, but Huawei Cloud returned no account name.");
|
|
1023
1023
|
return name$1;
|
|
1024
1024
|
}
|
|
1025
1025
|
/** One JSON error response the browser half renders verbatim. */
|
|
@@ -1032,14 +1032,14 @@ function jsonError(status, message) {
|
|
|
1032
1032
|
/** Read a bounded JSON object body, or throw a user-readable message. */
|
|
1033
1033
|
async function readJsonBody(request) {
|
|
1034
1034
|
const text = await request.text();
|
|
1035
|
-
if (text.length > MAX_BODY_BYTES) throw new Error("
|
|
1035
|
+
if (text.length > MAX_BODY_BYTES) throw new Error("Request body too large.");
|
|
1036
1036
|
let parsed;
|
|
1037
1037
|
try {
|
|
1038
1038
|
parsed = JSON.parse(text);
|
|
1039
1039
|
} catch {
|
|
1040
|
-
throw new Error("
|
|
1040
|
+
throw new Error("Request body is not valid JSON.");
|
|
1041
1041
|
}
|
|
1042
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("
|
|
1042
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("Request body must be a JSON object.");
|
|
1043
1043
|
return parsed;
|
|
1044
1044
|
}
|
|
1045
1045
|
/** Narrow one optional string field; absent and empty both read as undefined. */
|
|
@@ -1071,7 +1071,7 @@ function createCredentialRoutes(deps) {
|
|
|
1071
1071
|
const ak = optionalString(body.accessKeyId);
|
|
1072
1072
|
const sk = optionalString(body.secretAccessKey);
|
|
1073
1073
|
const token = optionalString(body.securityToken);
|
|
1074
|
-
if (!ak || !sk) return jsonError(400, "Access Key
|
|
1074
|
+
if (!ak || !sk) return jsonError(400, "Access Key and Secret Key are both required.");
|
|
1075
1075
|
let accountName;
|
|
1076
1076
|
try {
|
|
1077
1077
|
accountName = await verify(ak, sk, token);
|
|
@@ -1095,7 +1095,7 @@ function createCredentialRoutes(deps) {
|
|
|
1095
1095
|
store.set(SK_ACCOUNT, sk);
|
|
1096
1096
|
if (token) store.set(TOKEN_ACCOUNT, token);
|
|
1097
1097
|
} catch (error) {
|
|
1098
|
-
const message =
|
|
1098
|
+
const message = `Credential verified, but storing it failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
1099
1099
|
recordStatus([{
|
|
1100
1100
|
op: "set",
|
|
1101
1101
|
path: ["lastError"],
|
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.
|
|
4
|
+
"version": "0.0.7",
|
|
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.
|
|
44
|
+
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@deepseek-ai/cordis": "^4.0.4",
|