0
votes

I'm using node-xmpp-component to build an external-xmpp-component, and I need to pull all archived messages for any given jid.

I'm able to connect and send messages, but I can't figure how to build the sanza for requesting archived messages.

Note: This is question is not about how to get archived messages,it about how to get them from an external XMPP component.

1

1 Answers

0
votes

To get message archive, you need to query it from the user account requesting the archive. As you see in XEP example (Querying an archive), there is no place to define which user you are acting as. It is supposed to be the user sending the XMPP packet:

<iq type='set' id='juliet1'>
  <query xmlns='urn:xmpp:mam:0' queryid='f27' />
</iq>

However, node-xmpp-component implements XEP-0114: Jabber Component Protocol. The Component Protocol says basically, you can only act as the component or any usernames from that component domain:

Once authenticated, the component can send stanzas through the server and receive stanzas from the server. All stanzas sent to the server MUST possess a 'from' attribute and a 'to' attribute, as in the 'jabber:server' namespace. The domain identifier portion of the JID contained in the 'from' attribute MUST match the hostname of the component. However, this is the only restriction on 'from' addresses, and the component MAY send stanzas from any user at its hostname.

It means that for privacy / security reasons, a "Jabber Component" cannot send packet on behalf of the main server user.

So, you cannot forge the IQ packet needed to query the MAM archive as a user from a component, the reason being privacy.

You need to find another design for the feature you want to implement.