@huaweidevtools/aishell-dsh-deploy 0.0.1-beta.8 → 0.0.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/index.js CHANGED
@@ -2472,17 +2472,32 @@ let cachedAccount;
2472
2472
  * account" is answered by the same call the credential form uses — no second
2473
2473
  * notion of validity.
2474
2474
  *
2475
- * @returns the identity, or `undefined` when the stored credentials cannot be
2476
- * verified. A missing identity is diagnostic-only, so this never fails a tool
2477
- * call; `list_existing_resources` is the one tool that turns it into its own
2478
- * error, because RMS needs the id as a path parameter.
2475
+ * ## Why the failure is thrown rather than folded into `undefined`
2476
+ *
2477
+ * `undefined` used to cover both reasons verification can fail, and the two
2478
+ * call for opposite responses. A credential IAM *rejected* is the person's to
2479
+ * fix: re-authenticate. A credential IAM never saw — a timeout, DNS, a proxy —
2480
+ * is nobody's mistake, and telling the person to re-authenticate sends them to
2481
+ * re-enter a credential that was already correct.
2482
+ *
2483
+ * So the rejected case returns `undefined`, which is the "not authenticated"
2484
+ * condition callers already handle, and every other failure throws with IAM's
2485
+ * own words. A transient fault then surfaces as a transient fault.
2486
+ *
2487
+ * @returns the identity, or `undefined` when IAM rejected the credentials.
2488
+ * Also `undefined` when none are stored.
2489
+ * @throws when IAM could not be reached, or answered something unusable — the
2490
+ * distinction `status === 0` and a 5xx draw from a rejection.
2479
2491
  */
2480
2492
  async function loadAccount() {
2481
2493
  if (cachedAccount !== void 0) return cachedAccount;
2482
2494
  const credentials = readStoredCredentials();
2483
2495
  if (credentials === void 0) return void 0;
2484
2496
  const result = await verifyCredentials(credentials, { region: credentials.region });
2485
- if (!result.ok) return void 0;
2497
+ if (!result.ok) {
2498
+ if (result.status === 0 || result.status >= 500) throw new Error(`${result.message} The stored credentials were not rejected — retry.`);
2499
+ return void 0;
2500
+ }
2486
2501
  cachedAccount = {
2487
2502
  account_id: result.account.accountId,
2488
2503
  account_name: result.account.name
@@ -3246,11 +3261,16 @@ function registerExistingResourcesTool(registrar) {
3246
3261
  /**
3247
3262
  * Resolve the account_id (== RMS domain_id) for the RMS path param.
3248
3263
  * Credentials for signing are loaded separately by signedHttp at call time.
3264
+ *
3265
+ * @throws when the identity cannot be had. A rejected credential is the
3266
+ * person's to fix, so it is named that way; a failure to *reach* IAM
3267
+ * propagates from `loadAccount` with its own message rather than being
3268
+ * restated here as a credential problem.
3249
3269
  */
3250
3270
  async function resolveDomainId() {
3251
3271
  const account = await loadAccount();
3252
3272
  if (account?.account_id) return account.account_id;
3253
- throw new Error("account_id not available — the stored credentials could not be verified against IAM. Re-authenticate, then retry.");
3273
+ throw new Error("The stored credentials were rejected by IAM, so account_id is not available. Re-authenticate, then retry.");
3254
3274
  }
3255
3275
  async function handleListExistingResources(serviceFilter, regionFilter, detail, limit = 100, marker) {
3256
3276
  let domainId;
@@ -3754,7 +3774,7 @@ async function runTerraform(cwd, args, extraEnv = []) {
3754
3774
  if (refusal !== void 0) throw new Error(refusal);
3755
3775
  const { binary, env } = await resolveTerraformEnv(cwd, extraEnv);
3756
3776
  if (env["HW_ACCESS_KEY"]) {
3757
- const account = await loadAccount();
3777
+ const account = await loadAccount().catch(() => void 0);
3758
3778
  if (account) await backfillAccount(cwd, {
3759
3779
  name: account.account_name,
3760
3780
  account_id: account.account_id
@@ -88,10 +88,22 @@ export declare function hasCredentials(): boolean;
88
88
  * account" is answered by the same call the credential form uses — no second
89
89
  * notion of validity.
90
90
  *
91
- * @returns the identity, or `undefined` when the stored credentials cannot be
92
- * verified. A missing identity is diagnostic-only, so this never fails a tool
93
- * call; `list_existing_resources` is the one tool that turns it into its own
94
- * error, because RMS needs the id as a path parameter.
91
+ * ## Why the failure is thrown rather than folded into `undefined`
92
+ *
93
+ * `undefined` used to cover both reasons verification can fail, and the two
94
+ * call for opposite responses. A credential IAM *rejected* is the person's to
95
+ * fix: re-authenticate. A credential IAM never saw — a timeout, DNS, a proxy —
96
+ * is nobody's mistake, and telling the person to re-authenticate sends them to
97
+ * re-enter a credential that was already correct.
98
+ *
99
+ * So the rejected case returns `undefined`, which is the "not authenticated"
100
+ * condition callers already handle, and every other failure throws with IAM's
101
+ * own words. A transient fault then surfaces as a transient fault.
102
+ *
103
+ * @returns the identity, or `undefined` when IAM rejected the credentials.
104
+ * Also `undefined` when none are stored.
105
+ * @throws when IAM could not be reached, or answered something unusable — the
106
+ * distinction `status === 0` and a 5xx draw from a rejection.
95
107
  */
96
108
  export declare function loadAccount(): Promise<AccountIdentity | undefined>;
97
109
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@huaweidevtools/aishell-dsh-deploy",
3
3
  "description": "Huawei Cloud infrastructure tools for DSH — Terraform, OpenAPI, resource inventory, cost estimates",
4
- "version": "0.0.1-beta.8",
4
+ "version": "0.0.8",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,7 +30,7 @@
30
30
  "adm-zip": "^0.6.1",
31
31
  "jsonpath-plus": "^10.4.0",
32
32
  "zod": "^4.2.0",
33
- "@huaweidevtools/aishell-dsh-credentials-store": "0.0.1-beta.8"
33
+ "@huaweidevtools/aishell-dsh-credentials-store": "0.0.8"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@deepseek-ai/cordis": "^4.0.4",