parse 3.5.1 → 4.0.0-alpha.10
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/LICENSE +167 -25
- package/NOTICE +10 -0
- package/README.md +20 -7
- package/dist/parse.js +12838 -21190
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +7921 -17062
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +2 -27
- package/lib/browser/AnonymousUtils.js +6 -42
- package/lib/browser/Cloud.js +12 -77
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -191
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -8
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -42
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -20
- package/lib/browser/LiveQueryClient.js +105 -213
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -19
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +61 -222
- package/lib/browser/Parse.js +12 -115
- package/lib/browser/ParseACL.js +33 -148
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -95
- package/lib/browser/ParseError.js +63 -99
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -89
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +665 -1845
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -70
- package/lib/browser/ParseQuery.js +403 -1504
- package/lib/browser/ParseRelation.js +12 -68
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -208
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -50
- package/lib/browser/RESTController.js +28 -157
- package/lib/browser/SingleInstanceStateController.js +19 -144
- package/lib/browser/Socket.weapp.js +0 -10
- package/lib/browser/Storage.js +10 -80
- package/lib/browser/StorageController.browser.js +4 -24
- package/lib/browser/StorageController.default.js +4 -24
- package/lib/browser/StorageController.react-native.js +6 -40
- package/lib/browser/StorageController.weapp.js +5 -23
- package/lib/browser/TaskQueue.js +1 -29
- package/lib/browser/UniqueInstanceStateController.js +19 -149
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -23
- package/lib/browser/canBeSerialized.js +3 -40
- package/lib/browser/decode.js +3 -40
- package/lib/browser/encode.js +9 -77
- package/lib/browser/equals.js +2 -34
- package/lib/browser/escape.js +1 -15
- package/lib/browser/isRevocableSession.js +2 -18
- package/lib/browser/parseDate.js +2 -20
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -24
- package/lib/browser/unsavedChildren.js +6 -57
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -25
- package/lib/node/AnonymousUtils.js +5 -44
- package/lib/node/Cloud.js +10 -73
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -227
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -8
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -44
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -22
- package/lib/node/LiveQueryClient.js +72 -154
- package/lib/node/LiveQuerySubscription.js +7 -26
- package/lib/node/LocalDatastore.js +19 -182
- package/lib/node/LocalDatastoreController.js +6 -45
- package/lib/node/LocalDatastoreController.react-native.js +6 -52
- package/lib/node/LocalDatastoreUtils.js +1 -13
- package/lib/node/ObjectStateMutations.js +18 -134
- package/lib/node/OfflineQuery.js +27 -151
- package/lib/node/Parse.js +11 -108
- package/lib/node/ParseACL.js +32 -157
- package/lib/node/ParseCLP.js +73 -302
- package/lib/node/ParseConfig.js +16 -91
- package/lib/node/ParseError.js +61 -74
- package/lib/node/ParseFile.js +55 -244
- package/lib/node/ParseGeoPoint.js +21 -89
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -17
- package/lib/node/ParseLiveQuery.js +10 -43
- package/lib/node/ParseObject.js +234 -997
- package/lib/node/ParseOp.js +31 -262
- package/lib/node/ParsePolygon.js +12 -69
- package/lib/node/ParseQuery.js +169 -888
- package/lib/node/ParseRelation.js +11 -68
- package/lib/node/ParseRole.js +10 -64
- package/lib/node/ParseSchema.js +46 -229
- package/lib/node/ParseSession.js +8 -57
- package/lib/node/ParseUser.js +107 -583
- package/lib/node/Push.js +4 -44
- package/lib/node/RESTController.js +19 -169
- package/lib/node/SingleInstanceStateController.js +17 -137
- package/lib/node/Socket.weapp.js +0 -7
- package/lib/node/Storage.js +10 -90
- package/lib/node/StorageController.browser.js +4 -30
- package/lib/node/StorageController.default.js +5 -28
- package/lib/node/StorageController.react-native.js +6 -47
- package/lib/node/StorageController.weapp.js +6 -28
- package/lib/node/TaskQueue.js +1 -24
- package/lib/node/UniqueInstanceStateController.js +16 -140
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -19
- package/lib/node/canBeSerialized.js +2 -35
- package/lib/node/decode.js +1 -33
- package/lib/node/encode.js +3 -61
- package/lib/node/equals.js +0 -27
- package/lib/node/escape.js +1 -13
- package/lib/node/isRevocableSession.js +1 -12
- package/lib/node/parseDate.js +1 -14
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -18
- package/lib/node/unsavedChildren.js +2 -45
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +2 -6
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +156 -711
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +46 -157
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +281 -948
- package/lib/react-native/LocalDatastoreController.js +71 -552
- package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +2 -65
- package/lib/react-native/OfflineQuery.js +25 -196
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +23 -161
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +55 -529
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +55 -472
- package/lib/react-native/ParseObject.js +245 -1246
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +182 -874
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +3 -54
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +95 -773
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +12 -109
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +0 -10
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -27
- package/lib/weapp/AnonymousUtils.js +6 -42
- package/lib/weapp/Cloud.js +12 -77
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -191
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -8
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -42
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -20
- package/lib/weapp/LiveQueryClient.js +105 -213
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -19
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +61 -222
- package/lib/weapp/Parse.js +12 -115
- package/lib/weapp/ParseACL.js +33 -148
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -95
- package/lib/weapp/ParseError.js +63 -99
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -89
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +665 -1845
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -70
- package/lib/weapp/ParseQuery.js +403 -1504
- package/lib/weapp/ParseRelation.js +12 -68
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -208
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -50
- package/lib/weapp/RESTController.js +28 -157
- package/lib/weapp/SingleInstanceStateController.js +19 -144
- package/lib/weapp/Socket.weapp.js +0 -10
- package/lib/weapp/Storage.js +10 -80
- package/lib/weapp/StorageController.browser.js +4 -24
- package/lib/weapp/StorageController.default.js +4 -24
- package/lib/weapp/StorageController.react-native.js +6 -40
- package/lib/weapp/StorageController.weapp.js +5 -23
- package/lib/weapp/TaskQueue.js +1 -29
- package/lib/weapp/UniqueInstanceStateController.js +19 -149
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -23
- package/lib/weapp/canBeSerialized.js +3 -40
- package/lib/weapp/decode.js +3 -40
- package/lib/weapp/encode.js +9 -77
- package/lib/weapp/equals.js +2 -34
- package/lib/weapp/escape.js +1 -15
- package/lib/weapp/isRevocableSession.js +2 -18
- package/lib/weapp/parseDate.js +2 -20
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -24
- package/lib/weapp/unsavedChildren.js +6 -57
- package/lib/weapp/uuid.js +1 -6
- package/package.json +37 -30
- package/PATENTS +0 -37
package/lib/weapp/ParseACL.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
16
|
-
|
|
17
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
18
|
-
|
|
19
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
20
|
-
|
|
21
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
22
|
-
|
|
23
14
|
var _ParseRole = _interopRequireDefault(require("./ParseRole"));
|
|
24
|
-
|
|
25
15
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
26
16
|
/**
|
|
27
|
-
* Copyright (c) 2015-present, Parse, LLC.
|
|
28
|
-
* All rights reserved.
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the BSD-style license found in the
|
|
31
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
32
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
33
|
-
*
|
|
34
17
|
* @flow
|
|
35
18
|
*/
|
|
36
19
|
|
|
37
|
-
|
|
38
20
|
var PUBLIC_KEY = '*';
|
|
21
|
+
|
|
39
22
|
/**
|
|
40
23
|
* Creates a new ACL.
|
|
41
24
|
* If no argument is given, the ACL has no permissions for anyone.
|
|
@@ -50,18 +33,14 @@ var PUBLIC_KEY = '*';
|
|
|
50
33
|
*
|
|
51
34
|
* @alias Parse.ACL
|
|
52
35
|
*/
|
|
53
|
-
|
|
54
36
|
var ParseACL = /*#__PURE__*/function () {
|
|
55
37
|
/**
|
|
56
38
|
* @param {(Parse.User | object)} arg1 The user to initialize the ACL for
|
|
57
39
|
*/
|
|
58
|
-
function ParseACL(arg1
|
|
59
|
-
/*: ParseUser | ByIdMap*/
|
|
60
|
-
) {
|
|
40
|
+
function ParseACL(arg1 /*: ParseUser | ByIdMap*/) {
|
|
61
41
|
(0, _classCallCheck2.default)(this, ParseACL);
|
|
62
42
|
(0, _defineProperty2.default)(this, "permissionsById", void 0);
|
|
63
43
|
this.permissionsById = {};
|
|
64
|
-
|
|
65
44
|
if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
|
|
66
45
|
if (arg1 instanceof _ParseUser.default) {
|
|
67
46
|
this.setReadAccess(arg1, true);
|
|
@@ -70,18 +49,14 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
70
49
|
for (var _userId in arg1) {
|
|
71
50
|
var accessList = arg1[_userId];
|
|
72
51
|
this.permissionsById[_userId] = {};
|
|
73
|
-
|
|
74
52
|
for (var _permission in accessList) {
|
|
75
53
|
var allowed = accessList[_permission];
|
|
76
|
-
|
|
77
54
|
if (_permission !== 'read' && _permission !== 'write') {
|
|
78
55
|
throw new TypeError('Tried to create an ACL with an invalid permission type.');
|
|
79
56
|
}
|
|
80
|
-
|
|
81
57
|
if (typeof allowed !== 'boolean') {
|
|
82
58
|
throw new TypeError('Tried to create an ACL with an invalid permission value.');
|
|
83
59
|
}
|
|
84
|
-
|
|
85
60
|
this.permissionsById[_userId][_permission] = allowed;
|
|
86
61
|
}
|
|
87
62
|
}
|
|
@@ -90,98 +65,71 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
90
65
|
throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
|
|
91
66
|
}
|
|
92
67
|
}
|
|
68
|
+
|
|
93
69
|
/**
|
|
94
70
|
* Returns a JSON-encoded version of the ACL.
|
|
95
71
|
*
|
|
96
72
|
* @returns {object}
|
|
97
73
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
74
|
(0, _createClass2.default)(ParseACL, [{
|
|
101
75
|
key: "toJSON",
|
|
102
|
-
value: function ()
|
|
103
|
-
/*: ByIdMap*/
|
|
104
|
-
{
|
|
76
|
+
value: function () /*: ByIdMap*/{
|
|
105
77
|
var permissions = {};
|
|
106
|
-
|
|
107
78
|
for (var p in this.permissionsById) {
|
|
108
79
|
permissions[p] = this.permissionsById[p];
|
|
109
80
|
}
|
|
110
|
-
|
|
111
81
|
return permissions;
|
|
112
82
|
}
|
|
83
|
+
|
|
113
84
|
/**
|
|
114
85
|
* Returns whether this ACL is equal to another object
|
|
115
86
|
*
|
|
116
87
|
* @param {ParseACL} other The other object's ACL to compare to
|
|
117
88
|
* @returns {boolean}
|
|
118
89
|
*/
|
|
119
|
-
|
|
120
90
|
}, {
|
|
121
91
|
key: "equals",
|
|
122
|
-
value: function (other
|
|
123
|
-
/*: ParseACL*/
|
|
124
|
-
)
|
|
125
|
-
/*: boolean*/
|
|
126
|
-
{
|
|
92
|
+
value: function (other /*: ParseACL*/) /*: boolean*/{
|
|
127
93
|
if (!(other instanceof ParseACL)) {
|
|
128
94
|
return false;
|
|
129
95
|
}
|
|
130
|
-
|
|
131
96
|
var users = (0, _keys.default)(this.permissionsById);
|
|
132
97
|
var otherUsers = (0, _keys.default)(other.permissionsById);
|
|
133
|
-
|
|
134
98
|
if (users.length !== otherUsers.length) {
|
|
135
99
|
return false;
|
|
136
100
|
}
|
|
137
|
-
|
|
138
101
|
for (var u in this.permissionsById) {
|
|
139
102
|
if (!other.permissionsById[u]) {
|
|
140
103
|
return false;
|
|
141
104
|
}
|
|
142
|
-
|
|
143
105
|
if (this.permissionsById[u].read !== other.permissionsById[u].read) {
|
|
144
106
|
return false;
|
|
145
107
|
}
|
|
146
|
-
|
|
147
108
|
if (this.permissionsById[u].write !== other.permissionsById[u].write) {
|
|
148
109
|
return false;
|
|
149
110
|
}
|
|
150
111
|
}
|
|
151
|
-
|
|
152
112
|
return true;
|
|
153
113
|
}
|
|
154
114
|
}, {
|
|
155
115
|
key: "_setAccess",
|
|
156
|
-
value: function (accessType
|
|
157
|
-
/*: string*/
|
|
158
|
-
, userId
|
|
159
|
-
/*: ParseUser | ParseRole | string*/
|
|
160
|
-
, allowed
|
|
161
|
-
/*: boolean*/
|
|
162
|
-
) {
|
|
116
|
+
value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
163
117
|
if (userId instanceof _ParseUser.default) {
|
|
164
118
|
userId = userId.id;
|
|
165
119
|
} else if (userId instanceof _ParseRole.default) {
|
|
166
120
|
var name = userId.getName();
|
|
167
|
-
|
|
168
121
|
if (!name) {
|
|
169
122
|
throw new TypeError('Role must have a name');
|
|
170
123
|
}
|
|
171
|
-
|
|
172
124
|
userId = 'role:' + name;
|
|
173
125
|
}
|
|
174
|
-
|
|
175
126
|
if (typeof userId !== 'string') {
|
|
176
127
|
throw new TypeError('userId must be a string.');
|
|
177
128
|
}
|
|
178
|
-
|
|
179
129
|
if (typeof allowed !== 'boolean') {
|
|
180
130
|
throw new TypeError('allowed must be either true or false.');
|
|
181
131
|
}
|
|
182
|
-
|
|
183
132
|
var permissions = this.permissionsById[userId];
|
|
184
|
-
|
|
185
133
|
if (!permissions) {
|
|
186
134
|
if (!allowed) {
|
|
187
135
|
// The user already doesn't have this permission, so no action is needed
|
|
@@ -191,12 +139,10 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
191
139
|
this.permissionsById[userId] = permissions;
|
|
192
140
|
}
|
|
193
141
|
}
|
|
194
|
-
|
|
195
142
|
if (allowed) {
|
|
196
143
|
this.permissionsById[userId][accessType] = true;
|
|
197
144
|
} else {
|
|
198
145
|
delete permissions[accessType];
|
|
199
|
-
|
|
200
146
|
if ((0, _keys.default)(permissions).length === 0) {
|
|
201
147
|
delete this.permissionsById[userId];
|
|
202
148
|
}
|
|
@@ -204,53 +150,38 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
204
150
|
}
|
|
205
151
|
}, {
|
|
206
152
|
key: "_getAccess",
|
|
207
|
-
value: function (accessType
|
|
208
|
-
/*: string*/
|
|
209
|
-
, userId
|
|
210
|
-
/*: ParseUser | ParseRole | string*/
|
|
211
|
-
)
|
|
212
|
-
/*: boolean*/
|
|
213
|
-
{
|
|
153
|
+
value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
214
154
|
if (userId instanceof _ParseUser.default) {
|
|
215
155
|
userId = userId.id;
|
|
216
|
-
|
|
217
156
|
if (!userId) {
|
|
218
157
|
throw new Error('Cannot get access for a ParseUser without an ID');
|
|
219
158
|
}
|
|
220
159
|
} else if (userId instanceof _ParseRole.default) {
|
|
221
160
|
var name = userId.getName();
|
|
222
|
-
|
|
223
161
|
if (!name) {
|
|
224
162
|
throw new TypeError('Role must have a name');
|
|
225
163
|
}
|
|
226
|
-
|
|
227
164
|
userId = 'role:' + name;
|
|
228
165
|
}
|
|
229
|
-
|
|
230
166
|
var permissions = this.permissionsById[userId];
|
|
231
|
-
|
|
232
167
|
if (!permissions) {
|
|
233
168
|
return false;
|
|
234
169
|
}
|
|
235
|
-
|
|
236
170
|
return !!permissions[accessType];
|
|
237
171
|
}
|
|
172
|
+
|
|
238
173
|
/**
|
|
239
174
|
* Sets whether the given user is allowed to read this object.
|
|
240
175
|
*
|
|
241
176
|
* @param userId An instance of Parse.User or its objectId.
|
|
242
177
|
* @param {boolean} allowed Whether that user should have read access.
|
|
243
178
|
*/
|
|
244
|
-
|
|
245
179
|
}, {
|
|
246
180
|
key: "setReadAccess",
|
|
247
|
-
value: function (userId
|
|
248
|
-
/*: ParseUser | ParseRole | string*/
|
|
249
|
-
, allowed
|
|
250
|
-
/*: boolean*/
|
|
251
|
-
) {
|
|
181
|
+
value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
252
182
|
this._setAccess('read', userId, allowed);
|
|
253
183
|
}
|
|
184
|
+
|
|
254
185
|
/**
|
|
255
186
|
* Get whether the given user id is *explicitly* allowed to read this object.
|
|
256
187
|
* Even if this returns false, the user may still be able to access it if
|
|
@@ -260,32 +191,24 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
260
191
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
261
192
|
* @returns {boolean}
|
|
262
193
|
*/
|
|
263
|
-
|
|
264
194
|
}, {
|
|
265
195
|
key: "getReadAccess",
|
|
266
|
-
value: function (userId
|
|
267
|
-
/*: ParseUser | ParseRole | string*/
|
|
268
|
-
)
|
|
269
|
-
/*: boolean*/
|
|
270
|
-
{
|
|
196
|
+
value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
271
197
|
return this._getAccess('read', userId);
|
|
272
198
|
}
|
|
199
|
+
|
|
273
200
|
/**
|
|
274
201
|
* Sets whether the given user id is allowed to write this object.
|
|
275
202
|
*
|
|
276
203
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role..
|
|
277
204
|
* @param {boolean} allowed Whether that user should have write access.
|
|
278
205
|
*/
|
|
279
|
-
|
|
280
206
|
}, {
|
|
281
207
|
key: "setWriteAccess",
|
|
282
|
-
value: function (userId
|
|
283
|
-
/*: ParseUser | ParseRole | string*/
|
|
284
|
-
, allowed
|
|
285
|
-
/*: boolean*/
|
|
286
|
-
) {
|
|
208
|
+
value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
287
209
|
this._setAccess('write', userId, allowed);
|
|
288
210
|
}
|
|
211
|
+
|
|
289
212
|
/**
|
|
290
213
|
* Gets whether the given user id is *explicitly* allowed to write this object.
|
|
291
214
|
* Even if this returns false, the user may still be able to write it if
|
|
@@ -295,68 +218,56 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
295
218
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
296
219
|
* @returns {boolean}
|
|
297
220
|
*/
|
|
298
|
-
|
|
299
221
|
}, {
|
|
300
222
|
key: "getWriteAccess",
|
|
301
|
-
value: function (userId
|
|
302
|
-
/*: ParseUser | ParseRole | string*/
|
|
303
|
-
)
|
|
304
|
-
/*: boolean*/
|
|
305
|
-
{
|
|
223
|
+
value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
306
224
|
return this._getAccess('write', userId);
|
|
307
225
|
}
|
|
226
|
+
|
|
308
227
|
/**
|
|
309
228
|
* Sets whether the public is allowed to read this object.
|
|
310
229
|
*
|
|
311
230
|
* @param {boolean} allowed
|
|
312
231
|
*/
|
|
313
|
-
|
|
314
232
|
}, {
|
|
315
233
|
key: "setPublicReadAccess",
|
|
316
|
-
value: function (allowed
|
|
317
|
-
/*: boolean*/
|
|
318
|
-
) {
|
|
234
|
+
value: function (allowed /*: boolean*/) {
|
|
319
235
|
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
320
236
|
}
|
|
237
|
+
|
|
321
238
|
/**
|
|
322
239
|
* Gets whether the public is allowed to read this object.
|
|
323
240
|
*
|
|
324
241
|
* @returns {boolean}
|
|
325
242
|
*/
|
|
326
|
-
|
|
327
243
|
}, {
|
|
328
244
|
key: "getPublicReadAccess",
|
|
329
|
-
value: function ()
|
|
330
|
-
/*: boolean*/
|
|
331
|
-
{
|
|
245
|
+
value: function () /*: boolean*/{
|
|
332
246
|
return this.getReadAccess(PUBLIC_KEY);
|
|
333
247
|
}
|
|
248
|
+
|
|
334
249
|
/**
|
|
335
250
|
* Sets whether the public is allowed to write this object.
|
|
336
251
|
*
|
|
337
252
|
* @param {boolean} allowed
|
|
338
253
|
*/
|
|
339
|
-
|
|
340
254
|
}, {
|
|
341
255
|
key: "setPublicWriteAccess",
|
|
342
|
-
value: function (allowed
|
|
343
|
-
/*: boolean*/
|
|
344
|
-
) {
|
|
256
|
+
value: function (allowed /*: boolean*/) {
|
|
345
257
|
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
346
258
|
}
|
|
259
|
+
|
|
347
260
|
/**
|
|
348
261
|
* Gets whether the public is allowed to write this object.
|
|
349
262
|
*
|
|
350
263
|
* @returns {boolean}
|
|
351
264
|
*/
|
|
352
|
-
|
|
353
265
|
}, {
|
|
354
266
|
key: "getPublicWriteAccess",
|
|
355
|
-
value: function ()
|
|
356
|
-
/*: boolean*/
|
|
357
|
-
{
|
|
267
|
+
value: function () /*: boolean*/{
|
|
358
268
|
return this.getWriteAccess(PUBLIC_KEY);
|
|
359
269
|
}
|
|
270
|
+
|
|
360
271
|
/**
|
|
361
272
|
* Gets whether users belonging to the given role are allowed
|
|
362
273
|
* to read this object. Even if this returns false, the role may
|
|
@@ -366,25 +277,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
366
277
|
* @returns {boolean} true if the role has read access. false otherwise.
|
|
367
278
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
368
279
|
*/
|
|
369
|
-
|
|
370
280
|
}, {
|
|
371
281
|
key: "getRoleReadAccess",
|
|
372
|
-
value: function (role
|
|
373
|
-
/*: ParseRole | string*/
|
|
374
|
-
)
|
|
375
|
-
/*: boolean*/
|
|
376
|
-
{
|
|
282
|
+
value: function (role /*: ParseRole | string*/) /*: boolean*/{
|
|
377
283
|
if (role instanceof _ParseRole.default) {
|
|
378
284
|
// Normalize to the String name
|
|
379
285
|
role = role.getName();
|
|
380
286
|
}
|
|
381
|
-
|
|
382
287
|
if (typeof role !== 'string') {
|
|
383
288
|
throw new TypeError('role must be a ParseRole or a String');
|
|
384
289
|
}
|
|
385
|
-
|
|
386
290
|
return this.getReadAccess('role:' + role);
|
|
387
291
|
}
|
|
292
|
+
|
|
388
293
|
/**
|
|
389
294
|
* Gets whether users belonging to the given role are allowed
|
|
390
295
|
* to write this object. Even if this returns false, the role may
|
|
@@ -394,25 +299,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
394
299
|
* @returns {boolean} true if the role has write access. false otherwise.
|
|
395
300
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
396
301
|
*/
|
|
397
|
-
|
|
398
302
|
}, {
|
|
399
303
|
key: "getRoleWriteAccess",
|
|
400
|
-
value: function (role
|
|
401
|
-
/*: ParseRole | string*/
|
|
402
|
-
)
|
|
403
|
-
/*: boolean*/
|
|
404
|
-
{
|
|
304
|
+
value: function (role /*: ParseRole | string*/) /*: boolean*/{
|
|
405
305
|
if (role instanceof _ParseRole.default) {
|
|
406
306
|
// Normalize to the String name
|
|
407
307
|
role = role.getName();
|
|
408
308
|
}
|
|
409
|
-
|
|
410
309
|
if (typeof role !== 'string') {
|
|
411
310
|
throw new TypeError('role must be a ParseRole or a String');
|
|
412
311
|
}
|
|
413
|
-
|
|
414
312
|
return this.getWriteAccess('role:' + role);
|
|
415
313
|
}
|
|
314
|
+
|
|
416
315
|
/**
|
|
417
316
|
* Sets whether users belonging to the given role are allowed
|
|
418
317
|
* to read this object.
|
|
@@ -421,25 +320,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
421
320
|
* @param {boolean} allowed Whether the given role can read this object.
|
|
422
321
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
423
322
|
*/
|
|
424
|
-
|
|
425
323
|
}, {
|
|
426
324
|
key: "setRoleReadAccess",
|
|
427
|
-
value: function (role
|
|
428
|
-
/*: ParseRole | string*/
|
|
429
|
-
, allowed
|
|
430
|
-
/*: boolean*/
|
|
431
|
-
) {
|
|
325
|
+
value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
432
326
|
if (role instanceof _ParseRole.default) {
|
|
433
327
|
// Normalize to the String name
|
|
434
328
|
role = role.getName();
|
|
435
329
|
}
|
|
436
|
-
|
|
437
330
|
if (typeof role !== 'string') {
|
|
438
331
|
throw new TypeError('role must be a ParseRole or a String');
|
|
439
332
|
}
|
|
440
|
-
|
|
441
333
|
this.setReadAccess('role:' + role, allowed);
|
|
442
334
|
}
|
|
335
|
+
|
|
443
336
|
/**
|
|
444
337
|
* Sets whether users belonging to the given role are allowed
|
|
445
338
|
* to write this object.
|
|
@@ -448,28 +341,20 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
448
341
|
* @param {boolean} allowed Whether the given role can write this object.
|
|
449
342
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
450
343
|
*/
|
|
451
|
-
|
|
452
344
|
}, {
|
|
453
345
|
key: "setRoleWriteAccess",
|
|
454
|
-
value: function (role
|
|
455
|
-
/*: ParseRole | string*/
|
|
456
|
-
, allowed
|
|
457
|
-
/*: boolean*/
|
|
458
|
-
) {
|
|
346
|
+
value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
459
347
|
if (role instanceof _ParseRole.default) {
|
|
460
348
|
// Normalize to the String name
|
|
461
349
|
role = role.getName();
|
|
462
350
|
}
|
|
463
|
-
|
|
464
351
|
if (typeof role !== 'string') {
|
|
465
352
|
throw new TypeError('role must be a ParseRole or a String');
|
|
466
353
|
}
|
|
467
|
-
|
|
468
354
|
this.setWriteAccess('role:' + role, allowed);
|
|
469
355
|
}
|
|
470
356
|
}]);
|
|
471
357
|
return ParseACL;
|
|
472
358
|
}();
|
|
473
|
-
|
|
474
359
|
var _default = ParseACL;
|
|
475
360
|
exports.default = _default;
|