Skip to content

Adding support for setting the fetch API credentials mode #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

qnesingh
Copy link
Contributor

Issue #, if available: 1296

Description of changes: Adds support to set credentials in the fetch API to include, same-origin, or omit.

If one or more of the packages in the /packages directory has been modified, be sure yarn changeset add has been run and its output has
been committed and included in this pull request. See CONTRIBUTING.md.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@qnesingh qnesingh requested review from a team as code owners June 26, 2024 14:06
@qnesingh qnesingh requested a review from JordonPhillips June 26, 2024 14:06
@kuhe kuhe self-assigned this Jun 26, 2024
/**
* A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
*/
credentials?: "include" | "omit" | "same-origin" | undefined | string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe credentialsMode instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

credentials matches the property on the Fetch request itself. I think it makes sense to keep this property name consistent with how it's used on the request.

@@ -77,6 +77,7 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
}
const requestTimeoutInMs = this.config!.requestTimeout;
const keepAlive = this.config!.keepAlive === true;
const credentials = this.config!.credentials as RequestInit["credentials"];
Copy link
Contributor

Choose a reason for hiding this comment

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

we're already using RequestInit, so RequestCredentials is probably globally available too, but I'm being conservative here.

@kuhe kuhe merged commit 4784fb9 into smithy-lang:main Jun 27, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants