parse 3.4.2 → 3.4.3-beta.1

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.
@@ -24,6 +24,8 @@ _Object$defineProperty(exports, "__esModule", {
24
24
 
25
25
  exports.default = void 0;
26
26
 
27
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
28
+
27
29
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
28
30
 
29
31
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
@@ -40,8 +42,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/
40
42
 
41
43
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
42
44
 
43
- var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
44
-
45
45
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
46
46
 
47
47
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
@@ -68,12 +68,12 @@ function ownKeys(object, enumerableOnly) {
68
68
 
69
69
  function _objectSpread(target) {
70
70
  for (var i = 1; i < arguments.length; i++) {
71
- var _context5, _context6;
71
+ var _context8, _context9;
72
72
 
73
73
  var source = null != arguments[i] ? arguments[i] : {};
74
- i % 2 ? _forEachInstanceProperty2(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) {
74
+ i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
75
75
  (0, _defineProperty2.default)(target, key, source[key]);
76
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context6 = ownKeys(Object(source))).call(_context6, function (key) {
76
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
77
77
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
78
78
  });
79
79
  }
@@ -113,7 +113,8 @@ XHR = require('./Xhr.weapp');
113
113
  type: string,
114
114
  };*/
115
115
 
116
- var dataUriRegexp = /^data:([a-zA-Z]+\/[-a-zA-Z0-9+.]+)(;charset=[a-zA-Z0-9\-\/]*)?;base64,/;
116
+ var base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
117
+ var dataUriRegex = new RegExp("^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(".concat(base64Regex.source, ")*$"), 'i');
117
118
 
118
119
  function b64Digit(number
119
120
  /*: number*/
@@ -227,26 +228,31 @@ var ParseFile = /*#__PURE__*/function () {
227
228
  type: specifiedType
228
229
  };
229
230
  } else if (data && typeof data.base64 === 'string') {
230
- var base64 = data.base64;
231
- var commaIndex = (0, _indexOf.default)(base64).call(base64, ',');
232
-
233
- if (commaIndex !== -1) {
234
- 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.
235
-
236
- this._data = (0, _slice.default)(base64).call(base64, commaIndex + 1);
237
- this._source = {
238
- format: 'base64',
239
- base64: this._data,
240
- type: matches[1]
241
- };
242
- } else {
243
- this._data = base64;
244
- this._source = {
245
- format: 'base64',
246
- base64: base64,
247
- type: specifiedType
248
- };
231
+ var _context, _context2, _context3; // Check if data URI or base64 string is valid
232
+
233
+
234
+ var validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
235
+
236
+ if (!validationRegex.test(data.base64)) {
237
+ throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
249
238
  }
239
+
240
+ var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
241
+
242
+ 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
243
+ // If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
244
+ // As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
245
+
246
+
247
+ if (dataUriRegex.test(data.base64)) {
248
+ _type = _type || 'text/plain';
249
+ }
250
+
251
+ this._source = {
252
+ format: 'base64',
253
+ base64: base64,
254
+ type: _type
255
+ };
250
256
  } else {
251
257
  throw new TypeError('Cannot create a Parse.File with that data.');
252
258
  }
@@ -268,20 +274,20 @@ var ParseFile = /*#__PURE__*/function () {
268
274
  var _this = this;
269
275
 
270
276
  var options, controller, result;
271
- return _regenerator.default.wrap(function (_context) {
277
+ return _regenerator.default.wrap(function (_context4) {
272
278
  while (1) {
273
- switch (_context.prev = _context.next) {
279
+ switch (_context4.prev = _context4.next) {
274
280
  case 0:
275
281
  if (!this._data) {
276
- _context.next = 2;
282
+ _context4.next = 2;
277
283
  break;
278
284
  }
279
285
 
280
- return _context.abrupt("return", this._data);
286
+ return _context4.abrupt("return", this._data);
281
287
 
282
288
  case 2:
283
289
  if (this._url) {
284
- _context.next = 4;
290
+ _context4.next = 4;
285
291
  break;
286
292
  }
287
293
 
@@ -294,17 +300,17 @@ var ParseFile = /*#__PURE__*/function () {
294
300
  }
295
301
  };
296
302
  controller = _CoreManager.default.getFileController();
297
- _context.next = 8;
303
+ _context4.next = 8;
298
304
  return controller.download(this._url, options);
299
305
 
300
306
  case 8:
301
- result = _context.sent;
307
+ result = _context4.sent;
302
308
  this._data = result.base64;
303
- return _context.abrupt("return", this._data);
309
+ return _context4.abrupt("return", this._data);
304
310
 
305
311
  case 11:
306
312
  case "end":
307
- return _context.stop();
313
+ return _context4.stop();
308
314
  }
309
315
  }
310
316
  }, _callee, this);
@@ -560,9 +566,9 @@ var ParseFile = /*#__PURE__*/function () {
560
566
  var _this4 = this;
561
567
 
562
568
  if (metadata && (0, _typeof2.default)(metadata) === 'object') {
563
- var _context2;
569
+ var _context5;
564
570
 
565
- (0, _forEach.default)(_context2 = (0, _keys.default)(metadata)).call(_context2, function (key) {
571
+ (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
566
572
  _this4.addMetadata(key, metadata[key]);
567
573
  });
568
574
  }
@@ -599,9 +605,9 @@ var ParseFile = /*#__PURE__*/function () {
599
605
  var _this5 = this;
600
606
 
601
607
  if (tags && (0, _typeof2.default)(tags) === 'object') {
602
- var _context3;
608
+ var _context6;
603
609
 
604
- (0, _forEach.default)(_context3 = (0, _keys.default)(tags)).call(_context3, function (key) {
610
+ (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
605
611
  _this5.addTag(key, tags[key]);
606
612
  });
607
613
  }
@@ -673,19 +679,19 @@ var DefaultController = {
673
679
  ) {
674
680
  var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
675
681
 
676
- return _regenerator.default.wrap(function (_context4) {
682
+ return _regenerator.default.wrap(function (_context7) {
677
683
  while (1) {
678
- switch (_context4.prev = _context4.next) {
684
+ switch (_context7.prev = _context7.next) {
679
685
  case 0:
680
686
  if (!(source.format !== 'file')) {
681
- _context4.next = 2;
687
+ _context7.next = 2;
682
688
  break;
683
689
  }
684
690
 
685
691
  throw new Error('saveFile can only be used with File-type sources.');
686
692
 
687
693
  case 2:
688
- _context4.next = 4;
694
+ _context7.next = 4;
689
695
  return new _promise.default(function (res, rej) {
690
696
  // eslint-disable-next-line no-undef
691
697
  var reader = new FileReader();
@@ -702,7 +708,7 @@ var DefaultController = {
702
708
  });
703
709
 
704
710
  case 4:
705
- base64Data = _context4.sent; // we only want the data after the comma
711
+ base64Data = _context7.sent; // we only want the data after the comma
706
712
  // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
707
713
 
708
714
  _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
@@ -714,15 +720,15 @@ var DefaultController = {
714
720
  base64: data,
715
721
  type: source.type || (source.file ? source.file.type : null)
716
722
  };
717
- _context4.next = 10;
723
+ _context7.next = 10;
718
724
  return DefaultController.saveBase64(name, newSource, options);
719
725
 
720
726
  case 10:
721
- return _context4.abrupt("return", _context4.sent);
727
+ return _context7.abrupt("return", _context7.sent);
722
728
 
723
729
  case 11:
724
730
  case "end":
725
- return _context4.stop();
731
+ return _context7.stop();
726
732
  }
727
733
  }
728
734
  }, _callee2);
@@ -152,6 +152,8 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
152
152
  )
153
153
  /*: ParseObject | boolean*/
154
154
  {
155
+ this._validateName(name);
156
+
155
157
  return this.set('name', name, options);
156
158
  }
157
159
  /**
@@ -192,6 +194,17 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
192
194
  {
193
195
  return this.relation('roles');
194
196
  }
197
+ }, {
198
+ key: "_validateName",
199
+ value: function (newName) {
200
+ if (typeof newName !== 'string') {
201
+ throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
202
+ }
203
+
204
+ if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
205
+ throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
206
+ }
207
+ }
195
208
  }, {
196
209
  key: "validate",
197
210
  value: function (attrs
@@ -217,12 +230,10 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
217
230
  return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
218
231
  }
219
232
 
220
- if (typeof newName !== 'string') {
221
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
222
- }
223
-
224
- if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
225
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
233
+ try {
234
+ this._validateName(newName);
235
+ } catch (e) {
236
+ return e;
226
237
  }
227
238
  }
228
239
 
@@ -1280,7 +1280,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
1280
1280
  * Request an email verification.
1281
1281
  *
1282
1282
  * @param {string} email The email address associated with the user that
1283
- * forgot their password.
1283
+ * needs to verify their email.
1284
1284
  * @param {object} options
1285
1285
  * @static
1286
1286
  * @returns {Promise}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse",
3
- "version": "3.4.2",
3
+ "version": "3.4.3-beta.1",
4
4
  "description": "The Parse JavaScript SDK",
5
5
  "homepage": "https://parseplatform.org/",
6
6
  "keywords": [
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/runtime-corejs3": "7.17.8",
33
- "@babel/runtime": "7.17.9",
33
+ "@babel/runtime": "7.18.0",
34
34
  "idb-keyval": "6.0.3",
35
35
  "react-native-crypto-js": "1.0.0",
36
36
  "uuid": "3.4.0",
37
- "ws": "7.5.1",
37
+ "ws": "8.6.0",
38
38
  "xmlhttprequest": "1.8.0"
39
39
  },
40
40
  "devDependencies": {
@@ -82,7 +82,7 @@
82
82
  "jsdoc-babel": "0.5.0",
83
83
  "lint-staged": "10.5.3",
84
84
  "metro-react-native-babel-preset": "0.59.0",
85
- "parse-server": "github:parse-community/parse-server#alpha",
85
+ "parse-server": "git+https://github.com/parse-community/parse-server#alpha",
86
86
  "prettier": "2.2.1",
87
87
  "regenerator-runtime": "0.13.5",
88
88
  "semantic-release": "17.4.6",