@aws-amplify/datastore 3.7.5-unstable.9 → 3.7.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.7.5](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.4...@aws-amplify/datastore@3.7.5) (2022-01-27)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/datastore
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.7.4](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.3...@aws-amplify/datastore@3.7.4) (2022-01-07)
7
15
 
8
16
  **Note:** Version bump only for package @aws-amplify/datastore
@@ -61913,6 +61913,119 @@ function () {
61913
61913
  });
61914
61914
  });
61915
61915
  };
61916
+ /**
61917
+ * Delete the current authenticated user
61918
+ * @return {Promise}
61919
+ **/
61920
+ //TODO: Check return type void
61921
+
61922
+
61923
+ AuthClass.prototype.deleteUser = function () {
61924
+ return __awaiter(this, void 0, void 0, function () {
61925
+ var e_5, isSignedInHostedUI;
61926
+
61927
+ var _this = this;
61928
+
61929
+ return __generator(this, function (_a) {
61930
+ switch (_a.label) {
61931
+ case 0:
61932
+ _a.trys.push([0, 2,, 3]);
61933
+
61934
+ return [4
61935
+ /*yield*/
61936
+ , this._storageSync];
61937
+
61938
+ case 1:
61939
+ _a.sent();
61940
+
61941
+ return [3
61942
+ /*break*/
61943
+ , 3];
61944
+
61945
+ case 2:
61946
+ e_5 = _a.sent();
61947
+ logger.debug('Failed to sync cache info into memory', e_5);
61948
+ throw new Error(e_5);
61949
+
61950
+ case 3:
61951
+ isSignedInHostedUI = this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
61952
+ return [2
61953
+ /*return*/
61954
+ , new Promise(function (res, rej) {
61955
+ return __awaiter(_this, void 0, void 0, function () {
61956
+ var user_1;
61957
+
61958
+ var _this = this;
61959
+
61960
+ return __generator(this, function (_a) {
61961
+ if (this.userPool) {
61962
+ user_1 = this.userPool.getCurrentUser();
61963
+
61964
+ if (!user_1) {
61965
+ logger.debug('Failed to get user from user pool');
61966
+ return [2
61967
+ /*return*/
61968
+ , rej(new Error('No current user.'))];
61969
+ } else {
61970
+ user_1.getSession(function (err, session) {
61971
+ return __awaiter(_this, void 0, void 0, function () {
61972
+ var _this = this;
61973
+
61974
+ return __generator(this, function (_a) {
61975
+ if (err) {
61976
+ logger.debug('Failed to get the user session', err);
61977
+ return [2
61978
+ /*return*/
61979
+ , rej(err)];
61980
+ } else {
61981
+ user_1.deleteUser(function (err, result) {
61982
+ if (err) {
61983
+ rej(err);
61984
+ } else {
61985
+ dispatchAuthEvent('userDeleted', result, 'The authenticated user has been deleted.');
61986
+ user_1.signOut();
61987
+ _this.user = null;
61988
+
61989
+ try {
61990
+ _this.cleanCachedItems(); // clean aws credentials
61991
+
61992
+ } catch (e) {
61993
+ // TODO: change to rejects in refactor
61994
+ logger.debug('failed to clear cached items');
61995
+ }
61996
+
61997
+ if (isSignedInHostedUI) {
61998
+ _this.oAuthSignOutRedirect(res, rej);
61999
+ } else {
62000
+ dispatchAuthEvent('signOut', _this.user, "A user has been signed out");
62001
+ res(result);
62002
+ }
62003
+ }
62004
+ });
62005
+ }
62006
+
62007
+ return [2
62008
+ /*return*/
62009
+ ];
62010
+ });
62011
+ });
62012
+ });
62013
+ }
62014
+ } else {
62015
+ logger.debug('no Congito User pool');
62016
+ rej(new Error('Cognito User pool does not exist'));
62017
+ }
62018
+
62019
+ return [2
62020
+ /*return*/
62021
+ ];
62022
+ });
62023
+ });
62024
+ })];
62025
+ }
62026
+ });
62027
+ });
62028
+ };
61916
62029
  /**
61917
62030
  * Update an authenticated users' attributes
61918
62031
  * @param {CognitoUser} - The currently logged in user object
@@ -62184,7 +62297,7 @@ function () {
62184
62297
 
62185
62298
  AuthClass.prototype.currentAuthenticatedUser = function (params) {
62186
62299
  return __awaiter(this, void 0, void 0, function () {
62187
- var federatedUser, e_5, federatedInfo, user, e_6;
62300
+ var federatedUser, e_6, federatedInfo, user, e_7;
62188
62301
  return __generator(this, function (_a) {
62189
62302
  switch (_a.label) {
62190
62303
  case 0:
@@ -62207,9 +62320,9 @@ function () {
62207
62320
  , 4];
62208
62321
 
62209
62322
  case 3:
62210
- e_5 = _a.sent();
62211
- logger.debug('Failed to sync cache info into memory', e_5);
62212
- throw e_5;
62323
+ e_6 = _a.sent();
62324
+ logger.debug('Failed to sync cache info into memory', e_6);
62325
+ throw e_6;
62213
62326
 
62214
62327
  case 4:
62215
62328
  try {
@@ -62252,13 +62365,13 @@ function () {
62252
62365
  , 9];
62253
62366
 
62254
62367
  case 8:
62255
- e_6 = _a.sent();
62368
+ e_7 = _a.sent();
62256
62369
 
62257
- if (e_6 === 'No userPool') {
62370
+ if (e_7 === 'No userPool') {
62258
62371
  logger.error('Cannot get the current user because the user pool is missing. ' + 'Please make sure the Auth module is configured with a valid Cognito User Pool ID');
62259
62372
  }
62260
62373
 
62261
- logger.debug('The user is not authenticated by the error', e_6);
62374
+ logger.debug('The user is not authenticated by the error', e_7);
62262
62375
  return [2
62263
62376
  /*return*/
