@jibb-open/jssdk 3.5.8 → 3.5.10

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.
Files changed (83) hide show
  1. package/api/admin.js +418 -0
  2. package/api/auth.js +246 -0
  3. package/api/eventbus.js +249 -0
  4. package/api/index.js +53 -0
  5. package/api/meeting.js +488 -0
  6. package/api/recording.js +260 -0
  7. package/api/superadmin.js +105 -0
  8. package/api/user.js +51 -0
  9. package/api/webexbot.js +41 -0
  10. package/api/whiteboard.js +179 -0
  11. package/config.js +16 -0
  12. package/examples/browser/462.jibb.js +306 -0
  13. package/{src/examples → examples}/browser/index.html +0 -0
  14. package/examples/browser/jibb.js +7381 -0
  15. package/examples/browser/startSession.js +102 -0
  16. package/{src/examples → examples}/examples.js +1 -0
  17. package/examples/webexDevicesMacros/cameraPresets/jibb.js +280 -0
  18. package/examples/webexDevicesMacros/simplestExample/jibb.js +182 -0
  19. package/examples/webexDevicesMacros/webexDevice JSSDK/jibb_WebexXapi.js +3033 -0
  20. package/examples/webexDevicesMacros/withCameraControl/jibb.js +264 -0
  21. package/package.json +1 -1
  22. package/post-processing.js +43 -0
  23. package/types/exceptions.js +55 -0
  24. package/{src/types → types}/jibb.pb.js +5 -38
  25. package/types/proto.js +15 -0
  26. package/types/types.js +67 -0
  27. package/utils/cached_variable.js +25 -0
  28. package/utils/future.js +31 -0
  29. package/utils/http/http.axios.js +41 -0
  30. package/utils/http/index.js +10 -0
  31. package/utils/index.js +11 -0
  32. package/utils/logger/index.js +19 -0
  33. package/utils/logger/logger.empty.js +25 -0
  34. package/utils/logger/logger.pino.js +19 -0
  35. package/ws/connection_base.js +95 -0
  36. package/ws/eventbus.js +376 -0
  37. package/ws/index.js +36 -0
  38. package/ws/ipsa.js +262 -0
  39. package/ws/meeting.js +181 -0
  40. package/ws/observable_connection.js +87 -0
  41. package/ws/retry_connection.js +94 -0
  42. package/.babelrc +0 -31
  43. package/README.md +0 -4
  44. package/src/api/admin.js +0 -333
  45. package/src/api/auth.js +0 -208
  46. package/src/api/eventbus.js +0 -246
  47. package/src/api/index.js +0 -26
  48. package/src/api/meeting.js +0 -421
  49. package/src/api/recording.js +0 -225
  50. package/src/api/superadmin.js +0 -84
  51. package/src/api/user.js +0 -46
  52. package/src/api/webexbot.js +0 -32
  53. package/src/api/whiteboard.js +0 -175
  54. package/src/config.js +0 -12
  55. package/src/examples/browser/462.jibb.js +0 -1
  56. package/src/examples/browser/jibb.js +0 -2
  57. package/src/examples/browser/startSession.js +0 -112
  58. package/src/examples/webexDevicesMacros/cameraPresets/jibb.js +0 -338
  59. package/src/examples/webexDevicesMacros/simplestExample/jibb.js +0 -212
  60. package/src/examples/webexDevicesMacros/webexDevice JSSDK/jibb_WebexXapi.js +0 -2
  61. package/src/examples/webexDevicesMacros/withCameraControl/jibb.js +0 -303
  62. package/src/index.webex-devices.js +0 -13
  63. package/src/post-processing.js +0 -39
  64. package/src/types/exceptions.js +0 -48
  65. package/src/types/proto.js +0 -7
  66. package/src/types/types.js +0 -64
  67. package/src/utils/cached_variable.js +0 -23
  68. package/src/utils/future.js +0 -24
  69. package/src/utils/http/http.axios.js +0 -34
  70. package/src/utils/http/http.xapi.js +0 -87
  71. package/src/utils/http/index.js +0 -8
  72. package/src/utils/index.js +0 -5
  73. package/src/utils/logger/index.js +0 -11
  74. package/src/utils/logger/logger.empty.js +0 -25
  75. package/src/utils/logger/logger.pino.js +0 -15
  76. package/src/ws/connection_base.js +0 -81
  77. package/src/ws/eventbus.js +0 -363
  78. package/src/ws/index.js +0 -15
  79. package/src/ws/ipsa.js +0 -246
  80. package/src/ws/meeting.js +0 -170
  81. package/src/ws/observable_connection.js +0 -84
  82. package/src/ws/retry_connection.js +0 -82
  83. package/webpack.config.cjs +0 -144
