@jibb-open/jssdk 3.5.7 → 3.5.9

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 (42) hide show
  1. package/dist/api/admin.js +418 -0
  2. package/dist/api/auth.js +246 -0
  3. package/dist/api/eventbus.js +249 -0
  4. package/dist/api/index.js +53 -0
  5. package/dist/api/meeting.js +488 -0
  6. package/dist/api/recording.js +260 -0
  7. package/dist/api/superadmin.js +105 -0
  8. package/dist/api/user.js +51 -0
  9. package/dist/api/webexbot.js +41 -0
  10. package/dist/api/whiteboard.js +179 -0
  11. package/dist/config.js +16 -0
  12. package/dist/examples/browser/462.jibb.js +306 -0
  13. package/dist/examples/browser/index.html +17 -0
  14. package/dist/examples/browser/jibb.js +7381 -0
  15. package/dist/examples/browser/startSession.js +102 -0
  16. package/dist/examples/examples.js +6 -0
  17. package/dist/examples/webexDevicesMacros/cameraPresets/jibb.js +280 -0
  18. package/dist/examples/webexDevicesMacros/simplestExample/jibb.js +182 -0
  19. package/dist/examples/webexDevicesMacros/webexDevice JSSDK/jibb_WebexXapi.js +3033 -0
  20. package/dist/examples/webexDevicesMacros/withCameraControl/jibb.js +264 -0
  21. package/dist/package.json +69 -0
  22. package/dist/post-processing.js +43 -0
  23. package/dist/types/exceptions.js +55 -0
  24. package/dist/types/jibb.pb.js +1324 -0
  25. package/dist/types/proto.js +15 -0
  26. package/dist/types/types.js +67 -0
  27. package/dist/utils/cached_variable.js +25 -0
  28. package/dist/utils/future.js +31 -0
  29. package/dist/utils/http/http.axios.js +41 -0
  30. package/dist/utils/http/index.js +10 -0
  31. package/dist/utils/index.js +11 -0
  32. package/dist/utils/logger/index.js +19 -0
  33. package/dist/utils/logger/logger.empty.js +25 -0
  34. package/dist/utils/logger/logger.pino.js +19 -0
  35. package/dist/ws/connection_base.js +95 -0
  36. package/dist/ws/eventbus.js +376 -0
  37. package/dist/ws/index.js +36 -0
  38. package/dist/ws/ipsa.js +262 -0
  39. package/dist/ws/meeting.js +181 -0
  40. package/dist/ws/observable_connection.js +87 -0
  41. package/dist/ws/retry_connection.js +94 -0
  42. package/package.json +1 -1
