From 7e83c196ca21aef56c42fd122f0d65cfa4becd6c Mon Sep 17 00:00:00 2001 From: Clombrong Date: Thu, 26 Jun 2025 17:28:38 +0200 Subject: feat(sasl): add negotiate function --- lib/stream.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/stream.ml b/lib/stream.ml index e3ed62f..ff3b939 100644 --- a/lib/stream.ml +++ b/lib/stream.ml @@ -1,3 +1,6 @@ +open Lwt.Syntax +open Lwt.Infix + exception ClosedStream type features = { @@ -31,3 +34,16 @@ let parse_features (el : Xml.element) : features = parse_feature {mechanisms=[]; starttls=`None; unknown=[]} (List.filter_map find_left el.children) + +(** [negotiate domain stream] is a promise containing the features supported by the + XMPP server communicating with [stream]. + + This function should be called every time a stream needs to be reopened and stream + negotiation takes place. + + Basically, it conforms to + {{: https://datatracker.ietf.org/doc/html/rfc6120#section-4.3 }}. *) +let negotiate (domain : string) ((stream, push) : Portal.t) : features Lwt.t = + let* _id = Portal.header domain (stream, push) + in let+ features = Xml.get stream >|= parse_features + in features -- cgit v1.2.3