diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-30 20:09:13 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-07-26 21:55:11 +0200 |
commit | 519cca49042948b01b63ba2a6eb5392de11d69bd (patch) | |
tree | 55a53ca88bfaecbc584f6886a91e9886c0ff2313 /lib/sasl.ml | |
parent | 6157a418a779bbb8c862332e6cae3f03d45a7665 (diff) |
feat(sasl): use Jid.t as the jid type
Diffstat (limited to 'lib/sasl.ml')
-rw-r--r-- | lib/sasl.ml | 10 |
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 |