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:
9
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
generated
vendored
Normal file
9
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getProfileName, parseKnownFiles } from "@smithy/shared-ini-file-loader";
|
||||
import { resolveProfileData } from "./resolveProfileData";
|
||||
export const fromIni = (init = {}) => async ({ callerClientConfig } = {}) => {
|
||||
init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
|
||||
const profiles = await parseKnownFiles(init);
|
||||
return resolveProfileData(getProfileName({
|
||||
profile: init.profile ?? callerClientConfig?.profile,
|
||||
}), profiles, init, callerClientConfig);
|
||||
};
|
||||
1
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/index.js
generated
vendored
Normal file
1
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./fromIni";
|
||||
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;
|
||||
};
|
||||
30
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
generated
vendored
Normal file
30
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
import { chain, CredentialsProviderError } from "@smithy/property-provider";
|
||||
export const resolveCredentialSource = (credentialSource, profileName, logger) => {
|
||||
const sourceProvidersMap = {
|
||||
EcsContainer: async (options) => {
|
||||
const { fromHttp } = await import("@aws-sdk/credential-provider-http");
|
||||
const { fromContainerMetadata } = await import("@smithy/credential-provider-imds");
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
||||
return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
|
||||
},
|
||||
Ec2InstanceMetadata: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
||||
const { fromInstanceMetadata } = await import("@smithy/credential-provider-imds");
|
||||
return async () => fromInstanceMetadata(options)().then(setNamedProvider);
|
||||
},
|
||||
Environment: async (options) => {
|
||||
logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
||||
const { fromEnv } = await import("@aws-sdk/credential-provider-env");
|
||||
return async () => fromEnv(options)().then(setNamedProvider);
|
||||
},
|
||||
};
|
||||
if (credentialSource in sourceProvidersMap) {
|
||||
return sourceProvidersMap[credentialSource];
|
||||
}
|
||||
else {
|
||||
throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
|
||||
`expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger });
|
||||
}
|
||||
};
|
||||
const setNamedProvider = (creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
||||
12
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveLoginCredentials.js
generated
vendored
Normal file
12
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveLoginCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
import { fromLoginCredentials } from "@aws-sdk/credential-provider-login";
|
||||
export const isLoginProfile = (data) => {
|
||||
return Boolean(data && data.login_session);
|
||||
};
|
||||
export const resolveLoginCredentials = async (profileName, options, callerClientConfig) => {
|
||||
const credentials = await fromLoginCredentials({
|
||||
...options,
|
||||
profile: profileName,
|
||||
})({ callerClientConfig });
|
||||
return setCredentialFeature(credentials, "CREDENTIALS_PROFILE_LOGIN", "AC");
|
||||
};
|
||||
6
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
generated
vendored
Normal file
6
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
export const isProcessProfile = (arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string";
|
||||
export const resolveProcessCredentials = async (options, profile) => import("@aws-sdk/credential-provider-process").then(({ fromProcess }) => fromProcess({
|
||||
...options,
|
||||
profile,
|
||||
})().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v")));
|
||||
32
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
generated
vendored
Normal file
32
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { CredentialsProviderError } from "@smithy/property-provider";
|
||||
import { isAssumeRoleProfile, resolveAssumeRoleCredentials } from "./resolveAssumeRoleCredentials";
|
||||
import { isLoginProfile, resolveLoginCredentials } from "./resolveLoginCredentials";
|
||||
import { isProcessProfile, resolveProcessCredentials } from "./resolveProcessCredentials";
|
||||
import { isSsoProfile, resolveSsoCredentials } from "./resolveSsoCredentials";
|
||||
import { isStaticCredsProfile, resolveStaticCredentials } from "./resolveStaticCredentials";
|
||||
import { isWebIdentityProfile, resolveWebIdentityCredentials } from "./resolveWebIdentityCredentials";
|
||||
export const resolveProfileData = async (profileName, profiles, options, callerClientConfig, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
|
||||
const data = profiles[profileName];
|
||||
if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, { profile: profileName, logger: options.logger })) {
|
||||
return resolveAssumeRoleCredentials(profileName, profiles, options, callerClientConfig, visitedProfiles, resolveProfileData);
|
||||
}
|
||||
if (isStaticCredsProfile(data)) {
|
||||
return resolveStaticCredentials(data, options);
|
||||
}
|
||||
if (isWebIdentityProfile(data)) {
|
||||
return resolveWebIdentityCredentials(data, options, callerClientConfig);
|
||||
}
|
||||
if (isProcessProfile(data)) {
|
||||
return resolveProcessCredentials(options, profileName);
|
||||
}
|
||||
if (isSsoProfile(data)) {
|
||||
return await resolveSsoCredentials(profileName, data, options, callerClientConfig);
|
||||
}
|
||||
if (isLoginProfile(data)) {
|
||||
return resolveLoginCredentials(profileName, options, callerClientConfig);
|
||||
}
|
||||
throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, { logger: options.logger });
|
||||
};
|
||||
25
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
generated
vendored
Normal file
25
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
export const resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
||||
const { fromSSO } = await import("@aws-sdk/credential-provider-sso");
|
||||
return fromSSO({
|
||||
profile,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
clientConfig: options.clientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => {
|
||||
if (profileData.sso_session) {
|
||||
return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
|
||||
}
|
||||
else {
|
||||
return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
|
||||
}
|
||||
});
|
||||
};
|
||||
export const isSsoProfile = (arg) => arg &&
|
||||
(typeof arg.sso_start_url === "string" ||
|
||||
typeof arg.sso_account_id === "string" ||
|
||||
typeof arg.sso_session === "string" ||
|
||||
typeof arg.sso_region === "string" ||
|
||||
typeof arg.sso_role_name === "string");
|
||||
18
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
generated
vendored
Normal file
18
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
export const isStaticCredsProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.aws_access_key_id === "string" &&
|
||||
typeof arg.aws_secret_access_key === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 &&
|
||||
["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
|
||||
export const resolveStaticCredentials = async (profile, options) => {
|
||||
options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
|
||||
const credentials = {
|
||||
accessKeyId: profile.aws_access_key_id,
|
||||
secretAccessKey: profile.aws_secret_access_key,
|
||||
sessionToken: profile.aws_session_token,
|
||||
...(profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope }),
|
||||
...(profile.aws_account_id && { accountId: profile.aws_account_id }),
|
||||
};
|
||||
return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
|
||||
};
|
||||
16
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
generated
vendored
Normal file
16
backend/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { setCredentialFeature } from "@aws-sdk/core/client";
|
||||
export const isWebIdentityProfile = (arg) => Boolean(arg) &&
|
||||
typeof arg === "object" &&
|
||||
typeof arg.web_identity_token_file === "string" &&
|
||||
typeof arg.role_arn === "string" &&
|
||||
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1;
|
||||
export const resolveWebIdentityCredentials = async (profile, options, callerClientConfig) => import("@aws-sdk/credential-provider-web-identity").then(({ fromTokenFile }) => fromTokenFile({
|
||||
webIdentityTokenFile: profile.web_identity_token_file,
|
||||
roleArn: profile.role_arn,
|
||||
roleSessionName: profile.role_session_name,
|
||||
roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
|
||||
logger: options.logger,
|
||||
parentClientConfig: options.parentClientConfig,
|
||||
})({
|
||||
callerClientConfig,
|
||||
}).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q")));
|
||||
Reference in New Issue
Block a user