package/ws/ipsa.js ADDED
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.IPSA = void 0;
7
+ require("core-js/modules/es.promise.js");
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/web.url.js");
10
+ require("core-js/modules/web.url-search-params.js");
11
+ require("core-js/modules/es.array.reduce.js");
12
+ require("core-js/modules/es.array-buffer.constructor.js");
13
+ require("core-js/modules/es.array-buffer.slice.js");
14
+ require("core-js/modules/es.typed-array.uint8-array.js");
15
+ require("core-js/modules/es.typed-array.fill.js");
16
+ require("core-js/modules/es.typed-array.set.js");
17
+ require("core-js/modules/es.typed-array.sort.js");
18
+ require("core-js/modules/es.typed-array.to-locale-string.js");
19
+ var _config = require("../config.js");
20
+ var _index = require("../utils/logger/index.js");
21
+ var _retry_connection = require("./retry_connection.js");
22
+ var _connection_base = require("./connection_base.js");
23
+ var _types = require("../types/types.js");
24
+ var _proto = require("../types/proto.js");
25
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
26
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
27
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
28
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
29
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
30
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
31
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
32
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
33
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
34
+ const ErrorCode = _proto.types.Code;
35
+ var _expiryTimer = /*#__PURE__*/new WeakMap();
36
+ var _clear = /*#__PURE__*/new WeakSet();
37
+ var _write = /*#__PURE__*/new WeakSet();
38
+ var _handleMessage = /*#__PURE__*/new WeakSet();
39
+ var _onResponse = /*#__PURE__*/new WeakSet();
40
+ var _writeInputImage = /*#__PURE__*/new WeakSet();
41
+ var _setConfig = /*#__PURE__*/new WeakSet();
42
+ class IPSAClass extends _retry_connection.RetryConnection {
43
+ constructor() {
44
+ super('ipsa');
45
+ _classPrivateMethodInitSpec(this, _setConfig);
46
+ _classPrivateMethodInitSpec(this, _writeInputImage);
47
+ _classPrivateMethodInitSpec(this, _onResponse);
48
+ _classPrivateMethodInitSpec(this, _handleMessage);
49
+ _classPrivateMethodInitSpec(this, _write);
50
+ _classPrivateMethodInitSpec(this, _clear);
51
+ _classPrivateFieldInitSpec(this, _expiryTimer, {
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ this.socket = null;
56
+ this.onInputImage = null;
57
+ this.onError = null;
58
+ this.onResponse = null;
59
+ this.userToken = null;
60
+ _classPrivateFieldSet(this, _expiryTimer, null);
61
+ _classPrivateMethodGet(this, _clear, _clear2).call(this);
62
+ }
63
+ start(_ref) {
64
+ let {
65
+ userToken,
66
+ request,
67
+ onInputImage,
68
+ onError,
69
+ onResponse
70
+ } = _ref;
71
+ if (!this.isStarted()) {
72
+ this.setRuntimeConfig(request.runtimeConfig);
73
+ this.setAppConfig(request.appConfig);
74
+ _classPrivateMethodGet(this, _setConfig, _setConfig2).call(this, request.config);
75
+ this.onInputImage = onInputImage;
76
+ this.onError = onError;
77
+ this.onResponse = onResponse;
78
+ this.userToken = userToken;
79
+ let meetingClaims = new _types.MeetingClaims(this.appConfigRequest.appConfig.meetingToken);
80
+ let userClaims = new _types.UserClaims(this.userToken);
81
+ let seconds = Math.min(userClaims.getSecondsUntilExpiry(), meetingClaims.getSecondsUntilExpiry());
82
+ if (seconds <= 0) {
83
+ this.onErrorMessage(ErrorCode.ERR_TIMEOUT, "token expired");
84
+ return;
85
+ } else {
86
+ _classPrivateFieldSet(this, _expiryTimer, setTimeout(() => {
87
+ this.stop();
88
+ this.onErrorMessage(ErrorCode.ERR_TIMEOUT, "token expired");
89
+ }, seconds));
90
+ }
91
+ }
92
+ super.start();
93
+ }
94
+ stop() {
95
+ clearTimeout(_classPrivateFieldGet(this, _expiryTimer));
96
+ _classPrivateMethodGet(this, _clear, _clear2).call(this);
97
+ super.stop();
98
+ }
99
+ disconnect() {
100
+ super.disconnect();
101
+ if (this.socket != null) {
102
+ this.socket.close();
103
+ this.socket = null;
104
+ // this.fireOnError(ErrorLevel.ERROR, ErrorCode.ERR_CLOSED, "closed") //this one fired after diconnection error causes multiple connection (it call retray connection again)
105
+ }
106
+ }
107
+
108
+ async connect() {
109
+ if (this.getConnectionStatus() != _connection_base.ConnectionStatus.DISCONNECTED) return;
110
+ super.connect();
111
+ let meetingId = this.appConfigRequest.appConfig.meetingId;
112
+ let meetingToken = this.appConfigRequest.appConfig.meetingToken;
113
+ try {
114
+ let c = new _types.UserClaims(this.userToken);
115
+ if (c.isExpired()) {
116
+ this.onErrorMessage(ErrorCode.ERR_TIMEOUT, "token expired");
117
+ return;
118
+ }
119
+ } catch (err) {
120
+ this.onErrorMessage(ErrorCode.ERR_UNAUTHORIZED, "unauthorized");
121
+ return;
122
+ }
123
+ _index.logger.info("Connecting IPSA to meeting ".concat(meetingId, "..."));
124
+ let base = new URL(_config.Config.apiBaseURL);
125
+ let uri = "wss://".concat(base.hostname, "/ws/ipsa/").concat(meetingId, "?user_token=").concat(this.userToken, "&meeting_token=").concat(meetingToken);
126
+ this.socket = new WebSocket(uri);
127
+ this.socket.binaryType = "arraybuffer";
128
+ this.socket.addEventListener("open", async () => {
129
+ try {
130
+ await _classPrivateMethodGet(this, _write, _write2).call(this, this.configRequest);
131
+ await _classPrivateMethodGet(this, _write, _write2).call(this, this.runtimeConfigRequest);
132
+ await _classPrivateMethodGet(this, _write, _write2).call(this, this.appConfigRequest);
133
+ this.onConnected();
134
+ } catch (err) {
135
+ this.onWarningMessage(ErrorCode.ERR_IO, err);
136
+ this.disconnect();
137
+ return;
138
+ }
139
+ let loopFunction = () => {
140
+ if (!this.isConnected() || !this.isStarted()) return;
141
+ if (this.socket.bufferedAmount > 0) {
142
+ _index.logger.warn("ipsa: low internet speed connection");
143
+ setTimeout(loopFunction, 100);
144
+ } else {
145
+ setTimeout(loopFunction, 500);
146
+ _classPrivateMethodGet(this, _writeInputImage, _writeInputImage2).call(this).catch(err => _index.logger.error(err));
147
+ }
148
+ };
149
+ loopFunction();
150
+ });
151
+ this.socket.addEventListener("close", () => {
152
+ this.onDisconnected();
153
+ });
154
+ this.socket.addEventListener("message", event => {
155
+ _classPrivateMethodGet(this, _handleMessage, _handleMessage2).call(this, event.data);
156
+ });
157
+ this.socket.addEventListener("error", err => {
158
+ this.onWarningMessage(ErrorCode.ERR_IO, err);
159
+ });
160
+ }
161
+ getAverageResponseTime() {
162
+ let avg = NaN;
163
+ try {
164
+ let items = Array.from(this.stats.values()).map(e => e.responseTime - e.requestTime).filter(e => !isNaN(e));
165
+ let sum = items.reduce((a, b) => a + b);
166
+ avg = sum / items.length;
167
+ } catch (err) {}
168
+ return avg;
169
+ }
170
+ setRuntimeConfig(cfg) {
171
+ let request = _proto.ipsa.Request.create({
172
+ runtimeConfig: cfg
173
+ });
174
+ this.runtimeConfigRequest = request;
175
+ if (this.isConnected()) _classPrivateMethodGet(this, _write, _write2).call(this, request);
176
+ }
177
+ setAppConfig(cfg) {
178
+ let request = _proto.ipsa.Request.create({
179
+ appConfig: cfg
180
+ });
181
+ this.appConfigRequest = request;
182
+ if (this.isConnected()) _classPrivateMethodGet(this, _write, _write2).call(this, request);
183
+ }
184
+ }
185
+ function _clear2() {
186
+ this.appConfigRequest = null;
187
+ this.configRequest = null;
188
+ this.runtimeConfigRequest = null;
189
+ this.stats = new Map();
190
+ this.requestId = 0;
191
+ }
192
+ async function _write2(msg) {
193
+ let err = _proto.ipsa.Request.verify(msg);
194
+ if (err) throw new Error("invalid message: " + err);
195
+ if (msg) {
196
+ let data = _proto.ipsa.Request.encode(msg).finish();
197
+ this.socket.send(data);
198
+ }
199
+ }
200
+ async function _handleMessage2(msg) {
201
+ var _msg, _msg2, _msg3, _msg4;
202
+ try {
203
+ if (msg instanceof ArrayBuffer) {
204
+ let buffer = new Uint8Array(msg);
205
+ let response = _proto.ipsa.Response.decode(buffer);
206
+ _classPrivateMethodGet(this, _onResponse, _onResponse2).call(this, response);
207
+ return;
208
+ }
209
+ } catch (err) {
210
+ _index.logger.error(err);
211
+ }
212
+ try {
213
+ msg = JSON.parse(msg);
214
+ switch (msg.code) {
215
+ case ErrorCode.ERR_TOO_MANY_CONNECTIONS:
216
+ case ErrorCode.ERR_UNAUTHORIZED:
217
+ case ErrorCode.ERR_BAD_REQUEST:
218
+ this.onErrorMessage((_msg = msg) === null || _msg === void 0 ? void 0 : _msg.code, (_msg2 = msg) === null || _msg2 === void 0 ? void 0 : _msg2.reason);
219
+ this.stop();
220
+ break;
221
+ default:
222
+ this.onInfoMessage((_msg3 = msg) === null || _msg3 === void 0 ? void 0 : _msg3.code, (_msg4 = msg) === null || _msg4 === void 0 ? void 0 : _msg4.reason);
223
+ break;
224
+ }
225
+ } catch (e) {
226
+ this.onWarningMessage(ErrorCode.ERR_IO, e);
227
+ }
228
+ }
229
+ function _onResponse2(response) {
230
+ if (response.id >= 100) {
231
+ let id = response.id - 100;
232
+ let s = this.stats.get(id) || {};
233
+ s.responseTime = performance.now();
234
+ this.stats.set(id, s);
235
+ }
236
+ if (this.onResponse) {
237
+ this.onResponse(response);
238
+ }
239
+ }
240
+ async function _writeInputImage2() {
241
+ let img = await this.onInputImage();
242
+ this.requestId = (this.requestId + 1) % 8;
243
+ this.stats.set(this.requestId, {
244
+ requestTime: performance.now()
245
+ });
246
+ let request = _proto.ipsa.Request.create({
247
+ id: this.requestId + 100,
248
+ ipsa: {
249
+ data: img
250
+ }
251
+ });
252
+ _classPrivateMethodGet(this, _write, _write2).call(this, request);
253
+ }
254
+ function _setConfig2(cfg) {
255
+ let request = _proto.ipsa.Request.create({
256
+ config: cfg
257
+ });
258
+ this.configRequest = request;
259
+ if (this.isConnected()) _classPrivateMethodGet(this, _write, _write2).call(this, request);
260
+ }
261
+ let IPSA = new IPSAClass();
262
+ exports.IPSA = IPSA;
package/ws/meeting.js ADDED
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MeetingConnection = void 0;
7
+ require("core-js/modules/es.global-this.js");
8
+ require("core-js/modules/es.promise.js");
9
+ require("core-js/modules/web.dom-collections.iterator.js");
10
+ require("core-js/modules/web.url.js");
11
+ require("core-js/modules/web.url-search-params.js");
12
+ require("core-js/modules/es.array-buffer.constructor.js");
13
+ require("core-js/modules/es.array-buffer.slice.js");
14
+ require("core-js/modules/es.typed-array.uint8-array.js");
15
+ require("core-js/modules/es.typed-array.fill.js");
16
+ require("core-js/modules/es.typed-array.set.js");
17
+ require("core-js/modules/es.typed-array.sort.js");
18
+ require("core-js/modules/es.typed-array.to-locale-string.js");
19
+ var _auth = require("../api/auth.js");
20
+ var _config = require("../config.js");
21
+ var _index = require("../utils/logger/index.js");
22
+ var _retry_connection = require("./retry_connection.js");
23
+ var _connection_base = require("./connection_base.js");
24
+ var _types = require("../types/types.js");
25
+ var _proto = require("../types/proto.js");
26
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
27
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
28
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
29
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
30
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
31
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
32
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
33
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
34
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
35
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+ let Message = _proto.meeting.Message;
38
+ let ErrorCode = _proto.types.Code;
39
+ if ((globalThis === null || globalThis === void 0 ? void 0 : globalThis.WebSocket) == undefined) {
40
+ Promise.resolve().then(() => _interopRequireWildcard(require("isomorphic-ws"))).then(webSocket => {
41
+ globalThis.WebSocket = webSocket.default;
42
+ });
43
+ }
44
+ var _expiryTimer = /*#__PURE__*/new WeakMap();
45
+ var _handleMessage = /*#__PURE__*/new WeakSet();
46
+ class MeetingConnectionImp extends _retry_connection.RetryConnection {
47
+ constructor() {
48
+ super('meeting');
49
+ _classPrivateMethodInitSpec(this, _handleMessage);
50
+ _classPrivateFieldInitSpec(this, _expiryTimer, {
51
+ writable: true,
52
+ value: void 0
53
+ });
54
+ this.meetingId = null;
55
+ this.meetingToken = null;
56
+ _classPrivateFieldSet(this, _expiryTimer, null);
57
+ }
58
+ getName() {
59
+ return "".concat(super.getName(), "-").concat(this.meetingId);
60
+ }
61
+ async start(meetingToken) {
62
+ this.meetingToken = meetingToken;
63
+ this.meetingClaims = new _types.MeetingClaims(meetingToken);
64
+ this.meetingId = this.meetingClaims.meetindId;
65
+ let seconds = this.meetingClaims.getSecondsUntilExpiry();
66
+ if (seconds <= 0) {
67
+ this.onErrorMessage(ErrorCode.ERR_TIMEOUT, "meeting token expired");
68
+ return;
69
+ }
70
+ _classPrivateFieldSet(this, _expiryTimer, setTimeout(() => {
71
+ this.stop();
72
+ this.onErrorMessage(ErrorCode.ERR_TIMEOUT, "meeting token expired");
73
+ }, seconds));
74
+ super.start();
75
+ }
76
+ async stop() {
77
+ clearTimeout(_classPrivateFieldGet(this, _expiryTimer));
78
+ super.stop();
79
+ }
80
+ disconnect() {
81
+ if (this.socket != null) {
82
+ this.socket.close();
83
+ this.socket = null;
84
+ // this.fireOnError(ErrorLevel.ERROR, ErrorCode.ERR_CLOSED, "closed") //this one fired after diconnection error causes multiple connection (it call retray connection again)
85
+ _index.logger.info("meeting disconnect ", this.meetingId);
86
+ }
87
+ super.disconnect();
88
+ }
89
+ async connect() {
90
+ if (this.getConnectionStatus() != _connection_base.ConnectionStatus.DISCONNECTED) return;
91
+ super.connect();
92
+ let self = this;
93
+ try {
94
+ if (this.meetingClaims.isExpired()) {
95
+ self.onErrorMessage(ErrorCode.ERR_TIMEOUT, "meeting token expired");
96
+ return;
97
+ }
98
+ } catch (e) {
99
+ self.onErrorMessage(ErrorCode.ERR_BAD_REQUEST, "invalid meeting token");
100
+ return;
101
+ }
102
+ let base = new URL(_config.Config.apiBaseURL);
103
+ let uri = "wss://" + base.hostname + "/ws/meetings/" + this.meetingId + "?meeting_token=" + this.meetingToken;
104
+ this.socket = new WebSocket(uri);
105
+ this.socket.binaryType = "arraybuffer";
106
+ this.socket.addEventListener("open", function () {
107
+ self.onConnected();
108
+ });
109
+ this.socket.addEventListener("close", function () {
110
+ self.onDisconnected();
111
+ });
112
+ this.socket.addEventListener("message", function (event) {
113
+ _classPrivateMethodGet(self, _handleMessage, _handleMessage2).call(self, event.data);
114
+ });
115
+ this.socket.addEventListener("error", function (err) {
116
+ self.onWarningMessage(ErrorCode.ERR_IO, err);
117
+ });
118
+ }
119
+ async sendPointer(x, y) {
120
+ await super.waitForConnection();
121
+ let claims = await _auth.Auth.getUserClaims();
122
+ let msg = Message.fromObject({
123
+ pointer: {
124
+ email: claims.email,
125
+ x: x,
126
+ y: y
127
+ }
128
+ });
129
+ let buf = Message.encode(msg).finish();
130
+ this.socket.send(buf);
131
+ }
132
+ async sendDrawing(_ref) {
133
+ let {
134
+ email,
135
+ data
136
+ } = _ref;
137
+ await super.waitForConnection();
138
+ let msg = Message.fromObject({
139
+ drawing: {
140
+ email: email,
141
+ data: data
142
+ }
143
+ });
144
+ _index.logger.debug("".concat(this.getName(), ".Drawing: "), Message.toObject(msg));
145
+ let buf = Message.encode(msg).finish();
146
+ this.socket.send(buf);
147
+ }
148
+ }
149
+ async function _handleMessage2(msg) {
150
+ try {
151
+ if (msg instanceof ArrayBuffer) {
152
+ let buffer = new Uint8Array(msg);
153
+ let event = Message.decode(buffer);
154
+ if (event !== null && event !== void 0 && event.update) this.notify('onMeetingUpdate', event.update);
155
+ if (event !== null && event !== void 0 && event.drawing) this.notify('onDrawing', event.drawing);
156
+ if (event !== null && event !== void 0 && event.pointer) this.notify('onPointer', event);else if (event !== null && event !== void 0 && event.join) this.notify('onMeetingJoin', event.join);else if (event !== null && event !== void 0 && event.leave) this.notify('onMeetingLeave', event.leave);
157
+ return;
158
+ }
159
+ } catch (err) {
160
+ _index.logger.error(err);
161
+ }
162
+ try {
163
+ let Error = JSON.parse(msg);
164
+ switch (Error.code) {
165
+ case ErrorCode.ERR_TOO_MANY_CONNECTIONS:
166
+ case ErrorCode.ERR_UNAUTHORIZED:
167
+ case ErrorCode.ERR_BAD_REQUEST:
168
+ case ErrorCode.ERR_TIMEOUT:
169
+ this.onErrorMessage(Error.code, Error.reason);
170
+ break;
171
+ default:
172
+ this.onInfoMessage(Error.code, Error.reason);
173
+ break;
174
+ }
175
+ } catch (e) {
176
+ _index.logger.error(e);
177
+ this.onWarningMessage(ErrorCode.ERR_IO, msg);
178
+ }
179
+ }
180
+ let MeetingConnection = new MeetingConnectionImp();
181
+ exports.MeetingConnection = MeetingConnection;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ObservableConnection = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ require("core-js/modules/esnext.aggregate-error.js");
9
+ require("core-js/modules/es.promise.js");
10
+ require("core-js/modules/esnext.promise.any.js");
11
+ var _index = require("../utils/logger/index.js");
12
+ var _connection_base = require("./connection_base.js");
13
+ class ObservableConnection extends _connection_base.ConnectionBase {
14
+ constructor(connectionName) {
15
+ super(connectionName);
16
+ this.observers = new Map();
17
+ }
18
+ subscribe(id, observer) {
19
+ this.observers.set(id, observer);
20
+ }
21
+ unsubscribeAll() {
22
+ this.observers = new Map();
23
+ }
24
+ unsubscribe(id) {
25
+ try {
26
+ this.observers.delete(id);
27
+ } catch (err) {
28
+ _index.logger.error(err);
29
+ }
30
+ }
31
+ notify(eventName) {
32
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33
+ args[_key - 1] = arguments[_key];
34
+ }
35
+ this.observers.forEach(o => {
36
+ try {
37
+ let fn = o[eventName];
38
+ if (fn !== undefined) fn(...args);
39
+ } catch (err) {
40
+ _index.logger.error("Error occured notifying event ".concat(eventName), err);
41
+ }
42
+ });
43
+ }
44
+ callSubscribers(functionName) {
45
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
46
+ args[_key2 - 1] = arguments[_key2];
47
+ }
48
+ let promises = [];
49
+ this.observers.forEach(o => {
50
+ try {
51
+ let fn = o[functionName];
52
+ if (fn !== undefined) {
53
+ let res = fn(...args);
54
+ promises.push(res);
55
+ }
56
+ } catch (error) {
57
+ _index.logger.error(error);
58
+ }
59
+ });
60
+ return Promise.any(promises);
61
+ }
62
+ onDisconnected() {
63
+ super.onDisconnected();
64
+ this.notify("onDisconnected");
65
+ }
66
+ onConnected() {
67
+ super.onConnected();
68
+ this.notify("onConnected");
69
+ }
70
+ onStopped() {
71
+ super.onStopped();
72
+ this.notify("onStopped");
73
+ }
74
+ onErrorMessage(code, reason) {
75
+ super.onErrorMessage(code, reason);
76
+ this.notify("onErrorMessage", code, reason);
77
+ }
78
+ onWarningMessage(code, reason) {
79
+ super.onWarningMessage(code, reason);
80
+ this.notify("onWarningMessage", code, reason);
81
+ }
82
+ onInfoMessage(code, reason) {
83
+ super.onInfoMessage(code, reason);
84
+ this.notify("onInfoMessage", code, reason);
85
+ }
86
+ }
87
+ exports.ObservableConnection = ObservableConnection;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RetryConnection = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ var _index = require("../utils/logger/index.js");
9
+ var _observable_connection = require("./observable_connection.js");
10
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
11
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
12
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
13
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
14
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
15
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
16
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
17
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
18
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
19
+ var _started = /*#__PURE__*/new WeakMap();
20
+ var _reconnect = /*#__PURE__*/new WeakSet();
21
+ class RetryConnection extends _observable_connection.ObservableConnection {
22
+ constructor(connectionName) {
23
+ let maxRetryCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
24
+ let minRetryIntervalMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
25
+ let maxRetryIntervalMs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 32000;
26
+ super(connectionName);
27
+ _classPrivateMethodInitSpec(this, _reconnect);
28
+ _classPrivateFieldInitSpec(this, _started, {
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ this.maxRetryCount = maxRetryCount;
33
+ this.minRetryIntervalMs = minRetryIntervalMs;
34
+ this.maxRetryIntervalMs = maxRetryIntervalMs;
35
+ this.retryCount = 0;
36
+ this.retryIntervalMs = minRetryIntervalMs;
37
+ this.lastConnectionTime = Date.now() - maxRetryIntervalMs;
38
+ this.retryTimer = null;
39
+ _classPrivateFieldSet(this, _started, false);
40
+ }
41
+ start() {
42
+ if (!this.isStarted()) {
43
+ _index.logger.info("".concat(this.getName(), ": starting..."));
44
+ _classPrivateFieldSet(this, _started, true);
45
+ this.connect();
46
+ }
47
+ }
48
+ stop() {
49
+ _index.logger.info("".concat(this.getName(), ": stopping..."));
50
+ _classPrivateFieldSet(this, _started, false);
51
+ this.disconnect();
52
+ }
53
+ isStarted() {
54
+ return _classPrivateFieldGet(this, _started);
55
+ }
56
+ onDisconnected() {
57
+ super.onDisconnected();
58
+ if (this.isStarted()) _classPrivateMethodGet(this, _reconnect, _reconnect2).call(this);
59
+ }
60
+ connect() {
61
+ if (this.isStarted()) super.connect();
62
+ }
63
+ disconnect() {
64
+ if (this.retryTimer) {
65
+ clearTimeout(this.retryTimer);
66
+ this.retryTimer = null;
67
+ }
68
+ super.disconnect();
69
+ }
70
+ onErrorMessage(code, reason) {
71
+ super.onErrorMessage(code, reason);
72
+ this.stop();
73
+ }
74
+ }
75
+ exports.RetryConnection = RetryConnection;
76
+ function _reconnect2() {
77
+ let self = this;
78
+ if (Date.now() - this.lastConnectionTime < this.retryIntervalMs) {
79
+ this.retryIntervalMs = Math.min(this.retryIntervalMs * 2, this.maxRetryIntervalMs);
80
+ this.retryCount = this.retryCount + 1;
81
+ } else {
82
+ this.retryCount = 1;
83
+ this.retryIntervalMs = this.minRetryIntervalMs;
84
+ }
85
+ if (this.retryCount >= this.maxRetryCount) {
86
+ this.stop();
87
+ return;
88
+ }
89
+ this.retryTimer = setTimeout(() => {
90
+ _index.logger.info("".concat(this.getName(), ": retrying connection... [interval: ").concat(this.retryIntervalMs, "ms]"));
91
+ self.lastConnectionTime = Date.now() + 4000;
92
+ self.connect();
93
+ }, this.retryIntervalMs);
94
+ }
package/.babelrc DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "env": {
3
- "webapp": {
4
- "ignore": ["**/*.xapi.js", "**/*.webex-devices.js"],
5
- "presets": [
6
- [
7
- "@babel/env",
8
- {
9
- "targets": {
10
- "edge": "17",
11
- "firefox": "60",
12
- "chrome": "67",
13
- "safari": "11.1"
14
- },
15
- "useBuiltIns": "usage",
16
- "corejs": "3.6.5"
17
- }
18
- ]
19
- ],
20
-
21
- "plugins": [
22
- [
23
- "babel-plugin-transform-import-ignore",
24
- {
25
- "patterns": [".webex-devices.js", "*xapi*"]
26
- }
27
- ]
28
- ]
29
- }
30
- }
31
- }
package/README.md DELETED
@@ -1,4 +0,0 @@
1
- # jibb-jssdk
2
- For SDK Documentation please visit: http://inkerz.github.io/jibb-jssdk
3
-
4
- also, please see code examples under Namespaces > Examples