Skip to content
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

feat: allow modifying trustless-gateway fetch #751

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Feb 27, 2025

  • feat: add support for custom headers in trustless gateway
  • chore: allow test trustless gateway server introspection
  • feat: allow modification of fetch options to trustless gateway

Title

feat: allow modifying trustless-gateway fetch

Description

This PR allows consumers to modify headers and any other RequestInit options that trustless-gateways use when making a fetch request to a trustless gateway.

This allows consumers to add JWT tokens to the request, or modifying the request in a variety of other ways. If the user does not modify the requestInit object, the default behavior is to use the same requestInit object that was used prior to this PR.

Fixes #659
Replaces #732

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

pcfreak30 and others added 3 commits February 1, 2025 04:48
Added an optional `headers` property to the `TrustlessGatewayBlockBroker` and `TrustlessGatewaySession` options, allowing users to specify custom headers for HTTP requests.

Changes include:
* Added `headers` property to `TrustlessGatewayBlockBroker` and `TrustlessGatewaySession` options
* Updated `findHttpGatewayProviders` function to accept an optional `headers` object
* Passed `headers` object to `TrustlessGateway` constructor
* Updated `TrustlessGateway` constructor to accept an optional `headers` object
* Added `headers` to HTTP request options in `TrustlessGateway`
@SgtPooki SgtPooki requested a review from a team as a code owner February 27, 2025 20:59
Copy link
Member Author

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

self review

@SgtPooki
Copy link
Member Author

SgtPooki commented Feb 27, 2025

@pcfreak30 can you confirm this will work for your use-case?

cc @achingbrain

@SgtPooki SgtPooki requested a review from achingbrain February 27, 2025 21:05
@pcfreak30
Copy link

@pcfreak30 can you confirm this will work for your use-case?

cc @achingbrain

At a glance, yes. primary use case is a JWT.

@SgtPooki
Copy link
Member Author

SgtPooki commented Feb 27, 2025

I'll need to look further into the chrome failures later. I was able to reproduce these locally but cannot any longer.

fixed with cd1f716 (#751)

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.

@helia/block-brokers should support http headers being passed
2 participants