diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 17:12:31 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-26 21:40:53 +0200 |
commit | 30f002289ef6f5dd544f25bc4965fa8f1761a199 (patch) | |
tree | 519e1b3c60715de82d1f95c6b136476c3dbc8a2b /lib/sasl.ml | |
parent | 38b332a6c3940c3156b27b88e15e9735bebce718 (diff) |
refactor(sasl): move all auth-related types from Stream to Sasl
Diffstat (limited to 'lib/sasl.ml')
-rw-r--r-- | lib/sasl.ml | 11 |
1 files changed, 9 insertions, 2 deletions
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 |