quickblox 2.14.0 → 2.15.0
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/README.md +1 -1
- package/package.json +1 -1
- package/quickblox.js +20704 -20873
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChat.js +107 -46
- package/src/modules/webrtc/qbRTCPeerConnection.js +446 -306
- package/src/modules/webrtc/qbWebRTCClient.js +43 -21
- package/src/modules/webrtc/qbWebRTCHelpers.js +60 -36
- package/src/modules/webrtc/qbWebRTCSession.js +640 -408
- package/src/modules/webrtc/qbWebRTCSignalingProcessor.js +57 -52
- package/src/modules/webrtc/qbWebRTCSignalingProvider.js +24 -20
- package/src/qbConfig.js +15 -16
- package/src/qbMain.js +27 -17
- package/src/qbProxy.js +0 -3
- package/src/qbUtils.js +1 -0
|
@@ -9,12 +9,11 @@ require('strophe.js');
|
|
|
9
9
|
|
|
10
10
|
var SignalingConstants = require('./qbWebRTCSignalingConstants');
|
|
11
11
|
|
|
12
|
-
function WebRTCSignalingProcessor(service, delegate
|
|
12
|
+
function WebRTCSignalingProcessor(service, delegate) {
|
|
13
13
|
var self = this;
|
|
14
14
|
|
|
15
15
|
self.service = service;
|
|
16
16
|
self.delegate = delegate;
|
|
17
|
-
self.connection = connection;
|
|
18
17
|
|
|
19
18
|
this._onMessage = function(from, extraParams, delay, userId) {
|
|
20
19
|
|
|
@@ -66,84 +65,90 @@ function WebRTCSignalingProcessor(service, delegate, connection) {
|
|
|
66
65
|
}
|
|
67
66
|
};
|
|
68
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Convert XML into JS object
|
|
70
|
+
* @param {Element} extraParams
|
|
71
|
+
* @returns {Object}
|
|
72
|
+
*/
|
|
69
73
|
this._getExtension = function(extraParams) {
|
|
70
74
|
if (!extraParams) {
|
|
71
|
-
return
|
|
75
|
+
return {};
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
var extension = {},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for (var i = 0, len = extraParams.childNodes.length; i < len; i++) {
|
|
78
|
-
if (extraParams.childNodes[i].tagName === 'iceCandidates') {
|
|
78
|
+
var extension = {},
|
|
79
|
+
iceCandidates = [],
|
|
80
|
+
opponents = [];
|
|
79
81
|
|
|
82
|
+
extraParams.childNodes.forEach(function (childNode) {
|
|
83
|
+
if (childNode.nodeName === 'iceCandidates') {
|
|
80
84
|
/** iceCandidates */
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
for (var k = 0, len3 = childrenNodes.length; k < len3; k++) {
|
|
88
|
-
candidate[childrenNodes[k].tagName] = childrenNodes[k].textContent;
|
|
89
|
-
}
|
|
90
|
-
|
|
85
|
+
childNode.childNodes.forEach(function (candidateNode) {
|
|
86
|
+
var candidate = {};
|
|
87
|
+
candidateNode.childNodes.forEach(function (node) {
|
|
88
|
+
candidate[node.nodeName] = node.textContent;
|
|
89
|
+
});
|
|
91
90
|
iceCandidates.push(candidate);
|
|
92
|
-
}
|
|
91
|
+
});
|
|
93
92
|
|
|
94
|
-
} else if (
|
|
93
|
+
} else if (childNode.nodeName === 'opponentsIDs') {
|
|
95
94
|
/** opponentsIDs */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
opponents.push(parseInt(opponent));
|
|
101
|
-
}
|
|
95
|
+
childNode.childNodes.forEach(function (opponentNode) {
|
|
96
|
+
var opponentId = opponentNode.textContent;
|
|
97
|
+
opponents.push(parseInt(opponentId));
|
|
98
|
+
});
|
|
102
99
|
} else {
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
for (var t=0; t<extraParams.childNodes[i].childNodes.length; ++t) {
|
|
110
|
-
wholeNodeContent += extraParams.childNodes[i].childNodes[t].textContent;
|
|
111
|
-
}
|
|
112
|
-
extension[extraParams.childNodes[i].tagName] = wholeNodeContent;
|
|
113
|
-
} else {
|
|
114
|
-
extension = self._XMLtoJS(extension, extraParams.childNodes[i].tagName, extraParams.childNodes[i]);
|
|
115
|
-
}
|
|
100
|
+
if (childNode.childNodes.length > 1) {
|
|
101
|
+
extension = self._XMLtoJS(
|
|
102
|
+
extension,
|
|
103
|
+
childNode.nodeName,
|
|
104
|
+
childNode
|
|
105
|
+
);
|
|
116
106
|
} else {
|
|
117
|
-
if (
|
|
118
|
-
extension = self._XMLtoJS(
|
|
107
|
+
if (childNode.nodeName === 'userInfo') {
|
|
108
|
+
extension = self._XMLtoJS(
|
|
109
|
+
extension,
|
|
110
|
+
childNode.nodeName,
|
|
111
|
+
childNode
|
|
112
|
+
);
|
|
119
113
|
} else {
|
|
120
|
-
extension[
|
|
114
|
+
extension[childNode.nodeName] = childNode.textContent;
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (iceCandidates.length > 0) {
|
|
126
121
|
extension.iceCandidates = iceCandidates;
|
|
127
122
|
}
|
|
128
|
-
if (opponents.length > 0){
|
|
123
|
+
if (opponents.length > 0) {
|
|
129
124
|
extension.opponentsIDs = opponents;
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
return extension;
|
|
133
128
|
};
|
|
134
129
|
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} extension
|
|
133
|
+
* @param {string} title
|
|
134
|
+
* @param {Element} element
|
|
135
|
+
* @returns {Object}
|
|
136
|
+
*/
|
|
137
|
+
this._XMLtoJS = function(extension, title, element) {
|
|
137
138
|
var self = this;
|
|
138
139
|
extension[title] = {};
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
extension[title] = self._XMLtoJS(
|
|
141
|
+
element.childNodes.forEach(function (childNode) {
|
|
142
|
+
if (childNode.childNodes.length > 1) {
|
|
143
|
+
extension[title] = self._XMLtoJS(
|
|
144
|
+
extension[title],
|
|
145
|
+
childNode.nodeName,
|
|
146
|
+
childNode
|
|
147
|
+
);
|
|
143
148
|
} else {
|
|
144
|
-
extension[title][
|
|
149
|
+
extension[title][childNode.nodeName] = childNode.textContent;
|
|
145
150
|
}
|
|
146
|
-
}
|
|
151
|
+
});
|
|
147
152
|
return extension;
|
|
148
153
|
};
|
|
149
154
|
}
|
|
@@ -15,22 +15,21 @@ var SignalingConstants = require('./qbWebRTCSignalingConstants');
|
|
|
15
15
|
var Utils = require('../../qbUtils');
|
|
16
16
|
var config = require('../../qbConfig');
|
|
17
17
|
|
|
18
|
-
function WebRTCSignalingProvider(service,
|
|
18
|
+
function WebRTCSignalingProvider(service, chat) {
|
|
19
19
|
this.service = service;
|
|
20
|
-
this.
|
|
20
|
+
this.chat = chat;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
WebRTCSignalingProvider.prototype.sendCandidate = function(userId, iceCandidates, ext) {
|
|
23
|
+
WebRTCSignalingProvider.prototype.sendCandidate = function (userId, iceCandidates, ext) {
|
|
24
24
|
var extension = ext || {};
|
|
25
25
|
extension.iceCandidates = iceCandidates;
|
|
26
26
|
|
|
27
27
|
this.sendMessage(userId, extension, SignalingConstants.SignalingType.CANDIDATE);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
WebRTCSignalingProvider.prototype.sendMessage = function(userId, ext, signalingType) {
|
|
30
|
+
WebRTCSignalingProvider.prototype.sendMessage = function (userId, ext, signalingType) {
|
|
31
31
|
var extension = ext || {},
|
|
32
|
-
self = this
|
|
33
|
-
msg, params;
|
|
32
|
+
self = this;
|
|
34
33
|
|
|
35
34
|
/** basic parameters */
|
|
36
35
|
extension.moduleIdentifier = SignalingConstants.MODULE_ID;
|
|
@@ -46,23 +45,23 @@ WebRTCSignalingProvider.prototype.sendMessage = function(userId, ext, signalingT
|
|
|
46
45
|
delete extension.userInfo;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
params = {
|
|
48
|
+
var params = {
|
|
50
49
|
to: Helpers.getUserJid(userId, config.creds.appId),
|
|
51
50
|
type: 'headline',
|
|
52
51
|
id: Utils.getBsonObjectId()
|
|
53
52
|
};
|
|
54
53
|
|
|
55
|
-
msg = $msg(params).c('extraParams', {
|
|
54
|
+
var msg = $msg(params).c('extraParams', {
|
|
56
55
|
xmlns: Strophe.NS.CLIENT
|
|
57
56
|
});
|
|
58
57
|
|
|
59
|
-
Object.keys(extension).forEach(function(field) {
|
|
58
|
+
Object.keys(extension).forEach(function (field) {
|
|
60
59
|
if (field === 'iceCandidates') {
|
|
61
60
|
/** iceCandidates */
|
|
62
|
-
msg
|
|
63
|
-
extension[field].forEach(function(candidate) {
|
|
64
|
-
msg
|
|
65
|
-
Object.keys(candidate).forEach(function(key) {
|
|
61
|
+
msg.c('iceCandidates');
|
|
62
|
+
extension[field].forEach(function (candidate) {
|
|
63
|
+
msg.c('iceCandidate');
|
|
64
|
+
Object.keys(candidate).forEach(function (key) {
|
|
66
65
|
msg.c(key).t(candidate[key]).up();
|
|
67
66
|
});
|
|
68
67
|
msg.up();
|
|
@@ -70,9 +69,9 @@ WebRTCSignalingProvider.prototype.sendMessage = function(userId, ext, signalingT
|
|
|
70
69
|
msg.up();
|
|
71
70
|
} else if (field === 'opponentsIDs') {
|
|
72
71
|
/** opponentsIDs */
|
|
73
|
-
msg
|
|
74
|
-
extension[field].forEach(function(opponentId) {
|
|
75
|
-
msg
|
|
72
|
+
msg.c('opponentsIDs');
|
|
73
|
+
extension[field].forEach(function (opponentId) {
|
|
74
|
+
msg.c('opponentID').t(opponentId).up();
|
|
76
75
|
});
|
|
77
76
|
msg.up();
|
|
78
77
|
} else if (typeof extension[field] === 'object') {
|
|
@@ -82,14 +81,19 @@ WebRTCSignalingProvider.prototype.sendMessage = function(userId, ext, signalingT
|
|
|
82
81
|
}
|
|
83
82
|
});
|
|
84
83
|
|
|
85
|
-
this.connection.send(msg);
|
|
84
|
+
this.chat.connection.send(msg);
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
/**
|
|
89
|
-
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @param {string} title
|
|
90
|
+
* @param {Object} obj
|
|
91
|
+
* @param {Strophe.Builder} msg
|
|
92
|
+
*/
|
|
93
|
+
WebRTCSignalingProvider.prototype._JStoXML = function (title, obj, msg) {
|
|
90
94
|
var self = this;
|
|
91
95
|
msg.c(title);
|
|
92
|
-
Object.keys(obj).forEach(function(field) {
|
|
96
|
+
Object.keys(obj).forEach(function (field) {
|
|
93
97
|
if (typeof obj[field] === 'object')
|
|
94
98
|
self._JStoXML(field, obj[field], msg);
|
|
95
99
|
else
|
package/src/qbConfig.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
var config = {
|
|
15
|
-
version: '2.
|
|
16
|
-
buildNumber: '
|
|
15
|
+
version: '2.15.0',
|
|
16
|
+
buildNumber: '1137',
|
|
17
17
|
creds: {
|
|
18
18
|
'appId': 0,
|
|
19
19
|
'authKey': '',
|
|
@@ -21,7 +21,7 @@ var config = {
|
|
|
21
21
|
'accountKey': ''
|
|
22
22
|
},
|
|
23
23
|
endpoints: {
|
|
24
|
-
api: '
|
|
24
|
+
api: 'api.quickblox.com',
|
|
25
25
|
chat: 'chat.quickblox.com',
|
|
26
26
|
muc: 'muc.chat.quickblox.com'
|
|
27
27
|
},
|
|
@@ -73,7 +73,7 @@ var config = {
|
|
|
73
73
|
},
|
|
74
74
|
timeout: null,
|
|
75
75
|
debug: {
|
|
76
|
-
mode:
|
|
76
|
+
mode: 0,
|
|
77
77
|
file: null
|
|
78
78
|
},
|
|
79
79
|
addISOTime: false,
|
|
@@ -108,23 +108,22 @@ config.set = function(options) {
|
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
/*
|
|
112
|
-
* 17.08.22 artan: waiting for backend fix, look at tasks:
|
|
113
|
-
* [CROS-815] - Update sessionExpirationDate on each request
|
|
114
|
-
* [SR-1322] - Set param Access-Control-Expose-Headerson server side
|
|
115
|
-
*/
|
|
116
111
|
config.updateSessionExpirationDate = function (tokenExpirationDate, headerHasToken = false) {
|
|
117
112
|
var connectionTimeLag = 1; // minute
|
|
118
|
-
var newDate
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
var newDate;
|
|
114
|
+
if (headerHasToken) {
|
|
115
|
+
var d = tokenExpirationDate.replaceAll('-','/');
|
|
116
|
+
newDate = new Date(d);
|
|
117
|
+
newDate.setMinutes ( newDate.getMinutes() - connectionTimeLag);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
newDate = new Date(tokenExpirationDate);
|
|
121
|
+
newDate.setMinutes ( newDate.getMinutes() - connectionTimeLag);
|
|
123
122
|
newDate.setMinutes ( newDate.getMinutes() + config.liveSessionInterval );
|
|
124
|
-
console.log('out date: ', newDate);
|
|
125
123
|
}
|
|
126
124
|
config.qbTokenExpirationDate = newDate;
|
|
127
|
-
console.log('updateSessionExpirationDate ... Set value: ',
|
|
125
|
+
console.log('updateSessionExpirationDate ... Set value: ', config.qbTokenExpirationDate);
|
|
128
126
|
};
|
|
129
127
|
|
|
128
|
+
|
|
130
129
|
module.exports = config;
|
package/src/qbMain.js
CHANGED
|
@@ -28,24 +28,12 @@ QuickBlox.prototype = {
|
|
|
28
28
|
_getOS: Utils.getOS.bind(Utils),
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Init QuickBlox SDK with User Account data for start session with token.
|
|
32
31
|
* @memberof QB
|
|
33
|
-
* @param {Number}
|
|
34
|
-
* @param {String | Number}
|
|
32
|
+
* @param {Number | String} appIdOrToken - Application ID (from your admin panel) or Session Token.
|
|
33
|
+
* @param {String | Number} authKeyOrAppId - Authorization key or Application ID. You need to set up Application ID if you use session token as appIdOrToken parameter.
|
|
34
|
+
* @param {String} authSecret - Authorization secret key (from your admin panel).
|
|
35
35
|
* @param {Object} configMap - Settings object for QuickBlox SDK.
|
|
36
36
|
*/
|
|
37
|
-
initWithAppId: function(appId, accountKey, configMap) {
|
|
38
|
-
if (typeof appId !== 'number') {
|
|
39
|
-
throw new Error('Type of appId must be a number');
|
|
40
|
-
}
|
|
41
|
-
if (appId === '' || appId === undefined || appId === null ||
|
|
42
|
-
accountKey === '' || accountKey === undefined || accountKey === null) {
|
|
43
|
-
throw new Error('Cannot init QuickBlox without app credentials (app ID, auth key)');
|
|
44
|
-
} else {
|
|
45
|
-
this.init('', appId, null, accountKey, configMap);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
|
|
49
37
|
init: function(appIdOrToken, authKeyOrAppId, authSecret, accountKey, configMap) {
|
|
50
38
|
if (typeof accountKey === 'string' && accountKey.length) {
|
|
51
39
|
if (configMap && typeof configMap === 'object') {
|
|
@@ -93,8 +81,7 @@ QuickBlox.prototype = {
|
|
|
93
81
|
/** add WebRTC API if API is avaible */
|
|
94
82
|
if( Utils.isWebRTCAvailble() ) {
|
|
95
83
|
var WebRTCClient = require('./modules/webrtc/qbWebRTCClient');
|
|
96
|
-
this.webrtc = new WebRTCClient(this.service, this.chat
|
|
97
|
-
this.chat.webrtcSignalingProcessor = this.webrtc.signalingProcessor;
|
|
84
|
+
this.webrtc = new WebRTCClient(this.service, this.chat);
|
|
98
85
|
} else {
|
|
99
86
|
this.webrtc = false;
|
|
100
87
|
}
|
|
@@ -145,6 +132,26 @@ QuickBlox.prototype = {
|
|
|
145
132
|
}
|
|
146
133
|
},
|
|
147
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Init QuickBlox SDK with User Account data for start session with token.
|
|
137
|
+
* @memberof QB
|
|
138
|
+
* @param {Number} appId - Application ID (from your admin panel).
|
|
139
|
+
* @param {String | Number} accountKey - Account key (from your admin panel).
|
|
140
|
+
* @param {Object} configMap - Settings object for QuickBlox SDK.
|
|
141
|
+
*/
|
|
142
|
+
initWithAppId: function(appId, accountKey, configMap) {
|
|
143
|
+
//добавить проверку типа параметров
|
|
144
|
+
if (typeof appId !== 'number') {
|
|
145
|
+
throw new Error('Type of appId must be a number');
|
|
146
|
+
}
|
|
147
|
+
if (appId === '' || appId === undefined || appId === null ||
|
|
148
|
+
accountKey === '' || accountKey === undefined || accountKey === null) {
|
|
149
|
+
throw new Error('Cannot init QuickBlox without app credentials (app ID, auth key)');
|
|
150
|
+
} else {
|
|
151
|
+
this.init('', appId, null, accountKey, configMap);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
148
155
|
/**
|
|
149
156
|
* Return current session
|
|
150
157
|
* @memberof QB
|
|
@@ -183,6 +190,9 @@ QuickBlox.prototype = {
|
|
|
183
190
|
if (typeof callback === 'function') {
|
|
184
191
|
try{
|
|
185
192
|
this.auth.getSession(callback);
|
|
193
|
+
// TODO: pay attention on it, if we decide to remove application_id from QB.init:
|
|
194
|
+
// artan 06-09-2022
|
|
195
|
+
// should set value application_id from session model into config.creds.appId
|
|
186
196
|
}
|
|
187
197
|
catch(er){
|
|
188
198
|
callback(er, null);
|
package/src/qbProxy.js
CHANGED
|
@@ -141,7 +141,6 @@ ServiceProxy.prototype = {
|
|
|
141
141
|
qbResponse = response;
|
|
142
142
|
|
|
143
143
|
if (qbRequest.method === 'GET' || qbRequest.method === 'POST'){
|
|
144
|
-
// TODO: need to check in [CROS-815]
|
|
145
144
|
var qbTokenExpirationDate = qbResponse.headers.get('qb-token-expirationdate');
|
|
146
145
|
var headerHasToken = !(qbTokenExpirationDate === null ||
|
|
147
146
|
typeof qbTokenExpirationDate === 'undefined');
|
|
@@ -164,8 +163,6 @@ ServiceProxy.prototype = {
|
|
|
164
163
|
}).then(function(body) {
|
|
165
164
|
_requestCallback(null, qbResponse, body);
|
|
166
165
|
}, function(error) {
|
|
167
|
-
// TODO: review in [CROS-815]
|
|
168
|
-
console.log('Error: ', error);
|
|
169
166
|
_requestCallback(error);
|
|
170
167
|
});
|
|
171
168
|
|