Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented May 27, 2025

This PR refactors the BaseCredentials implementation to provide better type safety and a cleaner API surface. By converting from an abstract class to a static factory pattern with proper interfaces, we improve the developer experience and make the code more maintainable.

The changes also reduce external dependencies by removing the direct dependency on @smithy/node-http-handler and creating our own simplified interface for request handler settings.

Reason for this change is that in the previous version SdkProviderServices was used but not publicly exported since this interface wasn't meant for public consumption. That however made it difficult to implement custom BaseCredentials solutions. Instead of SdkProviderServices we have no reduced the public API surface to the exactly needed properties.

BREAKING CHANGE: Custom implementations of BaseCredentials have changed. If you previously extended the abstract BaseCredentials class and implemented the abstract method, you can now pass any object implementing the new IBaseCredentialsProvider interface. The method name change to sdkBaseConfig and it now receives two parameters: an ioHost that can be used to emit messages and a clientConfig to should be honored for all SDK requests. However the clientConfig may be extended as needed.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label May 27, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team May 27, 2025 17:57
@mrgrain mrgrain changed the title feat(toolkit-lib): improved types for BaseCredentials feat(toolkit-lib)!: improved types for BaseCredentials May 27, 2025
requestResponse<T>(msg: IoRequest<unknown, T>): Promise<T>;
}

export interface IActionAwareIoHost {
Copy link
Contributor Author

@mrgrain mrgrain May 27, 2025

Choose a reason for hiding this comment

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

This only exists so that we can pass it to sdkBaseConfig of awsCliCompatible without having to also pass the action. I'm a bit on the fence w.r.t to that though.

Alternatively we could make it a regular IIoHost and do some trickery by conditionally checking if the received IoHost is already an IoHelper or not. If it is, we can use it as is and if it's not we set an action value like auth. In practice this will always be an IoHelper when used with the Toolkit. Only if used externally this might be something else.

However I thought this IActionAwareIoHost might come handy elsewhere.

@mrgrain mrgrain force-pushed the mrgrain/feat/toolkit-lib/base-credentials-types branch from 1294775 to 6d92764 Compare May 27, 2025 20:13
@mrgrain mrgrain temporarily deployed to integ-approval May 27, 2025 20:13 — with GitHub Actions Inactive
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.09%. Comparing base (c48b685) to head (6d92764).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #542      +/-   ##
==========================================
+ Coverage   78.88%   79.09%   +0.20%     
==========================================
  Files          47       47              
  Lines        7072     7074       +2     
  Branches      785      791       +6     
==========================================
+ Hits         5579     5595      +16     
+ Misses       1474     1460      -14     
  Partials       19       19              
Flag Coverage Δ
suite.unit 79.09% <100.00%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit b04ad30 May 28, 2025
21 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/feat/toolkit-lib/base-credentials-types branch May 28, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants