ParseCLP.js 21 KB

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