parse 5.2.0-alpha.1 → 5.2.0-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.
- package/dist/parse.js +10519 -15246
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10499 -15371
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +23 -41
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -485
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +258 -624
- package/lib/browser/LocalDatastoreController.default.js +42 -226
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +66 -160
- package/lib/browser/LocalDatastoreUtils.js +4 -7
- package/lib/browser/ObjectStateMutations.js +54 -96
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +44 -60
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -572
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +294 -438
- package/lib/browser/ParseGeoPoint.js +121 -146
- package/lib/browser/ParseHooks.js +23 -25
- package/lib/browser/ParseInstallation.js +225 -367
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2014 -2621
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1708 -2052
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -140
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +941 -1284
- package/lib/browser/Push.js +15 -38
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +31 -43
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +5 -9
- package/lib/node/AnonymousUtils.js +10 -15
- package/lib/node/Cloud.js +11 -11
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +20 -39
- package/lib/node/FacebookUtils.js +4 -8
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +12 -13
- package/lib/node/LiveQueryClient.js +23 -21
- package/lib/node/LiveQuerySubscription.js +6 -7
- package/lib/node/LocalDatastore.js +23 -23
- package/lib/node/LocalDatastoreController.default.js +11 -12
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +25 -21
- package/lib/node/LocalDatastoreUtils.js +4 -7
- package/lib/node/ObjectStateMutations.js +12 -22
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +36 -50
- package/lib/node/ParseACL.js +21 -30
- package/lib/node/ParseCLP.js +38 -40
- package/lib/node/ParseConfig.js +10 -17
- package/lib/node/ParseError.js +460 -461
- package/lib/node/ParseFile.js +27 -47
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +16 -18
- package/lib/node/ParseInstallation.js +10 -11
- package/lib/node/ParseLiveQuery.js +9 -14
- package/lib/node/ParseObject.js +142 -173
- package/lib/node/ParseOp.js +35 -47
- package/lib/node/ParsePolygon.js +14 -20
- package/lib/node/ParseQuery.js +100 -123
- package/lib/node/ParseRelation.js +10 -19
- package/lib/node/ParseRole.js +10 -11
- package/lib/node/ParseSchema.js +29 -42
- package/lib/node/ParseSession.js +10 -11
- package/lib/node/ParseUser.js +76 -87
- package/lib/node/Push.js +7 -12
- package/lib/node/RESTController.js +24 -36
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +14 -19
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +20 -20
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +2 -3
- package/lib/node/UniqueInstanceStateController.js +43 -63
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +4 -4
- package/lib/node/canBeSerialized.js +5 -5
- package/lib/node/decode.js +4 -4
- package/lib/node/encode.js +5 -5
- package/lib/node/equals.js +4 -4
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +5 -5
- package/lib/node/unsavedChildren.js +5 -5
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +8 -7
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +3 -3
- package/lib/react-native/LocalDatastoreController.default.js +1 -2
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +2 -4
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +3 -4
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +77 -87
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +43 -45
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +13 -30
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +24 -49
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +2 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +23 -41
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -485
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +258 -624
- package/lib/weapp/LocalDatastoreController.default.js +42 -226
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
- package/lib/weapp/LocalDatastoreUtils.js +4 -7
- package/lib/weapp/ObjectStateMutations.js +54 -96
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +44 -59
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -572
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +295 -440
- package/lib/weapp/ParseGeoPoint.js +121 -146
- package/lib/weapp/ParseHooks.js +23 -25
- package/lib/weapp/ParseInstallation.js +225 -367
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2014 -2621
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1708 -2052
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -140
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +941 -1284
- package/lib/weapp/Push.js +15 -38
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +31 -43
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +24 -30
package/lib/browser/ParseCLP.js
CHANGED
|
@@ -1,128 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
-
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
5
|
-
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
|
-
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
7
|
-
var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
|
|
8
|
-
var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
9
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
10
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
11
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
12
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
13
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
14
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
15
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
16
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
17
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
18
6
|
value: true
|
|
19
7
|
});
|
|
20
8
|
exports.default = void 0;
|
|
21
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
22
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
23
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
24
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
25
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
26
10
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
27
|
-
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
28
|
-
var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
|
|
29
11
|
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/entries"));
|
|
30
12
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
31
13
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
14
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
15
|
+
var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
|
|
32
16
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
33
17
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
34
18
|
var _ParseRole = _interopRequireDefault(require("./ParseRole"));
|
|
35
19
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (_Object$getOwnPropertySymbols) {
|
|
39
|
-
var symbols = _Object$getOwnPropertySymbols(object);
|
|
40
|
-
enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
41
|
-
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
42
|
-
})), keys.push.apply(keys, symbols);
|
|
43
|
-
}
|
|
44
|
-
return keys;
|
|
45
|
-
}
|
|
46
|
-
function _objectSpread(target) {
|
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
-
var _context3, _context4;
|
|
49
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
50
|
-
i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
|
|
51
|
-
(0, _defineProperty2.default)(target, key, source[key]);
|
|
52
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
|
|
53
|
-
_Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
59
|
-
var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
|
|
60
|
-
if (!it) {
|
|
61
|
-
if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
62
|
-
if (it) o = it;
|
|
63
|
-
var i = 0;
|
|
64
|
-
var F = function () {};
|
|
65
|
-
return {
|
|
66
|
-
s: F,
|
|
67
|
-
n: function () {
|
|
68
|
-
if (i >= o.length) return {
|
|
69
|
-
done: true
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
done: false,
|
|
73
|
-
value: o[i++]
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
e: function (_e) {
|
|
77
|
-
throw _e;
|
|
78
|
-
},
|
|
79
|
-
f: F
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
83
|
-
}
|
|
84
|
-
var normalCompletion = true,
|
|
85
|
-
didErr = false,
|
|
86
|
-
err;
|
|
87
|
-
return {
|
|
88
|
-
s: function () {
|
|
89
|
-
it = it.call(o);
|
|
90
|
-
},
|
|
91
|
-
n: function () {
|
|
92
|
-
var step = it.next();
|
|
93
|
-
normalCompletion = step.done;
|
|
94
|
-
return step;
|
|
95
|
-
},
|
|
96
|
-
e: function (_e2) {
|
|
97
|
-
didErr = true;
|
|
98
|
-
err = _e2;
|
|
99
|
-
},
|
|
100
|
-
f: function () {
|
|
101
|
-
try {
|
|
102
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
103
|
-
} finally {
|
|
104
|
-
if (didErr) throw err;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
110
|
-
var _context2;
|
|
111
|
-
if (!o) return;
|
|
112
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
113
|
-
var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
|
|
114
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
115
|
-
if (n === "Map" || n === "Set") return _Array$from(o);
|
|
116
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
117
|
-
}
|
|
118
|
-
function _arrayLikeToArray(arr, len) {
|
|
119
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
120
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
121
|
-
return arr2;
|
|
122
|
-
}
|
|
123
|
-
/*:: export type PermissionsMap = { writeUserFields?: string[], readUserFields?: string[] } & { [permission: string]: UsersMap };*/
|
|
124
|
-
var PUBLIC_KEY = '*';
|
|
125
|
-
var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default();
|
|
20
|
+
const PUBLIC_KEY = '*';
|
|
21
|
+
const VALID_PERMISSIONS = new _map.default();
|
|
126
22
|
VALID_PERMISSIONS.set('get', {});
|
|
127
23
|
VALID_PERMISSIONS.set('find', {});
|
|
128
24
|
VALID_PERMISSIONS.set('count', {});
|
|
@@ -130,7 +26,7 @@ VALID_PERMISSIONS.set('create', {});
|
|
|
130
26
|
VALID_PERMISSIONS.set('update', {});
|
|
131
27
|
VALID_PERMISSIONS.set('delete', {});
|
|
132
28
|
VALID_PERMISSIONS.set('addField', {});
|
|
133
|
-
|
|
29
|
+
const VALID_PERMISSIONS_EXTENDED = new _map.default();
|
|
134
30
|
VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
135
31
|
|
|
136
32
|
/**
|
|
@@ -225,80 +121,53 @@ VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
|
225
121
|
*
|
|
226
122
|
* @alias Parse.CLP
|
|
227
123
|
*/
|
|
228
|
-
|
|
124
|
+
class ParseCLP {
|
|
229
125
|
/**
|
|
230
126
|
* @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
|
|
231
127
|
*/
|
|
232
|
-
|
|
233
|
-
var _this = this;
|
|
234
|
-
(0, _classCallCheck2.default)(this, ParseCLP);
|
|
128
|
+
constructor(userId) {
|
|
235
129
|
(0, _defineProperty2.default)(this, "permissionsMap", void 0);
|
|
236
130
|
this.permissionsMap = {};
|
|
237
131
|
// Initialize permissions Map with default permissions
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
_this["getRole".concat(action, "Access")] = function (role) {
|
|
272
|
-
return this["get".concat(action, "Access")](this._getRoleName(role));
|
|
273
|
-
};
|
|
274
|
-
_this["setRole".concat(action, "Access")] = function (role, allowed) {
|
|
275
|
-
this["set".concat(action, "Access")](this._getRoleName(role), allowed);
|
|
276
|
-
};
|
|
132
|
+
for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)) {
|
|
133
|
+
this.permissionsMap[operation] = (0, _assign.default)({}, group);
|
|
134
|
+
const action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
|
|
135
|
+
this[`get${action}RequiresAuthentication`] = function () {
|
|
136
|
+
return this._getAccess(operation, 'requiresAuthentication');
|
|
137
|
+
};
|
|
138
|
+
this[`set${action}RequiresAuthentication`] = function (allowed) {
|
|
139
|
+
this._setAccess(operation, 'requiresAuthentication', allowed);
|
|
140
|
+
};
|
|
141
|
+
this[`get${action}PointerFields`] = function () {
|
|
142
|
+
return this._getAccess(operation, 'pointerFields', false);
|
|
143
|
+
};
|
|
144
|
+
this[`set${action}PointerFields`] = function (pointerFields) {
|
|
145
|
+
this._setArrayAccess(operation, 'pointerFields', pointerFields);
|
|
146
|
+
};
|
|
147
|
+
this[`get${action}Access`] = function (entity) {
|
|
148
|
+
return this._getAccess(operation, entity);
|
|
149
|
+
};
|
|
150
|
+
this[`set${action}Access`] = function (entity, allowed) {
|
|
151
|
+
this._setAccess(operation, entity, allowed);
|
|
152
|
+
};
|
|
153
|
+
this[`getPublic${action}Access`] = function () {
|
|
154
|
+
return this[`get${action}Access`](PUBLIC_KEY);
|
|
155
|
+
};
|
|
156
|
+
this[`setPublic${action}Access`] = function (allowed) {
|
|
157
|
+
this[`set${action}Access`](PUBLIC_KEY, allowed);
|
|
158
|
+
};
|
|
159
|
+
this[`getRole${action}Access`] = function (role) {
|
|
160
|
+
return this[`get${action}Access`](this._getRoleName(role));
|
|
161
|
+
};
|
|
162
|
+
this[`setRole${action}Access`] = function (role, allowed) {
|
|
163
|
+
this[`set${action}Access`](this._getRoleName(role), allowed);
|
|
277
164
|
};
|
|
278
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
279
|
-
_loop();
|
|
280
|
-
}
|
|
281
|
-
// Initialize permissions Map with default extended permissions
|
|
282
|
-
} catch (err) {
|
|
283
|
-
_iterator.e(err);
|
|
284
|
-
} finally {
|
|
285
|
-
_iterator.f();
|
|
286
165
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
291
|
-
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
292
|
-
operation = _step2$value[0],
|
|
293
|
-
group = _step2$value[1];
|
|
294
|
-
this.permissionsMap[operation] = (0, _assign.default)({}, group);
|
|
295
|
-
}
|
|
296
|
-
} catch (err) {
|
|
297
|
-
_iterator2.e(err);
|
|
298
|
-
} finally {
|
|
299
|
-
_iterator2.f();
|
|
166
|
+
// Initialize permissions Map with default extended permissions
|
|
167
|
+
for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)) {
|
|
168
|
+
this.permissionsMap[operation] = (0, _assign.default)({}, group);
|
|
300
169
|
}
|
|
301
|
-
if (userId &&
|
|
170
|
+
if (userId && typeof userId === 'object') {
|
|
302
171
|
if (userId instanceof _ParseUser.default) {
|
|
303
172
|
this.setReadAccess(userId, true);
|
|
304
173
|
this.setWriteAccess(userId, true);
|
|
@@ -306,31 +175,29 @@ var ParseCLP = /*#__PURE__*/function () {
|
|
|
306
175
|
this.setRoleReadAccess(userId, true);
|
|
307
176
|
this.setRoleWriteAccess(userId, true);
|
|
308
177
|
} else {
|
|
309
|
-
for (
|
|
178
|
+
for (const permission in userId) {
|
|
310
179
|
var _context;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (typeof
|
|
180
|
+
const users = userId[permission];
|
|
181
|
+
const isValidPermission = !!VALID_PERMISSIONS.get(permission);
|
|
182
|
+
const isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(permission);
|
|
183
|
+
const isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, permission);
|
|
184
|
+
if (typeof permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
|
|
316
185
|
throw new TypeError('Tried to create an CLP with an invalid permission type.');
|
|
317
186
|
}
|
|
318
187
|
if (isValidGroupPermission) {
|
|
319
|
-
if ((0, _every.default)(users).call(users,
|
|
320
|
-
|
|
321
|
-
})) {
|
|
322
|
-
this.permissionsMap[_permission] = users;
|
|
188
|
+
if ((0, _every.default)(users).call(users, pointer => typeof pointer === 'string')) {
|
|
189
|
+
this.permissionsMap[permission] = users;
|
|
323
190
|
continue;
|
|
324
191
|
} else {
|
|
325
192
|
throw new TypeError('Tried to create an CLP with an invalid permission value.');
|
|
326
193
|
}
|
|
327
194
|
}
|
|
328
|
-
for (
|
|
329
|
-
|
|
195
|
+
for (const user in users) {
|
|
196
|
+
const allowed = users[user];
|
|
330
197
|
if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
|
|
331
198
|
throw new TypeError('Tried to create an CLP with an invalid permission value.');
|
|
332
199
|
}
|
|
333
|
-
this.permissionsMap[
|
|
200
|
+
this.permissionsMap[permission][user] = allowed;
|
|
334
201
|
}
|
|
335
202
|
}
|
|
336
203
|
}
|
|
@@ -344,433 +211,366 @@ var ParseCLP = /*#__PURE__*/function () {
|
|
|
344
211
|
*
|
|
345
212
|
* @returns {object}
|
|
346
213
|
*/
|
|
347
|
-
(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
214
|
+
toJSON() {
|
|
215
|
+
return {
|
|
216
|
+
...this.permissionsMap
|
|
217
|
+
};
|
|
218
|
+
}
|
|
352
219
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Returns whether this CLP is equal to another object
|
|
222
|
+
*
|
|
223
|
+
* @param other The other object to compare to
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
*/
|
|
226
|
+
equals(other) {
|
|
227
|
+
if (!(other instanceof ParseCLP)) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
const permissions = (0, _keys.default)(this.permissionsMap);
|
|
231
|
+
const otherPermissions = (0, _keys.default)(other.permissionsMap);
|
|
232
|
+
if (permissions.length !== otherPermissions.length) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
for (const permission in this.permissionsMap) {
|
|
236
|
+
if (!other.permissionsMap[permission]) {
|
|
363
237
|
return false;
|
|
364
238
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (
|
|
239
|
+
const users = (0, _keys.default)(this.permissionsMap[permission]);
|
|
240
|
+
const otherUsers = (0, _keys.default)(other.permissionsMap[permission]);
|
|
241
|
+
if (users.length !== otherUsers.length) {
|
|
368
242
|
return false;
|
|
369
243
|
}
|
|
370
|
-
for (
|
|
371
|
-
if (!other.permissionsMap[
|
|
244
|
+
for (const user in this.permissionsMap[permission]) {
|
|
245
|
+
if (!other.permissionsMap[permission][user]) {
|
|
372
246
|
return false;
|
|
373
247
|
}
|
|
374
|
-
|
|
375
|
-
var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
|
|
376
|
-
if (users.length !== otherUsers.length) {
|
|
248
|
+
if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
|
|
377
249
|
return false;
|
|
378
250
|
}
|
|
379
|
-
for (var user in this.permissionsMap[_permission2]) {
|
|
380
|
-
if (!other.permissionsMap[_permission2][user]) {
|
|
381
|
-
return false;
|
|
382
|
-
}
|
|
383
|
-
if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
|
|
384
|
-
return false;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
251
|
}
|
|
388
|
-
return true;
|
|
389
252
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
if (typeof name !== 'string') {
|
|
399
|
-
throw new TypeError('role must be a Parse.Role or a String');
|
|
400
|
-
}
|
|
401
|
-
return "role:".concat(name);
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
_getRoleName(role) {
|
|
256
|
+
let name = role;
|
|
257
|
+
if (role instanceof _ParseRole.default) {
|
|
258
|
+
// Normalize to the String name
|
|
259
|
+
name = role.getName();
|
|
402
260
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
value: function _parseEntity(entity /*: Entity*/) {
|
|
406
|
-
var userId = entity;
|
|
407
|
-
if (userId instanceof _ParseUser.default) {
|
|
408
|
-
userId = userId.id;
|
|
409
|
-
if (!userId) {
|
|
410
|
-
throw new Error('Cannot get access for a Parse.User without an id.');
|
|
411
|
-
}
|
|
412
|
-
} else if (userId instanceof _ParseRole.default) {
|
|
413
|
-
userId = this._getRoleName(userId);
|
|
414
|
-
}
|
|
415
|
-
if (typeof userId !== 'string') {
|
|
416
|
-
throw new TypeError('userId must be a string.');
|
|
417
|
-
}
|
|
418
|
-
return userId;
|
|
261
|
+
if (typeof name !== 'string') {
|
|
262
|
+
throw new TypeError('role must be a Parse.Role or a String');
|
|
419
263
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (!permissions) {
|
|
429
|
-
if (!allowed) {
|
|
430
|
-
// The user already doesn't have this permission, so no action is needed
|
|
431
|
-
return;
|
|
432
|
-
} else {
|
|
433
|
-
this.permissionsMap[permission][userId] = {};
|
|
434
|
-
}
|
|
264
|
+
return `role:${name}`;
|
|
265
|
+
}
|
|
266
|
+
_parseEntity(entity) {
|
|
267
|
+
let userId = entity;
|
|
268
|
+
if (userId instanceof _ParseUser.default) {
|
|
269
|
+
userId = userId.id;
|
|
270
|
+
if (!userId) {
|
|
271
|
+
throw new Error('Cannot get access for a Parse.User without an id.');
|
|
435
272
|
}
|
|
436
|
-
|
|
437
|
-
|
|
273
|
+
} else if (userId instanceof _ParseRole.default) {
|
|
274
|
+
userId = this._getRoleName(userId);
|
|
275
|
+
}
|
|
276
|
+
if (typeof userId !== 'string') {
|
|
277
|
+
throw new TypeError('userId must be a string.');
|
|
278
|
+
}
|
|
279
|
+
return userId;
|
|
280
|
+
}
|
|
281
|
+
_setAccess(permission, userId, allowed) {
|
|
282
|
+
userId = this._parseEntity(userId);
|
|
283
|
+
if (typeof allowed !== 'boolean') {
|
|
284
|
+
throw new TypeError('allowed must be either true or false.');
|
|
285
|
+
}
|
|
286
|
+
const permissions = this.permissionsMap[permission][userId];
|
|
287
|
+
if (!permissions) {
|
|
288
|
+
if (!allowed) {
|
|
289
|
+
// The user already doesn't have this permission, so no action is needed
|
|
290
|
+
return;
|
|
438
291
|
} else {
|
|
439
|
-
|
|
292
|
+
this.permissionsMap[permission][userId] = {};
|
|
440
293
|
}
|
|
441
294
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
userId = this._parseEntity(userId);
|
|
447
|
-
var permissions = this.permissionsMap[permission][userId];
|
|
448
|
-
if (returnBoolean) {
|
|
449
|
-
if (!permissions) {
|
|
450
|
-
return false;
|
|
451
|
-
}
|
|
452
|
-
return !!this.permissionsMap[permission][userId];
|
|
453
|
-
}
|
|
454
|
-
return permissions;
|
|
295
|
+
if (allowed) {
|
|
296
|
+
this.permissionsMap[permission][userId] = true;
|
|
297
|
+
} else {
|
|
298
|
+
delete this.permissionsMap[permission][userId];
|
|
455
299
|
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
300
|
+
}
|
|
301
|
+
_getAccess(permission, userId) {
|
|
302
|
+
let returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
303
|
+
userId = this._parseEntity(userId);
|
|
304
|
+
const permissions = this.permissionsMap[permission][userId];
|
|
305
|
+
if (returnBoolean) {
|
|
461
306
|
if (!permissions) {
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
|
|
465
|
-
delete this.permissionsMap[permission][userId];
|
|
466
|
-
} else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
|
|
467
|
-
return typeof field === 'string';
|
|
468
|
-
})) {
|
|
469
|
-
this.permissionsMap[permission][userId] = fields;
|
|
470
|
-
} else {
|
|
471
|
-
throw new TypeError('fields must be an array of strings or undefined.');
|
|
307
|
+
return false;
|
|
472
308
|
}
|
|
309
|
+
return !!this.permissionsMap[permission][userId];
|
|
473
310
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
|
|
489
|
-
}
|
|
311
|
+
return permissions;
|
|
312
|
+
}
|
|
313
|
+
_setArrayAccess(permission, userId, fields) {
|
|
314
|
+
userId = this._parseEntity(userId);
|
|
315
|
+
const permissions = this.permissionsMap[permission][userId];
|
|
316
|
+
if (!permissions) {
|
|
317
|
+
this.permissionsMap[permission][userId] = [];
|
|
318
|
+
}
|
|
319
|
+
if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
|
|
320
|
+
delete this.permissionsMap[permission][userId];
|
|
321
|
+
} else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, field => typeof field === 'string')) {
|
|
322
|
+
this.permissionsMap[permission][userId] = fields;
|
|
323
|
+
} else {
|
|
324
|
+
throw new TypeError('fields must be an array of strings or undefined.');
|
|
490
325
|
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
326
|
+
}
|
|
327
|
+
_setGroupPointerPermission(operation, pointerFields) {
|
|
328
|
+
const fields = this.permissionsMap[operation];
|
|
329
|
+
if (!fields) {
|
|
330
|
+
this.permissionsMap[operation] = [];
|
|
331
|
+
}
|
|
332
|
+
if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
|
|
333
|
+
delete this.permissionsMap[operation];
|
|
334
|
+
} else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, field => typeof field === 'string')) {
|
|
335
|
+
this.permissionsMap[operation] = pointerFields;
|
|
336
|
+
} else {
|
|
337
|
+
throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
|
|
495
338
|
}
|
|
339
|
+
}
|
|
340
|
+
_getGroupPointerPermissions(operation) {
|
|
341
|
+
return this.permissionsMap[operation] || [];
|
|
342
|
+
}
|
|
496
343
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
this._setGroupPointerPermission('readUserFields', pointerFields);
|
|
506
|
-
}
|
|
344
|
+
/**
|
|
345
|
+
* Sets user pointer fields to allow permission for get/count/find operations.
|
|
346
|
+
*
|
|
347
|
+
* @param {string[]} pointerFields User pointer fields
|
|
348
|
+
*/
|
|
349
|
+
setReadUserFields(pointerFields) {
|
|
350
|
+
this._setGroupPointerPermission('readUserFields', pointerFields);
|
|
351
|
+
}
|
|
507
352
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return this._getGroupPointerPermissions('readUserFields') || [];
|
|
515
|
-
}
|
|
353
|
+
/**
|
|
354
|
+
* @returns {string[]} User pointer fields
|
|
355
|
+
*/
|
|
356
|
+
getReadUserFields() {
|
|
357
|
+
return this._getGroupPointerPermissions('readUserFields') || [];
|
|
358
|
+
}
|
|
516
359
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
this._setGroupPointerPermission('writeUserFields', pointerFields);
|
|
526
|
-
}
|
|
360
|
+
/**
|
|
361
|
+
* Sets user pointer fields to allow permission for create/delete/update/addField operations
|
|
362
|
+
*
|
|
363
|
+
* @param {string[]} pointerFields User pointer fields
|
|
364
|
+
*/
|
|
365
|
+
setWriteUserFields(pointerFields) {
|
|
366
|
+
this._setGroupPointerPermission('writeUserFields', pointerFields);
|
|
367
|
+
}
|
|
527
368
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return this._getGroupPointerPermissions('writeUserFields') || [];
|
|
535
|
-
}
|
|
369
|
+
/**
|
|
370
|
+
* @returns {string[]} User pointer fields
|
|
371
|
+
*/
|
|
372
|
+
getWriteUserFields() {
|
|
373
|
+
return this._getGroupPointerPermissions('writeUserFields') || [];
|
|
374
|
+
}
|
|
536
375
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
this._setArrayAccess('protectedFields', userId, fields);
|
|
547
|
-
}
|
|
376
|
+
/**
|
|
377
|
+
* Sets whether the given user is allowed to retrieve fields from this class.
|
|
378
|
+
*
|
|
379
|
+
* @param userId An instance of Parse.User or its objectId.
|
|
380
|
+
* @param {string[]} fields fields to be protected
|
|
381
|
+
*/
|
|
382
|
+
setProtectedFields(userId, fields) {
|
|
383
|
+
this._setArrayAccess('protectedFields', userId, fields);
|
|
384
|
+
}
|
|
548
385
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return this._getAccess('protectedFields', userId, false);
|
|
559
|
-
}
|
|
386
|
+
/**
|
|
387
|
+
* Returns array of fields are accessable to this user.
|
|
388
|
+
*
|
|
389
|
+
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
390
|
+
* @returns {string[]}
|
|
391
|
+
*/
|
|
392
|
+
getProtectedFields(userId) {
|
|
393
|
+
return this._getAccess('protectedFields', userId, false);
|
|
394
|
+
}
|
|
560
395
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
this._setAccess('count', userId, allowed);
|
|
573
|
-
}
|
|
396
|
+
/**
|
|
397
|
+
* Sets whether the given user is allowed to read from this class.
|
|
398
|
+
*
|
|
399
|
+
* @param userId An instance of Parse.User or its objectId.
|
|
400
|
+
* @param {boolean} allowed whether that user should have read access.
|
|
401
|
+
*/
|
|
402
|
+
setReadAccess(userId, allowed) {
|
|
403
|
+
this._setAccess('find', userId, allowed);
|
|
404
|
+
this._setAccess('get', userId, allowed);
|
|
405
|
+
this._setAccess('count', userId, allowed);
|
|
406
|
+
}
|
|
574
407
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
|
|
588
|
-
}
|
|
408
|
+
/**
|
|
409
|
+
* Get whether the given user id is *explicitly* allowed to read from this class.
|
|
410
|
+
* Even if this returns false, the user may still be able to access it if
|
|
411
|
+
* getPublicReadAccess returns true or a role that the user belongs to has
|
|
412
|
+
* write access.
|
|
413
|
+
*
|
|
414
|
+
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
415
|
+
* @returns {boolean}
|
|
416
|
+
*/
|
|
417
|
+
getReadAccess(userId) {
|
|
418
|
+
return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
|
|
419
|
+
}
|
|
589
420
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this._setAccess('addField', userId, allowed);
|
|
603
|
-
}
|
|
421
|
+
/**
|
|
422
|
+
* Sets whether the given user id is allowed to write to this class.
|
|
423
|
+
*
|
|
424
|
+
* @param userId An instance of Parse.User or its objectId, or a Parse.Role..
|
|
425
|
+
* @param {boolean} allowed Whether that user should have write access.
|
|
426
|
+
*/
|
|
427
|
+
setWriteAccess(userId, allowed) {
|
|
428
|
+
this._setAccess('create', userId, allowed);
|
|
429
|
+
this._setAccess('update', userId, allowed);
|
|
430
|
+
this._setAccess('delete', userId, allowed);
|
|
431
|
+
this._setAccess('addField', userId, allowed);
|
|
432
|
+
}
|
|
604
433
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
|
|
618
|
-
}
|
|
434
|
+
/**
|
|
435
|
+
* Gets whether the given user id is *explicitly* allowed to write to this class.
|
|
436
|
+
* Even if this returns false, the user may still be able to write it if
|
|
437
|
+
* getPublicWriteAccess returns true or a role that the user belongs to has
|
|
438
|
+
* write access.
|
|
439
|
+
*
|
|
440
|
+
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
441
|
+
* @returns {boolean}
|
|
442
|
+
*/
|
|
443
|
+
getWriteAccess(userId) {
|
|
444
|
+
return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
|
|
445
|
+
}
|
|
619
446
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
629
|
-
}
|
|
447
|
+
/**
|
|
448
|
+
* Sets whether the public is allowed to read from this class.
|
|
449
|
+
*
|
|
450
|
+
* @param {boolean} allowed
|
|
451
|
+
*/
|
|
452
|
+
setPublicReadAccess(allowed) {
|
|
453
|
+
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
454
|
+
}
|
|
630
455
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
return this.getReadAccess(PUBLIC_KEY);
|
|
640
|
-
}
|
|
456
|
+
/**
|
|
457
|
+
* Gets whether the public is allowed to read from this class.
|
|
458
|
+
*
|
|
459
|
+
* @returns {boolean}
|
|
460
|
+
*/
|
|
461
|
+
getPublicReadAccess() {
|
|
462
|
+
return this.getReadAccess(PUBLIC_KEY);
|
|
463
|
+
}
|
|
641
464
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
651
|
-
}
|
|
465
|
+
/**
|
|
466
|
+
* Sets whether the public is allowed to write to this class.
|
|
467
|
+
*
|
|
468
|
+
* @param {boolean} allowed
|
|
469
|
+
*/
|
|
470
|
+
setPublicWriteAccess(allowed) {
|
|
471
|
+
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
472
|
+
}
|
|
652
473
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
return this.getWriteAccess(PUBLIC_KEY);
|
|
662
|
-
}
|
|
474
|
+
/**
|
|
475
|
+
* Gets whether the public is allowed to write to this class.
|
|
476
|
+
*
|
|
477
|
+
* @returns {boolean}
|
|
478
|
+
*/
|
|
479
|
+
getPublicWriteAccess() {
|
|
480
|
+
return this.getWriteAccess(PUBLIC_KEY);
|
|
481
|
+
}
|
|
663
482
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
this.setProtectedFields(PUBLIC_KEY, fields);
|
|
673
|
-
}
|
|
483
|
+
/**
|
|
484
|
+
* Sets whether the public is allowed to protect fields in this class.
|
|
485
|
+
*
|
|
486
|
+
* @param {string[]} fields
|
|
487
|
+
*/
|
|
488
|
+
setPublicProtectedFields(fields) {
|
|
489
|
+
this.setProtectedFields(PUBLIC_KEY, fields);
|
|
490
|
+
}
|
|
674
491
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
return this.getProtectedFields(PUBLIC_KEY);
|
|
684
|
-
}
|
|
492
|
+
/**
|
|
493
|
+
* Gets whether the public is allowed to read fields from this class.
|
|
494
|
+
*
|
|
495
|
+
* @returns {string[]}
|
|
496
|
+
*/
|
|
497
|
+
getPublicProtectedFields() {
|
|
498
|
+
return this.getProtectedFields(PUBLIC_KEY);
|
|
499
|
+
}
|
|
685
500
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return this.getReadAccess(this._getRoleName(role));
|
|
699
|
-
}
|
|
501
|
+
/**
|
|
502
|
+
* Gets whether users belonging to the given role are allowed
|
|
503
|
+
* to read from this class. Even if this returns false, the role may
|
|
504
|
+
* still be able to write it if a parent role has read access.
|
|
505
|
+
*
|
|
506
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
507
|
+
* @returns {boolean} true if the role has read access. false otherwise.
|
|
508
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
509
|
+
*/
|
|
510
|
+
getRoleReadAccess(role) {
|
|
511
|
+
return this.getReadAccess(this._getRoleName(role));
|
|
512
|
+
}
|
|
700
513
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return this.getWriteAccess(this._getRoleName(role));
|
|
714
|
-
}
|
|
514
|
+
/**
|
|
515
|
+
* Gets whether users belonging to the given role are allowed
|
|
516
|
+
* to write to this user. Even if this returns false, the role may
|
|
517
|
+
* still be able to write it if a parent role has write access.
|
|
518
|
+
*
|
|
519
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
520
|
+
* @returns {boolean} true if the role has write access. false otherwise.
|
|
521
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
522
|
+
*/
|
|
523
|
+
getRoleWriteAccess(role) {
|
|
524
|
+
return this.getWriteAccess(this._getRoleName(role));
|
|
525
|
+
}
|
|
715
526
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
this.setReadAccess(this._getRoleName(role), allowed);
|
|
728
|
-
}
|
|
527
|
+
/**
|
|
528
|
+
* Sets whether users belonging to the given role are allowed
|
|
529
|
+
* to read from this class.
|
|
530
|
+
*
|
|
531
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
532
|
+
* @param {boolean} allowed Whether the given role can read this object.
|
|
533
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
534
|
+
*/
|
|
535
|
+
setRoleReadAccess(role, allowed) {
|
|
536
|
+
this.setReadAccess(this._getRoleName(role), allowed);
|
|
537
|
+
}
|
|
729
538
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
this.setWriteAccess(this._getRoleName(role), allowed);
|
|
742
|
-
}
|
|
539
|
+
/**
|
|
540
|
+
* Sets whether users belonging to the given role are allowed
|
|
541
|
+
* to write to this class.
|
|
542
|
+
*
|
|
543
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
544
|
+
* @param {boolean} allowed Whether the given role can write this object.
|
|
545
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
546
|
+
*/
|
|
547
|
+
setRoleWriteAccess(role, allowed) {
|
|
548
|
+
this.setWriteAccess(this._getRoleName(role), allowed);
|
|
549
|
+
}
|
|
743
550
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
return this.getProtectedFields(this._getRoleName(role));
|
|
757
|
-
}
|
|
551
|
+
/**
|
|
552
|
+
* Gets whether users belonging to the given role are allowed
|
|
553
|
+
* to count to this user. Even if this returns false, the role may
|
|
554
|
+
* still be able to count it if a parent role has count access.
|
|
555
|
+
*
|
|
556
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
557
|
+
* @returns {string[]}
|
|
558
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
559
|
+
*/
|
|
560
|
+
getRoleProtectedFields(role) {
|
|
561
|
+
return this.getProtectedFields(this._getRoleName(role));
|
|
562
|
+
}
|
|
758
563
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}]);
|
|
773
|
-
return ParseCLP;
|
|
774
|
-
}();
|
|
775
|
-
var _default = ParseCLP;
|
|
776
|
-
exports.default = _default;
|
|
564
|
+
/**
|
|
565
|
+
* Sets whether users belonging to the given role are allowed
|
|
566
|
+
* to set access field in this class.
|
|
567
|
+
*
|
|
568
|
+
* @param role The name of the role, or a Parse.Role object.
|
|
569
|
+
* @param {string[]} fields Fields to be protected by Role.
|
|
570
|
+
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
571
|
+
*/
|
|
572
|
+
setRoleProtectedFields(role, fields) {
|
|
573
|
+
this.setProtectedFields(this._getRoleName(role), fields);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
var _default = exports.default = ParseCLP;
|