Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ describe(resolveAwsSdkSigV4Config.name, () => {
expect(await config.credentials()).toEqual({
accessKeyId: "unit-test",
secretAccessKey: "unit-test",
$source: {
CREDENTIALS_CODE: "e",
},
});

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,19 @@ export const resolveAwsSdkSigV4Config = <T>(
});
const boundProvider = bindCallerConfig(config, memoizedProvider);
if (isUserSupplied && !boundProvider.attributed) {
resolvedCredentials = async (options: Record<string, any> | undefined) =>
boundProvider(options).then((creds: AttributedAwsCredentialIdentity) =>
setCredentialFeature(creds, "CREDENTIALS_CODE", "e")
);
// Check if the original input was a credential object
const isCredentialObject = typeof inputCredentials === "object" && inputCredentials !== null;

resolvedCredentials = async (options: Record<string, any> | undefined) => {
const creds = await boundProvider(options);
const attributedCreds = creds as AttributedAwsCredentialIdentity;

// Only set CREDENTIALS_CODE if user provided a credential object and no source attribution exists
if (isCredentialObject && (!attributedCreds.$source || Object.keys(attributedCreds.$source).length === 0)) {
return setCredentialFeature(attributedCreds, "CREDENTIALS_CODE", "e");
Copy link
Copy Markdown
Contributor

@kuhe kuhe Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this still needs to check that no other attribution exists in $source

}
return attributedCreds;
};
resolvedCredentials.memoized = boundProvider.memoized;
resolvedCredentials.configBound = boundProvider.configBound;
resolvedCredentials.attributed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "SSO_SESSION_TOKEN_us-sso-region-1",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_SSO_LEGACY: "u",
},
});
Expand Down Expand Up @@ -523,7 +522,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_us-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -567,7 +565,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_us-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -613,7 +610,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_us-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -666,7 +662,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_us-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -724,7 +719,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_ARWI_SESSION_TOKEN_ap-northeast-1",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
});
Expand Down Expand Up @@ -765,7 +759,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_ARWI_SESSION_TOKEN_eu-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
});
Expand Down Expand Up @@ -827,7 +820,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "COGNITO_SESSION_TOKEN_ap-northeast-1",
identityId: "",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: { CREDENTIALS_CODE: "e" },
});
});

Expand All @@ -846,7 +838,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "COGNITO_SESSION_TOKEN_ap-northeast-1",
identityId: "ap-northeast-1:COGNITO_IDENTITY_ID",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: { CREDENTIALS_CODE: "e" },
});
});

