@jibb-open/jssdk 3.17.6 → 3.18.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/api/auth.js +126 -1
- package/api/cisco.js +37 -1
- package/api/eventbus.js +150 -1
- package/api/index.js +21 -1
- package/api/meeting.js +332 -1
- package/api/recording.js +55 -1
- package/api/user.js +24 -1
- package/api/webexbot.js +23 -1
- package/api/whiteboard.js +116 -1
- package/config.js +9 -1
- package/package.json +3 -1
- package/types/exceptions.js +68 -1
- package/types/jibb.pb.js +7067 -1
- package/types/proto.js +5 -1
- package/types/types.js +167 -1
- package/utils/cached_variable.js +18 -1
- package/utils/future.js +24 -1
- package/utils/http/http.axios.js +38 -1
- package/utils/http/index.js +9 -1
- package/utils/index.js +4 -1
- package/utils/logger/index.js +9 -1
- package/utils/logger/logger.empty.js +9 -1
- package/utils/logger/logger.pino.js +12 -1
- package/ws/connection_base.js +125 -1
- package/ws/eventbus.js +293 -1
- package/ws/index.js +11 -1
- package/ws/ipsa.js +161 -1
- package/ws/meeting.js +179 -1
- package/ws/observable_connection.js +91 -1
- package/ws/retry_connection.js +107 -1
package/ws/eventbus.js
CHANGED
|
@@ -1 +1,293 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.array-buffer.constructor.js";
|
|
2
|
+
import "core-js/modules/es.array-buffer.slice.js";
|
|
3
|
+
import "core-js/modules/es.promise.js";
|
|
4
|
+
import "core-js/modules/es.typed-array.uint8-array.js";
|
|
5
|
+
import "core-js/modules/es.typed-array.fill.js";
|
|
6
|
+
import "core-js/modules/es.typed-array.set.js";
|
|
7
|
+
import "core-js/modules/es.typed-array.sort.js";
|
|
8
|
+
import "core-js/modules/es.typed-array.to-locale-string.js";
|
|
9
|
+
import "core-js/modules/es.weak-map.js";
|
|
10
|
+
import "core-js/modules/esnext.aggregate-error.js";
|
|
11
|
+
import "core-js/modules/esnext.promise.any.js";
|
|
12
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
13
|
+
import "core-js/modules/web.url.js";
|
|
14
|
+
import "core-js/modules/web.url.to-json.js";
|
|
15
|
+
import "core-js/modules/web.url-search-params.js";
|
|
16
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
17
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
18
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
19
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
20
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
21
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
22
|
+
import { Config } from "../config.js";
|
|
23
|
+
import { logger } from "../utils/logger/index.js";
|
|
24
|
+
import { InvalidArgumentError, PermissionDeniedError, SessionTimeoutError } from '../types/exceptions.js';
|
|
25
|
+
import { UserClaims } from "../types/types.js";
|
|
26
|
+
import { types, cilix } from "../types/proto.js";
|
|
27
|
+
import { getUserToken } from "../api/auth.js";
|
|
28
|
+
import { Observable, ObservableRetryConnection } from "./observable_connection.js";
|
|
29
|
+
const ClientType = types.ClientType;
|
|
30
|
+
const BusMessage = cilix.BusMessage;
|
|
31
|
+
let clientType = ClientType.WEBAPP;
|
|
32
|
+
let clientName = "client";
|
|
33
|
+
let instance = undefined;
|
|
34
|
+
const observable = new Observable();
|
|
35
|
+
var _expiryTimer = /*#__PURE__*/new WeakMap();
|
|
36
|
+
var _EventBusConnection_brand = /*#__PURE__*/new WeakSet();
|
|
37
|
+
class EventBusConnection extends ObservableRetryConnection {
|
|
38
|
+
static getInstance() {
|
|
39
|
+
if (!instance) instance = new EventBusConnection();
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
static addEventListener(observer) {
|
|
43
|
+
return observable.addEventListener(observer);
|
|
44
|
+
}
|
|
45
|
+
static removeEventListener(id) {
|
|
46
|
+
observable.removeEventListener(id);
|
|
47
|
+
}
|
|
48
|
+
static setClientName(name) {
|
|
49
|
+
clientName = name;
|
|
50
|
+
}
|
|
51
|
+
static setClientType(t) {
|
|
52
|
+
clientType = t;
|
|
53
|
+
}
|
|
54
|
+
constructor() {
|
|
55
|
+
super("eventbus-".concat(clientName));
|
|
56
|
+
_classPrivateMethodInitSpec(this, _EventBusConnection_brand);
|
|
57
|
+
_classPrivateFieldInitSpec(this, _expiryTimer, void 0);
|
|
58
|
+
this.observable = observable;
|
|
59
|
+
this.userToken = null;
|
|
60
|
+
_classPrivateFieldSet(_expiryTimer, this, null);
|
|
61
|
+
}
|
|
62
|
+
async stop() {
|
|
63
|
+
clearTimeout(_classPrivateFieldGet(_expiryTimer, this));
|
|
64
|
+
super.stop();
|
|
65
|
+
}
|
|
66
|
+
async write(msg) {
|
|
67
|
+
logger.debug("".concat(this.name, ".write: "), BusMessage.toObject(msg));
|
|
68
|
+
let data = BusMessage.encode(msg).finish();
|
|
69
|
+
return super.write(data);
|
|
70
|
+
}
|
|
71
|
+
writeObject(msg) {
|
|
72
|
+
let err = BusMessage.verify(msg);
|
|
73
|
+
if (err) throw new Error(err);
|
|
74
|
+
let request = BusMessage.fromObject(msg);
|
|
75
|
+
return this.write(request);
|
|
76
|
+
}
|
|
77
|
+
async getURI() {
|
|
78
|
+
try {
|
|
79
|
+
this.userToken = await getUserToken();
|
|
80
|
+
this.userClaims = new UserClaims(this.userToken);
|
|
81
|
+
let seconds = this.userClaims.getSecondsUntilExpiry();
|
|
82
|
+
if (seconds <= 0) {
|
|
83
|
+
let e = new PermissionDeniedError("user token expired");
|
|
84
|
+
this.onError(e);
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
_classPrivateFieldSet(_expiryTimer, this, setTimeout(() => {
|
|
88
|
+
this.onError(new SessionTimeoutError("user token expired"));
|
|
89
|
+
}, seconds));
|
|
90
|
+
} catch (err) {
|
|
91
|
+
let e = new PermissionDeniedError(err);
|
|
92
|
+
this.onError(e);
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
let base = new URL(Config.apiBaseURL);
|
|
96
|
+
let url = base.host + (base.pathname !== '/' ? base.pathname : '');
|
|
97
|
+
let typeStr = _assertClassBrand(_EventBusConnection_brand, this, _getClientTypeAsString).call(this, clientType);
|
|
98
|
+
return "wss://".concat(url, "/ws/eventbus/").concat(typeStr, "?user_token=").concat(this.userToken, "&name=").concat(clientName);
|
|
99
|
+
}
|
|
100
|
+
onData(msg) {
|
|
101
|
+
try {
|
|
102
|
+
if (msg instanceof ArrayBuffer) {
|
|
103
|
+
let buffer = new Uint8Array(msg);
|
|
104
|
+
let response = BusMessage.decode(buffer);
|
|
105
|
+
buffer = null;
|
|
106
|
+
logger.debug("".concat(this.name, ".read: "), response);
|
|
107
|
+
_assertClassBrand(_EventBusConnection_brand, this, _onMessage).call(this, response);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
logger.error(err);
|
|
112
|
+
}
|
|
113
|
+
this.parseJSONResponse(msg);
|
|
114
|
+
}
|
|
115
|
+
stopStream(clientId) {
|
|
116
|
+
return this.writeObject({
|
|
117
|
+
stopRequest: {},
|
|
118
|
+
dst: {
|
|
119
|
+
id: clientId
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
stopAllStreams() {
|
|
124
|
+
return this.writeObject({
|
|
125
|
+
stopRequest: {}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
startStream(_ref) {
|
|
129
|
+
let {
|
|
130
|
+
config,
|
|
131
|
+
runtimeConfig,
|
|
132
|
+
camera,
|
|
133
|
+
clientId,
|
|
134
|
+
meetingToken
|
|
135
|
+
} = _ref;
|
|
136
|
+
return this.writeObject({
|
|
137
|
+
startRequest: {
|
|
138
|
+
config,
|
|
139
|
+
runtimeConfig,
|
|
140
|
+
camera,
|
|
141
|
+
meetingToken
|
|
142
|
+
},
|
|
143
|
+
dst: {
|
|
144
|
+
id: clientId
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
requestCameraPreview(clientId, sourceId) {
|
|
149
|
+
return this.writeObject({
|
|
150
|
+
previewRequest: {
|
|
151
|
+
source: {
|
|
152
|
+
id: sourceId
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
dst: {
|
|
156
|
+
id: clientId
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
setRuntimeConfig(clientId, cfg) {
|
|
161
|
+
return this.writeObject({
|
|
162
|
+
runtimeConfigRequest: cfg,
|
|
163
|
+
dst: {
|
|
164
|
+
id: clientId
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
getCameraList(clientId) {
|
|
169
|
+
return this.writeObject({
|
|
170
|
+
cameraListRequest: {},
|
|
171
|
+
dst: {
|
|
172
|
+
id: clientId
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
sendCameraList(camList, src, dst) {
|
|
177
|
+
let response = {
|
|
178
|
+
cameraListResponse: {
|
|
179
|
+
items: camList
|
|
180
|
+
},
|
|
181
|
+
src: src,
|
|
182
|
+
dst: dst
|
|
183
|
+
};
|
|
184
|
+
return this.writeObject(response);
|
|
185
|
+
}
|
|
186
|
+
getClientStatusList() {
|
|
187
|
+
let request = {
|
|
188
|
+
clientStatusRequest: {}
|
|
189
|
+
};
|
|
190
|
+
return this.writeObject(request);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function _onMessage(msg) {
|
|
194
|
+
if (!msg || typeof msg !== 'object') return;
|
|
195
|
+
try {
|
|
196
|
+
msg.clientConnected && _assertClassBrand(_EventBusConnection_brand, this, _onClientConnected).call(this, msg);
|
|
197
|
+
msg.clientDisconnected && _assertClassBrand(_EventBusConnection_brand, this, _onClientDisconnected).call(this, msg);
|
|
198
|
+
msg.cameraListRequest && _assertClassBrand(_EventBusConnection_brand, this, _onCameraListRequest).call(this, msg);
|
|
199
|
+
msg.cameraListResponse && _assertClassBrand(_EventBusConnection_brand, this, _onCameraListResponse).call(this, msg);
|
|
200
|
+
msg.runtimeConfigRequest && _assertClassBrand(_EventBusConnection_brand, this, _onRuntimeConfigRequest).call(this, msg);
|
|
201
|
+
msg.startRequest && _assertClassBrand(_EventBusConnection_brand, this, _onStartRequest).call(this, msg);
|
|
202
|
+
msg.stopRequest && _assertClassBrand(_EventBusConnection_brand, this, _onStopRequest).call(this, msg);
|
|
203
|
+
msg.previewRequest && _assertClassBrand(_EventBusConnection_brand, this, _onPreviewRequest).call(this, msg);
|
|
204
|
+
msg.previewResponse && _assertClassBrand(_EventBusConnection_brand, this, _onPreviewResponse).call(this, msg);
|
|
205
|
+
msg.ipsaResponse && _assertClassBrand(_EventBusConnection_brand, this, _onIPSAResponse).call(this, msg);
|
|
206
|
+
msg.tooManyPublishers && _assertClassBrand(_EventBusConnection_brand, this, _onTooManyPublishers).call(this, msg);
|
|
207
|
+
msg.recordingStarted && _assertClassBrand(_EventBusConnection_brand, this, _onRecordingStarted).call(this, msg);
|
|
208
|
+
msg.recordingStopped && _assertClassBrand(_EventBusConnection_brand, this, _onRecordingStopped).call(this, msg);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
logger.error(e);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function _getClientTypeAsString(clientType) {
|
|
214
|
+
let found = Object.entries(ClientType).find(_ref2 => {
|
|
215
|
+
let [k, v] = _ref2;
|
|
216
|
+
return v == clientType;
|
|
217
|
+
});
|
|
218
|
+
if (!found) throw new InvalidArgumentError("Invalid client type: ".concat(clientType));
|
|
219
|
+
let name = found[0].toLowerCase();
|
|
220
|
+
return name;
|
|
221
|
+
}
|
|
222
|
+
function _sendPreview(image, dst) {
|
|
223
|
+
this.writeObject({
|
|
224
|
+
previewResponse: {
|
|
225
|
+
image: image
|
|
226
|
+
},
|
|
227
|
+
dst: dst
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async function _onCameraListRequest(msg) {
|
|
231
|
+
let response = await _assertClassBrand(_EventBusConnection_brand, this, _callSubscribers).call(this, 'onCameraListRequest', msg.cameraListRequest);
|
|
232
|
+
this.sendCameraList(response, msg.dst, msg.src);
|
|
233
|
+
}
|
|
234
|
+
function _onCameraListResponse(msg) {
|
|
235
|
+
observable.notify('onCameraListResponse', msg.cameraListResponse);
|
|
236
|
+
}
|
|
237
|
+
function _onClientConnected(msg) {
|
|
238
|
+
logger.info("".concat(this.name, ": client connected: "), msg.src);
|
|
239
|
+
observable.notify('onClientConnected', msg.src);
|
|
240
|
+
}
|
|
241
|
+
function _onClientDisconnected(msg) {
|
|
242
|
+
logger.warn("".concat(this.name, ": client disconnected: "), msg.src);
|
|
243
|
+
observable.notify('onClientDisconnected', msg.src);
|
|
244
|
+
}
|
|
245
|
+
function _onRuntimeConfigRequest(msg) {
|
|
246
|
+
observable.notify('onRuntimeConfigRequest', msg.runtimeConfigRequest);
|
|
247
|
+
}
|
|
248
|
+
function _onStopRequest(msg) {
|
|
249
|
+
observable.notify('onStopRequest', msg.stopRequest);
|
|
250
|
+
}
|
|
251
|
+
async function _onPreviewRequest(msg) {
|
|
252
|
+
let response = await _assertClassBrand(_EventBusConnection_brand, this, _callSubscribers).call(this, 'onPreviewRequest', msg.previewRequest);
|
|
253
|
+
_assertClassBrand(_EventBusConnection_brand, this, _sendPreview).call(this, response, msg.src);
|
|
254
|
+
}
|
|
255
|
+
function _onPreviewResponse(msg) {
|
|
256
|
+
observable.notify('onPreviewResponse', msg.previewResponse);
|
|
257
|
+
}
|
|
258
|
+
function _onStartRequest(msg) {
|
|
259
|
+
var _req$camera, _req$inputSource;
|
|
260
|
+
let req = msg.startRequest;
|
|
261
|
+
if (!(req !== null && req !== void 0 && (_req$camera = req.camera) !== null && _req$camera !== void 0 && _req$camera.id) && req !== null && req !== void 0 && (_req$inputSource = req.inputSource) !== null && _req$inputSource !== void 0 && _req$inputSource.id) {
|
|
262
|
+
req.camera = {
|
|
263
|
+
id: req.inputSource.id
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
observable.notify('onStartRequest', req);
|
|
267
|
+
}
|
|
268
|
+
function _onCornersReceived(msg) {
|
|
269
|
+
observable.notify('onCornersReceived', msg.corners.corners);
|
|
270
|
+
}
|
|
271
|
+
function _onIPSAResponse(msg) {
|
|
272
|
+
msg && observable.notify('onIPSAResponse', msg.ipsaResponse);
|
|
273
|
+
}
|
|
274
|
+
function _onTooManyPublishers(msg) {
|
|
275
|
+
observable.notify('onTooManyPublishers', msg.tooManyPublishers);
|
|
276
|
+
}
|
|
277
|
+
function _onRecordingStarted(msg) {
|
|
278
|
+
observable.notify('onRecordingStarted', msg.recordingStarted);
|
|
279
|
+
}
|
|
280
|
+
function _onRecordingStopped(msg) {
|
|
281
|
+
observable.notify('onRecordingStopped', msg.recordingStopped);
|
|
282
|
+
}
|
|
283
|
+
function _callSubscribers(functionName) {
|
|
284
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
285
|
+
args[_key - 1] = arguments[_key];
|
|
286
|
+
}
|
|
287
|
+
let promises = [...observable.observers].map(_ref3 => {
|
|
288
|
+
let [k, o] = _ref3;
|
|
289
|
+
return o[functionName];
|
|
290
|
+
}).filter(fn => fn !== undefined).map(fn => fn(...args));
|
|
291
|
+
return Promise.any(promises);
|
|
292
|
+
}
|
|
293
|
+
export { EventBusConnection };
|
package/ws/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.global-this.js";
|
|
2
|
+
import "core-js/modules/es.promise.js";
|
|
3
|
+
import { EventBusConnection } from "./eventbus.js";
|
|
4
|
+
import { IPSA } from "./ipsa.js";
|
|
5
|
+
import { MeetingConnection } from "./meeting.js";
|
|
6
|
+
if ((globalThis === null || globalThis === void 0 ? void 0 : globalThis.WebSocket) == undefined) {
|
|
7
|
+
import("isomorphic-ws").then(webSocket => {
|
|
8
|
+
globalThis.WebSocket = webSocket.default;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { MeetingConnection, EventBusConnection, IPSA };
|
package/ws/ipsa.js
CHANGED
|
@@ -1 +1,161 @@
|
|
|
1
|
-
|
|
1
|
+
var _IPSAClass;
|
|
2
|
+
import "core-js/modules/es.array-buffer.constructor.js";
|
|
3
|
+
import "core-js/modules/es.array-buffer.slice.js";
|
|
4
|
+
import "core-js/modules/es.promise.js";
|
|
5
|
+
import "core-js/modules/es.typed-array.uint8-array.js";
|
|
6
|
+
import "core-js/modules/es.typed-array.fill.js";
|
|
7
|
+
import "core-js/modules/es.typed-array.set.js";
|
|
8
|
+
import "core-js/modules/es.typed-array.sort.js";
|
|
9
|
+
import "core-js/modules/es.typed-array.to-locale-string.js";
|
|
10
|
+
import "core-js/modules/es.weak-map.js";
|
|
11
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
12
|
+
import "core-js/modules/web.url.js";
|
|
13
|
+
import "core-js/modules/web.url.to-json.js";
|
|
14
|
+
import "core-js/modules/web.url-search-params.js";
|
|
15
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
16
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
17
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
20
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
21
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
22
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
23
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
24
|
+
import { Config as SDKConfig } from "../config.js";
|
|
25
|
+
import { logger } from "../utils/logger/index.js";
|
|
26
|
+
import { MeetingClaims, UserClaims } from "../types/types.js";
|
|
27
|
+
import { ipsa } from "../types/proto.js";
|
|
28
|
+
import { getUserToken } from "../api/auth.js";
|
|
29
|
+
import { ObservableRetryConnection } from "./observable_connection.js";
|
|
30
|
+
import { AlreadyStartedError, InvalidArgumentError, NotConnectedError, PermissionDeniedError, SessionTimeoutError } from "../types/exceptions.js";
|
|
31
|
+
var _meetingExpiryTimer = /*#__PURE__*/new WeakMap();
|
|
32
|
+
var _IPSAClass_brand = /*#__PURE__*/new WeakSet();
|
|
33
|
+
class IPSAClass extends ObservableRetryConnection {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super('ipsa', options);
|
|
36
|
+
_classPrivateMethodInitSpec(this, _IPSAClass_brand);
|
|
37
|
+
_classPrivateFieldInitSpec(this, _meetingExpiryTimer, void 0);
|
|
38
|
+
this.socket = null;
|
|
39
|
+
_classPrivateFieldSet(_meetingExpiryTimer, this, null);
|
|
40
|
+
this.meetingToken = null;
|
|
41
|
+
this.meetingClaims = null;
|
|
42
|
+
}
|
|
43
|
+
async start(_ref) {
|
|
44
|
+
let {
|
|
45
|
+
meetingToken,
|
|
46
|
+
request
|
|
47
|
+
} = _ref;
|
|
48
|
+
if (this.isStarted()) {
|
|
49
|
+
this.onError(new AlreadyStartedError("already started"));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.setRuntimeConfig(request.runtimeConfig);
|
|
53
|
+
_assertClassBrand(_IPSAClass_brand, this, _setConfig).call(this, request.config);
|
|
54
|
+
this.meetingToken = meetingToken;
|
|
55
|
+
this.meetingClaims = new MeetingClaims(this.meetingToken);
|
|
56
|
+
let seconds = this.meetingClaims.getSecondsUntilExpiry();
|
|
57
|
+
if (seconds <= 0) {
|
|
58
|
+
let e = new PermissionDeniedError("meeting token expired");
|
|
59
|
+
this.onError(e);
|
|
60
|
+
throw e;
|
|
61
|
+
} else {
|
|
62
|
+
clearTimeout(_classPrivateFieldGet(_meetingExpiryTimer, this));
|
|
63
|
+
_classPrivateFieldSet(_meetingExpiryTimer, this, setTimeout(() => {
|
|
64
|
+
let e = new SessionTimeoutError("meeting token expired");
|
|
65
|
+
this.onError(e);
|
|
66
|
+
}, seconds));
|
|
67
|
+
}
|
|
68
|
+
super.start();
|
|
69
|
+
}
|
|
70
|
+
stop() {
|
|
71
|
+
clearTimeout(_classPrivateFieldGet(_meetingExpiryTimer, this));
|
|
72
|
+
this.configRequest = null;
|
|
73
|
+
this.runtimeConfigRequest = null;
|
|
74
|
+
super.stop();
|
|
75
|
+
}
|
|
76
|
+
async getURI() {
|
|
77
|
+
let userToken;
|
|
78
|
+
try {
|
|
79
|
+
userToken = await getUserToken({
|
|
80
|
+
minExpiry: 3600
|
|
81
|
+
});
|
|
82
|
+
let claims = new UserClaims(userToken);
|
|
83
|
+
let seconds = claims.getSecondsUntilExpiry();
|
|
84
|
+
if (seconds <= 0) {
|
|
85
|
+
let e = new PermissionDeniedError("user token expired");
|
|
86
|
+
this.onError(e);
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
let e = new PermissionDeniedError(err);
|
|
91
|
+
this.onError(e);
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
let meetingId = this.meetingClaims.meetindId;
|
|
95
|
+
logger.info("Starting IPSA...");
|
|
96
|
+
let base = new URL(SDKConfig.apiBaseURL);
|
|
97
|
+
let url = base.host + (base.pathname !== '/' ? base.pathname : '');
|
|
98
|
+
return "wss://".concat(url, "/ws/ipsa/").concat(meetingId, "?user_token=").concat(userToken, "&meeting_token=").concat(this.meetingToken);
|
|
99
|
+
}
|
|
100
|
+
onData(msg) {
|
|
101
|
+
try {
|
|
102
|
+
if (msg instanceof ArrayBuffer) {
|
|
103
|
+
let buffer = new Uint8Array(msg);
|
|
104
|
+
let response = ipsa.Response.decode(buffer);
|
|
105
|
+
this.notify('onResponse', response);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
logger.error(err);
|
|
110
|
+
}
|
|
111
|
+
this.parseJSONResponse(msg);
|
|
112
|
+
}
|
|
113
|
+
writeData(data) {
|
|
114
|
+
let sz = this.getBufferedAmount();
|
|
115
|
+
if (sz > 0) logger.warn("ipsa: low internet speed connection. [buffer size: ".concat(sz, "]"));
|
|
116
|
+
let request = ipsa.Request.create({
|
|
117
|
+
ipsa: {
|
|
118
|
+
data: data
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return _assertClassBrand(_IPSAClass_brand, this, _write).call(this, request);
|
|
122
|
+
}
|
|
123
|
+
onConnected() {
|
|
124
|
+
super.onConnected();
|
|
125
|
+
_assertClassBrand(_IPSAClass_brand, this, _write).call(this, this.configRequest);
|
|
126
|
+
_assertClassBrand(_IPSAClass_brand, this, _write).call(this, this.runtimeConfigRequest);
|
|
127
|
+
}
|
|
128
|
+
setRuntimeConfig(cfg) {
|
|
129
|
+
if (!cfg) throw new InvalidArgumentError("bad request");
|
|
130
|
+
let request = ipsa.Request.create({
|
|
131
|
+
runtimeConfig: cfg
|
|
132
|
+
});
|
|
133
|
+
this.runtimeConfigRequest = request;
|
|
134
|
+
if (this.isConnected()) _assertClassBrand(_IPSAClass_brand, this, _write).call(this, request);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
_IPSAClass = IPSAClass;
|
|
138
|
+
async function _write(msg) {
|
|
139
|
+
let err = ipsa.Request.verify(msg);
|
|
140
|
+
if (err) {
|
|
141
|
+
let e = new InvalidArgumentError("invalid message: " + err);
|
|
142
|
+
this.onError(e);
|
|
143
|
+
throw e;
|
|
144
|
+
}
|
|
145
|
+
if (msg) {
|
|
146
|
+
let data = ipsa.Request.encode(msg).finish();
|
|
147
|
+
_get(_getPrototypeOf(_IPSAClass.prototype), "write", this).call(this, data);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function _setConfig(cfg) {
|
|
151
|
+
if (!cfg) throw new InvalidArgumentError("bad request");
|
|
152
|
+
let request = ipsa.Request.create({
|
|
153
|
+
config: cfg
|
|
154
|
+
});
|
|
155
|
+
this.configRequest = request;
|
|
156
|
+
}
|
|
157
|
+
export let IPSA = new IPSAClass({
|
|
158
|
+
maxRetryCount: 10,
|
|
159
|
+
minRetryIntervalMs: 500,
|
|
160
|
+
maxRetryIntervalMs: 4000
|
|
161
|
+
});
|