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