forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xep0077.ts
89 lines (83 loc) · 2.61 KB
/
xep0077.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
// ====================================================================
// XEP-0077: In-Band Registration
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0077.html
// Version: 2.4 (2012-01-253)
// ====================================================================
import {
addAlias,
childBoolean,
childDate,
childText,
DefinitionOptions,
extendStreamFeatures
} from '../jxt';
import { NS_DATAFORM, NS_INBAND_REGISTRATION, NS_OOB, NS_REGISTER } from '../Namespaces';
import { DataForm, Link } from './';
declare module './' {
export interface StreamFeatures {
inbandRegistration?: boolean;
}
export interface IQPayload {
account?: AccountManagement;
}
}
export interface AccountManagement {
registered?: boolean;
instructions?: string;
username?: string;
nick?: string;
password?: string;
fullName?: string;
givenName?: string;
familyName?: string;
email?: string;
address?: string;
locality?: string;
region?: string;
postalCode?: string;
phone?: string;
uri?: string;
date?: Date;
misc?: string;
text?: string;
key?: string;
remove?: boolean;
form?: DataForm;
registrationLink?: Link;
}
const Protocol: DefinitionOptions[] = [
extendStreamFeatures({
inbandRegistration: childBoolean(NS_INBAND_REGISTRATION, 'register')
}),
addAlias(NS_DATAFORM, 'x', ['iq.account.form']),
addAlias(NS_OOB, 'x', ['iq.account.registrationLink']),
{
element: 'query',
fields: {
address: childText(null, 'address'),
date: childDate(null, 'date'),
email: childText(null, 'email'),
familyName: childText(null, 'last'),
fullName: childText(null, 'name'),
givenName: childText(null, 'first'),
instructions: childText(null, 'instructions'),
key: childText(null, 'key'),
locality: childText(null, 'city'),
misc: childText(null, 'misc'),
nick: childText(null, 'nick'),
password: childText(null, 'password'),
phone: childText(null, 'phone'),
postalCode: childText(null, 'zip'),
region: childText(null, 'state'),
registered: childBoolean(null, 'registered'),
remove: childBoolean(null, 'remove'),
text: childText(null, 'text'),
uri: childText(null, 'uri'),
username: childText(null, 'username')
},
namespace: NS_REGISTER,
path: 'iq.account'
}
];
export default Protocol;