@aws-amplify/core 4.7.6 → 4.7.7-ds-allow-applicable-data.6
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/aws-amplify-core.js +718 -64
- package/dist/aws-amplify-core.js.map +1 -1
- package/dist/aws-amplify-core.min.js +4 -4
- package/dist/aws-amplify-core.min.js.map +1 -1
- package/lib/Credentials.d.ts +1 -1
- package/lib/Credentials.js +1 -1
- package/lib/Credentials.js.map +1 -1
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Util/BackgroundProcessManager.d.ts +178 -0
- package/lib/Util/BackgroundProcessManager.js +385 -0
- package/lib/Util/BackgroundProcessManager.js.map +1 -0
- package/lib/Util/Retry.d.ts +2 -2
- package/lib/Util/Retry.js +76 -34
- package/lib/Util/Retry.js.map +1 -1
- package/lib/Util/index.d.ts +1 -0
- package/lib/Util/index.js +1 -0
- package/lib/Util/index.js.map +1 -1
- package/lib-esm/Credentials.d.ts +1 -1
- package/lib-esm/Credentials.js +1 -1
- package/lib-esm/Credentials.js.map +1 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Util/BackgroundProcessManager.d.ts +178 -0
- package/lib-esm/Util/BackgroundProcessManager.js +383 -0
- package/lib-esm/Util/BackgroundProcessManager.js.map +1 -0
- package/lib-esm/Util/Retry.d.ts +2 -2
- package/lib-esm/Util/Retry.js +76 -34
- package/lib-esm/Util/Retry.js.map +1 -1
- package/lib-esm/Util/index.d.ts +1 -0
- package/lib-esm/Util/index.js +1 -0
- package/lib-esm/Util/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Credentials.ts +13 -14
- package/src/Platform/version.ts +1 -1
- package/src/Util/BackgroundProcessManager.ts +415 -0
- package/src/Util/Retry.ts +66 -31
- package/src/Util/index.ts +1 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @private For internal Amplify use.
|
|
50
|
+
*
|
|
51
|
+
* Creates a new scope for promises, observables, and other types of work or
|
|
52
|
+
* processes that may be running in the background. This manager provides
|
|
53
|
+
* an singular entrypoint to request termination and await completion.
|
|
54
|
+
*
|
|
55
|
+
* As work completes on its own prior to close, the manager removes them
|
|
56
|
+
* from the registry to avoid holding references to completed jobs.
|
|
57
|
+
*/
|
|
58
|
+
var BackgroundProcessManager = /** @class */ (function () {
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new manager for promises, observables, and other types
|
|
61
|
+
* of work that may be running in the background. This manager provides
|
|
62
|
+
* a centralized mechanism to request termination and await completion.
|
|
63
|
+
*/
|
|
64
|
+
function BackgroundProcessManager() {
|
|
65
|
+
/**
|
|
66
|
+
* A string indicating whether the manager is accepting new work ("Open"),
|
|
67
|
+
* waiting for work to complete ("Closing"), or fully done with all
|
|
68
|
+
* submitted work and *not* accepting new jobs ("Closed").
|
|
69
|
+
*/
|
|
70
|
+
this._state = BackgroundProcessManagerState.Open;
|
|
71
|
+
/**
|
|
72
|
+
* The list of outstanding jobs we'll need to wait for upon `close()`
|
|
73
|
+
*/
|
|
74
|
+
this.jobs = new Set();
|
|
75
|
+
}
|
|
76
|
+
BackgroundProcessManager.prototype.add = function (jobOrDescription, optionalDescription) {
|
|
77
|
+
var job;
|
|
78
|
+
var description;
|
|
79
|
+
if (typeof jobOrDescription === 'string') {
|
|
80
|
+
job = undefined;
|
|
81
|
+
description = jobOrDescription;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
job = jobOrDescription;
|
|
85
|
+
description = optionalDescription;
|
|
86
|
+
}
|
|
87
|
+
var error = this.closedFailure(description);
|
|
88
|
+
if (error)
|
|
89
|
+
return error;
|
|
90
|
+
if (job === undefined) {
|
|
91
|
+
return this.addHook(description);
|
|
92
|
+
}
|
|
93
|
+
else if (typeof job === 'function') {
|
|
94
|
+
return this.addFunction(job, description);
|
|
95
|
+
}
|
|
96
|
+
else if (job instanceof BackgroundProcessManager) {
|
|
97
|
+
return this.addManager(job, description);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new Error('If `job` is provided, it must be an Observable, Function, or BackgroundProcessManager.');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Adds a **cleaner** function that doesn't immediately get executed.
|
|
105
|
+
* Instead, the caller gets a **terminate** function back. The *cleaner* is
|
|
106
|
+
* invoked only once the mananger *closes* or the returned **terminate**
|
|
107
|
+
* function is called.
|
|
108
|
+
*
|
|
109
|
+
* @param clean The cleanup function.
|
|
110
|
+
* @param description Optional description to help identify pending jobs.
|
|
111
|
+
* @returns A terminate function.
|
|
112
|
+
*/
|
|
113
|
+
BackgroundProcessManager.prototype.addCleaner = function (clean, description) {
|
|
114
|
+
var _this = this;
|
|
115
|
+
var _a = this.addHook(description), resolve = _a.resolve, onTerminate = _a.onTerminate;
|
|
116
|
+
var proxy = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0: return [4 /*yield*/, clean()];
|
|
120
|
+
case 1:
|
|
121
|
+
_a.sent();
|
|
122
|
+
resolve();
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); };
|
|
127
|
+
onTerminate.then(proxy);
|
|
128
|
+
return proxy;
|
|
129
|
+
};
|
|
130
|
+
BackgroundProcessManager.prototype.addFunction = function (job, description) {
|
|
131
|
+
// the function we call when we want to try to terminate this job.
|
|
132
|
+
var terminate;
|
|
133
|
+
// the promise the job can opt into listening to for termination.
|
|
134
|
+
var onTerminate = new Promise(function (resolve) {
|
|
135
|
+
terminate = resolve;
|
|
136
|
+
});
|
|
137
|
+
// finally! start the job.
|
|
138
|
+
var jobResult = job(onTerminate);
|
|
139
|
+
// depending on what the job gives back, register the result
|
|
140
|
+
// so we can monitor for completion.
|
|
141
|
+
if (typeof (jobResult === null || jobResult === void 0 ? void 0 : jobResult.then) === 'function') {
|
|
142
|
+
this.registerPromise(jobResult, terminate, description);
|
|
143
|
+
}
|
|
144
|
+
// At the end of the day, or you know, method call, it doesn't matter
|
|
145
|
+
// what the return value is at all; we just pass it through to the
|
|
146
|
+
// caller.
|
|
147
|
+
return jobResult;
|
|
148
|
+
};
|
|
149
|
+
BackgroundProcessManager.prototype.addManager = function (manager, description) {
|
|
150
|
+
var _this = this;
|
|
151
|
+
this.addCleaner(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, manager.close()];
|
|
154
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
155
|
+
}
|
|
156
|
+
}); }); }, description);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Creates and registers a fabricated job for processes that need to operate
|
|
160
|
+
* with callbacks/hooks. The returned `resolve` and `reject`
|
|
161
|
+
* functions can be used to signal the job is done successfully or not.
|
|
162
|
+
* The returned `onTerminate` is a promise that will resolve when the
|
|
163
|
+
* manager is requesting the termination of the job.
|
|
164
|
+
*
|
|
165
|
+
* @param description Optional description to help identify pending jobs.
|
|
166
|
+
* @returns `{ resolve, reject, onTerminate }`
|
|
167
|
+
*/
|
|
168
|
+
BackgroundProcessManager.prototype.addHook = function (description) {
|
|
169
|
+
// the resolve/reject functions we'll provide to the caller to signal
|
|
170
|
+
// the state of the job.
|
|
171
|
+
var resolve;
|
|
172
|
+
var reject;
|
|
173
|
+
// the underlying promise we'll use to manage it, pretty much like
|
|
174
|
+
// any other promise.
|
|
175
|
+
var promise = new Promise(function (res, rej) {
|
|
176
|
+
resolve = res;
|
|
177
|
+
reject = rej;
|
|
178
|
+
});
|
|
179
|
+
// the function we call when we want to try to terminate this job.
|
|
180
|
+
var terminate;
|
|
181
|
+
// the promise the job can opt into listening to for termination.
|
|
182
|
+
var onTerminate = new Promise(function (resolveTerminate) {
|
|
183
|
+
terminate = resolveTerminate;
|
|
184
|
+
});
|
|
185
|
+
this.registerPromise(promise, terminate, description);
|
|
186
|
+
return {
|
|
187
|
+
resolve: resolve,
|
|
188
|
+
reject: reject,
|
|
189
|
+
onTerminate: onTerminate,
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Adds a Promise based job to the list of jobs for monitoring and listens
|
|
194
|
+
* for either a success or failure, upon which the job is considered "done"
|
|
195
|
+
* and removed from the registry.
|
|
196
|
+
*
|
|
197
|
+
* @param promise A promise that is on its way to being returned to a
|
|
198
|
+
* caller, which needs to be tracked as a background job.
|
|
199
|
+
* @param terminate The termination function to register, which can be
|
|
200
|
+
* invoked to request the job stop.
|
|
201
|
+
* @param description Optional description to help identify pending jobs.
|
|
202
|
+
*/
|
|
203
|
+
BackgroundProcessManager.prototype.registerPromise = function (promise, terminate, description) {
|
|
204
|
+
var _this = this;
|
|
205
|
+
var jobEntry = { promise: promise, terminate: terminate, description: description };
|
|
206
|
+
this.jobs.add(jobEntry);
|
|
207
|
+
// in all of my testing, it is safe to multi-subscribe to a promise.
|
|
208
|
+
// so, rather than create another layer of promising, we're just going
|
|
209
|
+
// to hook into the promise we already have, and when it's done
|
|
210
|
+
// (successfully or not), we no longer need to wait for it upon close.
|
|
211
|
+
//
|
|
212
|
+
// sorry this is a bit hand-wavy:
|
|
213
|
+
//
|
|
214
|
+
// i believe we use `.then` and `.catch` instead of `.finally` because
|
|
215
|
+
// `.finally` is invoked in a different order in the sequence, and this
|
|
216
|
+
// breaks assumptions throughout and causes failures.
|
|
217
|
+
promise
|
|
218
|
+
.then(function () {
|
|
219
|
+
_this.jobs.delete(jobEntry);
|
|
220
|
+
})
|
|
221
|
+
.catch(function () {
|
|
222
|
+
_this.jobs.delete(jobEntry);
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "length", {
|
|
226
|
+
/**
|
|
227
|
+
* The number of jobs being waited on.
|
|
228
|
+
*
|
|
229
|
+
* We don't use this for anything. It's just informational for the caller,
|
|
230
|
+
* and can be used in logging and testing.
|
|
231
|
+
*
|
|
232
|
+
* @returns the number of jobs.
|
|
233
|
+
*/
|
|
234
|
+
get: function () {
|
|
235
|
+
return this.jobs.size;
|
|
236
|
+
},
|
|
237
|
+
enumerable: true,
|
|
238
|
+
configurable: true
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "state", {
|
|
241
|
+
/**
|
|
242
|
+
* The execution state of the manager. One of:
|
|
243
|
+
*
|
|
244
|
+
* 1. "Open" -> Accepting new jobs
|
|
245
|
+
* 1. "Closing" -> Not accepting new work. Waiting for jobs to complete.
|
|
246
|
+
* 1. "Closed" -> Not accepting new work. All submitted jobs are complete.
|
|
247
|
+
*/
|
|
248
|
+
get: function () {
|
|
249
|
+
return this._state;
|
|
250
|
+
},
|
|
251
|
+
enumerable: true,
|
|
252
|
+
configurable: true
|
|
253
|
+
});
|
|
254
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "pending", {
|
|
255
|
+
/**
|
|
256
|
+
* The registered `description` of all still-pending jobs.
|
|
257
|
+
*
|
|
258
|
+
* @returns descriptions as an array.
|
|
259
|
+
*/
|
|
260
|
+
get: function () {
|
|
261
|
+
return Array.from(this.jobs).map(function (job) { return job.description; });
|
|
262
|
+
},
|
|
263
|
+
enumerable: true,
|
|
264
|
+
configurable: true
|
|
265
|
+
});
|
|
266
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "isOpen", {
|
|
267
|
+
/**
|
|
268
|
+
* Whether the manager is accepting new jobs.
|
|
269
|
+
*/
|
|
270
|
+
get: function () {
|
|
271
|
+
return this._state === BackgroundProcessManagerState.Open;
|
|
272
|
+
},
|
|
273
|
+
enumerable: true,
|
|
274
|
+
configurable: true
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "isClosing", {
|
|
277
|
+
/**
|
|
278
|
+
* Whether the manager is rejecting new work, but still waiting for
|
|
279
|
+
* submitted work to complete.
|
|
280
|
+
*/
|
|
281
|
+
get: function () {
|
|
282
|
+
return this._state === BackgroundProcessManagerState.Closing;
|
|
283
|
+
},
|
|
284
|
+
enumerable: true,
|
|
285
|
+
configurable: true
|
|
286
|
+
});
|
|
287
|
+
Object.defineProperty(BackgroundProcessManager.prototype, "isClosed", {
|
|
288
|
+
/**
|
|
289
|
+
* Whether the manager is rejecting work and done waiting for submitted
|
|
290
|
+
* work to complete.
|
|
291
|
+
*/
|
|
292
|
+
get: function () {
|
|
293
|
+
return this._state === BackgroundProcessManagerState.Closed;
|
|
294
|
+
},
|
|
295
|
+
enumerable: true,
|
|
296
|
+
configurable: true
|
|
297
|
+
});
|
|
298
|
+
BackgroundProcessManager.prototype.closedFailure = function (description) {
|
|
299
|
+
if (!this.isOpen) {
|
|
300
|
+
return Promise.reject(new Error([
|
|
301
|
+
'The manager is closing or closed, which occurs after `close()` has been called.',
|
|
302
|
+
"This error occurred trying to add \"" + description + "\".",
|
|
303
|
+
"Pending jobs: [\n" + this.pending
|
|
304
|
+
.map(function (t) { return ' ' + t; })
|
|
305
|
+
.join(',\n') + "\n]",
|
|
306
|
+
].join('\n')));
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Signals jobs to stop (for those that accept interruptions) and waits
|
|
311
|
+
* for confirmation that jobs have stopped.
|
|
312
|
+
*
|
|
313
|
+
* This immediately puts the manager into a closing state and just begins
|
|
314
|
+
* to reject new work. After all work in the manager is complete, the
|
|
315
|
+
* manager goes into a `Completed` state and `close()` returns.
|
|
316
|
+
*
|
|
317
|
+
* @returns The settled results of each job's promise.
|
|
318
|
+
*/
|
|
319
|
+
BackgroundProcessManager.prototype.close = function () {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
+
var _a, _b, job, results;
|
|
322
|
+
var e_1, _c;
|
|
323
|
+
return __generator(this, function (_d) {
|
|
324
|
+
switch (_d.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
// prevents more jobs from being added
|
|
327
|
+
this._state = BackgroundProcessManagerState.Closing;
|
|
328
|
+
try {
|
|
329
|
+
for (_a = __values(Array.from(this.jobs)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
330
|
+
job = _b.value;
|
|
331
|
+
try {
|
|
332
|
+
job.terminate();
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
// Due to potential races with a job's natural completion, it's
|
|
336
|
+
// reasonable to expect the termination call to fail. Hence,
|
|
337
|
+
// not logging as an error.
|
|
338
|
+
console.warn("Failed to send termination signal to job. Error: " + error.message, job);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
343
|
+
finally {
|
|
344
|
+
try {
|
|
345
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
346
|
+
}
|
|
347
|
+
finally { if (e_1) throw e_1.error; }
|
|
348
|
+
}
|
|
349
|
+
return [4 /*yield*/, Promise.allSettled(Array.from(this.jobs).map(function (j) { return j.promise; }))];
|
|
350
|
+
case 1:
|
|
351
|
+
results = _d.sent();
|
|
352
|
+
// At this point, we're already *not* accepting new work, and all
|
|
353
|
+
// pending work is done. It's safe to set state to `Closed`. Any
|
|
354
|
+
// process that's checking this property will be able to safely operate
|
|
355
|
+
// on this value at this point.
|
|
356
|
+
this._state = BackgroundProcessManagerState.Closed;
|
|
357
|
+
return [2 /*return*/, results];
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
return BackgroundProcessManager;
|
|
363
|
+
}());
|
|
364
|
+
export { BackgroundProcessManager };
|
|
365
|
+
/**
|
|
366
|
+
* All possible states a `BackgroundProcessManager` instance can be in.
|
|
367
|
+
*/
|
|
368
|
+
export var BackgroundProcessManagerState;
|
|
369
|
+
(function (BackgroundProcessManagerState) {
|
|
370
|
+
/**
|
|
371
|
+
* Accepting new jobs.
|
|
372
|
+
*/
|
|
373
|
+
BackgroundProcessManagerState["Open"] = "Open";
|
|
374
|
+
/**
|
|
375
|
+
* Not accepting new jobs. Waiting for submitted jobs to complete.
|
|
376
|
+
*/
|
|
377
|
+
BackgroundProcessManagerState["Closing"] = "Closing";
|
|
378
|
+
/**
|
|
379
|
+
* Not accepting new jobs. All submitted jobs are complete.
|
|
380
|
+
*/
|
|
381
|
+
BackgroundProcessManagerState["Closed"] = "Closed";
|
|
382
|
+
})(BackgroundProcessManagerState || (BackgroundProcessManagerState = {}));
|
|
383
|
+
//# sourceMappingURL=BackgroundProcessManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackgroundProcessManager.js","sourceRoot":"","sources":["../../src/Util/BackgroundProcessManager.ts"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D,KAAK,CAAC,OAAS,EACnE,GAAG,CACH,CAAC;iCACF;6BACD;;;;;;;;;wBAIe,qBAAM,OAAO,CAAC,UAAU,CACvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS,CAAC,CACzC,EAAA;;wBAFK,OAAO,GAAG,SAEf;wBAED,iEAAiE;wBACjE,gEAAgE;wBAChE,uEAAuE;wBACvE,+BAA+B;wBAC/B,IAAI,CAAC,MAAM,GAAG,6BAA6B,CAAC,MAAM,CAAC;wBAEnD,sBAAO,OAAO,EAAC;;;;KACf;IACF,+BAAC;AAAD,CAAC,AArWD,IAqWC;;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BAeX;AAfD,WAAY,6BAA6B;IACxC;;OAEG;IACH,8CAAa,CAAA;IAEb;;OAEG;IACH,oDAAmB,CAAA;IAEnB;;OAEG;IACH,kDAAiB,CAAA;AAClB,CAAC,EAfW,6BAA6B,KAA7B,6BAA6B,QAexC"}
|
package/lib-esm/Util/Retry.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class NonRetryableError extends Error {
|
|
|
7
7
|
* @private
|
|
8
8
|
* Internal use of Amplify only
|
|
9
9
|
*/
|
|
10
|
-
export declare function retry(functionToRetry:
|
|
10
|
+
export declare function retry<T>(functionToRetry: (...args: any[]) => T, args: any[], delayFn: DelayFunction, onTerminate?: Promise<void>): Promise<T>;
|
|
11
11
|
/**
|
|
12
12
|
* @private
|
|
13
13
|
* Internal use of Amplify only
|
|
@@ -17,4 +17,4 @@ export declare function jitteredBackoff(maxDelayMs?: number): DelayFunction;
|
|
|
17
17
|
* @private
|
|
18
18
|
* Internal use of Amplify only
|
|
19
19
|
*/
|
|
20
|
-
export declare const jitteredExponentialRetry: (functionToRetry:
|
|
20
|
+
export declare const jitteredExponentialRetry: <T>(functionToRetry: (...args: any[]) => T, args: any[], maxDelayMs?: number, onTerminate?: Promise<void>) => Promise<T>;
|
package/lib-esm/Util/Retry.js
CHANGED
|
@@ -87,41 +87,83 @@ var isNonRetryableError = function (obj) {
|
|
|
87
87
|
* @private
|
|
88
88
|
* Internal use of Amplify only
|
|
89
89
|
*/
|
|
90
|
-
export function retry(functionToRetry, args, delayFn,
|
|
91
|
-
if (attempt === void 0) { attempt = 1; }
|
|
90
|
+
export function retry(functionToRetry, args, delayFn, onTerminate) {
|
|
92
91
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var
|
|
92
|
+
var _this = this;
|
|
94
93
|
return __generator(this, function (_a) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (typeof functionToRetry !== 'function') {
|
|
98
|
-
throw Error('functionToRetry must be a function');
|
|
99
|
-
}
|
|
100
|
-
logger.debug(functionToRetry.name + " attempt #" + attempt + " with this vars: " + JSON.stringify(args));
|
|
101
|
-
_a.label = 1;
|
|
102
|
-
case 1:
|
|
103
|
-
_a.trys.push([1, 3, , 8]);
|
|
104
|
-
return [4 /*yield*/, functionToRetry.apply(void 0, __spread(args))];
|
|
105
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
106
|
-
case 3:
|
|
107
|
-
err_1 = _a.sent();
|
|
108
|
-
logger.debug("error on " + functionToRetry.name, err_1);
|
|
109
|
-
if (isNonRetryableError(err_1)) {
|
|
110
|
-
logger.debug(functionToRetry.name + " non retryable error", err_1);
|
|
111
|
-
throw err_1;
|
|
112
|
-
}
|
|
113
|
-
retryIn_1 = delayFn(attempt, args, err_1);
|
|
114
|
-
logger.debug(functionToRetry.name + " retrying in " + retryIn_1 + " ms");
|
|
115
|
-
if (!(retryIn_1 !== false)) return [3 /*break*/, 6];
|
|
116
|
-
return [4 /*yield*/, new Promise(function (res) { return setTimeout(res, retryIn_1); })];
|
|
117
|
-
case 4:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [4 /*yield*/, retry(functionToRetry, args, delayFn, attempt + 1)];
|
|
120
|
-
case 5: return [2 /*return*/, _a.sent()];
|
|
121
|
-
case 6: throw err_1;
|
|
122
|
-
case 7: return [3 /*break*/, 8];
|
|
123
|
-
case 8: return [2 /*return*/];
|
|
94
|
+
if (typeof functionToRetry !== 'function') {
|
|
95
|
+
throw Error('functionToRetry must be a function');
|
|
124
96
|
}
|
|
97
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
98
|
+
var attempt, terminated, timeout, wakeUp, lastError, _loop_1, state_1;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
attempt = 0;
|
|
103
|
+
terminated = false;
|
|
104
|
+
wakeUp = function () { };
|
|
105
|
+
onTerminate &&
|
|
106
|
+
onTerminate.then(function () {
|
|
107
|
+
// signal not to try anymore.
|
|
108
|
+
terminated = true;
|
|
109
|
+
// stop sleeping if we're sleeping.
|
|
110
|
+
clearTimeout(timeout);
|
|
111
|
+
wakeUp();
|
|
112
|
+
});
|
|
113
|
+
_loop_1 = function () {
|
|
114
|
+
var _a, _b, err_1, retryIn_1;
|
|
115
|
+
return __generator(this, function (_c) {
|
|
116
|
+
switch (_c.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
attempt++;
|
|
119
|
+
logger.debug(functionToRetry.name + " attempt #" + attempt + " with this vars: " + JSON.stringify(args));
|
|
120
|
+
_c.label = 1;
|
|
121
|
+
case 1:
|
|
122
|
+
_c.trys.push([1, 3, , 7]);
|
|
123
|
+
_a = {};
|
|
124
|
+
_b = resolve;
|
|
125
|
+
return [4 /*yield*/, functionToRetry.apply(void 0, __spread(args))];
|
|
126
|
+
case 2: return [2 /*return*/, (_a.value = _b.apply(void 0, [_c.sent()]), _a)];
|
|
127
|
+
case 3:
|
|
128
|
+
err_1 = _c.sent();
|
|
129
|
+
lastError = err_1;
|
|
130
|
+
logger.debug("error on " + functionToRetry.name, err_1);
|
|
131
|
+
if (isNonRetryableError(err_1)) {
|
|
132
|
+
logger.debug(functionToRetry.name + " non retryable error", err_1);
|
|
133
|
+
return [2 /*return*/, { value: reject(err_1) }];
|
|
134
|
+
}
|
|
135
|
+
retryIn_1 = delayFn(attempt, args, err_1);
|
|
136
|
+
logger.debug(functionToRetry.name + " retrying in " + retryIn_1 + " ms");
|
|
137
|
+
if (!(retryIn_1 === false || terminated)) return [3 /*break*/, 4];
|
|
138
|
+
return [2 /*return*/, { value: reject(err_1) }];
|
|
139
|
+
case 4: return [4 /*yield*/, new Promise(function (r) {
|
|
140
|
+
wakeUp = r; // export wakeUp for onTerminate handling
|
|
141
|
+
timeout = setTimeout(wakeUp, retryIn_1);
|
|
142
|
+
})];
|
|
143
|
+
case 5:
|
|
144
|
+
_c.sent();
|
|
145
|
+
_c.label = 6;
|
|
146
|
+
case 6: return [3 /*break*/, 7];
|
|
147
|
+
case 7: return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
_a.label = 1;
|
|
152
|
+
case 1:
|
|
153
|
+
if (!!terminated) return [3 /*break*/, 3];
|
|
154
|
+
return [5 /*yield**/, _loop_1()];
|
|
155
|
+
case 2:
|
|
156
|
+
state_1 = _a.sent();
|
|
157
|
+
if (typeof state_1 === "object")
|
|
158
|
+
return [2 /*return*/, state_1.value];
|
|
159
|
+
return [3 /*break*/, 1];
|
|
160
|
+
case 3:
|
|
161
|
+
// reached if terminated while waiting for a timer.
|
|
162
|
+
reject(lastError);
|
|
163
|
+
return [2 /*return*/];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}); })];
|
|
125
167
|
});
|
|
126
168
|
});
|
|
127
169
|
}
|
|
@@ -143,8 +185,8 @@ export function jitteredBackoff(maxDelayMs) {
|
|
|
143
185
|
* @private
|
|
144
186
|
* Internal use of Amplify only
|
|
145
187
|
*/
|
|
146
|
-
export var jitteredExponentialRetry = function (functionToRetry, args, maxDelayMs) {
|
|
188
|
+
export var jitteredExponentialRetry = function (functionToRetry, args, maxDelayMs, onTerminate) {
|
|
147
189
|
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
148
|
-
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs));
|
|
190
|
+
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs), onTerminate);
|
|
149
191
|
};
|
|
150
192
|
//# sourceMappingURL=Retry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Retry.js","sourceRoot":"","sources":["../../src/Util/Retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAClE,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAElC;IAAuC,qCAAK;IAE3C,2BAAY,OAAe;QAA3B,YACC,kBAAM,OAAO,CAAC,SACd;QAHe,kBAAY,GAAG,IAAI,CAAC;;IAGpC,CAAC;IACF,wBAAC;AAAD,CAAC,AALD,CAAuC,KAAK,GAK3C;;AAED,IAAM,mBAAmB,GAAG,UAAC,GAAQ;IACpC,IAAM,GAAG,GAA4B,cAAc,CAAC;IACpD,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAgB,KAAK,CAC1B,
|
|
1
|
+
{"version":3,"file":"Retry.js","sourceRoot":"","sources":["../../src/Util/Retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAClE,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAElC;IAAuC,qCAAK;IAE3C,2BAAY,OAAe;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tC,IAAW,EACX,UAAiC,EACjC,WAA2B;IAD3B,2BAAA,EAAA,yBAAiC;IAGjC,OAAA,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;AAAtE,CAAsE,CAAC"}
|
package/lib-esm/Util/index.d.ts
CHANGED
package/lib-esm/Util/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Util/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Util/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "4.7.6",
|
|
3
|
+
"version": "4.7.7-ds-allow-applicable-data.6+d82091b85",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"lib-esm"
|
|
109
109
|
]
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "d82091b85c02867800d3e012977604b8851328cc"
|
|
112
112
|
}
|
package/src/Credentials.ts
CHANGED
|
@@ -187,7 +187,7 @@ export class CredentialsClass {
|
|
|
187
187
|
const MAX_DELAY_MS = 10 * 1000;
|
|
188
188
|
// refreshHandler will retry network errors, otherwise it will
|
|
189
189
|
// return NonRetryableError to break out of jitteredExponentialRetry
|
|
190
|
-
return jitteredExponentialRetry(refreshHandler, [], MAX_DELAY_MS)
|
|
190
|
+
return jitteredExponentialRetry<any>(refreshHandler, [], MAX_DELAY_MS)
|
|
191
191
|
.then(data => {
|
|
192
192
|
logger.debug('refresh federated token sucessfully', data);
|
|
193
193
|
return this._setCredentialsFromFederation({
|
|
@@ -256,7 +256,7 @@ export class CredentialsClass {
|
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
const identityId = this._identityId = await this._getGuestIdentityId();
|
|
259
|
+
const identityId = (this._identityId = await this._getGuestIdentityId());
|
|
260
260
|
|
|
261
261
|
const cognitoClient = new CognitoIdentityClient({
|
|
262
262
|
region,
|
|
@@ -446,19 +446,14 @@ export class CredentialsClass {
|
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
const {
|
|
449
|
-
Credentials: {
|
|
450
|
-
AccessKeyId,
|
|
451
|
-
Expiration,
|
|
452
|
-
SecretKey,
|
|
453
|
-
SessionToken,
|
|
454
|
-
},
|
|
449
|
+
Credentials: { AccessKeyId, Expiration, SecretKey, SessionToken },
|
|
455
450
|
// single source of truth for the primary identity associated with the logins
|
|
456
451
|
// only if a guest identity is used for a first-time user, that guest identity will become its primary identity
|
|
457
452
|
IdentityId: primaryIdentityId,
|
|
458
453
|
} = await cognitoClient.send(
|
|
459
454
|
new GetCredentialsForIdentityCommand({
|
|
460
|
-
|
|
461
|
-
|
|
455
|
+
IdentityId: guestIdentityId || generatedOrRetrievedIdentityId,
|
|
456
|
+
Logins: logins,
|
|
462
457
|
})
|
|
463
458
|
);
|
|
464
459
|
|
|
@@ -466,9 +461,13 @@ export class CredentialsClass {
|
|
|
466
461
|
if (guestIdentityId) {
|
|
467
462
|
// if guestIdentity is found and used by GetCredentialsForIdentity
|
|
468
463
|
// it will be linked to the logins provided, and disqualified as an unauth identity
|
|
469
|
-
logger.debug(
|
|
464
|
+
logger.debug(
|
|
465
|
+
`The guest identity ${guestIdentityId} has been successfully linked to the logins`
|
|
466
|
+
);
|
|
470
467
|
if (guestIdentityId === primaryIdentityId) {
|
|
471
|
-
logger.debug(
|
|
468
|
+
logger.debug(
|
|
469
|
+
`The guest identity ${guestIdentityId} has become the primary identity`
|
|
470
|
+
);
|
|
472
471
|
}
|
|
473
472
|
// remove it from local storage to avoid being used as a guest Identity by _setCredentialsForGuest
|
|
474
473
|
await this._removeGuestIdentityId();
|
|
@@ -481,7 +480,7 @@ export class CredentialsClass {
|
|
|
481
480
|
sessionToken: SessionToken,
|
|
482
481
|
expiration: Expiration,
|
|
483
482
|
identityId: primaryIdentityId,
|
|
484
|
-
|
|
483
|
+
};
|
|
485
484
|
};
|
|
486
485
|
|
|
487
486
|
const credentials = credentialsProvider().catch(async err => {
|
|
@@ -587,7 +586,7 @@ export class CredentialsClass {
|
|
|
587
586
|
await this._storageSync;
|
|
588
587
|
this._storage.setItem(
|
|
589
588
|
this._getCognitoIdentityIdStorageKey(identityPoolId),
|
|
590
|
-
identityId
|
|
589
|
+
identityId
|
|
591
590
|
);
|
|
592
591
|
} catch (e) {
|
|
593
592
|
logger.debug('Failed to cache guest identityId', e);
|