Closed varunsrin closed 1 year ago
My two cents:
Supporting web browsers isn't an immediate problem, but in the medium term it lowers the barrier to entry for community members looking to make something using farcaster, which is good. I imagine some devs will want very basic access and choose to use the hub RPC for reading/writing and others will use more feature-rich APIs or build their own backends for indexing data. There's certainly an opportunity for community members to make their own indexing services and APIs on top of hubs for many use cases, similar to Alchemy's various APIs for ethereum.
We should support both grpc and grpc-web simultaneously using a proxy (I made it work with Envoy, as you mentioned, though there may be other options too). So hub-to-hub communication will continue to use gRPC directly.
we should see whether farcaster/js works by default in serverless platforms like vercel. if it does, we can punt this to a later milestone
Create a new package called @farcaster/hub-web
that exports the same methods as @farcaster/hub-nodejs
except with a grpc-web client instead of a grpc one that works in browsers.
@farcaster/hub-web
package in the monoreporpc.proto
schema and export it from the new package. If using ts-proto, we can use the outputClientImpl=grpc-web
option (see documentation).@farcaster/utils
from the new package, but utils right now depends on @farcaster/protobufs
which depends on @grpc/grpc-js
which is not supported in the browser. So we need to refactor utils to not depend on grpc-js. One option would be to remove any services generated code from the protobufs package (see the outputServices=false
ts-proto option) and add generated grpc-js code to the @farcaster/hub-nodejs
package. That way the nodejs package has the grpc-js client and the web package has the grpc-web client.@farcaster/hub-nodejs
package or generate its own server and client grpc-js implementations from the rpc.proto
schema, since right now those are imported from the protobufs package (see server.ts and hubble.ts).@farcaster/utils
and @farcaster/protobufs
into a single @farcaster/core
repo, since they'll always be used together and should support all environments after the refactor.It appears this is solved, yet the readme states that it is not
I've supplied a PR to remove that! Let me know if this looks right 🙏 https://github.com/farcasterxyz/hub-monorepo/pull/1865
What is the feature you would like to implement?
Get @farcaster/js compiling in browsers
Why is this feature important?
Single-page and stand alone client applications will be able to interface directly with Hubs without a server.
Will the protocol spec need to be updated??
No
Additional context