parse 4.2.0-alpha.6 → 4.2.0-alpha.8

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/parse.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.2.0-alpha.6
2
+ * Parse JavaScript SDK v4.2.0-alpha.8
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -538,7 +538,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
538
538
  SERVER_AUTH_TOKEN: null,
539
539
  LIVEQUERY_SERVER_URL: null,
540
540
  ENCRYPTED_KEY: null,
541
- VERSION: 'js' + "4.2.0-alpha.6",
541
+ VERSION: 'js' + "4.2.0-alpha.8",
542
542
  APPLICATION_ID: null,
543
543
  JAVASCRIPT_KEY: null,
544
544
  MASTER_KEY: null,
@@ -3611,7 +3611,9 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
3611
3611
  function nestedSet(obj, key, value) {
3612
3612
  var path = key.split('.');
3613
3613
  for (var i = 0; i < path.length - 1; i++) {
3614
- if (!(path[i] in obj)) obj[path[i]] = {};
3614
+ if (!(path[i] in obj)) {
3615
+ obj[path[i]] = {};
3616
+ }
3615
3617
  obj = obj[path[i]];
3616
3618
  }
3617
3619
  if (typeof value === 'undefined') {
@@ -4240,7 +4242,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
4240
4242
  var _distance = point.radiansTo(centerPoint);
4241
4243
  return _distance <= maxDistance;
4242
4244
  }
4243
- break;
4245
+ return false;
4244
4246
  }
4245
4247
  case '$geoIntersects':
4246
4248
  {
@@ -9024,7 +9026,7 @@ var ParseObject = /*#__PURE__*/function () {
9024
9026
  /**
9025
9027
  * Returns the ACL for this object.
9026
9028
  *
9027
- * @returns {Parse.ACL} An instance of Parse.ACL.
9029
+ * @returns {Parse.ACL|null} An instance of Parse.ACL.
9028
9030
  * @see Parse.Object#get
9029
9031
  */
9030
9032
  }, {
@@ -15163,8 +15165,14 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15163
15165
  throw new Error('Invalid type: authData field should be an object');
15164
15166
  }
15165
15167
  authData[authType] = options.authData;
15168
+ var oldAnonymousData = authData.anonymous;
15169
+ this.stripAnonymity();
15166
15170
  var controller = _CoreManager.default.getUserController();
15167
- return controller.linkWith(this, authData, saveOpts);
15171
+ return controller.linkWith(this, authData, saveOpts).catch(function (e) {
15172
+ delete authData[authType];
15173
+ _this2.restoreAnonimity(oldAnonymousData);
15174
+ throw e;
15175
+ });
15168
15176
  } else {
15169
15177
  return new _promise.default(function (resolve, reject) {
15170
15178
  provider.authenticate({
@@ -15395,6 +15403,24 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15395
15403
  }
15396
15404
  return isCurrentAsync;
15397
15405
  }()
15406
+ }, {
15407
+ key: "stripAnonymity",
15408
+ value: function () {
15409
+ var authData = this.get('authData');
15410
+ if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15411
+ // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15412
+ authData.anonymous = null;
15413
+ }
15414
+ }
15415
+ }, {
15416
+ key: "restoreAnonimity",
15417
+ value: function (anonymousData /*: any*/) {
15418
+ if (anonymousData) {
15419
+ var authData = this.get('authData');
15420
+ authData.anonymous = anonymousData;
15421
+ }
15422
+ }
15423
+
15398
15424
  /**
15399
15425
  * Returns get("username").
15400
15426
  *
@@ -15418,12 +15444,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15418
15444
  }, {
15419
15445
  key: "setUsername",
15420
15446
  value: function (username /*: string*/) {
15421
- // Strip anonymity
15422
- var authData = this.get('authData');
15423
- if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15424
- // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15425
- authData.anonymous = null;
15426
- }
15447
+ this.stripAnonymity();
15427
15448
  this.set('username', username);
15428
15449
  }
15429
15450
 
@@ -15552,6 +15573,9 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15552
15573
  if (options.hasOwnProperty('usePost')) {
15553
15574
  loginOptions.usePost = options.usePost;
15554
15575
  }
15576
+ if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
15577
+ loginOptions.context = options.context;
15578
+ }
15555
15579
  var controller = _CoreManager.default.getUserController();
15556
15580
  return controller.logIn(this, loginOptions);
15557
15581
  }
@@ -18612,7 +18636,10 @@ function _regeneratorRuntime() {
18612
18636
  if ("executing" === state) throw new Error("Generator is already running");
18613
18637
  if ("completed" === state) {
18614
18638
  if ("throw" === method) throw arg;
18615
- return doneResult();
18639
+ return {
18640
+ value: void 0,
18641
+ done: !0
18642
+ };
18616
18643
  }
18617
18644
  for (context.method = method, context.arg = arg;;) {
18618
18645
  var delegate = context.delegate;
@@ -18666,7 +18693,7 @@ function _regeneratorRuntime() {
18666
18693
  }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
18667
18694
  }
18668
18695
  function values(iterable) {
18669
- if (iterable) {
18696
+ if (iterable || "" === iterable) {
18670
18697
  var iteratorMethod = iterable[iteratorSymbol];
18671
18698
  if (iteratorMethod) return iteratorMethod.call(iterable);
18672
18699
  if ("function" == typeof iterable.next) return iterable;
@@ -18679,15 +18706,7 @@ function _regeneratorRuntime() {
18679
18706
  return next.next = next;
18680
18707
  }
18681
18708
  }
18682
- return {
18683
- next: doneResult
18684
- };
18685
- }
18686
- function doneResult() {
18687
- return {
18688
- value: undefined,
18689
- done: !0
18690
- };
18709
+ throw new TypeError(_typeof(iterable) + " is not iterable");
18691
18710
  }
18692
18711
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
18693
18712
  value: GeneratorFunctionPrototype,