Skip to content
Anton Bachin edited this page May 11, 2023 · 36 revisions

Web Roadmap

Lists needed improvements to Dream and the OCaml ecosystem for OCaml to be practically useful for Web programming.

Authentication

Today's websites use password login, social login, and two-factor authentication.

  • ❌ Password login.

    • πŸ‘Ž Currently, people have to roll their own solutions.
    • βœ”οΈ Argon2 is the recommended hash function for password storage these days. ocaml-argon2 binds to its C implementation.
    • ❌ We need all the helpers around Argon2, such as the actual login flow, registration, recovery, etc.
  • ❌ Social login.

    • πŸ‘Ž Is basically not ever done by people in OCaml.
    • βœ”οΈ ocaml-oidc implements OpenID Connect, used by most social logins, such as Gmail.
      • ❌ We need to test actually connecting to the various social login providers and work out all the quirks.
    • ❌ Providers such as GitHub implement a bare OAuth2 login process. We need to factor OAuth2 out of ocaml-oidc.
    • ❌ Facebook has its own Facebook Connect. We need to implement this.
  • ❌ Two-factor authentication.

    • πŸ‘Ž Does not exist in OCaml in the form most commonly found on the Web.
      • βœ”οΈ u2f implements U2F, which requires specialized devices.
    • βœ”οΈ qrc implements QR code generation.
    • ❌ Implement TOTP, the most common 2FA method besides SMS.
    • ❌ Make sure the implementation has an API that matches an expected API for SMS and U2F 2FA.
    • ❌ Integrate TOTP with QR code generation, as commonly used on the Web.
  • Other auth methods.

    • WebAuthn?
  • References

HTTPS

  • βœ”οΈ HTTPS itself is well-supported in OCaml.
  • βœ”οΈ Practical use of HTTPS by small-to-medium groups requires Let's Encrypt, implemented by ocaml-letsencrypt.
  • ❌ ocaml-letencrypt needs to be adapted to Dream and made easy to use. This should use the ALPN challenge method.

JSON and data handling

  • πŸ‘Ž OCaml is really awkward at handling "just data," unlike Python and JS.
    • βœ”οΈ Yojson does this to some extent, but has verbose combinators, and the types don't match JSON.
    • βœ”οΈ ezjsonm's types exactly match JSON, but it is based on a slow parser.
    • βœ”οΈ Consider jsonaf.
  • ❌ Study existing solutions in OCaml, F#, ReScript, Rust, Go.
  • ❌ Create a library with types that match JSON exactly, has a fast parser, and short combinators or custom operators.
  • ❌ Port one of the Deriving PPXs to it.
  • ❌ What should be done for form data?
  • ❌ Dynamically tagged data is very nice for automatically putting into SQL prepared statements. Look into this.
  • ❌ Consider implementing JSON5 as an option.

SQL access

  • βœ”οΈ Caqti is a common interface for accessing SQLite, PostgreSQL, and MariaDB.
  • ❌ There is no ready migration option. People on Discord are using gomigrate.
    • βœ”οΈ Antonio has a gist with some migration code.
    • βœ”οΈ Look at ocoi.
    • Look at omigrate
  • ❌ Caqti does not report detailed errors from database drivers.
  • ❌ Caqti appears to lack a transaction wrapper.
  • ❌ Caqti does not have a published manual, or neat API. It is necessary to convoluted functors spread across several .mli files.
  • ❌ We need to find a link to how to write portable SQL (for those who want to do that).
  • ❌ Direct use of Caqti involves a lot of boilerplate. Is there a way to reduce that without PPX?
  • ❌ If a PPX can help with removing some lingering boilerplate, consider a non-intrustive optional PPX.
    • βœ”οΈ There is ppx_rapper β€” study it.
  • ❌ The Caqti Dream integration creates its own connection pool. Allow taking a connection pool created by the user.
  • ❌ Study PG'OCaml and F#'s Npgsql.
  • ❌ Consider some kind of schema checker to run at startup, perhaps part of the migration library.
  • ❌ Consider Ecto.
  • ❌ What does Caqti 1.7.0 offer?

Effects port

  • ❌ What will Dream look like with effects in the language?

Router

  • ❌ A lower combinator layer allowing partial validation during routing, perhaps even allowing composing handlers using a monad. See #122.
  • ❌ Optimizations, such as a trie. Possible solution: art
  • ❌ Generate JSON schema from handlers/routes.

Regular expressions

  • ❌ A cache to skip an explicit compilation step.
  • ❌ Unicode support.
  • ❌ Pick a favorite syntax (PCRE2).

Testing

Caching & CDN

  • ❌ ETags.
  • ❌ Aid for Cache-control, asset hashing.

WebAssembly

Compilation to JS

  • ❌ There are js_of_ocaml, Rescript, and Melange.

Upstreaming

  • ❌ All the vendored dependencies need to be upstreamed and/or released.

Internationalization

Cryptography

Deployment

Protocols

Email

#138

  • βœ”οΈ Library for sending emails via SMTP letters
  • βœ”οΈ Library for composing email mrmime
  • βœ”οΈ Library for validating email address (don't even try to do it with regex, it's really complex): emile
  • ❌ Special handlers for common providers like Mailgun or Amazon SES, sending emails via http protocol.
    • ❌ API access to email-sending services will benefit greatly from Dream having a Dream-friendly client library.
  • ❌ Message queue back ends:
    • ❌ In-memory.
    • ❌ Local broker-less persistent.
    • ❌ RabbitMQ (can already be accessed by amqp-client).
    • ❌ Amazon SQS (aws-sqs).
    • ❌ Optionally Redis.

Templating

  • ❌ Improved syntax highlighting of eml (being worked on at Tarides).
  • ❌ Full IntelliSense support in eml.

Logging

I/O rework

  • βœ”οΈ Very clearly figure out, for both streaming bodies and WebSockets, exactly where allocations are done on each write, where buffering occurs, etc.
  • βœ”οΈ Exactly how and to whom are errors reported?
  • βœ”οΈ Implement proper flow control to avoid filling internal buffers server-side or client-side.
  • ❌ Improve async detection of closed WebSockets.