From 519cca49042948b01b63ba2a6eb5392de11d69bd Mon Sep 17 00:00:00 2001 From: Clombrong Date: Mon, 30 Jun 2025 20:09:13 +0200 Subject: feat(sasl): use Jid.t as the jid type --- lib/sasl.ml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3