@aws-amplify/auth 4.6.15-unstable.4 → 4.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/build.js +5 -0
  3. package/dist/aws-amplify-auth.js +14660 -0
  4. package/dist/aws-amplify-auth.js.map +1 -0
  5. package/dist/aws-amplify-auth.min.js +43 -0
  6. package/dist/aws-amplify-auth.min.js.map +1 -0
  7. package/index.js +7 -0
  8. package/lib/Auth.js +140 -65
  9. package/lib/Auth.js.map +1 -1
  10. package/lib/Errors.js +27 -5
  11. package/lib/Errors.js.map +1 -1
  12. package/lib/OAuth/OAuth.js +118 -36
  13. package/lib/OAuth/OAuth.js.map +1 -1
  14. package/lib/OAuth/oauthStorage.js +12 -2
  15. package/lib/OAuth/oauthStorage.js.map +1 -1
  16. package/lib/OAuth/oauthStorage.native.js +12 -2
  17. package/lib/OAuth/oauthStorage.native.js.map +1 -1
  18. package/lib/OAuth/urlOpener.js +12 -2
  19. package/lib/OAuth/urlOpener.js.map +1 -1
  20. package/lib/OAuth/urlOpener.native.js +12 -2
  21. package/lib/OAuth/urlOpener.native.js.map +1 -1
  22. package/lib/index.js +12 -2
  23. package/lib/index.js.map +1 -1
  24. package/lib/types/Auth.js +12 -2
  25. package/lib/types/Auth.js.map +1 -1
  26. package/lib/types/index.js +16 -4
  27. package/lib/types/index.js.map +1 -1
  28. package/lib/urlListener.js +12 -2
  29. package/lib/urlListener.js.map +1 -1
  30. package/lib/urlListener.native.js +76 -9
  31. package/lib/urlListener.native.js.map +1 -1
  32. package/lib-esm/Auth.js +77 -5
  33. package/lib-esm/Auth.js.map +1 -1
  34. package/lib-esm/Errors.js +25 -3
  35. package/lib-esm/Errors.js.map +1 -1
  36. package/lib-esm/OAuth/OAuth.js +85 -13
  37. package/lib-esm/OAuth/OAuth.js.map +1 -1
  38. package/lib-esm/OAuth/oauthStorage.js +12 -2
  39. package/lib-esm/OAuth/oauthStorage.js.map +1 -1
  40. package/lib-esm/OAuth/oauthStorage.native.js +12 -2
  41. package/lib-esm/OAuth/oauthStorage.native.js.map +1 -1
  42. package/lib-esm/OAuth/urlOpener.js +12 -2
  43. package/lib-esm/OAuth/urlOpener.js.map +1 -1
  44. package/lib-esm/OAuth/urlOpener.native.js +12 -2
  45. package/lib-esm/OAuth/urlOpener.native.js.map +1 -1
  46. package/lib-esm/index.js +12 -2
  47. package/lib-esm/index.js.map +1 -1
  48. package/lib-esm/types/Auth.js +12 -2
  49. package/lib-esm/types/Auth.js.map +1 -1
  50. package/lib-esm/types/index.js +12 -2
  51. package/lib-esm/types/index.js.map +1 -1
  52. package/lib-esm/urlListener.js +12 -2
  53. package/lib-esm/urlListener.js.map +1 -1
  54. package/lib-esm/urlListener.native.js +70 -3
  55. package/lib-esm/urlListener.native.js.map +1 -1
  56. package/package.json +11 -13
  57. package/src/Auth.ts +14 -4
  58. package/src/Errors.ts +12 -2
  59. package/src/OAuth/OAuth.ts +37 -27
  60. package/src/OAuth/oauthStorage.native.ts +12 -2
  61. package/src/OAuth/oauthStorage.ts +12 -2
  62. package/src/OAuth/urlOpener.native.ts +12 -2
  63. package/src/OAuth/urlOpener.ts +12 -2
  64. package/src/index.ts +12 -2
  65. package/src/types/Auth.ts +12 -2
  66. package/src/types/index.ts +12 -2
  67. package/src/urlListener.native.ts +12 -2
  68. package/src/urlListener.ts +12 -2
  69. package/testSequencer.js +24 -0
  70. package/webpack.config.dev.js +6 -0
  71. package/lib/.tsbuildinfo +0 -3
  72. package/lib/Auth.d.ts +0 -301
  73. package/lib/Errors.d.ts +0 -9
  74. package/lib/OAuth/OAuth.d.ts +0 -29
  75. package/lib/OAuth/oauthStorage.d.ts +0 -5
  76. package/lib/OAuth/oauthStorage.native.d.ts +0 -5
  77. package/lib/OAuth/urlOpener.d.ts +0 -1
  78. package/lib/OAuth/urlOpener.native.d.ts +0 -1
  79. package/lib/common/AuthErrorStrings.d.ts +0 -17
  80. package/lib/index.d.ts +0 -9
  81. package/lib/types/Auth.d.ts +0 -170
  82. package/lib/types/index.d.ts +0 -1
  83. package/lib/urlListener.d.ts +0 -2
  84. package/lib/urlListener.native.d.ts +0 -2
  85. package/lib-esm/.tsbuildinfo +0 -3
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./dist/aws-amplify-auth.min.js');
5
+ } else {
6
+ module.exports = require('./dist/aws-amplify-auth.js');
7
+ }
package/lib/Auth.js CHANGED
@@ -1,14 +1,89 @@
1
1
  "use strict";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
