@forward-software/react-auth 1.0.2 → 1.1.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/dist/react-auth.cjs.development.js +346 -824
- package/dist/react-auth.cjs.development.js.map +1 -1
- package/dist/react-auth.cjs.production.min.js +1 -1
- package/dist/react-auth.cjs.production.min.js.map +1 -1
- package/dist/react-auth.esm.js +346 -824
- package/dist/react-auth.esm.js.map +1 -1
- package/dist/types/deferred.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +12 -15
- package/src/types/deferred.ts +18 -0
- package/src/types/index.ts +49 -29
|
@@ -8,348 +8,115 @@ var React = require('react');
|
|
|
8
8
|
var React__default = _interopDefault(React);
|
|
9
9
|
var shim = require('use-sync-external-store/shim');
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var value = info.value;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
reject(error);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (info.done) {
|
|
21
|
-
resolve(value);
|
|
22
|
-
} else {
|
|
23
|
-
Promise.resolve(value).then(_next, _throw);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _asyncToGenerator(fn) {
|
|
28
|
-
return function () {
|
|
29
|
-
var self = this,
|
|
30
|
-
args = arguments;
|
|
31
|
-
return new Promise(function (resolve, reject) {
|
|
32
|
-
var gen = fn.apply(self, args);
|
|
33
|
-
|
|
34
|
-
function _next(value) {
|
|
35
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _throw(err) {
|
|
39
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_next(undefined);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function _defineProperties(target, props) {
|
|
48
|
-
for (var i = 0; i < props.length; i++) {
|
|
49
|
-
var descriptor = props[i];
|
|
50
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
-
descriptor.configurable = true;
|
|
52
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
58
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
59
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
60
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
61
|
-
writable: false
|
|
62
|
-
});
|
|
63
|
-
return Constructor;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _extends() {
|
|
67
|
-
_extends = Object.assign || function (target) {
|
|
68
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
69
|
-
var source = arguments[i];
|
|
70
|
-
|
|
71
|
-
for (var key in source) {
|
|
72
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
73
|
-
target[key] = source[key];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return target;
|
|
11
|
+
function _regeneratorRuntime() {
|
|
12
|
+
_regeneratorRuntime = function () {
|
|
13
|
+
return exports;
|
|
79
14
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
91
|
-
*
|
|
92
|
-
* This source code is licensed under the MIT license found in the
|
|
93
|
-
* LICENSE file in the root directory of this source tree.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
var runtime = (function (exports) {
|
|
97
|
-
|
|
98
|
-
var Op = Object.prototype;
|
|
99
|
-
var hasOwn = Op.hasOwnProperty;
|
|
100
|
-
var undefined$1; // More compressible than void 0.
|
|
101
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
102
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
103
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
104
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
105
|
-
|
|
15
|
+
var exports = {},
|
|
16
|
+
Op = Object.prototype,
|
|
17
|
+
hasOwn = Op.hasOwnProperty,
|
|
18
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
19
|
+
obj[key] = desc.value;
|
|
20
|
+
},
|
|
21
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
22
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
23
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
24
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
106
25
|
function define(obj, key, value) {
|
|
107
|
-
Object.defineProperty(obj, key, {
|
|
26
|
+
return Object.defineProperty(obj, key, {
|
|
108
27
|
value: value,
|
|
109
|
-
enumerable:
|
|
110
|
-
configurable:
|
|
111
|
-
writable:
|
|
112
|
-
});
|
|
113
|
-
return obj[key];
|
|
28
|
+
enumerable: !0,
|
|
29
|
+
configurable: !0,
|
|
30
|
+
writable: !0
|
|
31
|
+
}), obj[key];
|
|
114
32
|
}
|
|
115
33
|
try {
|
|
116
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
117
34
|
define({}, "");
|
|
118
35
|
} catch (err) {
|
|
119
|
-
define = function(obj, key, value) {
|
|
36
|
+
define = function (obj, key, value) {
|
|
120
37
|
return obj[key] = value;
|
|
121
38
|
};
|
|
122
39
|
}
|
|
123
|
-
|
|
124
40
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// .throw, and .return methods.
|
|
132
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
133
|
-
|
|
134
|
-
return generator;
|
|
41
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
42
|
+
generator = Object.create(protoGenerator.prototype),
|
|
43
|
+
context = new Context(tryLocsList || []);
|
|
44
|
+
return defineProperty(generator, "_invoke", {
|
|
45
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
46
|
+
}), generator;
|
|
135
47
|
}
|
|
136
|
-
exports.wrap = wrap;
|
|
137
|
-
|
|
138
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
139
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
140
|
-
// have been (and was previously) designed to take a closure to be
|
|
141
|
-
// invoked without arguments, but in all the cases we care about we
|
|
142
|
-
// already have an existing method we want to call, so there's no need
|
|
143
|
-
// to create a new function object. We can even get away with assuming
|
|
144
|
-
// the method takes exactly one argument, since that happens to be true
|
|
145
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
146
|
-
// only additional allocation required is the completion record, which
|
|
147
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
148
48
|
function tryCatch(fn, obj, arg) {
|
|
149
49
|
try {
|
|
150
|
-
return {
|
|
50
|
+
return {
|
|
51
|
+
type: "normal",
|
|
52
|
+
arg: fn.call(obj, arg)
|
|
53
|
+
};
|
|
151
54
|
} catch (err) {
|
|
152
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
type: "throw",
|
|
57
|
+
arg: err
|
|
58
|
+
};
|
|
153
59
|
}
|
|
154
60
|
}
|
|
155
|
-
|
|
156
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
157
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
158
|
-
var GenStateExecuting = "executing";
|
|
159
|
-
var GenStateCompleted = "completed";
|
|
160
|
-
|
|
161
|
-
// Returning this object from the innerFn has the same effect as
|
|
162
|
-
// breaking out of the dispatch switch statement.
|
|
61
|
+
exports.wrap = wrap;
|
|
163
62
|
var ContinueSentinel = {};
|
|
164
|
-
|
|
165
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
166
|
-
// .constructor.prototype properties for functions that return Generator
|
|
167
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
168
|
-
// minifier not to mangle the names of these two functions.
|
|
169
63
|
function Generator() {}
|
|
170
64
|
function GeneratorFunction() {}
|
|
171
65
|
function GeneratorFunctionPrototype() {}
|
|
172
|
-
|
|
173
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
174
|
-
// don't natively support it.
|
|
175
66
|
var IteratorPrototype = {};
|
|
176
67
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
177
68
|
return this;
|
|
178
69
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
NativeIteratorPrototype !== Op &&
|
|
184
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
185
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
186
|
-
// of the polyfill.
|
|
187
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
191
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
192
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
193
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
194
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
195
|
-
GeneratorFunction.displayName = define(
|
|
196
|
-
GeneratorFunctionPrototype,
|
|
197
|
-
toStringTagSymbol,
|
|
198
|
-
"GeneratorFunction"
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
202
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
70
|
+
var getProto = Object.getPrototypeOf,
|
|
71
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
72
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
73
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
203
74
|
function defineIteratorMethods(prototype) {
|
|
204
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
205
|
-
define(prototype, method, function(arg) {
|
|
75
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
76
|
+
define(prototype, method, function (arg) {
|
|
206
77
|
return this._invoke(method, arg);
|
|
207
78
|
});
|
|
208
79
|
});
|
|
209
80
|
}
|
|
210
|
-
|
|
211
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
212
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
213
|
-
return ctor
|
|
214
|
-
? ctor === GeneratorFunction ||
|
|
215
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
216
|
-
// do is to check its .name property.
|
|
217
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
218
|
-
: false;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
exports.mark = function(genFun) {
|
|
222
|
-
if (Object.setPrototypeOf) {
|
|
223
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
224
|
-
} else {
|
|
225
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
226
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
227
|
-
}
|
|
228
|
-
genFun.prototype = Object.create(Gp);
|
|
229
|
-
return genFun;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
// Within the body of any async function, `await x` is transformed to
|
|
233
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
234
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
235
|
-
// meant to be awaited.
|
|
236
|
-
exports.awrap = function(arg) {
|
|
237
|
-
return { __await: arg };
|
|
238
|
-
};
|
|
239
|
-
|
|
240
81
|
function AsyncIterator(generator, PromiseImpl) {
|
|
241
82
|
function invoke(method, arg, resolve, reject) {
|
|
242
83
|
var record = tryCatch(generator[method], generator, arg);
|
|
243
|
-
if (record.type
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}, function(err) {
|
|
254
|
-
invoke("throw", err, resolve, reject);
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
259
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
260
|
-
// the .value of the Promise<{value,done}> result for the
|
|
261
|
-
// current iteration.
|
|
262
|
-
result.value = unwrapped;
|
|
263
|
-
resolve(result);
|
|
264
|
-
}, function(error) {
|
|
265
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
266
|
-
// into the async generator function so it can be handled there.
|
|
84
|
+
if ("throw" !== record.type) {
|
|
85
|
+
var result = record.arg,
|
|
86
|
+
value = result.value;
|
|
87
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
88
|
+
invoke("next", value, resolve, reject);
|
|
89
|
+
}, function (err) {
|
|
90
|
+
invoke("throw", err, resolve, reject);
|
|
91
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
92
|
+
result.value = unwrapped, resolve(result);
|
|
93
|
+
}, function (error) {
|
|
267
94
|
return invoke("throw", error, resolve, reject);
|
|
268
95
|
});
|
|
269
96
|
}
|
|
97
|
+
reject(record.arg);
|
|
270
98
|
}
|
|
271
|
-
|
|
272
99
|
var previousPromise;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
100
|
+
defineProperty(this, "_invoke", {
|
|
101
|
+
value: function (method, arg) {
|
|
102
|
+
function callInvokeWithMethodAndArg() {
|
|
103
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
104
|
+
invoke(method, arg, resolve, reject);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
279
108
|
}
|
|
280
|
-
|
|
281
|
-
return previousPromise =
|
|
282
|
-
// If enqueue has been called before, then we want to wait until
|
|
283
|
-
// all previous Promises have been resolved before calling invoke,
|
|
284
|
-
// so that results are always delivered in the correct order. If
|
|
285
|
-
// enqueue has not been called before, then it is important to
|
|
286
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
287
|
-
// so that the async generator function has the opportunity to do
|
|
288
|
-
// any necessary setup in a predictable way. This predictability
|
|
289
|
-
// is why the Promise constructor synchronously invokes its
|
|
290
|
-
// executor callback, and why async functions synchronously
|
|
291
|
-
// execute code before the first await. Since we implement simple
|
|
292
|
-
// async functions in terms of async generators, it is especially
|
|
293
|
-
// important to get this right, even though it requires care.
|
|
294
|
-
previousPromise ? previousPromise.then(
|
|
295
|
-
callInvokeWithMethodAndArg,
|
|
296
|
-
// Avoid propagating failures to Promises returned by later
|
|
297
|
-
// invocations of the iterator.
|
|
298
|
-
callInvokeWithMethodAndArg
|
|
299
|
-
) : callInvokeWithMethodAndArg();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Define the unified helper method that is used to implement .next,
|
|
303
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
304
|
-
this._invoke = enqueue;
|
|
109
|
+
});
|
|
305
110
|
}
|
|
306
|
-
|
|
307
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
308
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
309
|
-
return this;
|
|
310
|
-
});
|
|
311
|
-
exports.AsyncIterator = AsyncIterator;
|
|
312
|
-
|
|
313
|
-
// Note that simple async functions are implemented on top of
|
|
314
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
315
|
-
// the final result produced by the iterator.
|
|
316
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
317
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
318
|
-
|
|
319
|
-
var iter = new AsyncIterator(
|
|
320
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
321
|
-
PromiseImpl
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
return exports.isGeneratorFunction(outerFn)
|
|
325
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
326
|
-
: iter.next().then(function(result) {
|
|
327
|
-
return result.done ? result.value : iter.next();
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
|
|
331
111
|
function makeInvokeMethod(innerFn, self, context) {
|
|
332
|
-
var state =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (state === GenStateCompleted) {
|
|
340
|
-
if (method === "throw") {
|
|
341
|
-
throw arg;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
345
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
112
|
+
var state = "suspendedStart";
|
|
113
|
+
return function (method, arg) {
|
|
114
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
115
|
+
if ("completed" === state) {
|
|
116
|
+
if ("throw" === method) throw arg;
|
|
346
117
|
return doneResult();
|
|
347
118
|
}
|
|
348
|
-
|
|
349
|
-
context.method = method;
|
|
350
|
-
context.arg = arg;
|
|
351
|
-
|
|
352
|
-
while (true) {
|
|
119
|
+
for (context.method = method, context.arg = arg;;) {
|
|
353
120
|
var delegate = context.delegate;
|
|
354
121
|
if (delegate) {
|
|
355
122
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
@@ -358,488 +125,271 @@ var runtime = (function (exports) {
|
|
|
358
125
|
return delegateResult;
|
|
359
126
|
}
|
|
360
127
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
// Setting context._sent for legacy support of Babel's
|
|
364
|
-
// function.sent implementation.
|
|
365
|
-
context.sent = context._sent = context.arg;
|
|
366
|
-
|
|
367
|
-
} else if (context.method === "throw") {
|
|
368
|
-
if (state === GenStateSuspendedStart) {
|
|
369
|
-
state = GenStateCompleted;
|
|
370
|
-
throw context.arg;
|
|
371
|
-
}
|
|
372
|
-
|
|
128
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
129
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
373
130
|
context.dispatchException(context.arg);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
context.abrupt("return", context.arg);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
state = GenStateExecuting;
|
|
380
|
-
|
|
131
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
132
|
+
state = "executing";
|
|
381
133
|
var record = tryCatch(innerFn, self, context);
|
|
382
|
-
if (record.type
|
|
383
|
-
|
|
384
|
-
// GenStateExecuting and loop back for another invocation.
|
|
385
|
-
state = context.done
|
|
386
|
-
? GenStateCompleted
|
|
387
|
-
: GenStateSuspendedYield;
|
|
388
|
-
|
|
389
|
-
if (record.arg === ContinueSentinel) {
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
|
|
134
|
+
if ("normal" === record.type) {
|
|
135
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
393
136
|
return {
|
|
394
137
|
value: record.arg,
|
|
395
138
|
done: context.done
|
|
396
139
|
};
|
|
397
|
-
|
|
398
|
-
} else if (record.type === "throw") {
|
|
399
|
-
state = GenStateCompleted;
|
|
400
|
-
// Dispatch the exception by looping back around to the
|
|
401
|
-
// context.dispatchException(context.arg) call above.
|
|
402
|
-
context.method = "throw";
|
|
403
|
-
context.arg = record.arg;
|
|
404
140
|
}
|
|
141
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
405
142
|
}
|
|
406
143
|
};
|
|
407
144
|
}
|
|
408
|
-
|
|
409
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
410
|
-
// result, either by returning a { value, done } result from the
|
|
411
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
412
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
413
145
|
function maybeInvokeDelegate(delegate, context) {
|
|
414
146
|
var method = delegate.iterator[context.method];
|
|
415
|
-
if (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (context.method === "throw") {
|
|
421
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
422
|
-
if (delegate.iterator["return"]) {
|
|
423
|
-
// If the delegate iterator has a return method, give it a
|
|
424
|
-
// chance to clean up.
|
|
425
|
-
context.method = "return";
|
|
426
|
-
context.arg = undefined$1;
|
|
427
|
-
maybeInvokeDelegate(delegate, context);
|
|
428
|
-
|
|
429
|
-
if (context.method === "throw") {
|
|
430
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
431
|
-
// "return" to "throw", let that override the TypeError below.
|
|
432
|
-
return ContinueSentinel;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
context.method = "throw";
|
|
437
|
-
context.arg = new TypeError(
|
|
438
|
-
"The iterator does not provide a 'throw' method");
|
|
147
|
+
if (undefined === method) {
|
|
148
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
149
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
150
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
439
151
|
}
|
|
440
|
-
|
|
441
152
|
return ContinueSentinel;
|
|
442
153
|
}
|
|
443
|
-
|
|
444
154
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
445
|
-
|
|
446
|
-
if (record.type === "throw") {
|
|
447
|
-
context.method = "throw";
|
|
448
|
-
context.arg = record.arg;
|
|
449
|
-
context.delegate = null;
|
|
450
|
-
return ContinueSentinel;
|
|
451
|
-
}
|
|
452
|
-
|
|
155
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
453
156
|
var info = record.arg;
|
|
454
|
-
|
|
455
|
-
if (! info) {
|
|
456
|
-
context.method = "throw";
|
|
457
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
458
|
-
context.delegate = null;
|
|
459
|
-
return ContinueSentinel;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
if (info.done) {
|
|
463
|
-
// Assign the result of the finished delegate to the temporary
|
|
464
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
465
|
-
context[delegate.resultName] = info.value;
|
|
466
|
-
|
|
467
|
-
// Resume execution at the desired location (see delegateYield).
|
|
468
|
-
context.next = delegate.nextLoc;
|
|
469
|
-
|
|
470
|
-
// If context.method was "throw" but the delegate handled the
|
|
471
|
-
// exception, let the outer generator proceed normally. If
|
|
472
|
-
// context.method was "next", forget context.arg since it has been
|
|
473
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
474
|
-
// "return", allow the original .return call to continue in the
|
|
475
|
-
// outer generator.
|
|
476
|
-
if (context.method !== "return") {
|
|
477
|
-
context.method = "next";
|
|
478
|
-
context.arg = undefined$1;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
} else {
|
|
482
|
-
// Re-yield the result returned by the delegate method.
|
|
483
|
-
return info;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
487
|
-
// the outer generator.
|
|
488
|
-
context.delegate = null;
|
|
489
|
-
return ContinueSentinel;
|
|
157
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
490
158
|
}
|
|
491
|
-
|
|
492
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
493
|
-
// unified ._invoke helper method.
|
|
494
|
-
defineIteratorMethods(Gp);
|
|
495
|
-
|
|
496
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
497
|
-
|
|
498
|
-
// A Generator should always return itself as the iterator object when the
|
|
499
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
500
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
501
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
502
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
503
|
-
define(Gp, iteratorSymbol, function() {
|
|
504
|
-
return this;
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
define(Gp, "toString", function() {
|
|
508
|
-
return "[object Generator]";
|
|
509
|
-
});
|
|
510
|
-
|
|
511
159
|
function pushTryEntry(locs) {
|
|
512
|
-
var entry = {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
if (2 in locs) {
|
|
519
|
-
entry.finallyLoc = locs[2];
|
|
520
|
-
entry.afterLoc = locs[3];
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
this.tryEntries.push(entry);
|
|
160
|
+
var entry = {
|
|
161
|
+
tryLoc: locs[0]
|
|
162
|
+
};
|
|
163
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
524
164
|
}
|
|
525
|
-
|
|
526
165
|
function resetTryEntry(entry) {
|
|
527
166
|
var record = entry.completion || {};
|
|
528
|
-
record.type = "normal";
|
|
529
|
-
delete record.arg;
|
|
530
|
-
entry.completion = record;
|
|
167
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
531
168
|
}
|
|
532
|
-
|
|
533
169
|
function Context(tryLocsList) {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
538
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
539
|
-
this.reset(true);
|
|
170
|
+
this.tryEntries = [{
|
|
171
|
+
tryLoc: "root"
|
|
172
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
540
173
|
}
|
|
541
|
-
|
|
542
|
-
exports.keys = function(object) {
|
|
543
|
-
var keys = [];
|
|
544
|
-
for (var key in object) {
|
|
545
|
-
keys.push(key);
|
|
546
|
-
}
|
|
547
|
-
keys.reverse();
|
|
548
|
-
|
|
549
|
-
// Rather than returning an object with a next method, we keep
|
|
550
|
-
// things simple and return the next function itself.
|
|
551
|
-
return function next() {
|
|
552
|
-
while (keys.length) {
|
|
553
|
-
var key = keys.pop();
|
|
554
|
-
if (key in object) {
|
|
555
|
-
next.value = key;
|
|
556
|
-
next.done = false;
|
|
557
|
-
return next;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// To avoid creating an additional object, we just hang the .value
|
|
562
|
-
// and .done properties off the next function object itself. This
|
|
563
|
-
// also ensures that the minifier will not anonymize the function.
|
|
564
|
-
next.done = true;
|
|
565
|
-
return next;
|
|
566
|
-
};
|
|
567
|
-
};
|
|
568
|
-
|
|
569
174
|
function values(iterable) {
|
|
570
175
|
if (iterable) {
|
|
571
176
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
572
|
-
if (iteratorMethod)
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (typeof iterable.next === "function") {
|
|
577
|
-
return iterable;
|
|
578
|
-
}
|
|
579
|
-
|
|
177
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
178
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
580
179
|
if (!isNaN(iterable.length)) {
|
|
581
|
-
var i = -1,
|
|
582
|
-
|
|
583
|
-
if (hasOwn.call(iterable, i))
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
return next;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
next.value = undefined$1;
|
|
591
|
-
next.done = true;
|
|
592
|
-
|
|
593
|
-
return next;
|
|
594
|
-
};
|
|
595
|
-
|
|
180
|
+
var i = -1,
|
|
181
|
+
next = function next() {
|
|
182
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
183
|
+
return next.value = undefined, next.done = !0, next;
|
|
184
|
+
};
|
|
596
185
|
return next.next = next;
|
|
597
186
|
}
|
|
598
187
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
188
|
+
return {
|
|
189
|
+
next: doneResult
|
|
190
|
+
};
|
|
602
191
|
}
|
|
603
|
-
exports.values = values;
|
|
604
|
-
|
|
605
192
|
function doneResult() {
|
|
606
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
value: undefined,
|
|
195
|
+
done: !0
|
|
196
|
+
};
|
|
607
197
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
198
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
199
|
+
value: GeneratorFunctionPrototype,
|
|
200
|
+
configurable: !0
|
|
201
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
202
|
+
value: GeneratorFunction,
|
|
203
|
+
configurable: !0
|
|
204
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
205
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
206
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
207
|
+
}, exports.mark = function (genFun) {
|
|
208
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
209
|
+
}, exports.awrap = function (arg) {
|
|
210
|
+
return {
|
|
211
|
+
__await: arg
|
|
212
|
+
};
|
|
213
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
214
|
+
return this;
|
|
215
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
216
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
217
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
218
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
219
|
+
return result.done ? result.value : iter.next();
|
|
220
|
+
});
|
|
221
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
222
|
+
return this;
|
|
223
|
+
}), define(Gp, "toString", function () {
|
|
224
|
+
return "[object Generator]";
|
|
225
|
+
}), exports.keys = function (val) {
|
|
226
|
+
var object = Object(val),
|
|
227
|
+
keys = [];
|
|
228
|
+
for (var key in object) keys.push(key);
|
|
229
|
+
return keys.reverse(), function next() {
|
|
230
|
+
for (; keys.length;) {
|
|
231
|
+
var key = keys.pop();
|
|
232
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
635
233
|
}
|
|
234
|
+
return next.done = !0, next;
|
|
235
|
+
};
|
|
236
|
+
}, exports.values = values, Context.prototype = {
|
|
237
|
+
constructor: Context,
|
|
238
|
+
reset: function (skipTempReset) {
|
|
239
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
636
240
|
},
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
var rootEntry = this.tryEntries[0];
|
|
642
|
-
var rootRecord = rootEntry.completion;
|
|
643
|
-
if (rootRecord.type === "throw") {
|
|
644
|
-
throw rootRecord.arg;
|
|
645
|
-
}
|
|
646
|
-
|
|
241
|
+
stop: function () {
|
|
242
|
+
this.done = !0;
|
|
243
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
244
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
647
245
|
return this.rval;
|
|
648
246
|
},
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
if (this.done) {
|
|
652
|
-
throw exception;
|
|
653
|
-
}
|
|
654
|
-
|
|
247
|
+
dispatchException: function (exception) {
|
|
248
|
+
if (this.done) throw exception;
|
|
655
249
|
var context = this;
|
|
656
250
|
function handle(loc, caught) {
|
|
657
|
-
record.type = "throw";
|
|
658
|
-
record.arg = exception;
|
|
659
|
-
context.next = loc;
|
|
660
|
-
|
|
661
|
-
if (caught) {
|
|
662
|
-
// If the dispatched exception was caught by a catch block,
|
|
663
|
-
// then let that catch block handle the exception normally.
|
|
664
|
-
context.method = "next";
|
|
665
|
-
context.arg = undefined$1;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return !! caught;
|
|
251
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
669
252
|
}
|
|
670
|
-
|
|
671
253
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
672
|
-
var entry = this.tryEntries[i]
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (entry.tryLoc === "root") {
|
|
676
|
-
// Exception thrown outside of any try block that could handle
|
|
677
|
-
// it, so set the completion value of the entire function to
|
|
678
|
-
// throw the exception.
|
|
679
|
-
return handle("end");
|
|
680
|
-
}
|
|
681
|
-
|
|
254
|
+
var entry = this.tryEntries[i],
|
|
255
|
+
record = entry.completion;
|
|
256
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
682
257
|
if (entry.tryLoc <= this.prev) {
|
|
683
|
-
var hasCatch = hasOwn.call(entry, "catchLoc")
|
|
684
|
-
|
|
685
|
-
|
|
258
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
259
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
686
260
|
if (hasCatch && hasFinally) {
|
|
687
|
-
if (this.prev < entry.catchLoc)
|
|
688
|
-
|
|
689
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
690
|
-
return handle(entry.finallyLoc);
|
|
691
|
-
}
|
|
692
|
-
|
|
261
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
262
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
693
263
|
} else if (hasCatch) {
|
|
694
|
-
if (this.prev < entry.catchLoc)
|
|
695
|
-
return handle(entry.catchLoc, true);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
} else if (hasFinally) {
|
|
699
|
-
if (this.prev < entry.finallyLoc) {
|
|
700
|
-
return handle(entry.finallyLoc);
|
|
701
|
-
}
|
|
702
|
-
|
|
264
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
703
265
|
} else {
|
|
704
|
-
throw new Error("try statement without catch or finally");
|
|
266
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
267
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
705
268
|
}
|
|
706
269
|
}
|
|
707
270
|
}
|
|
708
271
|
},
|
|
709
|
-
|
|
710
|
-
abrupt: function(type, arg) {
|
|
272
|
+
abrupt: function (type, arg) {
|
|
711
273
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
712
274
|
var entry = this.tryEntries[i];
|
|
713
|
-
if (entry.tryLoc <= this.prev &&
|
|
714
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
715
|
-
this.prev < entry.finallyLoc) {
|
|
275
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
716
276
|
var finallyEntry = entry;
|
|
717
277
|
break;
|
|
718
278
|
}
|
|
719
279
|
}
|
|
720
|
-
|
|
721
|
-
if (finallyEntry &&
|
|
722
|
-
(type === "break" ||
|
|
723
|
-
type === "continue") &&
|
|
724
|
-
finallyEntry.tryLoc <= arg &&
|
|
725
|
-
arg <= finallyEntry.finallyLoc) {
|
|
726
|
-
// Ignore the finally entry if control is not jumping to a
|
|
727
|
-
// location outside the try/catch block.
|
|
728
|
-
finallyEntry = null;
|
|
729
|
-
}
|
|
730
|
-
|
|
280
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
731
281
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
732
|
-
record.type = type;
|
|
733
|
-
record.arg = arg;
|
|
734
|
-
|
|
735
|
-
if (finallyEntry) {
|
|
736
|
-
this.method = "next";
|
|
737
|
-
this.next = finallyEntry.finallyLoc;
|
|
738
|
-
return ContinueSentinel;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return this.complete(record);
|
|
282
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
742
283
|
},
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
throw record.arg;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
if (record.type === "break" ||
|
|
750
|
-
record.type === "continue") {
|
|
751
|
-
this.next = record.arg;
|
|
752
|
-
} else if (record.type === "return") {
|
|
753
|
-
this.rval = this.arg = record.arg;
|
|
754
|
-
this.method = "return";
|
|
755
|
-
this.next = "end";
|
|
756
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
757
|
-
this.next = afterLoc;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
return ContinueSentinel;
|
|
284
|
+
complete: function (record, afterLoc) {
|
|
285
|
+
if ("throw" === record.type) throw record.arg;
|
|
286
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
761
287
|
},
|
|
762
|
-
|
|
763
|
-
finish: function(finallyLoc) {
|
|
288
|
+
finish: function (finallyLoc) {
|
|
764
289
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
765
290
|
var entry = this.tryEntries[i];
|
|
766
|
-
if (entry.finallyLoc === finallyLoc)
|
|
767
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
768
|
-
resetTryEntry(entry);
|
|
769
|
-
return ContinueSentinel;
|
|
770
|
-
}
|
|
291
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
771
292
|
}
|
|
772
293
|
},
|
|
773
|
-
|
|
774
|
-
"catch": function(tryLoc) {
|
|
294
|
+
catch: function (tryLoc) {
|
|
775
295
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
776
296
|
var entry = this.tryEntries[i];
|
|
777
297
|
if (entry.tryLoc === tryLoc) {
|
|
778
298
|
var record = entry.completion;
|
|
779
|
-
if (record.type
|
|
299
|
+
if ("throw" === record.type) {
|
|
780
300
|
var thrown = record.arg;
|
|
781
301
|
resetTryEntry(entry);
|
|
782
302
|
}
|
|
783
303
|
return thrown;
|
|
784
304
|
}
|
|
785
305
|
}
|
|
786
|
-
|
|
787
|
-
// The context.catch method must only be called with a location
|
|
788
|
-
// argument that corresponds to a known catch block.
|
|
789
306
|
throw new Error("illegal catch attempt");
|
|
790
307
|
},
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
this.delegate = {
|
|
308
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
309
|
+
return this.delegate = {
|
|
794
310
|
iterator: values(iterable),
|
|
795
311
|
resultName: resultName,
|
|
796
312
|
nextLoc: nextLoc
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
313
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
314
|
+
}
|
|
315
|
+
}, exports;
|
|
316
|
+
}
|
|
317
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
318
|
+
try {
|
|
319
|
+
var info = gen[key](arg);
|
|
320
|
+
var value = info.value;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
reject(error);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (info.done) {
|
|
326
|
+
resolve(value);
|
|
327
|
+
} else {
|
|
328
|
+
Promise.resolve(value).then(_next, _throw);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function _asyncToGenerator(fn) {
|
|
332
|
+
return function () {
|
|
333
|
+
var self = this,
|
|
334
|
+
args = arguments;
|
|
335
|
+
return new Promise(function (resolve, reject) {
|
|
336
|
+
var gen = fn.apply(self, args);
|
|
337
|
+
function _next(value) {
|
|
338
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
339
|
+
}
|
|
340
|
+
function _throw(err) {
|
|
341
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
342
|
+
}
|
|
343
|
+
_next(undefined);
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function _defineProperties(target, props) {
|
|
348
|
+
for (var i = 0; i < props.length; i++) {
|
|
349
|
+
var descriptor = props[i];
|
|
350
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
351
|
+
descriptor.configurable = true;
|
|
352
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
353
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
357
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
358
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
359
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
360
|
+
writable: false
|
|
361
|
+
});
|
|
362
|
+
return Constructor;
|
|
363
|
+
}
|
|
364
|
+
function _extends() {
|
|
365
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
366
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
367
|
+
var source = arguments[i];
|
|
368
|
+
for (var key in source) {
|
|
369
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
370
|
+
target[key] = source[key];
|
|
371
|
+
}
|
|
803
372
|
}
|
|
804
|
-
|
|
805
|
-
return ContinueSentinel;
|
|
806
373
|
}
|
|
374
|
+
return target;
|
|
807
375
|
};
|
|
376
|
+
return _extends.apply(this, arguments);
|
|
377
|
+
}
|
|
808
378
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
817
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
818
|
-
// object. Either way, the resulting object will be used to initialize
|
|
819
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
820
|
-
module.exports
|
|
821
|
-
));
|
|
822
|
-
|
|
823
|
-
try {
|
|
824
|
-
regeneratorRuntime = runtime;
|
|
825
|
-
} catch (accidentalStrictMode) {
|
|
826
|
-
// This module should not be running in strict mode, so the above
|
|
827
|
-
// assignment should always work unless something is misconfigured. Just
|
|
828
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
829
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
830
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
831
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
832
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
833
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
834
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
835
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
836
|
-
if (typeof globalThis === "object") {
|
|
837
|
-
globalThis.regeneratorRuntime = runtime;
|
|
838
|
-
} else {
|
|
839
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
379
|
+
var Deferred = /*#__PURE__*/function () {
|
|
380
|
+
function Deferred() {
|
|
381
|
+
var _this = this;
|
|
382
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
383
|
+
_this.reject = reject;
|
|
384
|
+
_this.resolve = resolve;
|
|
385
|
+
});
|
|
840
386
|
}
|
|
841
|
-
|
|
842
|
-
|
|
387
|
+
var _proto = Deferred.prototype;
|
|
388
|
+
_proto.getPromise = function getPromise() {
|
|
389
|
+
return this.promise;
|
|
390
|
+
};
|
|
391
|
+
return Deferred;
|
|
392
|
+
}();
|
|
843
393
|
|
|
844
394
|
// TODO: Improve -> `listeners` are unbounded -- don't use this in practice!
|
|
845
395
|
function createEventEmitter() {
|
|
@@ -866,51 +416,46 @@ function createEventEmitter() {
|
|
|
866
416
|
var BaseAuthClient = /*#__PURE__*/function () {
|
|
867
417
|
function BaseAuthClient() {
|
|
868
418
|
var _this = this;
|
|
869
|
-
|
|
870
419
|
this._state = {
|
|
871
420
|
isAuthenticated: false,
|
|
872
421
|
isInitialized: false,
|
|
873
422
|
tokens: {}
|
|
874
423
|
};
|
|
424
|
+
// refresh queue - used to avoid concurrency issue during Token refresh
|
|
425
|
+
this.refreshQ = [];
|
|
875
426
|
this.eventEmitter = createEventEmitter();
|
|
876
|
-
this.subscribers = new Set();
|
|
877
|
-
|
|
427
|
+
this.subscribers = new Set();
|
|
428
|
+
// Should be declared like this to avoid binding issues when used by useSyncExternalStore
|
|
878
429
|
this.subscribe = function (subscription) {
|
|
879
430
|
_this.subscribers.add(subscription);
|
|
880
|
-
|
|
881
431
|
return function () {
|
|
882
432
|
return _this.subscribers["delete"](subscription);
|
|
883
433
|
};
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
|
|
434
|
+
};
|
|
435
|
+
// Should be declared like this to avoid binding issues when used by useSyncExternalStore
|
|
887
436
|
this.getSnapshot = function () {
|
|
888
437
|
return _this._state;
|
|
889
438
|
};
|
|
890
|
-
}
|
|
439
|
+
}
|
|
440
|
+
//
|
|
891
441
|
// Getters
|
|
892
442
|
//
|
|
893
|
-
|
|
894
|
-
|
|
895
443
|
var _proto = BaseAuthClient.prototype;
|
|
896
|
-
|
|
897
444
|
//
|
|
898
445
|
// Public methods
|
|
899
446
|
//
|
|
900
447
|
_proto.init =
|
|
901
448
|
/*#__PURE__*/
|
|
902
449
|
function () {
|
|
903
|
-
var _init = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
450
|
+
var _init = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
904
451
|
var _this$onPostInit;
|
|
905
|
-
|
|
906
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
452
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
907
453
|
while (1) {
|
|
908
454
|
switch (_context.prev = _context.next) {
|
|
909
455
|
case 0:
|
|
910
456
|
_context.prev = 0;
|
|
911
457
|
_context.next = 3;
|
|
912
458
|
return this.onInit();
|
|
913
|
-
|
|
914
459
|
case 3:
|
|
915
460
|
this.setState({
|
|
916
461
|
isInitialized: true
|
|
@@ -918,7 +463,6 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
918
463
|
this.emit('initSuccess', undefined);
|
|
919
464
|
_context.next = 11;
|
|
920
465
|
break;
|
|
921
|
-
|
|
922
466
|
case 7:
|
|
923
467
|
_context.prev = 7;
|
|
924
468
|
_context.t0 = _context["catch"](0);
|
|
@@ -926,14 +470,11 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
926
470
|
isInitialized: false
|
|
927
471
|
});
|
|
928
472
|
this.emit('initFailed', _context.t0);
|
|
929
|
-
|
|
930
473
|
case 11:
|
|
931
474
|
_context.next = 13;
|
|
932
475
|
return (_this$onPostInit = this.onPostInit) == null ? void 0 : _this$onPostInit.call(this);
|
|
933
|
-
|
|
934
476
|
case 13:
|
|
935
477
|
return _context.abrupt("return", this.isInitialized);
|
|
936
|
-
|
|
937
478
|
case 14:
|
|
938
479
|
case "end":
|
|
939
480
|
return _context.stop();
|
|
@@ -941,33 +482,27 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
941
482
|
}
|
|
942
483
|
}, _callee, this, [[0, 7]]);
|
|
943
484
|
}));
|
|
944
|
-
|
|
945
485
|
function init() {
|
|
946
486
|
return _init.apply(this, arguments);
|
|
947
487
|
}
|
|
948
|
-
|
|
949
488
|
return init;
|
|
950
489
|
}();
|
|
951
|
-
|
|
952
490
|
_proto.login = /*#__PURE__*/function () {
|
|
953
|
-
var _login = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
491
|
+
var _login = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(credentials) {
|
|
954
492
|
var _this$onPreLogin, _this$onPostLogin;
|
|
955
|
-
|
|
956
493
|
var isSuccess, tokens;
|
|
957
|
-
return
|
|
494
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
958
495
|
while (1) {
|
|
959
496
|
switch (_context2.prev = _context2.next) {
|
|
960
497
|
case 0:
|
|
961
498
|
this.emit('loginStarted', undefined);
|
|
962
499
|
_context2.next = 3;
|
|
963
500
|
return (_this$onPreLogin = this.onPreLogin) == null ? void 0 : _this$onPreLogin.call(this);
|
|
964
|
-
|
|
965
501
|
case 3:
|
|
966
502
|
isSuccess = false;
|
|
967
503
|
_context2.prev = 4;
|
|
968
504
|
_context2.next = 7;
|
|
969
505
|
return this.onLogin(credentials);
|
|
970
|
-
|
|
971
506
|
case 7:
|
|
972
507
|
tokens = _context2.sent;
|
|
973
508
|
this.setState({
|
|
@@ -978,7 +513,6 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
978
513
|
isSuccess = true;
|
|
979
514
|
_context2.next = 18;
|
|
980
515
|
break;
|
|
981
|
-
|
|
982
516
|
case 13:
|
|
983
517
|
_context2.prev = 13;
|
|
984
518
|
_context2.t0 = _context2["catch"](4);
|
|
@@ -988,14 +522,11 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
988
522
|
});
|
|
989
523
|
this.emit('loginFailed', _context2.t0);
|
|
990
524
|
isSuccess = false;
|
|
991
|
-
|
|
992
525
|
case 18:
|
|
993
526
|
_context2.next = 20;
|
|
994
527
|
return (_this$onPostLogin = this.onPostLogin) == null ? void 0 : _this$onPostLogin.call(this, isSuccess);
|
|
995
|
-
|
|
996
528
|
case 20:
|
|
997
529
|
return _context2.abrupt("return", this.isAuthenticated);
|
|
998
|
-
|
|
999
530
|
case 21:
|
|
1000
531
|
case "end":
|
|
1001
532
|
return _context2.stop();
|
|
@@ -1003,95 +534,49 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
1003
534
|
}
|
|
1004
535
|
}, _callee2, this, [[4, 13]]);
|
|
1005
536
|
}));
|
|
1006
|
-
|
|
1007
537
|
function login(_x) {
|
|
1008
538
|
return _login.apply(this, arguments);
|
|
1009
539
|
}
|
|
1010
|
-
|
|
1011
540
|
return login;
|
|
1012
541
|
}();
|
|
1013
|
-
|
|
1014
542
|
_proto.refresh = /*#__PURE__*/function () {
|
|
1015
|
-
var _refresh = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
1016
|
-
var
|
|
1017
|
-
|
|
1018
|
-
var isSuccess, tokens;
|
|
1019
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
543
|
+
var _refresh = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(minValidity) {
|
|
544
|
+
var deferred;
|
|
545
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1020
546
|
while (1) {
|
|
1021
547
|
switch (_context3.prev = _context3.next) {
|
|
1022
548
|
case 0:
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
return (
|
|
1026
|
-
|
|
549
|
+
deferred = new Deferred();
|
|
550
|
+
this.runRefresh(deferred, minValidity);
|
|
551
|
+
return _context3.abrupt("return", deferred.getPromise());
|
|
1027
552
|
case 3:
|
|
1028
|
-
isSuccess = false;
|
|
1029
|
-
_context3.prev = 4;
|
|
1030
|
-
_context3.next = 7;
|
|
1031
|
-
return this.onRefresh(minValidity);
|
|
1032
|
-
|
|
1033
|
-
case 7:
|
|
1034
|
-
tokens = _context3.sent;
|
|
1035
|
-
this.setState({
|
|
1036
|
-
isAuthenticated: true,
|
|
1037
|
-
tokens: tokens
|
|
1038
|
-
});
|
|
1039
|
-
this.emit('refreshSuccess', undefined);
|
|
1040
|
-
isSuccess = true;
|
|
1041
|
-
_context3.next = 18;
|
|
1042
|
-
break;
|
|
1043
|
-
|
|
1044
|
-
case 13:
|
|
1045
|
-
_context3.prev = 13;
|
|
1046
|
-
_context3.t0 = _context3["catch"](4);
|
|
1047
|
-
this.setState({
|
|
1048
|
-
isAuthenticated: false,
|
|
1049
|
-
tokens: {}
|
|
1050
|
-
});
|
|
1051
|
-
this.emit('refreshFailed', _context3.t0);
|
|
1052
|
-
isSuccess = false;
|
|
1053
|
-
|
|
1054
|
-
case 18:
|
|
1055
|
-
_context3.next = 20;
|
|
1056
|
-
return (_this$onPostRefresh = this.onPostRefresh) == null ? void 0 : _this$onPostRefresh.call(this, isSuccess);
|
|
1057
|
-
|
|
1058
|
-
case 20:
|
|
1059
|
-
return _context3.abrupt("return", this.isAuthenticated);
|
|
1060
|
-
|
|
1061
|
-
case 21:
|
|
1062
553
|
case "end":
|
|
1063
554
|
return _context3.stop();
|
|
1064
555
|
}
|
|
1065
556
|
}
|
|
1066
|
-
}, _callee3, this
|
|
557
|
+
}, _callee3, this);
|
|
1067
558
|
}));
|
|
1068
|
-
|
|
1069
559
|
function refresh(_x2) {
|
|
1070
560
|
return _refresh.apply(this, arguments);
|
|
1071
561
|
}
|
|
1072
|
-
|
|
1073
562
|
return refresh;
|
|
1074
563
|
}();
|
|
1075
|
-
|
|
1076
564
|
_proto.logout = /*#__PURE__*/function () {
|
|
1077
|
-
var _logout = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
565
|
+
var _logout = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1078
566
|
var _this$onPreLogout, _this$onPostLogout;
|
|
1079
|
-
|
|
1080
567
|
var isSuccess;
|
|
1081
|
-
return
|
|
568
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1082
569
|
while (1) {
|
|
1083
570
|
switch (_context4.prev = _context4.next) {
|
|
1084
571
|
case 0:
|
|
1085
572
|
this.emit('logoutStarted', undefined);
|
|
1086
573
|
_context4.next = 3;
|
|
1087
574
|
return (_this$onPreLogout = this.onPreLogout) == null ? void 0 : _this$onPreLogout.call(this);
|
|
1088
|
-
|
|
1089
575
|
case 3:
|
|
1090
576
|
isSuccess = false;
|
|
1091
577
|
_context4.prev = 4;
|
|
1092
578
|
_context4.next = 7;
|
|
1093
579
|
return this.onLogout();
|
|
1094
|
-
|
|
1095
580
|
case 7:
|
|
1096
581
|
this.setState({
|
|
1097
582
|
isAuthenticated: false,
|
|
@@ -1101,17 +586,14 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
1101
586
|
isSuccess = true;
|
|
1102
587
|
_context4.next = 16;
|
|
1103
588
|
break;
|
|
1104
|
-
|
|
1105
589
|
case 12:
|
|
1106
590
|
_context4.prev = 12;
|
|
1107
591
|
_context4.t0 = _context4["catch"](4);
|
|
1108
592
|
this.emit('logoutFailed', _context4.t0);
|
|
1109
593
|
isSuccess = false;
|
|
1110
|
-
|
|
1111
594
|
case 16:
|
|
1112
595
|
_context4.next = 18;
|
|
1113
596
|
return (_this$onPostLogout = this.onPostLogout) == null ? void 0 : _this$onPostLogout.call(this, isSuccess);
|
|
1114
|
-
|
|
1115
597
|
case 18:
|
|
1116
598
|
case "end":
|
|
1117
599
|
return _context4.stop();
|
|
@@ -1119,37 +601,94 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
1119
601
|
}
|
|
1120
602
|
}, _callee4, this, [[4, 12]]);
|
|
1121
603
|
}));
|
|
1122
|
-
|
|
1123
604
|
function logout() {
|
|
1124
605
|
return _logout.apply(this, arguments);
|
|
1125
606
|
}
|
|
1126
|
-
|
|
1127
607
|
return logout;
|
|
1128
608
|
}();
|
|
1129
|
-
|
|
1130
609
|
_proto.on = function on(eventName, listener) {
|
|
1131
610
|
this.eventEmitter.on(eventName, listener);
|
|
1132
611
|
};
|
|
1133
|
-
|
|
1134
612
|
_proto.off = function off(eventName, listener) {
|
|
1135
613
|
this.eventEmitter.off(eventName, listener);
|
|
1136
|
-
}
|
|
614
|
+
}
|
|
615
|
+
//
|
|
1137
616
|
// Protected methods
|
|
1138
617
|
//
|
|
1139
618
|
;
|
|
1140
|
-
|
|
1141
619
|
_proto.setState = function setState(stateUpdate) {
|
|
1142
620
|
this._state = _extends({}, this._state, stateUpdate);
|
|
1143
621
|
this.notifySubscribers();
|
|
1144
|
-
}
|
|
622
|
+
}
|
|
623
|
+
//
|
|
1145
624
|
// Private methods
|
|
1146
625
|
//
|
|
1147
626
|
;
|
|
1148
|
-
|
|
627
|
+
_proto.runRefresh =
|
|
628
|
+
/*#__PURE__*/
|
|
629
|
+
function () {
|
|
630
|
+
var _runRefresh = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(deferred, minValidity) {
|
|
631
|
+
var _this$onPreRefresh, _this$onPostRefresh;
|
|
632
|
+
var isAuthenticated, tokens, p;
|
|
633
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
634
|
+
while (1) {
|
|
635
|
+
switch (_context5.prev = _context5.next) {
|
|
636
|
+
case 0:
|
|
637
|
+
// Add deferred Promise to refresh queue
|
|
638
|
+
this.refreshQ.push(deferred);
|
|
639
|
+
// If refresh queue already has promises enqueued do not attempt a new refresh - one is already in progress
|
|
640
|
+
if (!(this.refreshQ.length !== 1)) {
|
|
641
|
+
_context5.next = 3;
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
return _context5.abrupt("return");
|
|
645
|
+
case 3:
|
|
646
|
+
this.emit('refreshStarted', undefined);
|
|
647
|
+
_context5.next = 6;
|
|
648
|
+
return (_this$onPreRefresh = this.onPreRefresh) == null ? void 0 : _this$onPreRefresh.call(this);
|
|
649
|
+
case 6:
|
|
650
|
+
isAuthenticated = false;
|
|
651
|
+
tokens = {};
|
|
652
|
+
_context5.prev = 8;
|
|
653
|
+
_context5.next = 11;
|
|
654
|
+
return this.onRefresh(minValidity);
|
|
655
|
+
case 11:
|
|
656
|
+
tokens = _context5.sent;
|
|
657
|
+
isAuthenticated = true;
|
|
658
|
+
this.emit('refreshSuccess', undefined);
|
|
659
|
+
_context5.next = 20;
|
|
660
|
+
break;
|
|
661
|
+
case 16:
|
|
662
|
+
_context5.prev = 16;
|
|
663
|
+
_context5.t0 = _context5["catch"](8);
|
|
664
|
+
isAuthenticated = false;
|
|
665
|
+
this.emit('refreshFailed', _context5.t0);
|
|
666
|
+
case 20:
|
|
667
|
+
this.setState({
|
|
668
|
+
isAuthenticated: isAuthenticated,
|
|
669
|
+
tokens: tokens
|
|
670
|
+
});
|
|
671
|
+
_context5.next = 23;
|
|
672
|
+
return (_this$onPostRefresh = this.onPostRefresh) == null ? void 0 : _this$onPostRefresh.call(this, isAuthenticated);
|
|
673
|
+
case 23:
|
|
674
|
+
for (p = this.refreshQ.pop(); p != null; p = this.refreshQ.pop()) {
|
|
675
|
+
p.resolve(isAuthenticated);
|
|
676
|
+
}
|
|
677
|
+
case 24:
|
|
678
|
+
case "end":
|
|
679
|
+
return _context5.stop();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}, _callee5, this, [[8, 16]]);
|
|
683
|
+
}));
|
|
684
|
+
function runRefresh(_x3, _x4) {
|
|
685
|
+
return _runRefresh.apply(this, arguments);
|
|
686
|
+
}
|
|
687
|
+
return runRefresh;
|
|
688
|
+
}();
|
|
1149
689
|
_proto.emit = function emit(eventName, error) {
|
|
1150
690
|
this.eventEmitter.emit(eventName, error);
|
|
1151
691
|
};
|
|
1152
|
-
|
|
1153
692
|
_proto.notifySubscribers = function notifySubscribers() {
|
|
1154
693
|
this.subscribers.forEach(function (s) {
|
|
1155
694
|
try {
|
|
@@ -1157,7 +696,6 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
1157
696
|
} catch (_unused) {}
|
|
1158
697
|
});
|
|
1159
698
|
};
|
|
1160
|
-
|
|
1161
699
|
_createClass(BaseAuthClient, [{
|
|
1162
700
|
key: "isInitialized",
|
|
1163
701
|
get: function get() {
|
|
@@ -1174,47 +712,39 @@ var BaseAuthClient = /*#__PURE__*/function () {
|
|
|
1174
712
|
return this._state.tokens;
|
|
1175
713
|
}
|
|
1176
714
|
}]);
|
|
1177
|
-
|
|
1178
715
|
return BaseAuthClient;
|
|
1179
716
|
}();
|
|
1180
717
|
|
|
1181
718
|
function createAuth(authClient) {
|
|
1182
719
|
// Create a React context containing a BaseAuthClient instance.
|
|
1183
|
-
var authContext = React.createContext(null);
|
|
1184
|
-
|
|
720
|
+
var authContext = React.createContext(null);
|
|
721
|
+
// Create the React Context Provider for the BaseAuthClient instance.
|
|
1185
722
|
var AuthProvider = function AuthProvider(_ref) {
|
|
1186
723
|
var children = _ref.children,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
724
|
+
ErrorComponent = _ref.ErrorComponent,
|
|
725
|
+
LoadingComponent = _ref.LoadingComponent;
|
|
1190
726
|
var _useState = React.useState(false),
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
727
|
+
isInitFailed = _useState[0],
|
|
728
|
+
setInitFailed = _useState[1];
|
|
1194
729
|
var _useSyncExternalStore = shim.useSyncExternalStore(authClient.subscribe, authClient.getSnapshot),
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
730
|
+
isAuthenticated = _useSyncExternalStore.isAuthenticated,
|
|
731
|
+
isInitialized = _useSyncExternalStore.isInitialized;
|
|
1198
732
|
React.useEffect(function () {
|
|
1199
733
|
function initAuthClient() {
|
|
1200
734
|
return _initAuthClient.apply(this, arguments);
|
|
1201
735
|
} // Init AuthClient
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
736
|
function _initAuthClient() {
|
|
1205
|
-
_initAuthClient = _asyncToGenerator( /*#__PURE__*/
|
|
737
|
+
_initAuthClient = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1206
738
|
var initSuccess;
|
|
1207
|
-
return
|
|
739
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1208
740
|
while (1) {
|
|
1209
741
|
switch (_context.prev = _context.next) {
|
|
1210
742
|
case 0:
|
|
1211
743
|
_context.next = 2;
|
|
1212
744
|
return authClient.init();
|
|
1213
|
-
|
|
1214
745
|
case 2:
|
|
1215
746
|
initSuccess = _context.sent;
|
|
1216
747
|
setInitFailed(!initSuccess);
|
|
1217
|
-
|
|
1218
748
|
case 4:
|
|
1219
749
|
case "end":
|
|
1220
750
|
return _context.stop();
|
|
@@ -1224,18 +754,14 @@ function createAuth(authClient) {
|
|
|
1224
754
|
}));
|
|
1225
755
|
return _initAuthClient.apply(this, arguments);
|
|
1226
756
|
}
|
|
1227
|
-
|
|
1228
757
|
initAuthClient();
|
|
1229
758
|
}, []);
|
|
1230
|
-
|
|
1231
759
|
if (!!ErrorComponent && isInitFailed) {
|
|
1232
760
|
return ErrorComponent;
|
|
1233
761
|
}
|
|
1234
|
-
|
|
1235
762
|
if (!!LoadingComponent && !isInitialized) {
|
|
1236
763
|
return LoadingComponent;
|
|
1237
764
|
}
|
|
1238
|
-
|
|
1239
765
|
return React__default.createElement(authContext.Provider, {
|
|
1240
766
|
value: {
|
|
1241
767
|
authClient: authClient,
|
|
@@ -1243,19 +769,15 @@ function createAuth(authClient) {
|
|
|
1243
769
|
isInitialized: isInitialized
|
|
1244
770
|
}
|
|
1245
771
|
}, children);
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
|
|
772
|
+
};
|
|
773
|
+
// Retrieve the AuthClient from the current context
|
|
1249
774
|
var useAuthClient = function useAuthClient() {
|
|
1250
775
|
var ctx = React.useContext(authContext);
|
|
1251
|
-
|
|
1252
776
|
if (!ctx) {
|
|
1253
777
|
throw new Error('useAuthClient hook should be used inside AuthProvider');
|
|
1254
778
|
}
|
|
1255
|
-
|
|
1256
779
|
return ctx.authClient;
|
|
1257
780
|
};
|
|
1258
|
-
|
|
1259
781
|
return {
|
|
1260
782
|
AuthProvider: AuthProvider,
|
|
1261
783
|
useAuthClient: useAuthClient
|