forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxep0335.ts
66 lines (60 loc) · 1.69 KB
/
xep0335.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ====================================================================
// XEP-0335: JSON Containers
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0335.html
// Version: 0.1 (2013-10-25)
//
// --------------------------------------------------------------------
// XEP-0432: Simple JSON Messaging
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0432.html
// Version: 0.1.0 (2020-02-25)
// ====================================================================
import {
childJSON,
DefinitionOptions,
extendMessage,
pubsubItemContentAliases,
textJSON,
attribute
} from '../jxt';
import { NS_JSON_0, NS_JSON_MESSAGE_0 } from '../Namespaces';
import { PubsubItemContent } from './';
declare module './' {
export interface Message {
json?: any;
jsonPayloads?: JSONTransfer[];
}
}
export interface JSONTransfer {
type: string;
data?: any;
}
export interface JSONItem extends PubsubItemContent {
itemType: typeof NS_JSON_0;
json?: any;
}
const Protocol: DefinitionOptions[] = [
extendMessage({
json: childJSON(NS_JSON_0, 'json')
}),
{
aliases: pubsubItemContentAliases(),
element: 'json',
fields: {
json: textJSON()
},
namespace: NS_JSON_0,
type: NS_JSON_0
},
{
aliases: [{ path: 'message.jsonPayloads', multiple: true }],
element: 'payload',
fields: {
type: attribute('datatype'),
data: childJSON(NS_JSON_0, 'json')
},
namespace: NS_JSON_MESSAGE_0
}
];
export default Protocol;