@huaweidevtools/aishell-dsh-deploy 0.0.1-beta.9 → 0.0.9
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 +27 -7
- package/lib/types/credentials.d.ts +16 -4
- package/package.json +2 -2
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
|
-
*
|
|
2476
|
-
*
|
|
2477
|
-
*
|
|
2478
|
-
*
|
|
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)
|
|
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("
|
|
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
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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.
|
|
4
|
+
"version": "0.0.9",
|
|
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.
|
|
33
|
+
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.9"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@deepseek-ai/cordis": "^4.0.4",
|