parse 6.2.0-alpha.2 → 7.0.0-alpha.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.
- package/dist/parse.js +58692 -26593
- package/dist/parse.min.js +1 -14
- package/dist/parse.weapp.js +58735 -26628
- package/dist/parse.weapp.min.js +1 -14
- package/index.js +1 -1
- package/lib/browser/CoreManager.js +3 -4
- package/lib/browser/ObjectStateMutations.js +51 -9
- package/lib/browser/Parse.js +42 -44
- package/lib/browser/ParseFile.js +72 -52
- package/lib/browser/ParseObject.js +31 -28
- package/lib/browser/ParseOp.js +2 -2
- package/lib/browser/ParseQuery.js +14 -14
- package/lib/browser/RESTController.js +153 -129
- package/lib/browser/SingleInstanceStateController.js +28 -27
- package/lib/browser/UniqueInstanceStateController.js +19 -23
- package/lib/browser/Xhr.weapp.js +62 -102
- package/lib/browser/decode.js +8 -1
- package/lib/browser/encode.js +9 -1
- package/lib/browser/isDangerousKey.js +29 -0
- package/lib/node/CoreManager.js +3 -4
- package/lib/node/ObjectStateMutations.js +50 -9
- package/lib/node/Parse.js +43 -47
- package/lib/node/ParseFile.js +73 -68
- package/lib/node/ParseObject.js +28 -27
- package/lib/node/RESTController.js +151 -128
- package/lib/node/SingleInstanceStateController.js +26 -28
- package/lib/node/UniqueInstanceStateController.js +19 -24
- package/lib/node/Xhr.weapp.js +58 -81
- package/lib/node/decode.js +8 -1
- package/lib/node/encode.js +9 -1
- package/lib/node/isDangerousKey.js +25 -0
- package/lib/react-native/CoreManager.js +3 -4
- package/lib/react-native/ObjectStateMutations.js +40 -9
- package/lib/react-native/Parse.js +25 -37
- package/lib/react-native/ParseFile.js +61 -49
- package/lib/react-native/ParseObject.js +28 -27
- package/lib/react-native/ParseQuery.js +25 -25
- package/lib/react-native/RESTController.js +185 -150
- package/lib/react-native/SingleInstanceStateController.js +23 -28
- package/lib/react-native/UniqueInstanceStateController.js +19 -24
- package/lib/react-native/Xhr.weapp.js +63 -95
- package/lib/react-native/decode.js +7 -1
- package/lib/react-native/encode.js +7 -1
- package/lib/react-native/isDangerousKey.js +17 -0
- package/lib/weapp/CoreManager.js +3 -4
- package/lib/weapp/ObjectStateMutations.js +51 -9
- package/lib/weapp/Parse.js +40 -44
- package/lib/weapp/ParseFile.js +72 -53
- package/lib/weapp/ParseObject.js +31 -28
- package/lib/weapp/ParseOp.js +2 -2
- package/lib/weapp/ParseQuery.js +14 -14
- package/lib/weapp/RESTController.js +154 -130
- package/lib/weapp/SingleInstanceStateController.js +28 -27
- package/lib/weapp/UniqueInstanceStateController.js +19 -23
- package/lib/weapp/Xhr.weapp.js +62 -102
- package/lib/weapp/decode.js +8 -1
- package/lib/weapp/encode.js +9 -1
- package/lib/weapp/isDangerousKey.js +29 -0
- package/node.js +1 -1
- package/package.json +33 -35
- package/react-native.js +1 -1
- package/types/Parse.d.ts +16 -10
- package/types/ParseFile.d.ts +19 -4
- package/types/ParseObject.d.ts +1 -1
- package/types/RESTController.d.ts +2 -7
- package/types/SingleInstanceStateController.d.ts +3 -3
- package/types/Xhr.weapp.d.ts +1 -29
- package/types/isDangerousKey.d.ts +7 -0
- package/weapp.js +1 -1
package/lib/browser/Xhr.weapp.js
CHANGED
|
@@ -5,108 +5,68 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
5
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.onreadystatechange = () => {};
|
|
50
|
-
this.requestTask = null;
|
|
51
|
-
}
|
|
52
|
-
getAllResponseHeaders() {
|
|
53
|
-
let header = '';
|
|
54
|
-
for (const key in this.responseHeader) {
|
|
55
|
-
header += key + ':' + this.getResponseHeader(key) + '\r\n';
|
|
56
|
-
}
|
|
57
|
-
return header;
|
|
58
|
-
}
|
|
59
|
-
getResponseHeader(key) {
|
|
60
|
-
return this.responseHeader[key];
|
|
61
|
-
}
|
|
62
|
-
setRequestHeader(key, value) {
|
|
63
|
-
this.header[key] = value;
|
|
64
|
-
}
|
|
65
|
-
open(method, url) {
|
|
66
|
-
this.method = method;
|
|
67
|
-
this.url = url;
|
|
68
|
-
}
|
|
69
|
-
abort() {
|
|
70
|
-
if (!this.requestTask) {
|
|
71
|
-
return;
|
|
8
|
+
exports.polyfillFetch = polyfillFetch;
|
|
9
|
+
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
10
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
11
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
12
|
+
/* istanbul ignore file */
|
|
13
|
+
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
function parseResponse(res) {
|
|
16
|
+
var _context;
|
|
17
|
+
let headers = res.header || {};
|
|
18
|
+
headers = (0, _reduce.default)(_context = (0, _keys.default)(headers)).call(_context, (map, key) => {
|
|
19
|
+
map[key.toLowerCase()] = headers[key];
|
|
20
|
+
return map;
|
|
21
|
+
}, {});
|
|
22
|
+
return {
|
|
23
|
+
status: res.statusCode,
|
|
24
|
+
json: () => {
|
|
25
|
+
if (typeof res.data === 'object') {
|
|
26
|
+
return _promise.default.resolve(res.data);
|
|
27
|
+
}
|
|
28
|
+
let json = {};
|
|
29
|
+
try {
|
|
30
|
+
json = JSON.parse(res.data);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error(err);
|
|
33
|
+
}
|
|
34
|
+
return _promise.default.resolve(json);
|
|
35
|
+
},
|
|
36
|
+
headers: {
|
|
37
|
+
keys: () => (0, _keys.default)(headers),
|
|
38
|
+
get: n => headers[n.toLowerCase()],
|
|
39
|
+
has: n => n.toLowerCase() in headers,
|
|
40
|
+
entries: () => {
|
|
41
|
+
const all = [];
|
|
42
|
+
for (const key in headers) {
|
|
43
|
+
if (headers[key]) {
|
|
44
|
+
all.push([key, headers[key]]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return all;
|
|
48
|
+
}
|
|
72
49
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.requestTask = wx.request({
|
|
82
|
-
url: this.url,
|
|
83
|
-
method: this.method,
|
|
84
|
-
data: data,
|
|
85
|
-
header: this.header,
|
|
86
|
-
responseType: this.responseType,
|
|
87
|
-
success: res => {
|
|
88
|
-
this.status = res.statusCode;
|
|
89
|
-
this.response = res.data;
|
|
90
|
-
this.responseHeader = res.header;
|
|
91
|
-
this.responseText = (0, _stringify.default)(res.data);
|
|
92
|
-
this.requestTask = null;
|
|
93
|
-
this.onreadystatechange();
|
|
94
|
-
},
|
|
95
|
-
fail: err => {
|
|
96
|
-
this.requestTask = null;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function polyfillFetch() {
|
|
53
|
+
const typedGlobal = global;
|
|
54
|
+
if (typeof typedGlobal.fetch !== 'function') {
|
|
55
|
+
typedGlobal.fetch = (url, options) => {
|
|
56
|
+
const dataType = url.match(/\.(txt|json|html|txt|csv)/) ? 'text' : 'arraybuffer';
|
|
57
|
+
return new _promise.default((resolve, reject) => {
|
|
97
58
|
// @ts-ignore
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
59
|
+
wx.request({
|
|
60
|
+
url,
|
|
61
|
+
method: options.method || 'GET',
|
|
62
|
+
data: options.body,
|
|
63
|
+
header: options.headers,
|
|
64
|
+
dataType,
|
|
65
|
+
responseType: dataType,
|
|
66
|
+
success: response => resolve(parseResponse(response)),
|
|
67
|
+
fail: error => reject(error)
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
110
71
|
}
|
|
111
|
-
}
|
|
112
|
-
var _default = exports.default = XhrWeapp;
|
|
72
|
+
}
|
package/lib/browser/decode.js
CHANGED
|
@@ -13,6 +13,7 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
13
13
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
14
14
|
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
15
15
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
16
|
+
var _isDangerousKey = require("./isDangerousKey");
|
|
16
17
|
function decode(value) {
|
|
17
18
|
if (value === null || typeof value !== 'object' || value instanceof Date) {
|
|
18
19
|
return value;
|
|
@@ -60,7 +61,13 @@ function decode(value) {
|
|
|
60
61
|
}
|
|
61
62
|
const copy = {};
|
|
62
63
|
for (const k in value) {
|
|
63
|
-
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
65
|
+
// Skip dangerous keys that could pollute prototypes
|
|
66
|
+
if ((0, _isDangerousKey.isDangerousKey)(k)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
copy[k] = decode(value[k]);
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
72
|
return copy;
|
|
66
73
|
}
|
package/lib/browser/encode.js
CHANGED
|
@@ -18,6 +18,7 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
18
18
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
19
19
|
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
20
20
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
21
|
+
var _isDangerousKey = require("./isDangerousKey");
|
|
21
22
|
function encode(value, disallowObjects, forcePointers, seen, offline) {
|
|
22
23
|
const ParseObject = _CoreManager.default.getParseObject();
|
|
23
24
|
if (value instanceof ParseObject) {
|
|
@@ -67,7 +68,14 @@ function encode(value, disallowObjects, forcePointers, seen, offline) {
|
|
|
67
68
|
if (value && typeof value === 'object') {
|
|
68
69
|
const output = {};
|
|
69
70
|
for (const k in value) {
|
|
70
|
-
|
|
71
|
+
// Only iterate over own properties
|
|
72
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
73
|
+
// Skip dangerous keys that could pollute prototypes
|
|
74
|
+
if ((0, _isDangerousKey.isDangerousKey)(k)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
return output;
|
|
73
81
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.isDangerousKey = isDangerousKey;
|
|
9
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
10
|
+
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
11
|
+
/**
|
|
12
|
+
* Check if a property name or path is potentially dangerous for prototype pollution
|
|
13
|
+
* Dangerous keys include: __proto__, constructor, prototype
|
|
14
|
+
* @param key - The property name or dotted path to check
|
|
15
|
+
* @returns true if the key is dangerous, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
function isDangerousKey(key) {
|
|
18
|
+
const dangerousKeys = ["__proto__", "constructor", "prototype"];
|
|
19
|
+
// Check if the key itself is dangerous
|
|
20
|
+
if ((0, _includes.default)(dangerousKeys).call(dangerousKeys, key)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
// Check if any part of a dotted path is dangerous
|
|
24
|
+
if ((0, _includes.default)(key).call(key, ".")) {
|
|
25
|
+
const parts = key.split(".");
|
|
26
|
+
return (0, _some.default)(parts).call(parts, part => (0, _includes.default)(dangerousKeys).call(dangerousKeys, part));
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -12,11 +12,9 @@ const config = {
|
|
|
12
12
|
REQUEST_BATCH_SIZE: 20,
|
|
13
13
|
REQUEST_HEADERS: {},
|
|
14
14
|
SERVER_URL: 'https://api.parse.com/1',
|
|
15
|
-
SERVER_AUTH_TYPE: null,
|
|
16
|
-
SERVER_AUTH_TOKEN: null,
|
|
17
15
|
LIVEQUERY_SERVER_URL: null,
|
|
18
16
|
ENCRYPTED_KEY: null,
|
|
19
|
-
VERSION: 'js' + "
|
|
17
|
+
VERSION: 'js' + "7.0.0-alpha.1",
|
|
20
18
|
APPLICATION_ID: null,
|
|
21
19
|
JAVASCRIPT_KEY: null,
|
|
22
20
|
MAINTENANCE_KEY: null,
|
|
@@ -27,7 +25,8 @@ const config = {
|
|
|
27
25
|
ENCRYPTED_USER: false,
|
|
28
26
|
IDEMPOTENCY: false,
|
|
29
27
|
ALLOW_CUSTOM_OBJECT_ID: false,
|
|
30
|
-
PARSE_ERRORS: []
|
|
28
|
+
PARSE_ERRORS: [],
|
|
29
|
+
NODE_LOGGING: false
|
|
31
30
|
};
|
|
32
31
|
function requireMethods(name, methods, controller) {
|
|
33
32
|
methods.forEach(func => {
|
|
@@ -18,6 +18,7 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
18
18
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
19
19
|
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
20
20
|
var _ParseOp = require("./ParseOp");
|
|
21
|
+
var _isDangerousKey = require("./isDangerousKey");
|
|
21
22
|
function _interopRequireDefault(e) {
|
|
22
23
|
return e && e.__esModule ? e : {
|
|
23
24
|
default: e
|
|
@@ -25,16 +26,24 @@ function _interopRequireDefault(e) {
|
|
|
25
26
|
}
|
|
26
27
|
function defaultState() {
|
|
27
28
|
return {
|
|
28
|
-
serverData:
|
|
29
|
-
pendingOps: [
|
|
30
|
-
objectCache:
|
|
29
|
+
serverData: Object.create(null),
|
|
30
|
+
pendingOps: [Object.create(null)],
|
|
31
|
+
objectCache: Object.create(null),
|
|
31
32
|
tasks: new _TaskQueue.default(),
|
|
32
33
|
existed: false
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
function setServerData(serverData, attributes) {
|
|
36
37
|
for (const attr in attributes) {
|
|
37
|
-
|
|
38
|
+
// Skip properties from prototype chain
|
|
39
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, attr)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// Skip dangerous keys that could pollute prototypes
|
|
43
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (typeof attributes[attr] !== "undefined") {
|
|
38
47
|
serverData[attr] = attributes[attr];
|
|
39
48
|
} else {
|
|
40
49
|
delete serverData[attr];
|
|
@@ -42,6 +51,10 @@ function setServerData(serverData, attributes) {
|
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
53
|
function setPendingOp(pendingOps, attr, op) {
|
|
54
|
+
// Skip dangerous keys that could pollute prototypes
|
|
55
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
45
58
|
const last = pendingOps.length - 1;
|
|
46
59
|
if (op) {
|
|
47
60
|
pendingOps[last][attr] = op;
|
|
@@ -50,12 +63,12 @@ function setPendingOp(pendingOps, attr, op) {
|
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
function pushPendingState(pendingOps) {
|
|
53
|
-
pendingOps.push(
|
|
66
|
+
pendingOps.push(Object.create(null));
|
|
54
67
|
}
|
|
55
68
|
function popPendingState(pendingOps) {
|
|
56
69
|
const first = pendingOps.shift();
|
|
57
70
|
if (!pendingOps.length) {
|
|
58
|
-
pendingOps[0] =
|
|
71
|
+
pendingOps[0] = Object.create(null);
|
|
59
72
|
}
|
|
60
73
|
return first;
|
|
61
74
|
}
|
|
@@ -63,6 +76,14 @@ function mergeFirstPendingState(pendingOps) {
|
|
|
63
76
|
const first = popPendingState(pendingOps);
|
|
64
77
|
const next = pendingOps[0];
|
|
65
78
|
for (const attr in first) {
|
|
79
|
+
// Skip properties from prototype chain
|
|
80
|
+
if (!Object.prototype.hasOwnProperty.call(first, attr)) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Skip dangerous keys that could pollute prototypes
|
|
84
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
66
87
|
if (next[attr] && first[attr]) {
|
|
67
88
|
const merged = next[attr].mergeWith(first[attr]);
|
|
68
89
|
if (merged) {
|
|
@@ -74,6 +95,10 @@ function mergeFirstPendingState(pendingOps) {
|
|
|
74
95
|
}
|
|
75
96
|
}
|
|
76
97
|
function estimateAttribute(serverData, pendingOps, object, attr) {
|
|
98
|
+
// Skip dangerous keys that could pollute prototypes
|
|
99
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
77
102
|
let value = serverData[attr];
|
|
78
103
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
79
104
|
if (pendingOps[i][attr]) {
|
|
@@ -89,12 +114,20 @@ function estimateAttribute(serverData, pendingOps, object, attr) {
|
|
|
89
114
|
return value;
|
|
90
115
|
}
|
|
91
116
|
function estimateAttributes(serverData, pendingOps, object) {
|
|
92
|
-
const data =
|
|
117
|
+
const data = Object.create(null);
|
|
93
118
|
for (var attr in serverData) {
|
|
94
119
|
data[attr] = serverData[attr];
|
|
95
120
|
}
|
|
96
121
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
97
122
|
for (attr in pendingOps[i]) {
|
|
123
|
+
// Skip properties from prototype chain
|
|
124
|
+
if (!Object.prototype.hasOwnProperty.call(pendingOps[i], attr)) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
// Skip dangerous keys that could pollute prototypes
|
|
128
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
98
131
|
if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
|
|
99
132
|
if (object.id) {
|
|
100
133
|
data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
|
|
@@ -112,7 +145,7 @@ function estimateAttributes(serverData, pendingOps, object) {
|
|
|
112
145
|
if (!isNaN(nextKey)) {
|
|
113
146
|
object[key] = [];
|
|
114
147
|
} else {
|
|
115
|
-
object[key] =
|
|
148
|
+
object[key] = Object.create(null);
|
|
116
149
|
}
|
|
117
150
|
} else {
|
|
118
151
|
if (Array.isArray(object[key])) {
|
|
@@ -154,7 +187,7 @@ function nestedSet(obj, key, value) {
|
|
|
154
187
|
if (!isNaN(nextPath)) {
|
|
155
188
|
obj[path] = [];
|
|
156
189
|
} else {
|
|
157
|
-
obj[path] =
|
|
190
|
+
obj[path] = Object.create(null);
|
|
158
191
|
}
|
|
159
192
|
}
|
|
160
193
|
obj = obj[path];
|
|
@@ -168,6 +201,14 @@ function nestedSet(obj, key, value) {
|
|
|
168
201
|
function commitServerChanges(serverData, objectCache, changes) {
|
|
169
202
|
const ParseObject = _CoreManager.default.getParseObject();
|
|
170
203
|
for (const attr in changes) {
|
|
204
|
+
// Skip properties from prototype chain
|
|
205
|
+
if (!Object.prototype.hasOwnProperty.call(changes, attr)) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
// Skip dangerous keys that could pollute prototypes
|
|
209
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
171
212
|
const val = changes[attr];
|
|
172
213
|
nestedSet(serverData, attr, val);
|
|
173
214
|
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
package/lib/node/Parse.js
CHANGED
|
@@ -42,30 +42,25 @@ var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
|
42
42
|
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
|
|
43
43
|
var _StorageController = _interopRequireDefault(require("./StorageController"));
|
|
44
44
|
var _WebSocketController = _interopRequireDefault(require("./WebSocketController"));
|
|
45
|
-
function
|
|
46
|
-
if ("function"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
65
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
66
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
67
|
-
}
|
|
68
|
-
return n.default = e, t && t.set(e, n), n;
|
|
45
|
+
function _interopRequireWildcard(e, t) {
|
|
46
|
+
if ("function" == typeof WeakMap) var r = new WeakMap(),
|
|
47
|
+
n = new WeakMap();
|
|
48
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
49
|
+
if (!t && e && e.__esModule) return e;
|
|
50
|
+
var o,
|
|
51
|
+
i,
|
|
52
|
+
f = {
|
|
53
|
+
__proto__: null,
|
|
54
|
+
default: e
|
|
55
|
+
};
|
|
56
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
|
57
|
+
if (o = t ? n : r) {
|
|
58
|
+
if (o.has(e)) return o.get(e);
|
|
59
|
+
o.set(e, f);
|
|
60
|
+
}
|
|
61
|
+
for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
|
|
62
|
+
return f;
|
|
63
|
+
})(e, t);
|
|
69
64
|
}
|
|
70
65
|
function _interopRequireDefault(e) {
|
|
71
66
|
return e && e.__esModule ? e : {
|
|
@@ -225,26 +220,6 @@ const Parse = {
|
|
|
225
220
|
get serverURL() {
|
|
226
221
|
return _CoreManager.default.get('SERVER_URL');
|
|
227
222
|
},
|
|
228
|
-
/**
|
|
229
|
-
* @property {string} Parse.serverAuthToken
|
|
230
|
-
* @static
|
|
231
|
-
*/
|
|
232
|
-
set serverAuthToken(value) {
|
|
233
|
-
_CoreManager.default.set('SERVER_AUTH_TOKEN', value);
|
|
234
|
-
},
|
|
235
|
-
get serverAuthToken() {
|
|
236
|
-
return _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
237
|
-
},
|
|
238
|
-
/**
|
|
239
|
-
* @property {string} Parse.serverAuthType
|
|
240
|
-
* @static
|
|
241
|
-
*/
|
|
242
|
-
set serverAuthType(value) {
|
|
243
|
-
_CoreManager.default.set('SERVER_AUTH_TYPE', value);
|
|
244
|
-
},
|
|
245
|
-
get serverAuthType() {
|
|
246
|
-
return _CoreManager.default.get('SERVER_AUTH_TYPE');
|
|
247
|
-
},
|
|
248
223
|
/**
|
|
249
224
|
* @property {ParseLiveQuery} Parse.LiveQuery
|
|
250
225
|
* @static
|
|
@@ -305,6 +280,27 @@ const Parse = {
|
|
|
305
280
|
get allowCustomObjectId() {
|
|
306
281
|
return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
|
|
307
282
|
},
|
|
283
|
+
/**
|
|
284
|
+
* Setting this property to `true` enables enhanced logging for `Parse.Object`
|
|
285
|
+
* in Node.js environments. Specifically, it will log:
|
|
286
|
+
*
|
|
287
|
+
* ```
|
|
288
|
+
* ParseObject: className: <CLASS_NAME>, id: <OBJECT_ID>
|
|
289
|
+
* Attributes: <OBJECT_ATTRIBUTES>
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @warning This should not be enabled in production environments as this may
|
|
293
|
+
* expose sensitive information in server logs.
|
|
294
|
+
*
|
|
295
|
+
* @property {boolean} Parse.nodeLogging
|
|
296
|
+
* @static
|
|
297
|
+
*/
|
|
298
|
+
set nodeLogging(value) {
|
|
299
|
+
_CoreManager.default.set('NODE_LOGGING', value);
|
|
300
|
+
},
|
|
301
|
+
get nodeLogging() {
|
|
302
|
+
return _CoreManager.default.get('NODE_LOGGING');
|
|
303
|
+
},
|
|
308
304
|
_request(...args) {
|
|
309
305
|
return _CoreManager.default.getRESTController().request.apply(null, args);
|
|
310
306
|
},
|
|
@@ -389,13 +385,13 @@ const Parse = {
|
|
|
389
385
|
};
|
|
390
386
|
_CoreManager.default.setRESTController(_RESTController.default);
|
|
391
387
|
Parse.initialize = Parse._initialize;
|
|
392
|
-
Parse.Cloud =
|
|
388
|
+
Parse.Cloud = {
|
|
389
|
+
...(Parse.Cloud || {})
|
|
390
|
+
};
|
|
393
391
|
Parse.Cloud.useMasterKey = function () {
|
|
394
392
|
_CoreManager.default.set('USE_MASTER_KEY', true);
|
|
395
393
|
};
|
|
396
394
|
Parse.Hooks = Hooks;
|
|
397
|
-
|
|
398
395
|
// For legacy requires, of the form `var Parse = require('parse').Parse`
|
|
399
396
|
Parse.Parse = Parse;
|
|
400
|
-
module.exports = Parse;
|
|
401
397
|
var _default = exports.default = Parse;
|