@jibb-open/jssdk 3.5.5
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/.babelrc +31 -0
- package/README.md +3 -0
- package/package.json +72 -0
- package/src/api/admin.js +333 -0
- package/src/api/auth.js +208 -0
- package/src/api/eventbus.js +246 -0
- package/src/api/index.js +26 -0
- package/src/api/meeting.js +421 -0
- package/src/api/recording.js +225 -0
- package/src/api/superadmin.js +84 -0
- package/src/api/user.js +46 -0
- package/src/api/webexbot.js +32 -0
- package/src/api/whiteboard.js +175 -0
- package/src/config.js +12 -0
- package/src/examples/browser/462.jibb.js +1 -0
- package/src/examples/browser/index.html +13 -0
- package/src/examples/browser/jibb.js +2 -0
- package/src/examples/browser/startSession.js +112 -0
- package/src/examples/examples.js +5 -0
- package/src/examples/webexDevicesMacros/cameraPresets/jibb.js +338 -0
- package/src/examples/webexDevicesMacros/simplestExample/jibb.js +212 -0
- package/src/examples/webexDevicesMacros/webexDevice JSSDK/jibb_WebexXapi.js +2 -0
- package/src/examples/webexDevicesMacros/withCameraControl/jibb.js +303 -0
- package/src/index.webex-devices.js +13 -0
- package/src/post-processing.js +39 -0
- package/src/types/exceptions.js +48 -0
- package/src/types/jibb.pb.js +1426 -0
- package/src/types/proto.js +7 -0
- package/src/types/types.js +64 -0
- package/src/utils/cached_variable.js +23 -0
- package/src/utils/future.js +24 -0
- package/src/utils/http/http.axios.js +34 -0
- package/src/utils/http/http.xapi.js +87 -0
- package/src/utils/http/index.js +8 -0
- package/src/utils/index.js +5 -0
- package/src/utils/logger/index.js +11 -0
- package/src/utils/logger/logger.empty.js +25 -0
- package/src/utils/logger/logger.pino.js +15 -0
- package/src/ws/connection_base.js +81 -0
- package/src/ws/eventbus.js +363 -0
- package/src/ws/index.js +15 -0
- package/src/ws/ipsa.js +238 -0
- package/src/ws/meeting.js +170 -0
- package/src/ws/observable_connection.js +84 -0
- package/src/ws/retry_connection.js +82 -0
- package/webpack.config.cjs +144 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import jwt_decode from "jwt-decode";
|
|
2
|
+
|
|
3
|
+
export const MeetingTypes = {
|
|
4
|
+
DEFAULT: 0,
|
|
5
|
+
WHITEBOARD: 1,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const AccessLevel = {
|
|
9
|
+
USER: "USER",
|
|
10
|
+
ADMIN: "ADMIN",
|
|
11
|
+
SUPERADMIN: "SUPERADMIN",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const UserType = {
|
|
15
|
+
UNKNOWN: 0,
|
|
16
|
+
LIMITED: 1,
|
|
17
|
+
MEMBER: 2,
|
|
18
|
+
ADMIN: 3,
|
|
19
|
+
OWNER: 4,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export class MeetingClaims {
|
|
23
|
+
constructor(token) {
|
|
24
|
+
this.claims = jwt_decode(token)
|
|
25
|
+
this.expiryTime = new Date(this.claims.exp * 1000)
|
|
26
|
+
this.owner = this.claims.data.owner
|
|
27
|
+
this.meetindId = this.claims.data.meeting_id
|
|
28
|
+
this.title = this.claims.data.title
|
|
29
|
+
this.capacity = this.claims.data.capacity
|
|
30
|
+
this.permission = this.claims.data.permission
|
|
31
|
+
this.meetingType = this.claims.data.meeting_type
|
|
32
|
+
this.isTemporary = this.claims.data.is_temporary
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getSecondsUntilExpiry() {
|
|
36
|
+
return this.expiryTime - Date.now() - 60
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
isExpired() {
|
|
40
|
+
return this.getSecondsUntilExpiry() <= 0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class UserClaims {
|
|
45
|
+
constructor(token) {
|
|
46
|
+
this.token = token
|
|
47
|
+
this.claims = jwt_decode(token)
|
|
48
|
+
this.expiryTime = new Date(this.claims.exp * 1000)
|
|
49
|
+
this.email = this.claims.data?.email
|
|
50
|
+
this.userId = this.claims.sub
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getSecondsUntilExpiry() {
|
|
54
|
+
return this.expiryTime - Date.now() - 60
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
isExpired() {
|
|
58
|
+
return this.getSecondsUntilExpiry() <= 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getUserId() {
|
|
62
|
+
return this.userId
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class CachedVariable {
|
|
2
|
+
constructor(expirySeconds = 60) {
|
|
3
|
+
this.value = null
|
|
4
|
+
this.expirySeconds = expirySeconds
|
|
5
|
+
this.expiryTime = Date.now()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
isExpired() {
|
|
9
|
+
return (this.value == null) || (Date.now() > this.expiryTime)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get() {
|
|
13
|
+
if (this.isExpired())
|
|
14
|
+
return undefined
|
|
15
|
+
else
|
|
16
|
+
return this.value
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set(value) {
|
|
20
|
+
this.value = value
|
|
21
|
+
this.expiryTime = Date.now() + (this.expirySeconds * 1000)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class Future {
|
|
2
|
+
constructor() {
|
|
3
|
+
let self = this
|
|
4
|
+
this.resolve = undefined
|
|
5
|
+
this.reject = undefined
|
|
6
|
+
this.promise = new Promise((resolve, reject) => {
|
|
7
|
+
self.resolve = resolve
|
|
8
|
+
self.reject = reject
|
|
9
|
+
})
|
|
10
|
+
this.promise.catch(() => {return undefined})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get() {
|
|
14
|
+
return this.promise
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
reject(val) {
|
|
18
|
+
this.reject(val)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set(val) {
|
|
22
|
+
this.resolve(val)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import axios from "axios"
|
|
2
|
+
|
|
3
|
+
class HttpClient {
|
|
4
|
+
async get(url, headers, options = {}) {
|
|
5
|
+
options.headers = headers
|
|
6
|
+
return axios.get(url, options)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async post(url, body = {}, headers = {}) {
|
|
10
|
+
return axios.post(url, body, {
|
|
11
|
+
headers: headers,
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async patch(url, body = {}, headers = {}) {
|
|
16
|
+
return axios.patch(url, body, {
|
|
17
|
+
headers: headers,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async put(url, body = {}, headers = {}) {
|
|
22
|
+
return axios.put(url, body, {
|
|
23
|
+
headers: headers,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async delete(url, headers = {}) {
|
|
28
|
+
return axios.delete(url, {
|
|
29
|
+
headers: headers,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
globalThis.http = new HttpClient()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import xapi from "xapi";
|
|
2
|
+
|
|
3
|
+
class HttpClient {
|
|
4
|
+
async get(url, headers) {
|
|
5
|
+
let response = await xapi.Command.HttpClient.Get({
|
|
6
|
+
AllowInsecureHTTPS: "True",
|
|
7
|
+
Header: this.#makeStringHeader(headers),
|
|
8
|
+
Url: url,
|
|
9
|
+
ResultBody: "PlainText",
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
return this.#parseAndChangeResponseKeyName(response)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async post(url, body = {}, headers = {}) {
|
|
16
|
+
let response = await xapi.Command.HttpClient.Post(
|
|
17
|
+
{
|
|
18
|
+
AllowInsecureHTTPS: "True",
|
|
19
|
+
Header: this.#makeStringHeader(headers),
|
|
20
|
+
Url: url,
|
|
21
|
+
ResultBody: "PlainText",
|
|
22
|
+
},
|
|
23
|
+
JSON.stringify(body)
|
|
24
|
+
)
|
|
25
|
+
return this.#parseAndChangeResponseKeyName(response)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async patch(url, body = {}, headers = {}) {
|
|
29
|
+
let response = await xapi.Command.HttpClient.Patch(
|
|
30
|
+
{
|
|
31
|
+
AllowInsecureHTTPS: "True",
|
|
32
|
+
Header: this.#makeStringHeader(headers),
|
|
33
|
+
Url: url,
|
|
34
|
+
ResultBody: "PlainText",
|
|
35
|
+
},
|
|
36
|
+
JSON.stringify(body)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return this.#parseAndChangeResponseKeyName(response)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async put(url, body = {}, headers = {}) {
|
|
43
|
+
let response = await xapi.Command.HttpClient.Put(
|
|
44
|
+
{
|
|
45
|
+
AllowInsecureHTTPS: "True",
|
|
46
|
+
Header: this.#makeStringHeader(headers),
|
|
47
|
+
Url: url,
|
|
48
|
+
ResultBody: "PlainText",
|
|
49
|
+
},
|
|
50
|
+
JSON.stringify(body)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return this.#parseAndChangeResponseKeyName(response)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async delete(url, headers = {}) {
|
|
57
|
+
let response = await xapi.Command.HttpClient.Delete({
|
|
58
|
+
AllowInsecureHTTPS: "True",
|
|
59
|
+
Header: this.#makeStringHeader(headers),
|
|
60
|
+
Url: url,
|
|
61
|
+
ResultBody: "PlainText",
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return this.#parseAndChangeResponseKeyName(response)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#makeStringHeader(header) {
|
|
68
|
+
let result = []
|
|
69
|
+
for (const [k, v] of Object.entries(header)) {
|
|
70
|
+
result.push(`${k}: ${v}`)
|
|
71
|
+
}
|
|
72
|
+
return result
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#parseAndChangeResponseKeyName(obj) {
|
|
76
|
+
let result = obj
|
|
77
|
+
result["data"] = JSON.parse(result.Body)
|
|
78
|
+
delete result["Body"]
|
|
79
|
+
return result
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// webex devices running enviroment dose not have globalThis object, creating global.globalThis.http in this file enable the value assingment index.js line 4
|
|
84
|
+
|
|
85
|
+
global.globalThis = {}
|
|
86
|
+
global.globalThis.http = new HttpClient()
|
|
87
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class EmptyLoggerr {
|
|
2
|
+
error() {
|
|
3
|
+
// This is intentional
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
debug() {
|
|
7
|
+
// This is intentional
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
warn() {
|
|
11
|
+
// This is intentional
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
info() {
|
|
15
|
+
// This is intentional
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setLevel() {
|
|
19
|
+
// This is intentional
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let logger = new EmptyLoggerr()
|
|
24
|
+
|
|
25
|
+
export {logger}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { logger } from "../utils/logger/index.js"
|
|
2
|
+
import { Future } from "../utils/future.js"
|
|
3
|
+
|
|
4
|
+
export const ConnectionStatus = {
|
|
5
|
+
CONNECTED: "CONNECTED",
|
|
6
|
+
DISCONNECTED: "DISCONNECTED",
|
|
7
|
+
CONNECTING: "CONNECTING",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ConnectionBase {
|
|
11
|
+
#name
|
|
12
|
+
#connectionStatus
|
|
13
|
+
#connectionFuture
|
|
14
|
+
|
|
15
|
+
constructor(name) {
|
|
16
|
+
this.#name = name
|
|
17
|
+
this.#connectionStatus = ConnectionStatus.DISCONNECTED
|
|
18
|
+
this.#connectionFuture = new Future()
|
|
19
|
+
this.#connectionFuture.reject("disconnected")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getName() {
|
|
23
|
+
return this.#name
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
connect() {
|
|
27
|
+
switch (this.#connectionStatus) {
|
|
28
|
+
case ConnectionStatus.CONNECTED:
|
|
29
|
+
logger.error(`${this.getName()}: already connected`)
|
|
30
|
+
break
|
|
31
|
+
case ConnectionStatus.CONNECTING:
|
|
32
|
+
logger.error(`${this.getName()}: connection already in progress`)
|
|
33
|
+
break
|
|
34
|
+
case ConnectionStatus.DISCONNECTED:
|
|
35
|
+
logger.info(`${this.getName()}: connecting ...`)
|
|
36
|
+
this.#connectionStatus = ConnectionStatus.CONNECTING
|
|
37
|
+
this.#connectionFuture = new Future()
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
disconnect() {
|
|
43
|
+
this.onDisconnected()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onConnected() {
|
|
47
|
+
logger.info(`${this.getName()}: connected`)
|
|
48
|
+
this.#connectionStatus = ConnectionStatus.CONNECTED
|
|
49
|
+
this.#connectionFuture.set("connected")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
onDisconnected() {
|
|
53
|
+
logger.warn(`${this.getName()}: disconnected`)
|
|
54
|
+
this.#connectionStatus = ConnectionStatus.DISCONNECTED
|
|
55
|
+
this.#connectionFuture.reject("disconnected")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isConnected() {
|
|
59
|
+
return this.#connectionStatus == ConnectionStatus.CONNECTED
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
waitForConnection() {
|
|
63
|
+
return this.#connectionFuture.get()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getConnectionStatus() {
|
|
67
|
+
return this.#connectionStatus
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onErrorMessage(code, reason) {
|
|
71
|
+
logger.warn(`${this.getName()}: onErrorMessage, code: ${code}, reason: ${reason}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onWarningMessage(code, reason) {
|
|
75
|
+
logger.warn(`${this.getName()}: onWarningMessage, code: ${code}, reason: ${reason}`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onInfoMessage(code, reason) {
|
|
79
|
+
logger.info(`${this.getName()}: onInfoMessage, code: ${code}, reason: ${reason}`)
|
|
80
|
+
}
|
|
81
|
+
}
|