diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 17:28:38 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-27 08:56:27 +0200 |
commit | 7e83c196ca21aef56c42fd122f0d65cfa4becd6c (patch) | |
tree | c0defbf534c12b6cbaffe6a8b8aae27194df5bb1 /lib | |
parent | 30f002289ef6f5dd544f25bc4965fa8f1761a199 (diff) |
feat(sasl): add negotiate function
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stream.ml | 16 |
1 files changed, 16 insertions, 0 deletions
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 |