forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxep0138.ts
76 lines (67 loc) · 1.98 KB
/
xep0138.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
// ====================================================================
// XEP-0138: Stream Compression
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0138.html
// Version: 2.0 (2009-05-27)
// ====================================================================
import { childEnum, childText, DefinitionOptions, multipleChildText } from '../jxt';
import { NS_COMPRESSION, NS_COMPRESSION_FEATURE } from '../Namespaces';
declare module './' {
export interface StreamFeatures {
compression?: CompressionFeature;
}
}
export interface CompressionFeature {
methods: string[];
}
export interface CompressionStart {
type: 'start';
method: string;
}
export interface CompressionFailure {
type: 'failure';
condition: 'unsupported-method' | 'setup-failed' | 'processing-failed';
}
export interface CompressionSuccess {
type: 'success';
}
export type Compression = CompressionStart | CompressionFailure | CompressionSuccess;
const Protocol: DefinitionOptions[] = [
{
element: 'compression',
fields: {
methods: multipleChildText(null, 'method')
},
namespace: NS_COMPRESSION_FEATURE,
path: 'features.compression'
},
{
element: 'compress',
fields: {
method: childText(null, 'method')
},
namespace: NS_COMPRESSION,
path: 'compression',
type: 'start',
typeField: 'type'
},
{
aliases: ['error.compressionError'],
element: 'failure',
fields: {
condition: childEnum(null, ['unsupported-method', 'setup-failed', 'processing-failed'])
},
namespace: NS_COMPRESSION,
path: 'compression',
type: 'failure',
typeField: 'type'
},
{
element: 'compressed',
namespace: NS_COMPRESSION,
path: 'compression',
type: 'success',
typeField: 'type'
}
];
export default Protocol;