Skip to content

Commit 3ca8179

Browse files
authored
chore: revert to 3.618.0
1 parent f80c65c commit 3ca8179

File tree

15 files changed

+42
-261
lines changed

15 files changed

+42
-261
lines changed

clients/client-sts/src/defaultStsRoleAssumers.ts

+4-37
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,6 @@ export type RoleAssumer = (
2929

3030
const ASSUME_ROLE_DEFAULT_REGION = "us-east-1";
3131

32-
interface AssumedRoleUser {
33-
/**
34-
* The ARN of the temporary security credentials that are returned from the AssumeRole action.
35-
*/
36-
Arn?: string;
37-
38-
/**
39-
* A unique identifier that contains the role ID and the role session name of the role that is being assumed.
40-
*/
41-
AssumedRoleId?: string;
42-
}
43-
44-
/**
45-
* @internal
46-
*/
47-
const getAccountIdFromAssumedRoleUser = (assumedRoleUser?: AssumedRoleUser) => {
48-
if (typeof assumedRoleUser?.Arn === "string") {
49-
const arnComponents = assumedRoleUser.Arn.split(":");
50-
if (arnComponents.length > 4 && arnComponents[4] !== "") {
51-
return arnComponents[4];
52-
}
53-
}
54-
return undefined;
55-
};
56-
5732
/**
5833
* @internal
5934
*
@@ -109,21 +84,17 @@ export const getDefaultRoleAssumer = (
10984
logger: logger as any,
11085
});
11186
}
112-
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
87+
const { Credentials } = await stsClient.send(new AssumeRoleCommand(params));
11388
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
11489
throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
11590
}
116-
117-
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
118-
11991
return {
12092
accessKeyId: Credentials.AccessKeyId,
12193
secretAccessKey: Credentials.SecretAccessKey,
12294
sessionToken: Credentials.SessionToken,
12395
expiration: Credentials.Expiration,
12496
// TODO(credentialScope): access normally when shape is updated.
125-
...((Credentials as any).CredentialScope && { credentialScope: (Credentials as any).CredentialScope }),
126-
...(accountId && { accountId }),
97+
credentialScope: (Credentials as any).CredentialScope,
12798
};
12899
};
129100
};
@@ -163,21 +134,17 @@ export const getDefaultRoleAssumerWithWebIdentity = (
163134
logger: logger as any,
164135
});
165136
}
166-
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
137+
const { Credentials } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
167138
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
168139
throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
169140
}
170-
171-
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
172-
173141
return {
174142
accessKeyId: Credentials.AccessKeyId,
175143
secretAccessKey: Credentials.SecretAccessKey,
176144
sessionToken: Credentials.SessionToken,
177145
expiration: Credentials.Expiration,
178146
// TODO(credentialScope): access normally when shape is updated.
179-
...((Credentials as any).CredentialScope && { credentialScope: (Credentials as any).CredentialScope }),
180-
...(accountId && { accountId }),
147+
credentialScope: (Credentials as any).CredentialScope,
181148
};
182149
};
183150
};

clients/client-sts/test/defaultRoleAssumers.spec.ts

-26
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ describe("getDefaultRoleAssumer", () => {
8989
);
9090
});
9191

92-
it("should return accountId in the credentials", async () => {
93-
const roleAssumer = getDefaultRoleAssumer();
94-
const params: AssumeRoleCommandInput = {
95-
RoleArn: "arn:aws:foo",
96-
RoleSessionName: "session",
97-
};
98-
const sourceCred = { accessKeyId: "key", secretAccessKey: "secrete" };
99-
const assumedRole = await roleAssumer(sourceCred, params);
100-
expect(assumedRole.accountId).toEqual("123");
101-
});
102-
10392
it("should use the STS client config", async () => {
10493
const logger = console;
10594
const region = "some-region";
@@ -180,10 +169,6 @@ describe("getDefaultRoleAssumer", () => {
180169
describe("getDefaultRoleAssumerWithWebIdentity", () => {
181170
const assumeRoleResponse = `<Response xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
182171
<AssumeRoleWithWebIdentityResult>
183-
<AssumedRoleUser>
184-
<AssumedRoleId>AROAZOX2IL27GNRBJHWC2:session</AssumedRoleId>
185-
<Arn>arn:aws:sts::123456789012:assumed-role/assume-role-test/session</Arn>
186-
</AssumedRoleUser>
187172
<Credentials>
188173
<AccessKeyId>key</AccessKeyId>
189174
<SecretAccessKey>secrete</SecretAccessKey>
@@ -224,17 +209,6 @@ describe("getDefaultRoleAssumerWithWebIdentity", () => {
224209
});
225210
});
226211

227-
it("should return accountId in the credentials", async () => {
228-
const roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity();
229-
const params: AssumeRoleWithWebIdentityCommandInput = {
230-
RoleArn: "arn:aws:foo",
231-
RoleSessionName: "session",
232-
WebIdentityToken: "token",
233-
};
234-
const assumedRole = await roleAssumerWithWebIdentity(params);
235-
expect(assumedRole.accountId).toEqual("123456789012");
236-
});
237-
238212
it("should use the STS client middleware", async () => {
239213
const customMiddlewareFunction = jest.fn();
240214
const roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({}, [

codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/sts-client-defaultRoleAssumers.spec.ts

-26
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ describe("getDefaultRoleAssumer", () => {
8787
);
8888
});
8989

90-
it("should return accountId in the credentials", async () => {
91-
const roleAssumer = getDefaultRoleAssumer();
92-
const params: AssumeRoleCommandInput = {
93-
RoleArn: "arn:aws:foo",
94-
RoleSessionName: "session",
95-
};
96-
const sourceCred = { accessKeyId: "key", secretAccessKey: "secrete" };
97-
const assumedRole = await roleAssumer(sourceCred, params);
98-
expect(assumedRole.accountId).toEqual("123");
99-
});
100-
10190
it("should use the STS client config", async () => {
10291
const logger = console;
10392
const region = "some-region";
@@ -178,10 +167,6 @@ describe("getDefaultRoleAssumer", () => {
178167
describe("getDefaultRoleAssumerWithWebIdentity", () => {
179168
const assumeRoleResponse = `<Response xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
180169
<AssumeRoleWithWebIdentityResult>
181-
<AssumedRoleUser>
182-
<AssumedRoleId>AROAZOX2IL27GNRBJHWC2:session</AssumedRoleId>
183-
<Arn>arn:aws:sts::123456789012:assumed-role/assume-role-test/session</Arn>
184-
</AssumedRoleUser>
185170
<Credentials>
186171
<AccessKeyId>key</AccessKeyId>
187172
<SecretAccessKey>secrete</SecretAccessKey>
@@ -222,17 +207,6 @@ describe("getDefaultRoleAssumerWithWebIdentity", () => {
222207
});
223208
});
224209

225-
it("should return accountId in the credentials", async () => {
226-
const roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity();
227-
const params: AssumeRoleWithWebIdentityCommandInput = {
228-
RoleArn: "arn:aws:foo",
229-
RoleSessionName: "session",
230-
WebIdentityToken: "token",
231-
};
232-
const assumedRole = await roleAssumerWithWebIdentity(params);
233-
expect(assumedRole.accountId).toEqual("123456789012");
234-
});
235-
236210
it("should use the STS client middleware", async () => {
237211
const customMiddlewareFunction = jest.fn();
238212
const roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({}, [

codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/sts-client-defaultStsRoleAssumers.ts

+4-37
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,6 @@ export type RoleAssumer = (
2626

2727
const ASSUME_ROLE_DEFAULT_REGION = "us-east-1";
2828

29-
interface AssumedRoleUser {
30-
/**
31-
* The ARN of the temporary security credentials that are returned from the AssumeRole action.
32-
*/
33-
Arn?: string;
34-
35-
/**
36-
* A unique identifier that contains the role ID and the role session name of the role that is being assumed.
37-
*/
38-
AssumedRoleId?: string;
39-
}
40-
41-
/**
42-
* @internal
43-
*/
44-
const getAccountIdFromAssumedRoleUser = (assumedRoleUser?: AssumedRoleUser) => {
45-
if (typeof assumedRoleUser?.Arn === "string") {
46-
const arnComponents = assumedRoleUser.Arn.split(":");
47-
if (arnComponents.length > 4 && arnComponents[4] !== "") {
48-
return arnComponents[4];
49-
}
50-
}
51-
return undefined;
52-
};
53-
5429
/**
5530
* @internal
5631
*
@@ -106,21 +81,17 @@ export const getDefaultRoleAssumer = (
10681
logger: logger as any,
10782
});
10883
}
109-
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
84+
const { Credentials } = await stsClient.send(new AssumeRoleCommand(params));
11085
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
11186
throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
11287
}
113-
114-
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
115-
11688
return {
11789
accessKeyId: Credentials.AccessKeyId,
11890
secretAccessKey: Credentials.SecretAccessKey,
11991
sessionToken: Credentials.SessionToken,
12092
expiration: Credentials.Expiration,
12193
// TODO(credentialScope): access normally when shape is updated.
122-
...((Credentials as any).CredentialScope && { credentialScope: (Credentials as any).CredentialScope }),
123-
...(accountId && { accountId }),
94+
credentialScope: (Credentials as any).CredentialScope,
12495
};
12596
};
12697
};
@@ -160,21 +131,17 @@ export const getDefaultRoleAssumerWithWebIdentity = (
160131
logger: logger as any,
161132
});
162133
}
163-
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
134+
const { Credentials } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
164135
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
165136
throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
166137
}
167-
168-
const accountId = getAccountIdFromAssumedRoleUser(AssumedRoleUser);
169-
170138
return {
171139
accessKeyId: Credentials.AccessKeyId,
172140
secretAccessKey: Credentials.SecretAccessKey,
173141
sessionToken: Credentials.SessionToken,
174142
expiration: Credentials.Expiration,
175143
// TODO(credentialScope): access normally when shape is updated.
176-
...((Credentials as any).CredentialScope && { credentialScope: (Credentials as any).CredentialScope }),
177-
...(accountId && { accountId }),
144+
credentialScope: (Credentials as any).CredentialScope,
178145
};
179146
};
180147
};

packages/credential-provider-env/src/fromEnv.spec.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { CredentialsProviderError } from "@smithy/property-provider";
22

3-
import { ENV_ACCOUNT_ID, ENV_EXPIRATION, ENV_KEY, ENV_SECRET, ENV_SESSION, fromEnv } from "./fromEnv";
3+
import { ENV_EXPIRATION, ENV_KEY, ENV_SECRET, ENV_SESSION, fromEnv } from "./fromEnv";
44

55
describe(fromEnv.name, () => {
66
const ORIGINAL_ENV = process.env;
77
const mockAccessKeyId = "mockAccessKeyId";
88
const mockSecretAccessKey = "mockSecretAccessKey";
99
const mockSessionToken = "mockSessionToken";
1010
const mockExpiration = new Date().toISOString();
11-
const mockAccountId = "123456789012";
1211

1312
beforeEach(() => {
1413
process.env = {
@@ -17,7 +16,6 @@ describe(fromEnv.name, () => {
1716
[ENV_SECRET]: mockSecretAccessKey,
1817
[ENV_SESSION]: mockSessionToken,
1918
[ENV_EXPIRATION]: mockExpiration,
20-
[ENV_ACCOUNT_ID]: mockAccountId,
2119
};
2220
});
2321

@@ -32,33 +30,19 @@ describe(fromEnv.name, () => {
3230
secretAccessKey: mockSecretAccessKey,
3331
sessionToken: mockSessionToken,
3432
expiration: new Date(mockExpiration),
35-
accountId: mockAccountId,
3633
});
3734
});
3835

39-
it("can create credentials without a session token, accountId, or expiration", async () => {
36+
it("can create credentials without a session token or expiration", async () => {
4037
delete process.env[ENV_SESSION];
4138
delete process.env[ENV_EXPIRATION];
42-
delete process.env[ENV_ACCOUNT_ID];
4339
const receivedCreds = await fromEnv()();
4440
expect(receivedCreds).toStrictEqual({
4541
accessKeyId: mockAccessKeyId,
4642
secretAccessKey: mockSecretAccessKey,
4743
});
4844
});
4945

50-
it("should include accountId when it is provided in environment variables", async () => {
51-
process.env[ENV_ACCOUNT_ID] = mockAccountId;
52-
const receivedCreds = await fromEnv()();
53-
expect(receivedCreds).toHaveProperty("accountId", mockAccountId);
54-
});
55-
56-
it("should not include accountId when it is not provided in environment variables", async () => {
57-
delete process.env[ENV_ACCOUNT_ID]; // Ensure accountId is not set
58-
const receivedCreds = await fromEnv()();
59-
expect(receivedCreds).not.toHaveProperty("accountId");
60-
});
61-
6246
it.each([ENV_KEY, ENV_SECRET])("throws if env['%s'] is not found", async (key) => {
6347
delete process.env[key];
6448
const expectedError = new CredentialsProviderError("Unable to find environment variable credentials.");

packages/credential-provider-env/src/fromEnv.ts

-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ export const ENV_EXPIRATION = "AWS_CREDENTIAL_EXPIRATION";
2424
* @internal
2525
*/
2626
export const ENV_CREDENTIAL_SCOPE = "AWS_CREDENTIAL_SCOPE";
27-
/**
28-
* @internal
29-
*/
30-
export const ENV_ACCOUNT_ID = "AWS_ACCOUNT_ID";
3127