62264
62377
  , Promise.reject('The user is not authenticated')];
@@ -62343,7 +62456,7 @@ function () {
62343
62456
 
62344
62457
  AuthClass.prototype.currentUserCredentials = function () {
62345
62458
  return __awaiter(this, void 0, void 0, function () {
62346
- var e_7, federatedInfo;
62459
+ var e_8, federatedInfo;
62347
62460
 
62348
62461
  var _this = this;
62349
62462
 
@@ -62368,9 +62481,9 @@ function () {
62368
62481
  , 4];
62369
62482
 
62370
62483
  case 3:
62371
- e_7 = _a.sent();
62372
- logger.debug('Failed to sync cache info into memory', e_7);
62373
- throw e_7;
62484
+ e_8 = _a.sent();
62485
+ logger.debug('Failed to sync cache info into memory', e_8);
62486
+ throw e_8;
62374
62487
 
62375
62488
  case 4:
62376
62489
  federatedInfo = null;
@@ -62485,7 +62598,7 @@ function () {
62485
62598
 
62486
62599
  AuthClass.prototype.cognitoIdentitySignOut = function (opts, user) {
62487
62600
  return __awaiter(this, void 0, void 0, function () {
62488
- var e_8, isSignedInHostedUI;
62601
+ var e_9, isSignedInHostedUI;
62489
62602
 
62490
62603
  var _this = this;
62491
62604
 
@@ -62506,9 +62619,9 @@ function () {
62506
62619
  , 3];
62507
62620
 
62508
62621
  case 2:
62509
- e_8 = _a.sent();
62510
- logger.debug('Failed to sync cache info into memory', e_8);
62511
- throw e_8;
62622
+ e_9 = _a.sent();
62623
+ logger.debug('Failed to sync cache info into memory', e_9);
62624
+ throw e_9;
62512
62625
 
62513
62626
  case 3:
62514
62627
  isSignedInHostedUI = this._oAuthHandler && this._storage.getItem('amplify-signin-with-hostedUI') === 'true';
@@ -62595,7 +62708,7 @@ function () {
62595
62708
 
62596
62709
  AuthClass.prototype.signOut = function (opts) {
62597
62710
  return __awaiter(this, void 0, void 0, function () {
62598
- var e_9, user;
62711
+ var e_10, user;
62599
62712
  return __generator(this, function (_a) {
62600
62713
  switch (_a.label) {
62601
62714
  case 0:
@@ -62613,7 +62726,7 @@ function () {
62613
62726
  , 3];
62614
62727
 
62615
62728
  case 2:
62616
- e_9 = _a.sent();
62729
+ e_10 = _a.sent();
62617
62730
  logger.debug('failed to clear cached items');
62618
62731
  return [3
62619
62732
  /*break*/
@@ -62814,7 +62927,7 @@ function () {
62814
62927
 
62815
62928
  AuthClass.prototype.currentUserInfo = function () {
62816
62929
  return __awaiter(this, void 0, void 0, function () {
62817
- var source, user, attributes, userAttrs, credentials, e_10, info, err_1, user;
62930
+ var source, user, attributes, userAttrs, credentials, e_11, info, err_1, user;
62818
62931
  return __generator(this, function (_a) {
62819
62932
  switch (_a.label) {
62820
62933
  case 0:
@@ -62866,8 +62979,8 @@ function () {
62866
62979
  , 7];
62867
62980
 
62868
62981
  case 6:
62869
- e_10 = _a.sent();
62870
- logger.debug('Failed to retrieve credentials while getting current user info', e_10);
62982
+ e_11 = _a.sent();
62983
+ logger.debug('Failed to retrieve credentials while getting current user info', e_11);
62871
62984
  return [3
62872
62985
  /*break*/
62873
62986
  , 7];