aboutsummaryrefslogtreecommitdiff
path: root/lib/sasl.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sasl.ml')
-rw-r--r--lib/sasl.ml10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/sasl.ml b/lib/sasl.ml
index 3cd1220..a7f30d9 100644
--- a/lib/sasl.ml
+++ b/lib/sasl.ml
@@ -5,7 +5,7 @@ type mechanism =
| Unknown of string [@@deriving show { with_path = false }]
type config = {
- jid : string;
+ jid : Jid.t;
password : string;
preferred_mechanisms : mechanism list;
}
@@ -66,11 +66,9 @@ let authenticate
(portal : Portal.t)
({jid; password; preferred_mechanisms} : config)
(sasl_mechanisms : 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
- | [localpart; _domain] -> localpart
- | _ -> failwith "Invalid JID"
+ let localpart = match jid.localpart with
+ | Some l -> l
+ | None -> failwith "Invalid JID: No localpart"
and preferred, not_preferred =
List.partition (fun f -> List.exists ((=) f) preferred_mechanisms) sasl_mechanisms
in