feat: allow modifying trustless-gateway fetch#751
Merged
Conversation
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`
Member
Author
|
@pcfreak30 can you confirm this will work for your use-case? cc @achingbrain |
Contributor
At a glance, yes. primary use case is a JWT. |
Member
Author
|
I'll need to look further into the chrome failures later. I was able to reproduce these locally fixed with |
Member
Author
|
ping @achingbrain and @2color for review |
2color
reviewed
Mar 4, 2025
2color
approved these changes
Mar 4, 2025
Contributor
|
Happy to see this get merged in :). Thanks for collaborating. |
achingbrain
reviewed
Mar 6, 2025
| } | ||
|
|
||
| export async function * findHttpGatewayProviders (cid: CID, routing: Routing, logger: ComponentLogger, allowInsecure: boolean, allowLocal: boolean, options?: AbortOptions): AsyncGenerator<TrustlessGateway> { | ||
| export async function * findHttpGatewayProviders (cid: CID, routing: Routing, logger: ComponentLogger, allowInsecure: boolean, allowLocal: boolean, transformRequestInit?: TransformRequestInit, options: AbortOptions = {}): AsyncGenerator<TrustlessGateway> { |
Member
There was a problem hiding this comment.
Given that it's optional, can transformRequestInit go in the options object?
achingbrain
approved these changes
Mar 6, 2025
Member
achingbrain
left a comment
There was a problem hiding this comment.
LGTM. Small nit about the optional arg.
Merged
2color
added a commit
that referenced
this pull request
Mar 13, 2025
* origin/main: chore: use peer id parsing function from libp2p (#762) feat: add republish signed ipns records (#745) fix: use bytestream methods to add byte streams (#758) chore: bump codecov/codecov-action from 5.3.1 to 5.4.0 (#752) feat: allow modifying trustless-gateway fetch (#751) fix: align implicit default ttl with specs (#749) docs: add spell checker to ci (#743) chore: Update FUNDING.json for Optimism RPF (#746)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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