xmpp/receipts d---------
all: add strict namespace checking to mux

Previously anything that had a local name that looked like a stanza
("message", "iq", or "presence") would be treated as such, opening us up
to potential vulnerabilities in servers that allow a
{jabber:server}message on a jabber:client stream but don't treat it as a
stanza, for example.
Being more strict about checking namespaces helps to avoid this issue,
but does require a breaking change to the mux API.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: remove s2s bool from stream send

Previously we set the namespace depending on whether a server-to-server
value was set. However, the namespace is set in the stream and may be
other values (such as the Jabber Component namespace) as well, so just
leave this alone and let the negotiator handle it.

Signed-off-by: Sam Whited <sam@samwhited.com>
all: generate disco features

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: add a callback for unhandled receipts

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: remove unused variable

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: fix build with new version of xmlstream

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: always set namespace on stanzas

Attempt to guess at stanzas and set a namespace on them if unset. This
guarantees that the other side actually sees them as stanzas and the
user doesn't have to know what type of session we have and remember to
set a namespace every single time they send anything.

This won't change anything for the normal TCP binding (where there was a
default namespace and the empty namespace would just use that), but for
future bindings like WebSockets where there isn't a default namespace
this will make sure IQs still get the xmlns attribute written.

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: don't request receipt for receipt

Per the spec we should not request a receipt on a receipt itself to
prevent loops. This behavior existed in the handler, but not in the
generic Transformer.

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: add struct and stream APIs

Previously we had to block waiting on response if we wanted to request
read receipts. However, this is more likely to be used asynchronously
where we associate the receipt with the original message using the ID.
To faciliate this, one type and one function was added: one for the
struct based API and one for the stream based API.

Fixes #89

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts, form_test: typo fixes

Signed-off-by: Sam Whited <sam@samwhited.com>
all: use xmlstream.Iter and remove internal/iter

The internal/iter package previously contained an API for iterating over
child elements and decoding them lazily.

This is needed by any package that exposes an iterator such as the
roster package, and is mentioned in the documentation
(https://mellium.im/docs/extensions) as the API to use when creating
your own extensions, but it was internal and not actually usable by this
package. Its own doc comment said that it would eventually be exported
when the API stabalized. It hasn't been necessary to change the API
since creating it so it became time to let it graduate to the
mellium.im/xmlstream module where it can be more broadly useful.

This patch bumps the version of xmlstream used and makes the minor
changes necessary to use the xmlstream version of the iterator. It also
removes the old internal/iter package and updates the documentation to
mention its new location as part of xmlstream.

They grow up so fast!

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: fix broken doc comment

Fix some copy/pasta from the xtime package that had leaked into

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: limit the amount of locking required

Limiting the amount of output stream locking required to just the actual
sending of the element means we don't have to block the entire output
stream while we wait for a response, which will likely lead to deadlock.

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: fix resource leak

Previously messages weren't removed from being tracked by the handler
after they were acked or after the context was canceled. This patch
makes sure they are removed, and adds a regression test to double check
that they're removed on context cancelation.

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: new Message Delivery Receipts package

This patch imlements XEP-0184: Message Delivery Receipts

Signed-off-by: Sam Whited <sam@samwhited.com>