Expand Down Expand Up @@ -875,7 +866,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_eu-west-1",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -907,7 +897,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_eu-west-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand All @@ -930,7 +919,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_ARWI_SESSION_TOKEN_ap-northeast-1",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
});
Expand Down Expand Up @@ -1108,7 +1096,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "STS_AR_SESSION_TOKEN_ap-northeast-1",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
CREDENTIALS_STS_ASSUME_ROLE: "i",
},
Expand Down Expand Up @@ -1156,7 +1143,6 @@ describe("credential-provider-node integration test", () => {
secretAccessKey: "DEFAULT",
sessionToken: undefined,
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE: "n",
},
});
Expand Down Expand Up @@ -1232,7 +1218,6 @@ describe("credential-provider-node integration test", () => {
sessionToken: "SSO_SESSION_TOKEN_us-sso-region-2",
expiration: new Date("3000-01-01T00:00:00.000Z"),
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE_SSO: "r",
CREDENTIALS_SSO: "s",
},
Expand Down Expand Up @@ -1306,9 +1291,6 @@ describe("credential-provider-node integration test", () => {
expect(credentials).toEqual({
accessKeyId: "STS_AK1",
secretAccessKey: "STS_SAK1",
$source: {
CREDENTIALS_CODE: "e",
},
});
});

Expand All @@ -1321,18 +1303,12 @@ describe("credential-provider-node integration test", () => {
expect(credentials1).toEqual({
accessKeyId: "STS_AK1",
secretAccessKey: "STS_SAK1",
$source: {
CREDENTIALS_CODE: "e",
},
});

const credentials2 = await client.config.credentials({});
expect(credentials2).toEqual({
accessKeyId: "STS_AK1",
secretAccessKey: "STS_SAK1",
$source: {
CREDENTIALS_CODE: "e",
},
});

const credentials3 = await client.config.credentials({
Expand All @@ -1341,18 +1317,12 @@ describe("credential-provider-node integration test", () => {
expect(credentials3).toEqual({
accessKeyId: "STS_AK2",
secretAccessKey: "STS_SAK2",
$source: {
CREDENTIALS_CODE: "e",
},
});

const credentials4 = await client.config.credentials({});
expect(credentials4).toEqual({
accessKeyId: "STS_AK2",
secretAccessKey: "STS_SAK2",
$source: {
CREDENTIALS_CODE: "e",
},
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ describe(fromCognitoIdentity.name, () => {
});
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
},
accessKeyId: "COGNITO_ACCESS_KEY_ID",
expiration: new Date("3000-01-01T00:00:00.000Z"),
identityId: "us-east-2:128d0a74-c82f-4553-916d-90053example",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ describe(fromCognitoIdentityPool.name, () => {
});
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
},
accessKeyId: "COGNITO_ACCESS_KEY_ID",
expiration: new Date("3000-01-01T00:00:00.000Z"),
identityId: "us-east-2:COGNITO_IDENTITY_ID",
Expand Down
2 changes: 0 additions & 2 deletions packages/credential-providers/tests/fromHttp.integ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe(fromHttp.name, () => {
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_HTTP: "z",
CREDENTIALS_CODE: "e",
},
accessKeyId: "CONTAINER_ACCESS_KEY",
expiration: new Date("3000-01-01T00:00:00.000Z"),
Expand Down Expand Up @@ -48,7 +47,6 @@ describe(fromHttp.name, () => {
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_HTTP: "z",
CREDENTIALS_CODE: "e",
},
accessKeyId: "CONTAINER_ACCESS_KEY",
expiration: new Date("3000-01-01T00:00:00.000Z"),
Expand Down
3 changes: 0 additions & 3 deletions packages/credential-providers/tests/fromIni.integ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe(fromIni.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE: "n",
},
accessKeyId: "A",
Expand All @@ -57,7 +56,6 @@ describe(fromIni.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE: "n",
},
accessKeyId: "A",
Expand All @@ -84,7 +82,6 @@ describe(fromIni.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROFILE: "n",
},
accessKeyId: "A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe(fromLoginCredentials.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_LOGIN: "AD",
},
accessKeyId: "LOGIN_ACCESS_KEY_ID",
Expand Down Expand Up @@ -123,7 +122,6 @@ describe(fromLoginCredentials.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_LOGIN: "AD",
},
accessKeyId: "LOGIN_ACCESS_KEY_ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe(fromProcess.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROCESS: "w",
},
accessKeyId: "PROCESS_ACCESS_KEY_ID",
Expand All @@ -48,7 +47,6 @@ describe(fromProcess.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROCESS: "w",
},
accessKeyId: "PROCESS_ACCESS_KEY_ID",
Expand All @@ -73,7 +71,6 @@ describe(fromProcess.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_PROCESS: "w",
},
accessKeyId: "PROCESS_ACCESS_KEY_ID",
Expand Down
2 changes: 0 additions & 2 deletions packages/credential-providers/tests/fromSSO.integ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe(fromSSO.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_SSO_LEGACY: "u",
},
accessKeyId: "SSO_ACCESS_KEY_ID",
Expand All @@ -69,7 +68,6 @@ describe(fromSSO.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_SSO_LEGACY: "u",
},
accessKeyId: "SSO_ACCESS_KEY_ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe(fromTokenFile.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN: "h",
},
Expand Down Expand Up @@ -63,7 +62,6 @@ describe(fromTokenFile.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
accessKeyId: "STS_ARWI_ACCESS_KEY_ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe(fromWebToken.name, () => {
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_CODE: "e",
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
accessKeyId: "STS_ARWI_ACCESS_KEY_ID",
Expand Down
Loading