xmtp / xmtp-js

XMTP client SDKs for JavaScript applications.

Home Page:https://xmtp.org/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: GRPC ApiClient for Node.js

neekolas opened this issue · comments

Is your feature request related to a problem?

The current ApiClient implementation uses the HTTP API, which is not very reliable for long-lived streaming sessions. Once a pluggable API client is merged in, we could create an API client that communicates with our nodes over GRPC.

Describe the solution to the problem

Use Buf to generate the service stubs for Node.js, and then wrap those stubs in an interface that matches the current ApiClient.

Describe the uses cases for the feature

Bots and server-side applications using xmtp-js

Additional details

Special caution will need to be taken with the message field. The generated code for the current HTTP API shows the message field as having a type of Uint8Array, but the actual returned value is a base64 encoded string. We have hacked around and paved over this limitation of the HTTP code generator by base64 decoding the string in our SDK (check for usage of b64Decode. We'll want to isolate those hacks to the ApiClient so that both the GRPC and HTTP APIs return the same types.