fix: 修复配额说明重复和undefined问题
- 在editStorageForm中初始化oss_storage_quota_value和oss_quota_unit - 删除重复的旧配额说明块,保留新的当前配额设置显示 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
80
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
generated
vendored
Normal file
80
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
import { getProfileName } from "@smithy/shared-ini-file-loader";
|
||||
import { resolveCredentialSource } from "./resolveCredentialSource";
|
||||
export const isAssumeRoleProfile = (arg, { profile = "default", logger } = {}) => {
|
||||
return (Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 &&
|
||||
(isAssumeRoleWithSourceProfile(arg, { profile, logger }) || isCredentialSourceProfile(arg, { profile, logger })));
|
||||
};
|
||||
const isAssumeRoleWithSourceProfile = (arg, { profile, logger }) => {
|
||||
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
||||
if (withSourceProfile) {
|
||||
logger?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
||||
}
|
||||
return withSourceProfile;
|
||||
};
|
||||
const isCredentialSourceProfile = (arg, { profile, logger }) => {
|
||||
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
||||
if (withProviderProfile) {
|
||||
logger?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
||||
}
|
||||
return withProviderProfile;
|
||||
};
|
||||
export const resolveAssumeRoleCredentials = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, resolveProfileData) => {
|
||||
options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
|
||||
const profileData = profiles[profileName];
|
||||
const { source_profile, region } = profileData;
|
||||
if (!options.roleAssumer) {
|
||||
const { getDefaultRoleAssumer } = await import("@aws-sdk/nested-clients/sts");
|
||||
options.roleAssumer = getDefaultRoleAssumer({
|
||||
...options.clientConfig,
|
||||
credentialProviderLogger: options.logger,
|
||||
parentClientConfig: {
|
||||
...callerClientConfig,
|
||||
...options?.parentClientConfig,
|
||||
region: region ?? options?.parentClientConfig?.region ?? callerClientConfig?.region,
|
||||
},
|
||||
}, options.clientPlugins);
|
||||
}
|
||||
if (source_profile && source_profile in visitedProfiles) {
|
||||
throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile` +
|
||||
` ${getProfileName(options)}. Profiles visited: ` +
|
||||
Object.keys(visitedProfiles).join(", "), { logger: options.logger });
|
||||
}
|
||||
options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
|
||||
const sourceCredsProvider = source_profile
|
||||
? resolveProfileData(source_profile, profiles, options, callerClientConfig, {
|
||||
...visitedProfiles,
|
||||
[source_profile]: true,
|
||||
}, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {}))
|
||||
: (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
|
||||
if (isCredentialSourceWithoutRoleArn(profileData)) {
|
||||
return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
else {
|
||||
const params = {
|
||||
RoleArn: profileData.role_arn,
|
||||
RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
|
||||
ExternalId: profileData.external_id,
|
||||
DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10),
|
||||
};
|
||||
const { mfa_serial } = profileData;
|
||||
if (mfa_serial) {
|
||||
if (!options.mfaCodeProvider) {
|
||||
throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, { logger: options.logger, tryNextLink: false });
|
||||
}
|
||||
params.SerialNumber = mfa_serial;
|
||||
params.TokenCode = await options.mfaCodeProvider(mfa_serial);
|
||||
}
|
||||
const sourceCreds = await sourceCredsProvider;
|
||||
return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
|
||||
}
|
||||
};
|
||||
const isCredentialSourceWithoutRoleArn = (section) => {
|
||||
return !section.role_arn && !!section.credential_source;
|
||||
};
|
||||
Reference in New Issue
Block a user