quickblox 2.15.5 → 2.16.1
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 +9 -1
- package/package.json +2 -1
- package/quickblox.d.ts +688 -0
- package/quickblox.js +19327 -19240
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChatHelpers.js +2 -2
- package/src/qbConfig.js +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://discord.gg/c6bxq9BC"><img src="https://img.shields.io/discord/1042743094833065985?color=5865F2&logo=discord&logoColor=white&label=QuickBlox%20Discord%20server&style=for-the-badge" alt="Discord server" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
1
9
|
# QuickBlox JavaScript SDK
|
|
2
10
|
|
|
3
11
|
[](https://travis-ci.org/QuickBlox/quickblox-javascript-sdk)
|
|
@@ -16,7 +24,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
|
|
|
16
24
|
## Dependencies for browser
|
|
17
25
|
|
|
18
26
|
```html
|
|
19
|
-
<script src="https://unpkg.com/quickblox@2.
|
|
27
|
+
<script src="https://unpkg.com/quickblox@2.16.1/quickblox.min.js"></script>
|
|
20
28
|
```
|
|
21
29
|
|
|
22
30
|
## Bower and RequireJS
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickblox",
|
|
3
3
|
"description": "QuickBlox JavaScript SDK",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.1",
|
|
5
5
|
"homepage": "https://quickblox.com/developers/Javascript",
|
|
6
6
|
"main": "src/qbMain.js",
|
|
7
|
+
"types": "quickblox.d.ts",
|
|
7
8
|
"license": "(Apache-2.0)",
|
|
8
9
|
"keywords": [
|
|
9
10
|
"quickblox",
|
package/quickblox.d.ts
ADDED
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
type Dictionary<T> = Record<string, T>;
|
|
2
|
+
|
|
3
|
+
declare enum QBChatProtocol {
|
|
4
|
+
BOSH = 1,
|
|
5
|
+
WebSockets = 2,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ICEServer {
|
|
9
|
+
urls: string;
|
|
10
|
+
username: string;
|
|
11
|
+
credential: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare interface QBConfig {
|
|
15
|
+
debug?: boolean | { mode: 1 } | { mode: 2; file: string };
|
|
16
|
+
endpoints?: {
|
|
17
|
+
chat?: string;
|
|
18
|
+
api?: string;
|
|
19
|
+
};
|
|
20
|
+
webrtc?: {
|
|
21
|
+
iceServers?: ICEServer[];
|
|
22
|
+
};
|
|
23
|
+
chatProtocol?: {
|
|
24
|
+
active: QBChatProtocol;
|
|
25
|
+
};
|
|
26
|
+
streamManagement?: {
|
|
27
|
+
enable: boolean;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare interface QBError {
|
|
32
|
+
code?: number;
|
|
33
|
+
status?: string;
|
|
34
|
+
detail?: string | string[] | Dictionary<string | string[]>;
|
|
35
|
+
message: string | string[] | Dictionary<string | string[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface QBCallback<T> {
|
|
39
|
+
(error: null | undefined, result: T): void;
|
|
40
|
+
(error: QBError, result: null | undefined): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export declare interface QBUser {
|
|
44
|
+
id: number;
|
|
45
|
+
full_name: string;
|
|
46
|
+
email: string;
|
|
47
|
+
login: string;
|
|
48
|
+
phone: string;
|
|
49
|
+
/** Date ISO string */
|
|
50
|
+
created_at: string;
|
|
51
|
+
/** Date ISO string */
|
|
52
|
+
updated_at: string;
|
|
53
|
+
/** Date ISO string */
|
|
54
|
+
last_request_at: string;
|
|
55
|
+
custom_data: string | null;
|
|
56
|
+
user_tags: string | null;
|
|
57
|
+
password?: string;
|
|
58
|
+
old_password?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare interface ListUserResponse {
|
|
62
|
+
current_page: number;
|
|
63
|
+
per_page: number;
|
|
64
|
+
total_entries: number;
|
|
65
|
+
items: Array<{ user: QBUser }>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare interface QBSession {
|
|
69
|
+
_id: string;
|
|
70
|
+
application_id: number;
|
|
71
|
+
/** Date ISO string */
|
|
72
|
+
created_at: string;
|
|
73
|
+
id: number;
|
|
74
|
+
nonce: string;
|
|
75
|
+
token: string;
|
|
76
|
+
ts: number;
|
|
77
|
+
/** Date ISO string */
|
|
78
|
+
updated_at: string;
|
|
79
|
+
user_id: QBUser["id"];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type ChatConnectParams =
|
|
83
|
+
| {
|
|
84
|
+
userId: number;
|
|
85
|
+
/** user's password or session token */
|
|
86
|
+
password: string;
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
jid: string;
|
|
90
|
+
/** user's password or session token */
|
|
91
|
+
password: string;
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
email: string;
|
|
95
|
+
/** user's password or session token */
|
|
96
|
+
password: string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export declare interface ChatMessageAttachment {
|
|
100
|
+
/** ID of the file on QuickBlox server (UID of file from QB.content.createAndUpload) */
|
|
101
|
+
id: string | number;
|
|
102
|
+
uid?: string;
|
|
103
|
+
/** Type of attachment. Example: audio, video, image or other */
|
|
104
|
+
type: string;
|
|
105
|
+
/** Link to a file in Internet */
|
|
106
|
+
url?: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
size?: number;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare enum QBChatDialogType {
|
|
113
|
+
PUBLIC = 1,
|
|
114
|
+
GROUP = 2,
|
|
115
|
+
PRIVATE = 3,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare interface QBChatDialog {
|
|
119
|
+
_id: string;
|
|
120
|
+
/** Date ISO string */
|
|
121
|
+
created_at: string;
|
|
122
|
+
data?: { [key: string]: string };
|
|
123
|
+
last_message: string | null;
|
|
124
|
+
/** Date ISO string */
|
|
125
|
+
last_message_date_sent: string | null;
|
|
126
|
+
last_message_id: string | null;
|
|
127
|
+
last_message_user_id: QBUser["id"] | null;
|
|
128
|
+
name: string;
|
|
129
|
+
occupants_ids: number[];
|
|
130
|
+
photo: null;
|
|
131
|
+
type: QBChatDialogType;
|
|
132
|
+
/** Date ISO string */
|
|
133
|
+
updated_at: string;
|
|
134
|
+
user_id: QBUser["id"];
|
|
135
|
+
xmpp_room_jid: string | null;
|
|
136
|
+
unread_messages_count: number | null;
|
|
137
|
+
joined?: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export declare interface QBChatMessage {
|
|
141
|
+
_id: string;
|
|
142
|
+
attachments: ChatMessageAttachment[];
|
|
143
|
+
chat_dialog_id: QBChatDialog["_id"];
|
|
144
|
+
/** Date ISO string */
|
|
145
|
+
created_at: string;
|
|
146
|
+
/** Date timestamp */
|
|
147
|
+
date_sent: number;
|
|
148
|
+
delivered_ids?: Array<QBUser["id"]>;
|
|
149
|
+
message: string | null;
|
|
150
|
+
read_ids?: Array<QBUser["id"]>;
|
|
151
|
+
read: 0 | 1;
|
|
152
|
+
recipient_id: QBUser["id"] | null;
|
|
153
|
+
sender_id: QBUser["id"];
|
|
154
|
+
/** Date ISO string */
|
|
155
|
+
updated_at: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare interface QBMessageStatusParams {
|
|
159
|
+
messageId: QBChatMessage["_id"];
|
|
160
|
+
dialogId: QBChatDialog["_id"];
|
|
161
|
+
userId: QBUser["id"];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export declare interface QBChatNewMessage {
|
|
165
|
+
type: "chat" | "groupchat";
|
|
166
|
+
body: string;
|
|
167
|
+
extension: {
|
|
168
|
+
attachments?: ChatMessageAttachment[];
|
|
169
|
+
save_to_history: 0 | 1;
|
|
170
|
+
dialog_id: QBChatDialog["_id"];
|
|
171
|
+
};
|
|
172
|
+
markable: 0 | 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare interface QBChatXMPPMessage {
|
|
176
|
+
id: string;
|
|
177
|
+
dialog_id: QBChatDialog["_id"];
|
|
178
|
+
recipient_id: null;
|
|
179
|
+
type: "chat" | "groupchat";
|
|
180
|
+
body: string;
|
|
181
|
+
delay: null;
|
|
182
|
+
markable: 0 | 1;
|
|
183
|
+
extension: {
|
|
184
|
+
attachments?: ChatMessageAttachment[];
|
|
185
|
+
date_sent: string;
|
|
186
|
+
type?: string;
|
|
187
|
+
user_id?: string;
|
|
188
|
+
profile_id?: string;
|
|
189
|
+
organization_id?: string;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export declare interface QBSystemMessage {
|
|
194
|
+
id: string;
|
|
195
|
+
userId: QBUser["id"];
|
|
196
|
+
body?: null | string;
|
|
197
|
+
extension?: Dictionary<string>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export declare interface QBGetDialogResult {
|
|
201
|
+
items: QBChatDialog[];
|
|
202
|
+
limit: number;
|
|
203
|
+
skip: number;
|
|
204
|
+
total_entries: number;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export declare type GetMessagesResult = {
|
|
208
|
+
items: QBChatMessage[];
|
|
209
|
+
limit: number;
|
|
210
|
+
skip: number;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
interface QBChatModule {
|
|
214
|
+
dialog: {
|
|
215
|
+
create(
|
|
216
|
+
params: Dictionary<unknown>,
|
|
217
|
+
callback: QBCallback<QBChatDialog>
|
|
218
|
+
): void;
|
|
219
|
+
list(
|
|
220
|
+
params: Dictionary<unknown>,
|
|
221
|
+
callback: QBCallback<QBGetDialogResult>
|
|
222
|
+
): void;
|
|
223
|
+
update(
|
|
224
|
+
id: string,
|
|
225
|
+
data: Dictionary<unknown>,
|
|
226
|
+
callback: QBCallback<QBChatDialog>
|
|
227
|
+
): void;
|
|
228
|
+
};
|
|
229
|
+
message: {
|
|
230
|
+
list(
|
|
231
|
+
params: Dictionary<unknown>,
|
|
232
|
+
callback: QBCallback<GetMessagesResult>
|
|
233
|
+
): void;
|
|
234
|
+
};
|
|
235
|
+
isConnected: boolean;
|
|
236
|
+
send<T extends QBChatNewMessage>(
|
|
237
|
+
jidOrUserId: QBUser["id"] | string,
|
|
238
|
+
message: T
|
|
239
|
+
): string;
|
|
240
|
+
sendSystemMessage(
|
|
241
|
+
jidOrUserId: QBUser["id"] | string,
|
|
242
|
+
message: { extension: QBSystemMessage["extension"] }
|
|
243
|
+
): string;
|
|
244
|
+
sendDeliveredStatus(params: QBMessageStatusParams): void;
|
|
245
|
+
sendReadStatus(params: QBMessageStatusParams): void;
|
|
246
|
+
sendIsTypingStatus(jidOrUserId: QBUser["id"] | string): void;
|
|
247
|
+
sendIsStopTypingStatus(jidOrUserId: QBUser["id"] | string): void;
|
|
248
|
+
connect: (params: ChatConnectParams, callback: QBCallback<unknown>) => void;
|
|
249
|
+
disconnect: () => void;
|
|
250
|
+
ping(jidOrUserId: string | number, callback: QBCallback<unknown>): void;
|
|
251
|
+
ping(callback: QBCallback<unknown>): void;
|
|
252
|
+
muc: {
|
|
253
|
+
join(dialogJid: string, callback: QBCallback<unknown>): void;
|
|
254
|
+
leave(dialogJid: string, callback: QBCallback<unknown>): void;
|
|
255
|
+
};
|
|
256
|
+
helpers: {
|
|
257
|
+
getDialogJid(dialogId: QBChatDialog["_id"]): string;
|
|
258
|
+
getDialogIdFromNode(jid: string): QBChatDialog["_id"];
|
|
259
|
+
getUserCurrentJid(): string;
|
|
260
|
+
getUserJid(userId: QBUser["id"], appId?: string | number): string;
|
|
261
|
+
getRoomJidFromDialogId(dialogId: QBChatDialog["_id"]): string;
|
|
262
|
+
};
|
|
263
|
+
onMessageListener?: (
|
|
264
|
+
senderId: QBUser["id"],
|
|
265
|
+
message: QBChatXMPPMessage
|
|
266
|
+
) => void;
|
|
267
|
+
onMessageErrorListener?: (messageId: string, error: unknown) => void;
|
|
268
|
+
onMessageTypingListener?: (
|
|
269
|
+
isTyping: boolean,
|
|
270
|
+
userId: QBUser["id"],
|
|
271
|
+
dialogId: QBChatDialog["_id"]
|
|
272
|
+
) => void;
|
|
273
|
+
onDeliveredStatusListener?: (
|
|
274
|
+
messageId: string,
|
|
275
|
+
dialogId: QBChatDialog["_id"],
|
|
276
|
+
userId: QBUser["id"]
|
|
277
|
+
) => void;
|
|
278
|
+
onReadStatusListener?: (
|
|
279
|
+
messageId: string,
|
|
280
|
+
dialogId: QBChatDialog["_id"],
|
|
281
|
+
userId: QBUser["id"]
|
|
282
|
+
) => void;
|
|
283
|
+
onSystemMessageListener?: (message: QBSystemMessage) => void;
|
|
284
|
+
onReconnectFailedListener?: (error: unknown) => void;
|
|
285
|
+
onDisconnectedListener?: VoidFunction;
|
|
286
|
+
onReconnectListener?: VoidFunction;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export declare interface QBContentObject {
|
|
290
|
+
account_id: number;
|
|
291
|
+
app_id: number;
|
|
292
|
+
content_type: string;
|
|
293
|
+
created_at: string;
|
|
294
|
+
id: number;
|
|
295
|
+
name: string;
|
|
296
|
+
public: boolean;
|
|
297
|
+
size: number;
|
|
298
|
+
uid: string;
|
|
299
|
+
updated_at: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface QBAccess {
|
|
303
|
+
access: "open" | "owner" | "open_for_users_ids" | "open_for_groups";
|
|
304
|
+
users_ids: string[];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface QBPermissions {
|
|
308
|
+
create: QBAccess;
|
|
309
|
+
read: QBAccess;
|
|
310
|
+
update: QBAccess;
|
|
311
|
+
delete: QBAccess;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export declare interface QBCustomObject {
|
|
315
|
+
/**
|
|
316
|
+
* ID of the record
|
|
317
|
+
* Generated automatically by the server after record creation
|
|
318
|
+
*/
|
|
319
|
+
_id: string;
|
|
320
|
+
/** ID of the user who created the record */
|
|
321
|
+
user_id: QBUser["id"];
|
|
322
|
+
/** ID of parent object (Relations) */
|
|
323
|
+
_parent_id: string | null;
|
|
324
|
+
/** Date & time when a record was created, filled automatically */
|
|
325
|
+
created_at: number;
|
|
326
|
+
/** Date & time when record was updated, filled automatically */
|
|
327
|
+
updated_at: number;
|
|
328
|
+
permissions: QBPermissions;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export declare interface QBDataFile {
|
|
332
|
+
content_type: string;
|
|
333
|
+
file_id: string;
|
|
334
|
+
name: string;
|
|
335
|
+
size: number;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export declare interface BlobObject extends QBContentObject {
|
|
339
|
+
blob_object_access: { params: string };
|
|
340
|
+
blob_status: unknown;
|
|
341
|
+
set_completed_at: unknown;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface QBContentModule {
|
|
345
|
+
privateUrl(fileUID: string): string;
|
|
346
|
+
publicUrl(fileUID: string): string;
|
|
347
|
+
getInfo(id: number, callback: QBCallback<{ blob: QBContentObject }>);
|
|
348
|
+
create(
|
|
349
|
+
params: { name: string; content_type: string; public?: boolean },
|
|
350
|
+
callback: QBCallback<BlobObject>
|
|
351
|
+
);
|
|
352
|
+
markUploaded(
|
|
353
|
+
params: { id: number; size: number },
|
|
354
|
+
callback: QBCallback<unknown>
|
|
355
|
+
);
|
|
356
|
+
delete(id: number, callback: QBCallback<unknown>);
|
|
357
|
+
createAndUpload(
|
|
358
|
+
params: {
|
|
359
|
+
name: string;
|
|
360
|
+
file: Buffer;
|
|
361
|
+
type: string;
|
|
362
|
+
size: number;
|
|
363
|
+
public?: boolean;
|
|
364
|
+
},
|
|
365
|
+
callback: QBCallback<QBContentObject>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export declare interface QBDataDeletedResponse {
|
|
370
|
+
deleted: Array<QBCustomObject["_id"]>;
|
|
371
|
+
deletedCount: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
interface QBDataModule {
|
|
375
|
+
create<T extends QBCustomObject>(
|
|
376
|
+
className: string,
|
|
377
|
+
data: Dictionary<unknown>,
|
|
378
|
+
callback: QBCallback<T>
|
|
379
|
+
): void;
|
|
380
|
+
delete<T extends QBCustomObject["_id"] | Array<QBCustomObject["_id"]>>(
|
|
381
|
+
className: string,
|
|
382
|
+
ids: T,
|
|
383
|
+
callback: QBCallback<QBDataDeletedResponse>
|
|
384
|
+
): void;
|
|
385
|
+
list<T extends QBCustomObject>(
|
|
386
|
+
className: string,
|
|
387
|
+
filters: Dictionary<unknown>,
|
|
388
|
+
callback: QBCallback<{
|
|
389
|
+
class_name: string;
|
|
390
|
+
items: T[];
|
|
391
|
+
limit: number;
|
|
392
|
+
skip: number;
|
|
393
|
+
}>
|
|
394
|
+
): void;
|
|
395
|
+
update<
|
|
396
|
+
T extends QBCustomObject
|
|
397
|
+
>(
|
|
398
|
+
className: string,
|
|
399
|
+
data: { _id: string } & Dictionary<unknown>,
|
|
400
|
+
callback: QBCallback<T>
|
|
401
|
+
): void;
|
|
402
|
+
fileUrl(
|
|
403
|
+
className: string,
|
|
404
|
+
params: { id: string; field_name: string }
|
|
405
|
+
): string;
|
|
406
|
+
uploadFile(
|
|
407
|
+
className: string,
|
|
408
|
+
params: { id: string; field_name: string; file: File; name: string },
|
|
409
|
+
callback: QBCallback<QBDataFile>
|
|
410
|
+
): void;
|
|
411
|
+
deleteFile(
|
|
412
|
+
className: string,
|
|
413
|
+
params: { id: string; field_name: string },
|
|
414
|
+
callback: QBCallback<unknown>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export declare interface QBCreateUserWithLogin {
|
|
419
|
+
login: string;
|
|
420
|
+
password: string;
|
|
421
|
+
blob_id?: number;
|
|
422
|
+
custom_data?: string | null;
|
|
423
|
+
email?: string;
|
|
424
|
+
external_user_id?: string | number;
|
|
425
|
+
facebook_id?: string;
|
|
426
|
+
full_name?: string;
|
|
427
|
+
phone?: string;
|
|
428
|
+
tag_list?: string | string[];
|
|
429
|
+
website?: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export declare interface QBCreateUserWithEmail {
|
|
433
|
+
email: string;
|
|
434
|
+
password: string;
|
|
435
|
+
blob_id?: number;
|
|
436
|
+
custom_data?: string | null;
|
|
437
|
+
external_user_id?: string | number;
|
|
438
|
+
facebook_id?: string;
|
|
439
|
+
full_name?: string;
|
|
440
|
+
login?: string;
|
|
441
|
+
phone?: string;
|
|
442
|
+
tag_list?: string | string[];
|
|
443
|
+
website?: string;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export declare type GetUserParam =
|
|
447
|
+
| { login: string }
|
|
448
|
+
| { full_name: string }
|
|
449
|
+
| { facebook_id: string }
|
|
450
|
+
| { phone: string }
|
|
451
|
+
| { email: string }
|
|
452
|
+
| { tags: string }
|
|
453
|
+
| { external: string };
|
|
454
|
+
|
|
455
|
+
export declare type GetUserParams =
|
|
456
|
+
| GetUserParam
|
|
457
|
+
| {
|
|
458
|
+
page?: number;
|
|
459
|
+
per_page?: number;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
export declare type ListUserParams = {
|
|
463
|
+
page?: number;
|
|
464
|
+
per_page?: number;
|
|
465
|
+
filter?: Dictionary<unknown>;
|
|
466
|
+
order?: string;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
interface QBUsersModule {
|
|
470
|
+
get(params: number, callback: QBCallback<QBUser>): void;
|
|
471
|
+
get(params: GetUserParams, callback: QBCallback<ListUserResponse>): void;
|
|
472
|
+
listUsers(
|
|
473
|
+
params: ListUserParams,
|
|
474
|
+
callback: QBCallback<ListUserResponse>
|
|
475
|
+
): void;
|
|
476
|
+
create<T = QBCreateUserWithLogin | QBCreateUserWithEmail>(
|
|
477
|
+
params: T,
|
|
478
|
+
callback: QBCallback<QBUser>
|
|
479
|
+
): void;
|
|
480
|
+
delete(userId: number, callback: QBCallback<unknown>): void;
|
|
481
|
+
update(
|
|
482
|
+
userId: number,
|
|
483
|
+
user: Partial<Omit<QBUser, "id">>,
|
|
484
|
+
callback: QBCallback<QBUser>
|
|
485
|
+
): void;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export declare interface QBGetUserMediaParams {
|
|
489
|
+
audio: MediaStreamConstraints["audio"];
|
|
490
|
+
video: MediaStreamConstraints["video"];
|
|
491
|
+
/** Id attribute of HTMLVideoElement */
|
|
492
|
+
elemId?: string;
|
|
493
|
+
options?: {
|
|
494
|
+
muted?: boolean;
|
|
495
|
+
mirror?: boolean;
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export declare interface QBWebRTCSession {
|
|
500
|
+
State: {
|
|
501
|
+
NEW: 1;
|
|
502
|
+
ACTIVE: 2;
|
|
503
|
+
HUNGUP: 3;
|
|
504
|
+
REJECTED: 4;
|
|
505
|
+
CLOSED: 5;
|
|
506
|
+
};
|
|
507
|
+
ID: string;
|
|
508
|
+
/**
|
|
509
|
+
* One of {@link QBWebRTCSession#State}
|
|
510
|
+
*/
|
|
511
|
+
state: number;
|
|
512
|
+
initiatorID: number;
|
|
513
|
+
opponentsIDs: number[];
|
|
514
|
+
peerConnections: { [userId: number]: RTCPeerConnection };
|
|
515
|
+
callType: 1 | 2;
|
|
516
|
+
startCallTime?: Date;
|
|
517
|
+
localStream?: MediaStream;
|
|
518
|
+
mediaParams: QBGetUserMediaParams | null;
|
|
519
|
+
getUserMedia(
|
|
520
|
+
params: QBGetUserMediaParams,
|
|
521
|
+
callback: QBCallback<MediaStream>
|
|
522
|
+
): void;
|
|
523
|
+
/** Attach media stream to audio/video element */
|
|
524
|
+
attachMediaStream(
|
|
525
|
+
videoElemId: string,
|
|
526
|
+
stream: MediaStream,
|
|
527
|
+
options?: QBGetUserMediaParams["options"]
|
|
528
|
+
): void;
|
|
529
|
+
/** Detach media stream from audio/video element */
|
|
530
|
+
detachMediaStream(videoElemId: string): void;
|
|
531
|
+
mute(type: "audio" | "video"): void;
|
|
532
|
+
unmute(type: "audio" | "video"): void;
|
|
533
|
+
/** Innitiate a call */
|
|
534
|
+
call(params: Dictionary<unknown>): void;
|
|
535
|
+
/** Accept call */
|
|
536
|
+
accept(params: Dictionary<unknown>): void;
|
|
537
|
+
/** Reject call */
|
|
538
|
+
reject(params: Dictionary<unknown>): void;
|
|
539
|
+
/** Stop call (Hang up) */
|
|
540
|
+
stop(params: Dictionary<unknown>): void;
|
|
541
|
+
switchMediaTracks(
|
|
542
|
+
deviceIds: { audio?: { exact: string }; video?: { exact: string } },
|
|
543
|
+
callback: QBCallback<MediaStream>
|
|
544
|
+
): void;
|
|
545
|
+
/** Add tracks from provided stream to local stream (and replace in peers) */
|
|
546
|
+
_replaceTracks(stream: MediaStream): void;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export declare interface QBWebRTCModule {
|
|
550
|
+
CallType: {
|
|
551
|
+
VIDEO: 1;
|
|
552
|
+
AUDIO: 2;
|
|
553
|
+
};
|
|
554
|
+
getMediaDevices(kind?: MediaDeviceKind): Promise<MediaDeviceInfo[]>;
|
|
555
|
+
createNewSession(opponentsIds: number[], callType: 1 | 2): QBWebRTCSession;
|
|
556
|
+
onAcceptCallListener?: (
|
|
557
|
+
session: QBWebRTCSession,
|
|
558
|
+
userId: number,
|
|
559
|
+
userInfo: Dictionary<unknown>
|
|
560
|
+
) => void;
|
|
561
|
+
onCallListener?: (
|
|
562
|
+
session: QBWebRTCSession,
|
|
563
|
+
userInfo: Dictionary<unknown>
|
|
564
|
+
) => void;
|
|
565
|
+
onCallStatsReport?: (
|
|
566
|
+
session: QBWebRTCSession,
|
|
567
|
+
userId: number,
|
|
568
|
+
stats: string[]
|
|
569
|
+
) => void;
|
|
570
|
+
onRejectCallListener?: (
|
|
571
|
+
session: QBWebRTCSession,
|
|
572
|
+
userId: number,
|
|
573
|
+
userInfo: Dictionary<unknown>
|
|
574
|
+
) => void;
|
|
575
|
+
onRemoteStreamListener?: (
|
|
576
|
+
sesion: QBWebRTCSession,
|
|
577
|
+
userId: number,
|
|
578
|
+
stream: MediaStream
|
|
579
|
+
) => void;
|
|
580
|
+
onSessionCloseListener?: (session: QBWebRTCSession) => void;
|
|
581
|
+
onSessionConnectionStateChangedListener?: (
|
|
582
|
+
sesion: QBWebRTCSession,
|
|
583
|
+
userId: number,
|
|
584
|
+
state: unknown
|
|
585
|
+
) => void;
|
|
586
|
+
onStopCallListener?: (
|
|
587
|
+
session: QBWebRTCSession,
|
|
588
|
+
userId: number,
|
|
589
|
+
userInfo: Dictionary<unknown>
|
|
590
|
+
) => void;
|
|
591
|
+
onUpdateCallListener?: (
|
|
592
|
+
session: QBWebRTCSession,
|
|
593
|
+
userId: number,
|
|
594
|
+
userInfo: Dictionary<unknown>
|
|
595
|
+
) => void;
|
|
596
|
+
onUserNotAnswerListener?: (session: QBWebRTCSession, userId: number) => void;
|
|
597
|
+
onReconnectListener?: (session: QBWebRTCSession, userId: number, state: unknown) => void;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export declare type QBLoginParams =
|
|
601
|
+
| {
|
|
602
|
+
login: string;
|
|
603
|
+
password: string;
|
|
604
|
+
}
|
|
605
|
+
| {
|
|
606
|
+
email: string;
|
|
607
|
+
password: string;
|
|
608
|
+
}
|
|
609
|
+
| {
|
|
610
|
+
provider: "firebase_phone";
|
|
611
|
+
firebase_phone: { access_token: string; project_id: string };
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
export class QuickBlox {
|
|
615
|
+
buildNumber: string;
|
|
616
|
+
|
|
617
|
+
chat: QBChatModule;
|
|
618
|
+
|
|
619
|
+
content: QBContentModule;
|
|
620
|
+
|
|
621
|
+
data: QBDataModule;
|
|
622
|
+
|
|
623
|
+
createSession: {
|
|
624
|
+
(callback: QBCallback<QBSession>): void;
|
|
625
|
+
(params: QBLoginParams, callback: QBCallback<QBSession>): void;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
startSessionWithToken(
|
|
629
|
+
token: string,
|
|
630
|
+
callback: QBCallback<{ session: QBSession }>
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
destroySession(callback: QBCallback<unknown>): void;
|
|
634
|
+
|
|
635
|
+
getSession(callback: QBCallback<{ session: QBSession }>): void;
|
|
636
|
+
|
|
637
|
+
init(
|
|
638
|
+
appIdOrToken: string | number,
|
|
639
|
+
authKeyOrAppId: string | number,
|
|
640
|
+
authSecret: string | null | undefined,
|
|
641
|
+
accountKey: string,
|
|
642
|
+
config?: QBConfig
|
|
643
|
+
): void;
|
|
644
|
+
|
|
645
|
+
initWithAppId(appId: number, accountKey: string, config?: QBConfig):void;
|
|
646
|
+
|
|
647
|
+
login(params: QBLoginParams, callback: QBCallback<QBUser>): void;
|
|
648
|
+
|
|
649
|
+
logout(callback: QBCallback<unknown>): void;
|
|
650
|
+
|
|
651
|
+
service: {
|
|
652
|
+
qbInst: {
|
|
653
|
+
session: QBSession | null;
|
|
654
|
+
config: {
|
|
655
|
+
webrtc: {
|
|
656
|
+
answerTimeInterval: number;
|
|
657
|
+
};
|
|
658
|
+
endpoints: {
|
|
659
|
+
api: string;
|
|
660
|
+
};
|
|
661
|
+
urls: {
|
|
662
|
+
blobs: string;
|
|
663
|
+
type: string;
|
|
664
|
+
data: string;
|
|
665
|
+
};
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
users: QBUsersModule;
|
|
671
|
+
|
|
672
|
+
webrtc: QBWebRTCModule;
|
|
673
|
+
|
|
674
|
+
version: string;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
interface QuickBloxConstructor {
|
|
678
|
+
prototype: QuickBlox;
|
|
679
|
+
new (): QuickBlox;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
interface QB extends QuickBlox {
|
|
683
|
+
QuickBlox: QuickBloxConstructor;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
declare const SDK: QB;
|
|
687
|
+
|
|
688
|
+
export default SDK;
|