@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/src/api/admin.js DELETED
@@ -1,333 +0,0 @@
1
- import {Config} from '../config.js';
2
- import {http} from "../utils/http/index.js"
3
- import {Auth} from "./auth.js"
4
- import {AccessLevel, UserType} from "../types/types.js"
5
-
6
-
7
- /**
8
- *
9
- * @module admin
10
- * This is an experimental API.
11
- */
12
-
13
- const accessLevel = AccessLevel.ADMIN
14
-
15
-
16
- /**
17
- *
18
- *
19
- * @async
20
- * @returns {array} - list of Organization
21
- */
22
- export async function getOrganizationList() {
23
- let headers = {
24
- "Content-Type": "application/json",
25
- Accept: "application/json",
26
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
27
- }
28
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations`, headers)
29
- return response.data.organizations
30
- }
31
-
32
- /**
33
- *
34
- * @async
35
- * @param {number} orgId
36
- * @returns {object}
37
- */
38
- export async function getOrganizationDetails(orgId) {
39
- if (orgId === "") {
40
- throw new Error("organization ID can not be empty")
41
- }
42
-
43
- let headers = {
44
- "Content-Type": "application/json",
45
- Accept: "application/json",
46
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
47
- }
48
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}`, headers)
49
- return response.data
50
- }
51
-
52
- /**
53
- *
54
- * @async
55
- * @param {number} orgId
56
- * @param {*} pagination
57
- * @returns {list}
58
- */
59
- export async function getUserList(orgId, pagination) {
60
- let headers = {
61
- "Content-Type": "application/json",
62
- Accept: "application/json",
63
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
64
- }
65
- if (pagination !== undefined) headers["x-jibb-pagination"] = JSON.stringify(pagination)
66
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users`, headers)
67
-
68
- pagination = response.headers["x-jibb-pagination"]
69
- pagination = pagination && JSON.parse(pagination)
70
- return {
71
- users: response.data.users,
72
- pagination: pagination,
73
- }
74
- }
75
-
76
- /**
77
- *
78
- * @async
79
- * @param {object} param0
80
- * @param {Number} param0.orgId
81
- * @param {list} param0.users - list of user object that contain email, first_name, last_name, user_type. user_type is a number from 0-4
82
- * @returns - http result
83
- */
84
- export async function createUsers({ orgId, users }) {
85
- let headers = {
86
- "Content-Type": "application/json",
87
- Accept: "application/json",
88
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
89
- }
90
- let body = {
91
- users,
92
- }
93
- return http.post(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users`, body, headers)
94
- }
95
-
96
-
97
- /**
98
- *
99
- * @async
100
- * @param {object} param0
101
- * @param {string} param0.orgId
102
- * @param {string} param0.email
103
- * @param {number} param0.userType - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
104
- * @returns - http result
105
- */
106
- export async function createOrganizationUser({ orgId, email, userType }) {
107
- let headers = {
108
- "Content-Type": "application/json",
109
- Accept: "application/json",
110
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
111
- }
112
- let body = {
113
- users: [
114
- {
115
- email: email,
116
- user_type: userType,
117
- },
118
- ],
119
- }
120
- return http.post(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users`, body, headers)
121
- }
122
-
123
- /**
124
- *
125
- * @async
126
- * @param {object} param0
127
- * @param {number} param0.orgId
128
- * @param {number} param0.userId
129
- * @returns - http result
130
- */
131
- export async function SendUserActivationEmail({ orgId, userIds }) {
132
- let headers = {
133
- "Content-Type": "application/json",
134
- Accept: "application/json",
135
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
136
- }
137
- let body = {
138
- user_ids: userIds,
139
- }
140
- return http.post(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/activation/email`, body, headers)
141
- }
142
- /**
143
- *
144
- * @async
145
- * @param {object} param0
146
- * @param {number} param0.orgId
147
- * @param {number} param0.userId
148
- * @returns - http result
149
- */
150
- export async function deleteOrganizationUser({ orgId, userId }) {
151
- let headers = {
152
- "Content-Type": "application/json",
153
- Accept: "application/json",
154
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
155
- }
156
- return http.delete(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users/${userId}`, headers)
157
- }
158
- /**
159
- *
160
- * @async
161
- * @param {object} param0
162
- * @param {number} param0.orgId
163
- * @param {number} param0.userId
164
- * @param {number} param0.userType - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
165
- * @returns - http result
166
- */
167
- export async function updateUserType({ orgId, userId, userType }) {
168
- let headers = {
169
- "Content-Type": "application/json",
170
- Accept: "application/json",
171
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
172
- }
173
- let body = {
174
- user_type: userType,
175
- }
176
- return http.patch(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users/${userId}`, body, headers)
177
- }
178
- /**
179
- *
180
- * @async
181
- * @param {object} param0
182
- * @param {number} param0.orgId
183
- * @param {number} param0.userId
184
- * @returns {object}
185
- */
186
- export async function getOrganizationUserDetails({ orgId, userId }) {
187
- let headers = {
188
- "Content-Type": "application/json",
189
- Accept: "application/json",
190
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
191
- }
192
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/users/${userId}`, headers)
193
- return response.data
194
- }
195
-
196
- // error code:401 status:Unauthorized should we / what token to use ? , orgId? not sure of the body
197
- /**
198
- *
199
- * @async
200
- * @param {object} param0
201
- * @param {number} param0.orgId
202
- * @param {string} [param0.metadata=]
203
- * @param {boolean} [param0.autoAddUsers=false]
204
- * @param {UserType} [param0.defaultUserType=0] - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
205
- * @param {boolean} [param0.enabled=fales]
206
- * @returns - http result
207
- */
208
- export async function setSAML({ orgId, metadata, autoAddUsers, defaultUserType, enabled }) {
209
- if (orgId === "" || orgId === undefined) {
210
- throw new Error("organization ID can not be empty")
211
- }
212
-
213
- let headers = {
214
- "Content-Type": "application/json",
215
- Accept: "application/json",
216
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
217
- }
218
- let body = {
219
- organization_id: orgId,
220
- metadata: metadata || "",
221
- auto_add_users: autoAddUsers !== undefined ? autoAddUsers : false,
222
- default_user_type: defaultUserType !== undefined ? defaultUserType : UserType.UNKNOWN,
223
- enabled: enabled || false,
224
- }
225
-
226
- return http.put(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/saml`, body, headers)
227
- }
228
-
229
- // error code:401 status:Unauthorized should we / what token to use ? , orgId? not sure of the body
230
- /**
231
- * @async
232
- * @param {number} orgId
233
- * @returns - http result
234
- */
235
- export async function deleteSAML(orgId) {
236
- let headers = {
237
- "Content-Type": "application/json",
238
- Accept: "application/json",
239
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
240
- }
241
- return http.delete(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/saml`, headers)
242
- }
243
- /**
244
- *
245
- * @async
246
- * @param {number} orgId
247
- * @returns {object}
248
- */
249
- export async function getSAML(orgId) {
250
- if (orgId === "") {
251
- throw new Error("organization ID can not be empty")
252
- }
253
-
254
- let headers = {
255
- "Content-Type": "application/json",
256
- Accept: "application/json",
257
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
258
- }
259
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/saml`, headers)
260
- return response.data
261
- }
262
- /**
263
- *
264
- * @async
265
- * @param {number} orgId
266
- * @returns {object}
267
- */
268
- export async function getDomainList(orgId) {
269
- let headers = {
270
- "Content-Type": "application/json",
271
- Accept: "application/json",
272
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
273
- }
274
- let response = await http.get(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/domains`, headers)
275
- return response.data
276
- }
277
- /**
278
- *
279
- * @async
280
- * @param {object} param0
281
- * @param {object} param0.orgId
282
- * @param {string} param0.domain
283
- * @returns {object}
284
- */
285
- export async function createDomain({ orgId, domain }) {
286
- let headers = {
287
- "Content-Type": "application/json",
288
- Accept: "application/json",
289
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
290
- }
291
- let body = {
292
- domain_name: domain,
293
- }
294
- let response = await http.post(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/domains`, body, headers)
295
- return response.data
296
- }
297
- /**
298
- *
299
- * @async
300
- * @param {object} param0
301
- * @param {object} param0.orgId
302
- * @param {string} param0.domain
303
- * @returns - http result
304
- */
305
- export async function deleteDomain({ orgId, domainId }) {
306
- let headers = {
307
- "Content-Type": "application/json",
308
- Accept: "application/json",
309
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
310
- }
311
- return http.delete(`${Config.apiBaseURL}/v1/admin/organizations/${orgId}/domains/${domainId}`, headers)
312
- }
313
- /**
314
- *
315
- * @async
316
- * @param {object} param0
317
- * @param {object} param0.orgId
318
- * @param {string} param0.domain
319
- * @returns {object}
320
- */
321
- export async function verifyDomain({ orgId, domainId }) {
322
- let headers = {
323
- "Content-Type": "application/json",
324
- Accept: "application/json",
325
- "x-jibb-user-jwt": await Auth.getUserToken({ accessLevel: accessLevel }),
326
- }
327
- let response = await http.get(
328
- `${Config.apiBaseURL}/v1/admin/organizations/${orgId}/domains/${domainId}/verify`,
329
- headers
330
- )
331
- return response.data
332
- }
333
-
package/src/api/auth.js DELETED
@@ -1,208 +0,0 @@
1
- import { Config } from "../config.js"
2
- import { logger } from "../utils/logger/index.js"
3
- import { AccessLevel, UserClaims } from "../types/types.js"
4
- import { http } from "../utils/http/index.js"
5
-
6
- /**
7
- * @module auth
8
- */
9
-
10
-
11
- /**
12
- * AuthClass.
13
- * @class AuthClass
14
- *
15
- */
16
-
17
- class AuthClass {
18
- #userClaims
19
-
20
- constructor() {
21
- logger.debug("Creating new Auth instance")
22
- this.apiKey = undefined
23
- this.#userClaims = new Map()
24
- this.getIdToken = undefined
25
- }
26
-
27
- /**
28
- * Manually setting userToken
29
- * @param {string} token
30
- * @param {AccessLevel} accessLevel
31
- */
32
- setUserToken(token, accessLevel = AccessLevel.USER) {
33
- let claims = new UserClaims(token)
34
- this.#userClaims.set(accessLevel, claims)
35
- }
36
-
37
- /**
38
- * setting Api key
39
- * @param {string} apiKey
40
- */
41
- setApiKey(apiKey) {
42
- this.apiKey = apiKey
43
- this.#userClaims.clear()
44
- }
45
-
46
- async #getUserTokenFromApiKey({ expiry, accessLevel }) {
47
- let headers = {
48
- "Content-Type": "application/json",
49
- Accept: "application/json",
50
- }
51
- let body = {
52
- api_key: this.apiKey,
53
- expiry: {
54
- seconds: expiry,
55
- },
56
- }
57
- let url
58
-
59
- switch (accessLevel) {
60
- case AccessLevel.ADMIN:
61
- url = `${Config.apiBaseURL}/v1/admin/auth/token`
62
- break
63
- case AccessLevel.SUPERADMIN:
64
- url = `${Config.apiBaseURL}/v1/superadmin/auth/token`
65
- break
66
- default:
67
- url = `${Config.apiBaseURL}/v1/auth/token`
68
- break
69
- }
70
-
71
- let response = await http.post(url, body, headers)
72
- return response.data.token
73
- }
74
-
75
- async #getUserTokenFromIDToken({ expiry, accessLevel }) {
76
- let headers = {
77
- "Content-Type": "application/json",
78
- Accept: "application/json",
79
- "x-jibb-id-jwt": await this.getIdToken(),
80
- }
81
- let body = {
82
- expiry: {
83
- seconds: expiry,
84
- },
85
- }
86
- let url
87
-
88
- switch (accessLevel) {
89
- case AccessLevel.ADMIN:
90
- url = `${Config.apiBaseURL}/v1/admin/auth/token`
91
- break
92
- case AccessLevel.SUPERADMIN:
93
- url = `${Config.apiBaseURL}/v1/superadmin/auth/token`
94
- break
95
- default:
96
- url = `${Config.apiBaseURL}/v1/auth/token`
97
- break
98
- }
99
-
100
- let response = await http.post(url, body, headers)
101
- return response.data.token
102
- }
103
-
104
- /**
105
- *
106
- * @returns {UserClaims}
107
- */
108
- async getUserClaims() {
109
- await this.getUserToken()
110
- return this.#userClaims.get(AccessLevel.USER)
111
- }
112
-
113
- /**
114
- *
115
- * @async
116
- * @param {object} [param0={}]
117
- * @param {Number} [param0.expiry=3600] - meeting ID.
118
- * @param {boolean} [param0.refresh=fales] - 1 Read or 2 Write.
119
- * @param {AccessLevel} [param0.accessLevel=AccessLevel.USER]
120
- * @returns {string} - user Token.
121
- */
122
-
123
- async getUserToken({ expiry, refresh, accessLevel } = {}) {
124
- let claim = undefined
125
- refresh = refresh || false
126
- accessLevel = accessLevel || AccessLevel.USER
127
- expiry = expiry || 3600
128
-
129
- if (refresh === true) {
130
- await this.#refreshUserToken({ expiry, accessLevel })
131
- }
132
-
133
- claim = this.#userClaims.get(accessLevel)
134
- if (claim !== undefined && !claim.isExpired()) return claim.token
135
-
136
- await this.#refreshUserToken({ expiry, accessLevel })
137
-
138
- claim = this.#userClaims.get(accessLevel)
139
- if (claim !== undefined && !claim.isExpired()) return claim.token
140
-
141
- throw new Error("could not create user token")
142
- }
143
-
144
- async #refreshUserToken({ expiry, accessLevel }) {
145
- if (this.apiKey) {
146
- let token = await this.#getUserTokenFromApiKey({ expiry, accessLevel })
147
- this.setUserToken(token, accessLevel)
148
- return token
149
- }
150
-
151
- try {
152
- let token = await this.#getUserTokenFromIDToken({ expiry, accessLevel })
153
- this.setUserToken(token, accessLevel)
154
- return token
155
- } catch (error) {
156
- logger.error(error)
157
- }
158
- }
159
-
160
- /**
161
- * clear user.
162
- */
163
-
164
- logout() {
165
- this.#userClaims.clear()
166
- }
167
-
168
- /**
169
- *
170
- * Generate a new API Key, old API KEY will be discareded
171
- * It require a userToken to be set.
172
- * @returns {string} api key
173
- */
174
- async generateAPIKey() {
175
- let headers = {
176
- "Content-Type": "application/json",
177
- Accept: "application/json",
178
- "x-jibb-user-jwt": await this.getUserToken(),
179
- }
180
- let response = await http.get(`${Config.apiBaseURL}/v1/auth/apikey`, headers)
181
- return response.data.apiKey
182
- }
183
-
184
- /**
185
- *
186
- * Generating a one time password.
187
- * It require a IdToken to be set.
188
- * @async
189
- * @returns {string} - Custom Password.
190
- */
191
- async generateCustomAuthPassword() {
192
- let headers = {
193
- "Content-Type": "application/json",
194
- Accept: "application/json",
195
- "x-jibb-id-jwt": await this.getIdToken(),
196
- }
197
-
198
- let response = await http.get(`${Config.apiBaseURL}/v1/auth/custom`, headers)
199
- return response.data.password
200
- }
201
- }
202
-
203
- /**
204
- * Expotred instance of AuthClass.
205
- * @type {AuthClass}
206
- */
207
- let Auth = new AuthClass()
208
- export { Auth }