-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(credential-providers): add credential attribution (#6546)
* chore(credential-providers): add credential attribution * chore(credential-providers): attribute credential feature sources * test(credential-provider-node): add credential source assertions * test: fix unit test * test(credential-providers): fix unit tests * chore(core): separate function files * chore: undo script change * chore: change Promise.resolve to async fn
- Loading branch information
Showing
38 changed files
with
326 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./emitWarningIfUnsupportedVersion"; | ||
export * from "./setCredentialFeature"; | ||
export * from "./setFeature"; |
40 changes: 40 additions & 0 deletions
40
packages/core/src/submodules/client/setCredentialFeature.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { AttributedAwsCredentialIdentity } from "@aws-sdk/types"; | ||
|
||
import { setCredentialFeature } from "./setCredentialFeature"; | ||
|
||
describe(setCredentialFeature.name, () => { | ||
it("should create the data path if it does't exist", () => { | ||
const credentials = { | ||
accessKeyId: "", | ||
secretAccessKey: "", | ||
} as AttributedAwsCredentialIdentity; | ||
expect(setCredentialFeature(credentials, "CREDENTIALS_CODE", "e")).toEqual({ | ||
accessKeyId: "", | ||
secretAccessKey: "", | ||
$source: { | ||
CREDENTIALS_CODE: "e", | ||
}, | ||
}); | ||
}); | ||
|
||
it("should track a set of features", () => { | ||
const credentials = { | ||
accessKeyId: "", | ||
secretAccessKey: "", | ||
} as AttributedAwsCredentialIdentity; | ||
|
||
setCredentialFeature(credentials, "CREDENTIALS_CODE", "e"); | ||
setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g"); | ||
// it ignores duplicates. | ||
setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS", "g"); | ||
|
||
expect(setCredentialFeature(credentials, "CREDENTIALS_CODE", "e")).toEqual({ | ||
accessKeyId: "", | ||
secretAccessKey: "", | ||
$source: { | ||
CREDENTIALS_CODE: "e", | ||
CREDENTIALS_ENV_VARS: "g", | ||
}, | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/core/src/submodules/client/setCredentialFeature.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { AttributedAwsCredentialIdentity, AwsSdkCredentialsFeatures } from "@aws-sdk/types"; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @returns the credentials with source feature attribution. | ||
*/ | ||
export function setCredentialFeature<F extends keyof AwsSdkCredentialsFeatures>( | ||
credentials: AttributedAwsCredentialIdentity, | ||
feature: F, | ||
value: AwsSdkCredentialsFeatures[F] | ||
): AttributedAwsCredentialIdentity { | ||
if (!credentials.$source) { | ||
credentials.$source = {}; | ||
} | ||
credentials.$source![feature] = value; | ||
return credentials; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.