parse 3.4.2 → 3.4.3-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v3.4.2
2
+ * Parse JavaScript SDK v3.4.3-alpha.3
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -699,7 +699,7 @@ var config
699
699
  SERVER_AUTH_TOKEN: null,
700
700
  LIVEQUERY_SERVER_URL: null,
701
701
  ENCRYPTED_KEY: null,
702
- VERSION: 'js' + "3.4.2",
702
+ VERSION: 'js' + "3.4.3-alpha.3",
703
703
  APPLICATION_ID: null,
704
704
  JAVASCRIPT_KEY: null,
705
705
  MASTER_KEY: null,
@@ -2772,7 +2772,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
2772
2772
 
2773
2773
  delete data.object.__type;
2774
2774
 
2775
- var parseObject = _ParseObject.default.fromJSON(data.object, override);
2775
+ var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
2776
2776
 
2777
2777
  if (data.original) {
2778
2778
  subscription.emit(data.op, parseObject, data.original, response);
@@ -8382,6 +8382,8 @@ _Object$defineProperty(exports, "__esModule", {
8382
8382
 
8383
8383
  exports.default = void 0;
8384
8384
 
8385
+ var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
8386
+
8385
8387
  var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
8386
8388
 
8387
8389
  var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
@@ -8398,8 +8400,6 @@ var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/
8398
8400
 
8399
8401
  var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
8400
8402
 
8401
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
8402
-
8403
8403
  var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
8404
8404
 
8405
8405
  var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
@@ -8426,12 +8426,12 @@ function ownKeys(object, enumerableOnly) {
8426
8426
 
8427
8427
  function _objectSpread(target) {
8428
8428
  for (var i = 1; i < arguments.length; i++) {
8429
- var _context5, _context6;
8429
+ var _context8, _context9;
8430
8430
 
8431
8431
  var source = null != arguments[i] ? arguments[i] : {};
8432
- i % 2 ? _forEachInstanceProperty2(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) {
8432
+ i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
8433
8433
  (0, _defineProperty2.default)(target, key, source[key]);
8434
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context6 = ownKeys(Object(source))).call(_context6, function (key) {
8434
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
8435
8435
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
8436
8436
  });
8437
8437
  }
@@ -8471,7 +8471,8 @@ XHR = _dereq_('./Xhr.weapp');
8471
8471
  type: string,
8472
8472
  };*/
8473
8473
 
8474
- var dataUriRegexp = /^data:([a-zA-Z]+\/[-a-zA-Z0-9+.]+)(;charset=[a-zA-Z0-9\-\/]*)?;base64,/;
8474
+ var base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
8475
+ var dataUriRegex = new RegExp("^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(".concat(base64Regex.source, ")*$"), 'i');
8475
8476
 
8476
8477
  function b64Digit(number
8477
8478
  /*: number*/
@@ -8585,26 +8586,31 @@ var ParseFile = /*#__PURE__*/function () {
8585
8586
  type: specifiedType
8586
8587
  };
8587
8588
  } else if (data && typeof data.base64 === 'string') {
8588
- var base64 = data.base64;
8589
- var commaIndex = (0, _indexOf.default)(base64).call(base64, ',');
8589
+ var _context, _context2, _context3; // Check if data URI or base64 string is valid
8590
8590
 
8591
- if (commaIndex !== -1) {
8592
- var matches = dataUriRegexp.exec((0, _slice.default)(base64).call(base64, 0, commaIndex + 1)); // if data URI with type and charset, there will be 4 matches.
8593
8591
 
8594
- this._data = (0, _slice.default)(base64).call(base64, commaIndex + 1);
8595
- this._source = {
8596
- format: 'base64',
8597
- base64: this._data,
8598
- type: matches[1]
8599
- };
8600
- } else {
8601
- this._data = base64;
8602
- this._source = {
8603
- format: 'base64',
8604
- base64: base64,
8605
- type: specifiedType
8606
- };
8592
+ var validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
8593
+
8594
+ if (!validationRegex.test(data.base64)) {
8595
+ throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
8607
8596
  }
8597
+
8598
+ var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
8599
+
8600
+ var _type = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || ''; // https://tools.ietf.org/html/rfc2397
8601
+ // If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
8602
+ // As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
8603
+
8604
+
8605
+ if (dataUriRegex.test(data.base64)) {
8606
+ _type = _type || 'text/plain';
8607
+ }
8608
+
8609
+ this._source = {
8610
+ format: 'base64',
8611
+ base64: base64,
8612
+ type: _type
8613
+ };
8608
8614
  } else {
8609
8615
  throw new TypeError('Cannot create a Parse.File with that data.');
8610
8616
  }
@@ -8626,20 +8632,20 @@ var ParseFile = /*#__PURE__*/function () {
8626
8632
  var _this = this;
8627
8633
 
8628
8634
  var options, controller, result;
8629
- return _regenerator.default.wrap(function (_context) {
8635
+ return _regenerator.default.wrap(function (_context4) {
8630
8636
  while (1) {
8631
- switch (_context.prev = _context.next) {
8637
+ switch (_context4.prev = _context4.next) {
8632
8638
  case 0:
8633
8639
  if (!this._data) {
8634
- _context.next = 2;
8640
+ _context4.next = 2;
8635
8641
  break;
8636
8642
  }
8637
8643
 
8638
- return _context.abrupt("return", this._data);
8644
+ return _context4.abrupt("return", this._data);
8639
8645
 
8640
8646
  case 2:
8641
8647
  if (this._url) {
8642
- _context.next = 4;
8648
+ _context4.next = 4;
8643
8649
  break;
8644
8650
  }
8645
8651
 
@@ -8652,17 +8658,17 @@ var ParseFile = /*#__PURE__*/function () {
8652
8658
  }
8653
8659
  };
8654
8660
  controller = _CoreManager.default.getFileController();
8655
- _context.next = 8;
8661
+ _context4.next = 8;
8656
8662
  return controller.download(this._url, options);
8657
8663
 
8658
8664
  case 8:
8659
- result = _context.sent;
8665
+ result = _context4.sent;
8660
8666
  this._data = result.base64;
8661
- return _context.abrupt("return", this._data);
8667
+ return _context4.abrupt("return", this._data);
8662
8668
 
8663
8669
  case 11:
8664
8670
  case "end":
8665
- return _context.stop();
8671
+ return _context4.stop();
8666
8672
  }
8667
8673
  }
8668
8674
  }, _callee, this);
@@ -8918,9 +8924,9 @@ var ParseFile = /*#__PURE__*/function () {
8918
8924
  var _this4 = this;
8919
8925
 
8920
8926
  if (metadata && (0, _typeof2.default)(metadata) === 'object') {
8921
- var _context2;
8927
+ var _context5;
8922
8928
 
8923
- (0, _forEach.default)(_context2 = (0, _keys.default)(metadata)).call(_context2, function (key) {
8929
+ (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
8924
8930
  _this4.addMetadata(key, metadata[key]);
8925
8931
  });
8926
8932
  }
@@ -8957,9 +8963,9 @@ var ParseFile = /*#__PURE__*/function () {
8957
8963
  var _this5 = this;
8958
8964
 
8959
8965
  if (tags && (0, _typeof2.default)(tags) === 'object') {
8960
- var _context3;
8966
+ var _context6;
8961
8967
 
8962
- (0, _forEach.default)(_context3 = (0, _keys.default)(tags)).call(_context3, function (key) {
8968
+ (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
8963
8969
  _this5.addTag(key, tags[key]);
8964
8970
  });
8965
8971
  }
@@ -9031,19 +9037,19 @@ var DefaultController = {
9031
9037
  ) {
9032
9038
  var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
9033
9039
 
9034
- return _regenerator.default.wrap(function (_context4) {
9040
+ return _regenerator.default.wrap(function (_context7) {
9035
9041
  while (1) {
9036
- switch (_context4.prev = _context4.next) {
9042
+ switch (_context7.prev = _context7.next) {
9037
9043
  case 0:
9038
9044
  if (!(source.format !== 'file')) {
9039
- _context4.next = 2;
9045
+ _context7.next = 2;
9040
9046
  break;
9041
9047
  }
9042
9048
 
9043
9049
  throw new Error('saveFile can only be used with File-type sources.');
9044
9050
 
9045
9051
  case 2:
9046
- _context4.next = 4;
9052
+ _context7.next = 4;
9047
9053
  return new _promise.default(function (res, rej) {
9048
9054
  // eslint-disable-next-line no-undef
9049
9055
  var reader = new FileReader();
@@ -9060,7 +9066,7 @@ var DefaultController = {
9060
9066
  });
9061
9067
 
9062
9068
  case 4:
9063
- base64Data = _context4.sent; // we only want the data after the comma
9069
+ base64Data = _context7.sent; // we only want the data after the comma
9064
9070
  // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
9065
9071
 
9066
9072
  _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
@@ -9072,15 +9078,15 @@ var DefaultController = {
9072
9078
  base64: data,
9073
9079
  type: source.type || (source.file ? source.file.type : null)
9074
9080
  };
9075
- _context4.next = 10;
9081
+ _context7.next = 10;
9076
9082
  return DefaultController.saveBase64(name, newSource, options);
9077
9083
 
9078
9084
  case 10:
9079
- return _context4.abrupt("return", _context4.sent);
9085
+ return _context7.abrupt("return", _context7.sent);
9080
9086
 
9081
9087
  case 11:
9082
9088
  case "end":
9083
- return _context4.stop();
9089
+ return _context7.stop();
9084
9090
  }
9085
9091
  }
9086
9092
  }, _callee2);
@@ -18137,6 +18143,8 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
18137
18143
  )
18138
18144
  /*: ParseObject | boolean*/
18139
18145
  {
18146
+ this._validateName(name);
18147
+
18140
18148
  return this.set('name', name, options);
18141
18149
  }
18142
18150
  /**
@@ -18177,6 +18185,17 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
18177
18185
  {
18178
18186
  return this.relation('roles');
18179
18187
  }
18188
+ }, {
18189
+ key: "_validateName",
18190
+ value: function (newName) {
18191
+ if (typeof newName !== 'string') {
18192
+ throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
18193
+ }
18194
+
18195
+ if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
18196
+ throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
18197
+ }
18198
+ }
18180
18199
  }, {
18181
18200
  key: "validate",
18182
18201
  value: function (attrs
@@ -18202,12 +18221,10 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
18202
18221
  return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
18203
18222
  }
18204
18223
 
18205
- if (typeof newName !== 'string') {
18206
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
18207
- }
18208
-
18209
- if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
18210
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
18224
+ try {
18225
+ this._validateName(newName);
18226
+ } catch (e) {
18227
+ return e;
18211
18228
  }
18212
18229
  }
18213
18230
 
@@ -20390,7 +20407,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
20390
20407
  * Request an email verification.
20391
20408
  *
20392
20409
  * @param {string} email The email address associated with the user that
20393
- * forgot their password.
20410
+ * needs to verify their email.
20394
20411
  * @param {object} options
20395
20412
  * @static
20396
20413
  * @returns {Promise}