3228
/**
3329
* @internal
@@ -45,7 +41,6 @@ export const fromEnv =
4541
const sessionToken: string | undefined = process.env[ENV_SESSION];
4642
const expiry: string | undefined = process.env[ENV_EXPIRATION];
4743
const credentialScope: string | undefined = process.env[ENV_CREDENTIAL_SCOPE];
48-
const accountId: string | undefined = process.env[ENV_ACCOUNT_ID];
4944

5045
if (accessKeyId && secretAccessKey) {
5146
return {
@@ -54,7 +49,6 @@ export const fromEnv =
5449
...(sessionToken && { sessionToken }),
5550
...(expiry && { expiration: new Date(expiry) }),
5651
...(credentialScope && { credentialScope }),
57-
...(accountId && { accountId }),
5852
};
5953
}
6054

packages/credential-provider-ini/src/resolveStaticCredentials.spec.ts

-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const getMockStaticCredsProfile = () => ({
55
aws_secret_access_key: "mock_aws_secret_access_key",
66
aws_session_token: "mock_aws_session_token",
77
aws_credential_scope: "mock_aws_credential_scope",
8-
aws_account_id: "mock_aws_account_id",
98
});
109

1110
describe(isStaticCredsProfile.name, () => {
@@ -33,12 +32,6 @@ describe(isStaticCredsProfile.name, () => {
3332
});
3433
});
3534

36-
it.each(["aws_account_id"])("value at '%s' is not of type string | undefined", (key) => {
37-
[true, null, 1, NaN, {}].forEach((value) => {
38-
expect(isStaticCredsProfile({ ...getMockStaticCredsProfile(), [key]: value })).toEqual(false);
39-
});
40-
});
41-
4235
it("returns true for StaticCredentialsProfile", () => {
4336
expect(isStaticCredsProfile(getMockStaticCredsProfile())).toEqual(true);
4437
});
@@ -53,7 +46,6 @@ describe(resolveStaticCredentials.name, () => {
5346
secretAccessKey: mockProfile.aws_secret_access_key,
5447
sessionToken: mockProfile.aws_session_token,
5548
credentialScope: mockProfile.aws_credential_scope,
56-
accountId: mockProfile.aws_account_id,
5749
});
5850
});
5951
});

packages/credential-provider-ini/src/resolveStaticCredentials.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface StaticCredsProfile extends Profile {
1010
aws_secret_access_key: string;
1111
aws_session_token?: string;
1212
aws_credential_scope?: string;
13-
aws_account_id?: string;
1413
}
1514

1615
/**
@@ -21,8 +20,7 @@ export const isStaticCredsProfile = (arg: any): arg is StaticCredsProfile =>
2120
typeof arg === "object" &&
2221
typeof arg.aws_access_key_id === "string" &&
2322
typeof arg.aws_secret_access_key === "string" &&
24-
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 &&
25-
["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
23+
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
2624

2725
/**
2826
* @internal
@@ -36,7 +34,6 @@ export const resolveStaticCredentials = (
3634
accessKeyId: profile.aws_access_key_id,
3735
secretAccessKey: profile.aws_secret_access_key,
3836
sessionToken: profile.aws_session_token,
39-
...(profile.aws_credential_scope && { credentialScope: profile.aws_credential_scope }),
40-
...(profile.aws_account_id && { accountId: profile.aws_account_id }),
37+
credentialScope: profile.aws_credential_scope,
4138
});
4239
};

0 commit comments

Comments
 (0)