From 30f002289ef6f5dd544f25bc4965fa8f1761a199 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Thu, 26 Jun 2025 17:12:31 +0200 Subject: refactor(sasl): move all auth-related types from Stream to Sasl --- lib/sasl.ml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/sasl.ml') diff --git a/lib/sasl.ml b/lib/sasl.ml index 4bd80cc..137d84a 100644 --- a/lib/sasl.ml +++ b/lib/sasl.ml @@ -1,5 +1,8 @@ open Lwt.Infix -open Stream + +type auth_mechanism = + | PLAIN + | Unknown of string [@@deriving show { with_path = false }] type auth_config = { jid : string; @@ -15,6 +18,10 @@ let unrecoverable = function | NotAuthorized -> true | _ -> false +let parse_auth_mechanism = function + | "PLAIN" -> PLAIN + | other -> Unknown other + let parse_sasl_error = function | "not-authorized" -> NotAuthorized | "malformed-request" -> MalformedRequest @@ -58,7 +65,7 @@ let send_auth_stanza (stream, push) localpart pass mechanism = let authenticate (portal : Portal.t) ({jid; password; preferred_mechanisms} : auth_config) - (sasl_mechanisms : Stream.auth_mechanism list) = + (sasl_mechanisms : auth_mechanism list) = (* Probably not exactly compliant with https://xmpp.org/extensions/xep-0029.html, but it's just for simplicity's sake in alpha. *) let localpart = match String.split_on_char '@' jid with -- cgit v1.2.3