@dereekb/zoom 13.2.1 → 13.3.0
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/index.cjs.js +1586 -368
- package/index.esm.js +1589 -371
- package/nestjs/index.cjs.js +1527 -397
- package/nestjs/index.esm.js +1528 -398
- package/nestjs/package.json +4 -4
- package/package.json +3 -3
package/index.cjs.js
CHANGED
|
@@ -4,6 +4,53 @@ var fetch = require('@dereekb/util/fetch');
|
|
|
4
4
|
var util = require('@dereekb/util');
|
|
5
5
|
var makeError = require('make-error');
|
|
6
6
|
|
|
7
|
+
function _define_property$2(obj, key, value) {
|
|
8
|
+
if (key in obj) {
|
|
9
|
+
Object.defineProperty(obj, key, {
|
|
10
|
+
value: value,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
obj[key] = value;
|
|
17
|
+
}
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
function _object_spread(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
23
|
+
var ownKeys = Object.keys(source);
|
|
24
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
25
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
26
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
ownKeys.forEach(function(key) {
|
|
30
|
+
_define_property$2(target, key, source[key]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function ownKeys(object, enumerableOnly) {
|
|
36
|
+
var keys = Object.keys(object);
|
|
37
|
+
if (Object.getOwnPropertySymbols) {
|
|
38
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
39
|
+
keys.push.apply(keys, symbols);
|
|
40
|
+
}
|
|
41
|
+
return keys;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread_props(target, source) {
|
|
44
|
+
source = source != null ? source : {};
|
|
45
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
46
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
47
|
+
} else {
|
|
48
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
49
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
7
54
|
/**
|
|
8
55
|
* The Zoom API returns the data for a page for a specific key.
|
|
9
56
|
*
|
|
@@ -11,17 +58,16 @@ var makeError = require('make-error');
|
|
|
11
58
|
|
|
12
59
|
* @param dataTypeKey
|
|
13
60
|
* @returns
|
|
14
|
-
*/
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
const { next_page_token, page_count, page_number, page_size, total_records } = data;
|
|
61
|
+
*/ function mapToZoomPageResult(dataTypeKey) {
|
|
62
|
+
return function(data) {
|
|
63
|
+
var next_page_token = data.next_page_token, page_count = data.page_count, page_number = data.page_number, page_size = data.page_size, total_records = data.total_records;
|
|
18
64
|
return {
|
|
19
65
|
data: data[dataTypeKey],
|
|
20
|
-
next_page_token,
|
|
21
|
-
page_count,
|
|
22
|
-
page_number,
|
|
23
|
-
page_size,
|
|
24
|
-
total_records
|
|
66
|
+
next_page_token: next_page_token,
|
|
67
|
+
page_count: page_count,
|
|
68
|
+
page_number: page_number,
|
|
69
|
+
page_size: page_size,
|
|
70
|
+
total_records: total_records
|
|
25
71
|
};
|
|
26
72
|
};
|
|
27
73
|
}
|
|
@@ -31,68 +77,307 @@ function mapToZoomPageResult(dataTypeKey) {
|
|
|
31
77
|
* @param fetch
|
|
32
78
|
* @param defaults
|
|
33
79
|
* @returns
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
return fetch.fetchPageFactory({
|
|
37
|
-
...defaults,
|
|
80
|
+
*/ function zoomFetchPageFactory(fetch$1, defaults) {
|
|
81
|
+
return fetch.fetchPageFactory(_object_spread_props(_object_spread({}, defaults), {
|
|
38
82
|
fetch: fetch$1,
|
|
39
|
-
readFetchPageResultInfo: function (result) {
|
|
83
|
+
readFetchPageResultInfo: function readFetchPageResultInfo(result) {
|
|
40
84
|
return {
|
|
41
85
|
nextPageCursor: result.next_page_token,
|
|
42
86
|
hasNext: Boolean(result.next_page_token) // has more when a non-empty next_page_token is returned
|
|
43
87
|
};
|
|
44
88
|
},
|
|
45
|
-
buildInputForNextPage: function (pageResult, input, options) {
|
|
46
|
-
|
|
89
|
+
buildInputForNextPage: function buildInputForNextPage(pageResult, input, options) {
|
|
90
|
+
var _options_maxItemsPerPage;
|
|
91
|
+
return _object_spread_props(_object_spread({}, input), {
|
|
92
|
+
next_page_token: pageResult.nextPageCursor,
|
|
93
|
+
page_size: (_options_maxItemsPerPage = options.maxItemsPerPage) !== null && _options_maxItemsPerPage !== void 0 ? _options_maxItemsPerPage : input.page_size
|
|
94
|
+
});
|
|
47
95
|
}
|
|
48
|
-
});
|
|
96
|
+
}));
|
|
49
97
|
}
|
|
50
98
|
|
|
99
|
+
function _assert_this_initialized$1(self) {
|
|
100
|
+
if (self === void 0) {
|
|
101
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
102
|
+
}
|
|
103
|
+
return self;
|
|
104
|
+
}
|
|
105
|
+
function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
|
|
106
|
+
try {
|
|
107
|
+
var info = gen[key](arg);
|
|
108
|
+
var value = info.value;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
reject(error);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (info.done) {
|
|
114
|
+
resolve(value);
|
|
115
|
+
} else {
|
|
116
|
+
Promise.resolve(value).then(_next, _throw);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function _async_to_generator$5(fn) {
|
|
120
|
+
return function() {
|
|
121
|
+
var self = this, args = arguments;
|
|
122
|
+
return new Promise(function(resolve, reject) {
|
|
123
|
+
var gen = fn.apply(self, args);
|
|
124
|
+
function _next(value) {
|
|
125
|
+
asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
|
|
126
|
+
}
|
|
127
|
+
function _throw(err) {
|
|
128
|
+
asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
|
|
129
|
+
}
|
|
130
|
+
_next(undefined);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function _call_super$1(_this, derived, args) {
|
|
135
|
+
derived = _get_prototype_of$1(derived);
|
|
136
|
+
return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
|
|
137
|
+
}
|
|
138
|
+
function _class_call_check$1(instance, Constructor) {
|
|
139
|
+
if (!(instance instanceof Constructor)) {
|
|
140
|
+
throw new TypeError("Cannot call a class as a function");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function _defineProperties(target, props) {
|
|
144
|
+
for(var i = 0; i < props.length; i++){
|
|
145
|
+
var descriptor = props[i];
|
|
146
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
147
|
+
descriptor.configurable = true;
|
|
148
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
149
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
153
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
154
|
+
return Constructor;
|
|
155
|
+
}
|
|
156
|
+
function _define_property$1(obj, key, value) {
|
|
157
|
+
if (key in obj) {
|
|
158
|
+
Object.defineProperty(obj, key, {
|
|
159
|
+
value: value,
|
|
160
|
+
enumerable: true,
|
|
161
|
+
configurable: true,
|
|
162
|
+
writable: true
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
obj[key] = value;
|
|
166
|
+
}
|
|
167
|
+
return obj;
|
|
168
|
+
}
|
|
169
|
+
function _get_prototype_of$1(o) {
|
|
170
|
+
_get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
171
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
172
|
+
};
|
|
173
|
+
return _get_prototype_of$1(o);
|
|
174
|
+
}
|
|
175
|
+
function _inherits$1(subClass, superClass) {
|
|
176
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
177
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
178
|
+
}
|
|
179
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
180
|
+
constructor: {
|
|
181
|
+
value: subClass,
|
|
182
|
+
writable: true,
|
|
183
|
+
configurable: true
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
if (superClass) _set_prototype_of$1(subClass, superClass);
|
|
187
|
+
}
|
|
188
|
+
function _instanceof(left, right) {
|
|
189
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
190
|
+
return !!right[Symbol.hasInstance](left);
|
|
191
|
+
} else {
|
|
192
|
+
return left instanceof right;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function _possible_constructor_return$1(self, call) {
|
|
196
|
+
if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
|
|
197
|
+
return call;
|
|
198
|
+
}
|
|
199
|
+
return _assert_this_initialized$1(self);
|
|
200
|
+
}
|
|
201
|
+
function _set_prototype_of$1(o, p) {
|
|
202
|
+
_set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
203
|
+
o.__proto__ = p;
|
|
204
|
+
return o;
|
|
205
|
+
};
|
|
206
|
+
return _set_prototype_of$1(o, p);
|
|
207
|
+
}
|
|
208
|
+
function _type_of$1(obj) {
|
|
209
|
+
"@swc/helpers - typeof";
|
|
210
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
211
|
+
}
|
|
212
|
+
function _is_native_reflect_construct$1() {
|
|
213
|
+
try {
|
|
214
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
215
|
+
} catch (_) {}
|
|
216
|
+
return (_is_native_reflect_construct$1 = function() {
|
|
217
|
+
return !!result;
|
|
218
|
+
})();
|
|
219
|
+
}
|
|
220
|
+
function _ts_generator$5(thisArg, body) {
|
|
221
|
+
var f, y, t, _ = {
|
|
222
|
+
label: 0,
|
|
223
|
+
sent: function() {
|
|
224
|
+
if (t[0] & 1) throw t[1];
|
|
225
|
+
return t[1];
|
|
226
|
+
},
|
|
227
|
+
trys: [],
|
|
228
|
+
ops: []
|
|
229
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
230
|
+
return d(g, "next", {
|
|
231
|
+
value: verb(0)
|
|
232
|
+
}), d(g, "throw", {
|
|
233
|
+
value: verb(1)
|
|
234
|
+
}), d(g, "return", {
|
|
235
|
+
value: verb(2)
|
|
236
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
237
|
+
value: function() {
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
}), g;
|
|
241
|
+
function verb(n) {
|
|
242
|
+
return function(v) {
|
|
243
|
+
return step([
|
|
244
|
+
n,
|
|
245
|
+
v
|
|
246
|
+
]);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function step(op) {
|
|
250
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
251
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
252
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
253
|
+
if (y = 0, t) op = [
|
|
254
|
+
op[0] & 2,
|
|
255
|
+
t.value
|
|
256
|
+
];
|
|
257
|
+
switch(op[0]){
|
|
258
|
+
case 0:
|
|
259
|
+
case 1:
|
|
260
|
+
t = op;
|
|
261
|
+
break;
|
|
262
|
+
case 4:
|
|
263
|
+
_.label++;
|
|
264
|
+
return {
|
|
265
|
+
value: op[1],
|
|
266
|
+
done: false
|
|
267
|
+
};
|
|
268
|
+
case 5:
|
|
269
|
+
_.label++;
|
|
270
|
+
y = op[1];
|
|
271
|
+
op = [
|
|
272
|
+
0
|
|
273
|
+
];
|
|
274
|
+
continue;
|
|
275
|
+
case 7:
|
|
276
|
+
op = _.ops.pop();
|
|
277
|
+
_.trys.pop();
|
|
278
|
+
continue;
|
|
279
|
+
default:
|
|
280
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
281
|
+
_ = 0;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
285
|
+
_.label = op[1];
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
289
|
+
_.label = t[1];
|
|
290
|
+
t = op;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
if (t && _.label < t[2]) {
|
|
294
|
+
_.label = t[2];
|
|
295
|
+
_.ops.push(op);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
if (t[2]) _.ops.pop();
|
|
299
|
+
_.trys.pop();
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
op = body.call(thisArg, _);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
op = [
|
|
305
|
+
6,
|
|
306
|
+
e
|
|
307
|
+
];
|
|
308
|
+
y = 0;
|
|
309
|
+
} finally{
|
|
310
|
+
f = t = 0;
|
|
311
|
+
}
|
|
312
|
+
if (op[0] & 5) throw op[1];
|
|
313
|
+
return {
|
|
314
|
+
value: op[0] ? op[1] : void 0,
|
|
315
|
+
done: true
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
51
319
|
/**
|
|
52
320
|
* A code used in some cases to denote success.
|
|
53
|
-
*/
|
|
54
|
-
const ZOOM_SUCCESS_CODE = 'SUCCESS';
|
|
321
|
+
*/ var ZOOM_SUCCESS_CODE = 'SUCCESS';
|
|
55
322
|
/**
|
|
56
323
|
* Zoom Server Error
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
error
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
324
|
+
*/ var ZoomServerError = /*#__PURE__*/ function(BaseError) {
|
|
325
|
+
_inherits$1(ZoomServerError, BaseError);
|
|
326
|
+
function ZoomServerError(error) {
|
|
327
|
+
_class_call_check$1(this, ZoomServerError);
|
|
328
|
+
var _this;
|
|
329
|
+
_this = _call_super$1(this, ZoomServerError, [
|
|
330
|
+
error.message
|
|
331
|
+
]), _define_property$1(_this, "error", void 0);
|
|
332
|
+
_this.error = error;
|
|
333
|
+
return _this;
|
|
66
334
|
}
|
|
67
|
-
|
|
335
|
+
_create_class(ZoomServerError, [
|
|
336
|
+
{
|
|
337
|
+
key: "code",
|
|
338
|
+
get: function get() {
|
|
339
|
+
return this.error.code;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
]);
|
|
343
|
+
return ZoomServerError;
|
|
344
|
+
}(makeError.BaseError);
|
|
68
345
|
/**
|
|
69
346
|
* Zoom Server Error that includes the FetchResponseError
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
data
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
347
|
+
*/ var ZoomServerFetchResponseError = /*#__PURE__*/ function(ZoomServerError) {
|
|
348
|
+
_inherits$1(ZoomServerFetchResponseError, ZoomServerError);
|
|
349
|
+
function ZoomServerFetchResponseError(data, responseError) {
|
|
350
|
+
_class_call_check$1(this, ZoomServerFetchResponseError);
|
|
351
|
+
var _this;
|
|
352
|
+
_this = _call_super$1(this, ZoomServerFetchResponseError, [
|
|
353
|
+
data
|
|
354
|
+
]), _define_property$1(_this, "data", void 0), _define_property$1(_this, "responseError", void 0);
|
|
355
|
+
_this.data = data;
|
|
356
|
+
_this.responseError = responseError;
|
|
357
|
+
return _this;
|
|
78
358
|
}
|
|
79
|
-
|
|
359
|
+
return ZoomServerFetchResponseError;
|
|
360
|
+
}(ZoomServerError);
|
|
80
361
|
/**
|
|
81
362
|
* Creates a logZoomServerErrorFunction that logs the error to console.
|
|
82
363
|
*
|
|
83
364
|
* @param zoomApiNamePrefix Prefix to use when logging. I.E. ZoomError, etc.
|
|
84
365
|
* @returns
|
|
85
|
-
*/
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
366
|
+
*/ function logZoomServerErrorFunction(zoomApiNamePrefix) {
|
|
367
|
+
return function(error) {
|
|
368
|
+
if (_instanceof(error, ZoomServerFetchResponseError)) {
|
|
369
|
+
console.log("".concat(zoomApiNamePrefix, "Error(").concat(error.responseError.response.status, "): "), {
|
|
370
|
+
error: error,
|
|
371
|
+
errorData: error.data
|
|
372
|
+
});
|
|
373
|
+
} else if (_instanceof(error, ZoomServerError)) {
|
|
374
|
+
console.log("".concat(zoomApiNamePrefix, "Error(code:").concat(error.code, "): "), {
|
|
375
|
+
error: error
|
|
376
|
+
});
|
|
377
|
+
} else {
|
|
378
|
+
console.log("".concat(zoomApiNamePrefix, "Error(name:").concat(error.name, "): "), {
|
|
379
|
+
error: error
|
|
380
|
+
});
|
|
96
381
|
}
|
|
97
382
|
};
|
|
98
383
|
}
|
|
@@ -101,84 +386,131 @@ function logZoomServerErrorFunction(zoomApiNamePrefix) {
|
|
|
101
386
|
*
|
|
102
387
|
* @param fetch
|
|
103
388
|
* @returns
|
|
104
|
-
*/
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
389
|
+
*/ function handleZoomErrorFetchFactory(parseZoomError, defaultLogError) {
|
|
390
|
+
return function(fetch$1) {
|
|
391
|
+
var logError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogError;
|
|
392
|
+
return function(x, y) {
|
|
393
|
+
return _async_to_generator$5(function() {
|
|
394
|
+
var e, error;
|
|
395
|
+
return _ts_generator$5(this, function(_state) {
|
|
396
|
+
switch(_state.label){
|
|
397
|
+
case 0:
|
|
398
|
+
_state.trys.push([
|
|
399
|
+
0,
|
|
400
|
+
2,
|
|
401
|
+
,
|
|
402
|
+
5
|
|
403
|
+
]);
|
|
404
|
+
return [
|
|
405
|
+
4,
|
|
406
|
+
fetch$1(x, y)
|
|
407
|
+
];
|
|
408
|
+
case 1:
|
|
409
|
+
return [
|
|
410
|
+
2,
|
|
411
|
+
_state.sent()
|
|
412
|
+
]; // await to catch thrown errors
|
|
413
|
+
case 2:
|
|
414
|
+
e = _state.sent();
|
|
415
|
+
if (!_instanceof(e, fetch.FetchResponseError)) return [
|
|
416
|
+
3,
|
|
417
|
+
4
|
|
418
|
+
];
|
|
419
|
+
return [
|
|
420
|
+
4,
|
|
421
|
+
parseZoomError(e)
|
|
422
|
+
];
|
|
423
|
+
case 3:
|
|
424
|
+
error = _state.sent();
|
|
425
|
+
if (error) {
|
|
426
|
+
logError(error); // log before throwing.
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
_state.label = 4;
|
|
430
|
+
case 4:
|
|
431
|
+
throw e;
|
|
432
|
+
case 5:
|
|
433
|
+
return [
|
|
434
|
+
2
|
|
435
|
+
];
|
|
117
436
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
437
|
+
});
|
|
438
|
+
})();
|
|
121
439
|
};
|
|
122
440
|
};
|
|
123
441
|
}
|
|
124
442
|
// MARK: Parsed Errors
|
|
125
443
|
/**
|
|
126
444
|
* The status code that Zoom uses to indicates that too many requests have been made in a short period of time.
|
|
127
|
-
*/
|
|
128
|
-
const ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE = 429;
|
|
445
|
+
*/ var ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE = 429;
|
|
129
446
|
/**
|
|
130
447
|
* Also shares the same 429 code as ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE.
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const DEFAULT_ZOOM_API_RATE_LIMIT_RESET_PERIOD = util.MS_IN_SECOND;
|
|
448
|
+
*/ var ZOOM_TOO_MANY_REQUESTS_ERROR_CODE = 429;
|
|
449
|
+
var ZOOM_RATE_LIMIT_CATEGORY_HEADER = 'X-RateLimit-Category';
|
|
450
|
+
var ZOOM_RATE_LIMIT_TYPE_HEADER = 'X-RateLimit-Type';
|
|
451
|
+
var ZOOM_RATE_LIMIT_LIMIT_HEADER = 'X-RateLimit-Limit';
|
|
452
|
+
var ZOOM_RATE_LIMIT_REMAINING_HEADER = 'X-RateLimit-Remaining';
|
|
453
|
+
var ZOOM_RATE_LIMIT_RETRY_AFTER_HEADER = 'Retry-After';
|
|
454
|
+
var DEFAULT_ZOOM_API_RATE_LIMIT = 2;
|
|
455
|
+
var DEFAULT_ZOOM_API_RATE_LIMIT_RESET_PERIOD = util.MS_IN_SECOND;
|
|
140
456
|
function zoomRateLimitHeaderDetails(headers) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
457
|
+
var limitHeader = headers.get(ZOOM_RATE_LIMIT_LIMIT_HEADER);
|
|
458
|
+
var remainingHeader = headers.get(ZOOM_RATE_LIMIT_REMAINING_HEADER);
|
|
459
|
+
var retryAfterHeader = headers.get(ZOOM_RATE_LIMIT_RETRY_AFTER_HEADER);
|
|
460
|
+
var categoryHeader = headers.get(ZOOM_RATE_LIMIT_CATEGORY_HEADER);
|
|
461
|
+
var typeHeader = headers.get(ZOOM_RATE_LIMIT_TYPE_HEADER);
|
|
462
|
+
var result = null;
|
|
147
463
|
if (categoryHeader != null && typeHeader != null) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
result = {
|
|
464
|
+
var category = categoryHeader;
|
|
465
|
+
var type = typeHeader;
|
|
466
|
+
var limit = limitHeader ? Number(limitHeader) : undefined;
|
|
467
|
+
var remaining = remainingHeader ? Number(remainingHeader) : undefined;
|
|
468
|
+
var retryAfter = retryAfterHeader ? Number(retryAfterHeader) : undefined;
|
|
469
|
+
var retryAfterAt = retryAfterHeader ? new Date(retryAfterHeader) : undefined;
|
|
470
|
+
result = {
|
|
471
|
+
limit: limit,
|
|
472
|
+
remaining: remaining,
|
|
473
|
+
retryAfter: retryAfter,
|
|
474
|
+
retryAfterAt: retryAfterAt,
|
|
475
|
+
category: category,
|
|
476
|
+
type: type
|
|
477
|
+
};
|
|
155
478
|
}
|
|
156
479
|
return result;
|
|
157
480
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
481
|
+
var ZoomTooManyRequestsError = /*#__PURE__*/ function(ZoomServerFetchResponseError) {
|
|
482
|
+
_inherits$1(ZoomTooManyRequestsError, ZoomServerFetchResponseError);
|
|
483
|
+
function ZoomTooManyRequestsError() {
|
|
484
|
+
_class_call_check$1(this, ZoomTooManyRequestsError);
|
|
485
|
+
return _call_super$1(this, ZoomTooManyRequestsError, arguments);
|
|
161
486
|
}
|
|
162
|
-
|
|
487
|
+
_create_class(ZoomTooManyRequestsError, [
|
|
488
|
+
{
|
|
489
|
+
key: "headerDetails",
|
|
490
|
+
get: function get() {
|
|
491
|
+
return zoomRateLimitHeaderDetails(this.responseError.response.headers);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
]);
|
|
495
|
+
return ZoomTooManyRequestsError;
|
|
496
|
+
}(ZoomServerFetchResponseError);
|
|
163
497
|
/**
|
|
164
498
|
* Function that parses/transforms a ZoomServerErrorData into a general ZoomServerError or other known error type.
|
|
165
499
|
*
|
|
166
500
|
* @param errorResponseData
|
|
167
501
|
* @param responseError
|
|
168
502
|
* @returns
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
let result;
|
|
503
|
+
*/ function parseZoomServerErrorData(zoomServerError, responseError) {
|
|
504
|
+
var result;
|
|
172
505
|
if (responseError.response.status === ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE) {
|
|
173
506
|
result = new ZoomTooManyRequestsError(zoomServerError, responseError);
|
|
174
507
|
console.warn('ZoomTooManyRequestsError', {
|
|
175
|
-
result,
|
|
176
|
-
responseError,
|
|
508
|
+
result: result,
|
|
509
|
+
responseError: responseError,
|
|
177
510
|
headerDetails: result.headerDetails
|
|
178
511
|
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
switch (zoomServerError.code) {
|
|
512
|
+
} else if (zoomServerError) {
|
|
513
|
+
switch(zoomServerError.code){
|
|
182
514
|
default:
|
|
183
515
|
result = new ZoomServerFetchResponseError(zoomServerError, responseError);
|
|
184
516
|
break;
|
|
@@ -190,18 +522,24 @@ function parseZoomServerErrorData(zoomServerError, responseError) {
|
|
|
190
522
|
* Returns a pre-configured MakeUrlSearchParamsOptions that omits the silenceError key.
|
|
191
523
|
*
|
|
192
524
|
* If other options are input, it merges those two options together and adds silenceError to the omitted keys.
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
525
|
+
*/ function omitSilenceZoomErrorKeys(options) {
|
|
526
|
+
var omitKeys = [
|
|
527
|
+
'silenceError'
|
|
528
|
+
];
|
|
529
|
+
return fetch.mergeMakeUrlSearchParamsOptions([
|
|
530
|
+
options,
|
|
531
|
+
{
|
|
532
|
+
omitKeys: omitKeys
|
|
533
|
+
}
|
|
534
|
+
]);
|
|
197
535
|
}
|
|
198
536
|
function silenceZoomErrorWithCodesFunction(codes, returnFn) {
|
|
199
|
-
|
|
200
|
-
return (silence)
|
|
201
|
-
return (reason)
|
|
202
|
-
if (silence !== false && reason
|
|
537
|
+
var codesSet = new Set(util.asArray(codes));
|
|
538
|
+
return function(silence) {
|
|
539
|
+
return function(reason) {
|
|
540
|
+
if (silence !== false && _instanceof(reason, ZoomServerFetchResponseError)) {
|
|
203
541
|
if (codesSet.has(reason.code)) {
|
|
204
|
-
return returnFn
|
|
542
|
+
return returnFn === null || returnFn === void 0 ? void 0 : returnFn(reason);
|
|
205
543
|
}
|
|
206
544
|
}
|
|
207
545
|
throw reason;
|
|
@@ -211,25 +549,26 @@ function silenceZoomErrorWithCodesFunction(codes, returnFn) {
|
|
|
211
549
|
|
|
212
550
|
/**
|
|
213
551
|
* https://developers.zoom.us/docs/api/rest/reference/zoom-api/methods/#operation/meeting
|
|
214
|
-
*/
|
|
215
|
-
function
|
|
216
|
-
|
|
552
|
+
*/ function getMeeting(context) {
|
|
553
|
+
return function(input) {
|
|
554
|
+
return context.fetchJson("/meetings/".concat(input.meetingId), 'GET');
|
|
555
|
+
};
|
|
217
556
|
}
|
|
218
557
|
/**
|
|
219
558
|
* https://developers.zoom.us/docs/api/rest/reference/zoom-api/methods/#operation/meetings
|
|
220
|
-
*/
|
|
221
|
-
function
|
|
222
|
-
|
|
559
|
+
*/ function listMeetingsForUser(context) {
|
|
560
|
+
return function(input) {
|
|
561
|
+
return context.fetchJson("/users/".concat(input.user, "/meetings"), 'GET').then(mapToZoomPageResult('meetings'));
|
|
562
|
+
};
|
|
223
563
|
}
|
|
224
564
|
function listMeetingsForUserPageFactory(context) {
|
|
225
565
|
return zoomFetchPageFactory(listMeetingsForUser(context));
|
|
226
566
|
}
|
|
227
567
|
/**
|
|
228
568
|
* https://developers.zoom.us/docs/api/meetings/#tag/meetings/POST/users/{userId}/meetings
|
|
229
|
-
*/
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
return context.fetchJson(`/users/${input.user}/meetings`, {
|
|
569
|
+
*/ function createMeetingForUser(context) {
|
|
570
|
+
return function(input) {
|
|
571
|
+
return context.fetchJson("/users/".concat(input.user, "/meetings"), {
|
|
233
572
|
method: 'POST',
|
|
234
573
|
body: JSON.stringify(input.template)
|
|
235
574
|
});
|
|
@@ -237,32 +576,38 @@ function createMeetingForUser(context) {
|
|
|
237
576
|
}
|
|
238
577
|
/**
|
|
239
578
|
* https://developers.zoom.us/docs/api/meetings/#tag/meetings/PUT/meetings/{meetingId}
|
|
240
|
-
*/
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
579
|
+
*/ function updateMeeting(context) {
|
|
580
|
+
return function(input) {
|
|
581
|
+
return context.fetchJson("/meetings/".concat(input.meetingId, "?").concat(fetch.makeUrlSearchParams({
|
|
582
|
+
occurrence_id: input.occurrence_id
|
|
583
|
+
})), {
|
|
584
|
+
method: 'PATCH',
|
|
585
|
+
body: JSON.stringify(input.template)
|
|
586
|
+
});
|
|
587
|
+
};
|
|
246
588
|
}
|
|
247
|
-
|
|
589
|
+
var DELETE_MEETING_DOES_NOT_EXIST_ERROR_CODE = 3001;
|
|
248
590
|
/**
|
|
249
591
|
* https://developers.zoom.us/docs/api/meetings/#tag/meetings/DELETE/meetings/{meetingId}
|
|
250
|
-
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
592
|
+
*/ function deleteMeeting(context) {
|
|
593
|
+
var silenceDoesNotExistError = silenceZoomErrorWithCodesFunction(DELETE_MEETING_DOES_NOT_EXIST_ERROR_CODE);
|
|
594
|
+
return function(input) {
|
|
595
|
+
return context.fetchJson("/meetings/".concat(input.meetingId, "?").concat(fetch.makeUrlSearchParams(input, omitSilenceZoomErrorKeys())), 'DELETE').catch(silenceDoesNotExistError(input.silenceError));
|
|
596
|
+
};
|
|
254
597
|
}
|
|
255
598
|
/**
|
|
256
599
|
* https://developers.zoom.us/docs/api/meetings/#tag/meetings/GET/past_meetings/{meetingId}
|
|
257
|
-
*/
|
|
258
|
-
function
|
|
259
|
-
|
|
600
|
+
*/ function getPastMeeting(context) {
|
|
601
|
+
return function(input) {
|
|
602
|
+
return context.fetchJson("/past_meetings/".concat(input.meetingId), 'GET');
|
|
603
|
+
};
|
|
260
604
|
}
|
|
261
605
|
/**
|
|
262
606
|
* https://developers.zoom.us/docs/api/meetings/#tag/meetings/GET/past_meetings/{meetingId}/participants
|
|
263
|
-
*/
|
|
264
|
-
function
|
|
265
|
-
|
|
607
|
+
*/ function getPastMeetingParticipants(context) {
|
|
608
|
+
return function(input) {
|
|
609
|
+
return context.fetchJson("/past_meetings/".concat(input.meetingId, "/participants"), 'GET').then(mapToZoomPageResult('participants'));
|
|
610
|
+
};
|
|
266
611
|
}
|
|
267
612
|
function getPastMeetingParticipantsPageFactory(context) {
|
|
268
613
|
return zoomFetchPageFactory(getPastMeetingParticipants(context));
|
|
@@ -276,9 +621,8 @@ function getPastMeetingParticipantsPageFactory(context) {
|
|
|
276
621
|
* - `4` - A PMI Meeting.
|
|
277
622
|
* - `8` - A recurring meeting with fixed time.
|
|
278
623
|
* - `10` - A screen share only meeting.
|
|
279
|
-
*/
|
|
280
|
-
|
|
281
|
-
(function (ZoomMeetingType) {
|
|
624
|
+
*/ exports.ZoomMeetingType = void 0;
|
|
625
|
+
(function(ZoomMeetingType) {
|
|
282
626
|
ZoomMeetingType[ZoomMeetingType["INSTANT"] = 1] = "INSTANT";
|
|
283
627
|
ZoomMeetingType[ZoomMeetingType["SCHEDULED"] = 2] = "SCHEDULED";
|
|
284
628
|
ZoomMeetingType[ZoomMeetingType["RECURRING_NO_FIXED_TIME"] = 3] = "RECURRING_NO_FIXED_TIME";
|
|
@@ -287,13 +631,13 @@ exports.ZoomMeetingType = void 0;
|
|
|
287
631
|
ZoomMeetingType[ZoomMeetingType["SCREEN_SHARE_ONLY"] = 10] = "SCREEN_SHARE_ONLY";
|
|
288
632
|
})(exports.ZoomMeetingType || (exports.ZoomMeetingType = {}));
|
|
289
633
|
exports.ZoomRecurrenceType = void 0;
|
|
290
|
-
(function
|
|
634
|
+
(function(ZoomRecurrenceType) {
|
|
291
635
|
ZoomRecurrenceType[ZoomRecurrenceType["DAILY"] = 1] = "DAILY";
|
|
292
636
|
ZoomRecurrenceType[ZoomRecurrenceType["WEEKLY"] = 2] = "WEEKLY";
|
|
293
637
|
ZoomRecurrenceType[ZoomRecurrenceType["MONTHLY"] = 3] = "MONTHLY";
|
|
294
638
|
})(exports.ZoomRecurrenceType || (exports.ZoomRecurrenceType = {}));
|
|
295
639
|
exports.ZoomMonthlyWeek = void 0;
|
|
296
|
-
(function
|
|
640
|
+
(function(ZoomMonthlyWeek) {
|
|
297
641
|
ZoomMonthlyWeek[ZoomMonthlyWeek["LAST_WEEK"] = -1] = "LAST_WEEK";
|
|
298
642
|
ZoomMonthlyWeek[ZoomMonthlyWeek["FIRST_WEEK"] = 1] = "FIRST_WEEK";
|
|
299
643
|
ZoomMonthlyWeek[ZoomMonthlyWeek["SECOND_WEEK"] = 2] = "SECOND_WEEK";
|
|
@@ -301,7 +645,7 @@ exports.ZoomMonthlyWeek = void 0;
|
|
|
301
645
|
ZoomMonthlyWeek[ZoomMonthlyWeek["FOURTH_WEEK"] = 4] = "FOURTH_WEEK";
|
|
302
646
|
})(exports.ZoomMonthlyWeek || (exports.ZoomMonthlyWeek = {}));
|
|
303
647
|
exports.ZoomMonthlyWeekDay = void 0;
|
|
304
|
-
(function
|
|
648
|
+
(function(ZoomMonthlyWeekDay) {
|
|
305
649
|
ZoomMonthlyWeekDay[ZoomMonthlyWeekDay["SUNDAY"] = 1] = "SUNDAY";
|
|
306
650
|
ZoomMonthlyWeekDay[ZoomMonthlyWeekDay["MONDAY"] = 2] = "MONDAY";
|
|
307
651
|
ZoomMonthlyWeekDay[ZoomMonthlyWeekDay["TUESDAY"] = 3] = "TUESDAY";
|
|
@@ -311,34 +655,28 @@ exports.ZoomMonthlyWeekDay = void 0;
|
|
|
311
655
|
ZoomMonthlyWeekDay[ZoomMonthlyWeekDay["SATURDAY"] = 7] = "SATURDAY";
|
|
312
656
|
})(exports.ZoomMonthlyWeekDay || (exports.ZoomMonthlyWeekDay = {}));
|
|
313
657
|
exports.ZoomApprovalType = void 0;
|
|
314
|
-
(function
|
|
658
|
+
(function(ZoomApprovalType) {
|
|
315
659
|
/**
|
|
316
660
|
* Automatically approve.
|
|
317
|
-
*/
|
|
318
|
-
ZoomApprovalType[ZoomApprovalType["AUTOMATICALLY_APPROVE"] = 0] = "AUTOMATICALLY_APPROVE";
|
|
661
|
+
*/ ZoomApprovalType[ZoomApprovalType["AUTOMATICALLY_APPROVE"] = 0] = "AUTOMATICALLY_APPROVE";
|
|
319
662
|
/**
|
|
320
663
|
* Manually approve.
|
|
321
|
-
*/
|
|
322
|
-
ZoomApprovalType[ZoomApprovalType["MANUALLY_APPROVE"] = 1] = "MANUALLY_APPROVE";
|
|
664
|
+
*/ ZoomApprovalType[ZoomApprovalType["MANUALLY_APPROVE"] = 1] = "MANUALLY_APPROVE";
|
|
323
665
|
/**
|
|
324
666
|
* No registration required.
|
|
325
|
-
*/
|
|
326
|
-
ZoomApprovalType[ZoomApprovalType["NO_REGISTRATION_REQUIRED"] = 2] = "NO_REGISTRATION_REQUIRED";
|
|
667
|
+
*/ ZoomApprovalType[ZoomApprovalType["NO_REGISTRATION_REQUIRED"] = 2] = "NO_REGISTRATION_REQUIRED";
|
|
327
668
|
})(exports.ZoomApprovalType || (exports.ZoomApprovalType = {}));
|
|
328
669
|
exports.ZoomRegistrationType = void 0;
|
|
329
|
-
(function
|
|
670
|
+
(function(ZoomRegistrationType) {
|
|
330
671
|
/**
|
|
331
672
|
* Attendees register once and can attend any meeting occurrence.
|
|
332
|
-
*/
|
|
333
|
-
ZoomRegistrationType[ZoomRegistrationType["REGISTER_ONCE_ATTEND_ANY"] = 1] = "REGISTER_ONCE_ATTEND_ANY";
|
|
673
|
+
*/ ZoomRegistrationType[ZoomRegistrationType["REGISTER_ONCE_ATTEND_ANY"] = 1] = "REGISTER_ONCE_ATTEND_ANY";
|
|
334
674
|
/**
|
|
335
675
|
* Attendees must register for each meeting occurrence.
|
|
336
|
-
*/
|
|
337
|
-
ZoomRegistrationType[ZoomRegistrationType["REGISTER_FOR_EACH_OCCURRENCE"] = 2] = "REGISTER_FOR_EACH_OCCURRENCE";
|
|
676
|
+
*/ ZoomRegistrationType[ZoomRegistrationType["REGISTER_FOR_EACH_OCCURRENCE"] = 2] = "REGISTER_FOR_EACH_OCCURRENCE";
|
|
338
677
|
/**
|
|
339
678
|
* Attendees register once and can select one or more meeting occurrences to attend.
|
|
340
|
-
*/
|
|
341
|
-
ZoomRegistrationType[ZoomRegistrationType["REGISTER_ONCE_CHOOSE_OCCURRENCES"] = 3] = "REGISTER_ONCE_CHOOSE_OCCURRENCES";
|
|
679
|
+
*/ ZoomRegistrationType[ZoomRegistrationType["REGISTER_ONCE_CHOOSE_OCCURRENCES"] = 3] = "REGISTER_ONCE_CHOOSE_OCCURRENCES";
|
|
342
680
|
})(exports.ZoomRegistrationType || (exports.ZoomRegistrationType = {}));
|
|
343
681
|
|
|
344
682
|
/**
|
|
@@ -346,45 +684,192 @@ exports.ZoomRegistrationType = void 0;
|
|
|
346
684
|
*
|
|
347
685
|
* @param context
|
|
348
686
|
* @returns
|
|
349
|
-
*/
|
|
350
|
-
function
|
|
351
|
-
|
|
687
|
+
*/ function getUser(context) {
|
|
688
|
+
return function(input) {
|
|
689
|
+
return context.fetchJson("/users/".concat(input.userId), 'GET');
|
|
690
|
+
};
|
|
352
691
|
}
|
|
353
692
|
/**
|
|
354
693
|
* https://developers.zoom.us/docs/api/users/#tag/users/GET/users
|
|
355
694
|
*
|
|
356
695
|
* @param context
|
|
357
696
|
* @returns
|
|
358
|
-
*/
|
|
359
|
-
function
|
|
360
|
-
|
|
697
|
+
*/ function listUsers(context) {
|
|
698
|
+
return function(input) {
|
|
699
|
+
return context.fetchJson("/users?".concat(fetch.makeUrlSearchParams(input)), 'GET').then(mapToZoomPageResult('users'));
|
|
700
|
+
};
|
|
361
701
|
}
|
|
362
702
|
function listUsersPageFactory(context) {
|
|
363
703
|
return zoomFetchPageFactory(listUsers(context));
|
|
364
704
|
}
|
|
365
705
|
|
|
366
706
|
exports.ZoomUserType = void 0;
|
|
367
|
-
(function
|
|
707
|
+
(function(ZoomUserType) {
|
|
368
708
|
ZoomUserType[ZoomUserType["Basic"] = 1] = "Basic";
|
|
369
709
|
ZoomUserType[ZoomUserType["Licensed"] = 2] = "Licensed";
|
|
370
710
|
ZoomUserType[ZoomUserType["Unassigned"] = 4] = "Unassigned";
|
|
371
711
|
ZoomUserType[ZoomUserType["None"] = 99] = "None";
|
|
372
712
|
})(exports.ZoomUserType || (exports.ZoomUserType = {}));
|
|
373
713
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
714
|
+
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
715
|
+
try {
|
|
716
|
+
var info = gen[key](arg);
|
|
717
|
+
var value = info.value;
|
|
718
|
+
} catch (error) {
|
|
719
|
+
reject(error);
|
|
720
|
+
return;
|
|
381
721
|
}
|
|
382
|
-
|
|
722
|
+
if (info.done) {
|
|
723
|
+
resolve(value);
|
|
724
|
+
} else {
|
|
725
|
+
Promise.resolve(value).then(_next, _throw);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
function _async_to_generator$4(fn) {
|
|
729
|
+
return function() {
|
|
730
|
+
var self = this, args = arguments;
|
|
731
|
+
return new Promise(function(resolve, reject) {
|
|
732
|
+
var gen = fn.apply(self, args);
|
|
733
|
+
function _next(value) {
|
|
734
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
|
|
735
|
+
}
|
|
736
|
+
function _throw(err) {
|
|
737
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
|
|
738
|
+
}
|
|
739
|
+
_next(undefined);
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function _ts_generator$4(thisArg, body) {
|
|
744
|
+
var f, y, t, _ = {
|
|
745
|
+
label: 0,
|
|
746
|
+
sent: function() {
|
|
747
|
+
if (t[0] & 1) throw t[1];
|
|
748
|
+
return t[1];
|
|
749
|
+
},
|
|
750
|
+
trys: [],
|
|
751
|
+
ops: []
|
|
752
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
753
|
+
return d(g, "next", {
|
|
754
|
+
value: verb(0)
|
|
755
|
+
}), d(g, "throw", {
|
|
756
|
+
value: verb(1)
|
|
757
|
+
}), d(g, "return", {
|
|
758
|
+
value: verb(2)
|
|
759
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
760
|
+
value: function() {
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
}), g;
|
|
764
|
+
function verb(n) {
|
|
765
|
+
return function(v) {
|
|
766
|
+
return step([
|
|
767
|
+
n,
|
|
768
|
+
v
|
|
769
|
+
]);
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function step(op) {
|
|
773
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
774
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
775
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
776
|
+
if (y = 0, t) op = [
|
|
777
|
+
op[0] & 2,
|
|
778
|
+
t.value
|
|
779
|
+
];
|
|
780
|
+
switch(op[0]){
|
|
781
|
+
case 0:
|
|
782
|
+
case 1:
|
|
783
|
+
t = op;
|
|
784
|
+
break;
|
|
785
|
+
case 4:
|
|
786
|
+
_.label++;
|
|
787
|
+
return {
|
|
788
|
+
value: op[1],
|
|
789
|
+
done: false
|
|
790
|
+
};
|
|
791
|
+
case 5:
|
|
792
|
+
_.label++;
|
|
793
|
+
y = op[1];
|
|
794
|
+
op = [
|
|
795
|
+
0
|
|
796
|
+
];
|
|
797
|
+
continue;
|
|
798
|
+
case 7:
|
|
799
|
+
op = _.ops.pop();
|
|
800
|
+
_.trys.pop();
|
|
801
|
+
continue;
|
|
802
|
+
default:
|
|
803
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
804
|
+
_ = 0;
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
808
|
+
_.label = op[1];
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
812
|
+
_.label = t[1];
|
|
813
|
+
t = op;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
if (t && _.label < t[2]) {
|
|
817
|
+
_.label = t[2];
|
|
818
|
+
_.ops.push(op);
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
if (t[2]) _.ops.pop();
|
|
822
|
+
_.trys.pop();
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
op = body.call(thisArg, _);
|
|
826
|
+
} catch (e) {
|
|
827
|
+
op = [
|
|
828
|
+
6,
|
|
829
|
+
e
|
|
830
|
+
];
|
|
831
|
+
y = 0;
|
|
832
|
+
} finally{
|
|
833
|
+
f = t = 0;
|
|
834
|
+
}
|
|
835
|
+
if (op[0] & 5) throw op[1];
|
|
836
|
+
return {
|
|
837
|
+
value: op[0] ? op[1] : void 0,
|
|
838
|
+
done: true
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
// MARK: Parser
|
|
843
|
+
var logZoomErrorToConsole = logZoomServerErrorFunction('Zoom');
|
|
844
|
+
function parseZoomApiError(responseError) {
|
|
845
|
+
return _async_to_generator$4(function() {
|
|
846
|
+
var data, result;
|
|
847
|
+
return _ts_generator$4(this, function(_state) {
|
|
848
|
+
switch(_state.label){
|
|
849
|
+
case 0:
|
|
850
|
+
return [
|
|
851
|
+
4,
|
|
852
|
+
responseError.response.json().catch(function(x) {
|
|
853
|
+
return undefined;
|
|
854
|
+
})
|
|
855
|
+
];
|
|
856
|
+
case 1:
|
|
857
|
+
data = _state.sent();
|
|
858
|
+
if (data) {
|
|
859
|
+
result = parseZoomApiServerErrorResponseData(data, responseError);
|
|
860
|
+
}
|
|
861
|
+
return [
|
|
862
|
+
2,
|
|
863
|
+
result
|
|
864
|
+
];
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
})();
|
|
383
868
|
}
|
|
384
869
|
function parseZoomApiServerErrorResponseData(zoomServerError, responseError) {
|
|
385
|
-
|
|
870
|
+
var result;
|
|
386
871
|
if (zoomServerError) {
|
|
387
|
-
switch
|
|
872
|
+
switch(zoomServerError.code){
|
|
388
873
|
default:
|
|
389
874
|
result = parseZoomServerErrorData(zoomServerError, responseError);
|
|
390
875
|
break;
|
|
@@ -392,48 +877,274 @@ function parseZoomApiServerErrorResponseData(zoomServerError, responseError) {
|
|
|
392
877
|
}
|
|
393
878
|
return result;
|
|
394
879
|
}
|
|
395
|
-
|
|
880
|
+
var handleZoomErrorFetch = handleZoomErrorFetchFactory(parseZoomApiError, logZoomErrorToConsole);
|
|
396
881
|
|
|
882
|
+
function _assert_this_initialized(self) {
|
|
883
|
+
if (self === void 0) {
|
|
884
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
885
|
+
}
|
|
886
|
+
return self;
|
|
887
|
+
}
|
|
888
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
889
|
+
try {
|
|
890
|
+
var info = gen[key](arg);
|
|
891
|
+
var value = info.value;
|
|
892
|
+
} catch (error) {
|
|
893
|
+
reject(error);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (info.done) {
|
|
897
|
+
resolve(value);
|
|
898
|
+
} else {
|
|
899
|
+
Promise.resolve(value).then(_next, _throw);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
function _async_to_generator$3(fn) {
|
|
903
|
+
return function() {
|
|
904
|
+
var self = this, args = arguments;
|
|
905
|
+
return new Promise(function(resolve, reject) {
|
|
906
|
+
var gen = fn.apply(self, args);
|
|
907
|
+
function _next(value) {
|
|
908
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
909
|
+
}
|
|
910
|
+
function _throw(err) {
|
|
911
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
912
|
+
}
|
|
913
|
+
_next(undefined);
|
|
914
|
+
});
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function _call_super(_this, derived, args) {
|
|
918
|
+
derived = _get_prototype_of(derived);
|
|
919
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
920
|
+
}
|
|
921
|
+
function _class_call_check(instance, Constructor) {
|
|
922
|
+
if (!(instance instanceof Constructor)) {
|
|
923
|
+
throw new TypeError("Cannot call a class as a function");
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function _define_property(obj, key, value) {
|
|
927
|
+
if (key in obj) {
|
|
928
|
+
Object.defineProperty(obj, key, {
|
|
929
|
+
value: value,
|
|
930
|
+
enumerable: true,
|
|
931
|
+
configurable: true,
|
|
932
|
+
writable: true
|
|
933
|
+
});
|
|
934
|
+
} else {
|
|
935
|
+
obj[key] = value;
|
|
936
|
+
}
|
|
937
|
+
return obj;
|
|
938
|
+
}
|
|
939
|
+
function _get_prototype_of(o) {
|
|
940
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
941
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
942
|
+
};
|
|
943
|
+
return _get_prototype_of(o);
|
|
944
|
+
}
|
|
945
|
+
function _inherits(subClass, superClass) {
|
|
946
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
947
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
948
|
+
}
|
|
949
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
950
|
+
constructor: {
|
|
951
|
+
value: subClass,
|
|
952
|
+
writable: true,
|
|
953
|
+
configurable: true
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
957
|
+
}
|
|
958
|
+
function _possible_constructor_return(self, call) {
|
|
959
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
960
|
+
return call;
|
|
961
|
+
}
|
|
962
|
+
return _assert_this_initialized(self);
|
|
963
|
+
}
|
|
964
|
+
function _set_prototype_of(o, p) {
|
|
965
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
966
|
+
o.__proto__ = p;
|
|
967
|
+
return o;
|
|
968
|
+
};
|
|
969
|
+
return _set_prototype_of(o, p);
|
|
970
|
+
}
|
|
971
|
+
function _type_of(obj) {
|
|
972
|
+
"@swc/helpers - typeof";
|
|
973
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
974
|
+
}
|
|
975
|
+
function _is_native_reflect_construct() {
|
|
976
|
+
try {
|
|
977
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
978
|
+
} catch (_) {}
|
|
979
|
+
return (_is_native_reflect_construct = function() {
|
|
980
|
+
return !!result;
|
|
981
|
+
})();
|
|
982
|
+
}
|
|
983
|
+
function _ts_generator$3(thisArg, body) {
|
|
984
|
+
var f, y, t, _ = {
|
|
985
|
+
label: 0,
|
|
986
|
+
sent: function() {
|
|
987
|
+
if (t[0] & 1) throw t[1];
|
|
988
|
+
return t[1];
|
|
989
|
+
},
|
|
990
|
+
trys: [],
|
|
991
|
+
ops: []
|
|
992
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
993
|
+
return d(g, "next", {
|
|
994
|
+
value: verb(0)
|
|
995
|
+
}), d(g, "throw", {
|
|
996
|
+
value: verb(1)
|
|
997
|
+
}), d(g, "return", {
|
|
998
|
+
value: verb(2)
|
|
999
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1000
|
+
value: function() {
|
|
1001
|
+
return this;
|
|
1002
|
+
}
|
|
1003
|
+
}), g;
|
|
1004
|
+
function verb(n) {
|
|
1005
|
+
return function(v) {
|
|
1006
|
+
return step([
|
|
1007
|
+
n,
|
|
1008
|
+
v
|
|
1009
|
+
]);
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
function step(op) {
|
|
1013
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1014
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1015
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1016
|
+
if (y = 0, t) op = [
|
|
1017
|
+
op[0] & 2,
|
|
1018
|
+
t.value
|
|
1019
|
+
];
|
|
1020
|
+
switch(op[0]){
|
|
1021
|
+
case 0:
|
|
1022
|
+
case 1:
|
|
1023
|
+
t = op;
|
|
1024
|
+
break;
|
|
1025
|
+
case 4:
|
|
1026
|
+
_.label++;
|
|
1027
|
+
return {
|
|
1028
|
+
value: op[1],
|
|
1029
|
+
done: false
|
|
1030
|
+
};
|
|
1031
|
+
case 5:
|
|
1032
|
+
_.label++;
|
|
1033
|
+
y = op[1];
|
|
1034
|
+
op = [
|
|
1035
|
+
0
|
|
1036
|
+
];
|
|
1037
|
+
continue;
|
|
1038
|
+
case 7:
|
|
1039
|
+
op = _.ops.pop();
|
|
1040
|
+
_.trys.pop();
|
|
1041
|
+
continue;
|
|
1042
|
+
default:
|
|
1043
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1044
|
+
_ = 0;
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1048
|
+
_.label = op[1];
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1052
|
+
_.label = t[1];
|
|
1053
|
+
t = op;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
if (t && _.label < t[2]) {
|
|
1057
|
+
_.label = t[2];
|
|
1058
|
+
_.ops.push(op);
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
if (t[2]) _.ops.pop();
|
|
1062
|
+
_.trys.pop();
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
op = body.call(thisArg, _);
|
|
1066
|
+
} catch (e) {
|
|
1067
|
+
op = [
|
|
1068
|
+
6,
|
|
1069
|
+
e
|
|
1070
|
+
];
|
|
1071
|
+
y = 0;
|
|
1072
|
+
} finally{
|
|
1073
|
+
f = t = 0;
|
|
1074
|
+
}
|
|
1075
|
+
if (op[0] & 5) throw op[1];
|
|
1076
|
+
return {
|
|
1077
|
+
value: op[0] ? op[1] : void 0,
|
|
1078
|
+
done: true
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
397
1082
|
/**
|
|
398
1083
|
* Error in the following cases:
|
|
399
1084
|
* - the refresh token string is invalid
|
|
400
|
-
*/
|
|
401
|
-
const ZOOM_ACCOUNTS_INVALID_GRANT_ERROR_CODE = 'invalid_grant';
|
|
1085
|
+
*/ var ZOOM_ACCOUNTS_INVALID_GRANT_ERROR_CODE = 'invalid_grant';
|
|
402
1086
|
/**
|
|
403
1087
|
* Thrown if the call to the Zoom API creating an access token using a refresh token fails.
|
|
404
|
-
*/
|
|
405
|
-
|
|
406
|
-
errorCode
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
1088
|
+
*/ var ZoomOAuthAccessTokenError = /*#__PURE__*/ function(FetchRequestFactoryError) {
|
|
1089
|
+
_inherits(ZoomOAuthAccessTokenError, FetchRequestFactoryError);
|
|
1090
|
+
function ZoomOAuthAccessTokenError(errorCode) {
|
|
1091
|
+
_class_call_check(this, ZoomOAuthAccessTokenError);
|
|
1092
|
+
var _this;
|
|
1093
|
+
_this = _call_super(this, ZoomOAuthAccessTokenError, [
|
|
1094
|
+
"ZoomOAuthAccessTokenError: ".concat(errorCode)
|
|
1095
|
+
]), _define_property(_this, "errorCode", void 0);
|
|
1096
|
+
_this.errorCode = errorCode;
|
|
1097
|
+
return _this;
|
|
410
1098
|
}
|
|
411
|
-
|
|
1099
|
+
return ZoomOAuthAccessTokenError;
|
|
1100
|
+
}(fetch.FetchRequestFactoryError);
|
|
412
1101
|
/**
|
|
413
1102
|
* Thrown if a valid ZoomAccessToken cannot be retrieved successfully.
|
|
414
|
-
*/
|
|
415
|
-
|
|
416
|
-
reason
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const data = await responseError.response.json().catch((x) => undefined);
|
|
425
|
-
let result;
|
|
426
|
-
if (data) {
|
|
427
|
-
result = parseZoomOAuthServerErrorResponseData(data, responseError);
|
|
1103
|
+
*/ var ZoomOAuthAuthFailureError = /*#__PURE__*/ function(FetchRequestFactoryError) {
|
|
1104
|
+
_inherits(ZoomOAuthAuthFailureError, FetchRequestFactoryError);
|
|
1105
|
+
function ZoomOAuthAuthFailureError(reason) {
|
|
1106
|
+
_class_call_check(this, ZoomOAuthAuthFailureError);
|
|
1107
|
+
var _this;
|
|
1108
|
+
_this = _call_super(this, ZoomOAuthAuthFailureError, [
|
|
1109
|
+
"Failed to retrieve proper authentication for the API call. Reason: ".concat(reason)
|
|
1110
|
+
]), _define_property(_this, "reason", void 0);
|
|
1111
|
+
_this.reason = reason;
|
|
1112
|
+
return _this;
|
|
428
1113
|
}
|
|
429
|
-
return
|
|
1114
|
+
return ZoomOAuthAuthFailureError;
|
|
1115
|
+
}(fetch.FetchRequestFactoryError);
|
|
1116
|
+
var logZoomOAuthErrorToConsole = logZoomServerErrorFunction('ZoomOAuth');
|
|
1117
|
+
function parseZoomOAuthError(responseError) {
|
|
1118
|
+
return _async_to_generator$3(function() {
|
|
1119
|
+
var data, result;
|
|
1120
|
+
return _ts_generator$3(this, function(_state) {
|
|
1121
|
+
switch(_state.label){
|
|
1122
|
+
case 0:
|
|
1123
|
+
return [
|
|
1124
|
+
4,
|
|
1125
|
+
responseError.response.json().catch(function(x) {
|
|
1126
|
+
return undefined;
|
|
1127
|
+
})
|
|
1128
|
+
];
|
|
1129
|
+
case 1:
|
|
1130
|
+
data = _state.sent();
|
|
1131
|
+
if (data) {
|
|
1132
|
+
result = parseZoomOAuthServerErrorResponseData(data, responseError);
|
|
1133
|
+
}
|
|
1134
|
+
return [
|
|
1135
|
+
2,
|
|
1136
|
+
result
|
|
1137
|
+
];
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
})();
|
|
430
1141
|
}
|
|
431
1142
|
function parseZoomOAuthServerErrorResponseData(zoomServerError, responseError) {
|
|
432
|
-
|
|
1143
|
+
var result;
|
|
433
1144
|
if (zoomServerError) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
switch
|
|
1145
|
+
var potentialErrorStringCode = zoomServerError.error;
|
|
1146
|
+
var errorCode = potentialErrorStringCode !== null && potentialErrorStringCode !== void 0 ? potentialErrorStringCode : zoomServerError.code;
|
|
1147
|
+
switch(errorCode){
|
|
437
1148
|
case ZOOM_ACCOUNTS_INVALID_GRANT_ERROR_CODE:
|
|
438
1149
|
result = new ZoomOAuthAccessTokenError(errorCode);
|
|
439
1150
|
break;
|
|
@@ -444,28 +1155,172 @@ function parseZoomOAuthServerErrorResponseData(zoomServerError, responseError) {
|
|
|
444
1155
|
}
|
|
445
1156
|
return result;
|
|
446
1157
|
}
|
|
447
|
-
|
|
1158
|
+
var handleZoomOAuthErrorFetch = handleZoomErrorFetchFactory(parseZoomOAuthError, logZoomOAuthErrorToConsole);
|
|
448
1159
|
|
|
1160
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1161
|
+
try {
|
|
1162
|
+
var info = gen[key](arg);
|
|
1163
|
+
var value = info.value;
|
|
1164
|
+
} catch (error) {
|
|
1165
|
+
reject(error);
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (info.done) {
|
|
1169
|
+
resolve(value);
|
|
1170
|
+
} else {
|
|
1171
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
function _async_to_generator$2(fn) {
|
|
1175
|
+
return function() {
|
|
1176
|
+
var self = this, args = arguments;
|
|
1177
|
+
return new Promise(function(resolve, reject) {
|
|
1178
|
+
var gen = fn.apply(self, args);
|
|
1179
|
+
function _next(value) {
|
|
1180
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1181
|
+
}
|
|
1182
|
+
function _throw(err) {
|
|
1183
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1184
|
+
}
|
|
1185
|
+
_next(undefined);
|
|
1186
|
+
});
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function _ts_generator$2(thisArg, body) {
|
|
1190
|
+
var f, y, t, _ = {
|
|
1191
|
+
label: 0,
|
|
1192
|
+
sent: function() {
|
|
1193
|
+
if (t[0] & 1) throw t[1];
|
|
1194
|
+
return t[1];
|
|
1195
|
+
},
|
|
1196
|
+
trys: [],
|
|
1197
|
+
ops: []
|
|
1198
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1199
|
+
return d(g, "next", {
|
|
1200
|
+
value: verb(0)
|
|
1201
|
+
}), d(g, "throw", {
|
|
1202
|
+
value: verb(1)
|
|
1203
|
+
}), d(g, "return", {
|
|
1204
|
+
value: verb(2)
|
|
1205
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1206
|
+
value: function() {
|
|
1207
|
+
return this;
|
|
1208
|
+
}
|
|
1209
|
+
}), g;
|
|
1210
|
+
function verb(n) {
|
|
1211
|
+
return function(v) {
|
|
1212
|
+
return step([
|
|
1213
|
+
n,
|
|
1214
|
+
v
|
|
1215
|
+
]);
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
function step(op) {
|
|
1219
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1220
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1221
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1222
|
+
if (y = 0, t) op = [
|
|
1223
|
+
op[0] & 2,
|
|
1224
|
+
t.value
|
|
1225
|
+
];
|
|
1226
|
+
switch(op[0]){
|
|
1227
|
+
case 0:
|
|
1228
|
+
case 1:
|
|
1229
|
+
t = op;
|
|
1230
|
+
break;
|
|
1231
|
+
case 4:
|
|
1232
|
+
_.label++;
|
|
1233
|
+
return {
|
|
1234
|
+
value: op[1],
|
|
1235
|
+
done: false
|
|
1236
|
+
};
|
|
1237
|
+
case 5:
|
|
1238
|
+
_.label++;
|
|
1239
|
+
y = op[1];
|
|
1240
|
+
op = [
|
|
1241
|
+
0
|
|
1242
|
+
];
|
|
1243
|
+
continue;
|
|
1244
|
+
case 7:
|
|
1245
|
+
op = _.ops.pop();
|
|
1246
|
+
_.trys.pop();
|
|
1247
|
+
continue;
|
|
1248
|
+
default:
|
|
1249
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1250
|
+
_ = 0;
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1254
|
+
_.label = op[1];
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1258
|
+
_.label = t[1];
|
|
1259
|
+
t = op;
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
if (t && _.label < t[2]) {
|
|
1263
|
+
_.label = t[2];
|
|
1264
|
+
_.ops.push(op);
|
|
1265
|
+
break;
|
|
1266
|
+
}
|
|
1267
|
+
if (t[2]) _.ops.pop();
|
|
1268
|
+
_.trys.pop();
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
op = body.call(thisArg, _);
|
|
1272
|
+
} catch (e) {
|
|
1273
|
+
op = [
|
|
1274
|
+
6,
|
|
1275
|
+
e
|
|
1276
|
+
];
|
|
1277
|
+
y = 0;
|
|
1278
|
+
} finally{
|
|
1279
|
+
f = t = 0;
|
|
1280
|
+
}
|
|
1281
|
+
if (op[0] & 5) throw op[1];
|
|
1282
|
+
return {
|
|
1283
|
+
value: op[0] ? op[1] : void 0,
|
|
1284
|
+
done: true
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
449
1288
|
/**
|
|
450
1289
|
* Generates a new ZoomAccessTokenStringFactory.
|
|
451
|
-
*/
|
|
452
|
-
function
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1290
|
+
*/ function zoomAccessTokenStringFactory(zoomAccessTokenFactory) {
|
|
1291
|
+
return function() {
|
|
1292
|
+
return _async_to_generator$2(function() {
|
|
1293
|
+
var token;
|
|
1294
|
+
return _ts_generator$2(this, function(_state) {
|
|
1295
|
+
switch(_state.label){
|
|
1296
|
+
case 0:
|
|
1297
|
+
return [
|
|
1298
|
+
4,
|
|
1299
|
+
zoomAccessTokenFactory()
|
|
1300
|
+
];
|
|
1301
|
+
case 1:
|
|
1302
|
+
token = _state.sent();
|
|
1303
|
+
if (!(token === null || token === void 0 ? void 0 : token.accessToken)) {
|
|
1304
|
+
throw new ZoomOAuthAuthFailureError();
|
|
1305
|
+
}
|
|
1306
|
+
return [
|
|
1307
|
+
2,
|
|
1308
|
+
token.accessToken
|
|
1309
|
+
];
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
})();
|
|
459
1313
|
};
|
|
460
1314
|
}
|
|
461
1315
|
|
|
462
|
-
|
|
463
|
-
console.warn(
|
|
1316
|
+
var DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION = function DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION(headers) {
|
|
1317
|
+
console.warn("zoomRateLimitedFetchHandler(): Too many requests made. The limit is ".concat(headers.limit, " requests per reset period. RetryAt is set for ").concat(headers.retryAfterAt, "."));
|
|
464
1318
|
};
|
|
465
1319
|
function zoomRateLimitedFetchHandler(config) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
1320
|
+
var _ref, _ref1, _ref2;
|
|
1321
|
+
var onTooManyRequests = (config === null || config === void 0 ? void 0 : config.onTooManyRequests) !== false ? (_ref = config === null || config === void 0 ? void 0 : config.onTooManyRequests) !== null && _ref !== void 0 ? _ref : DEFAULT_ZOOM_RATE_LIMITED_TOO_MANY_REQUETS_LOG_FUNCTION : undefined;
|
|
1322
|
+
var defaultLimit = (_ref1 = config === null || config === void 0 ? void 0 : config.maxRateLimit) !== null && _ref1 !== void 0 ? _ref1 : DEFAULT_ZOOM_API_RATE_LIMIT;
|
|
1323
|
+
var defaultResetPeriod = (_ref2 = config === null || config === void 0 ? void 0 : config.resetPeriod) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_ZOOM_API_RATE_LIMIT_RESET_PERIOD;
|
|
469
1324
|
function configForLimit(limit, resetAt) {
|
|
470
1325
|
return {
|
|
471
1326
|
limit: defaultLimit,
|
|
@@ -474,41 +1329,40 @@ function zoomRateLimitedFetchHandler(config) {
|
|
|
474
1329
|
exponentRate: 1.2,
|
|
475
1330
|
maxWaitTime: util.MS_IN_SECOND * 5,
|
|
476
1331
|
resetPeriod: defaultResetPeriod,
|
|
477
|
-
resetAt
|
|
1332
|
+
resetAt: resetAt
|
|
478
1333
|
};
|
|
479
1334
|
}
|
|
480
|
-
|
|
481
|
-
|
|
1335
|
+
var defaultConfig = configForLimit();
|
|
1336
|
+
var rateLimiter = util.resetPeriodPromiseRateLimiter(defaultConfig);
|
|
482
1337
|
return fetch.rateLimitedFetchHandler({
|
|
483
|
-
rateLimiter,
|
|
484
|
-
updateWithResponse: function (response, fetchResponseError) {
|
|
485
|
-
|
|
486
|
-
|
|
1338
|
+
rateLimiter: rateLimiter,
|
|
1339
|
+
updateWithResponse: function updateWithResponse(response, fetchResponseError) {
|
|
1340
|
+
var hasLimitHeader = response.headers.has(ZOOM_RATE_LIMIT_REMAINING_HEADER);
|
|
1341
|
+
var shouldRetry = false;
|
|
487
1342
|
// let enabled = false; // rate limiter should not be turned off
|
|
488
1343
|
if (hasLimitHeader) {
|
|
489
|
-
|
|
1344
|
+
var headerDetails = zoomRateLimitHeaderDetails(response.headers);
|
|
490
1345
|
if (headerDetails) {
|
|
491
|
-
|
|
1346
|
+
var type = headerDetails.type, limit = headerDetails.limit, retryAfterAt = headerDetails.retryAfterAt, remaining = headerDetails.remaining;
|
|
492
1347
|
if (response.status === ZOOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE) {
|
|
493
1348
|
// For simple query-per-second rate limits, just schedule a retry
|
|
494
1349
|
if (type === 'QPS') {
|
|
495
1350
|
shouldRetry = true;
|
|
496
1351
|
try {
|
|
497
|
-
onTooManyRequests
|
|
498
|
-
}
|
|
499
|
-
catch (e) { }
|
|
1352
|
+
onTooManyRequests === null || onTooManyRequests === void 0 ? void 0 : onTooManyRequests(headerDetails, response, fetchResponseError);
|
|
1353
|
+
} catch (e) {}
|
|
500
1354
|
}
|
|
501
1355
|
}
|
|
502
1356
|
// NOTE: typically it seems like these headers are not available usually.
|
|
503
1357
|
// There is a daily limit for message requests
|
|
504
1358
|
if (limit != null && retryAfterAt != null && remaining != null) {
|
|
505
1359
|
if (limit !== defaultLimit) {
|
|
506
|
-
|
|
1360
|
+
var newConfig = configForLimit(limit, retryAfterAt);
|
|
507
1361
|
rateLimiter.setConfig(newConfig, false);
|
|
508
1362
|
}
|
|
509
1363
|
rateLimiter.setRemainingLimit(remaining);
|
|
510
1364
|
rateLimiter.setNextResetAt(retryAfterAt);
|
|
511
|
-
|
|
1365
|
+
// enabled = true;
|
|
512
1366
|
}
|
|
513
1367
|
}
|
|
514
1368
|
}
|
|
@@ -520,69 +1374,218 @@ function zoomRateLimitedFetchHandler(config) {
|
|
|
520
1374
|
|
|
521
1375
|
/**
|
|
522
1376
|
* The Zoom API URL for the US datacenter.
|
|
523
|
-
*/
|
|
524
|
-
const ZOOM_API_URL = 'https://api.zoom.us/v2';
|
|
1377
|
+
*/ var ZOOM_API_URL = 'https://api.zoom.us/v2';
|
|
525
1378
|
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
1379
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1380
|
+
try {
|
|
1381
|
+
var info = gen[key](arg);
|
|
1382
|
+
var value = info.value;
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
reject(error);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (info.done) {
|
|
1388
|
+
resolve(value);
|
|
1389
|
+
} else {
|
|
1390
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function _async_to_generator$1(fn) {
|
|
1394
|
+
return function() {
|
|
1395
|
+
var self = this, args = arguments;
|
|
1396
|
+
return new Promise(function(resolve, reject) {
|
|
1397
|
+
var gen = fn.apply(self, args);
|
|
1398
|
+
function _next(value) {
|
|
1399
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1400
|
+
}
|
|
1401
|
+
function _throw(err) {
|
|
1402
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1403
|
+
}
|
|
1404
|
+
_next(undefined);
|
|
1405
|
+
});
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
function _ts_generator$1(thisArg, body) {
|
|
1409
|
+
var f, y, t, _ = {
|
|
1410
|
+
label: 0,
|
|
1411
|
+
sent: function() {
|
|
1412
|
+
if (t[0] & 1) throw t[1];
|
|
1413
|
+
return t[1];
|
|
1414
|
+
},
|
|
1415
|
+
trys: [],
|
|
1416
|
+
ops: []
|
|
1417
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1418
|
+
return d(g, "next", {
|
|
1419
|
+
value: verb(0)
|
|
1420
|
+
}), d(g, "throw", {
|
|
1421
|
+
value: verb(1)
|
|
1422
|
+
}), d(g, "return", {
|
|
1423
|
+
value: verb(2)
|
|
1424
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1425
|
+
value: function() {
|
|
1426
|
+
return this;
|
|
1427
|
+
}
|
|
1428
|
+
}), g;
|
|
1429
|
+
function verb(n) {
|
|
1430
|
+
return function(v) {
|
|
1431
|
+
return step([
|
|
1432
|
+
n,
|
|
1433
|
+
v
|
|
1434
|
+
]);
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
function step(op) {
|
|
1438
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1439
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1440
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1441
|
+
if (y = 0, t) op = [
|
|
1442
|
+
op[0] & 2,
|
|
1443
|
+
t.value
|
|
1444
|
+
];
|
|
1445
|
+
switch(op[0]){
|
|
1446
|
+
case 0:
|
|
1447
|
+
case 1:
|
|
1448
|
+
t = op;
|
|
1449
|
+
break;
|
|
1450
|
+
case 4:
|
|
1451
|
+
_.label++;
|
|
1452
|
+
return {
|
|
1453
|
+
value: op[1],
|
|
1454
|
+
done: false
|
|
1455
|
+
};
|
|
1456
|
+
case 5:
|
|
1457
|
+
_.label++;
|
|
1458
|
+
y = op[1];
|
|
1459
|
+
op = [
|
|
1460
|
+
0
|
|
1461
|
+
];
|
|
1462
|
+
continue;
|
|
1463
|
+
case 7:
|
|
1464
|
+
op = _.ops.pop();
|
|
1465
|
+
_.trys.pop();
|
|
1466
|
+
continue;
|
|
1467
|
+
default:
|
|
1468
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1469
|
+
_ = 0;
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1473
|
+
_.label = op[1];
|
|
1474
|
+
break;
|
|
1475
|
+
}
|
|
1476
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1477
|
+
_.label = t[1];
|
|
1478
|
+
t = op;
|
|
1479
|
+
break;
|
|
1480
|
+
}
|
|
1481
|
+
if (t && _.label < t[2]) {
|
|
1482
|
+
_.label = t[2];
|
|
1483
|
+
_.ops.push(op);
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
if (t[2]) _.ops.pop();
|
|
1487
|
+
_.trys.pop();
|
|
1488
|
+
continue;
|
|
536
1489
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
1490
|
+
op = body.call(thisArg, _);
|
|
1491
|
+
} catch (e) {
|
|
1492
|
+
op = [
|
|
1493
|
+
6,
|
|
1494
|
+
e
|
|
1495
|
+
];
|
|
1496
|
+
y = 0;
|
|
1497
|
+
} finally{
|
|
1498
|
+
f = t = 0;
|
|
1499
|
+
}
|
|
1500
|
+
if (op[0] & 5) throw op[1];
|
|
1501
|
+
return {
|
|
1502
|
+
value: op[0] ? op[1] : void 0,
|
|
1503
|
+
done: true
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function zoomFactory(factoryConfig) {
|
|
1508
|
+
var oauthContext = factoryConfig.oauthContext;
|
|
1509
|
+
var serverAccessTokenStringFactory = zoomAccessTokenStringFactory(oauthContext.loadAccessToken);
|
|
1510
|
+
var fetchHandler = zoomRateLimitedFetchHandler(factoryConfig.rateLimiterConfig);
|
|
1511
|
+
var logZoomServerErrorFunction = factoryConfig.logZoomServerErrorFunction, _factoryConfig_fetchFactory = factoryConfig.fetchFactory, fetchFactory = _factoryConfig_fetchFactory === void 0 ? function(input) {
|
|
1512
|
+
return fetch.fetchApiFetchService.makeFetch({
|
|
1513
|
+
baseUrl: ZOOM_API_URL,
|
|
1514
|
+
baseRequest: function baseRequest() {
|
|
1515
|
+
return _async_to_generator$1(function() {
|
|
1516
|
+
var _tmp, _tmp1, _, _1;
|
|
1517
|
+
return _ts_generator$1(this, function(_state) {
|
|
1518
|
+
switch(_state.label){
|
|
1519
|
+
case 0:
|
|
1520
|
+
_tmp = {};
|
|
1521
|
+
_tmp1 = {
|
|
1522
|
+
'Content-Type': 'application/json'
|
|
1523
|
+
};
|
|
1524
|
+
_1 = (_ = "Bearer ").concat;
|
|
1525
|
+
return [
|
|
1526
|
+
4,
|
|
1527
|
+
input.zoomAccessTokenStringFactory()
|
|
1528
|
+
];
|
|
1529
|
+
case 1:
|
|
1530
|
+
return [
|
|
1531
|
+
2,
|
|
1532
|
+
(_tmp.headers = (_tmp1.Authorization = _1.apply(_, [
|
|
1533
|
+
_state.sent()
|
|
1534
|
+
]), _tmp1), _tmp)
|
|
1535
|
+
];
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
})();
|
|
1539
|
+
},
|
|
1540
|
+
fetchHandler: fetchHandler,
|
|
1541
|
+
timeout: 20 * 1000,
|
|
1542
|
+
requireOkResponse: true,
|
|
1543
|
+
useTimeout: true // use timeout
|
|
1544
|
+
});
|
|
1545
|
+
} : _factoryConfig_fetchFactory;
|
|
1546
|
+
return function(config) {
|
|
1547
|
+
var baseFetch = fetchFactory({
|
|
545
1548
|
zoomAccessTokenStringFactory: serverAccessTokenStringFactory
|
|
546
1549
|
});
|
|
547
|
-
|
|
548
|
-
|
|
1550
|
+
var serverFetch = handleZoomErrorFetch(baseFetch, logZoomServerErrorFunction);
|
|
1551
|
+
var serverFetchJson = fetch.fetchJsonFunction(serverFetch, {
|
|
549
1552
|
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
550
1553
|
});
|
|
551
1554
|
// MARK: Make User Context
|
|
552
|
-
|
|
553
|
-
|
|
1555
|
+
var makeUserContext = function makeUserContext(input) {
|
|
1556
|
+
var userAccessTokenFactory = oauthContext.makeUserAccessTokenFactory({
|
|
554
1557
|
refreshToken: input.refreshToken,
|
|
555
1558
|
userAccessTokenCache: input.accessTokenCache
|
|
556
1559
|
});
|
|
557
|
-
|
|
558
|
-
|
|
1560
|
+
var userAccessTokenStringFactory = zoomAccessTokenStringFactory(userAccessTokenFactory);
|
|
1561
|
+
var userFetch = fetchFactory({
|
|
559
1562
|
zoomAccessTokenStringFactory: userAccessTokenStringFactory
|
|
560
1563
|
});
|
|
561
|
-
|
|
1564
|
+
var userFetchJson = fetch.fetchJsonFunction(userFetch, {
|
|
562
1565
|
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
563
1566
|
});
|
|
564
|
-
|
|
1567
|
+
var result = {
|
|
565
1568
|
zoomServerContext: zoomContext,
|
|
566
1569
|
type: 'user',
|
|
567
1570
|
fetch: userFetch,
|
|
568
1571
|
fetchJson: userFetchJson,
|
|
569
|
-
userFetch,
|
|
570
|
-
userFetchJson,
|
|
1572
|
+
userFetch: userFetch,
|
|
1573
|
+
userFetchJson: userFetchJson,
|
|
571
1574
|
zoomRateLimiter: fetchHandler._rateLimiter
|
|
572
1575
|
};
|
|
573
1576
|
return result;
|
|
574
1577
|
};
|
|
575
|
-
|
|
1578
|
+
var zoomContext = {
|
|
576
1579
|
type: 'server',
|
|
577
1580
|
fetch: serverFetch,
|
|
578
1581
|
fetchJson: serverFetchJson,
|
|
579
|
-
serverFetch,
|
|
580
|
-
serverFetchJson,
|
|
581
|
-
makeUserContext,
|
|
582
|
-
config,
|
|
1582
|
+
serverFetch: serverFetch,
|
|
1583
|
+
serverFetchJson: serverFetchJson,
|
|
1584
|
+
makeUserContext: makeUserContext,
|
|
1585
|
+
config: config,
|
|
583
1586
|
zoomRateLimiter: fetchHandler._rateLimiter
|
|
584
1587
|
};
|
|
585
|
-
|
|
1588
|
+
var zoom = {
|
|
586
1589
|
zoomServerContext: zoomContext
|
|
587
1590
|
};
|
|
588
1591
|
return zoom;
|
|
@@ -594,10 +1597,10 @@ function zoomFactory(factoryConfig) {
|
|
|
594
1597
|
*
|
|
595
1598
|
* @param context
|
|
596
1599
|
* @returns
|
|
597
|
-
*/
|
|
598
|
-
function
|
|
599
|
-
|
|
600
|
-
return context.fetchJson(
|
|
1600
|
+
*/ function serverAccessToken(context) {
|
|
1601
|
+
return function(input) {
|
|
1602
|
+
var _ref;
|
|
1603
|
+
return context.fetchJson("/token?grant_type=account_credentials&account_id=".concat((_ref = input === null || input === void 0 ? void 0 : input.accountId) !== null && _ref !== void 0 ? _ref : context.config.accountId), zoomOAuthApiFetchJsonInput(context, input));
|
|
601
1604
|
};
|
|
602
1605
|
}
|
|
603
1606
|
/**
|
|
@@ -605,21 +1608,22 @@ function serverAccessToken(context) {
|
|
|
605
1608
|
*
|
|
606
1609
|
* @param context
|
|
607
1610
|
* @returns
|
|
608
|
-
*/
|
|
609
|
-
function
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return context.fetchJson(`/token?grant_type=refresh_token&refresh_token=${refreshToken}`, zoomOAuthApiFetchJsonInput(context, input));
|
|
1611
|
+
*/ function userAccessToken(context) {
|
|
1612
|
+
return function(input) {
|
|
1613
|
+
var refreshToken = input.refreshToken;
|
|
1614
|
+
return context.fetchJson("/token?grant_type=refresh_token&refresh_token=".concat(refreshToken), zoomOAuthApiFetchJsonInput(context, input));
|
|
613
1615
|
};
|
|
614
1616
|
}
|
|
615
1617
|
function zoomOAuthApiFetchJsonInput(context, input) {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
1618
|
+
var _ref, _ref1;
|
|
1619
|
+
var _input_client, _input_client1;
|
|
1620
|
+
var clientId = (_ref = input === null || input === void 0 ? void 0 : (_input_client = input.client) === null || _input_client === void 0 ? void 0 : _input_client.clientId) !== null && _ref !== void 0 ? _ref : context.config.clientId;
|
|
1621
|
+
var clientSecret = (_ref1 = input === null || input === void 0 ? void 0 : (_input_client1 = input.client) === null || _input_client1 === void 0 ? void 0 : _input_client1.clientSecret) !== null && _ref1 !== void 0 ? _ref1 : context.config.clientSecret;
|
|
1622
|
+
var fetchJsonInput = {
|
|
619
1623
|
headers: {
|
|
620
1624
|
Authorization: zoomOAuthServerBasicAuthorizationHeaderValue({
|
|
621
|
-
clientId,
|
|
622
|
-
clientSecret
|
|
1625
|
+
clientId: clientId,
|
|
1626
|
+
clientSecret: clientSecret
|
|
623
1627
|
})
|
|
624
1628
|
},
|
|
625
1629
|
method: 'POST'
|
|
@@ -627,83 +1631,242 @@ function zoomOAuthApiFetchJsonInput(context, input) {
|
|
|
627
1631
|
return fetchJsonInput;
|
|
628
1632
|
}
|
|
629
1633
|
function zoomOAuthServerBasicAuthorizationHeaderValue(input) {
|
|
630
|
-
return
|
|
1634
|
+
return "Basic ".concat(Buffer.from("".concat(input.clientId, ":").concat(input.clientSecret)).toString('base64'));
|
|
631
1635
|
}
|
|
632
1636
|
|
|
633
1637
|
/**
|
|
634
1638
|
* The Zoom OAuth API URL for the US datacenter.
|
|
635
|
-
*/
|
|
636
|
-
const ZOOM_OAUTH_API_URL = 'https://zoom.us/oauth';
|
|
1639
|
+
*/ var ZOOM_OAUTH_API_URL = 'https://zoom.us/oauth';
|
|
637
1640
|
|
|
638
|
-
function
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1641
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1642
|
+
try {
|
|
1643
|
+
var info = gen[key](arg);
|
|
1644
|
+
var value = info.value;
|
|
1645
|
+
} catch (error) {
|
|
1646
|
+
reject(error);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
if (info.done) {
|
|
1650
|
+
resolve(value);
|
|
1651
|
+
} else {
|
|
1652
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
function _async_to_generator(fn) {
|
|
1656
|
+
return function() {
|
|
1657
|
+
var self = this, args = arguments;
|
|
1658
|
+
return new Promise(function(resolve, reject) {
|
|
1659
|
+
var gen = fn.apply(self, args);
|
|
1660
|
+
function _next(value) {
|
|
1661
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
645
1662
|
}
|
|
1663
|
+
function _throw(err) {
|
|
1664
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1665
|
+
}
|
|
1666
|
+
_next(undefined);
|
|
1667
|
+
});
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
function _ts_generator(thisArg, body) {
|
|
1671
|
+
var f, y, t, _ = {
|
|
1672
|
+
label: 0,
|
|
1673
|
+
sent: function() {
|
|
1674
|
+
if (t[0] & 1) throw t[1];
|
|
1675
|
+
return t[1];
|
|
646
1676
|
},
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
1677
|
+
trys: [],
|
|
1678
|
+
ops: []
|
|
1679
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1680
|
+
return d(g, "next", {
|
|
1681
|
+
value: verb(0)
|
|
1682
|
+
}), d(g, "throw", {
|
|
1683
|
+
value: verb(1)
|
|
1684
|
+
}), d(g, "return", {
|
|
1685
|
+
value: verb(2)
|
|
1686
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1687
|
+
value: function() {
|
|
1688
|
+
return this;
|
|
658
1689
|
}
|
|
659
|
-
|
|
660
|
-
|
|
1690
|
+
}), g;
|
|
1691
|
+
function verb(n) {
|
|
1692
|
+
return function(v) {
|
|
1693
|
+
return step([
|
|
1694
|
+
n,
|
|
1695
|
+
v
|
|
1696
|
+
]);
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
function step(op) {
|
|
1700
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1701
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1702
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1703
|
+
if (y = 0, t) op = [
|
|
1704
|
+
op[0] & 2,
|
|
1705
|
+
t.value
|
|
1706
|
+
];
|
|
1707
|
+
switch(op[0]){
|
|
1708
|
+
case 0:
|
|
1709
|
+
case 1:
|
|
1710
|
+
t = op;
|
|
1711
|
+
break;
|
|
1712
|
+
case 4:
|
|
1713
|
+
_.label++;
|
|
1714
|
+
return {
|
|
1715
|
+
value: op[1],
|
|
1716
|
+
done: false
|
|
1717
|
+
};
|
|
1718
|
+
case 5:
|
|
1719
|
+
_.label++;
|
|
1720
|
+
y = op[1];
|
|
1721
|
+
op = [
|
|
1722
|
+
0
|
|
1723
|
+
];
|
|
1724
|
+
continue;
|
|
1725
|
+
case 7:
|
|
1726
|
+
op = _.ops.pop();
|
|
1727
|
+
_.trys.pop();
|
|
1728
|
+
continue;
|
|
1729
|
+
default:
|
|
1730
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1731
|
+
_ = 0;
|
|
1732
|
+
continue;
|
|
1733
|
+
}
|
|
1734
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1735
|
+
_.label = op[1];
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1739
|
+
_.label = t[1];
|
|
1740
|
+
t = op;
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
if (t && _.label < t[2]) {
|
|
1744
|
+
_.label = t[2];
|
|
1745
|
+
_.ops.push(op);
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
if (t[2]) _.ops.pop();
|
|
1749
|
+
_.trys.pop();
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
op = body.call(thisArg, _);
|
|
1753
|
+
} catch (e) {
|
|
1754
|
+
op = [
|
|
1755
|
+
6,
|
|
1756
|
+
e
|
|
1757
|
+
];
|
|
1758
|
+
y = 0;
|
|
1759
|
+
} finally{
|
|
1760
|
+
f = t = 0;
|
|
661
1761
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1762
|
+
if (op[0] & 5) throw op[1];
|
|
1763
|
+
return {
|
|
1764
|
+
value: op[0] ? op[1] : void 0,
|
|
1765
|
+
done: true
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function zoomOAuthFactory(factoryConfig) {
|
|
1770
|
+
var fetchHandler = zoomRateLimitedFetchHandler();
|
|
1771
|
+
var logZoomServerErrorFunction = factoryConfig.logZoomServerErrorFunction, _factoryConfig_fetchFactory = factoryConfig.fetchFactory, fetchFactory = _factoryConfig_fetchFactory === void 0 ? function(_) {
|
|
1772
|
+
return fetch.fetchApiFetchService.makeFetch({
|
|
1773
|
+
baseUrl: ZOOM_OAUTH_API_URL,
|
|
1774
|
+
baseRequest: {
|
|
1775
|
+
headers: {
|
|
1776
|
+
'Content-Type': 'application/json'
|
|
1777
|
+
}
|
|
1778
|
+
},
|
|
1779
|
+
fetchHandler: fetchHandler,
|
|
1780
|
+
timeout: 20 * 1000,
|
|
1781
|
+
requireOkResponse: true,
|
|
1782
|
+
useTimeout: true // use timeout
|
|
666
1783
|
});
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
1784
|
+
} : _factoryConfig_fetchFactory;
|
|
1785
|
+
return function(config) {
|
|
1786
|
+
var accessTokenFromTokenResponse = function accessTokenFromTokenResponse(result) {
|
|
1787
|
+
var createdAt = new Date().getTime();
|
|
1788
|
+
var access_token = result.access_token, api_url = result.api_url, scope = result.scope, expires_in = result.expires_in;
|
|
1789
|
+
var accessToken = {
|
|
671
1790
|
accessToken: access_token,
|
|
672
1791
|
apiDomain: api_url,
|
|
673
1792
|
expiresIn: expires_in,
|
|
674
1793
|
expiresAt: new Date(createdAt + expires_in * util.MS_IN_SECOND),
|
|
675
|
-
scope
|
|
1794
|
+
scope: scope
|
|
676
1795
|
};
|
|
677
1796
|
return accessToken;
|
|
1797
|
+
};
|
|
1798
|
+
if (!config.clientId) {
|
|
1799
|
+
throw new Error('ZoomOAuthConfig missing clientId.');
|
|
1800
|
+
} else if (!config.clientSecret) {
|
|
1801
|
+
throw new Error('ZoomOAuthConfig missing clientSecret.');
|
|
1802
|
+
} else if (!config.accountId) {
|
|
1803
|
+
throw new Error('ZoomOAuthConfig missing accountId.');
|
|
678
1804
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
1805
|
+
var baseFetch = fetchFactory();
|
|
1806
|
+
var fetch$1 = handleZoomOAuthErrorFetch(baseFetch, logZoomServerErrorFunction);
|
|
1807
|
+
var fetchJson = fetch.fetchJsonFunction(fetch$1, {
|
|
1808
|
+
handleFetchJsonParseErrorFunction: fetch.returnNullHandleFetchJsonParseErrorFunction
|
|
1809
|
+
});
|
|
1810
|
+
var tokenRefresher = function tokenRefresher() {
|
|
1811
|
+
return _async_to_generator(function() {
|
|
1812
|
+
var accessToken;
|
|
1813
|
+
return _ts_generator(this, function(_state) {
|
|
1814
|
+
switch(_state.label){
|
|
1815
|
+
case 0:
|
|
1816
|
+
return [
|
|
1817
|
+
4,
|
|
1818
|
+
serverAccessToken(oauthContext)()
|
|
1819
|
+
];
|
|
1820
|
+
case 1:
|
|
1821
|
+
accessToken = _state.sent();
|
|
1822
|
+
return [
|
|
1823
|
+
2,
|
|
1824
|
+
accessTokenFromTokenResponse(accessToken)
|
|
1825
|
+
];
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
})();
|
|
682
1829
|
};
|
|
683
|
-
|
|
684
|
-
tokenRefresher,
|
|
1830
|
+
var loadAccessToken = zoomOAuthZoomAccessTokenFactory({
|
|
1831
|
+
tokenRefresher: tokenRefresher,
|
|
685
1832
|
accessTokenCache: config.accessTokenCache
|
|
686
1833
|
});
|
|
687
1834
|
// User Access Token
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
1835
|
+
var makeUserAccessTokenFactory = function makeUserAccessTokenFactory(input) {
|
|
1836
|
+
var userTokenRefresher = function userTokenRefresher() {
|
|
1837
|
+
return _async_to_generator(function() {
|
|
1838
|
+
var accessToken;
|
|
1839
|
+
return _ts_generator(this, function(_state) {
|
|
1840
|
+
switch(_state.label){
|
|
1841
|
+
case 0:
|
|
1842
|
+
return [
|
|
1843
|
+
4,
|
|
1844
|
+
userAccessToken(oauthContext)(input)
|
|
1845
|
+
];
|
|
1846
|
+
case 1:
|
|
1847
|
+
accessToken = _state.sent();
|
|
1848
|
+
return [
|
|
1849
|
+
2,
|
|
1850
|
+
accessTokenFromTokenResponse(accessToken)
|
|
1851
|
+
];
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
})();
|
|
692
1855
|
};
|
|
693
1856
|
return zoomOAuthZoomAccessTokenFactory({
|
|
694
1857
|
tokenRefresher: userTokenRefresher,
|
|
695
1858
|
accessTokenCache: input.userAccessTokenCache
|
|
696
1859
|
});
|
|
697
1860
|
};
|
|
698
|
-
|
|
1861
|
+
var oauthContext = {
|
|
699
1862
|
fetch: fetch$1,
|
|
700
|
-
fetchJson,
|
|
701
|
-
loadAccessToken,
|
|
702
|
-
makeUserAccessTokenFactory,
|
|
703
|
-
config
|
|
1863
|
+
fetchJson: fetchJson,
|
|
1864
|
+
loadAccessToken: loadAccessToken,
|
|
1865
|
+
makeUserAccessTokenFactory: makeUserAccessTokenFactory,
|
|
1866
|
+
config: config
|
|
704
1867
|
};
|
|
705
|
-
|
|
706
|
-
oauthContext
|
|
1868
|
+
var zoomOAuth = {
|
|
1869
|
+
oauthContext: oauthContext
|
|
707
1870
|
};
|
|
708
1871
|
return zoomOAuth;
|
|
709
1872
|
};
|
|
@@ -713,48 +1876,103 @@ function zoomOAuthFactory(factoryConfig) {
|
|
|
713
1876
|
*
|
|
714
1877
|
* @param config
|
|
715
1878
|
* @returns
|
|
716
|
-
*/
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
const tokenExpirationBuffer = inputTokenExpirationBuffer ?? util.MS_IN_MINUTE;
|
|
1879
|
+
*/ function zoomOAuthZoomAccessTokenFactory(config) {
|
|
1880
|
+
var tokenRefresher = config.tokenRefresher, accessTokenCache = config.accessTokenCache, inputTokenExpirationBuffer = config.tokenExpirationBuffer;
|
|
1881
|
+
var tokenExpirationBuffer = inputTokenExpirationBuffer !== null && inputTokenExpirationBuffer !== void 0 ? inputTokenExpirationBuffer : util.MS_IN_MINUTE;
|
|
720
1882
|
/**
|
|
721
1883
|
* Caches the token internally here until it expires.
|
|
722
|
-
*/
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1884
|
+
*/ var currentToken = null;
|
|
1885
|
+
return function() {
|
|
1886
|
+
return _async_to_generator(function() {
|
|
1887
|
+
var cachedToken, isExpired, e;
|
|
1888
|
+
return _ts_generator(this, function(_state) {
|
|
1889
|
+
switch(_state.label){
|
|
1890
|
+
case 0:
|
|
1891
|
+
if (!!currentToken) return [
|
|
1892
|
+
3,
|
|
1893
|
+
2
|
|
1894
|
+
];
|
|
1895
|
+
return [
|
|
1896
|
+
4,
|
|
1897
|
+
accessTokenCache === null || accessTokenCache === void 0 ? void 0 : accessTokenCache.loadCachedToken()
|
|
1898
|
+
];
|
|
1899
|
+
case 1:
|
|
1900
|
+
cachedToken = _state.sent();
|
|
1901
|
+
if (cachedToken) {
|
|
1902
|
+
currentToken = cachedToken;
|
|
1903
|
+
}
|
|
1904
|
+
_state.label = 2;
|
|
1905
|
+
case 2:
|
|
1906
|
+
// check expiration
|
|
1907
|
+
if (currentToken != null) {
|
|
1908
|
+
isExpired = new Date().getTime() + tokenExpirationBuffer >= currentToken.expiresAt.getTime();
|
|
1909
|
+
if (isExpired) {
|
|
1910
|
+
currentToken = null;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
if (!!currentToken) return [
|
|
1914
|
+
3,
|
|
1915
|
+
10
|
|
1916
|
+
];
|
|
1917
|
+
_state.label = 3;
|
|
1918
|
+
case 3:
|
|
1919
|
+
_state.trys.push([
|
|
1920
|
+
3,
|
|
1921
|
+
5,
|
|
1922
|
+
,
|
|
1923
|
+
6
|
|
1924
|
+
]);
|
|
1925
|
+
return [
|
|
1926
|
+
4,
|
|
1927
|
+
tokenRefresher()
|
|
1928
|
+
];
|
|
1929
|
+
case 4:
|
|
1930
|
+
currentToken = _state.sent();
|
|
1931
|
+
return [
|
|
1932
|
+
3,
|
|
1933
|
+
6
|
|
1934
|
+
];
|
|
1935
|
+
case 5:
|
|
1936
|
+
e = _state.sent();
|
|
1937
|
+
console.error("zoomOAuthZoomAccessTokenFactory(): Failed retrieving new token from tokenRefresher: ", e);
|
|
1938
|
+
throw new ZoomOAuthAuthFailureError('Token Refresh Failed');
|
|
1939
|
+
case 6:
|
|
1940
|
+
if (!currentToken) return [
|
|
1941
|
+
3,
|
|
1942
|
+
10
|
|
1943
|
+
];
|
|
1944
|
+
_state.label = 7;
|
|
1945
|
+
case 7:
|
|
1946
|
+
_state.trys.push([
|
|
1947
|
+
7,
|
|
1948
|
+
9,
|
|
1949
|
+
,
|
|
1950
|
+
10
|
|
1951
|
+
]);
|
|
1952
|
+
return [
|
|
1953
|
+
4,
|
|
1954
|
+
accessTokenCache === null || accessTokenCache === void 0 ? void 0 : accessTokenCache.updateCachedToken(currentToken)
|
|
1955
|
+
];
|
|
1956
|
+
case 8:
|
|
1957
|
+
_state.sent();
|
|
1958
|
+
return [
|
|
1959
|
+
3,
|
|
1960
|
+
10
|
|
1961
|
+
];
|
|
1962
|
+
case 9:
|
|
1963
|
+
_state.sent();
|
|
1964
|
+
return [
|
|
1965
|
+
3,
|
|
1966
|
+
10
|
|
1967
|
+
];
|
|
1968
|
+
case 10:
|
|
1969
|
+
return [
|
|
1970
|
+
2,
|
|
1971
|
+
currentToken
|
|
1972
|
+
];
|
|
754
1973
|
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return currentToken;
|
|
1974
|
+
});
|
|
1975
|
+
})();
|
|
758
1976
|
};
|
|
759
1977
|
}
|
|
760
1978
|
|