2
+ /*
3
+ * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6
+ * the License. A copy of the License is located at
7
+ *
8
+ * http://aws.amazon.com/apache2.0/
9
+ *
10
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
12
+ * and limitations under the License.
13
+ */
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (_) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ var __read = (this && this.__read) || function (o, n) {
62
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
63
+ if (!m) return o;
64
+ var i = m.call(o), r, ar = [], e;
65
+ try {
66
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
67
+ }
68
+ catch (error) { e = { error: error }; }
69
+ finally {
70
+ try {
71
+ if (r && !r.done && (m = i["return"])) m.call(i);
72
+ }
73
+ finally { if (e) throw e.error; }
74
+ }
75
+ return ar;
76
+ };
77
+ var __importDefault = (this && this.__importDefault) || function (mod) {
78
+ return (mod && mod.__esModule) ? mod : { "default": mod };
79
+ };
4
80
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
6
81
  var types_1 = require("./types");
7
82
  var core_1 = require("@aws-amplify/core");
8
83
  var amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
9
84
  var url_1 = require("url");
10
- var OAuth_1 = tslib_1.__importDefault(require("./OAuth/OAuth"));
11
- var urlListener_1 = tslib_1.__importDefault(require("./urlListener"));
85
+ var OAuth_1 = __importDefault(require("./OAuth/OAuth"));
86
+ var urlListener_1 = __importDefault(require("./urlListener"));
12
87
  var Errors_1 = require("./Errors");
13
88
  var Auth_1 = require("./types/Auth");
14
89
  var logger = new core_1.ConsoleLogger('AuthClass');
