forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xep0166.ts
125 lines (114 loc) · 2.97 KB
/
xep0166.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ====================================================================
// XEP-0166: Jingle
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0166.html
// Version: 1.1.1 (2016-05-17)
//
// Additional:
// - Added unknown-content error
// ====================================================================
import {
JingleAction,
JingleContentSenders,
JingleErrorCondition,
JingleReasonCondition,
JingleSessionRole
} from '../Constants';
import { JID } from '../JID';
import {
attribute,
childEnum,
childText,
DefinitionOptions,
extendStanzaError,
JIDAttribute
} from '../jxt';
import { NS_JINGLE_1, NS_JINGLE_ERRORS_1 } from '../Namespaces';
declare module './' {
export interface IQPayload {
jingle?: Jingle;
}
export interface StanzaError {
jingleError?: JingleErrorCondition;
}
}
export interface Jingle {
action?: JingleAction;
initiator?: JID;
responder?: JID;
sid: string;
contents?: JingleContent[];
reason?: JingleReason;
info?: JingleInfo;
}
export interface JingleContent {
creator: JingleSessionRole;
name: string;
disposition?: string;
senders?: JingleContentSenders;
application?: JingleApplication;
transport?: JingleTransport;
security?: JingleSecurity;
}
export interface JingleReason {
condition: JingleReasonCondition;
alternativeSession?: string;
text?: string;
}
export interface JingleApplication {
applicationType: string;
}
export interface JingleTransport {
transportType: string;
}
export interface JingleSecurity {
securityType: string;
}
export interface JingleInfo {
infoType: string;
creator?: JingleSessionRole;
name?: string;
}
const Protocol: DefinitionOptions[] = [
extendStanzaError({
jingleError: childEnum(NS_JINGLE_ERRORS_1, Object.values(JingleErrorCondition))
}),
{
element: 'jingle',
fields: {
action: attribute('action'),
initiator: JIDAttribute('initiator'),
responder: JIDAttribute('responder'),
sid: attribute('sid')
},
namespace: NS_JINGLE_1,
path: 'iq.jingle'
},
{
aliases: [
{
multiple: true,
path: 'iq.jingle.contents'
}
],
element: 'content',
fields: {
creator: attribute('creator'),
disposition: attribute('disposition', 'session'),
name: attribute('name'),
senders: attribute('senders', 'both')
},
namespace: NS_JINGLE_1
},
{
element: 'reason',
fields: {
alternativeSession: childText(null, 'alternative-session'),
condition: childEnum(null, Object.values(JingleReasonCondition)),
text: childText(null, 'text')
},
namespace: NS_JINGLE_1,
path: 'iq.jingle.reason'
}
];
export default Protocol;