@flashphoner/sfusdk 1.0.47 → 2.0.48
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/dist/examples/sfu.d.ts +13 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk/connection.d.ts +25 -0
- package/dist/sdk/connection.js +101 -0
- package/dist/sdk/connection.js.map +1 -0
- package/dist/sdk/constants.d.ts +355 -0
- package/dist/sdk/constants.js +190 -0
- package/dist/sdk/constants.js.map +1 -0
- package/dist/sdk/logger.d.ts +10 -0
- package/dist/sdk/logger.js +22 -0
- package/dist/sdk/logger.js.map +1 -0
- package/dist/sdk/notifier.d.ts +7 -0
- package/dist/sdk/notifier.js +52 -0
- package/dist/sdk/notifier.js.map +1 -0
- package/dist/sdk/promises.d.ts +11 -0
- package/{src/sdk/promise.js → dist/sdk/promises.js} +14 -13
- package/dist/sdk/promises.js.map +1 -0
- package/dist/sdk/room-extended.d.ts +13 -0
- package/dist/sdk/room-extended.js +112 -0
- package/dist/sdk/room-extended.js.map +1 -0
- package/dist/sdk/room.d.ts +30 -0
- package/dist/sdk/room.js +384 -0
- package/dist/sdk/room.js.map +1 -0
- package/dist/sdk/sfu-extended.d.ts +126 -0
- package/dist/sdk/sfu-extended.js +511 -0
- package/dist/sdk/sfu-extended.js.map +1 -0
- package/dist/sdk/sfu.d.ts +22 -0
- package/dist/sdk/sfu.js +136 -0
- package/dist/sdk/sfu.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/sdk/connection.d.ts +25 -0
- package/dist/src/sdk/constants.d.ts +355 -0
- package/dist/src/sdk/logger.d.ts +10 -0
- package/dist/src/sdk/notifier.d.ts +7 -0
- package/dist/src/sdk/promises.d.ts +11 -0
- package/dist/src/sdk/room-extended.d.ts +13 -0
- package/dist/src/sdk/room.d.ts +30 -0
- package/dist/src/sdk/sfu-extended.d.ts +126 -0
- package/dist/src/sdk/sfu.d.ts +22 -0
- package/package.json +27 -27
- package/Gruntfile.js +0 -79
- package/README.md +0 -95
- package/dependencies/bootstrap/css/bootstrap-theme.css +0 -587
- package/dependencies/bootstrap/css/bootstrap-theme.css.map +0 -1
- package/dependencies/bootstrap/css/bootstrap-theme.min.css +0 -5
- package/dependencies/bootstrap/css/bootstrap.css +0 -6853
- package/dependencies/bootstrap/css/bootstrap.css.map +0 -1
- package/dependencies/bootstrap/css/bootstrap.min.css +0 -5
- package/dependencies/bootstrap/font-awesome/HELP-US-OUT.txt +0 -7
- package/dependencies/bootstrap/font-awesome/css/font-awesome.css +0 -2178
- package/dependencies/bootstrap/font-awesome/css/font-awesome.min.css +0 -4
- package/dependencies/bootstrap/font-awesome/fonts/FontAwesome.otf +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.svg +0 -685
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/dependencies/bootstrap/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/dependencies/bootstrap/font-awesome/less/animated.less +0 -34
- package/dependencies/bootstrap/font-awesome/less/bordered-pulled.less +0 -25
- package/dependencies/bootstrap/font-awesome/less/core.less +0 -12
- package/dependencies/bootstrap/font-awesome/less/fixed-width.less +0 -6
- package/dependencies/bootstrap/font-awesome/less/font-awesome.less +0 -18
- package/dependencies/bootstrap/font-awesome/less/icons.less +0 -724
- package/dependencies/bootstrap/font-awesome/less/larger.less +0 -13
- package/dependencies/bootstrap/font-awesome/less/list.less +0 -19
- package/dependencies/bootstrap/font-awesome/less/mixins.less +0 -60
- package/dependencies/bootstrap/font-awesome/less/path.less +0 -15
- package/dependencies/bootstrap/font-awesome/less/rotated-flipped.less +0 -20
- package/dependencies/bootstrap/font-awesome/less/screen-reader.less +0 -5
- package/dependencies/bootstrap/font-awesome/less/stacked.less +0 -20
- package/dependencies/bootstrap/font-awesome/less/variables.less +0 -735
- package/dependencies/bootstrap/font-awesome/scss/_animated.scss +0 -34
- package/dependencies/bootstrap/font-awesome/scss/_bordered-pulled.scss +0 -25
- package/dependencies/bootstrap/font-awesome/scss/_core.scss +0 -12
- package/dependencies/bootstrap/font-awesome/scss/_fixed-width.scss +0 -6
- package/dependencies/bootstrap/font-awesome/scss/_icons.scss +0 -724
- package/dependencies/bootstrap/font-awesome/scss/_larger.scss +0 -13
- package/dependencies/bootstrap/font-awesome/scss/_list.scss +0 -19
- package/dependencies/bootstrap/font-awesome/scss/_mixins.scss +0 -60
- package/dependencies/bootstrap/font-awesome/scss/_path.scss +0 -15
- package/dependencies/bootstrap/font-awesome/scss/_rotated-flipped.scss +0 -20
- package/dependencies/bootstrap/font-awesome/scss/_screen-reader.scss +0 -5
- package/dependencies/bootstrap/font-awesome/scss/_stacked.scss +0 -20
- package/dependencies/bootstrap/font-awesome/scss/_variables.scss +0 -735
- package/dependencies/bootstrap/font-awesome/scss/font-awesome.scss +0 -18
- package/dependencies/bootstrap/fonts/FontAwesome.otf +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.eot +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.svg +0 -655
- package/dependencies/bootstrap/fonts/fontawesome-webfont.ttf +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.woff +0 -0
- package/dependencies/bootstrap/fonts/fontawesome-webfont.woff2 +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dependencies/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/dependencies/bootstrap/icons/font-awesome.min.css +0 -4
- package/dependencies/bootstrap/js/bootstrap.js +0 -2363
- package/dependencies/bootstrap/js/bootstrap.min.js +0 -7
- package/dependencies/bootstrap/js/npm.js +0 -13
- package/dependencies/bootstrap/js/switch.js +0 -85
- package/dependencies/jquery/jquery-1.12.0.js +0 -11027
- package/dependencies/jquery/jquery-ui.js +0 -16617
- package/dependencies/jquery/jquery.js +0 -8981
- package/dependencies/jquery/jquery.json.js +0 -199
- package/dependencies/jquery/jquery.websocket.js +0 -61
- package/dependencies/sigma/sigma.layout.forceAtlas2.min.js +0 -1
- package/dependencies/sigma/sigma.layout.noverlap.min.js +0 -1
- package/dependencies/sigma/sigma.min.js +0 -2
- package/dependencies/sigma/sigma.plugins.relativeSize.min.js +0 -1
- package/dependencies/sigma/sigma.renderers.edgeLabels.min.js +0 -1
- package/dependencies/sigma/sigma.renderers.parallelEdges.min.js +0 -1
- package/dependencies/sigma/sigma.require.js +0 -12076
- package/docTemplate/README.md +0 -5
- package/docTemplate/publish.js +0 -654
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docTemplate/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docTemplate/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docTemplate/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docTemplate/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docTemplate/static/scripts/linenumber.js +0 -25
- package/docTemplate/static/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docTemplate/static/scripts/prettify/lang-css.js +0 -2
- package/docTemplate/static/scripts/prettify/prettify.js +0 -28
- package/docTemplate/static/styles/jsdoc-default.css +0 -354
- package/docTemplate/static/styles/prettify-jsdoc.css +0 -111
- package/docTemplate/static/styles/prettify-tomorrow.css +0 -132
- package/docTemplate/tmpl/augments.tmpl +0 -10
- package/docTemplate/tmpl/container.tmpl +0 -183
- package/docTemplate/tmpl/details.tmpl +0 -143
- package/docTemplate/tmpl/example.tmpl +0 -2
- package/docTemplate/tmpl/examples.tmpl +0 -13
- package/docTemplate/tmpl/exceptions.tmpl +0 -32
- package/docTemplate/tmpl/layout.tmpl +0 -38
- package/docTemplate/tmpl/mainpage.tmpl +0 -14
- package/docTemplate/tmpl/members.tmpl +0 -38
- package/docTemplate/tmpl/method.tmpl +0 -105
- package/docTemplate/tmpl/params.tmpl +0 -124
- package/docTemplate/tmpl/properties.tmpl +0 -108
- package/docTemplate/tmpl/returns.tmpl +0 -19
- package/docTemplate/tmpl/source.tmpl +0 -8
- package/docTemplate/tmpl/tutorial.tmpl +0 -19
- package/docTemplate/tmpl/type.tmpl +0 -7
- package/src/examples/client/chat.js +0 -67
- package/src/examples/client/config.json +0 -26
- package/src/examples/client/controls.js +0 -314
- package/src/examples/client/display.js +0 -502
- package/src/examples/client/main.css +0 -45
- package/src/examples/client/main.html +0 -220
- package/src/examples/client/main.js +0 -156
- package/src/examples/client/resources/details_close.png +0 -0
- package/src/examples/client/resources/details_open.png +0 -0
- package/src/examples/client/util.js +0 -67
- package/src/examples/commons/js/config.js +0 -81
- package/src/examples/commons/js/display.js +0 -484
- package/src/examples/commons/js/util.js +0 -202
- package/src/examples/commons/media/silence.mp3 +0 -0
- package/src/examples/controller/dependencies/sigma/sigma.renderers.edgeLabels.min.js +0 -1
- package/src/examples/controller/dependencies/sigma/sigma.renderers.parallelEdges.min.js +0 -1
- package/src/examples/controller/dependencies/sigma/sigma.require.js +0 -12076
- package/src/examples/controller/graph-view.js +0 -32
- package/src/examples/controller/main.css +0 -45
- package/src/examples/controller/main.html +0 -79
- package/src/examples/controller/main.js +0 -65
- package/src/examples/controller/parser.js +0 -202
- package/src/examples/controller/resources/details_close.png +0 -0
- package/src/examples/controller/resources/details_open.png +0 -0
- package/src/examples/controller/rest.js +0 -56
- package/src/examples/controller/table-view.js +0 -64
- package/src/examples/controller/test-data.js +0 -382
- package/src/examples/player/config.json +0 -8
- package/src/examples/player/player.css +0 -19
- package/src/examples/player/player.html +0 -54
- package/src/examples/player/player.js +0 -209
- package/src/examples/two-way-streaming/config.json +0 -34
- package/src/examples/two-way-streaming/two-way-streaming.css +0 -26
- package/src/examples/two-way-streaming/two-way-streaming.html +0 -72
- package/src/examples/two-way-streaming/two-way-streaming.js +0 -375
- package/src/sdk/constants.js +0 -514
- package/src/sdk/logger.js +0 -16
- package/src/sdk/room.js +0 -594
- package/src/sdk/sfu-extended.js +0 -843
- package/src/sdk/sfu.js +0 -208
- package/src/sdk/ws.js +0 -113
- package/src/tests/assets/1.jpeg +0 -0
- package/src/tests/lib/rtcaudiosourcesinewave.js +0 -109
- package/src/tests/lib/rtcvideosourcewrapper.js +0 -28
- package/src/tests/sdk/room.test.js +0 -229
- package/src/tests/sdk/sfu-extended.test.js +0 -265
- package/src/tests/sdk/sfu-extended.test.js_ +0 -265
- package/src/tests/util.js +0 -48
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const sfu = require("../../sdk/sfu-extended");
|
|
4
|
-
const constants = require("../../sdk/constants");
|
|
5
|
-
|
|
6
|
-
const SERVER = "ws://127.0.0.1:8080";
|
|
7
|
-
const USER = "bob@flashphoner.com";
|
|
8
|
-
const PASSWD = "123456";
|
|
9
|
-
const CHAT_ID = "test-chat-id";
|
|
10
|
-
const CHANNEL_ID = "test-channel-id";
|
|
11
|
-
const CHANNEL_NAME = "test-channel";
|
|
12
|
-
const CHAT_NAME = "test-chat";
|
|
13
|
-
const CHAT_NAME2 = "test-chat2";
|
|
14
|
-
const USER2 = "alice@flashphoner.com";
|
|
15
|
-
const MESSAGE_BODY = "This is a test message";
|
|
16
|
-
const MEMBERS = [
|
|
17
|
-
"bob@flashphoner.com",
|
|
18
|
-
"alice@flashphoner.com",
|
|
19
|
-
"kiri@flashphoner.com"
|
|
20
|
-
];
|
|
21
|
-
const FILE = "../assets/1.jpeg";
|
|
22
|
-
|
|
23
|
-
jest.isolateModules(() => {
|
|
24
|
-
sfu2 = require("../../sdk/sfu-extended");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
beforeAll( async () => {
|
|
28
|
-
await sfu.connect({
|
|
29
|
-
url: SERVER,
|
|
30
|
-
username: USER,
|
|
31
|
-
password: PASSWD
|
|
32
|
-
});
|
|
33
|
-
const chats = await sfu.getUserChats();
|
|
34
|
-
if (chats) {
|
|
35
|
-
Object.entries(chats).map(async ([key, value]) => {
|
|
36
|
-
await sfu.deleteChat({id: value.id});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
await sfu2.connect({
|
|
40
|
-
url: SERVER,
|
|
41
|
-
username: USER2,
|
|
42
|
-
password: PASSWD
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterAll(async () => {
|
|
47
|
-
await sfu.disconnect();
|
|
48
|
-
await sfu2.disconnect();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
describe("connection", () => {
|
|
53
|
-
test("should connect to server", () => {
|
|
54
|
-
expect(sfu.state()).toBe(constants.SFU_STATE.AUTHENTICATED);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe("contacts", () => {
|
|
59
|
-
test("should load user list", () => {
|
|
60
|
-
return sfu.getUserList();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("calendar", () => {
|
|
65
|
-
test("should load calendar", () => {
|
|
66
|
-
return sfu.getUserCalendar().then((calendar) => {
|
|
67
|
-
expect(calendar).toHaveProperty("events");
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("chat", () => {
|
|
73
|
-
test("should create new chat", () => {
|
|
74
|
-
return sfu.createChat({
|
|
75
|
-
id: CHAT_ID,
|
|
76
|
-
name: CHAT_NAME
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe("channels", () => {
|
|
80
|
-
test("should create new channel", () => {
|
|
81
|
-
return sfu.createChat({
|
|
82
|
-
id: CHANNEL_ID,
|
|
83
|
-
name: CHANNEL_NAME,
|
|
84
|
-
members: [USER2],
|
|
85
|
-
channel: true,
|
|
86
|
-
channelType: "PUBLIC",
|
|
87
|
-
channelSendPolicy: "ADMIN_AND_LIST",
|
|
88
|
-
sendPermissionList: [USER2]
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
test("should load public channels", async () => {
|
|
92
|
-
const channels = await sfu.getPublicChannels();
|
|
93
|
-
expect(channels).toBeTruthy();
|
|
94
|
-
expect(channels).toHaveProperty(CHANNEL_ID);
|
|
95
|
-
});
|
|
96
|
-
test("channel should appear in loaded chats", async () => {
|
|
97
|
-
const chats = await sfu.getUserChats();
|
|
98
|
-
expect(chats).toBeTruthy();
|
|
99
|
-
expect(chats).toHaveProperty(CHANNEL_ID);
|
|
100
|
-
});
|
|
101
|
-
test("should load channel", async () => {
|
|
102
|
-
const chat = await sfu.loadChat({id: CHANNEL_ID});
|
|
103
|
-
expect(chat.id).toBe(CHANNEL_ID);
|
|
104
|
-
expect(chat.name).toBe(CHANNEL_NAME);
|
|
105
|
-
expect(chat.members).toContain(USER);
|
|
106
|
-
expect(chat.channel).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
test("should load chats", () => {
|
|
110
|
-
return sfu.getUserChats().then((chats) => {
|
|
111
|
-
expect(chats).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
test("should add new member", () => {
|
|
115
|
-
return sfu.addMemberToChat({
|
|
116
|
-
id: CHAT_ID,
|
|
117
|
-
member: USER2
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
test("should send a message", () => {
|
|
121
|
-
return sfu.sendMessage({
|
|
122
|
-
chatId: CHAT_ID,
|
|
123
|
-
body: MESSAGE_BODY
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
test("should send message with attachment", () => {
|
|
127
|
-
const file = fs.readFileSync(path.resolve(__dirname, FILE));
|
|
128
|
-
let byteArray = new Uint8Array(file);
|
|
129
|
-
let base64Content = Buffer.from(byteArray).toString('base64');
|
|
130
|
-
return sfu.sendMessage({
|
|
131
|
-
chatId: CHAT_ID,
|
|
132
|
-
body: MESSAGE_BODY,
|
|
133
|
-
attachments: [
|
|
134
|
-
{
|
|
135
|
-
type: "file",
|
|
136
|
-
name: FILE,
|
|
137
|
-
payload: base64Content,
|
|
138
|
-
size: byteArray.length
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
test("should mark message as read", async () => {
|
|
144
|
-
const msg = await sfu.sendMessage({
|
|
145
|
-
chatId: CHAT_ID,
|
|
146
|
-
body: MESSAGE_BODY
|
|
147
|
-
});
|
|
148
|
-
const freshState = await sfu.markMessageRead(msg);
|
|
149
|
-
expect(freshState.lastReadMessageId).toBeTruthy();
|
|
150
|
-
expect(freshState).toBeTruthy();
|
|
151
|
-
});
|
|
152
|
-
test("should mark message as unread", async () => {
|
|
153
|
-
const msg1 = await sfu.sendMessage({
|
|
154
|
-
chatId: CHAT_ID,
|
|
155
|
-
body: MESSAGE_BODY
|
|
156
|
-
});
|
|
157
|
-
const msg2 = await sfu.sendMessage({
|
|
158
|
-
chatId: CHAT_ID,
|
|
159
|
-
body: MESSAGE_BODY
|
|
160
|
-
});
|
|
161
|
-
const freshState = await sfu.markMessageUnread(msg2);
|
|
162
|
-
expect(freshState).toBeTruthy();
|
|
163
|
-
expect(freshState.lastReadMessageId).toBeTruthy();
|
|
164
|
-
expect(freshState.lastReadMessageId).toEqual(msg1.id);
|
|
165
|
-
});
|
|
166
|
-
test("should load chat", () => {
|
|
167
|
-
return sfu.loadChat({
|
|
168
|
-
id: CHAT_ID
|
|
169
|
-
}).then((chat) => {
|
|
170
|
-
expect(chat.id).toBe(CHAT_ID);
|
|
171
|
-
expect(chat.name).toBe(CHAT_NAME);
|
|
172
|
-
expect(chat.members).toContain(USER);
|
|
173
|
-
expect(Array.isArray(chat.messages)).toBe(true);
|
|
174
|
-
expect(chat.messages.length).toBeGreaterThan(0);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
test("should remove member", () => {
|
|
178
|
-
return sfu.removeMemberFromChat({
|
|
179
|
-
id: CHAT_ID,
|
|
180
|
-
member: USER2
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
test("should rename chat", () => {
|
|
184
|
-
return sfu.renameChat({
|
|
185
|
-
id: CHAT_ID,
|
|
186
|
-
name: CHAT_NAME2
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
test("should invite contact", async () => {
|
|
190
|
-
const contact = await sfu.inviteContact({
|
|
191
|
-
to: USER2
|
|
192
|
-
});
|
|
193
|
-
expect(contact).toBeTruthy();
|
|
194
|
-
expect(contact.invite).toBeTruthy();
|
|
195
|
-
expect(contact.invite.id).toBeTruthy();
|
|
196
|
-
});
|
|
197
|
-
test("should confirm invite", async () => {
|
|
198
|
-
const contacts = await sfu2.getUserList();
|
|
199
|
-
let unconfirmedContact;
|
|
200
|
-
contacts.every((contact) => {
|
|
201
|
-
if (contact.invite && contact.invite.from !== USER2) {
|
|
202
|
-
unconfirmedContact = contact;
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
return true;
|
|
206
|
-
});
|
|
207
|
-
expect(unconfirmedContact).toBeTruthy();
|
|
208
|
-
const contact = await sfu2.confirmContact(unconfirmedContact.invite);
|
|
209
|
-
expect(contact).toBeTruthy();
|
|
210
|
-
expect(contact.confirmed).toEqual(true);
|
|
211
|
-
});
|
|
212
|
-
test("should remove contact", async () => {
|
|
213
|
-
const contact = await sfu.removeContact({
|
|
214
|
-
id: USER2
|
|
215
|
-
});
|
|
216
|
-
expect(contact).toBeTruthy();
|
|
217
|
-
});
|
|
218
|
-
test.skip("should receive message", (done) => {
|
|
219
|
-
sfu.on(constants.SFU_EVENT.MESSAGE, (msg) => {
|
|
220
|
-
done();
|
|
221
|
-
})
|
|
222
|
-
sfu.sendMessage({
|
|
223
|
-
chatId: CHAT_ID,
|
|
224
|
-
body: MESSAGE_BODY
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
test("should receive ACK message", async () => {
|
|
228
|
-
const msg = await sfu.sendMessage({
|
|
229
|
-
chatId: CHAT_ID,
|
|
230
|
-
body: MESSAGE_BODY
|
|
231
|
-
});
|
|
232
|
-
expect(msg).toBeTruthy();
|
|
233
|
-
expect(msg.id).toBeTruthy();
|
|
234
|
-
expect(msg.date).toBeTruthy();
|
|
235
|
-
});
|
|
236
|
-
test("should create new chat without id", () => {
|
|
237
|
-
return sfu.createChat({
|
|
238
|
-
name: CHAT_NAME
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
test("should create new chat with member list", () => {
|
|
242
|
-
return sfu.createChat({
|
|
243
|
-
name: CHAT_NAME,
|
|
244
|
-
members: MEMBERS
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
test("should create new chat without name based on members", async () => {
|
|
248
|
-
const chat = await sfu.createChat({
|
|
249
|
-
members: MEMBERS
|
|
250
|
-
});
|
|
251
|
-
expect(chat.name).toBeTruthy();
|
|
252
|
-
});
|
|
253
|
-
test("should delete chat", () => {
|
|
254
|
-
return sfu.deleteChat({
|
|
255
|
-
id: CHAT_ID
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
test("should change name after member was added", async () => {
|
|
259
|
-
const chat = await sfu.createChat({});
|
|
260
|
-
expect(chat.name).toBeTruthy();
|
|
261
|
-
const name1 = chat.name;
|
|
262
|
-
const sameChat = await sfu.addMemberToChat({id: chat.id, member: USER2});
|
|
263
|
-
expect(sameChat.name !== name1).toBeTruthy();
|
|
264
|
-
});
|
|
265
|
-
});
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const sfu = require("../../sdk/sfu-extended");
|
|
4
|
-
const constants = require("../../sdk/constants");
|
|
5
|
-
|
|
6
|
-
const SERVER = "ws://127.0.0.1:8080";
|
|
7
|
-
const USER = "bob@flashphoner.com";
|
|
8
|
-
const PASSWD = "123456";
|
|
9
|
-
const CHAT_ID = "test-chat-id";
|
|
10
|
-
const CHANNEL_ID = "test-channel-id";
|
|
11
|
-
const CHANNEL_NAME = "test-channel";
|
|
12
|
-
const CHAT_NAME = "test-chat";
|
|
13
|
-
const CHAT_NAME2 = "test-chat2";
|
|
14
|
-
const USER2 = "alice@flashphoner.com";
|
|
15
|
-
const MESSAGE_BODY = "This is a test message";
|
|
16
|
-
const MEMBERS = [
|
|
17
|
-
"bob@flashphoner.com",
|
|
18
|
-
"alice@flashphoner.com",
|
|
19
|
-
"kiri@flashphoner.com"
|
|
20
|
-
];
|
|
21
|
-
const FILE = "../assets/1.jpeg";
|
|
22
|
-
|
|
23
|
-
jest.isolateModules(() => {
|
|
24
|
-
sfu2 = require("../../sdk/sfu-extended");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
beforeAll( async () => {
|
|
28
|
-
await sfu.connect({
|
|
29
|
-
url: SERVER,
|
|
30
|
-
username: USER,
|
|
31
|
-
password: PASSWD
|
|
32
|
-
});
|
|
33
|
-
const chats = await sfu.getUserChats();
|
|
34
|
-
if (chats) {
|
|
35
|
-
Object.entries(chats).map(async ([key, value]) => {
|
|
36
|
-
await sfu.deleteChat({id: value.id});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
await sfu2.connect({
|
|
40
|
-
url: SERVER,
|
|
41
|
-
username: USER2,
|
|
42
|
-
password: PASSWD
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterAll(async () => {
|
|
47
|
-
await sfu.disconnect();
|
|
48
|
-
await sfu2.disconnect();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
describe("connection", () => {
|
|
53
|
-
test("should connect to server", () => {
|
|
54
|
-
expect(sfu.state()).toBe(constants.SFU_STATE.AUTHENTICATED);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe("contacts", () => {
|
|
59
|
-
test("should load user list", () => {
|
|
60
|
-
return sfu.getUserList();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("calendar", () => {
|
|
65
|
-
test("should load calendar", () => {
|
|
66
|
-
return sfu.getUserCalendar().then((calendar) => {
|
|
67
|
-
expect(calendar).toHaveProperty("events");
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("chat", () => {
|
|
73
|
-
test("should create new chat", () => {
|
|
74
|
-
return sfu.createChat({
|
|
75
|
-
id: CHAT_ID,
|
|
76
|
-
name: CHAT_NAME
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe("channels", () => {
|
|
80
|
-
test("should create new channel", () => {
|
|
81
|
-
return sfu.createChat({
|
|
82
|
-
id: CHANNEL_ID,
|
|
83
|
-
name: CHANNEL_NAME,
|
|
84
|
-
members: [USER2],
|
|
85
|
-
channel: true,
|
|
86
|
-
channelType: "PUBLIC",
|
|
87
|
-
channelSendPolicy: "ADMIN_AND_LIST",
|
|
88
|
-
sendPermissionList: [USER2]
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
test("should load public channels", async () => {
|
|
92
|
-
const channels = await sfu.getPublicChannels();
|
|
93
|
-
expect(channels).toBeTruthy();
|
|
94
|
-
expect(channels).toHaveProperty(CHANNEL_ID);
|
|
95
|
-
});
|
|
96
|
-
test("channel should appear in loaded chats", async () => {
|
|
97
|
-
const chats = await sfu.getUserChats();
|
|
98
|
-
expect(chats).toBeTruthy();
|
|
99
|
-
expect(chats).toHaveProperty(CHANNEL_ID);
|
|
100
|
-
});
|
|
101
|
-
test("should load channel", async () => {
|
|
102
|
-
const chat = await sfu.loadChat({id: CHANNEL_ID});
|
|
103
|
-
expect(chat.id).toBe(CHANNEL_ID);
|
|
104
|
-
expect(chat.name).toBe(CHANNEL_NAME);
|
|
105
|
-
expect(chat.members).toContain(USER);
|
|
106
|
-
expect(chat.channel).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
test("should load chats", () => {
|
|
110
|
-
return sfu.getUserChats().then((chats) => {
|
|
111
|
-
expect(chats).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
test("should add new member", () => {
|
|
115
|
-
return sfu.addMemberToChat({
|
|
116
|
-
id: CHAT_ID,
|
|
117
|
-
member: USER2
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
test("should send a message", () => {
|
|
121
|
-
return sfu.sendMessage({
|
|
122
|
-
chatId: CHAT_ID,
|
|
123
|
-
body: MESSAGE_BODY
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
test("should send message with attachment", () => {
|
|
127
|
-
const file = fs.readFileSync(path.resolve(__dirname, FILE));
|
|
128
|
-
let byteArray = new Uint8Array(file);
|
|
129
|
-
let base64Content = Buffer.from(byteArray).toString('base64');
|
|
130
|
-
return sfu.sendMessage({
|
|
131
|
-
chatId: CHAT_ID,
|
|
132
|
-
body: MESSAGE_BODY,
|
|
133
|
-
attachments: [
|
|
134
|
-
{
|
|
135
|
-
type: "file",
|
|
136
|
-
name: FILE,
|
|
137
|
-
payload: base64Content,
|
|
138
|
-
size: byteArray.length
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
test("should mark message as read", async () => {
|
|
144
|
-
const msg = await sfu.sendMessage({
|
|
145
|
-
chatId: CHAT_ID,
|
|
146
|
-
body: MESSAGE_BODY
|
|
147
|
-
});
|
|
148
|
-
const freshState = await sfu.markMessageRead(msg);
|
|
149
|
-
expect(freshState.lastReadMessageId).toBeTruthy();
|
|
150
|
-
expect(freshState).toBeTruthy();
|
|
151
|
-
});
|
|
152
|
-
test("should mark message as unread", async () => {
|
|
153
|
-
const msg1 = await sfu.sendMessage({
|
|
154
|
-
chatId: CHAT_ID,
|
|
155
|
-
body: MESSAGE_BODY
|
|
156
|
-
});
|
|
157
|
-
const msg2 = await sfu.sendMessage({
|
|
158
|
-
chatId: CHAT_ID,
|
|
159
|
-
body: MESSAGE_BODY
|
|
160
|
-
});
|
|
161
|
-
const freshState = await sfu.markMessageUnread(msg2);
|
|
162
|
-
expect(freshState).toBeTruthy();
|
|
163
|
-
expect(freshState.lastReadMessageId).toBeTruthy();
|
|
164
|
-
expect(freshState.lastReadMessageId).toEqual(msg1.id);
|
|
165
|
-
});
|
|
166
|
-
test("should load chat", () => {
|
|
167
|
-
return sfu.loadChat({
|
|
168
|
-
id: CHAT_ID
|
|
169
|
-
}).then((chat) => {
|
|
170
|
-
expect(chat.id).toBe(CHAT_ID);
|
|
171
|
-
expect(chat.name).toBe(CHAT_NAME);
|
|
172
|
-
expect(chat.members).toContain(USER);
|
|
173
|
-
expect(Array.isArray(chat.messages)).toBe(true);
|
|
174
|
-
expect(chat.messages.length).toBeGreaterThan(0);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
test("should remove member", () => {
|
|
178
|
-
return sfu.removeMemberFromChat({
|
|
179
|
-
id: CHAT_ID,
|
|
180
|
-
member: USER2
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
test("should rename chat", () => {
|
|
184
|
-
return sfu.renameChat({
|
|
185
|
-
id: CHAT_ID,
|
|
186
|
-
name: CHAT_NAME2
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
test("should invite contact", async () => {
|
|
190
|
-
const contact = await sfu.inviteContact({
|
|
191
|
-
to: USER2
|
|
192
|
-
});
|
|
193
|
-
expect(contact).toBeTruthy();
|
|
194
|
-
expect(contact.invite).toBeTruthy();
|
|
195
|
-
expect(contact.invite.id).toBeTruthy();
|
|
196
|
-
});
|
|
197
|
-
test("should confirm invite", async () => {
|
|
198
|
-
const contacts = await sfu2.getUserList();
|
|
199
|
-
let unconfirmedContact;
|
|
200
|
-
contacts.every((contact) => {
|
|
201
|
-
if (contact.invite && contact.invite.from !== USER2) {
|
|
202
|
-
unconfirmedContact = contact;
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
return true;
|
|
206
|
-
});
|
|
207
|
-
expect(unconfirmedContact).toBeTruthy();
|
|
208
|
-
const contact = await sfu2.confirmContact(unconfirmedContact.invite);
|
|
209
|
-
expect(contact).toBeTruthy();
|
|
210
|
-
expect(contact.confirmed).toEqual(true);
|
|
211
|
-
});
|
|
212
|
-
test("should remove contact", async () => {
|
|
213
|
-
const contact = await sfu.removeContact({
|
|
214
|
-
id: USER2
|
|
215
|
-
});
|
|
216
|
-
expect(contact).toBeTruthy();
|
|
217
|
-
});
|
|
218
|
-
test.skip("should receive message", (done) => {
|
|
219
|
-
sfu.on(constants.SFU_EVENT.MESSAGE, (msg) => {
|
|
220
|
-
done();
|
|
221
|
-
})
|
|
222
|
-
sfu.sendMessage({
|
|
223
|
-
chatId: CHAT_ID,
|
|
224
|
-
body: MESSAGE_BODY
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
test("should receive ACK message", async () => {
|
|
228
|
-
const msg = await sfu.sendMessage({
|
|
229
|
-
chatId: CHAT_ID,
|
|
230
|
-
body: MESSAGE_BODY
|
|
231
|
-
});
|
|
232
|
-
expect(msg).toBeTruthy();
|
|
233
|
-
expect(msg.id).toBeTruthy();
|
|
234
|
-
expect(msg.date).toBeTruthy();
|
|
235
|
-
});
|
|
236
|
-
test("should create new chat without id", () => {
|
|
237
|
-
return sfu.createChat({
|
|
238
|
-
name: CHAT_NAME
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
test("should create new chat with member list", () => {
|
|
242
|
-
return sfu.createChat({
|
|
243
|
-
name: CHAT_NAME,
|
|
244
|
-
members: MEMBERS
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
test("should create new chat without name based on members", async () => {
|
|
248
|
-
const chat = await sfu.createChat({
|
|
249
|
-
members: MEMBERS
|
|
250
|
-
});
|
|
251
|
-
expect(chat.name).toBeTruthy();
|
|
252
|
-
});
|
|
253
|
-
test("should delete chat", () => {
|
|
254
|
-
return sfu.deleteChat({
|
|
255
|
-
id: CHAT_ID
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
test("should change name after member was added", async () => {
|
|
259
|
-
const chat = await sfu.createChat({});
|
|
260
|
-
expect(chat.name).toBeTruthy();
|
|
261
|
-
const name1 = chat.name;
|
|
262
|
-
const sameChat = await sfu.addMemberToChat({id: chat.id, member: USER2});
|
|
263
|
-
expect(sameChat.name !== name1).toBeTruthy();
|
|
264
|
-
});
|
|
265
|
-
});
|
package/src/tests/util.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const waitForTrack = (pc, track) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
pc.ontrack = ({transceiver}) => {
|
|
4
|
-
if (transceiver.mid === track.mid) {
|
|
5
|
-
resolve(transceiver.receiver.track);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const waitForTracks = (pc, tracks) => {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
let waitingFor = tracks.length;
|
|
14
|
-
const trackArrived = () => {
|
|
15
|
-
waitingFor--;
|
|
16
|
-
if (waitingFor === 0) {
|
|
17
|
-
resolve();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
for (const track of tracks) {
|
|
21
|
-
waitForTrack(pc, track).then(trackArrived);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const waitForPeerConnectionStableState = (pc) => {
|
|
27
|
-
return waitForPeerConnectionState(pc, "stable");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const waitForPeerConnectionState = (pc, state) => {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
if (pc.signalingState === state) {
|
|
33
|
-
resolve();
|
|
34
|
-
}
|
|
35
|
-
pc.onsignalingstatechange = (e) => {
|
|
36
|
-
if (pc.signalingState === state) {
|
|
37
|
-
resolve();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
waitForTrack: waitForTrack,
|
|
45
|
-
waitForTracks: waitForTracks,
|
|
46
|
-
waitForPeerConnectionState: waitForPeerConnectionState,
|
|
47
|
-
waitForPeerConnectionStableState: waitForPeerConnectionStableState
|
|
48
|
-
}
|