parse 5.1.1-alpha.1 → 5.2.0-alpha.2
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 +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- 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 +24 -46
- 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 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- 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 +37 -49
- 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 +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- 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 +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- 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 +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- 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 +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- 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/Cloud.js +0 -1
- 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 +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- 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 +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- 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 +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- 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 +8 -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 +24 -46
- 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 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- 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 +37 -49
- 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 +23 -30
package/lib/weapp/ParseCLP.js
CHANGED
|
@@ -1,134 +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
|
-
* @flow
|
|
124
|
-
*/
|
|
125
|
-
/*:: type Entity = Entity;*/
|
|
126
|
-
/*:: type UsersMap = { [userId: string]: boolean | any };*/
|
|
127
|
-
/*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
|
|
128
|
-
var PUBLIC_KEY = '*';
|
|
129
|
-
var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
|
|
130
|
-
/*:: <string, UsersMap>*/
|
|
131
|
-
);
|
|
20
|
+
const PUBLIC_KEY = '*';
|
|
21
|
+
const VALID_PERMISSIONS = new _map.default();
|
|
132
22
|
VALID_PERMISSIONS.set('get', {});
|
|
133
23
|
VALID_PERMISSIONS.set('find', {});
|
|
134
24
|
VALID_PERMISSIONS.set('count', {});
|
|
@@ -136,9 +26,7 @@ VALID_PERMISSIONS.set('create', {});
|
|
|
136
26
|
VALID_PERMISSIONS.set('update', {});
|
|
137
27
|
VALID_PERMISSIONS.set('delete', {});
|
|
138
28
|
VALID_PERMISSIONS.set('addField', {});
|
|
139
|
-
|
|
140
|
-
/*:: <string, UsersMap>*/
|
|
141
|
-
);
|
|
29
|
+
const VALID_PERMISSIONS_EXTENDED = new _map.default();
|
|
142
30
|
VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
143
31
|
|
|
144
32
|
/**
|
|
@@ -233,80 +121,53 @@ VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
|
233
121
|
*
|
|
234
122
|
* @alias Parse.CLP
|
|
235
123
|
*/
|
|
236
|
-
|
|
124
|
+
class ParseCLP {
|
|
237
125
|
/**
|
|
238
126
|
* @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
|
|
239
127
|
*/
|
|
240
|
-
|
|
241
|
-
var _this = this;
|
|
242
|
-
(0, _classCallCheck2.default)(this, ParseCLP);
|
|
128
|
+
constructor(userId) {
|
|
243
129
|
(0, _defineProperty2.default)(this, "permissionsMap", void 0);
|
|
244
130
|
this.permissionsMap = {};
|
|
245
131
|
// Initialize permissions Map with default permissions
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
};
|
|
279
|
-
_this["getRole".concat(action, "Access")] = function (role) {
|
|
280
|
-
return this["get".concat(action, "Access")](this._getRoleName(role));
|
|
281
|
-
};
|
|
282
|
-
_this["setRole".concat(action, "Access")] = function (role, allowed) {
|
|
283
|
-
this["set".concat(action, "Access")](this._getRoleName(role), allowed);
|
|
284
|
-
};
|
|
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);
|
|
285
164
|
};
|
|
286
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
287
|
-
_loop();
|
|
288
|
-
}
|
|
289
|
-
// Initialize permissions Map with default extended permissions
|
|
290
|
-
} catch (err) {
|
|
291
|
-
_iterator.e(err);
|
|
292
|
-
} finally {
|
|
293
|
-
_iterator.f();
|
|
294
165
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
299
|
-
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
300
|
-
operation = _step2$value[0],
|
|
301
|
-
group = _step2$value[1];
|
|
302
|
-
this.permissionsMap[operation] = (0, _assign.default)({}, group);
|
|
303
|
-
}
|
|
304
|
-
} catch (err) {
|
|
305
|
-
_iterator2.e(err);
|
|
306
|
-
} finally {
|
|
307
|
-
_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);
|
|
308
169
|
}
|
|
309
|
-
if (userId &&
|
|
170
|
+
if (userId && typeof userId === 'object') {
|
|
310
171
|
if (userId instanceof _ParseUser.default) {
|
|
311
172
|
this.setReadAccess(userId, true);
|
|
312
173
|
this.setWriteAccess(userId, true);
|
|
@@ -314,31 +175,29 @@ var ParseCLP = /*#__PURE__*/function () {
|
|
|
314
175
|
this.setRoleReadAccess(userId, true);
|
|
315
176
|
this.setRoleWriteAccess(userId, true);
|
|
316
177
|
} else {
|
|
317
|
-
for (
|
|
178
|
+
for (const permission in userId) {
|
|
318
179
|
var _context;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
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)) {
|
|
324
185
|
throw new TypeError('Tried to create an CLP with an invalid permission type.');
|
|
325
186
|
}
|
|
326
187
|
if (isValidGroupPermission) {
|
|
327
|
-
if ((0, _every.default)(users).call(users,
|
|
328
|
-
|
|
329
|
-
})) {
|
|
330
|
-
this.permissionsMap[_permission] = users;
|
|
188
|
+
if ((0, _every.default)(users).call(users, pointer => typeof pointer === 'string')) {
|
|
189
|
+
this.permissionsMap[permission] = users;
|
|
331
190
|
continue;
|
|
332
191
|
} else {
|
|
333
192
|
throw new TypeError('Tried to create an CLP with an invalid permission value.');
|
|
334
193
|
}
|
|
335
194
|
}
|
|
336
|
-
for (
|
|
337
|
-
|
|
195
|
+
for (const user in users) {
|
|
196
|
+
const allowed = users[user];
|
|
338
197
|
if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
|
|
339
198
|
throw new TypeError('Tried to create an CLP with an invalid permission value.');
|
|
340
199
|
}
|
|
341
|
-
this.permissionsMap[
|
|
200
|
+
this.permissionsMap[permission][user] = allowed;
|
|
342
201
|
}
|
|
343
202
|
}
|
|
344
203
|
}
|
|
@@ -352,433 +211,366 @@ var ParseCLP = /*#__PURE__*/function () {
|
|
|
352
211
|
*
|
|
353
212
|
* @returns {object}
|
|
354
213
|
*/
|
|
355
|
-
(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
214
|
+
toJSON() {
|
|
215
|
+
return {
|
|
216
|
+
...this.permissionsMap
|
|
217
|
+
};
|
|
218
|
+
}
|
|
360
219
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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]) {
|
|
371
237
|
return false;
|
|
372
238
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
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) {
|
|
376
242
|
return false;
|
|
377
243
|
}
|
|
378
|
-
for (
|
|
379
|
-
if (!other.permissionsMap[
|
|
244
|
+
for (const user in this.permissionsMap[permission]) {
|
|
245
|
+
if (!other.permissionsMap[permission][user]) {
|
|
380
246
|
return false;
|
|
381
247
|
}
|
|
382
|
-
|
|
383
|
-
var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
|
|
384
|
-
if (users.length !== otherUsers.length) {
|
|
248
|
+
if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
|
|
385
249
|
return false;
|
|
386
250
|
}
|
|
387
|
-
for (var user in this.permissionsMap[_permission2]) {
|
|
388
|
-
if (!other.permissionsMap[_permission2][user]) {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
251
|
}
|
|
396
|
-
return true;
|
|
397
252
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
if (typeof name !== 'string') {
|
|
407
|
-
throw new TypeError('role must be a Parse.Role or a String');
|
|
408
|
-
}
|
|
409
|
-
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();
|
|
410
260
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
value: function _parseEntity(entity /*: Entity*/) {
|
|
414
|
-
var userId = entity;
|
|
415
|
-
if (userId instanceof _ParseUser.default) {
|
|
416
|
-
userId = userId.id;
|
|
417
|
-
if (!userId) {
|
|
418
|
-
throw new Error('Cannot get access for a Parse.User without an id.');
|
|
419
|
-
}
|
|
420
|
-
} else if (userId instanceof _ParseRole.default) {
|
|
421
|
-
userId = this._getRoleName(userId);
|
|
422
|
-
}
|
|
423
|
-
if (typeof userId !== 'string') {
|
|
424
|
-
throw new TypeError('userId must be a string.');
|
|
425
|
-
}
|
|
426
|
-
return userId;
|
|
261
|
+
if (typeof name !== 'string') {
|
|
262
|
+
throw new TypeError('role must be a Parse.Role or a String');
|
|
427
263
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (!permissions) {
|
|
437
|
-
if (!allowed) {
|
|
438
|
-
// The user already doesn't have this permission, so no action is needed
|
|
439
|
-
return;
|
|
440
|
-
} else {
|
|
441
|
-
this.permissionsMap[permission][userId] = {};
|
|
442
|
-
}
|
|
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.');
|
|
443
272
|
}
|
|
444
|
-
|
|
445
|
-
|
|
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;
|
|
446
291
|
} else {
|
|
447
|
-
|
|
292
|
+
this.permissionsMap[permission][userId] = {};
|
|
448
293
|
}
|
|
449
294
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
userId = this._parseEntity(userId);
|
|
455
|
-
var permissions = this.permissionsMap[permission][userId];
|
|
456
|
-
if (returnBoolean) {
|
|
457
|
-
if (!permissions) {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
return !!this.permissionsMap[permission][userId];
|
|
461
|
-
}
|
|
462
|
-
return permissions;
|
|
295
|
+
if (allowed) {
|
|
296
|
+
this.permissionsMap[permission][userId] = true;
|
|
297
|
+
} else {
|
|
298
|
+
delete this.permissionsMap[permission][userId];
|
|
463
299
|
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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) {
|
|
469
306
|
if (!permissions) {
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
|
|
473
|
-
delete this.permissionsMap[permission][userId];
|
|
474
|
-
} else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
|
|
475
|
-
return typeof field === 'string';
|
|
476
|
-
})) {
|
|
477
|
-
this.permissionsMap[permission][userId] = fields;
|
|
478
|
-
} else {
|
|
479
|
-
throw new TypeError('fields must be an array of strings or undefined.');
|
|
307
|
+
return false;
|
|
480
308
|
}
|
|
309
|
+
return !!this.permissionsMap[permission][userId];
|
|
481
310
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
|
|
497
|
-
}
|
|
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.');
|
|
498
325
|
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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.`);
|
|
503
338
|
}
|
|
339
|
+
}
|
|
340
|
+
_getGroupPointerPermissions(operation) {
|
|
341
|
+
return this.permissionsMap[operation] || [];
|
|
342
|
+
}
|
|
504
343
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
this._setGroupPointerPermission('readUserFields', pointerFields);
|
|
514
|
-
}
|
|
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
|
+
}
|
|
515
352
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
return this._getGroupPointerPermissions('readUserFields');
|
|
523
|
-
}
|
|
353
|
+
/**
|
|
354
|
+
* @returns {string[]} User pointer fields
|
|
355
|
+
*/
|
|
356
|
+
getReadUserFields() {
|
|
357
|
+
return this._getGroupPointerPermissions('readUserFields') || [];
|
|
358
|
+
}
|
|
524
359
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
this._setGroupPointerPermission('writeUserFields', pointerFields);
|
|
534
|
-
}
|
|
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
|
+
}
|
|
535
368
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return this._getGroupPointerPermissions('writeUserFields');
|
|
543
|
-
}
|
|
369
|
+
/**
|
|
370
|
+
* @returns {string[]} User pointer fields
|
|
371
|
+
*/
|
|
372
|
+
getWriteUserFields() {
|
|
373
|
+
return this._getGroupPointerPermissions('writeUserFields') || [];
|
|
374
|
+
}
|
|
544
375
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
this._setArrayAccess('protectedFields', userId, fields);
|
|
555
|
-
}
|
|
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
|
+
}
|
|
556
385
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return this._getAccess('protectedFields', userId, false);
|
|
567
|
-
}
|
|
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
|
+
}
|
|
568
395
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
this._setAccess('count', userId, allowed);
|
|
581
|
-
}
|
|
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
|
+
}
|
|
582
407
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
|
|
596
|
-
}
|
|
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
|
+
}
|
|
597
420
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
this._setAccess('addField', userId, allowed);
|
|
611
|
-
}
|
|
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
|
+
}
|
|
612
433
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
|
|
626
|
-
}
|
|
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
|
+
}
|
|
627
446
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
637
|
-
}
|
|
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
|
+
}
|
|
638
455
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return this.getReadAccess(PUBLIC_KEY);
|
|
648
|
-
}
|
|
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
|
+
}
|
|
649
464
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
659
|
-
}
|
|
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
|
+
}
|
|
660
473
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return this.getWriteAccess(PUBLIC_KEY);
|
|
670
|
-
}
|
|
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
|
+
}
|
|
671
482
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
this.setProtectedFields(PUBLIC_KEY, fields);
|
|
681
|
-
}
|
|
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
|
+
}
|
|
682
491
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return this.getProtectedFields(PUBLIC_KEY);
|
|
692
|
-
}
|
|
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
|
+
}
|
|
693
500
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
return this.getReadAccess(this._getRoleName(role));
|
|
707
|
-
}
|
|
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
|
+
}
|
|
708
513
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
return this.getWriteAccess(this._getRoleName(role));
|
|
722
|
-
}
|
|
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
|
+
}
|
|
723
526
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
this.setReadAccess(this._getRoleName(role), allowed);
|
|
736
|
-
}
|
|
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
|
+
}
|
|
737
538
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
this.setWriteAccess(this._getRoleName(role), allowed);
|
|
750
|
-
}
|
|
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
|
+
}
|
|
751
550
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
return this.getProtectedFields(this._getRoleName(role));
|
|
765
|
-
}
|
|
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
|
+
}
|
|
766
563
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}]);
|
|
781
|
-
return ParseCLP;
|
|
782
|
-
}();
|
|
783
|
-
var _default = ParseCLP;
|
|
784
|
-
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;
|