@@ -80,7 +155,7 @@ var AuthClass = /** @class */ (function () {
80
155
  if (!config)
81
156
  return this._config || {};
82
157
  logger.debug('configure Auth');
83
- var conf = Object.assign({}, this._config, core_1.parseAWSExports(config).Auth, config);
158
+ var conf = Object.assign({}, this._config, core_1.Parser.parseMobilehubConfig(config).Auth, config);
84
159
  this._config = conf;
85
160
  var _a = this._config, userPoolId = _a.userPoolId, userPoolWebClientId = _a.userPoolWebClientId, cookieStorage = _a.cookieStorage, oauth = _a.oauth, region = _a.region, identityPoolId = _a.identityPoolId, mandatorySignIn = _a.mandatorySignIn, refreshHandlers = _a.refreshHandlers, identityPoolRegion = _a.identityPoolRegion, clientMetadata = _a.clientMetadata, endpoint = _a.endpoint;
86
161
  if (!this._config.storage) {
@@ -311,10 +386,10 @@ var AuthClass = /** @class */ (function () {
311
386
  }, 5000);
312
387
  };
313
388
  AuthClass.prototype.signInAfterUserConfirmed = function (authDetails, listenEvent, autoSignInPollingIntervalId) {
314
- return tslib_1.__awaiter(this, void 0, void 0, function () {
389
+ return __awaiter(this, void 0, void 0, function () {
315
390
  var user, error_1;
316
391
  var _this = this;
317
- return tslib_1.__generator(this, function (_a) {
392
+ return __generator(this, function (_a) {
318
393
  switch (_a.label) {
319
394
  case 0:
320
395
  user = this.createCognitoUser(authDetails.getUsername());
@@ -481,9 +556,9 @@ var AuthClass = /** @class */ (function () {
481
556
  var _this = this;
482
557
  var that = this;
483
558
  return {
484
- onSuccess: function (session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
559
+ onSuccess: function (session) { return __awaiter(_this, void 0, void 0, function () {
485
560
  var cred, e_1, currentUser, e_2;
486
- return tslib_1.__generator(this, function (_a) {
561
+ return __generator(this, function (_a) {
487
562
  switch (_a.label) {
488
563
  case 0:
489
564
  logger.debug(session);
@@ -639,9 +714,9 @@ var AuthClass = /** @class */ (function () {
639
714
  return new Promise(function (res, rej) {
640
715
  var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
641
716
  var bypassCache = params ? params.bypassCache : false;
642
- user.getUserData(function (err, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
717
+ user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
643
718
  var cleanUpError_1, mfaType;
644
- return tslib_1.__generator(this, function (_a) {
719
+ return __generator(this, function (_a) {
645
720
  switch (_a.label) {
646
721
  case 0:
647
722
  if (!err) return [3 /*break*/, 5];
@@ -713,9 +788,9 @@ var AuthClass = /** @class */ (function () {
713
788
  AuthClass.prototype._getUserData = function (user, params) {
714
789
  var _this = this;
715
790
  return new Promise(function (res, rej) {
716
- user.getUserData(function (err, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
791
+ user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
717
792
  var cleanUpError_2;
718
- return tslib_1.__generator(this, function (_a) {
793
+ return __generator(this, function (_a) {
719
794
  switch (_a.label) {
720
795
  case 0:
721
796
  if (!err) return [3 /*break*/, 5];
@@ -751,10 +826,10 @@ var AuthClass = /** @class */ (function () {
751
826
  * @return - A promise resolve if success
752
827
  */
753
828
  AuthClass.prototype.setPreferredMFA = function (user, mfaMethod) {
754
- return tslib_1.__awaiter(this, void 0, void 0, function () {
829
+ return __awaiter(this, void 0, void 0, function () {
755
830
  var clientMetadata, userData, smsMfaSettings, totpMfaSettings, _a, mfaList, currentMFAType, that;
756
831
  var _this = this;
757
- return tslib_1.__generator(this, function (_b) {
832
+ return __generator(this, function (_b) {
758
833
  switch (_b.label) {
759
834
  case 0:
760
835
  clientMetadata = this._config.clientMetadata;
@@ -844,9 +919,9 @@ var AuthClass = /** @class */ (function () {
844
919
  logger.debug('Set user mfa success', result);
845
920
  logger.debug('Caching the latest user data into local');
846
921
  // cache the latest result into user data
847
- user.getUserData(function (err, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
922
+ user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
848
923
  var cleanUpError_3;
849
- return tslib_1.__generator(this, function (_a) {
924
+ return __generator(this, function (_a) {
850
925
  switch (_a.label) {
851
926
  case 0:
852
927
  if (!err) return [3 /*break*/, 5];
@@ -976,9 +1051,9 @@ var AuthClass = /** @class */ (function () {
976
1051
  var that = this;
977
1052
  return new Promise(function (resolve, reject) {
978
1053
  user.sendMFACode(code, {
979
- onSuccess: function (session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1054
+ onSuccess: function (session) { return __awaiter(_this, void 0, void 0, function () {
980
1055
  var cred, e_3;
981
- return tslib_1.__generator(this, function (_a) {
1056
+ return __generator(this, function (_a) {
982
1057
  switch (_a.label) {
983
1058
  case 0:
984
1059
  logger.debug(session);
@@ -1023,9 +1098,9 @@ var AuthClass = /** @class */ (function () {
1023
1098
  var that = this;
1024
1099
  return new Promise(function (resolve, reject) {
1025
1100
  user.completeNewPasswordChallenge(password, requiredAttributes, {
1026
- onSuccess: function (session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1101
+ onSuccess: function (session) { return __awaiter(_this, void 0, void 0, function () {
1027
1102
  var cred, e_4;
1028
- return tslib_1.__generator(this, function (_a) {
1103
+ return __generator(this, function (_a) {
1029
1104
  switch (_a.label) {
1030
1105
  case 0:
1031
1106
  logger.debug(session);
@@ -1124,10 +1199,10 @@ var AuthClass = /** @class */ (function () {
1124
1199
  **/
1125
1200
  // TODO: Check return type void
1126
1201
  AuthClass.prototype.deleteUser = function () {
1127
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1202
+ return __awaiter(this, void 0, void 0, function () {
1128
1203
  var e_5, isSignedInHostedUI;
1129
1204
  var _this = this;
1130
- return tslib_1.__generator(this, function (_a) {
1205
+ return __generator(this, function (_a) {
1131
1206
  switch (_a.label) {
1132
1207
  case 0:
1133
1208
  _a.trys.push([0, 2, , 3]);
@@ -1142,10 +1217,10 @@ var AuthClass = /** @class */ (function () {
1142
1217
  case 3:
1143
1218
  isSignedInHostedUI = this._oAuthHandler &&
1144
1219
  this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
1145
- return [2 /*return*/, new Promise(function (res, rej) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1220
+ return [2 /*return*/, new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
1146
1221
  var user_1;
1147
1222
  var _this = this;
1148
- return tslib_1.__generator(this, function (_a) {
1223
+ return __generator(this, function (_a) {
1149
1224
  if (this.userPool) {
1150
1225
  user_1 = this.userPool.getCurrentUser();
1151
1226
  if (!user_1) {
@@ -1153,10 +1228,10 @@ var AuthClass = /** @class */ (function () {
1153
1228
  return [2 /*return*/, rej(new Error('No current user.'))];
1154
1229
  }
1155
1230
  else {
1156
- user_1.getSession(function (err, session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1231
+ user_1.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
1157
1232
  var cleanUpError_4;
1158
1233
  var _this = this;
1159
- return tslib_1.__generator(this, function (_a) {
1234
+ return __generator(this, function (_a) {
1160
1235
  switch (_a.label) {
1161
1236
  case 0:
1162
1237
  if (!err) return [3 /*break*/, 5];
@@ -1331,10 +1406,10 @@ var AuthClass = /** @class */ (function () {
1331
1406
  this.isRefreshTokenExpiredError(err));
1332
1407
  };
1333
1408
  AuthClass.prototype.cleanUpInvalidSession = function (user) {
1334
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1409
+ return __awaiter(this, void 0, void 0, function () {
1335
1410
  var e_6;
1336
1411
  var _this = this;
1337
- return tslib_1.__generator(this, function (_a) {
1412
+ return __generator(this, function (_a) {
1338
1413
  switch (_a.label) {
1339
1414
  case 0:
1340
1415
  user.signOut();
@@ -1375,10 +1450,10 @@ var AuthClass = /** @class */ (function () {
1375
1450
  }
1376
1451
  return new Promise(function (res, rej) {
1377
1452
  _this._storageSync
1378
- .then(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1453
+ .then(function () { return __awaiter(_this, void 0, void 0, function () {
1379
1454
  var user, clientMetadata;
1380
1455
  var _this = this;
1381
- return tslib_1.__generator(this, function (_a) {
1456
+ return __generator(this, function (_a) {
1382
1457
  switch (_a.label) {
1383
1458
  case 0:
1384
1459
  if (!this.isOAuthInProgress()) return [3 /*break*/, 2];
@@ -1414,10 +1489,10 @@ var AuthClass = /** @class */ (function () {
1414
1489
  }
1415
1490
  clientMetadata = this._config.clientMetadata;
1416
1491
  // refresh the session if the session expired.
1417
- user.getSession(function (err, session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1492
+ user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
1418
1493
  var cleanUpError_5, bypassCache, clientMetadata, _a, scope;
1419
1494
  var _this = this;
1420
- return tslib_1.__generator(this, function (_b) {
1495
+ return __generator(this, function (_b) {
1421
1496
  switch (_b.label) {
1422
1497
  case 0:
1423
1498
  if (!err) return [3 /*break*/, 5];
@@ -1448,9 +1523,9 @@ var AuthClass = /** @class */ (function () {
1448
1523
  clientMetadata = this._config.clientMetadata;
1449
1524
  _a = session.getAccessToken().decodePayload().scope, scope = _a === void 0 ? '' : _a;
1450
1525
  if (scope.split(' ').includes(USER_ADMIN_SCOPE)) {
1451
- user.getUserData(function (err, data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1526
+ user.getUserData(function (err, data) { return __awaiter(_this, void 0, void 0, function () {
1452
1527
  var cleanUpError_6, preferredMFA, attributeList, i, attribute, userAttribute, attributes;
1453
- return tslib_1.__generator(this, function (_a) {
1528
+ return __generator(this, function (_a) {
1454
1529
  switch (_a.label) {
1455
1530
  case 0:
1456
1531
  if (!err) return [3 /*break*/, 7];
@@ -1520,9 +1595,9 @@ var AuthClass = /** @class */ (function () {
1520
1595
  * @return - A promise resolves to current authenticated CognitoUser if success
1521
1596
  */
1522
1597
  AuthClass.prototype.currentAuthenticatedUser = function (params) {
1523
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1598
+ return __awaiter(this, void 0, void 0, function () {
1524
1599
  var federatedUser, e_7, federatedInfo, user, e_8;
1525
- return tslib_1.__generator(this, function (_a) {
1600
+ return __generator(this, function (_a) {
1526
1601
  switch (_a.label) {
1527
1602
  case 0:
1528
1603
  logger.debug('getting current authenticated user');
@@ -1542,7 +1617,7 @@ var AuthClass = /** @class */ (function () {
1542
1617
  try {
1543
1618
  federatedInfo = JSON.parse(this._storage.getItem('aws-amplify-federatedInfo'));
1544
1619
  if (federatedInfo) {
1545
- federatedUser = tslib_1.__assign(tslib_1.__assign({}, federatedInfo.user), { token: federatedInfo.token });
1620
+ federatedUser = __assign(__assign({}, federatedInfo.user), { token: federatedInfo.token });
1546
1621
  }
1547
1622
  }
1548
1623
  catch (e) {
@@ -1625,9 +1700,9 @@ var AuthClass = /** @class */ (function () {
1625
1700
  var clientMetadata = this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
1626
1701
  return new Promise(function (res, rej) {
1627
1702
  logger.debug('Getting the session from this user:', user);
1628
- user.getSession(function (err, session) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1703
+ user.getSession(function (err, session) { return __awaiter(_this, void 0, void 0, function () {
1629
1704
  var cleanUpError_7;
1630
- return tslib_1.__generator(this, function (_a) {
1705
+ return __generator(this, function (_a) {
1631
1706
  switch (_a.label) {
1632
1707
  case 0:
1633
1708
  if (!err) return [3 /*break*/, 5];
@@ -1661,10 +1736,10 @@ var AuthClass = /** @class */ (function () {
1661
1736
  * @return - A promise resolves to be current user's credentials
1662
1737
  */
1663
1738
  AuthClass.prototype.currentUserCredentials = function () {
1664
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1739
+ return __awaiter(this, void 0, void 0, function () {
1665
1740
  var e_9, federatedInfo;
1666
1741
  var _this = this;
1667
- return tslib_1.__generator(this, function (_a) {
1742
+ return __generator(this, function (_a) {
1668
1743
  switch (_a.label) {
1669
1744
  case 0:
1670
1745
  logger.debug('Getting current user credentials');
@@ -1773,10 +1848,10 @@ var AuthClass = /** @class */ (function () {
1773
1848
  .then(function (user) { return that.verifyUserAttributeSubmit(user, attr, code); });
1774
1849
  };
1775
1850
  AuthClass.prototype.cognitoIdentitySignOut = function (opts, user) {
1776
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1851
+ return __awaiter(this, void 0, void 0, function () {
1777
1852
  var e_10, isSignedInHostedUI;
1778
1853
  var _this = this;
1779
- return tslib_1.__generator(this, function (_a) {
1854
+ return __generator(this, function (_a) {
1780
1855
  switch (_a.label) {
1781
1856
  case 0:
1782
1857
  _a.trys.push([0, 2, , 3]);
@@ -1797,10 +1872,10 @@ var AuthClass = /** @class */ (function () {
1797
1872
  // in order to use global signout
1798
1873
  // we must validate the user as an authenticated user by using getSession
1799
1874
  var clientMetadata = _this._config.clientMetadata; // TODO: verify behavior if this is override during signIn
1800
- user.getSession(function (err, result) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1875
+ user.getSession(function (err, result) { return __awaiter(_this, void 0, void 0, function () {
1801
1876
  var cleanUpError_8;
1802
1877
  var _this = this;
1803
- return tslib_1.__generator(this, function (_a) {
1878
+ return __generator(this, function (_a) {
1804
1879
  switch (_a.label) {
1805
1880
  case 0:
1806
1881
  if (!err) return [3 /*break*/, 5];
@@ -1879,9 +1954,9 @@ var AuthClass = /** @class */ (function () {
1879
1954
  * @return - A promise resolved if success
1880
1955
  */
1881
1956
  AuthClass.prototype.signOut = function (opts) {
1882
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1957
+ return __awaiter(this, void 0, void 0, function () {
1883
1958
  var e_11, user;
1884
- return tslib_1.__generator(this, function (_a) {
1959
+ return __generator(this, function (_a) {
1885
1960
  switch (_a.label) {
1886
1961
  case 0:
1887
1962
  _a.trys.push([0, 2, , 3]);
@@ -1923,8 +1998,8 @@ var AuthClass = /** @class */ (function () {
1923
1998
  });
1924
1999
  };
1925
2000
  AuthClass.prototype.cleanCachedItems = function () {
1926
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1927
- return tslib_1.__generator(this, function (_a) {
2001
+ return __awaiter(this, void 0, void 0, function () {
2002
+ return __generator(this, function (_a) {
1928
2003
  switch (_a.label) {
1929
2004
  case 0:
1930
2005
  // clear cognito cached item
@@ -2038,9 +2113,9 @@ var AuthClass = /** @class */ (function () {
2038
2113
  * @return {Object }- current User's information
2039
2114
  */
2040
2115
  AuthClass.prototype.currentUserInfo = function () {
2041
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2116
+ return __awaiter(this, void 0, void 0, function () {
2042
2117
  var source, user, attributes, userAttrs, credentials, e_12, info, err_1, user;
2043
- return tslib_1.__generator(this, function (_a) {
2118
+ return __generator(this, function (_a) {
2044
2119
  switch (_a.label) {
2045
2120
  case 0:
2046
2121
  source = this.Credentials.getCredSource();
@@ -2094,9 +2169,9 @@ var AuthClass = /** @class */ (function () {
2094
2169
  });
2095
2170
  };
2096
2171
  AuthClass.prototype.federatedSignIn = function (providerOrOptions, response, user) {
2097
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2172
+ return __awaiter(this, void 0, void 0, function () {
2098
2173
  var options, provider, customState, client_id, redirect_uri, provider, loggedInUser, token, identity_id, expires_at, credentials, currentUser;
2099
- return tslib_1.__generator(this, function (_a) {
2174
+ return __generator(this, function (_a) {
2100
2175
  switch (_a.label) {
2101
2176
  case 0:
2102
2177
  if (!this._config.identityPoolId && !this._config.userPoolId) {
@@ -2161,9 +2236,9 @@ var AuthClass = /** @class */ (function () {
2161
2236
  * @param {String} URL - optional parameter for customers to pass in the response URL
2162
2237
  */
2163
2238
  AuthClass.prototype._handleAuthResponse = function (URL) {
2164
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2239
+ return __awaiter(this, void 0, void 0, function () {
2165
2240
  var currentUrl, hasCodeOrError, hasTokenOrError, _a, accessToken, idToken, refreshToken, state, session, credentials, isCustomStateIncluded, currentUser, customState, err_2;
2166
- return tslib_1.__generator(this, function (_b) {
2241
+ return __generator(this, function (_b) {
2167
2242
  switch (_b.label) {
2168
2243
  case 0:
2169
2244
  if (this.oAuthFlowInProgress) {
@@ -2183,7 +2258,7 @@ var AuthClass = /** @class */ (function () {
2183
2258
  .split('&')
2184
2259
  .map(function (entry) { return entry.split('='); })
2185
2260
  .find(function (_a) {
2186
- var _b = tslib_1.__read(_a, 1), k = _b[0];
2261
+ var _b = __read(_a, 1), k = _b[0];
2187
2262
  return k === 'code' || k === 'error';
2188
2263
  });
2189
2264
  hasTokenOrError = !!(url_1.parse(currentUrl).hash || '#')
@@ -2191,7 +2266,7 @@ var AuthClass = /** @class */ (function () {
2191
2266
  .split('&')
2192
2267
  .map(function (entry) { return entry.split('='); })
2193
2268
  .find(function (_a) {
2194
- var _b = tslib_1.__read(_a, 1), k = _b[0];
2269
+ var _b = __read(_a, 1), k = _b[0];
2195
2270
  return k === 'access_token' || k === 'error';
2196
2271
  });
2197
2272
  if (!(hasCodeOrError || hasTokenOrError)) return [3 /*break*/, 7];
@@ -2326,9 +2401,9 @@ var AuthClass = /** @class */ (function () {
2326
2401
  return Promise.reject(new Errors_1.NoUserPoolError(type));
2327
2402
  };
2328
2403
  AuthClass.prototype.rememberDevice = function () {
2329
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2404
+ return __awaiter(this, void 0, void 0, function () {
2330
2405
  var currUser, error_2;
2331
- return tslib_1.__generator(this, function (_a) {
2406
+ return __generator(this, function (_a) {
2332
2407
  switch (_a.label) {
2333
2408
  case 0:
2334
2409
  _a.trys.push([0, 2, , 3]);
@@ -2365,9 +2440,9 @@ var AuthClass = /** @class */ (function () {
2365
2440
  });
2366
2441
  };
2367
2442
  AuthClass.prototype.forgetDevice = function () {
2368
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2443
+ return __awaiter(this, void 0, void 0, function () {
2369
2444
  var currUser, error_3;
2370
- return tslib_1.__generator(this, function (_a) {
2445
+ return __generator(this, function (_a) {
2371
2446
  switch (_a.label) {
2372
2447
  case 0:
2373
2448
  _a.trys.push([0, 2, , 3]);
@@ -2404,9 +2479,9 @@ var AuthClass = /** @class */ (function () {
2404
2479
  });
2405
2480
  };
2406
2481
  AuthClass.prototype.fetchDevices = function () {
2407
- return tslib_1.__awaiter(this, void 0, void 0, function () {
2482
+ return __awaiter(this, void 0, void 0, function () {
2408
2483
  var currUser, error_4;
2409
- return tslib_1.__generator(this, function (_a) {
2484
+ return __generator(this, function (_a) {
2410
2485
  switch (_a.label) {
2411
2486
  case 0:
2412
2487
  _a.trys.push([0, 2, , 3]);