@sockethub/platform-xmpp 5.0.0-alpha.4 → 5.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +146 -97
- package/README.md +75 -18
- package/package.json +15 -20
- package/src/incoming-handlers.js +298 -263
- package/src/incoming-handlers.test.data.js +260 -0
- package/src/incoming-handlers.test.js +87 -29
- package/src/index.js +696 -454
- package/src/index.test.js +477 -319
- package/src/schema.js +60 -48
- package/src/utils.js +21 -18
- package/src/utils.test.js +53 -33
- package/.eslintignore +0 -2
- package/coverage/tmp/coverage-39286-1663949499396-0.json +0 -1
- package/src/incoming-handlers.data.js +0 -198
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
module.exports = [
|
|
2
|
-
[
|
|
3
|
-
`presence error 1`,
|
|
4
|
-
`<presence type="error" to="hermes@5apps.com/hyperchannel" from="xmpp.5apps.com/#watercooler" xmlns:stream="http://etherx.jabber.org/streams"><error type="cancel"> <remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></presence>`,
|
|
5
|
-
{context: 'xmpp', type: 'join', actor: {id: 'xmpp.5apps.com/#watercooler', 'type': 'room'},
|
|
6
|
-
error: 'remote server not found xmpp.5apps.com/#watercooler',
|
|
7
|
-
target: {id: 'hermes@5apps.com/hyperchannel', type: 'person'}}
|
|
8
|
-
],
|
|
9
|
-
[
|
|
10
|
-
`presence error 2`,
|
|
11
|
-
`<presence type="error" to="hermes@5apps.com/hyperchannel" from="xmpp.5apps.com/#watercooler" xmlns:stream="http://etherx.jabber.org/streams"><error type="cancel"><not-allowed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Communication with remote domains is not enabled</text></error></presence>`,
|
|
12
|
-
{context: 'xmpp', type: 'update', actor: {id: 'xmpp.5apps.com/#watercooler', 'type': 'room'},
|
|
13
|
-
error: '<error type="cancel"><not-allowed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>' +
|
|
14
|
-
'<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Communication with remote domains is not enabled</text>' +
|
|
15
|
-
'</error>',
|
|
16
|
-
target: {id: 'hermes@5apps.com/hyperchannel', type: 'person'}}
|
|
17
|
-
],
|
|
18
|
-
[
|
|
19
|
-
`initial presence`,
|
|
20
|
-
`<presence to="foo@bar.org" from="baz@bag.org"></presence>`,
|
|
21
|
-
{context: 'xmpp', type: 'update', actor: { id: "baz@bag.org", type: "person" },
|
|
22
|
-
target: { id: "foo@bar.org", type: 'person' }, object: {type: 'presence', presence: "online"}}
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
`presence body`,
|
|
26
|
-
`<presence to="foo@bar.org" from="baz@bag.org"><show>online</show> <status>away message!</status></presence>`,
|
|
27
|
-
{context: 'xmpp', type: 'update', actor: { id: "baz@bag.org", type: "person" },
|
|
28
|
-
target: { id: "foo@bar.org", type: 'person' }, object: {type: 'presence', content: "away message!",
|
|
29
|
-
presence: "online"}}
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
`presence unavailable`,
|
|
33
|
-
`<presence to="foo@bar.org/hyperchannel" from="baz@bag.org/yarg" type="unavailable"><x xmlns="http://jabber.org/protocol/muc#user"><item affiliation="owner" role="none"></item></x></presence>`,
|
|
34
|
-
{ context: 'xmpp', type: "update", actor: { type: "person", id: "baz@bag.org/yarg" },
|
|
35
|
-
target: { id: "foo@bar.org/hyperchannel", type: 'person' },
|
|
36
|
-
object: { type: "presence", presence: "offline" },
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
`presence away`,
|
|
41
|
-
`<presence to="foo@bar.org/hyperchannel" from="baz@bag.org/yarg" type="available"><show>away</show><x xmlns="http://jabber.org/protocol/muc#user"><item affiliation="owner" role="none"></item></x></presence>`,
|
|
42
|
-
{ context: 'xmpp', type: "update", actor: { type: "person", id: "baz@bag.org/yarg" },
|
|
43
|
-
target: { id: "foo@bar.org/hyperchannel", type: 'person' },
|
|
44
|
-
object: { type: "presence", presence: "away" },
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
[
|
|
48
|
-
'attendance',
|
|
49
|
-
`<iq id="muc_id" type="result" to="ernie@jabber.net/Home" from="PartyChatRoom@jabber.net" xmlns:stream="http://etherx.jabber.org/streams"> <query xmlns="http://jabber.org/protocol/disco#items"> <item jid="PartyChatRoom@jabber.net/ernie" name="ernie"/> <item jid="PartyChatRoom@jabber.net/bert" name="bert"/><item jid="PartyChatRoom@jabber.net/oscar" name="oscar"/> <item jid="PartyChatRoom@jabber.net/big_bird" name="big_bird"/> <item jid="PartyChatRoom@jabber.net/elmo" name="elmo"/></query></iq>`,
|
|
50
|
-
{context: 'xmpp', type: 'query', actor: {id: 'PartyChatRoom@jabber.net', 'type': 'room'},
|
|
51
|
-
target: {id: 'ernie@jabber.net/Home', type: 'person'}, object: {'type': 'attendance',
|
|
52
|
-
members: ['ernie', 'bert', 'oscar', 'big_bird', 'elmo']}}
|
|
53
|
-
],
|
|
54
|
-
[
|
|
55
|
-
'message',
|
|
56
|
-
`<message from="radical@example.org/thinkpad" to="user@jabber.org" type="chat" id="purple9840c15f" xmlns:stream="http://etherx.jabber.org/streams">
|
|
57
|
-
<active xmlns="http://jabber.org/protocol/chatstates" />
|
|
58
|
-
<stanza-id xmlns="urn:xmpp:sid:0" id="123456789" />
|
|
59
|
-
<body>ohai</body>
|
|
60
|
-
</message>`,
|
|
61
|
-
{
|
|
62
|
-
context: 'xmpp',
|
|
63
|
-
type: 'send',
|
|
64
|
-
actor: { type: 'person', id: 'radical@example.org/thinkpad' },
|
|
65
|
-
target: { type: 'person', id: 'user@jabber.org' },
|
|
66
|
-
object: { type: 'message', content: 'ohai',
|
|
67
|
-
id: 'purple9840c15f', 'xmpp:stanza-id': '123456789' }
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
'message with delay (e.g. offline message)',
|
|
72
|
-
`<message from="radical@example.org/thinkpad" to="user@jabber.org" type="chat" id="purple9840c15f" xmlns:stream="http://etherx.jabber.org/streams">
|
|
73
|
-
<active xmlns="http://jabber.org/protocol/chatstates" />
|
|
74
|
-
<stanza-id xmlns="urn:xmpp:sid:0" id="123456789" />
|
|
75
|
-
<delay xmlns="urn:xmpp:delay" from="jabber.org" stamp="2021-04-17T18:50:25Z">Offline Storage</delay>
|
|
76
|
-
<body>ohai</body>
|
|
77
|
-
</message>`,
|
|
78
|
-
{
|
|
79
|
-
context: 'xmpp',
|
|
80
|
-
type: 'send',
|
|
81
|
-
published: '2021-04-17T18:50:25.000Z',
|
|
82
|
-
actor: { type: 'person', id: 'radical@example.org/thinkpad' },
|
|
83
|
-
target: { type: 'person', id: 'user@jabber.org' },
|
|
84
|
-
object: {
|
|
85
|
-
type: 'message',
|
|
86
|
-
content: 'ohai',
|
|
87
|
-
id: 'purple9840c15f',
|
|
88
|
-
'xmpp:stanza-id': '123456789'
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
'message correction (XEP-0308)',
|
|
94
|
-
`<message from="radical@example.org/thinkpad" to="user@jabber.org" type="chat" id="purple9840c15f" xmlns:stream="http://etherx.jabber.org/streams">
|
|
95
|
-
<active xmlns="http://jabber.org/protocol/chatstates" />
|
|
96
|
-
<stanza-id xmlns="urn:xmpp:sid:0" id="123456789" />
|
|
97
|
-
<replace id="purple1234c15f" />
|
|
98
|
-
<body>oh hey</body>
|
|
99
|
-
</message>`,
|
|
100
|
-
{
|
|
101
|
-
context: 'xmpp',
|
|
102
|
-
type: 'send',
|
|
103
|
-
actor: { type: 'person', id: 'radical@example.org/thinkpad' },
|
|
104
|
-
target: { type: 'person', id: 'user@jabber.org' },
|
|
105
|
-
object: { type: 'message', content: 'oh hey',
|
|
106
|
-
id: 'purple9840c15f', 'xmpp:stanza-id': '123456789',
|
|
107
|
-
'xmpp:replace': { id: 'purple1234c15f' } }
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
'group presence',
|
|
112
|
-
`<presence from='room@xmpp.example.org/speedboat'><show>chat</show> <status>brrroom!</status></presence>`,
|
|
113
|
-
{context: 'xmpp', type: 'update', actor: {id: 'room@xmpp.example.org/speedboat', 'type': 'person',
|
|
114
|
-
name: 'speedboat'}, object: {type: 'presence', content: 'brrroom!',
|
|
115
|
-
presence: 'chat' }}
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
'group message',
|
|
119
|
-
`<message from='coven@chat.shakespeare.lit/thirdwitch' id='hysf1v37' to='crone1@shakespeare.lit/desktop' type='groupchat'>
|
|
120
|
-
<stanza-id id="123456789" />
|
|
121
|
-
<body>Thrice the brinded cat hath mew'd.</body>
|
|
122
|
-
</message>`,
|
|
123
|
-
{
|
|
124
|
-
context: 'xmpp',
|
|
125
|
-
type: 'send',
|
|
126
|
-
actor: { type: 'person', id: 'coven@chat.shakespeare.lit/thirdwitch', name: 'thirdwitch' },
|
|
127
|
-
target: { type: 'room', id: 'coven@chat.shakespeare.lit' },
|
|
128
|
-
object: { id: 'hysf1v37', type: 'message', content: 'Thrice the brinded cat hath mew\'d.',
|
|
129
|
-
'xmpp:stanza-id': '123456789'}
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
// [
|
|
133
|
-
// 'subscribe',
|
|
134
|
-
// `<presence from=’user1@example.com’ to=’user2@example.com’ type=’subscribe’></presence>`,
|
|
135
|
-
// {}
|
|
136
|
-
// ],
|
|
137
|
-
// [
|
|
138
|
-
// 'subscribed',
|
|
139
|
-
// `<presence from=’user2@example.com’ to=’user1@example.com’ type=’subscribed’></presence>`,
|
|
140
|
-
// {}
|
|
141
|
-
// ],
|
|
142
|
-
// [
|
|
143
|
-
// 'status',
|
|
144
|
-
// `<presence><show>away</show><status>feeding the chickens</status></presence>`,
|
|
145
|
-
// {}
|
|
146
|
-
// ],
|
|
147
|
-
// [
|
|
148
|
-
// 'request roster',
|
|
149
|
-
// `<iq from=’abc@example.com’ type=’get’ id=’xyz123’>
|
|
150
|
-
// <query xmlns=’jabber:iq:roster’/> </iq>`,
|
|
151
|
-
// {}
|
|
152
|
-
// ],
|
|
153
|
-
// [
|
|
154
|
-
// 'present roster',
|
|
155
|
-
// `<iq to=’abc@example.com’ type=’result’ id=’xyz123’> <query xmlns=’jabber:iq:roster’>
|
|
156
|
-
// <item jid=’efg@example.com’ name=’EFG’/> <item jid=’hij’@ example.com’ name=’HIJ’/>
|
|
157
|
-
// </query> </iq>`,
|
|
158
|
-
// {}
|
|
159
|
-
// ],
|
|
160
|
-
// [
|
|
161
|
-
// 'join room',
|
|
162
|
-
// `<presence from='hav66@shakespeare.lit/pda' id='n13mt3l'
|
|
163
|
-
// to='coven@chat.shakespeare.lit/thirdwitch'>
|
|
164
|
-
// <x xmlns='http://jabber.org/protocol/muc'/> </presence>`,
|
|
165
|
-
// {}
|
|
166
|
-
// ],
|
|
167
|
-
[
|
|
168
|
-
'JID malformed',
|
|
169
|
-
`<presence from='coven@chat.shakespeare.lit' id='273hs51g' to='hag66@shakespeare.lit/pda' type='error'> <error by='coven@chat.shakespeare.lit' type='modify'> <jid-malformed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </presence>`,
|
|
170
|
-
{context: 'xmpp', type: "update", actor: {id: "coven@chat.shakespeare.lit", type: "room"},
|
|
171
|
-
error: `<error by="coven@chat.shakespeare.lit" type="modify"> <jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> </error>`,
|
|
172
|
-
target: {id: "hag66@shakespeare.lit/pda", type: "person"} },
|
|
173
|
-
]
|
|
174
|
-
// [
|
|
175
|
-
// 'presence affiliation owner',
|
|
176
|
-
// `<presence from='coven@chat.shakespeare.lit/firstwitch'
|
|
177
|
-
// id='3DCB0401-D7CF-4E31-BE05-EDF8D057BFBD' to='hag66@shakespeare.lit/pda'>
|
|
178
|
-
// <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='owner'
|
|
179
|
-
// role='moderator'/> </x> </presence>`,
|
|
180
|
-
// {}
|
|
181
|
-
// ],
|
|
182
|
-
// [
|
|
183
|
-
// 'presence affiliation member',
|
|
184
|
-
// `<presence from='coven@chat.shakespeare.lit/thirdwitch'
|
|
185
|
-
// id='27C55F89-1C6A-459A-9EB5-77690145D624' to='crone1@shakespeare.lit/desktop'>
|
|
186
|
-
// <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='member'
|
|
187
|
-
// role='participant'/> </x> </presence>`,
|
|
188
|
-
// {}
|
|
189
|
-
// ],
|
|
190
|
-
// [
|
|
191
|
-
// 'presence affiliation none',
|
|
192
|
-
// `<presence from='coven@chat.shakespeare.lit/thirdwitch'
|
|
193
|
-
// id='17232D15-134F-43C8-9A29-61C20A64B236' to='crone1@shakespeare.lit/desktop'>
|
|
194
|
-
// <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='none'
|
|
195
|
-
// jid='hag66@shakespeare.lit/pda' role='participant'/> </x> </presence>`,
|
|
196
|
-
// {}
|
|
197
|
-
// ]
|
|
198
|
-
];
|