@@ -0,0 +1,418 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SendUserActivationEmail = SendUserActivationEmail;
7
+ exports.createDomain = createDomain;
8
+ exports.createOrganizationUser = createOrganizationUser;
9
+ exports.createUsers = createUsers;
10
+ exports.deleteDomain = deleteDomain;
11
+ exports.deleteOrganizationUser = deleteOrganizationUser;
12
+ exports.deleteSAML = deleteSAML;
13
+ exports.getDomainList = getDomainList;
14
+ exports.getOrganizationDetails = getOrganizationDetails;
15
+ exports.getOrganizationList = getOrganizationList;
16
+ exports.getOrganizationUserDetails = getOrganizationUserDetails;
17
+ exports.getSAML = getSAML;
18
+ exports.getUserList = getUserList;
19
+ exports.setSAML = setSAML;
20
+ exports.updateUserType = updateUserType;
21
+ exports.verifyDomain = verifyDomain;
22
+ require("core-js/modules/es.promise.js");
23
+ require("core-js/modules/es.json.stringify.js");
24
+ var _config = require("../config.js");
25
+ var _index = require("../utils/http/index.js");
26
+ var _auth = require("./auth.js");
27
+ var _types = require("../types/types.js");
28
+ /**
29
+ *
30
+ * @module admin
31
+ * This is an experimental API.
32
+ */
33
+
34
+ const accessLevel = _types.AccessLevel.ADMIN;
35
+
36
+ /**
37
+ *
38
+ *
39
+ * @async
40
+ * @returns {array} - list of Organization
41
+ */
42
+ async function getOrganizationList() {
43
+ let headers = {
44
+ "Content-Type": "application/json",
45
+ Accept: "application/json",
46
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
47
+ accessLevel: accessLevel
48
+ })
49
+ };
50
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations"), headers);
51
+ return response.data.organizations;
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @async
57
+ * @param {number} orgId
58
+ * @returns {object}
59
+ */
60
+ async function getOrganizationDetails(orgId) {
61
+ if (orgId === "") {
62
+ throw new Error("organization ID can not be empty");
63
+ }
64
+ let headers = {
65
+ "Content-Type": "application/json",
66
+ Accept: "application/json",
67
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
68
+ accessLevel: accessLevel
69
+ })
70
+ };
71
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId), headers);
72
+ return response.data;
73
+ }
74
+
75
+ /**
76
+ *
77
+ * @async
78
+ * @param {number} orgId
79
+ * @param {*} pagination
80
+ * @returns {list}
81
+ */
82
+ async function getUserList(orgId, pagination) {
83
+ let headers = {
84
+ "Content-Type": "application/json",
85
+ Accept: "application/json",
86
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
87
+ accessLevel: accessLevel
88
+ })
89
+ };
90
+ if (pagination !== undefined) headers["x-jibb-pagination"] = JSON.stringify(pagination);
91
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users"), headers);
92
+ pagination = response.headers["x-jibb-pagination"];
93
+ pagination = pagination && JSON.parse(pagination);
94
+ return {
95
+ users: response.data.users,
96
+ pagination: pagination
97
+ };
98
+ }
99
+
100
+ /**
101
+ *
102
+ * @async
103
+ * @param {object} param0
104
+ * @param {Number} param0.orgId
105
+ * @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
106
+ * @returns - http result
107
+ */
108
+ async function createUsers(_ref) {
109
+ let {
110
+ orgId,
111
+ users
112
+ } = _ref;
113
+ let headers = {
114
+ "Content-Type": "application/json",
115
+ Accept: "application/json",
116
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
117
+ accessLevel: accessLevel
118
+ })
119
+ };
120
+ let body = {
121
+ users
122
+ };
123
+ return _index.http.post("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users"), body, headers);
124
+ }
125
+
126
+ /**
127
+ *
128
+ * @async
129
+ * @param {object} param0
130
+ * @param {string} param0.orgId
131
+ * @param {string} param0.email
132
+ * @param {number} param0.userType - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
133
+ * @returns - http result
134
+ */
135
+ async function createOrganizationUser(_ref2) {
136
+ let {
137
+ orgId,
138
+ email,
139
+ userType
140
+ } = _ref2;
141
+ let headers = {
142
+ "Content-Type": "application/json",
143
+ Accept: "application/json",
144
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
145
+ accessLevel: accessLevel
146
+ })
147
+ };
148
+ let body = {
149
+ users: [{
150
+ email: email,
151
+ user_type: userType
152
+ }]
153
+ };
154
+ return _index.http.post("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users"), body, headers);
155
+ }
156
+
157
+ /**
158
+ *
159
+ * @async
160
+ * @param {object} param0
161
+ * @param {number} param0.orgId
162
+ * @param {number} param0.userId
163
+ * @returns - http result
164
+ */
165
+ async function SendUserActivationEmail(_ref3) {
166
+ let {
167
+ orgId,
168
+ userIds
169
+ } = _ref3;
170
+ let headers = {
171
+ "Content-Type": "application/json",
172
+ Accept: "application/json",
173
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
174
+ accessLevel: accessLevel
175
+ })
176
+ };
177
+ let body = {
178
+ user_ids: userIds
179
+ };
180
+ return _index.http.post("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/activation/email"), body, headers);
181
+ }
182
+ /**
183
+ *
184
+ * @async
185
+ * @param {object} param0
186
+ * @param {number} param0.orgId
187
+ * @param {number} param0.userId
188
+ * @returns - http result
189
+ */
190
+ async function deleteOrganizationUser(_ref4) {
191
+ let {
192
+ orgId,
193
+ userId
194
+ } = _ref4;
195
+ let headers = {
196
+ "Content-Type": "application/json",
197
+ Accept: "application/json",
198
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
199
+ accessLevel: accessLevel
200
+ })
201
+ };
202
+ return _index.http.delete("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users/").concat(userId), headers);
203
+ }
204
+ /**
205
+ *
206
+ * @async
207
+ * @param {object} param0
208
+ * @param {number} param0.orgId
209
+ * @param {number} param0.userId
210
+ * @param {number} param0.userType - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
211
+ * @returns - http result
212
+ */
213
+ async function updateUserType(_ref5) {
214
+ let {
215
+ orgId,
216
+ userId,
217
+ userType
218
+ } = _ref5;
219
+ let headers = {
220
+ "Content-Type": "application/json",
221
+ Accept: "application/json",
222
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
223
+ accessLevel: accessLevel
224
+ })
225
+ };
226
+ let body = {
227
+ user_type: userType
228
+ };
229
+ return _index.http.patch("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users/").concat(userId), body, headers);
230
+ }
231
+ /**
232
+ *
233
+ * @async
234
+ * @param {object} param0
235
+ * @param {number} param0.orgId
236
+ * @param {number} param0.userId
237
+ * @returns {object}
238
+ */
239
+ async function getOrganizationUserDetails(_ref6) {
240
+ let {
241
+ orgId,
242
+ userId
243
+ } = _ref6;
244
+ let headers = {
245
+ "Content-Type": "application/json",
246
+ Accept: "application/json",
247
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
248
+ accessLevel: accessLevel
249
+ })
250
+ };
251
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/users/").concat(userId), headers);
252
+ return response.data;
253
+ }
254
+
255
+ // error code:401 status:Unauthorized should we / what token to use ? , orgId? not sure of the body
256
+ /**
257
+ *
258
+ * @async
259
+ * @param {object} param0
260
+ * @param {number} param0.orgId
261
+ * @param {string} [param0.metadata=]
262
+ * @param {boolean} [param0.autoAddUsers=false]
263
+ * @param {UserType} [param0.defaultUserType=0] - UNKNOWN = 0; LIMITED = 1; MEMBER = 2; ADMIN = 3; OWNER = 4;
264
+ * @param {boolean} [param0.enabled=fales]
265
+ * @returns - http result
266
+ */
267
+ async function setSAML(_ref7) {
268
+ let {
269
+ orgId,
270
+ metadata,
271
+ autoAddUsers,
272
+ defaultUserType,
273
+ enabled
274
+ } = _ref7;
275
+ if (orgId === "" || orgId === undefined) {
276
+ throw new Error("organization ID can not be empty");
277
+ }
278
+ let headers = {
279
+ "Content-Type": "application/json",
280
+ Accept: "application/json",
281
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
282
+ accessLevel: accessLevel
283
+ })
284
+ };
285
+ let body = {
286
+ organization_id: orgId,
287
+ metadata: metadata || "",
288
+ auto_add_users: autoAddUsers !== undefined ? autoAddUsers : false,
289
+ default_user_type: defaultUserType !== undefined ? defaultUserType : _types.UserType.UNKNOWN,
290
+ enabled: enabled || false
291
+ };
292
+ return _index.http.put("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/saml"), body, headers);
293
+ }
294
+
295
+ // error code:401 status:Unauthorized should we / what token to use ? , orgId? not sure of the body
296
+ /**
297
+ * @async
298
+ * @param {number} orgId
299
+ * @returns - http result
300
+ */
301
+ async function deleteSAML(orgId) {
302
+ let headers = {
303
+ "Content-Type": "application/json",
304
+ Accept: "application/json",
305
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
306
+ accessLevel: accessLevel
307
+ })
308
+ };
309
+ return _index.http.delete("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/saml"), headers);
310
+ }
311
+ /**
312
+ *
313
+ * @async
314
+ * @param {number} orgId
315
+ * @returns {object}
316
+ */
317
+ async function getSAML(orgId) {
318
+ if (orgId === "") {
319
+ throw new Error("organization ID can not be empty");
320
+ }
321
+ let headers = {
322
+ "Content-Type": "application/json",
323
+ Accept: "application/json",
324
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
325
+ accessLevel: accessLevel
326
+ })
327
+ };
328
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/saml"), headers);
329
+ return response.data;
330
+ }
331
+ /**
332
+ *
333
+ * @async
334
+ * @param {number} orgId
335
+ * @returns {object}
336
+ */
337
+ async function getDomainList(orgId) {
338
+ let headers = {
339
+ "Content-Type": "application/json",
340
+ Accept: "application/json",
341
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
342
+ accessLevel: accessLevel
343
+ })
344
+ };
345
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/domains"), headers);
346
+ return response.data;
347
+ }
348
+ /**
349
+ *
350
+ * @async
351
+ * @param {object} param0
352
+ * @param {object} param0.orgId
353
+ * @param {string} param0.domain
354
+ * @returns {object}
355
+ */
356
+ async function createDomain(_ref8) {
357
+ let {
358
+ orgId,
359
+ domain
360
+ } = _ref8;
361
+ let headers = {
362
+ "Content-Type": "application/json",
363
+ Accept: "application/json",
364
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
365
+ accessLevel: accessLevel
366
+ })
367
+ };
368
+ let body = {
369
+ domain_name: domain
370
+ };
371
+ let response = await _index.http.post("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/domains"), body, headers);
372
+ return response.data;
373
+ }
374
+ /**
375
+ *
376
+ * @async
377
+ * @param {object} param0
378
+ * @param {object} param0.orgId
379
+ * @param {string} param0.domain
380
+ * @returns - http result
381
+ */
382
+ async function deleteDomain(_ref9) {
383
+ let {
384
+ orgId,
385
+ domainId
386
+ } = _ref9;
387
+ let headers = {
388
+ "Content-Type": "application/json",
389
+ Accept: "application/json",
390
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
391
+ accessLevel: accessLevel
392
+ })
393
+ };
394
+ return _index.http.delete("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/domains/").concat(domainId), headers);
395
+ }
396
+ /**
397
+ *
398
+ * @async
399
+ * @param {object} param0
400
+ * @param {object} param0.orgId
401
+ * @param {string} param0.domain
402
+ * @returns {object}
403
+ */
404
+ async function verifyDomain(_ref10) {
405
+ let {
406
+ orgId,
407
+ domainId
408
+ } = _ref10;
409
+ let headers = {
410
+ "Content-Type": "application/json",
411
+ Accept: "application/json",
412
+ "x-jibb-user-jwt": await _auth.Auth.getUserToken({
413
+ accessLevel: accessLevel
414
+ })
415
+ };
416
+ let response = await _index.http.get("".concat(_config.Config.apiBaseURL, "/v1/admin/organizations/").concat(orgId, "/domains/").concat(domainId, "/verify"), headers);
417
+ return response.data;
418
+ }
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Auth = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ require("core-js/modules/es.promise.js");
9
+ var _config = require("../config.js");
10
+ var _index = require("../utils/logger/index.js");
11
+ var _types = require("../types/types.js");
12
+ var _index2 = require("../utils/http/index.js");
13
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
14
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
15
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
16
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
17
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
18
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
19
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
20
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
21
+ 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; } }
22
+ var _userClaims = /*#__PURE__*/new WeakMap();
23
+ var _getUserTokenFromApiKey = /*#__PURE__*/new WeakSet();
24
+ var _getUserTokenFromIDToken = /*#__PURE__*/new WeakSet();
25
+ var _refreshUserToken = /*#__PURE__*/new WeakSet();
26
+ /**
27
+ * @module auth
28
+ */
29
+
30
+ /**
31
+ * AuthClass.
32
+ * @class AuthClass
33
+ *
34
+ */
35
+
36
+ class AuthClass {
37
+ constructor() {
38
+ _classPrivateMethodInitSpec(this, _refreshUserToken);
39
+ _classPrivateMethodInitSpec(this, _getUserTokenFromIDToken);
40
+ _classPrivateMethodInitSpec(this, _getUserTokenFromApiKey);
41
+ _classPrivateFieldInitSpec(this, _userClaims, {
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ _index.logger.debug("Creating new Auth instance");
46
+ this.apiKey = undefined;
47
+ _classPrivateFieldSet(this, _userClaims, new Map());
48
+ this.getIdToken = undefined;
49
+ }
50
+
51
+ /**
52
+ * Manually setting userToken
53
+ * @param {string} token
54
+ * @param {AccessLevel} accessLevel
55
+ */
56
+ setUserToken(token) {
57
+ let accessLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types.AccessLevel.USER;
58
+ let claims = new _types.UserClaims(token);
59
+ _classPrivateFieldGet(this, _userClaims).set(accessLevel, claims);
60
+ }
61
+
62
+ /**
63
+ * setting Api key
64
+ * @param {string} apiKey
65
+ */
66
+ setApiKey(apiKey) {
67
+ this.apiKey = apiKey;
68
+ _classPrivateFieldGet(this, _userClaims).clear();
69
+ }
70
+ /**
71
+ *
72
+ * @returns {UserClaims}
73
+ */
74
+ async getUserClaims() {
75
+ await this.getUserToken();
76
+ return _classPrivateFieldGet(this, _userClaims).get(_types.AccessLevel.USER);
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @async
82
+ * @param {object} [param0={}]
83
+ * @param {Number} [param0.expiry=3600] - meeting ID.
84
+ * @param {boolean} [param0.refresh=fales] - 1 Read or 2 Write.
85
+ * @param {AccessLevel} [param0.accessLevel=AccessLevel.USER]
86
+ * @returns {string} - user Token.
87
+ */
88
+
89
+ async getUserToken() {
90
+ let {
91
+ expiry,
92
+ refresh,
93
+ accessLevel
94
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95
+ let claim = undefined;
96
+ refresh = refresh || false;
97
+ accessLevel = accessLevel || _types.AccessLevel.USER;
98
+ expiry = expiry || 3600;
99
+ if (refresh === true) {
100
+ await _classPrivateMethodGet(this, _refreshUserToken, _refreshUserToken2).call(this, {
101
+ expiry,
102
+ accessLevel
103
+ });
104
+ }
105
+ claim = _classPrivateFieldGet(this, _userClaims).get(accessLevel);
106
+ if (claim !== undefined && !claim.isExpired()) return claim.token;
107
+ await _classPrivateMethodGet(this, _refreshUserToken, _refreshUserToken2).call(this, {
108
+ expiry,
109
+ accessLevel
110
+ });
111
+ claim = _classPrivateFieldGet(this, _userClaims).get(accessLevel);
112
+ if (claim !== undefined && !claim.isExpired()) return claim.token;
113
+ throw new Error("could not create user token");
114
+ }
115
+ /**
116
+ * clear user.
117
+ */
118
+
119
+ logout() {
120
+ _classPrivateFieldGet(this, _userClaims).clear();
121
+ }
122
+
123
+ /**
124
+ *
125
+ * Generate a new API Key, old API KEY will be discareded
126
+ * It require a userToken to be set.
127
+ * @returns {string} api key
128
+ */
129
+ async generateAPIKey() {
130
+ let headers = {
131
+ "Content-Type": "application/json",
132
+ Accept: "application/json",
133
+ "x-jibb-user-jwt": await this.getUserToken()
134
+ };
135
+ let response = await _index2.http.get("".concat(_config.Config.apiBaseURL, "/v1/auth/apikey"), headers);
136
+ return response.data.apiKey;
137
+ }
138
+
139
+ /**
140
+ *
141
+ * Generating a one time password.
142
+ * It require a IdToken to be set.
143
+ * @async
144
+ * @returns {string} - Custom Password.
145
+ */
146
+ async generateCustomAuthPassword() {
147
+ let headers = {
148
+ "Content-Type": "application/json",
149
+ Accept: "application/json",
150
+ "x-jibb-id-jwt": await this.getIdToken()
151
+ };
152
+ let response = await _index2.http.get("".concat(_config.Config.apiBaseURL, "/v1/auth/custom"), headers);
153
+ return response.data.password;
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Expotred instance of AuthClass.
159
+ * @type {AuthClass}
160
+ */
161
+ async function _getUserTokenFromApiKey2(_ref) {
162
+ let {
163
+ expiry,
164
+ accessLevel
165
+ } = _ref;
166
+ let headers = {
167
+ "Content-Type": "application/json",
168
+ Accept: "application/json"
169
+ };
170
+ let body = {
171
+ api_key: this.apiKey,
172
+ expiry: {
173
+ seconds: expiry
174
+ }
175
+ };
176
+ let url;
177
+ switch (accessLevel) {
178
+ case _types.AccessLevel.ADMIN:
179
+ url = "".concat(_config.Config.apiBaseURL, "/v1/admin/auth/token");
180
+ break;
181
+ case _types.AccessLevel.SUPERADMIN:
182
+ url = "".concat(_config.Config.apiBaseURL, "/v1/superadmin/auth/token");
183
+ break;
184
+ default:
185
+ url = "".concat(_config.Config.apiBaseURL, "/v1/auth/token");
186
+ break;
187
+ }
188
+ let response = await _index2.http.post(url, body, headers);
189
+ return response.data.token;
190
+ }
191
+ async function _getUserTokenFromIDToken2(_ref2) {
192
+ let {
193
+ expiry,
194
+ accessLevel
195
+ } = _ref2;
196
+ let headers = {
197
+ "Content-Type": "application/json",
198
+ Accept: "application/json",
199
+ "x-jibb-id-jwt": await this.getIdToken()
200
+ };
201
+ let body = {
202
+ expiry: {
203
+ seconds: expiry
204
+ }
205
+ };
206
+ let url;
207
+ switch (accessLevel) {
208
+ case _types.AccessLevel.ADMIN:
209
+ url = "".concat(_config.Config.apiBaseURL, "/v1/admin/auth/token");
210
+ break;
211
+ case _types.AccessLevel.SUPERADMIN:
212
+ url = "".concat(_config.Config.apiBaseURL, "/v1/superadmin/auth/token");
213
+ break;
214
+ default:
215
+ url = "".concat(_config.Config.apiBaseURL, "/v1/auth/token");
216
+ break;
217
+ }
218
+ let response = await _index2.http.post(url, body, headers);
219
+ return response.data.token;
220
+ }
221
+ async function _refreshUserToken2(_ref3) {
222
+ let {
223
+ expiry,
224
+ accessLevel
225
+ } = _ref3;
226
+ if (this.apiKey) {
227
+ let token = await _classPrivateMethodGet(this, _getUserTokenFromApiKey, _getUserTokenFromApiKey2).call(this, {
228
+ expiry,
229
+ accessLevel
230
+ });
231
+ this.setUserToken(token, accessLevel);
232
+ return token;
233
+ }
234
+ try {
235
+ let token = await _classPrivateMethodGet(this, _getUserTokenFromIDToken, _getUserTokenFromIDToken2).call(this, {
236
+ expiry,
237
+ accessLevel
238
+ });
239
+ this.setUserToken(token, accessLevel);
240
+ return token;
241
+ } catch (error) {
242
+ _index.logger.error(error);
243
+ }
244
+ }
245
+ let Auth = new AuthClass();
246
+ exports.Auth = Auth;