aboutsummaryrefslogtreecommitdiff
path: root/lib/sasl.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sasl.ml')
-rw-r--r--lib/sasl.ml11
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