Skip to content

JS bindings should include io functionality #1250

Open

Description

@spacebear21

Due to WASM limitations the io feature is disabled in JS auto-generated bindings. We should consider whether to offer an alternative for fetching OHTTP keys in JS bindings, at a minimum just documenting how to fetch keys with the fetch API.

Activity

  1. DanGould commented on Dec 30, 2025

    @DanGould
    Member

    This could be a good first issue because it's well defined for someone who understands HTTP, WebSocket, and TLS clients, but it definitely has some sharp edges. The thing is this issue is implementing a solution that has already been proven in Mutiny ages ago.

    The thing is with NodeJS you can probably use the HTTPS client to do CONNECT requests and nest the bootstrap fetch OHTTP keys messages. If NodeJS has the HTTPS client, it may already have a viable TLS client available there to do the nested TLS.

    However, in the browser, I'm not sure CONNECT requests are available with the fetch API. Nor is a TLS client API available on any such CONNECT client or shipped made available to JavaScript. So I would include rustls to nest TLS in the example and then if CONNECT can't work I'd use the directory's WebSocket API instead to bootstrap and close this issue.

  2. added
    good first issue
    on Dec 30, 2025
  3. Anunayj commented on Jan 15, 2026

    @Anunayj

    Hey! I think I can try to take a dig at this, this weekend.

  4. spacebear21 commented on Jan 15, 2026

    @spacebear21
    CollaboratorAuthor

    Cool! The JS bindings are brand new and may be tricky to work with, so please don't hesitate to ask questions here or DM for guidance.

  5. Anunayj commented on Jan 18, 2026

    @Anunayj

    Hey there!
    I realized in the browser environment, when we end up having to use the HTTPS in WS proxy, we don't have access to any CA Trust Store, (I don't think browsers provide a way to access it).

    In that case, we'd likely have to bundle a whole trust store with the bindings themselves. We can use Mozilla's CA Bundle, but that would introduce challenges with keeping it updated, etc.

    Let me know what you recommend.

    P.S. is it necessary to use rustls for userspace TLS over WS? Can't we use something like node-forge and not have to deal with any WASM blobs.

  6. DanGould commented on Jan 19, 2026

    @DanGould
    Member

    Yes i believe we have to ship rustls, not because we're using wss:// but because we're proxying serialized TLS messages over that connection. Theoretically it may be possible to use node-forge but I think you'll find it much easier, especially for a first integration, to bind to something that wraps rustls in wasm as is explicitly demonstrated here in Mutiny Wallet. I suggest you re-write a ws-tls proxy/tunnel fetch function with rustls and expose that as a js-io-specific fetch function.

  7. mwihoti commented on Nov 19, 2026

    @mwihoti
    Contributor

    Hi @Anunayj, are you still planning to work on this? It now conflicts with master since the JS bindings were split into src/nodejs and src/web in #1513.If you’ve moved on, I’d like to pick up #1250. I’d follow how Python (#1386) and Dart (#1495) did it, which #1362 asks for: a small native fetchOhttpKeys in TypeScript for Node using built-in http CONNECT and tls, instead of reviving io in payjoin-ffi. For the browser I’d document the CONNECT limitation for now and leave the WebSocket/rustls bootstrap for a follow-up.

  8. Anunayj commented on Nov 19, 2026

    @Anunayj

    Hey @mwihoti I can pick this up this weekend, let me know if you have any review comments.

  9. mwihoti commented on Nov 19, 2026

    @mwihoti
    Contributor

    Thanks @Anunayj, glad you’re picking it back up! I went through the branch and noted a few things that might save you time: It’ll need a rebase. The JS bindings got split into src/nodejs/ and src/web/ in #1513.

    • I think the WebSocket path is hitting the wrong endpoint. It requests /ohttp-keys, but keys are served at /.well-known/ohttp-gateway.
    • I didn’t see a status check on either path, so a server error would show up as a decode error.
      When CONNECT fails and it falls back to WebSocket, the first error gets lost, which could make debugging harder.
    • The Node-only polyfills and undici would probably break the src/web build.
      Since Expose native fetch_ohttp_keys in every supported downstream language #1362 tracks native per-language implementations, it might be worth checking with @spacebear21 which direction they prefer before you rebase.

    I’d be happy to review again once you push. I’m also keen to learn how the JS bindings work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ffigood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions