casbin 5.20.2 → 5.20.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [5.20.4](https://github.com/casbin/node-casbin/compare/v5.20.3...v5.20.4) (2023-01-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add groupPolicy for GetPermissionForUser in frontend.ts ([#415](https://github.com/casbin/node-casbin/issues/415)) ([5d1a679](https://github.com/casbin/node-casbin/commit/5d1a6795f94af487218f10dce85fe191fb0dea37))
7
+
8
+ ## [5.20.3](https://github.com/casbin/node-casbin/compare/v5.20.2...v5.20.3) (2023-01-10)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Multiline Separator Handling ([#411](https://github.com/casbin/node-casbin/issues/411)) ([ab3467a](https://github.com/casbin/node-casbin/commit/ab3467a40004d48d323ebc79078077c8e1593514))
14
+
1
15
  ## [5.20.2](https://github.com/casbin/node-casbin/compare/v5.20.1...v5.20.2) (2023-01-08)
2
16
 
3
17
 
package/lib/cjs/config.js CHANGED
@@ -96,7 +96,7 @@ class Config {
96
96
  }
97
97
  else {
98
98
  let shouldWrite = false;
99
- if (line.includes(Config.DEFAULT_MULTI_LINE_SEPARATOR)) {
99
+ if (line.endsWith(Config.DEFAULT_MULTI_LINE_SEPARATOR)) {
100
100
  currentLine += line.substring(0, line.length - 1).trim();
101
101
  }
102
102
  else {
@@ -14,6 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.casbinJsGetPermissionForUser = void 0;
17
+ const lodash_1 = require("lodash");
17
18
  const util_1 = require("./util");
18
19
  /**
19
20
  * Experiment!
@@ -40,10 +41,15 @@ async function casbinJsGetPermissionForUser(e, user) {
40
41
  s += '[matchers]\n';
41
42
  s += `m = ${(_l = (_k = m.get('m')) === null || _k === void 0 ? void 0 : _k.get('m')) === null || _l === void 0 ? void 0 : _l.value.replace(/_/g, '.')}`;
42
43
  obj['m'] = s;
43
- obj['p'] = util_1.deepCopy(await e.getPolicy());
44
- for (const arr of obj['p']) {
45
- arr.splice(0, 0, 'p');
46
- }
44
+ const policy = util_1.deepCopy(await e.getPolicy());
45
+ const groupPolicy = util_1.deepCopy(await e.getGroupingPolicy());
46
+ policy.forEach((item) => {
47
+ item.unshift('p');
48
+ });
49
+ groupPolicy.forEach((item) => {
50
+ item.unshift('g');
51
+ });
52
+ obj['p'] = lodash_1.concat(policy, groupPolicy);
47
53
  return JSON.stringify(obj);
48
54
  }
49
55
  exports.casbinJsGetPermissionForUser = casbinJsGetPermissionForUser;
package/lib/esm/config.js CHANGED
@@ -93,7 +93,7 @@ export class Config {
93
93
  }
94
94
  else {
95
95
  let shouldWrite = false;
96
- if (line.includes(Config.DEFAULT_MULTI_LINE_SEPARATOR)) {
96
+ if (line.endsWith(Config.DEFAULT_MULTI_LINE_SEPARATOR)) {
97
97
  currentLine += line.substring(0, line.length - 1).trim();
98
98
  }
99
99
  else {
@@ -11,6 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
+ import { concat } from 'lodash';
14
15
  import { deepCopy } from './util';
15
16
  /**
16
17
  * Experiment!
@@ -37,9 +38,14 @@ export async function casbinJsGetPermissionForUser(e, user) {
37
38
  s += '[matchers]\n';
38
39
  s += `m = ${(_l = (_k = m.get('m')) === null || _k === void 0 ? void 0 : _k.get('m')) === null || _l === void 0 ? void 0 : _l.value.replace(/_/g, '.')}`;
39
40
  obj['m'] = s;
40
- obj['p'] = deepCopy(await e.getPolicy());
41
- for (const arr of obj['p']) {
42
- arr.splice(0, 0, 'p');
43
- }
41
+ const policy = deepCopy(await e.getPolicy());
42
+ const groupPolicy = deepCopy(await e.getGroupingPolicy());
43
+ policy.forEach((item) => {
44
+ item.unshift('p');
45
+ });
46
+ groupPolicy.forEach((item) => {
47
+ item.unshift('g');
48
+ });
49
+ obj['p'] = concat(policy, groupPolicy);
44
50
  return JSON.stringify(obj);
45
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casbin",
3
- "version": "5.20.2",
3
+ "version": "5.20.4",
4
4
  "description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS",
5
5
  "main": "lib/cjs/index.js",
6
6
  "typings": "lib/cjs/index.d.ts",