parse 4.0.0-alpha.1 → 4.0.0-alpha.11
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 +6 -5
- 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 +13 -100
- 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 +69 -269
- package/lib/node/ParseConfig.js +16 -91
- package/lib/node/ParseError.js +61 -74
- package/lib/node/ParseFile.js +49 -212
- 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 +229 -964
- 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 +18 -127
- 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 +35 -31
- package/PATENTS +0 -37
package/lib/node/ParseACL.js
CHANGED
|
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _ParseRole = _interopRequireDefault(require("./ParseRole"));
|
|
9
|
-
|
|
10
8
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) {
|
|
13
10
|
return obj && obj.__esModule ? obj : {
|
|
14
11
|
default: obj
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
/**
|
|
18
|
-
* Copyright (c) 2015-present, Parse, LLC.
|
|
19
|
-
* All rights reserved.
|
|
20
|
-
*
|
|
21
|
-
* This source code is licensed under the BSD-style license found in the
|
|
22
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
23
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
24
|
-
*
|
|
25
15
|
* @flow
|
|
26
16
|
*/
|
|
27
17
|
|
|
28
|
-
|
|
29
18
|
const PUBLIC_KEY = '*';
|
|
19
|
+
|
|
30
20
|
/**
|
|
31
21
|
* Creates a new ACL.
|
|
32
22
|
* If no argument is given, the ACL has no permissions for anyone.
|
|
@@ -41,18 +31,13 @@ const PUBLIC_KEY = '*';
|
|
|
41
31
|
*
|
|
42
32
|
* @alias Parse.ACL
|
|
43
33
|
*/
|
|
44
|
-
|
|
45
34
|
class ParseACL {
|
|
46
35
|
/*:: permissionsById: ByIdMap;*/
|
|
47
|
-
|
|
48
36
|
/**
|
|
49
37
|
* @param {(Parse.User | object)} arg1 The user to initialize the ACL for
|
|
50
38
|
*/
|
|
51
|
-
constructor(arg1
|
|
52
|
-
/*: ParseUser | ByIdMap*/
|
|
53
|
-
) {
|
|
39
|
+
constructor(arg1 /*: ParseUser | ByIdMap*/) {
|
|
54
40
|
this.permissionsById = {};
|
|
55
|
-
|
|
56
41
|
if (arg1 && typeof arg1 === 'object') {
|
|
57
42
|
if (arg1 instanceof _ParseUser.default) {
|
|
58
43
|
this.setReadAccess(arg1, true);
|
|
@@ -61,18 +46,14 @@ class ParseACL {
|
|
|
61
46
|
for (const userId in arg1) {
|
|
62
47
|
const accessList = arg1[userId];
|
|
63
48
|
this.permissionsById[userId] = {};
|
|
64
|
-
|
|
65
49
|
for (const permission in accessList) {
|
|
66
50
|
const allowed = accessList[permission];
|
|
67
|
-
|
|
68
51
|
if (permission !== 'read' && permission !== 'write') {
|
|
69
52
|
throw new TypeError('Tried to create an ACL with an invalid permission type.');
|
|
70
53
|
}
|
|
71
|
-
|
|
72
54
|
if (typeof allowed !== 'boolean') {
|
|
73
55
|
throw new TypeError('Tried to create an ACL with an invalid permission value.');
|
|
74
56
|
}
|
|
75
|
-
|
|
76
57
|
this.permissionsById[userId][permission] = allowed;
|
|
77
58
|
}
|
|
78
59
|
}
|
|
@@ -81,94 +62,65 @@ class ParseACL {
|
|
|
81
62
|
throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
|
|
82
63
|
}
|
|
83
64
|
}
|
|
65
|
+
|
|
84
66
|
/**
|
|
85
67
|
* Returns a JSON-encoded version of the ACL.
|
|
86
68
|
*
|
|
87
69
|
* @returns {object}
|
|
88
70
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
toJSON()
|
|
92
|
-
/*: ByIdMap*/
|
|
93
|
-
{
|
|
71
|
+
toJSON() /*: ByIdMap*/{
|
|
94
72
|
const permissions = {};
|
|
95
|
-
|
|
96
73
|
for (const p in this.permissionsById) {
|
|
97
74
|
permissions[p] = this.permissionsById[p];
|
|
98
75
|
}
|
|
99
|
-
|
|
100
76
|
return permissions;
|
|
101
77
|
}
|
|
78
|
+
|
|
102
79
|
/**
|
|
103
80
|
* Returns whether this ACL is equal to another object
|
|
104
81
|
*
|
|
105
82
|
* @param {ParseACL} other The other object's ACL to compare to
|
|
106
83
|
* @returns {boolean}
|
|
107
84
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
equals(other
|
|
111
|
-
/*: ParseACL*/
|
|
112
|
-
)
|
|
113
|
-
/*: boolean*/
|
|
114
|
-
{
|
|
85
|
+
equals(other /*: ParseACL*/) /*: boolean*/{
|
|
115
86
|
if (!(other instanceof ParseACL)) {
|
|
116
87
|
return false;
|
|
117
88
|
}
|
|
118
|
-
|
|
119
89
|
const users = Object.keys(this.permissionsById);
|
|
120
90
|
const otherUsers = Object.keys(other.permissionsById);
|
|
121
|
-
|
|
122
91
|
if (users.length !== otherUsers.length) {
|
|
123
92
|
return false;
|
|
124
93
|
}
|
|
125
|
-
|
|
126
94
|
for (const u in this.permissionsById) {
|
|
127
95
|
if (!other.permissionsById[u]) {
|
|
128
96
|
return false;
|
|
129
97
|
}
|
|
130
|
-
|
|
131
98
|
if (this.permissionsById[u].read !== other.permissionsById[u].read) {
|
|
132
99
|
return false;
|
|
133
100
|
}
|
|
134
|
-
|
|
135
101
|
if (this.permissionsById[u].write !== other.permissionsById[u].write) {
|
|
136
102
|
return false;
|
|
137
103
|
}
|
|
138
104
|
}
|
|
139
|
-
|
|
140
105
|
return true;
|
|
141
106
|
}
|
|
142
|
-
|
|
143
|
-
_setAccess(accessType
|
|
144
|
-
/*: string*/
|
|
145
|
-
, userId
|
|
146
|
-
/*: ParseUser | ParseRole | string*/
|
|
147
|
-
, allowed
|
|
148
|
-
/*: boolean*/
|
|
149
|
-
) {
|
|
107
|
+
_setAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
150
108
|
if (userId instanceof _ParseUser.default) {
|
|
151
109
|
userId = userId.id;
|
|
152
110
|
} else if (userId instanceof _ParseRole.default) {
|
|
153
111
|
const name = userId.getName();
|
|
154
|
-
|
|
155
112
|
if (!name) {
|
|
156
113
|
throw new TypeError('Role must have a name');
|
|
157
114
|
}
|
|
158
|
-
|
|
159
115
|
userId = 'role:' + name;
|
|
160
116
|
}
|
|
161
|
-
|
|
162
117
|
if (typeof userId !== 'string') {
|
|
163
118
|
throw new TypeError('userId must be a string.');
|
|
164
119
|
}
|
|
165
|
-
|
|
166
120
|
if (typeof allowed !== 'boolean') {
|
|
167
121
|
throw new TypeError('allowed must be either true or false.');
|
|
168
122
|
}
|
|
169
|
-
|
|
170
123
|
let permissions = this.permissionsById[userId];
|
|
171
|
-
|
|
172
124
|
if (!permissions) {
|
|
173
125
|
if (!allowed) {
|
|
174
126
|
// The user already doesn't have this permission, so no action is needed
|
|
@@ -178,64 +130,45 @@ class ParseACL {
|
|
|
178
130
|
this.permissionsById[userId] = permissions;
|
|
179
131
|
}
|
|
180
132
|
}
|
|
181
|
-
|
|
182
133
|
if (allowed) {
|
|
183
134
|
this.permissionsById[userId][accessType] = true;
|
|
184
135
|
} else {
|
|
185
136
|
delete permissions[accessType];
|
|
186
|
-
|
|
187
137
|
if (Object.keys(permissions).length === 0) {
|
|
188
138
|
delete this.permissionsById[userId];
|
|
189
139
|
}
|
|
190
140
|
}
|
|
191
141
|
}
|
|
192
|
-
|
|
193
|
-
_getAccess(accessType
|
|
194
|
-
/*: string*/
|
|
195
|
-
, userId
|
|
196
|
-
/*: ParseUser | ParseRole | string*/
|
|
197
|
-
)
|
|
198
|
-
/*: boolean*/
|
|
199
|
-
{
|
|
142
|
+
_getAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
200
143
|
if (userId instanceof _ParseUser.default) {
|
|
201
144
|
userId = userId.id;
|
|
202
|
-
|
|
203
145
|
if (!userId) {
|
|
204
146
|
throw new Error('Cannot get access for a ParseUser without an ID');
|
|
205
147
|
}
|
|
206
148
|
} else if (userId instanceof _ParseRole.default) {
|
|
207
149
|
const name = userId.getName();
|
|
208
|
-
|
|
209
150
|
if (!name) {
|
|
210
151
|
throw new TypeError('Role must have a name');
|
|
211
152
|
}
|
|
212
|
-
|
|
213
153
|
userId = 'role:' + name;
|
|
214
154
|
}
|
|
215
|
-
|
|
216
155
|
const permissions = this.permissionsById[userId];
|
|
217
|
-
|
|
218
156
|
if (!permissions) {
|
|
219
157
|
return false;
|
|
220
158
|
}
|
|
221
|
-
|
|
222
159
|
return !!permissions[accessType];
|
|
223
160
|
}
|
|
161
|
+
|
|
224
162
|
/**
|
|
225
163
|
* Sets whether the given user is allowed to read this object.
|
|
226
164
|
*
|
|
227
165
|
* @param userId An instance of Parse.User or its objectId.
|
|
228
166
|
* @param {boolean} allowed Whether that user should have read access.
|
|
229
167
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
setReadAccess(userId
|
|
233
|
-
/*: ParseUser | ParseRole | string*/
|
|
234
|
-
, allowed
|
|
235
|
-
/*: boolean*/
|
|
236
|
-
) {
|
|
168
|
+
setReadAccess(userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
237
169
|
this._setAccess('read', userId, allowed);
|
|
238
170
|
}
|
|
171
|
+
|
|
239
172
|
/**
|
|
240
173
|
* Get whether the given user id is *explicitly* allowed to read this object.
|
|
241
174
|
* Even if this returns false, the user may still be able to access it if
|
|
@@ -245,30 +178,20 @@ class ParseACL {
|
|
|
245
178
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
246
179
|
* @returns {boolean}
|
|
247
180
|
*/
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
getReadAccess(userId
|
|
251
|
-
/*: ParseUser | ParseRole | string*/
|
|
252
|
-
)
|
|
253
|
-
/*: boolean*/
|
|
254
|
-
{
|
|
181
|
+
getReadAccess(userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
255
182
|
return this._getAccess('read', userId);
|
|
256
183
|
}
|
|
184
|
+
|
|
257
185
|
/**
|
|
258
186
|
* Sets whether the given user id is allowed to write this object.
|
|
259
187
|
*
|
|
260
188
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role..
|
|
261
189
|
* @param {boolean} allowed Whether that user should have write access.
|
|
262
190
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
setWriteAccess(userId
|
|
266
|
-
/*: ParseUser | ParseRole | string*/
|
|
267
|
-
, allowed
|
|
268
|
-
/*: boolean*/
|
|
269
|
-
) {
|
|
191
|
+
setWriteAccess(userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
270
192
|
this._setAccess('write', userId, allowed);
|
|
271
193
|
}
|
|
194
|
+
|
|
272
195
|
/**
|
|
273
196
|
* Gets whether the given user id is *explicitly* allowed to write this object.
|
|
274
197
|
* Even if this returns false, the user may still be able to write it if
|
|
@@ -278,63 +201,46 @@ class ParseACL {
|
|
|
278
201
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
279
202
|
* @returns {boolean}
|
|
280
203
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
getWriteAccess(userId
|
|
284
|
-
/*: ParseUser | ParseRole | string*/
|
|
285
|
-
)
|
|
286
|
-
/*: boolean*/
|
|
287
|
-
{
|
|
204
|
+
getWriteAccess(userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
288
205
|
return this._getAccess('write', userId);
|
|
289
206
|
}
|
|
207
|
+
|
|
290
208
|
/**
|
|
291
209
|
* Sets whether the public is allowed to read this object.
|
|
292
210
|
*
|
|
293
211
|
* @param {boolean} allowed
|
|
294
212
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
setPublicReadAccess(allowed
|
|
298
|
-
/*: boolean*/
|
|
299
|
-
) {
|
|
213
|
+
setPublicReadAccess(allowed /*: boolean*/) {
|
|
300
214
|
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
301
215
|
}
|
|
216
|
+
|
|
302
217
|
/**
|
|
303
218
|
* Gets whether the public is allowed to read this object.
|
|
304
219
|
*
|
|
305
220
|
* @returns {boolean}
|
|
306
221
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
getPublicReadAccess()
|
|
310
|
-
/*: boolean*/
|
|
311
|
-
{
|
|
222
|
+
getPublicReadAccess() /*: boolean*/{
|
|
312
223
|
return this.getReadAccess(PUBLIC_KEY);
|
|
313
224
|
}
|
|
225
|
+
|
|
314
226
|
/**
|
|
315
227
|
* Sets whether the public is allowed to write this object.
|
|
316
228
|
*
|
|
317
229
|
* @param {boolean} allowed
|
|
318
230
|
*/
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
setPublicWriteAccess(allowed
|
|
322
|
-
/*: boolean*/
|
|
323
|
-
) {
|
|
231
|
+
setPublicWriteAccess(allowed /*: boolean*/) {
|
|
324
232
|
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
325
233
|
}
|
|
234
|
+
|
|
326
235
|
/**
|
|
327
236
|
* Gets whether the public is allowed to write this object.
|
|
328
237
|
*
|
|
329
238
|
* @returns {boolean}
|
|
330
239
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
getPublicWriteAccess()
|
|
334
|
-
/*: boolean*/
|
|
335
|
-
{
|
|
240
|
+
getPublicWriteAccess() /*: boolean*/{
|
|
336
241
|
return this.getWriteAccess(PUBLIC_KEY);
|
|
337
242
|
}
|
|
243
|
+
|
|
338
244
|
/**
|
|
339
245
|
* Gets whether users belonging to the given role are allowed
|
|
340
246
|
* to read this object. Even if this returns false, the role may
|
|
@@ -344,24 +250,17 @@ class ParseACL {
|
|
|
344
250
|
* @returns {boolean} true if the role has read access. false otherwise.
|
|
345
251
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
346
252
|
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
getRoleReadAccess(role
|
|
350
|
-
/*: ParseRole | string*/
|
|
351
|
-
)
|
|
352
|
-
/*: boolean*/
|
|
353
|
-
{
|
|
253
|
+
getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
|
|
354
254
|
if (role instanceof _ParseRole.default) {
|
|
355
255
|
// Normalize to the String name
|
|
356
256
|
role = role.getName();
|
|
357
257
|
}
|
|
358
|
-
|
|
359
258
|
if (typeof role !== 'string') {
|
|
360
259
|
throw new TypeError('role must be a ParseRole or a String');
|
|
361
260
|
}
|
|
362
|
-
|
|
363
261
|
return this.getReadAccess('role:' + role);
|
|
364
262
|
}
|
|
263
|
+
|
|
365
264
|
/**
|
|
366
265
|
* Gets whether users belonging to the given role are allowed
|
|
367
266
|
* to write this object. Even if this returns false, the role may
|
|
@@ -371,24 +270,17 @@ class ParseACL {
|
|
|
371
270
|
* @returns {boolean} true if the role has write access. false otherwise.
|
|
372
271
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
373
272
|
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
getRoleWriteAccess(role
|
|
377
|
-
/*: ParseRole | string*/
|
|
378
|
-
)
|
|
379
|
-
/*: boolean*/
|
|
380
|
-
{
|
|
273
|
+
getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
|
|
381
274
|
if (role instanceof _ParseRole.default) {
|
|
382
275
|
// Normalize to the String name
|
|
383
276
|
role = role.getName();
|
|
384
277
|
}
|
|
385
|
-
|
|
386
278
|
if (typeof role !== 'string') {
|
|
387
279
|
throw new TypeError('role must be a ParseRole or a String');
|
|
388
280
|
}
|
|
389
|
-
|
|
390
281
|
return this.getWriteAccess('role:' + role);
|
|
391
282
|
}
|
|
283
|
+
|
|
392
284
|
/**
|
|
393
285
|
* Sets whether users belonging to the given role are allowed
|
|
394
286
|
* to read this object.
|
|
@@ -397,24 +289,17 @@ class ParseACL {
|
|
|
397
289
|
* @param {boolean} allowed Whether the given role can read this object.
|
|
398
290
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
399
291
|
*/
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
setRoleReadAccess(role
|
|
403
|
-
/*: ParseRole | string*/
|
|
404
|
-
, allowed
|
|
405
|
-
/*: boolean*/
|
|
406
|
-
) {
|
|
292
|
+
setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
407
293
|
if (role instanceof _ParseRole.default) {
|
|
408
294
|
// Normalize to the String name
|
|
409
295
|
role = role.getName();
|
|
410
296
|
}
|
|
411
|
-
|
|
412
297
|
if (typeof role !== 'string') {
|
|
413
298
|
throw new TypeError('role must be a ParseRole or a String');
|
|
414
299
|
}
|
|
415
|
-
|
|
416
300
|
this.setReadAccess('role:' + role, allowed);
|
|
417
301
|
}
|
|
302
|
+
|
|
418
303
|
/**
|
|
419
304
|
* Sets whether users belonging to the given role are allowed
|
|
420
305
|
* to write this object.
|
|
@@ -423,26 +308,16 @@ class ParseACL {
|
|
|
423
308
|
* @param {boolean} allowed Whether the given role can write this object.
|
|
424
309
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
425
310
|
*/
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
setRoleWriteAccess(role
|
|
429
|
-
/*: ParseRole | string*/
|
|
430
|
-
, allowed
|
|
431
|
-
/*: boolean*/
|
|
432
|
-
) {
|
|
311
|
+
setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
433
312
|
if (role instanceof _ParseRole.default) {
|
|
434
313
|
// Normalize to the String name
|
|
435
314
|
role = role.getName();
|
|
436
315
|
}
|
|
437
|
-
|
|
438
316
|
if (typeof role !== 'string') {
|
|
439
317
|
throw new TypeError('role must be a ParseRole or a String');
|
|
440
318
|
}
|
|
441
|
-
|
|
442
319
|
this.setWriteAccess('role:' + role, allowed);
|
|
443
320
|
}
|
|
444
|
-
|
|
445
321
|
}
|
|
446
|
-
|
|
447
322
|
var _default = ParseACL;
|
|
448
323
|
exports.default = _default;
|