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!: A few things to make egress work #7

Merged
merged 4 commits into from
Nov 29, 2024
Merged

Conversation

Peeja
Copy link
Member

@Peeja Peeja commented Nov 26, 2024

Part of storacha/project-tracking#140

  • Match with DIDs, not Principals: We don't need to know the DID's key, just the DID itself. Therefore, we should take only the DID. Otherwise, code which wants to pass in a Space but only has the (string) DID must parse it into a full Principal first.
  • Make completely sure fetch works: Wrangler does weird things with proxies that make .bind() not sufficient.
  • Refer to CAR.code rather than magic number: Only because I read this line and wasn't sure which code it was without looking it up.

We don't need to know the DID's key, just the DID itself. Therefore, we
should take only the DID. Otherwise, code which wants to pass in a Space
but only has the (string) DID must parse it into a full `Principal`
first.
@Peeja Peeja requested review from alanshaw and fforbeck November 26, 2024 19:57
@alanshaw
Copy link
Member

Can you elaborate on the fetch related change? I don't follow. What is the issue and why does changing it to this help?

@Peeja Peeja changed the title A few things to make egress work feat!: A few things to make egress work Nov 26, 2024
@Peeja
Copy link
Member Author

Peeja commented Nov 27, 2024

@alanshaw Honestly, I don't totally understand the mechanics, but the upshot is that you end up with a Illegal invocation: function called with incorrect `this` reference. otherwise. Wrangler replaces globalThis.fetch with a Proxy, and my theory is that that somehow makes bind() not sufficient to keep its this.

@alanshaw
Copy link
Member

It sounds like a problem specific to cloudflare workers and I'd be inclined to move the solution over there, as in leave the option the same here but in cloudflare workers pass { fetch: (...args) => fetch(...args) } to the locator instead.

@Peeja
Copy link
Member Author

Peeja commented Nov 27, 2024

Yeah, I buy that.

alanshaw
alanshaw previously approved these changes Nov 27, 2024
@alanshaw alanshaw dismissed their stale review November 27, 2024 18:03

Accidental approve!

@Peeja Peeja merged commit aabacb9 into main Nov 29, 2024
1 check passed
@Peeja Peeja deleted the dids-not-principals-etc branch November 29, 2024 14:57
Peeja added a commit that referenced this pull request Nov 29, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.0.0](v1.1.3...v2.0.0)
(2024-11-29)


### ⚠ BREAKING CHANGES

* A few things to make egress work
([#7](#7))
* Match with `DID`s, not `Principal`s

### Features

* A few things to make egress work
([#7](#7))
([aabacb9](aabacb9))
* Match with `DID`s, not `Principal`s
([674d22f](674d22f))


### Bug Fixes

* Make completely sure `fetch` works
([6bf83ac](6bf83ac))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants