ParseCLP.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _ParseRole = _interopRequireDefault(require("./ParseRole"));
  7. var _ParseUser = _interopRequireDefault(require("./ParseUser"));
  8. function _interopRequireDefault(obj) {
  9. return obj && obj.__esModule ? obj : {
  10. default: obj
  11. };
  12. }
  13. /**
  14. * @flow
  15. */
  16. /*:: type Entity = Entity;*/
  17. /*:: type UsersMap = { [userId: string]: boolean | any };*/
  18. /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
  19. const PUBLIC_KEY = '*';
  20. const VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new Map(
  21. /*:: <string, UsersMap>*/
  22. );
  23. VALID_PERMISSIONS.set('get', {});
  24. VALID_PERMISSIONS.set('find', {});
  25. VALID_PERMISSIONS.set('count', {});
  26. VALID_PERMISSIONS.set('create', {});
  27. VALID_PERMISSIONS.set('update', {});
  28. VALID_PERMISSIONS.set('delete', {});
  29. VALID_PERMISSIONS.set('addField', {});
  30. const VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new Map(
  31. /*:: <string, UsersMap>*/
  32. );
  33. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  34. /**
  35. * Creates a new CLP.
  36. * If no argument is given, the CLP has no permissions for anyone.
  37. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  38. * permission for only that user or role.
  39. * If the argument is any other JSON object, that object will be interpretted
  40. * as a serialized CLP created with toJSON().
  41. *
  42. * <p>A CLP, or Class Level Permissions can be added to any
  43. * <code>Parse.Schema</code> to restrict access to only a subset of users
  44. * of your application.</p>
  45. *
  46. * <p>
  47. * For get/count/find/create/update/delete/addField using the following functions:
  48. *
  49. * Entity is type Parse.User or Parse.Role or string
  50. * Role is type Parse.Role or Name of Parse.Role
  51. *
  52. * getGetRequiresAuthentication()
  53. * setGetRequiresAuthentication(allowed: boolean)
  54. * getGetPointerFields()
  55. * setGetPointerFields(pointerFields: string[])
  56. * getGetAccess(entity: Entity)
  57. * setGetAccess(entity: Entity, allowed: boolean)
  58. * getPublicGetAccess()
  59. * setPublicGetAccess(allowed: boolean)
  60. * getRoleGetAccess(role: Role)
  61. * setRoleGetAccess(role: Role, allowed: boolean)
  62. * getFindRequiresAuthentication()
  63. * setFindRequiresAuthentication(allowed: boolean)
  64. * getFindPointerFields()
  65. * setFindPointerFields(pointerFields: string[])
  66. * getFindAccess(entity: Entity)
  67. * setFindAccess(entity: Entity, allowed: boolean)
  68. * getPublicFindAccess()
  69. * setPublicFindAccess(allowed: boolean)
  70. * getRoleFindAccess(role: Role)
  71. * setRoleFindAccess(role: Role, allowed: boolean)
  72. * getCountRequiresAuthentication()
  73. * setCountRequiresAuthentication(allowed: boolean)
  74. * getCountPointerFields()
  75. * setCountPointerFields(pointerFields: string[])
  76. * getCountAccess(entity: Entity)
  77. * setCountAccess(entity: Entity, allowed: boolean)
  78. * getPublicCountAccess()
  79. * setPublicCountAccess(allowed: boolean)
  80. * getRoleCountAccess(role: Role)
  81. * setRoleCountAccess(role: Role, allowed: boolean)
  82. * getCreateRequiresAuthentication()
  83. * setCreateRequiresAuthentication(allowed: boolean)
  84. * getCreatePointerFields()
  85. * setCreatePointerFields(pointerFields: string[])
  86. * getCreateAccess(entity: Entity)
  87. * setCreateAccess(entity: Entity, allowed: boolean)
  88. * getPublicCreateAccess()
  89. * setPublicCreateAccess(allowed: Boolean)
  90. * getRoleCreateAccess(role: Role)
  91. * setRoleCreateAccess(role: Role, allowed: boolean)
  92. * getUpdateRequiresAuthentication()
  93. * setUpdateRequiresAuthentication(allowed: boolean)
  94. * getUpdatePointerFields()
  95. * setUpdatePointerFields(pointerFields: string[])
  96. * getUpdateAccess(entity: Entity)
  97. * setUpdateAccess(entity: Entity, allowed: boolean)
  98. * getPublicUpdateAccess()
  99. * setPublicUpdateAccess(allowed: boolean)
  100. * getRoleUpdateAccess(role: Role)
  101. * setRoleUpdateAccess(role: Role, allowed: boolean)
  102. * getDeleteRequiresAuthentication()
  103. * setDeleteRequiresAuthentication(allowed: boolean)
  104. * getDeletePointerFields()
  105. * setDeletePointerFields(pointerFields: string[])
  106. * getDeleteAccess(entity: Entity)
  107. * setDeleteAccess(entity: Entity, allowed: boolean)
  108. * getPublicDeleteAccess()
  109. * setPublicDeleteAccess(allowed: boolean)
  110. * getRoleDeleteAccess(role: Role)
  111. * setRoleDeleteAccess(role: Role, allowed: boolean)
  112. * getAddFieldRequiresAuthentication()
  113. * setAddFieldRequiresAuthentication(allowed: boolean)
  114. * getAddFieldPointerFields()
  115. * setAddFieldPointerFields(pointerFields: string[])
  116. * getAddFieldAccess(entity: Entity)
  117. * setAddFieldAccess(entity: Entity, allowed: boolean)
  118. * getPublicAddFieldAccess()
  119. * setPublicAddFieldAccess(allowed: boolean)
  120. * getRoleAddFieldAccess(role: Role)
  121. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  122. * </p>
  123. *
  124. * @alias Parse.CLP
  125. */
  126. class ParseCLP {
  127. /*:: permissionsMap: PermissionsMap;*/
  128. /**
  129. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  130. */
  131. constructor(userId /*: ParseUser | ParseRole | PermissionsMap*/) {
  132. this.permissionsMap = {};
  133. // Initialize permissions Map with default permissions
  134. for (const [operation, group] of VALID_PERMISSIONS.entries()) {
  135. this.permissionsMap[operation] = Object.assign({}, group);
  136. const action = operation.charAt(0).toUpperCase() + operation.slice(1);
  137. this[`get${action}RequiresAuthentication`] = function () {
  138. return this._getAccess(operation, 'requiresAuthentication');
  139. };
  140. this[`set${action}RequiresAuthentication`] = function (allowed) {
  141. this._setAccess(operation, 'requiresAuthentication', allowed);
  142. };
  143. this[`get${action}PointerFields`] = function () {
  144. return this._getAccess(operation, 'pointerFields', false);
  145. };
  146. this[`set${action}PointerFields`] = function (pointerFields) {
  147. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  148. };
  149. this[`get${action}Access`] = function (entity) {
  150. return this._getAccess(operation, entity);
  151. };
  152. this[`set${action}Access`] = function (entity, allowed) {
  153. this._setAccess(operation, entity, allowed);
  154. };
  155. this[`getPublic${action}Access`] = function () {
  156. return this[`get${action}Access`](PUBLIC_KEY);
  157. };
  158. this[`setPublic${action}Access`] = function (allowed) {
  159. this[`set${action}Access`](PUBLIC_KEY, allowed);
  160. };
  161. this[`getRole${action}Access`] = function (role) {
  162. return this[`get${action}Access`](this._getRoleName(role));
  163. };
  164. this[`setRole${action}Access`] = function (role, allowed) {
  165. this[`set${action}Access`](this._getRoleName(role), allowed);
  166. };
  167. }
  168. // Initialize permissions Map with default extended permissions
  169. for (const [operation, group] of VALID_PERMISSIONS_EXTENDED.entries()) {
  170. this.permissionsMap[operation] = Object.assign({}, group);
  171. }
  172. if (userId && typeof userId === 'object') {
  173. if (userId instanceof _ParseUser.default) {
  174. this.setReadAccess(userId, true);
  175. this.setWriteAccess(userId, true);
  176. } else if (userId instanceof _ParseRole.default) {
  177. this.setRoleReadAccess(userId, true);
  178. this.setRoleWriteAccess(userId, true);
  179. } else {
  180. for (const permission in userId) {
  181. const users = userId[permission];
  182. const isValidPermission = !!VALID_PERMISSIONS.get(permission);
  183. const isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(permission);
  184. const isValidGroupPermission = ['readUserFields', 'writeUserFields'].includes(permission);
  185. if (typeof permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  186. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  187. }
  188. if (isValidGroupPermission) {
  189. if (users.every(pointer => typeof pointer === 'string')) {
  190. this.permissionsMap[permission] = users;
  191. continue;
  192. } else {
  193. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  194. }
  195. }
  196. for (const user in users) {
  197. const allowed = users[user];
  198. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  199. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  200. }
  201. this.permissionsMap[permission][user] = allowed;
  202. }
  203. }
  204. }
  205. } else if (typeof userId === 'function') {
  206. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  207. }
  208. }
  209. /**
  210. * Returns a JSON-encoded version of the CLP.
  211. *
  212. * @returns {object}
  213. */
  214. toJSON() /*: PermissionsMap*/{
  215. return {
  216. ...this.permissionsMap
  217. };
  218. }
  219. /**
  220. * Returns whether this CLP is equal to another object
  221. *
  222. * @param other The other object to compare to
  223. * @returns {boolean}
  224. */
  225. equals(other /*: ParseCLP*/) /*: boolean*/{
  226. if (!(other instanceof ParseCLP)) {
  227. return false;
  228. }
  229. const permissions = Object.keys(this.permissionsMap);
  230. const otherPermissions = Object.keys(other.permissionsMap);
  231. if (permissions.length !== otherPermissions.length) {
  232. return false;
  233. }
  234. for (const permission in this.permissionsMap) {
  235. if (!other.permissionsMap[permission]) {
  236. return false;
  237. }
  238. const users = Object.keys(this.permissionsMap[permission]);
  239. const otherUsers = Object.keys(other.permissionsMap[permission]);
  240. if (users.length !== otherUsers.length) {
  241. return false;
  242. }
  243. for (const user in this.permissionsMap[permission]) {
  244. if (!other.permissionsMap[permission][user]) {
  245. return false;
  246. }
  247. if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
  248. return false;
  249. }
  250. }
  251. }
  252. return true;
  253. }
  254. _getRoleName(role /*: ParseRole | string*/) /*: string*/{
  255. let name = role;
  256. if (role instanceof _ParseRole.default) {
  257. // Normalize to the String name
  258. name = role.getName();
  259. }
  260. if (typeof name !== 'string') {
  261. throw new TypeError('role must be a Parse.Role or a String');
  262. }
  263. return `role:${name}`;
  264. }
  265. _parseEntity(entity /*: Entity*/) {
  266. let userId = entity;
  267. if (userId instanceof _ParseUser.default) {
  268. userId = userId.id;
  269. if (!userId) {
  270. throw new Error('Cannot get access for a Parse.User without an id.');
  271. }
  272. } else if (userId instanceof _ParseRole.default) {
  273. userId = this._getRoleName(userId);
  274. }
  275. if (typeof userId !== 'string') {
  276. throw new TypeError('userId must be a string.');
  277. }
  278. return userId;
  279. }
  280. _setAccess(permission /*: string*/, userId /*: Entity*/, allowed /*: boolean*/) {
  281. userId = this._parseEntity(userId);
  282. if (typeof allowed !== 'boolean') {
  283. throw new TypeError('allowed must be either true or false.');
  284. }
  285. const permissions = this.permissionsMap[permission][userId];
  286. if (!permissions) {
  287. if (!allowed) {
  288. // The user already doesn't have this permission, so no action is needed
  289. return;
  290. } else {
  291. this.permissionsMap[permission][userId] = {};
  292. }
  293. }
  294. if (allowed) {
  295. this.permissionsMap[permission][userId] = true;
  296. } else {
  297. delete this.permissionsMap[permission][userId];
  298. }
  299. }
  300. _getAccess(permission /*: string*/, userId /*: Entity*/, returnBoolean = true) /*: boolean | string[]*/{
  301. userId = this._parseEntity(userId);
  302. const permissions = this.permissionsMap[permission][userId];
  303. if (returnBoolean) {
  304. if (!permissions) {
  305. return false;
  306. }
  307. return !!this.permissionsMap[permission][userId];
  308. }
  309. return permissions;
  310. }
  311. _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string*/) {
  312. userId = this._parseEntity(userId);
  313. const permissions = this.permissionsMap[permission][userId];
  314. if (!permissions) {
  315. this.permissionsMap[permission][userId] = [];
  316. }
  317. if (!fields || Array.isArray(fields) && fields.length === 0) {
  318. delete this.permissionsMap[permission][userId];
  319. } else if (Array.isArray(fields) && fields.every(field => typeof field === 'string')) {
  320. this.permissionsMap[permission][userId] = fields;
  321. } else {
  322. throw new TypeError('fields must be an array of strings or undefined.');
  323. }
  324. }
  325. _setGroupPointerPermission(operation /*: string*/, pointerFields /*: string[]*/) {
  326. const fields = this.permissionsMap[operation];
  327. if (!fields) {
  328. this.permissionsMap[operation] = [];
  329. }
  330. if (!pointerFields || Array.isArray(pointerFields) && pointerFields.length === 0) {
  331. delete this.permissionsMap[operation];
  332. } else if (Array.isArray(pointerFields) && pointerFields.every(field => typeof field === 'string')) {
  333. this.permissionsMap[operation] = pointerFields;
  334. } else {
  335. throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
  336. }
  337. }
  338. _getGroupPointerPermissions(operation /*: string*/) /*: string[]*/{
  339. return this.permissionsMap[operation];
  340. }
  341. /**
  342. * Sets user pointer fields to allow permission for get/count/find operations.
  343. *
  344. * @param {string[]} pointerFields User pointer fields
  345. */
  346. setReadUserFields(pointerFields /*: string[]*/) {
  347. this._setGroupPointerPermission('readUserFields', pointerFields);
  348. }
  349. /**
  350. * @returns {string[]} User pointer fields
  351. */
  352. getReadUserFields() /*: string[]*/{
  353. return this._getGroupPointerPermissions('readUserFields');
  354. }
  355. /**
  356. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  357. *
  358. * @param {string[]} pointerFields User pointer fields
  359. */
  360. setWriteUserFields(pointerFields /*: string[]*/) {
  361. this._setGroupPointerPermission('writeUserFields', pointerFields);
  362. }
  363. /**
  364. * @returns {string[]} User pointer fields
  365. */
  366. getWriteUserFields() /*: string[]*/{
  367. return this._getGroupPointerPermissions('writeUserFields');
  368. }
  369. /**
  370. * Sets whether the given user is allowed to retrieve fields from this class.
  371. *
  372. * @param userId An instance of Parse.User or its objectId.
  373. * @param {string[]} fields fields to be protected
  374. */
  375. setProtectedFields(userId /*: Entity*/, fields /*: string[]*/) {
  376. this._setArrayAccess('protectedFields', userId, fields);
  377. }
  378. /**
  379. * Returns array of fields are accessable to this user.
  380. *
  381. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  382. * @returns {string[]}
  383. */
  384. getProtectedFields(userId /*: Entity*/) /*: string[]*/{
  385. return this._getAccess('protectedFields', userId, false);
  386. }
  387. /**
  388. * Sets whether the given user is allowed to read from this class.
  389. *
  390. * @param userId An instance of Parse.User or its objectId.
  391. * @param {boolean} allowed whether that user should have read access.
  392. */
  393. setReadAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  394. this._setAccess('find', userId, allowed);
  395. this._setAccess('get', userId, allowed);
  396. this._setAccess('count', userId, allowed);
  397. }
  398. /**
  399. * Get whether the given user id is *explicitly* allowed to read from this class.
  400. * Even if this returns false, the user may still be able to access it if
  401. * getPublicReadAccess returns true or a role that the user belongs to has
  402. * write access.
  403. *
  404. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  405. * @returns {boolean}
  406. */
  407. getReadAccess(userId /*: Entity*/) /*: boolean*/{
  408. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  409. }
  410. /**
  411. * Sets whether the given user id is allowed to write to this class.
  412. *
  413. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  414. * @param {boolean} allowed Whether that user should have write access.
  415. */
  416. setWriteAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  417. this._setAccess('create', userId, allowed);
  418. this._setAccess('update', userId, allowed);
  419. this._setAccess('delete', userId, allowed);
  420. this._setAccess('addField', userId, allowed);
  421. }
  422. /**
  423. * Gets whether the given user id is *explicitly* allowed to write to this class.
  424. * Even if this returns false, the user may still be able to write it if
  425. * getPublicWriteAccess returns true or a role that the user belongs to has
  426. * write access.
  427. *
  428. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  429. * @returns {boolean}
  430. */
  431. getWriteAccess(userId /*: Entity*/) /*: boolean*/{
  432. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  433. }
  434. /**
  435. * Sets whether the public is allowed to read from this class.
  436. *
  437. * @param {boolean} allowed
  438. */
  439. setPublicReadAccess(allowed /*: boolean*/) {
  440. this.setReadAccess(PUBLIC_KEY, allowed);
  441. }
  442. /**
  443. * Gets whether the public is allowed to read from this class.
  444. *
  445. * @returns {boolean}
  446. */
  447. getPublicReadAccess() /*: boolean*/{
  448. return this.getReadAccess(PUBLIC_KEY);
  449. }
  450. /**
  451. * Sets whether the public is allowed to write to this class.
  452. *
  453. * @param {boolean} allowed
  454. */
  455. setPublicWriteAccess(allowed /*: boolean*/) {
  456. this.setWriteAccess(PUBLIC_KEY, allowed);
  457. }
  458. /**
  459. * Gets whether the public is allowed to write to this class.
  460. *
  461. * @returns {boolean}
  462. */
  463. getPublicWriteAccess() /*: boolean*/{
  464. return this.getWriteAccess(PUBLIC_KEY);
  465. }
  466. /**
  467. * Sets whether the public is allowed to protect fields in this class.
  468. *
  469. * @param {string[]} fields
  470. */
  471. setPublicProtectedFields(fields /*: string[]*/) {
  472. this.setProtectedFields(PUBLIC_KEY, fields);
  473. }
  474. /**
  475. * Gets whether the public is allowed to read fields from this class.
  476. *
  477. * @returns {string[]}
  478. */
  479. getPublicProtectedFields() /*: string[]*/{
  480. return this.getProtectedFields(PUBLIC_KEY);
  481. }
  482. /**
  483. * Gets whether users belonging to the given role are allowed
  484. * to read from this class. Even if this returns false, the role may
  485. * still be able to write it if a parent role has read access.
  486. *
  487. * @param role The name of the role, or a Parse.Role object.
  488. * @returns {boolean} true if the role has read access. false otherwise.
  489. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  490. */
  491. getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
  492. return this.getReadAccess(this._getRoleName(role));
  493. }
  494. /**
  495. * Gets whether users belonging to the given role are allowed
  496. * to write to this user. Even if this returns false, the role may
  497. * still be able to write it if a parent role has write access.
  498. *
  499. * @param role The name of the role, or a Parse.Role object.
  500. * @returns {boolean} true if the role has write access. false otherwise.
  501. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  502. */
  503. getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
  504. return this.getWriteAccess(this._getRoleName(role));
  505. }
  506. /**
  507. * Sets whether users belonging to the given role are allowed
  508. * to read from this class.
  509. *
  510. * @param role The name of the role, or a Parse.Role object.
  511. * @param {boolean} allowed Whether the given role can read this object.
  512. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  513. */
  514. setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  515. this.setReadAccess(this._getRoleName(role), allowed);
  516. }
  517. /**
  518. * Sets whether users belonging to the given role are allowed
  519. * to write to this class.
  520. *
  521. * @param role The name of the role, or a Parse.Role object.
  522. * @param {boolean} allowed Whether the given role can write this object.
  523. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  524. */
  525. setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  526. this.setWriteAccess(this._getRoleName(role), allowed);
  527. }
  528. /**
  529. * Gets whether users belonging to the given role are allowed
  530. * to count to this user. Even if this returns false, the role may
  531. * still be able to count it if a parent role has count access.
  532. *
  533. * @param role The name of the role, or a Parse.Role object.
  534. * @returns {string[]}
  535. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  536. */
  537. getRoleProtectedFields(role /*: ParseRole | string*/) /*: string[]*/{
  538. return this.getProtectedFields(this._getRoleName(role));
  539. }
  540. /**
  541. * Sets whether users belonging to the given role are allowed
  542. * to set access field in this class.
  543. *
  544. * @param role The name of the role, or a Parse.Role object.
  545. * @param {string[]} fields Fields to be protected by Role.
  546. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  547. */
  548. setRoleProtectedFields(role /*: ParseRole | string*/, fields /*: string[]*/) {
  549. this.setProtectedFields(this._getRoleName(role), fields);
  550. }
  551. }
  552. var _default = ParseCLP;
  553. exports.default = _default;