@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/api/auth.js
CHANGED
|
@@ -1 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.promise.js";
|
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
|
+
import { Config } from "../config.js";
|
|
4
|
+
import { AccessLevel, UserClaims } from "../types/types.js";
|
|
5
|
+
import { http } from "../utils/http/index.js";
|
|
6
|
+
let _userClaims = new Map();
|
|
7
|
+
let _apiKey = undefined;
|
|
8
|
+
let _getIdToken = async () => {
|
|
9
|
+
throw new Error("not implemented");
|
|
10
|
+
};
|
|
11
|
+
export function configure(_ref) {
|
|
12
|
+
let {
|
|
13
|
+
apiKey,
|
|
14
|
+
getIdToken
|
|
15
|
+
} = _ref;
|
|
16
|
+
if (apiKey) _apiKey = apiKey;
|
|
17
|
+
if (getIdToken) _getIdToken = getIdToken;
|
|
18
|
+
_userClaims.clear();
|
|
19
|
+
}
|
|
20
|
+
export function setUserToken(token) {
|
|
21
|
+
let accessLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AccessLevel.USER;
|
|
22
|
+
if (!token) return;
|
|
23
|
+
let c = new UserClaims(token);
|
|
24
|
+
if (!c.isExpired()) _userClaims.set(accessLevel, c);
|
|
25
|
+
}
|
|
26
|
+
export async function getUserClaims() {
|
|
27
|
+
return getUserToken().then(_token => {
|
|
28
|
+
return _userClaims.get(AccessLevel.USER);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export async function getUserToken() {
|
|
32
|
+
let {
|
|
33
|
+
minExpiry,
|
|
34
|
+
accessLevel
|
|
35
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
+
minExpiry = minExpiry || 30 * 60;
|
|
37
|
+
accessLevel = accessLevel || AccessLevel.USER;
|
|
38
|
+
let claim = _userClaims.get(accessLevel);
|
|
39
|
+
let refresh = false;
|
|
40
|
+
let exp = claim ? claim.getSecondsUntilExpiry() : 0;
|
|
41
|
+
if (exp < 60) {
|
|
42
|
+
claim = undefined;
|
|
43
|
+
refresh = true;
|
|
44
|
+
} else if (exp < minExpiry) refresh = true;
|
|
45
|
+
if (refresh) {
|
|
46
|
+
return _refreshUserToken(accessLevel).then(token => {
|
|
47
|
+
setUserToken(token, accessLevel);
|
|
48
|
+
return token;
|
|
49
|
+
}).catch(_err => {
|
|
50
|
+
if (claim) return claim.token;else throw _err;
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
if (claim) return claim.token;else throw new Error("could not create user token");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function logout() {
|
|
57
|
+
_apiKey = undefined;
|
|
58
|
+
_userClaims.clear();
|
|
59
|
+
}
|
|
60
|
+
export async function generateAPIKey() {
|
|
61
|
+
let headers = {
|
|
62
|
+
"Content-Type": "application/json",
|
|
63
|
+
Accept: "application/json",
|
|
64
|
+
"x-jibb-user-jwt": await getUserToken()
|
|
65
|
+
};
|
|
66
|
+
let response = await http.get("".concat(Config.apiBaseURL, "/v1/auth/apikey"), headers);
|
|
67
|
+
return response.data.apiKey;
|
|
68
|
+
}
|
|
69
|
+
export async function generateCustomAuthPassword() {
|
|
70
|
+
let headers = {
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
Accept: "application/json",
|
|
73
|
+
"x-jibb-id-jwt": await _getIdToken()
|
|
74
|
+
};
|
|
75
|
+
let response = await http.get("".concat(Config.apiBaseURL, "/v1/auth/custom"), headers);
|
|
76
|
+
return response.data.password;
|
|
77
|
+
}
|
|
78
|
+
async function _getUserTokenFromApiKey(accessLevel) {
|
|
79
|
+
let headers = {
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
Accept: "application/json"
|
|
82
|
+
};
|
|
83
|
+
let body = {
|
|
84
|
+
api_key: _apiKey
|
|
85
|
+
};
|
|
86
|
+
let url;
|
|
87
|
+
switch (accessLevel) {
|
|
88
|
+
case AccessLevel.ADMIN:
|
|
89
|
+
url = "".concat(Config.apiBaseURL, "/v1/admin/auth/token");
|
|
90
|
+
break;
|
|
91
|
+
case AccessLevel.SUPERADMIN:
|
|
92
|
+
url = "".concat(Config.apiBaseURL, "/v1/superadmin/auth/token");
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
url = "".concat(Config.apiBaseURL, "/v1/auth/token");
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
let response = await http.post(url, body, headers);
|
|
99
|
+
return response.data.token;
|
|
100
|
+
}
|
|
101
|
+
async function _getUserTokenFromIDToken(accessLevel) {
|
|
102
|
+
let headers = {
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
Accept: "application/json",
|
|
105
|
+
"x-jibb-id-jwt": await _getIdToken()
|
|
106
|
+
};
|
|
107
|
+
let body = {};
|
|
108
|
+
let url;
|
|
109
|
+
switch (accessLevel) {
|
|
110
|
+
case AccessLevel.ADMIN:
|
|
111
|
+
url = "".concat(Config.apiBaseURL, "/v1/admin/auth/token");
|
|
112
|
+
break;
|
|
113
|
+
case AccessLevel.SUPERADMIN:
|
|
114
|
+
url = "".concat(Config.apiBaseURL, "/v1/superadmin/auth/token");
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
url = "".concat(Config.apiBaseURL, "/v1/auth/token");
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
let response = await http.post(url, body, headers);
|
|
121
|
+
return response.data.token;
|
|
122
|
+
}
|
|
123
|
+
async function _refreshUserToken(accessLevel) {
|
|
124
|
+
if (_apiKey) return _getUserTokenFromApiKey(accessLevel);
|
|
125
|
+
return _getUserTokenFromIDToken(accessLevel);
|
|
126
|
+
}
|
package/api/cisco.js
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.json.stringify.js";
|
|
2
|
+
import "core-js/modules/es.promise.js";
|
|
3
|
+
import { Config } from "../config.js";
|
|
4
|
+
export async function getMacro(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
apiKey,
|
|
7
|
+
selectInputs,
|
|
8
|
+
cameraControl,
|
|
9
|
+
mtr
|
|
10
|
+
} = _ref;
|
|
11
|
+
let body = {
|
|
12
|
+
api_key: apiKey,
|
|
13
|
+
select_inputs: selectInputs,
|
|
14
|
+
camera_controls: cameraControl,
|
|
15
|
+
mtr: mtr
|
|
16
|
+
};
|
|
17
|
+
return httpPost("".concat(Config.apiBaseURL, "/v1/cisco/macro"), body);
|
|
18
|
+
}
|
|
19
|
+
export async function getJSSDK() {
|
|
20
|
+
return httpGet("".concat(Config.apiBaseURL, "/v1/cisco/jssdk"));
|
|
21
|
+
}
|
|
22
|
+
export async function getManifest() {
|
|
23
|
+
return httpGet("".concat(Config.apiBaseURL, "/v1/cisco/integration/manifest"));
|
|
24
|
+
}
|
|
25
|
+
function httpGet(theUrl) {
|
|
26
|
+
let xmlHttp = new XMLHttpRequest();
|
|
27
|
+
xmlHttp.open("GET", theUrl, false);
|
|
28
|
+
xmlHttp.send(null);
|
|
29
|
+
return xmlHttp.responseText;
|
|
30
|
+
}
|
|
31
|
+
function httpPost(theUrl, body) {
|
|
32
|
+
let xmlHttp = new XMLHttpRequest();
|
|
33
|
+
xmlHttp.open("POST", theUrl, false);
|
|
34
|
+
xmlHttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
35
|
+
xmlHttp.send(JSON.stringify(body));
|
|
36
|
+
return xmlHttp.responseText;
|
|
37
|
+
}
|
package/api/eventbus.js
CHANGED
|
@@ -1 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.promise.js";
|
|
2
|
+
import { getUserToken } from './auth.js';
|
|
3
|
+
import { Config } from '../config.js';
|
|
4
|
+
import { http } from "../utils/http/index.js";
|
|
5
|
+
export async function getCameraList(clientId) {
|
|
6
|
+
let response = await http.get("".concat(Config.apiBaseURL, "/v1/eventbus/clients/").concat(clientId, "/cameras"), await _prepareRequestHeaders());
|
|
7
|
+
return response.data.items;
|
|
8
|
+
}
|
|
9
|
+
export async function getCameraPreview(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
cameraId,
|
|
12
|
+
clientId
|
|
13
|
+
} = _ref;
|
|
14
|
+
let body = {
|
|
15
|
+
source: {
|
|
16
|
+
id: cameraId
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
let response = await http.get("".concat(Config.apiBaseURL, "/v1/eventbus/clients/").concat(clientId, "/cameras/").concat(cameraId), await _prepareRequestHeaders());
|
|
20
|
+
return response.data.image;
|
|
21
|
+
}
|
|
22
|
+
export async function startStream(_ref2) {
|
|
23
|
+
let {
|
|
24
|
+
meetingToken,
|
|
25
|
+
surfaceType,
|
|
26
|
+
cameraId,
|
|
27
|
+
sipUri,
|
|
28
|
+
flipLeftRight,
|
|
29
|
+
flipUpDown,
|
|
30
|
+
rotation,
|
|
31
|
+
fixedCorners,
|
|
32
|
+
clientId,
|
|
33
|
+
customCorners,
|
|
34
|
+
enableColor,
|
|
35
|
+
enableEstimation
|
|
36
|
+
} = _ref2;
|
|
37
|
+
let request = {
|
|
38
|
+
config: {
|
|
39
|
+
surface_type: surfaceType
|
|
40
|
+
},
|
|
41
|
+
runtime_config: _makeRuntimeConfig({
|
|
42
|
+
fixedCorners,
|
|
43
|
+
flipLeftRight,
|
|
44
|
+
flipUpDown,
|
|
45
|
+
rotation,
|
|
46
|
+
customCorners,
|
|
47
|
+
enableColor,
|
|
48
|
+
enableEstimation
|
|
49
|
+
}),
|
|
50
|
+
meeting_token: meetingToken
|
|
51
|
+
};
|
|
52
|
+
if (!cameraId && !sipUri) {
|
|
53
|
+
return Promise.reject("Invalid request: either sipUri or cameraId should be specified");
|
|
54
|
+
}
|
|
55
|
+
if (cameraId && sipUri) {
|
|
56
|
+
return Promise.reject("Invalid request: both sipUri (".concat(sipUri, ") and cameraId (").concat(sipUri, ") are specified"));
|
|
57
|
+
} else if (sipUri) {
|
|
58
|
+
request["sip_uri"] = sipUri;
|
|
59
|
+
} else {
|
|
60
|
+
request["camera"] = {
|
|
61
|
+
id: cameraId
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
let body = {
|
|
65
|
+
start_request: request
|
|
66
|
+
};
|
|
67
|
+
return http.post("".concat(Config.apiBaseURL, "/v1/eventbus/clients/").concat(clientId, "/start"), body, await _prepareRequestHeaders());
|
|
68
|
+
}
|
|
69
|
+
export async function stopStream(clientId) {
|
|
70
|
+
let body = {};
|
|
71
|
+
return http.post("".concat(Config.apiBaseURL, "/v1/eventbus/").concat(clientId, "/stop"), body, await _prepareRequestHeaders());
|
|
72
|
+
}
|
|
73
|
+
export async function sendMessage(body) {
|
|
74
|
+
return http.post("".concat(Config.apiBaseURL, "/v1/eventbus"), body, await _prepareRequestHeaders());
|
|
75
|
+
}
|
|
76
|
+
export async function setRuntimeConfig(_ref3) {
|
|
77
|
+
let {
|
|
78
|
+
flipLeftRight,
|
|
79
|
+
flipUpDown,
|
|
80
|
+
rotation,
|
|
81
|
+
fixedCorners,
|
|
82
|
+
customCorners,
|
|
83
|
+
clientId,
|
|
84
|
+
enableColor,
|
|
85
|
+
enableEstimation
|
|
86
|
+
} = _ref3;
|
|
87
|
+
let body = {
|
|
88
|
+
runtime_config_request: {
|
|
89
|
+
runtime_config: _makeRuntimeConfig({
|
|
90
|
+
fixedCorners,
|
|
91
|
+
flipLeftRight,
|
|
92
|
+
flipUpDown,
|
|
93
|
+
rotation,
|
|
94
|
+
customCorners,
|
|
95
|
+
enableColor,
|
|
96
|
+
enableEstimation
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return http.post("".concat(Config.apiBaseURL, "/v1/eventbus/").concat(clientId, "/runtime_config"), body, await _prepareRequestHeaders());
|
|
101
|
+
}
|
|
102
|
+
export async function getClientStatusList() {
|
|
103
|
+
let response = await http.get("".concat(Config.apiBaseURL, "/v1/eventbus/clients"), await _prepareRequestHeaders());
|
|
104
|
+
return response.data.clients;
|
|
105
|
+
}
|
|
106
|
+
async function _prepareRequestHeaders() {
|
|
107
|
+
return {
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
"x-jibb-user-jwt": await getUserToken()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function _makeRuntimeConfig(_ref4) {
|
|
114
|
+
let {
|
|
115
|
+
fixedCorners,
|
|
116
|
+
flipLeftRight,
|
|
117
|
+
flipUpDown,
|
|
118
|
+
rotation,
|
|
119
|
+
customCorners,
|
|
120
|
+
enableColor,
|
|
121
|
+
enableEstimation
|
|
122
|
+
} = _ref4;
|
|
123
|
+
switch (rotation) {
|
|
124
|
+
case 90:
|
|
125
|
+
rotation = "1";
|
|
126
|
+
break;
|
|
127
|
+
case 180:
|
|
128
|
+
case -180:
|
|
129
|
+
rotation = "2";
|
|
130
|
+
break;
|
|
131
|
+
case -90:
|
|
132
|
+
case 270:
|
|
133
|
+
rotation = "3";
|
|
134
|
+
break;
|
|
135
|
+
case 0:
|
|
136
|
+
case 360:
|
|
137
|
+
default:
|
|
138
|
+
rotation = "0";
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
custom_corners: customCorners || [],
|
|
143
|
+
rotation: rotation,
|
|
144
|
+
enable_color: enableColor || false,
|
|
145
|
+
fixed_corners: fixedCorners,
|
|
146
|
+
enable_estimation: enableEstimation || false,
|
|
147
|
+
flip_up_down: flipUpDown || false,
|
|
148
|
+
flip_left_right: flipLeftRight || false
|
|
149
|
+
};
|
|
150
|
+
}
|
package/api/index.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import * as WebexBot from "./webexbot.js";
|
|
2
|
+
import * as Meeting from "./meeting.js";
|
|
3
|
+
import * as User from "./user.js";
|
|
4
|
+
import * as Auth from "./auth.js";
|
|
5
|
+
import * as EventBus from "./eventbus.js";
|
|
6
|
+
import * as Recording from "./recording.js";
|
|
7
|
+
import { Whiteboard } from "./whiteboard.js";
|
|
8
|
+
import { initPinoLogger } from "../utils/logger/index.js";
|
|
9
|
+
import { initAxios } from "../utils/http/index.js";
|
|
10
|
+
initPinoLogger();
|
|
11
|
+
initAxios();
|
|
12
|
+
export { WebexBot, Meeting, Auth, User, Recording, Whiteboard, EventBus };
|
|
13
|
+
export default {
|
|
14
|
+
WebexBot,
|
|
15
|
+
Meeting,
|
|
16
|
+
Auth,
|
|
17
|
+
User,
|
|
18
|
+
Recording,
|
|
19
|
+
Whiteboard,
|
|
20
|
+
EventBus
|
|
21
|
+
};
|