@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,246 @@
|
|
|
1
|
+
import {Auth} from './auth.js';
|
|
2
|
+
import {Config} from '../config.js'
|
|
3
|
+
import {http} from "../utils/http/index.js"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EventBus.
|
|
7
|
+
* @module EventBus
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @async
|
|
15
|
+
* @param {string} clientId
|
|
16
|
+
* @returns {array} - list of available camera, each camera is an object of with id and name properties.
|
|
17
|
+
*/
|
|
18
|
+
export async function getCameraList(clientId) {
|
|
19
|
+
let response = await http.get(
|
|
20
|
+
`${Config.apiBaseURL}/v1/eventbus/clients/${clientId}/cameras`,
|
|
21
|
+
await _prepareRequestHeaders()
|
|
22
|
+
)
|
|
23
|
+
return response.data.items
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @async
|
|
29
|
+
* @param {object} param0
|
|
30
|
+
* @param {object} param0.cameraId
|
|
31
|
+
* @param {object} param0.clientId
|
|
32
|
+
* @returns {data}
|
|
33
|
+
*/
|
|
34
|
+
export async function getCameraPreview({ cameraId, clientId }) {
|
|
35
|
+
let body = {
|
|
36
|
+
source: {
|
|
37
|
+
id: cameraId,
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
let response = await http.post(
|
|
41
|
+
`${Config.apiBaseURL}/v1/eventbus/${clientId}/preview`,
|
|
42
|
+
body,
|
|
43
|
+
await _prepareRequestHeaders()
|
|
44
|
+
)
|
|
45
|
+
return response.data.image
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @async
|
|
51
|
+
* @param {object} param0
|
|
52
|
+
* @param {string} param0.meetingId
|
|
53
|
+
* @param {string} param0.meeting_token
|
|
54
|
+
* @param {string} param0.surfaceType - PAPER or WHITEBOARD
|
|
55
|
+
* @param {string} [param0.cameraId] - either sipUri or cameraId should be specified.
|
|
56
|
+
* @param {string} [param0.sipUri] - either sipUri or cameraId should be specified.
|
|
57
|
+
* @param {boolean} [param0.flipLeftRight=false] - mirror output stream.
|
|
58
|
+
* @param {boolean} [param0.flipUpDown=false] - mirror vertically output stream.
|
|
59
|
+
* @param {number} [param0.rotation=0] - output rotation degree 0, 90, 180, 270.
|
|
60
|
+
* @param {boolean} [param0.fixedCorners=fales] - enable srufcae fixed corners after first detection.
|
|
61
|
+
* @param {string} param0.clientId
|
|
62
|
+
* @param {array} [param0.customCorners] - array of 8 Numbers ranged from 0-1 that decribe 4 points based on percentage [x1, y1, x2, y2 ...] example [0.1, 0.1, 0.8, 0.1, 0.1, 0.8, 0.8 ,0.8]
|
|
63
|
+
* @param {boolean} [param0.enableColor]
|
|
64
|
+
* @param {boolean} [param0.enableEstimation]
|
|
65
|
+
* @returns - http result
|
|
66
|
+
*/
|
|
67
|
+
export async function startStream({
|
|
68
|
+
meetingId,
|
|
69
|
+
meetingToken,
|
|
70
|
+
surfaceType,
|
|
71
|
+
cameraId,
|
|
72
|
+
sipUri,
|
|
73
|
+
flipLeftRight,
|
|
74
|
+
flipUpDown,
|
|
75
|
+
rotation,
|
|
76
|
+
fixedCorners,
|
|
77
|
+
clientId,
|
|
78
|
+
customCorners,
|
|
79
|
+
enableColor,
|
|
80
|
+
enableEstimation,
|
|
81
|
+
}) {
|
|
82
|
+
let request = {
|
|
83
|
+
config: {
|
|
84
|
+
surface_type: surfaceType,
|
|
85
|
+
},
|
|
86
|
+
app_config: {
|
|
87
|
+
meeting_id: meetingId,
|
|
88
|
+
meeting_token: meetingToken,
|
|
89
|
+
},
|
|
90
|
+
runtime_config: _makeRuntimeConfig({
|
|
91
|
+
fixedCorners,
|
|
92
|
+
flipLeftRight,
|
|
93
|
+
flipUpDown,
|
|
94
|
+
rotation,
|
|
95
|
+
customCorners,
|
|
96
|
+
enableColor,
|
|
97
|
+
enableEstimation,
|
|
98
|
+
}),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!cameraId && !sipUri) {
|
|
102
|
+
return Promise.reject(`Invalid request: either sipUri or cameraId should be specified`)
|
|
103
|
+
}
|
|
104
|
+
if (cameraId && sipUri) {
|
|
105
|
+
return Promise.reject(`Invalid request: both sipUri (${sipUri}) and cameraId (${sipUri}) are specified`)
|
|
106
|
+
} else if (sipUri) {
|
|
107
|
+
request["sip_uri"] = sipUri
|
|
108
|
+
} else {
|
|
109
|
+
request["camera"] = {
|
|
110
|
+
id: cameraId,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let body = {
|
|
115
|
+
start_request: request,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return http.post(`${Config.apiBaseURL}/v1/eventbus/clients/${clientId}/start`, body, await _prepareRequestHeaders())
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//if there is no body I get error code:401 status:Unauthorized
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @async
|
|
126
|
+
* @param {string} clientId
|
|
127
|
+
* @returns - http result
|
|
128
|
+
*/
|
|
129
|
+
export async function stopStream(clientId) {
|
|
130
|
+
let body = {}
|
|
131
|
+
return http.post(`${Config.apiBaseURL}/v1/eventbus/${clientId}/stop`, body, await _prepareRequestHeaders())
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// the only decent solution that comes to my mind is using body as parameter,
|
|
135
|
+
//other one is having all possible events as paramaters ( more than 13) and then check for null and build the body like jibb.startStream.
|
|
136
|
+
// we can send grpc event data but then client need to have the grpc file and complie it.
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @async
|
|
141
|
+
* @param {string} body
|
|
142
|
+
* @returns - http result.
|
|
143
|
+
*/
|
|
144
|
+
export async function sendMessage(body) {
|
|
145
|
+
return http.post(`${Config.apiBaseURL}/v1/eventbus`, body, await _prepareRequestHeaders())
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* @async
|
|
150
|
+
* @param {object} param0
|
|
151
|
+
* @param {boolean} [param0.flipLeftRight=false] - mirror output stream.
|
|
152
|
+
* @param {boolean} [param0.flipUpDown=false] - mirror vertically output stream.
|
|
153
|
+
* @param {number} [param0.rotation=0] - output rotation degree 0, 90, 180, 270.
|
|
154
|
+
* @param {boolean} [param0.fixedCorners=fales] - enable srufcae fixed corners after first detection.
|
|
155
|
+
* @param {string} param0.clientId
|
|
156
|
+
* @param {array} [param0.customCorners] - array of 8 Numbers ranged from 0-1 that decribe 4 points based on percentage [x1, y1, x2, y2 ...] example [0.1, 0.1, 0.8, 0.1, 0.1, 0.8, 0.8 ,0.8]
|
|
157
|
+
* @param {boolean} [param0.enableColor]
|
|
158
|
+
* @param {boolean} [param0.enableEstimation]
|
|
159
|
+
* @returns - http result.
|
|
160
|
+
*/
|
|
161
|
+
export async function setRuntimeConfig({
|
|
162
|
+
flipLeftRight,
|
|
163
|
+
flipUpDown,
|
|
164
|
+
rotation,
|
|
165
|
+
fixedCorners,
|
|
166
|
+
customCorners,
|
|
167
|
+
clientId,
|
|
168
|
+
enableColor,
|
|
169
|
+
enableEstimation,
|
|
170
|
+
}) {
|
|
171
|
+
let body = {
|
|
172
|
+
runtime_config_request: {
|
|
173
|
+
runtime_config: _makeRuntimeConfig({
|
|
174
|
+
fixedCorners,
|
|
175
|
+
flipLeftRight,
|
|
176
|
+
flipUpDown,
|
|
177
|
+
rotation,
|
|
178
|
+
customCorners,
|
|
179
|
+
enableColor,
|
|
180
|
+
enableEstimation,
|
|
181
|
+
}),
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return http.post(`${Config.apiBaseURL}/v1/eventbus/${clientId}/runtime_config`, body, await _prepareRequestHeaders())
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
*
|
|
191
|
+
* @async
|
|
192
|
+
* @returns {array} - list of connected clients, each clinet is an object with id and type property
|
|
193
|
+
*/
|
|
194
|
+
export async function getClientStatusList() {
|
|
195
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/eventbus/clients`, await _prepareRequestHeaders())
|
|
196
|
+
|
|
197
|
+
return response.data.clients
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function _prepareRequestHeaders() {
|
|
201
|
+
return {
|
|
202
|
+
"Content-Type": "application/json",
|
|
203
|
+
Accept: "application/json",
|
|
204
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function _makeRuntimeConfig({
|
|
209
|
+
fixedCorners,
|
|
210
|
+
flipLeftRight,
|
|
211
|
+
flipUpDown,
|
|
212
|
+
rotation,
|
|
213
|
+
customCorners,
|
|
214
|
+
enableColor,
|
|
215
|
+
enableEstimation,
|
|
216
|
+
}) {
|
|
217
|
+
switch (rotation) {
|
|
218
|
+
case 90:
|
|
219
|
+
rotation = "1"
|
|
220
|
+
break
|
|
221
|
+
case 180:
|
|
222
|
+
case -180:
|
|
223
|
+
rotation = "2"
|
|
224
|
+
break
|
|
225
|
+
case -90:
|
|
226
|
+
case 270:
|
|
227
|
+
rotation = "3"
|
|
228
|
+
break
|
|
229
|
+
case 0:
|
|
230
|
+
case 360:
|
|
231
|
+
default:
|
|
232
|
+
rotation = "0"
|
|
233
|
+
break
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
custom_corners: customCorners || [],
|
|
238
|
+
rotation: rotation,
|
|
239
|
+
enable_color: enableColor || false,
|
|
240
|
+
fixed_corners: fixedCorners,
|
|
241
|
+
enable_estimation: enableEstimation || false,
|
|
242
|
+
flip_up_down: flipUpDown || false,
|
|
243
|
+
flip_left_right: flipLeftRight || false,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
package/src/api/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as WebexBot from "./webexbot.js"
|
|
2
|
+
import * as Meeting from "./meeting.js"
|
|
3
|
+
import * as SuperAdmin from "./superadmin.js"
|
|
4
|
+
import * as Admin from "./admin.js"
|
|
5
|
+
import * as User from "./user.js"
|
|
6
|
+
import {Auth} from "./auth.js"
|
|
7
|
+
import {Whiteboard} from "./whiteboard.js"
|
|
8
|
+
import * as EventBus from "./eventbus.js"
|
|
9
|
+
import * as Recording from "./recording.js"
|
|
10
|
+
import {initPinoLogger} from "../utils/logger/index.js"
|
|
11
|
+
|
|
12
|
+
initPinoLogger()
|
|
13
|
+
|
|
14
|
+
export {WebexBot, Meeting, Auth, User, Admin, SuperAdmin, Recording, Whiteboard, EventBus}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
WebexBot,
|
|
18
|
+
Meeting,
|
|
19
|
+
Auth,
|
|
20
|
+
User,
|
|
21
|
+
Admin,
|
|
22
|
+
SuperAdmin,
|
|
23
|
+
Recording,
|
|
24
|
+
Whiteboard,
|
|
25
|
+
EventBus,
|
|
26
|
+
}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import {Config} from "../config.js"
|
|
2
|
+
import {Auth} from "./auth.js"
|
|
3
|
+
import {logger} from "../utils/logger/index.js"
|
|
4
|
+
import {NotFoundError, PermissionDeniedError} from "../types/exceptions.js"
|
|
5
|
+
import {http} from "../utils/http/index.js"
|
|
6
|
+
import {UserClaims, MeetingClaims, MeetingTypes} from "../types/types.js"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @module meeting
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @async
|
|
17
|
+
* @param {Object} param0
|
|
18
|
+
* @param {string} [param0.title=""] - meeting title.
|
|
19
|
+
* @param {boolean} [param0.isTemporary=false] - meeting won't be saved in dashboard.
|
|
20
|
+
* @param {Number} [param0.capacity=2] - 1 or 2 , number of allowed stream to the meeting.
|
|
21
|
+
* @param {Number} [param0.meetingType=0] - 0 DEFAULT or 1 WHITEBOARD
|
|
22
|
+
* @returns {string} - ID of created meeting
|
|
23
|
+
*/
|
|
24
|
+
export async function createMeeting({title, isTemporary, capacity, meetingType}) {
|
|
25
|
+
let headers = {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
Accept: "application/json",
|
|
28
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
29
|
+
}
|
|
30
|
+
let body = {
|
|
31
|
+
title: title || "",
|
|
32
|
+
isTemporary: isTemporary || false,
|
|
33
|
+
capacity: capacity || 2,
|
|
34
|
+
meetingType: meetingType || MeetingTypes.DEFAULT,
|
|
35
|
+
}
|
|
36
|
+
let response = await http.post(`${Config.apiBaseURL}/v1/meetings`, body, headers)
|
|
37
|
+
return response.data.meetingId
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @export export async function function
|
|
43
|
+
* @param {object} param0
|
|
44
|
+
* @param {string} param0.meetingId - meeting ID.
|
|
45
|
+
* @param {Number} param0.permission - 1 Read or 2 Write.
|
|
46
|
+
* @param {Number} [param0.expiry=3600] - share time expiry in seconds.
|
|
47
|
+
* @param {object} [param0.auxData={}] - object that can be used to include specific data in meeting share like call ID for this share.
|
|
48
|
+
* @returns {string} - shareId
|
|
49
|
+
*/
|
|
50
|
+
export async function createTemporaryShare({meetingId, permission, expiry, auxData}) {
|
|
51
|
+
let headers = {
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
Accept: "application/json",
|
|
54
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
55
|
+
}
|
|
56
|
+
let body = {
|
|
57
|
+
permission: permission,
|
|
58
|
+
expiry: {
|
|
59
|
+
seconds: expiry || 3600,
|
|
60
|
+
},
|
|
61
|
+
auxilary: auxData || {},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let response = await http.post(`${Config.apiBaseURL}/v1/meetings/${meetingId}/temp-shares`, body, headers)
|
|
65
|
+
return response.data.shareId
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @async
|
|
71
|
+
* @param {object} param0
|
|
72
|
+
* @param {string} param0.meetingId
|
|
73
|
+
* @param {string} param0.shareId
|
|
74
|
+
* @returns {string} - token
|
|
75
|
+
*/
|
|
76
|
+
export async function getMeetingTokenFromTempShareId({meetingId, shareId}) {
|
|
77
|
+
let headers = {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
Accept: "application/json",
|
|
80
|
+
}
|
|
81
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/${meetingId}/temp-shares/${shareId}`, headers)
|
|
82
|
+
return response.data.token
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @async
|
|
88
|
+
* @param {object} param0
|
|
89
|
+
* @param {string} param0.meetingId
|
|
90
|
+
* @param {string} param0.mtoken
|
|
91
|
+
* @returns - http response
|
|
92
|
+
*/
|
|
93
|
+
export async function deleteMeetingImages({meetingId, mtoken}) {
|
|
94
|
+
let headers = {
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "application/json",
|
|
97
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
98
|
+
"x-jibb-meeting-jwt": mtoken,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return http.delete(`${Config.apiBaseURL}/v1/meetings/${meetingId}/images`, headers)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @async
|
|
107
|
+
* @param {object} param0
|
|
108
|
+
* @param {string} param0.meetingId
|
|
109
|
+
* @param {string} param0.meetingToken
|
|
110
|
+
* @returns {Array} - list of images
|
|
111
|
+
*/
|
|
112
|
+
export async function getMeetingImages({meetingId, meetingToken}) {
|
|
113
|
+
let headers = {
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
Accept: "application/json",
|
|
116
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
117
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/${meetingId}/images`, headers)
|
|
121
|
+
return response.data
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @async
|
|
127
|
+
* @param {object} param0
|
|
128
|
+
* @param {string} param0.meetingId
|
|
129
|
+
* @param {string} param0.meetingToken
|
|
130
|
+
* @param {string} param0.imageId
|
|
131
|
+
* @returns {data} - base64 data
|
|
132
|
+
*/
|
|
133
|
+
export async function getMeetingImage({meetingId, meetingToken, imageId}) {
|
|
134
|
+
let headers = {
|
|
135
|
+
"Content-Type": "application/json",
|
|
136
|
+
Accept: "application/json",
|
|
137
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
138
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/${meetingId}/images/${imageId}`, headers)
|
|
142
|
+
return response.data
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
* @async
|
|
148
|
+
* @param {object} param0
|
|
149
|
+
* @param {string} param0.meetingId
|
|
150
|
+
* @param {string} param0.meetingToken
|
|
151
|
+
* @returns - http response
|
|
152
|
+
*/
|
|
153
|
+
export async function startMeeting({meetingId, meetingToken}) {
|
|
154
|
+
let headers = {
|
|
155
|
+
"Content-Type": "application/json",
|
|
156
|
+
Accept: "application/json",
|
|
157
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
let body = {}
|
|
162
|
+
return await http.post(`${Config.apiBaseURL}/v1/meetings/${meetingId}/actions/start`, body, headers)
|
|
163
|
+
} catch (e) {
|
|
164
|
+
if (e?.response?.status == 404) throw new NotFoundError()
|
|
165
|
+
else throw e
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @async
|
|
172
|
+
* @param {object} param0
|
|
173
|
+
* @param {string} param0.meetingId
|
|
174
|
+
* @param {string} param0.meetingToken
|
|
175
|
+
* @returns - http response
|
|
176
|
+
*/
|
|
177
|
+
export async function endMeeting({meetingId, meetingToken}) {
|
|
178
|
+
let headers = {
|
|
179
|
+
"Content-Type": "application/json",
|
|
180
|
+
Accept: "application/json",
|
|
181
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
182
|
+
}
|
|
183
|
+
let body = {}
|
|
184
|
+
return http.post(`${Config.apiBaseURL}/v1/meetings/${meetingId}/actions/end`, body, headers)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @async
|
|
190
|
+
* @param {string} meetingId
|
|
191
|
+
* @returns - http response
|
|
192
|
+
*/
|
|
193
|
+
export async function deleteMeeting(meetingId) {
|
|
194
|
+
let headers = {
|
|
195
|
+
"Content-Type": "application/json",
|
|
196
|
+
Accept: "application/json",
|
|
197
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
198
|
+
}
|
|
199
|
+
return http.delete(`${Config.apiBaseURL}/v1/meetings/${meetingId}`, headers)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
* @async
|
|
205
|
+
* @param {object} param0
|
|
206
|
+
* @param {string} param0.meetingId
|
|
207
|
+
* @param {Number} param0.permission - 1 Read or 2 Write.
|
|
208
|
+
* @param {Number} [param0.expiry=3600] - share time expiry in seconds.
|
|
209
|
+
* @returns {string} - token
|
|
210
|
+
*/
|
|
211
|
+
export async function getMeetingToken({meetingId, permission, expiry = 3600}) {
|
|
212
|
+
let userToken
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
userToken = await Auth.getUserToken()
|
|
216
|
+
} catch (err) {
|
|
217
|
+
logger.error({
|
|
218
|
+
err,
|
|
219
|
+
})
|
|
220
|
+
throw new PermissionDeniedError("user is not authenticated")
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
let headers = {
|
|
225
|
+
"Content-Type": "application/json",
|
|
226
|
+
Accept: "application/json",
|
|
227
|
+
"x-jibb-user-jwt": userToken,
|
|
228
|
+
}
|
|
229
|
+
let response = await http.get(
|
|
230
|
+
`${Config.apiBaseURL}/v1/meetings/${meetingId}/token/${permission}?expiry.seconds=${expiry}`,
|
|
231
|
+
|
|
232
|
+
headers
|
|
233
|
+
)
|
|
234
|
+
return response.data.token
|
|
235
|
+
} catch (err) {
|
|
236
|
+
if (err?.response?.status == 404) throw new NotFoundError("meeting not found")
|
|
237
|
+
else throw err
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
*
|
|
243
|
+
* @async
|
|
244
|
+
* @param {*} pagination
|
|
245
|
+
* @returns {Array} - meeting list.
|
|
246
|
+
*/
|
|
247
|
+
export async function getMeetingList(pagination) {
|
|
248
|
+
let headers = {
|
|
249
|
+
"Content-Type": "application/json",
|
|
250
|
+
Accept: "application/json",
|
|
251
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
252
|
+
}
|
|
253
|
+
if (pagination !== undefined) headers["x-jibb-pagination"] = JSON.stringify(pagination)
|
|
254
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings`, headers)
|
|
255
|
+
pagination = response.headers["x-jibb-pagination"]
|
|
256
|
+
pagination = pagination && JSON.parse(pagination)
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
meetings: response.data.meetings,
|
|
260
|
+
pagination: pagination,
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
*
|
|
266
|
+
* @async
|
|
267
|
+
* @param {string} meetingId
|
|
268
|
+
* @returns {object} - object with meeting details.
|
|
269
|
+
*/
|
|
270
|
+
export async function getMeetingDetails(meetingId) {
|
|
271
|
+
let headers = {
|
|
272
|
+
"Content-Type": "application/json",
|
|
273
|
+
Accept: "application/json",
|
|
274
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/${meetingId}`, headers)
|
|
278
|
+
return response.data
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
*
|
|
283
|
+
* @async
|
|
284
|
+
* @param {object} param0
|
|
285
|
+
* @param {string} param0.meetingId
|
|
286
|
+
* @param {string} param0.title
|
|
287
|
+
* @param {Number} param0.capacity
|
|
288
|
+
* @returns - http result
|
|
289
|
+
*/
|
|
290
|
+
export async function updateMeeting({meetingId, title, capacity}) {
|
|
291
|
+
let headers = {
|
|
292
|
+
"Content-Type": "application/json",
|
|
293
|
+
Accept: "application/json",
|
|
294
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
let body = {}
|
|
298
|
+
if (title) {
|
|
299
|
+
body["title"] = title
|
|
300
|
+
}
|
|
301
|
+
if (capacity) {
|
|
302
|
+
body["capacity"] = capacity
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return http.post(`${Config.apiBaseURL}/v1/meetings/${meetingId}`, body, headers)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
* @async
|
|
311
|
+
* @param {string} meetingToken
|
|
312
|
+
* @returns {Boolean}
|
|
313
|
+
*/
|
|
314
|
+
export async function isMeetingOwner(meetingToken) {
|
|
315
|
+
try {
|
|
316
|
+
let meetingClaims = new MeetingClaims(meetingToken)
|
|
317
|
+
let userClaims = new UserClaims(await Auth.getUserToken())
|
|
318
|
+
return userClaims.email === meetingClaims.owner
|
|
319
|
+
} catch (err) {
|
|
320
|
+
return false
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @async
|
|
327
|
+
* @param {object} param0
|
|
328
|
+
* @param {string} param0.email
|
|
329
|
+
* @param {string} param0.meetingId
|
|
330
|
+
* @param {Number} param0.permission - 1 Read or 2 Write.
|
|
331
|
+
* @param {string} param0.meetingToken
|
|
332
|
+
* @returns {string}
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
export async function createShare({email, meetingId, permission, meetingToken}) {
|
|
336
|
+
let headers = {
|
|
337
|
+
"Content-Type": "application/json",
|
|
338
|
+
Accept: "application/json",
|
|
339
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
340
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
341
|
+
}
|
|
342
|
+
let body = {
|
|
343
|
+
email: email,
|
|
344
|
+
permission: permission,
|
|
345
|
+
}
|
|
346
|
+
let response = await http.post(`${Config.apiBaseURL}/v1/meetings/${meetingId}/shares`, body, headers)
|
|
347
|
+
return response.data
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
*
|
|
352
|
+
* @async
|
|
353
|
+
* @param {object} param0
|
|
354
|
+
* @param {string} param0.meetingId
|
|
355
|
+
* @param {string} param0.meetingToken
|
|
356
|
+
* @returns {list} - list of shares of this meeting
|
|
357
|
+
*/
|
|
358
|
+
export async function getListShare({meetingId, meetingToken}) {
|
|
359
|
+
let headers = {
|
|
360
|
+
"Content-Type": "application/json",
|
|
361
|
+
Accept: "application/json",
|
|
362
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
363
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
364
|
+
}
|
|
365
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/${meetingId}/shares`, headers)
|
|
366
|
+
|
|
367
|
+
return response.data.shares
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* @async
|
|
373
|
+
* @param {object} param0
|
|
374
|
+
* @param {string} param0.meetingId
|
|
375
|
+
* @param {string} param0.userId
|
|
376
|
+
* @param {string} param0.meetingToken
|
|
377
|
+
* @returns - http result
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
export async function deleteShare({meetingId, userId, meetingToken}) {
|
|
381
|
+
let headers = {
|
|
382
|
+
"Content-Type": "application/json",
|
|
383
|
+
Accept: "application/json",
|
|
384
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
385
|
+
"x-jibb-meeting-jwt": meetingToken,
|
|
386
|
+
}
|
|
387
|
+
return http.delete(`${Config.apiBaseURL}/v1/meetings/${meetingId}/shares/${userId}`, headers)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
*
|
|
392
|
+
* @async
|
|
393
|
+
* @returns {array} - list of meeting shared with me.
|
|
394
|
+
*/
|
|
395
|
+
export async function getListShareMe() {
|
|
396
|
+
let headers = {
|
|
397
|
+
"Content-Type": "application/json",
|
|
398
|
+
Accept: "application/json",
|
|
399
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
400
|
+
}
|
|
401
|
+
let response = await http.get(`${Config.apiBaseURL}/v1/meetings/shares`, headers)
|
|
402
|
+
|
|
403
|
+
return response.data.shares
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @param {string} meetingId
|
|
409
|
+
* @returns - http result.
|
|
410
|
+
*/
|
|
411
|
+
export async function deleteShareMe(meetingId) {
|
|
412
|
+
let headers = {
|
|
413
|
+
"Content-Type": "application/json",
|
|
414
|
+
Accept: "application/json",
|
|
415
|
+
"x-jibb-user-jwt": await Auth.getUserToken(),
|
|
416
|
+
}
|
|
417
|
+
return http.delete(`${Config.apiBaseURL}/v1/meetings/shares/${meetingId}`, headers)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|