casbin 5.47.0 → 5.49.0
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/lib/cjs/cachedEnforcer.js +1 -1
- package/lib/cjs/config.js +1 -1
- package/lib/cjs/coreEnforcer.js +25 -25
- package/lib/cjs/effect/defaultEffectorStream.js +5 -5
- package/lib/cjs/effect/index.js +6 -2
- package/lib/cjs/enforceContext.js +2 -1
- package/lib/cjs/enforcer.js +17 -13
- package/lib/cjs/frontend.js +2 -2
- package/lib/cjs/index.js +7 -3
- package/lib/cjs/internalEnforcer.d.ts +8 -0
- package/lib/cjs/internalEnforcer.js +105 -11
- package/lib/cjs/log/index.js +6 -2
- package/lib/cjs/managementEnforcer.d.ts +4 -3
- package/lib/cjs/managementEnforcer.js +13 -10
- package/lib/cjs/model/assertion.js +7 -3
- package/lib/cjs/model/functionMap.d.ts +1 -1
- package/lib/cjs/model/functionMap.js +6 -2
- package/lib/cjs/model/index.js +6 -2
- package/lib/cjs/model/model.js +17 -13
- package/lib/cjs/persist/defaultFilteredAdapter.js +1 -1
- package/lib/cjs/persist/fileAdapter.js +4 -4
- package/lib/cjs/persist/fileSystem.d.ts +1 -1
- package/lib/cjs/persist/fileSystem.js +6 -3
- package/lib/cjs/persist/helper.js +1 -1
- package/lib/cjs/persist/index.js +6 -2
- package/lib/cjs/rbac/defaultRoleManager.d.ts +1 -1
- package/lib/cjs/rbac/defaultRoleManager.js +2 -2
- package/lib/cjs/rbac/index.js +6 -2
- package/lib/cjs/syncedEnforcer.js +1 -1
- package/lib/cjs/util/builtinOperators.js +1 -1
- package/lib/cjs/util/index.js +6 -2
- package/lib/cjs/util/ip.d.ts +3 -3
- package/lib/cjs/util/util.d.ts +2 -2
- package/lib/cjs/util/util.js +4 -4
- package/lib/esm/constants.js +1 -0
- package/lib/esm/effect/defaultEffectorStream.js +5 -5
- package/lib/esm/effect/effectorStream.js +1 -0
- package/lib/esm/enforcer.js +5 -5
- package/lib/esm/internalEnforcer.d.ts +8 -0
- package/lib/esm/internalEnforcer.js +105 -11
- package/lib/esm/log/logger.js +1 -0
- package/lib/esm/managementEnforcer.d.ts +4 -3
- package/lib/esm/managementEnforcer.js +13 -10
- package/lib/esm/model/functionMap.d.ts +1 -1
- package/lib/esm/model/model.js +6 -6
- package/lib/esm/persist/adapter.js +1 -0
- package/lib/esm/persist/batchAdapter.js +1 -0
- package/lib/esm/persist/fileSystem.d.ts +1 -1
- package/lib/esm/persist/filteredAdapter.js +1 -0
- package/lib/esm/persist/updatableAdapter.js +1 -0
- package/lib/esm/persist/watcher.js +1 -0
- package/lib/esm/persist/watcherEx.js +1 -0
- package/lib/esm/rbac/defaultRoleManager.d.ts +1 -1
- package/lib/esm/rbac/roleManager.js +1 -0
- package/lib/esm/util/ip.d.ts +3 -3
- package/lib/esm/util/util.d.ts +2 -2
- package/lib/esm/util/util.js +2 -2
- package/package.json +3 -3
|
@@ -24,12 +24,13 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
24
24
|
if (this.model.hasPolicy(sec, ptype, rule)) {
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
27
28
|
if (this.adapter && this.autoSave) {
|
|
28
29
|
try {
|
|
29
30
|
await this.adapter.addPolicy(sec, ptype, rule);
|
|
30
31
|
}
|
|
31
32
|
catch (e) {
|
|
32
|
-
if (e.message !== 'not implemented') {
|
|
33
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
33
34
|
throw e;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -59,13 +60,14 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
64
|
+
if (this.adapter && this.autoSave) {
|
|
63
65
|
if ('addPolicies' in this.adapter) {
|
|
64
66
|
try {
|
|
65
67
|
await this.adapter.addPolicies(sec, ptype, rules);
|
|
66
68
|
}
|
|
67
69
|
catch (e) {
|
|
68
|
-
if (e.message !== 'not implemented') {
|
|
70
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
69
71
|
throw e;
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -103,13 +105,14 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
103
105
|
if (newRules.length === 0) {
|
|
104
106
|
return false;
|
|
105
107
|
}
|
|
106
|
-
|
|
108
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
109
|
+
if (this.adapter && this.autoSave) {
|
|
107
110
|
if ('addPolicies' in this.adapter) {
|
|
108
111
|
try {
|
|
109
112
|
await this.adapter.addPolicies(sec, ptype, newRules);
|
|
110
113
|
}
|
|
111
114
|
catch (e) {
|
|
112
|
-
if (e.message !== 'not implemented') {
|
|
115
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
113
116
|
throw e;
|
|
114
117
|
}
|
|
115
118
|
}
|
|
@@ -142,13 +145,14 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
142
145
|
if (!this.model.hasPolicy(sec, ptype, oldRule)) {
|
|
143
146
|
return false;
|
|
144
147
|
}
|
|
145
|
-
|
|
148
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
149
|
+
if (this.adapter && this.autoSave) {
|
|
146
150
|
if ('updatePolicy' in this.adapter) {
|
|
147
151
|
try {
|
|
148
152
|
await this.adapter.updatePolicy(sec, ptype, oldRule, newRule);
|
|
149
153
|
}
|
|
150
154
|
catch (e) {
|
|
151
|
-
if (e.message !== 'not implemented') {
|
|
155
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
152
156
|
throw e;
|
|
153
157
|
}
|
|
154
158
|
}
|
|
@@ -180,12 +184,13 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
180
184
|
if (!this.model.hasPolicy(sec, ptype, rule)) {
|
|
181
185
|
return false;
|
|
182
186
|
}
|
|
187
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
183
188
|
if (this.adapter && this.autoSave) {
|
|
184
189
|
try {
|
|
185
190
|
await this.adapter.removePolicy(sec, ptype, rule);
|
|
186
191
|
}
|
|
187
192
|
catch (e) {
|
|
188
|
-
if (e.message !== 'not implemented') {
|
|
193
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
189
194
|
throw e;
|
|
190
195
|
}
|
|
191
196
|
}
|
|
@@ -214,13 +219,14 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
214
219
|
return false;
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
|
-
|
|
222
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
223
|
+
if (this.adapter && this.autoSave) {
|
|
218
224
|
if ('removePolicies' in this.adapter) {
|
|
219
225
|
try {
|
|
220
226
|
await this.adapter.removePolicies(sec, ptype, rules);
|
|
221
227
|
}
|
|
222
228
|
catch (e) {
|
|
223
|
-
if (e.message !== 'not implemented') {
|
|
229
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
224
230
|
throw e;
|
|
225
231
|
}
|
|
226
232
|
}
|
|
@@ -250,12 +256,13 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
250
256
|
* removeFilteredPolicyInternal removes rules based on field filters from the current policy.
|
|
251
257
|
*/
|
|
252
258
|
async removeFilteredPolicyInternal(sec, ptype, fieldIndex, fieldValues, useWatcher) {
|
|
259
|
+
// Persist when an adapter is configured and autoSave is enabled.
|
|
253
260
|
if (this.adapter && this.autoSave) {
|
|
254
261
|
try {
|
|
255
262
|
await this.adapter.removeFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues);
|
|
256
263
|
}
|
|
257
264
|
catch (e) {
|
|
258
|
-
if (e.message !== 'not implemented') {
|
|
265
|
+
if (e instanceof Error && e.message !== 'not implemented') {
|
|
259
266
|
throw e;
|
|
260
267
|
}
|
|
261
268
|
}
|
|
@@ -291,4 +298,91 @@ export class InternalEnforcer extends CoreEnforcer {
|
|
|
291
298
|
const assertion = (_a = this.model.model.get('p')) === null || _a === void 0 ? void 0 : _a.get(ptype);
|
|
292
299
|
assertion === null || assertion === void 0 ? void 0 : assertion.fieldIndexMap.set(field, index);
|
|
293
300
|
}
|
|
301
|
+
async addPolicyWithoutNotify(sec, ptype, rule) {
|
|
302
|
+
if (this.model.hasPolicy(sec, ptype, rule)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
const ok = this.model.addPolicy(sec, ptype, rule);
|
|
306
|
+
if (sec === 'g' && ok) {
|
|
307
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyAdd, ptype, [rule]);
|
|
308
|
+
}
|
|
309
|
+
return ok;
|
|
310
|
+
}
|
|
311
|
+
async addPoliciesWithoutNotify(sec, ptype, rules) {
|
|
312
|
+
for (const rule of rules) {
|
|
313
|
+
if (this.model.hasPolicy(sec, ptype, rule)) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const [ok, effects] = await this.model.addPolicies(sec, ptype, rules);
|
|
318
|
+
if (sec === 'g' && ok && (effects === null || effects === void 0 ? void 0 : effects.length)) {
|
|
319
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyAdd, ptype, effects);
|
|
320
|
+
}
|
|
321
|
+
return ok;
|
|
322
|
+
}
|
|
323
|
+
async addPoliciesWithoutNotifyEx(sec, ptype, rules) {
|
|
324
|
+
const newRules = rules.filter((rule) => !this.model.hasPolicy(sec, ptype, rule));
|
|
325
|
+
if (newRules.length === 0) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
const [ok, effects] = await this.model.addPolicies(sec, ptype, newRules);
|
|
329
|
+
if (sec === 'g' && ok && (effects === null || effects === void 0 ? void 0 : effects.length)) {
|
|
330
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyAdd, ptype, effects);
|
|
331
|
+
}
|
|
332
|
+
return ok;
|
|
333
|
+
}
|
|
334
|
+
async updatePolicyWithoutNotify(sec, ptype, oldRule, newRule) {
|
|
335
|
+
if (!this.model.hasPolicy(sec, ptype, oldRule)) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const ok = this.model.updatePolicy(sec, ptype, oldRule, newRule);
|
|
339
|
+
if (sec === 'g' && ok) {
|
|
340
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyRemove, ptype, [oldRule]);
|
|
341
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyAdd, ptype, [newRule]);
|
|
342
|
+
}
|
|
343
|
+
return ok;
|
|
344
|
+
}
|
|
345
|
+
async removePolicyWithoutNotify(sec, ptype, rule) {
|
|
346
|
+
if (!this.model.hasPolicy(sec, ptype, rule)) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
const ok = await this.model.removePolicy(sec, ptype, rule);
|
|
350
|
+
if (sec === 'g' && ok) {
|
|
351
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyRemove, ptype, [rule]);
|
|
352
|
+
}
|
|
353
|
+
return ok;
|
|
354
|
+
}
|
|
355
|
+
async removePoliciesWithoutNotify(sec, ptype, rules) {
|
|
356
|
+
for (const rule of rules) {
|
|
357
|
+
if (!this.model.hasPolicy(sec, ptype, rule)) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const [ok, effects] = this.model.removePolicies(sec, ptype, rules);
|
|
362
|
+
if (sec === 'g' && ok && (effects === null || effects === void 0 ? void 0 : effects.length)) {
|
|
363
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyRemove, ptype, effects);
|
|
364
|
+
}
|
|
365
|
+
return ok;
|
|
366
|
+
}
|
|
367
|
+
async removeFilteredPolicyWithoutNotify(sec, ptype, fieldIndex, fieldValues) {
|
|
368
|
+
const [ok, effects] = this.model.removeFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues);
|
|
369
|
+
if (sec === 'g' && ok && (effects === null || effects === void 0 ? void 0 : effects.length)) {
|
|
370
|
+
await this.buildIncrementalRoleLinks(PolicyOp.PolicyRemove, ptype, effects);
|
|
371
|
+
}
|
|
372
|
+
return ok;
|
|
373
|
+
}
|
|
374
|
+
async updatePoliciesWithoutNotify(sec, ptype, oldRules, newRules) {
|
|
375
|
+
// Mirror the Go updatePoliciesWithoutNotify; reuse the existing internal flow.
|
|
376
|
+
// Because updatePoliciesInternal isn't implemented yet, fall back to per-item updates.
|
|
377
|
+
if (oldRules.length !== newRules.length) {
|
|
378
|
+
throw new Error('the length of oldRules should be equal to the length of newRules');
|
|
379
|
+
}
|
|
380
|
+
for (let i = 0; i < oldRules.length; i++) {
|
|
381
|
+
const ok = await this.updatePolicyWithoutNotify(sec, ptype, oldRules[i], newRules[i]);
|
|
382
|
+
if (!ok) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
294
388
|
}
|
package/lib/esm/log/logger.js
CHANGED
|
@@ -429,9 +429,10 @@ export declare class ManagementEnforcer extends InternalEnforcer {
|
|
|
429
429
|
*/
|
|
430
430
|
addFunction(name: string, func: MatchingFunction): Promise<void>;
|
|
431
431
|
selfAddPolicy(sec: string, ptype: string, rule: string[]): Promise<boolean>;
|
|
432
|
+
selfAddPolicies(sec: string, ptype: string, rules: string[][]): Promise<boolean>;
|
|
432
433
|
selfRemovePolicy(sec: string, ptype: string, rule: string[]): Promise<boolean>;
|
|
433
|
-
|
|
434
|
+
selfRemovePolicies(sec: string, ptype: string, rules: string[][]): Promise<boolean>;
|
|
435
|
+
selfRemoveFilteredPolicy(sec: string, ptype: string, fieldIndex: number, ...fieldValues: string[]): Promise<boolean>;
|
|
434
436
|
selfUpdatePolicy(sec: string, ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>;
|
|
435
|
-
|
|
436
|
-
selfRemovePolicies(sec: string, ptype: string, rule: string[][]): Promise<boolean>;
|
|
437
|
+
selfUpdatePolicies(sec: string, ptype: string, oldRules: string[][], newRules: string[][]): Promise<boolean>;
|
|
437
438
|
}
|
|
@@ -539,21 +539,24 @@ export class ManagementEnforcer extends InternalEnforcer {
|
|
|
539
539
|
this.fm.addFunction(name, func);
|
|
540
540
|
}
|
|
541
541
|
async selfAddPolicy(sec, ptype, rule) {
|
|
542
|
-
return this.
|
|
542
|
+
return this.addPolicyWithoutNotify(sec, ptype, rule);
|
|
543
|
+
}
|
|
544
|
+
async selfAddPolicies(sec, ptype, rules) {
|
|
545
|
+
return this.addPoliciesWithoutNotify(sec, ptype, rules);
|
|
543
546
|
}
|
|
544
547
|
async selfRemovePolicy(sec, ptype, rule) {
|
|
545
|
-
return this.
|
|
548
|
+
return this.removePolicyWithoutNotify(sec, ptype, rule);
|
|
546
549
|
}
|
|
547
|
-
async
|
|
548
|
-
return this.
|
|
550
|
+
async selfRemovePolicies(sec, ptype, rules) {
|
|
551
|
+
return this.removePoliciesWithoutNotify(sec, ptype, rules);
|
|
549
552
|
}
|
|
550
|
-
async
|
|
551
|
-
return this.
|
|
553
|
+
async selfRemoveFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues) {
|
|
554
|
+
return this.removeFilteredPolicyWithoutNotify(sec, ptype, fieldIndex, fieldValues);
|
|
552
555
|
}
|
|
553
|
-
async
|
|
554
|
-
return this.
|
|
556
|
+
async selfUpdatePolicy(sec, ptype, oldRule, newRule) {
|
|
557
|
+
return this.updatePolicyWithoutNotify(sec, ptype, oldRule, newRule);
|
|
555
558
|
}
|
|
556
|
-
async
|
|
557
|
-
return this.
|
|
559
|
+
async selfUpdatePolicies(sec, ptype, oldRules, newRules) {
|
|
560
|
+
return this.updatePoliciesWithoutNotify(sec, ptype, oldRules, newRules);
|
|
558
561
|
}
|
|
559
562
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MatchingFunction = (...arg: any[]) => boolean | number | string | Promise<boolean> | Promise<number> | Promise<string>;
|
|
2
2
|
export declare class FunctionMap {
|
|
3
3
|
private functions;
|
|
4
4
|
/**
|
package/lib/esm/model/model.js
CHANGED
|
@@ -447,12 +447,12 @@ export class Model {
|
|
|
447
447
|
*/
|
|
448
448
|
sortPoliciesBySubjectHierarchy() {
|
|
449
449
|
var _a, _b, _c;
|
|
450
|
-
if (((_b = (_a = this.model.get('e')) === null || _a === void 0 ? void 0 : _a.get('e')) === null || _b === void 0 ? void 0 : _b.value) !== "subjectPriority(p_eft) || deny" /* SUBJECT_PRIORITY */) {
|
|
450
|
+
if (((_b = (_a = this.model.get('e')) === null || _a === void 0 ? void 0 : _a.get('e')) === null || _b === void 0 ? void 0 : _b.value) !== "subjectPriority(p_eft) || deny" /* EffectExpress.SUBJECT_PRIORITY */) {
|
|
451
451
|
return;
|
|
452
452
|
}
|
|
453
453
|
(_c = this.model.get('p')) === null || _c === void 0 ? void 0 : _c.forEach((assertion, ptype) => {
|
|
454
|
-
const domainIndex = this.getFieldIndex(ptype, "dom" /* Domain */);
|
|
455
|
-
const subIndex = this.getFieldIndex(ptype, "sub" /* Subject */);
|
|
454
|
+
const domainIndex = this.getFieldIndex(ptype, "dom" /* FieldIndex.Domain */);
|
|
455
|
+
const subIndex = this.getFieldIndex(ptype, "sub" /* FieldIndex.Subject */);
|
|
456
456
|
// eslint-disable-next-line
|
|
457
457
|
const subjectHierarchyMap = this.getSubjectHierarchyMap(this.model.get('g').get('g').policy);
|
|
458
458
|
assertion.policy.sort((policyA, policyB) => {
|
|
@@ -478,9 +478,9 @@ export class Model {
|
|
|
478
478
|
let domain = defaultDomain;
|
|
479
479
|
groupPolicies.forEach((policy) => {
|
|
480
480
|
if (policy.length !== 2)
|
|
481
|
-
domain = policy[this.getFieldIndex('p', "dom" /* Domain */)];
|
|
482
|
-
const child = this.getNameWithDomain(domain, policy[this.getFieldIndex('p', "sub" /* Subject */)]);
|
|
483
|
-
const parent = this.getNameWithDomain(domain, policy[this.getFieldIndex('p', "obj" /* Object */)]);
|
|
481
|
+
domain = policy[this.getFieldIndex('p', "dom" /* FieldIndex.Domain */)];
|
|
482
|
+
const child = this.getNameWithDomain(domain, policy[this.getFieldIndex('p', "sub" /* FieldIndex.Subject */)]);
|
|
483
|
+
const parent = this.getNameWithDomain(domain, policy[this.getFieldIndex('p', "obj" /* FieldIndex.Object */)]);
|
|
484
484
|
policyMap.set(child, parent);
|
|
485
485
|
if (!subjectHierarchyMap.has(child)) {
|
|
486
486
|
subjectHierarchyMap.set(child, 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,6 @@ export interface FileSystem {
|
|
|
3
3
|
readFileSync(path: string, encoding?: string): Buffer | string;
|
|
4
4
|
writeFileSync(path: string, text: string, encoding?: string): void;
|
|
5
5
|
}
|
|
6
|
-
export declare const setDefaultFileSystem: (fs?: FileSystem
|
|
6
|
+
export declare const setDefaultFileSystem: (fs?: FileSystem) => void;
|
|
7
7
|
export declare const getDefaultFileSystem: () => FileSystem | undefined;
|
|
8
8
|
export declare const mustGetDefaultFileSystem: () => FileSystem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RoleManager } from './roleManager';
|
|
2
|
-
export
|
|
2
|
+
export type MatchingFunc = (arg1: string, arg2: string) => boolean;
|
|
3
3
|
export declare class DefaultRoleManager implements RoleManager {
|
|
4
4
|
private allDomains;
|
|
5
5
|
private maxHierarchyLevel;
|
package/lib/esm/util/ip.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Buffer } from 'buffer/';
|
|
2
2
|
export declare const ip: {
|
|
3
|
-
toBuffer: (ip: string, buff?: Buffer
|
|
4
|
-
toString: (buff: Buffer, offset?: number
|
|
3
|
+
toBuffer: (ip: string, buff?: Buffer, offset?: number) => Buffer;
|
|
4
|
+
toString: (buff: Buffer, offset?: number, length?: number) => string;
|
|
5
5
|
isV4Format: (ip: string) => boolean;
|
|
6
6
|
isV6Format: (ip: string) => boolean;
|
|
7
|
-
fromPrefixLen: (prefixlen: number, family?: string
|
|
7
|
+
fromPrefixLen: (prefixlen: number, family?: string) => string;
|
|
8
8
|
mask: (addr: string, mask: string) => string;
|
|
9
9
|
subnet: (addr: string, mask: string) => any;
|
|
10
10
|
cidrSubnet: (cidrString: string) => any;
|
package/lib/esm/util/util.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ declare function arrayRemoveDuplicates(s: string[]): string[];
|
|
|
6
6
|
declare function arrayToString(a: string[]): string;
|
|
7
7
|
declare function paramsToString(...v: string[]): string;
|
|
8
8
|
declare function setEquals(a: string[], b: string[]): boolean;
|
|
9
|
-
declare function readFile(path: string, encoding?: string):
|
|
10
|
-
declare function writeFile(path: string, file: string, encoding?: string):
|
|
9
|
+
declare function readFile(path: string, encoding?: string): Promise<string>;
|
|
10
|
+
declare function writeFile(path: string, file: string, encoding?: string): Promise<void>;
|
|
11
11
|
declare function hasEval(s: string): boolean;
|
|
12
12
|
declare function replaceEval(s: string, ruleName: string, rule: string): string;
|
|
13
13
|
declare function getEvalValue(s: string): string[];
|
package/lib/esm/util/util.js
CHANGED
|
@@ -80,8 +80,8 @@ function readFile(path, encoding) {
|
|
|
80
80
|
const fs = mustGetDefaultFileSystem();
|
|
81
81
|
return new Promise((resolve, reject) => {
|
|
82
82
|
try {
|
|
83
|
-
fs.readFileSync(path, encoding || 'utf8');
|
|
84
|
-
resolve();
|
|
83
|
+
const content = fs.readFileSync(path, encoding || 'utf8');
|
|
84
|
+
resolve(content);
|
|
85
85
|
}
|
|
86
86
|
catch (e) {
|
|
87
87
|
reject(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "casbin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.49.0",
|
|
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",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"semantic-release": "^17.4.4",
|
|
45
45
|
"ts-jest": "^26.5.3",
|
|
46
46
|
"tslint": "^5.11.0",
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^4.9.5"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@casbin/expression-eval": "^5.3.0",
|
|
51
51
|
"await-lock": "^2.0.1",
|
|
52
52
|
"buffer": "^6.0.3",
|
|
53
53
|
"csv-parse": "^5.5.6",
|
|
54
|
-
"minimatch": "^
|
|
54
|
+
"minimatch": "^10.2.1"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"lib",
|