casbin 5.12.0 → 5.14.0-beta.1
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 +34 -0
- package/README.md +37 -13
- package/dist/casbin.esm.js +3 -0
- package/dist/casbin.esm.js.map +1 -0
- package/dist/casbin.js +3 -0
- package/dist/casbin.js.map +1 -0
- package/dist/casbin.mjs +3 -0
- package/dist/casbin.mjs.map +1 -0
- package/{lib/cjs → es}/cachedEnforcer.d.ts +0 -0
- package/{lib/esm → es}/cachedEnforcer.js +1 -1
- package/{lib/esm → es}/config.d.ts +3 -4
- package/{lib/esm → es}/config.js +6 -14
- package/{lib/cjs → es}/coreEnforcer.d.ts +8 -7
- package/{lib/esm → es}/coreEnforcer.js +32 -14
- package/{lib/cjs → es}/effect/defaultEffector.d.ts +0 -0
- package/{lib/esm → es}/effect/defaultEffector.js +0 -0
- package/{lib/cjs → es}/effect/defaultEffectorStream.d.ts +0 -0
- package/{lib/esm → es}/effect/defaultEffectorStream.js +0 -0
- package/{lib/cjs → es}/effect/effector.d.ts +0 -0
- package/{lib/esm → es}/effect/effector.js +0 -0
- package/{lib/cjs → es}/effect/effectorStream.d.ts +0 -0
- package/{lib/esm → es}/effect/effectorStream.js +1 -0
- package/{lib/cjs → es}/effect/index.d.ts +0 -0
- package/{lib/esm → es}/effect/index.js +0 -0
- package/es/enforceContext.d.ts +10 -0
- package/es/enforceContext.js +13 -0
- package/{lib/esm → es}/enforcer.d.ts +51 -13
- package/{lib/esm → es}/enforcer.js +82 -22
- package/{lib/cjs → es}/frontend.d.ts +0 -0
- package/{lib/esm → es}/frontend.js +0 -0
- package/{lib/esm → es}/index.d.ts +1 -0
- package/{lib/esm → es}/index.js +1 -0
- package/{lib/cjs → es}/internalEnforcer.d.ts +0 -0
- package/{lib/esm → es}/internalEnforcer.js +0 -0
- package/{lib/cjs → es}/log/defaultLogger.d.ts +0 -0
- package/{lib/esm → es}/log/defaultLogger.js +0 -0
- package/{lib/cjs → es}/log/index.d.ts +0 -0
- package/{lib/esm → es}/log/index.js +0 -0
- package/{lib/cjs → es}/log/logUtil.d.ts +0 -0
- package/{lib/esm → es}/log/logUtil.js +0 -0
- package/{lib/cjs → es}/log/logger.d.ts +0 -0
- package/{lib/esm → es}/log/logger.js +1 -0
- package/{lib/cjs → es}/managementEnforcer.d.ts +0 -0
- package/{lib/esm → es}/managementEnforcer.js +0 -0
- package/{lib/cjs → es}/model/assertion.d.ts +0 -0
- package/{lib/esm → es}/model/assertion.js +0 -0
- package/{lib/cjs → es}/model/functionMap.d.ts +0 -0
- package/{lib/esm → es}/model/functionMap.js +0 -0
- package/{lib/cjs → es}/model/index.d.ts +0 -0
- package/{lib/esm → es}/model/index.js +0 -0
- package/{lib/esm → es}/model/model.d.ts +2 -6
- package/{lib/esm → es}/model/model.js +5 -13
- package/{lib/cjs → es}/persist/adapter.d.ts +0 -0
- package/{lib/esm → es}/persist/adapter.js +1 -0
- package/{lib/cjs → es}/persist/batchAdapter.d.ts +0 -0
- package/es/persist/batchAdapter.js +1 -0
- package/{lib/cjs → es}/persist/defaultFilteredAdapter.d.ts +3 -3
- package/{lib/esm → es}/persist/defaultFilteredAdapter.js +7 -12
- package/{lib/cjs → es}/persist/filteredAdapter.d.ts +0 -0
- package/es/persist/filteredAdapter.js +1 -0
- package/{lib/cjs → es}/persist/helper.d.ts +0 -0
- package/{lib/esm → es}/persist/helper.js +2 -6
- package/{lib/cjs → es}/persist/index.d.ts +1 -3
- package/{lib/esm → es}/persist/index.js +1 -3
- package/{lib/cjs/persist/fileAdapter.d.ts → es/persist/memoryAdapter.d.ts} +22 -21
- package/es/persist/memoryAdapter.js +93 -0
- package/{lib/cjs → es}/persist/updatableAdapter.d.ts +0 -0
- package/{lib/esm → es}/persist/updatableAdapter.js +1 -0
- package/{lib/cjs → es}/persist/watcher.d.ts +0 -0
- package/{lib/esm → es}/persist/watcher.js +1 -0
- package/{lib/cjs → es}/rbac/defaultRoleManager.d.ts +0 -0
- package/{lib/esm → es}/rbac/defaultRoleManager.js +0 -0
- package/{lib/cjs → es}/rbac/index.d.ts +0 -0
- package/{lib/esm → es}/rbac/index.js +0 -0
- package/{lib/cjs → es}/rbac/roleManager.d.ts +0 -0
- package/{lib/esm → es}/rbac/roleManager.js +1 -0
- package/{lib/esm → es}/syncedEnforcer.d.ts +2 -2
- package/{lib/esm → es}/syncedEnforcer.js +3 -3
- package/{lib/cjs → es}/util/builtinOperators.d.ts +0 -0
- package/{lib/esm → es}/util/builtinOperators.js +15 -2
- package/{lib/cjs → es}/util/index.d.ts +0 -0
- package/{lib/esm → es}/util/index.js +0 -0
- package/{lib/cjs → es}/util/ip.d.ts +0 -0
- package/{lib/esm → es}/util/ip.js +0 -0
- package/{lib/cjs → es}/util/util.d.ts +3 -3
- package/{lib/esm → es}/util/util.js +59 -29
- package/examples/mulitple_policy.csv +2 -0
- package/lib/{esm/cachedEnforcer.d.ts → cachedEnforcer.d.ts} +0 -0
- package/lib/{cjs/cachedEnforcer.js → cachedEnforcer.js} +1 -1
- package/lib/{cjs/config.d.ts → config.d.ts} +3 -4
- package/lib/{cjs/config.js → config.js} +8 -16
- package/lib/{esm/coreEnforcer.d.ts → coreEnforcer.d.ts} +8 -7
- package/lib/{cjs/coreEnforcer.js → coreEnforcer.js} +32 -14
- package/lib/{esm/effect → effect}/defaultEffector.d.ts +0 -0
- package/lib/{cjs/effect → effect}/defaultEffector.js +0 -0
- package/lib/{esm/effect → effect}/defaultEffectorStream.d.ts +0 -0
- package/lib/{cjs/effect → effect}/defaultEffectorStream.js +0 -0
- package/lib/{esm/effect → effect}/effector.d.ts +0 -0
- package/lib/{cjs/effect → effect}/effector.js +0 -0
- package/lib/{esm/effect → effect}/effectorStream.d.ts +0 -0
- package/lib/{cjs/effect → effect}/effectorStream.js +0 -0
- package/lib/{esm/effect → effect}/index.d.ts +0 -0
- package/lib/{cjs/effect → effect}/index.js +1 -1
- package/lib/enforceContext.d.ts +10 -0
- package/lib/enforceContext.js +18 -0
- package/lib/{cjs/enforcer.d.ts → enforcer.d.ts} +51 -13
- package/lib/{cjs/enforcer.js → enforcer.js} +81 -21
- package/lib/{esm/frontend.d.ts → frontend.d.ts} +0 -0
- package/lib/{cjs/frontend.js → frontend.js} +0 -0
- package/lib/{cjs/index.d.ts → index.d.ts} +1 -0
- package/lib/{cjs/index.js → index.js} +17 -3
- package/lib/{esm/internalEnforcer.d.ts → internalEnforcer.d.ts} +0 -0
- package/lib/{cjs/internalEnforcer.js → internalEnforcer.js} +0 -0
- package/lib/{esm/log → log}/defaultLogger.d.ts +0 -0
- package/lib/{cjs/log → log}/defaultLogger.js +0 -0
- package/lib/{esm/log → log}/index.d.ts +0 -0
- package/lib/{cjs/log → log}/index.js +1 -1
- package/lib/{esm/log → log}/logUtil.d.ts +0 -0
- package/lib/{cjs/log → log}/logUtil.js +0 -0
- package/lib/{esm/log → log}/logger.d.ts +0 -0
- package/lib/{cjs/log → log}/logger.js +0 -0
- package/lib/{esm/managementEnforcer.d.ts → managementEnforcer.d.ts} +0 -0
- package/lib/{cjs/managementEnforcer.js → managementEnforcer.js} +0 -0
- package/lib/{esm/model → model}/assertion.d.ts +0 -0
- package/lib/{cjs/model → model}/assertion.js +20 -1
- package/lib/{esm/model → model}/functionMap.d.ts +0 -0
- package/lib/{cjs/model → model}/functionMap.js +20 -1
- package/lib/{esm/model → model}/index.d.ts +0 -0
- package/lib/{cjs/model → model}/index.js +1 -1
- package/lib/{cjs/model → model}/model.d.ts +2 -6
- package/lib/{cjs/model → model}/model.js +26 -16
- package/lib/{esm/persist → persist}/adapter.d.ts +0 -0
- package/lib/{cjs/persist → persist}/adapter.js +0 -0
- package/lib/{esm/persist → persist}/batchAdapter.d.ts +0 -0
- package/lib/{cjs/persist → persist}/batchAdapter.js +0 -0
- package/lib/{esm/persist → persist}/defaultFilteredAdapter.d.ts +3 -3
- package/lib/{cjs/persist → persist}/defaultFilteredAdapter.js +6 -11
- package/lib/{esm/persist → persist}/filteredAdapter.d.ts +0 -0
- package/lib/{cjs/persist → persist}/filteredAdapter.js +0 -0
- package/lib/{esm/persist → persist}/helper.d.ts +0 -0
- package/lib/{cjs/persist → persist}/helper.js +2 -6
- package/lib/{esm/persist → persist}/index.d.ts +1 -3
- package/lib/{cjs/persist → persist}/index.js +2 -4
- package/lib/{esm/persist/fileAdapter.d.ts → persist/memoryAdapter.d.ts} +22 -21
- package/lib/persist/memoryAdapter.js +97 -0
- package/lib/{esm/persist → persist}/updatableAdapter.d.ts +0 -0
- package/lib/{cjs/persist → persist}/updatableAdapter.js +0 -0
- package/lib/{esm/persist → persist}/watcher.d.ts +0 -0
- package/lib/{cjs/persist → persist}/watcher.js +0 -0
- package/lib/{esm/rbac → rbac}/defaultRoleManager.d.ts +0 -0
- package/lib/{cjs/rbac → rbac}/defaultRoleManager.js +0 -0
- package/lib/{esm/rbac → rbac}/index.d.ts +0 -0
- package/lib/{cjs/rbac → rbac}/index.js +1 -1
- package/lib/{esm/rbac → rbac}/roleManager.d.ts +0 -0
- package/lib/{cjs/rbac → rbac}/roleManager.js +0 -0
- package/lib/{cjs/syncedEnforcer.d.ts → syncedEnforcer.d.ts} +2 -2
- package/lib/{cjs/syncedEnforcer.js → syncedEnforcer.js} +7 -4
- package/lib/{esm/util → util}/builtinOperators.d.ts +0 -0
- package/lib/{cjs/util → util}/builtinOperators.js +15 -2
- package/lib/{esm/util → util}/index.d.ts +0 -0
- package/lib/{cjs/util → util}/index.js +1 -1
- package/lib/{esm/util → util}/ip.d.ts +0 -0
- package/lib/{cjs/util → util}/ip.js +0 -0
- package/lib/{esm/util → util}/util.d.ts +3 -3
- package/lib/{cjs/util → util}/util.js +61 -31
- package/package.json +33 -15
- package/lib/cjs/persist/batchFileAdapter.d.ts +0 -14
- package/lib/cjs/persist/batchFileAdapter.js +0 -19
- package/lib/cjs/persist/fileAdapter.js +0 -112
- package/lib/cjs/persist/stringAdapter.d.ts +0 -32
- package/lib/cjs/persist/stringAdapter.js +0 -57
- package/lib/esm/persist/batchAdapter.js +0 -0
- package/lib/esm/persist/batchFileAdapter.d.ts +0 -14
- package/lib/esm/persist/batchFileAdapter.js +0 -15
- package/lib/esm/persist/fileAdapter.js +0 -108
- package/lib/esm/persist/filteredAdapter.js +0 -0
- package/lib/esm/persist/stringAdapter.d.ts +0 -32
- package/lib/esm/persist/stringAdapter.js +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
# [5.14.0-beta.1](https://github.com/casbin/node-casbin/compare/v5.13.1...v5.14.0-beta.1) (2022-02-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix logic error and add unittests ([e36cc23](https://github.com/casbin/node-casbin/commit/e36cc239b1588e884453e5441eda184350fdae39))
|
|
7
|
+
* rename StringAdapter to MemoryAdapter ([0b1019a](https://github.com/casbin/node-casbin/commit/0b1019aa2324ea4ea4c37119728dadac1bcf1fc3))
|
|
8
|
+
* use csv-like format ([3b54c93](https://github.com/casbin/node-casbin/commit/3b54c934d0d9d08a4af18799c1292f9dc728e6a4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add policyArrayToString and policyStringToArray to util ([0f66bc1](https://github.com/casbin/node-casbin/commit/0f66bc1b2fcddfd9c6e847dd06fd4a5f53c55fa9))
|
|
14
|
+
* Extend multiple sections type of escapeAssertion ([#180](https://github.com/casbin/node-casbin/issues/180)) ([33c784c](https://github.com/casbin/node-casbin/commit/33c784cbdc0d650ba75b8177b69f41dc0ca11fae))
|
|
15
|
+
* implement csv parser ([968a232](https://github.com/casbin/node-casbin/commit/968a23237b3193e594910f5f798bf349d6bff04c))
|
|
16
|
+
* implement string adapater ([0c59cae](https://github.com/casbin/node-casbin/commit/0c59cae0eba851509ff754b6f523a4feafc11f80))
|
|
17
|
+
* Multiple sections type ([cc58c57](https://github.com/casbin/node-casbin/commit/cc58c57ae4a7c3202c7217497bef8016df93fe26))
|
|
18
|
+
* RBAC with Domains API ([3e38bb5](https://github.com/casbin/node-casbin/commit/3e38bb5a7223657fae21896ba2e0b9b39e099481))
|
|
19
|
+
|
|
20
|
+
## [5.13.1](https://github.com/casbin/node-casbin/compare/v5.13.0...v5.13.1) (2022-02-22)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* 'eval' not detected ([86e2add](https://github.com/casbin/node-casbin/commit/86e2add7c5aaa7901d21c1c4b9cb8e6d0b8bef75))
|
|
26
|
+
* created two regex expressions ([de5f2f4](https://github.com/casbin/node-casbin/commit/de5f2f4f27f40941b125bf068b8f90e44ba69fb1))
|
|
27
|
+
|
|
28
|
+
# [5.13.0](https://github.com/casbin/node-casbin/compare/v5.12.0...v5.13.0) (2022-01-25)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* getImplicitUsersForRole ([#341](https://github.com/casbin/node-casbin/issues/341)) ([ebfaede](https://github.com/casbin/node-casbin/commit/ebfaede003cf0a4eef8a16f815f06518e74974fb))
|
|
34
|
+
|
|
1
35
|
# [5.12.0](https://github.com/casbin/node-casbin/compare/v5.11.5...v5.12.0) (2022-01-16)
|
|
2
36
|
|
|
3
37
|
|
package/README.md
CHANGED
|
@@ -40,34 +40,58 @@
|
|
|
40
40
|
|
|
41
41
|
https://casbin.org/docs/en/overview
|
|
42
42
|
|
|
43
|
+
## Feature
|
|
44
|
+
|
|
45
|
+
- 😎 Written in TypeScript to provide the type definitions
|
|
46
|
+
- 🎯 Support multiple access model such as ACL, RBAC, ABAC
|
|
47
|
+
- 🎮 Run everywhere on JavaScript platforms such as WEB, Node.js, React-Native, Electron, etc.
|
|
48
|
+
|
|
43
49
|
## Installation
|
|
44
50
|
|
|
45
51
|
```shell script
|
|
46
52
|
# NPM
|
|
47
|
-
npm install casbin --save
|
|
53
|
+
npm install casbin@beta --save
|
|
48
54
|
|
|
49
55
|
# Yarn
|
|
50
|
-
yarn add casbin
|
|
56
|
+
yarn add casbin@beta
|
|
51
57
|
```
|
|
52
58
|
|
|
53
59
|
## Get started
|
|
54
60
|
|
|
55
|
-
New
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
New an enforcer with a model string and a memory policy, see [Model](#official-model) section for details:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { newEnforcer, newModel, MemoryAdapter } from 'casbin';
|
|
65
|
+
|
|
66
|
+
const model = newModel(`
|
|
67
|
+
[request_definition]
|
|
68
|
+
r = sub, obj, act
|
|
69
|
+
[policy_definition]
|
|
70
|
+
p = sub, obj, act
|
|
71
|
+
[role_definition]
|
|
72
|
+
g = _, _
|
|
73
|
+
[policy_effect]
|
|
74
|
+
e = some(where (p.eft == allow))
|
|
75
|
+
[matchers]
|
|
76
|
+
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
|
|
77
|
+
`);
|
|
78
|
+
|
|
79
|
+
const adapter = new MemoryAdapter(`
|
|
80
|
+
p, alice, data1, read
|
|
81
|
+
p, bob, data2, write
|
|
82
|
+
p, data2_admin, data2, read
|
|
83
|
+
p, data2_admin, data2, write
|
|
84
|
+
g, alice, data2_admin
|
|
85
|
+
`);
|
|
86
|
+
|
|
87
|
+
const enforcer = await newEnforcer(model, adapter);
|
|
64
88
|
```
|
|
65
89
|
|
|
66
90
|
> **Note**: you can also initialize an enforcer with policy in DB instead of file, see [Persistence](#policy-persistence) section for details.
|
|
67
91
|
|
|
68
92
|
Add an enforcement hook into your code right before the access happens:
|
|
69
93
|
|
|
70
|
-
```
|
|
94
|
+
```typescript
|
|
71
95
|
const sub = 'alice'; // the user that wants to access a resource.
|
|
72
96
|
const obj = 'data1'; // the resource that is going to be accessed.
|
|
73
97
|
const act = 'read'; // the operation that the user performs on the resource.
|
|
@@ -87,7 +111,7 @@ if (res) {
|
|
|
87
111
|
Besides the static policy file, `node-casbin` also provides API for permission management at run-time.
|
|
88
112
|
For example, You can get all the roles assigned to a user as below:
|
|
89
113
|
|
|
90
|
-
```
|
|
114
|
+
```typescript
|
|
91
115
|
const roles = await enforcer.getRolesForUser('alice');
|
|
92
116
|
```
|
|
93
117
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function e(e,t){return e(t={exports:{}},t.exports),t.exports}for(var t=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r=function(e){var t,r,n=u(e),i=n[0],a=n[1],l=new s(function(e,t,r){return 3*(t+r)/4-r}(0,i,a)),c=0,h=a>0?i-4:i;for(r=0;r<h;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],l[c++]=t>>16&255,l[c++]=t>>8&255,l[c++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,l[c++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,l[c++]=t>>8&255,l[c++]=255&t);return l},n=function(e){for(var t,r=e.length,n=r%3,o=[],s=16383,a=0,l=r-n;a<l;a+=s)o.push(h(e,a,a+s>l?l:a+s));1===n?(t=e[r-1],o.push(i[t>>2]+i[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],o.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return o.join("")},i=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,c=a.length;l<c;++l)i[l]=a[l],o[a.charCodeAt(l)]=l;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function h(e,t,r){for(var n,o,s=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var f={byteLength:t,toByteArray:r,fromByteArray:n},d=function(e,t,r,n,i){var o,s,a=8*i-n-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=f,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=f,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},p=function(e,t,r,n,i,o){var s,a,l,c=8*o-i-1,u=(1<<c)-1,h=u>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*y},y=e((function(e,t){const r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=function(e){+e!=e&&(e=0);return o.alloc(+e)},t.INSPECT_MAX_BYTES=50;const n=2147483647;function i(e){if(e>n)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return s(e,t,r)}function s(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|y(e,t);let n=i(r);const s=n.write(e,t);s!==r&&(n=n.slice(0,s));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(J(e,Uint8Array)){const t=new Uint8Array(e);return u(t.buffer,t.byteOffset,t.byteLength)}return c(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(J(e,ArrayBuffer)||e&&J(e.buffer,ArrayBuffer))return u(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(J(e,SharedArrayBuffer)||e&&J(e.buffer,SharedArrayBuffer)))return u(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return o.from(n,t,r);const s=function(e){if(o.isBuffer(e)){const t=0|h(e.length),r=i(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||X(e.length)?i(0):c(e);if("Buffer"===e.type&&Array.isArray(e.data))return c(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return a(e),i(e<0?0:0|h(e))}function c(e){const t=e.length<0?0:0|h(e.length),r=i(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function u(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,o.prototype),n}function h(e){if(e>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function y(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||J(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(e).length;default:if(i)return n?-1:z(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return B(this,t,r);case"base64":return R(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){let o,s=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,l/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===l)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){let r=!0;for(let n=0;n<l;n++)if(c(e,o+n)!==c(t,n)){r=!1;break}if(r)return o}return-1}function P(e,t,r,n){r=Number(r)||0;const i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(X(n))return s;e[r+s]=n}return s}function E(e,t,r,n){return K(z(t,e.length-r),e,r,n)}function b(e,t,r,n){return K(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function A(e,t,r,n){return K(Y(t),e,r,n)}function F(e,t,r,n){return K(function(e,t){let r,n,i;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function R(e,t,r){return 0===t&&r===e.length?f.fromByteArray(e):f.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i<r;){const t=e[i];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,l;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(l=(31&t)<<6|63&r,l>127&&(o=l));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(l=(15&t)<<12|(63&r)<<6|63&n,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(l=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(e){const t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=k));return r}(n)}t.kMaxLength=n,o.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return s(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return function(e,t,r){return a(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}(e,t,r)},o.allocUnsafe=function(e){return l(e)},o.allocUnsafeSlow=function(e){return l(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(J(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),J(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=o.allocUnsafe(t);let i=0;for(r=0;r<e.length;++r){let t=e[r];if(J(t,Uint8Array))i+t.length>n.length?(o.isBuffer(t)||(t=o.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!o.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},o.byteLength=y,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)m(this,t,t+1);return this},o.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},o.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},o.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):g.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},r&&(o.prototype[r]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,i){if(J(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let s=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0);const l=Math.min(s,a),c=this.slice(n,i),u=e.slice(t,r);for(let e=0;e<l;++e)if(c[e]!==u[e]){s=c[e],a=u[e];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return P(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return b(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function x(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function B(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function N(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=H[e[n]];return i}function S(e,t,r){const n=e.slice(t,r);let i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,i,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function L(e,t,r,n,i){j(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function _(e,t,r,n,i){j(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function T(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(e,t,r,n,i){return t=+t,r>>>=0,i||T(e,0,r,4),p(e,t,r,n,23,4),r+4}function O(e,t,r,n,i){return t=+t,r>>>=0,i||T(e,0,r,8),p(e,t,r,n,52,8),r+8}o.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return n},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readBigUInt64LE=Z((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),o.prototype.readBigUInt64BE=Z((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readBigInt64LE=Z((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),o.prototype.readBigInt64BE=Z((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||W(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),o.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),d(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),d(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),d(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),d(this,e,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){U(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){U(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeBigUInt64LE=Z((function(e,t=0){return L(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),o.prototype.writeBigUInt64BE=Z((function(e,t=0){return _(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let i=0,o=1,s=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeBigInt64LE=Z((function(e,t=0){return L(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),o.prototype.writeBigInt64BE=Z((function(e,t=0){return _(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),o.prototype.writeFloatLE=function(e,t,r){return C(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return C(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);const i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{const s=o.isBuffer(e)?e:o.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};const $={};function G(e,t,r){$[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function D(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function j(e,t,r,n,i,o){if(e>r||e<t){const n="bigint"==typeof t?"n":"";let i;throw i=o>3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new $.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){q(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||W(t,e.length-(r+1))}(n,i,o)}function q(e,t){if("number"!=typeof e)throw new $.ERR_INVALID_ARG_TYPE(t,"number",e)}function W(e,t,r){if(Math.floor(e)!==e)throw q(e,r),new $.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new $.ERR_BUFFER_OUT_OF_BOUNDS;throw new $.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}G("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),G("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),G("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function z(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Y(e){return f.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function J(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}const H=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}})),g=y.Buffer;
|
|
2
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */y.SlowBuffer,y.INSPECT_MAX_BYTES,y.kMaxLength;const m=/^(\d{1,3}\.){3,3}\d{1,3}$/,w=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,v={toBuffer:function(e,t,r){let n;if(r=r||0,this.isV4Format(e))n=t||new g(r+4),e.split(/\./g).map((function(e){r=r||0,n[r++]=255&parseInt(e,10)}));else if(this.isV6Format(e)){const i=e.split(":",8);let o;for(o=0;o<i.length;o++){let e;this.isV4Format(i[o])&&(e=this.toBuffer(i[o]),i[o]=e.slice(0,2).toString("hex")),e&&++o<8&&i.splice(o,0,e.slice(2,4).toString("hex"))}if(""===i[0])for(;i.length<8;)i.unshift("0");else if(""===i[i.length-1])for(;i.length<8;)i.push("0");else if(i.length<8){for(o=0;o<i.length&&""!==i[o];o++);const e=[o,1];for(o=9-i.length;o>0;o--)e.push("0");i.splice.apply(i,e)}for(n=t||new g(r+16),o=0;o<i.length;o++){const e=parseInt(i[o],16);n[r++]=e>>8&255,n[r++]=255&e}}if(!n)throw Error("Invalid ip address: "+e);return n},toString:function(e,t,r){t=t||0;let n=[];if(4===(r=r||e.length-t)){for(let i=0;i<r;i++)n.push(e[t+i]);n=n.join(".")}else if(16===r){for(let i=0;i<r;i+=2)n.push(e.readUInt16BE(t+i).toString(16));n=n.join(":"),n=n.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),n=n.replace(/:{3,4}/,"::")}return n},isV4Format:function(e){return m.test(e)},isV6Format:function(e){return w.test(e)},fromPrefixLen:function(e,t){let r=4;"ipv6"===(t=e>32?"ipv6":function(e){return e?e.toLowerCase():"ipv4"}("string"==typeof t?t:""))&&(r=16);const n=new g(r);for(let t=0,r=n.length;t<r;++t){let r=8;e<8&&(r=e),e-=r,n[t]=255&~(255>>r)}return v.toString(n)},mask:function(e,t){const r=v.toBuffer(e),n=v.toBuffer(t),i=new g(Math.max(r.length,n.length));let o;if(r.length===n.length)for(o=0;o<r.length;o++)i[o]=r[o]&n[o];else if(4===n.length)for(o=0;o<n.length;o++)i[o]=r[r.length-4+o]&n[o];else{for(let e=0;e<i.length-6;e++)i[e]=0;for(i[10]=255,i[11]=255,o=0;o<r.length;o++)i[o+12]=r[o]&n[o+12];o+=12}for(;o<i.length;o++)i[o]=0;return v.toString(i)},subnet:function(e,t){const r=v.toLong(v.mask(e,t)),n=v.toBuffer(t);for(let e=0;e<n.length;e++)255===n[e]||n[e];return{contains:function(e){return r===v.toLong(v.mask(e,t))}}},cidrSubnet:function(e){const t=e.split("/"),r=t[0];if(2!==t.length)throw new Error("invalid CIDR subnet: "+r);const n=v.fromPrefixLen(parseInt(t[1],10));return v.subnet(r,n)},isEqual:function(e,t){let r=v.toBuffer(e),n=v.toBuffer(t);if(r.length===n.length){for(let e=0;e<r.length;e++)if(r[e]!==n[e])return!1;return!0}if(4===n.length){const e=n;n=r,r=e}for(let e=0;e<10;e++)if(0!==n[e])return!1;const i=n.readUInt16BE(10);if(0!==i&&65535!==i)return!1;for(let e=0;e<4;e++)if(r[e]!==n[e+12])return!1;return!0},toLong:function(e){let t=0;return e.split(".").forEach((function(e){t<<=8,t+=parseInt(e)})),t>>>0},fromLong:function(e){return(e>>>24)+"."+(e>>16&255)+"."+(e>>8&255)+"."+(255&e)}};function P(e,t){return new RegExp(t).test(e)}function E(...e){const[t,r]=e;return function(e,t){const r=t.indexOf("*");return-1===r?e===t:e.length>r?e.slice(0,r)===t.slice(0,r):e===t.slice(0,r)}((t||"").toString(),(r||"").toString())}function b(...e){const[t,r]=e;return function(e,t){const r=t.indexOf("*");return-1===r?"":e.length>r&&e.slice(0,r)===t.slice(0,r)?e.slice(r,e.length):""}((t||"").toString(),(r||"").toString())}function A(e,t){t=t.replace(/\/\*/g,"/.*");const r=new RegExp(/(.*):[^/]+(.*)/g);for(;t.includes("/:");)t=t.replace(r,"$1[^/]+$2");return"*"===t&&(t="(.*)"),P(e,"^"+t+"$")}function F(...e){const[t,r]=e;return A((t||"").toString(),(r||"").toString())}function R(...e){const[t,r,n]=e;return function(e,t,r){if(A(e,t)){const n=new RegExp("[^/]+","g"),i=t.match(n),o=e.match(n);if(!i||!o)return"";const s=i.indexOf(`:${r}`);return-1===s?"":o[s]}return""}((t||"").toString(),(r||"").toString(),(n||"").toString())}function I(...e){const[t,r]=e;return function(e,t){t=t.replace(/\/\*/g,"/.*");const r=new RegExp(/(.*){[^/]+}(.*)/g);for(;t.includes("/{");)t=t.replace(r,"$1[^/]+$2");return P(e,"^"+t+"$")}((t||"").toString(),(r||"").toString())}function k(...e){const[t,r]=e;return function(e,t){t=t.replace(/\/\*/g,"/.*");const r=[];let n=-1;for(let e=0;e<t.length;e++){const i=t.charAt(e);"{"===i?n=e:"}"===i&&r.push(t.substring(n,e+1))}let i=new RegExp(/(.*){[^/]+}(.*)/g);for(;t.includes("/{");)t=t.replace(i,"$1([^/]+)$2");i=new RegExp("^"+t+"$");let o=i.exec(e);if(!o)return!1;if(o=o.slice(1),r.length!==o.length)throw new Error("KeyMatch4: number of tokens is not equal to number of values");const s=new Map;r.forEach(((e,t)=>{const n=r[t];let i=s.get(n);i||(i=[]),o&&i.push(o[t]),s.set(n,i)}));for(const e of s.values())if(e.length>1)for(let e=1;e<o.length;e++)if(o[e]!==o[0])return!1;return!0}((t||"").toString(),(r||"").toString())}function x(...e){const[t,r]=e;return P((t||"").toString(),(r||"").toString())}function B(...e){const[t,r]=e;return function(e,t){try{require("buffer")}catch(e){throw new Error("Please add buffer to your dependency.")}if(!v.isV4Format(e)&&!v.isV6Format(e))throw new Error("invalid argument: ip1 in ipMatch() function is not an IP address.");if(2===t.split("/").length)return v.cidrSubnet(t).contains(e);if(!v.isV4Format(t)&&!v.isV6Format(t))throw console.log(t),new Error("invalid argument: ip2 in ipMatch() function is not an IP address.");return v.isEqual(e,t)}((t||"").toString(),(r||"").toString())}function N(e,t){try{return require("picomatch")(t)(e)}catch(e){throw new Error("Please add picomatch to your dependency.")}}function S(e){const t=new Map;return async function(...r){const n=r.toString();let i=t.get(n);if(i)return i;const[o,s]=r,a=(o||"").toString(),l=(s||"").toString();if(e)if(2===r.length)i=await e.hasLink(a,l);else{const t=r[2].toString();i=await e.hasLink(a,l,t)}else i=a===l;return t.set(n,i),i}}function M(e){return(e.startsWith("r")||e.startsWith("p"))&&(e=e.replace(".","_")),e.replace(/([| =)(&<>,+\-!*\/])([rp][0-9]*)\./g,(e=>e.replace(".","_")))}function U(e=[],t=[]){const r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(e[n]!==t[n])return!1;return!0}function L(e){return[...new Set(e)]}const _=new RegExp(/\beval\(([^),]*)\)/g),T=new RegExp(/\beval\(([^),]*)\)/);function C(e){return T.test(e)}function O(e,t,r){return e.replace(`eval(${t})`,"("+r+")")}function $(e){const t=e.match(_),r=[];if(!t)return[];for(const e of t){const t=e.indexOf("(");r.push(e.slice(t+1,-1))}return r}function G(e){let{value:t,done:r}=e.next();for(;;){if(t instanceof Promise)throw new Error("cannot handle Promise in generatorRunSync, Please use generatorRunAsync");if(r)return t;{const n=t;({value:t,done:r}=e.next(n))}}}async function D(e){let{value:t,done:r}=e.next();for(;;){if(r)return t;{const n=await t;({value:t,done:r}=e.next(n))}}}function j(e){if("object"!=typeof e)return;const t=e instanceof Array?[]:{};for(const r in e)e.hasOwnProperty(r)&&(t[r]="object"==typeof e[r]?j(e[r]):e[r]);return t}function q(e){return e.map((e=>`"${(null===e?"":e.toString()).replace(/"/g,'""')}"`)).join(",")}function W(e){const t=/,$/,r=/^".*"$/,n=e.split(/\r?\n/),i=[];for(let e of n){const n=e.indexOf("#");if(-1!==n&&(e=e.substr(0,n)),e=e.trim(),t.test(e))throw new Error("The csv standard does not allow a comma at the end of a sentence");const o=e.split(",");let s=[];for(let t of o){if(t=t.trim(),r.test(t)&&(t=t.substr(1,t.length-2)),t.includes('""')){for(let r=0;r<t.length;){if('"'===t[r]){if('"'!==t[r+1])throw new Error(`Unescaped " at ${e}`);r+=2}r+=1}t=t.replace(/""/g,'"')}s.push(t)}i.push(j(s)),s=[]}return i}function V(e,t){return t instanceof Array?t.includes(e):e in t}function z(e){if(!e.includes(" in ")||!e.includes(" ("))return e;const t=/ \([^)]*\)/g,r=e.split("");let n;for(;null!==(n=t.exec(e));)n[0].includes(",")&&(r[n.index+1]="[",r[t.lastIndex-1]="]");return e=r.join("")}var Y=Object.freeze({__proto__:null,keyMatchFunc:E,keyGetFunc:b,keyMatch2Func:F,keyGet2Func:R,keyMatch3Func:I,regexMatchFunc:x,ipMatchFunc:B,generateGFunction:S,keyMatch4Func:k,globMatch:N,escapeAssertion:M,removeComments:function(e){const t=e.indexOf("#");return t>-1?e.slice(0,t).trim():e},arrayEquals:U,array2DEquals:function(e=[],t=[]){const r=e.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(!U(e[n],t[n]))return!1;return!0},arrayRemoveDuplicates:L,arrayToString:function(e){return e.join(", ")},paramsToString:function(...e){return e.join(", ")},setEquals:function(e,t){return U(e.sort(),t.sort())},hasEval:C,replaceEval:O,getEvalValue:$,generatorRunSync:G,generatorRunAsync:D,deepCopy:j,policyArrayToString:q,policyStringToArray:W,customIn:V,bracketCompatible:z});class K{constructor(){this.data=new Map}static newConfig(e){const t=new K;return t.parseText(e),t}static newConfigFromText(e){const t=new K;return t.parseText(e),t}addConfig(e,t,r){""===e&&(e=K.DEFAULT_SECTION);this.data.has(e)||this.data.set(e,new Map);const n=this.data.get(e);return!!n&&(n.set(t,r),n.has(t))}parseText(e){const t=e.split("\n").filter((e=>e)),r=t.length;let n="",i="";t.forEach(((e,t)=>{let o=e.indexOf(K.DEFAULT_COMMENT);o>-1&&(e=e.slice(0,o)),o=e.indexOf(K.DEFAULT_COMMENT_SEM),o>-1&&(e=e.slice(0,o));const s=e.trim();if(!s)return;const a=t+1;if(s.startsWith("[")&&s.endsWith("]"))0!==i.length&&(this.write(n,a-1,i),i=""),n=s.substring(1,s.length-1);else{let e=!1;s.includes(K.DEFAULT_MULTI_LINE_SEPARATOR)?i+=s.substring(0,s.length-1).trim():(i+=s,e=!0),(e||a===r)&&(this.write(n,a,i),i="")}}))}write(e,t,r){const n=r.indexOf("=");if(-1===n)throw new Error(`parse the content error : line ${t}`);const i=r.substring(0,n),o=r.substring(n+1);this.addConfig(e,i.trim(),o.trim())}getBool(e){return!!this.get(e)}getInt(e){return Number.parseInt(this.get(e),10)}getFloat(e){return Number.parseFloat(this.get(e))}getString(e){return this.get(e)}getStrings(e){return this.get(e).split(",")}set(e,t){if(!e)throw new Error("key is empty");let r,n="";const i=e.toLowerCase().split("::");i.length>=2?(n=i[0],r=i[1]):r=i[0],this.addConfig(n,r,t)}get(e){let t,r;const n=e.toLowerCase().split("::");n.length>=2?(t=n[0],r=n[1]):(t=K.DEFAULT_SECTION,r=n[0]);const i=this.data.get(t),o=i&&i.get(r);return o||""}}K.DEFAULT_SECTION="default",K.DEFAULT_COMMENT="#",K.DEFAULT_COMMENT_SEM=";",K.DEFAULT_MULTI_LINE_SEPARATOR="\\";var J=e((function(e,t){!function(r){var n="Compound",i="MemberExpression",o="Literal",s=function(e,t){var r=new Error(e+" at character "+t);throw r.index=t,r.description=e,r},a=!0,l={"-":a,"!":a,"~":a,"+":a},c={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},u=function(e){var t,r=0;for(var n in e)(t=n.length)>r&&e.hasOwnProperty(n)&&(r=t);return r},h=u(l),f=u(c),d={true:!0,false:!1,null:null},p=function(e){return c[e]||0},y=function(e,t,r){return{type:"||"===e||"&&"===e?"LogicalExpression":"BinaryExpression",operator:e,left:t,right:r}},g=function(e){return e>=48&&e<=57},m=function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=128&&!c[String.fromCharCode(e)]},w=function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e>=128&&!c[String.fromCharCode(e)]},v=function(e){for(var t,r,a=0,u=e.charAt,v=e.charCodeAt,P=function(t){return u.call(e,t)},E=function(t){return v.call(e,t)},b=e.length,A=function(){for(var e=E(a);32===e||9===e||10===e||13===e;)e=E(++a)},F=function(){var e,t,r=I();return A(),63!==E(a)?r:(a++,(e=F())||s("Expected expression",a),A(),58===E(a)?(a++,(t=F())||s("Expected expression",a),{type:"ConditionalExpression",test:r,consequent:e,alternate:t}):void s("Expected :",a))},R=function(){A();for(var t=e.substr(a,f),r=t.length;r>0;){if(c.hasOwnProperty(t)&&(!m(E(a))||a+t.length<e.length&&!w(E(a+t.length))))return a+=r,t;t=t.substr(0,--r)}return!1},I=function(){var e,t,r,n,i,o,l,c,u;if(o=k(),!(t=R()))return o;for(i={value:t,prec:p(t)},(l=k())||s("Expected expression after "+t,a),n=[o,i,l];(t=R())&&0!==(r=p(t));){for(i={value:t,prec:r},u=t;n.length>2&&r<=n[n.length-2].prec;)l=n.pop(),t=n.pop().value,o=n.pop(),e=y(t,o,l),n.push(e);(e=k())||s("Expected expression after "+u,a),n.push(i,e)}for(e=n[c=n.length-1];c>1;)e=y(n[c-1].value,n[c-2],e),c-=2;return e},k=function(){var t,r,n;if(A(),t=E(a),g(t)||46===t)return x();if(39===t||34===t)return B();if(91===t)return L();for(n=(r=e.substr(a,h)).length;n>0;){if(l.hasOwnProperty(r)&&(!m(E(a))||a+r.length<e.length&&!w(E(a+r.length))))return a+=n,{type:"UnaryExpression",operator:r,argument:k(),prefix:!0};r=r.substr(0,--n)}return!(!m(t)&&40!==t)&&M()},x=function(){for(var e,t,r="";g(E(a));)r+=P(a++);if(46===E(a))for(r+=P(a++);g(E(a));)r+=P(a++);if("e"===(e=P(a))||"E"===e){for(r+=P(a++),"+"!==(e=P(a))&&"-"!==e||(r+=P(a++));g(E(a));)r+=P(a++);g(E(a-1))||s("Expected exponent ("+r+P(a)+")",a)}return t=E(a),m(t)?s("Variable names cannot start with a number ("+r+P(a)+")",a):46===t&&s("Unexpected period",a),{type:o,value:parseFloat(r),raw:r}},B=function(){for(var e,t="",r=P(a++),n=!1;a<b;){if((e=P(a++))===r){n=!0;break}if("\\"===e)switch(e=P(a++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return n||s('Unclosed quote after "'+t+'"',a),{type:o,value:t,raw:r+t+r}},N=function(){var t,r=E(a),n=a;for(m(r)?a++:s("Unexpected "+P(a),a);a<b&&(r=E(a),w(r));)a++;return t=e.slice(n,a),d.hasOwnProperty(t)?{type:o,value:d[t],raw:t}:"this"===t?{type:"ThisExpression"}:{type:"Identifier",name:t}},S=function(e){for(var t,r,i=[],o=!1,l=0;a<b;){if(A(),(t=E(a))===e){o=!0,a++,41===e&&l&&l>=i.length&&s("Unexpected token "+String.fromCharCode(e),a);break}if(44===t){if(a++,++l!==i.length)if(41===e)s("Unexpected token ,",a);else if(93===e)for(var c=i.length;c<l;c++)i.push(null)}else(r=F())&&r.type!==n||s("Expected comma",a),i.push(r)}return o||s("Expected "+String.fromCharCode(e),a),i},M=function(){var e,t;for(t=40===(e=E(a))?U():N(),A(),e=E(a);46===e||91===e||40===e;)a++,46===e?(A(),t={type:i,computed:!1,object:t,property:N()}):91===e?(t={type:i,computed:!0,object:t,property:F()},A(),93!==(e=E(a))&&s("Unclosed [",a),a++):40===e&&(t={type:"CallExpression",arguments:S(41),callee:t}),A(),e=E(a);return t},U=function(){a++;var e=F();if(A(),41===E(a))return a++,e;s("Unclosed (",a)},L=function(){return a++,{type:"ArrayExpression",elements:S(93)}},_=[];a<b;)59===(t=E(a))||44===t?a++:(r=F())?_.push(r):a<b&&s('Unexpected "'+P(a)+'"',a);return 1===_.length?_[0]:{type:n,body:_}};v.version="0.3.5",v.toString=function(){return"JavaScript Expression Parser (JSEP) v"+v.version},v.addUnaryOp=function(e){return h=Math.max(e.length,h),l[e]=a,this},v.addBinaryOp=function(e,t){return f=Math.max(e.length,f),c[e]=t,this},v.addLiteral=function(e,t){return d[e]=t,this},v.removeUnaryOp=function(e){return delete l[e],e.length===h&&(h=u(l)),this},v.removeAllUnaryOps=function(){return l={},h=0,this},v.removeBinaryOp=function(e){return delete c[e],e.length===f&&(f=u(c)),this},v.removeAllBinaryOps=function(){return c={},f=0,this},v.removeLiteral=function(e){return delete d[e],this},v.removeAllLiterals=function(){return d={},this},e.exports?t=e.exports=v:t.parse=v}()}));J.parse;var X,H=function e(t,r){try{var n,i=t;switch(i.type){case"ArrayExpression":return Promise.resolve(Q(i.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([e(i.left,r),e(i.right,r)])).then((function(e){return te[i.operator](e[0],e[1])}));case"CallExpression":var o,s,a,l=function(){if("function"==typeof s){var e=s,t=e.apply,n=o;return Promise.resolve(Q(i.arguments,r)).then((function(r){return Promise.resolve(t.call(e,n,r))}))}},c="MemberExpression"===i.callee.type?Promise.resolve(Z(i.callee,r)).then((function(e){o=(a=e)[0],s=a[1]})):Promise.resolve(e(i.callee,r)).then((function(e){s=e}));return Promise.resolve(c&&c.then?c.then(l):l());case"ConditionalExpression":return Promise.resolve(e(i.test,r)).then((function(t){return Promise.resolve(e(t?i.consequent:i.alternate,r))}));case"Identifier":return Promise.resolve(r[i.name]);case"Literal":return Promise.resolve(i.value);case"LogicalExpression":var u=function(t){return n?t:Promise.resolve(Promise.all([e(i.left,r),e(i.right,r)])).then((function(e){return te[i.operator](e[0],e[1])}))},h="||"===i.operator?(n=1,Promise.resolve(e(i.left,r)).then((function(t){return t||Promise.resolve(e(i.right,r))}))):function(){if("&&"===i.operator)return n=1,Promise.resolve(e(i.left,r)).then((function(t){return t?Promise.resolve(e(i.right,r)):t}))}();return Promise.resolve(h&&h.then?h.then(u):u(h));case"MemberExpression":return Promise.resolve(Z(i,r)).then((function(e){return e[1]}));case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var f=re[i.operator];return Promise.resolve(e(i.argument,r)).then((function(e){return f.call(re,e)}));default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},Z=function(e,t){try{return Promise.resolve(H(e.object,t)).then((function(r){return e.computed?Promise.resolve(H(e.property,t)).then((function(e){return[r,r[e]]})):[r,r[e.property.name]]}))}catch(e){return Promise.reject(e)}},Q=function(e,t){try{return Promise.resolve(Promise.all(e.map((function(e){return H(e,t)}))))}catch(e){return Promise.reject(e)}},ee={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},te={"||":function(e,t){return e||t},"&&":function(e,t){return e&&t},"|":function(e,t){return e|t},"^":function(e,t){return e^t},"&":function(e,t){return e&t},"==":function(e,t){return e==t},"!=":function(e,t){return e!=t},"===":function(e,t){return e===t},"!==":function(e,t){return e!==t},"<":function(e,t){return e<t},">":function(e,t){return e>t},"<=":function(e,t){return e<=t},">=":function(e,t){return e>=t},"<<":function(e,t){return e<<t},">>":function(e,t){return e>>t},">>>":function(e,t){return e>>>t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t}},re={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function ne(e,t){return e.map((function(e){return oe(e,t)}))}function ie(e,t){var r=oe(e.object,t);return e.computed?[r,r[oe(e.property,t)]]:[r,r[e.property.name]]}function oe(e,t){var r=e;switch(r.type){case"ArrayExpression":return ne(r.elements,t);case"BinaryExpression":return te[r.operator](oe(r.left,t),oe(r.right,t));case"CallExpression":var n,i,o;if("MemberExpression"===r.callee.type?(n=(o=ie(r.callee,t))[0],i=o[1]):i=oe(r.callee,t),"function"!=typeof i)return;return i.apply(n,ne(r.arguments,t));case"ConditionalExpression":return oe(r.test,t)?oe(r.consequent,t):oe(r.alternate,t);case"Identifier":return t[r.name];case"Literal":return r.value;case"LogicalExpression":return"||"===r.operator?oe(r.left,t)||oe(r.right,t):"&&"===r.operator?oe(r.left,t)&&oe(r.right,t):te[r.operator](oe(r.left,t),oe(r.right,t));case"MemberExpression":return ie(r,t)[1];case"ThisExpression":return t;case"UnaryExpression":return re[r.operator](oe(r.argument,t));default:return}}!function(e){e[e.Allow=1]="Allow",e[e.Indeterminate=2]="Indeterminate",e[e.Deny=3]="Deny"}(X||(X={}));class se{constructor(e){this.done=!1,this.res=!1,this.expr=e}current(){return this.res}pushEffect(e){switch(this.expr){case"some(where (p_eft == allow))":e===X.Allow&&(this.res=!0,this.done=!0);break;case"!some(where (p_eft == deny))":this.res=!0,e===X.Deny&&(this.res=!1,this.done=!0);break;case"some(where (p_eft == allow)) && !some(where (p_eft == deny))":e===X.Allow?this.res=!0:e===X.Deny&&(this.res=!1,this.done=!0);break;case"priority(p_eft) || deny":e!==X.Indeterminate&&(this.res=e===X.Allow,this.done=!0);break;default:throw new Error("unsupported effect")}return[this.res,this.done]}}class ae{newStream(e){return new se(e)}}class le{constructor(){this.enable=!1}enableLog(e){this.enable=e}isEnable(){return this.enable}print(...e){this.enable&&console.log(...e)}printf(e,...t){this.enable&&console.log(e,...t)}}let ce=new le;function ue(e){ce=e}function he(){return ce}function fe(...e){ce.print(...e)}function de(e,...t){ce.printf(e,...t)}function pe(e,t,r){const n=e.get(t);return void 0===n?(e.set(t,r),r):n}class ye{constructor(e){this.name=e,this.roles=[]}addRole(e){this.roles.some((t=>t.name===e.name))||this.roles.push(e)}deleteRole(e){this.roles=this.roles.filter((t=>t.name!==e.name))}hasRole(e,t){if(this.name===e)return!0;if(t<=0)return!1;for(const r of this.roles)if(r.hasRole(e,t-1))return!0;return!1}hasDirectRole(e){return this.roles.some((t=>t.name===e))}toString(){return this.name+this.roles.join(", ")}getRoles(){return this.roles.map((e=>e.name))}}class ge extends Map{constructor(){super()}hasRole(e,t){let r=!1;return t?(this.forEach(((n,i)=>{t(e,i)&&(r=!0)})),r):this.has(e)}createRole(e,t){const r=pe(this,e,new ye(e));return t&&this.forEach(((n,i)=>{if(t(e,i)&&e!==i){const e=pe(this,i,new ye(i));r.addRole(e)}})),r}}class me{constructor(e){this.hasPattern=!1,this.hasDomainPattern=!1,this.allDomains=new Map,this.allDomains.set("casbin::default",new ge),this.maxHierarchyLevel=e}async addMatchingFunc(e,t){if(this.hasPattern=!0,"string"==typeof e&&t)this.matchingFunc=t;else{if("function"!=typeof e)throw new Error("error: domain should be 1 parameter");this.matchingFunc=e}}async addDomainMatchingFunc(e){this.hasDomainPattern=!0,this.domainMatchingFunc=e}generateTempRoles(e){pe(this.allDomains,e,new ge);const t=new Set([e]);this.hasDomainPattern&&this.allDomains.forEach(((r,n)=>{this.domainMatchingFunc(e,n)&&t.add(n)}));const r=new ge;return t.forEach((e=>{pe(this.allDomains,e,new ge).forEach(((e,t)=>{const n=r.createRole(e.name,this.matchingFunc);e.getRoles().forEach((e=>{n.addRole(r.createRole(e,this.matchingFunc))}))}))})),r}async addLink(e,t,...r){if(0===r.length)r=["casbin::default"];else if(r.length>1)throw new Error("error: domain should be 1 parameter");const n=pe(this.allDomains,r[0],new ge),i=pe(n,e,new ye(e)),o=pe(n,t,new ye(t));i.addRole(o)}async clear(){this.allDomains=new Map,this.allDomains.set("casbin::default",new ge)}async deleteLink(e,t,...r){if(0===r.length)r=["casbin::default"];else if(r.length>1)throw new Error("error: domain should be 1 parameter");const n=pe(this.allDomains,r[0],new ge);if(!n.has(e)||!n.has(t))return;const i=pe(n,e,new ye(e)),o=pe(n,t,new ye(t));i.deleteRole(o)}async hasLink(e,t,...r){if(0===r.length)r=["casbin::default"];else if(r.length>1)throw new Error("error: domain should be 1 parameter");if(e===t)return!0;let n;if(n=this.hasPattern||this.hasDomainPattern?this.generateTempRoles(r[0]):pe(this.allDomains,r[0],new ge),!n.hasRole(e,this.matchingFunc)||!n.hasRole(t,this.matchingFunc))return!1;return n.createRole(e,this.matchingFunc).hasRole(t,this.maxHierarchyLevel)}async getRoles(e,...t){if(0===t.length)t=["casbin::default"];else if(t.length>1)throw new Error("error: domain should be 1 parameter");let r;return r=this.hasPattern||this.hasDomainPattern?this.generateTempRoles(t[0]):pe(this.allDomains,t[0],new ge),r.hasRole(e,this.matchingFunc)?r.createRole(e,this.matchingFunc).getRoles():[]}async getUsers(e,...t){if(0===t.length)t=["casbin::default"];else if(t.length>1)throw new Error("error: domain should be 1 parameter");let r;return r=this.hasPattern||this.hasDomainPattern?this.generateTempRoles(t[0]):pe(this.allDomains,t[0],new ge),r.hasRole(e,this.matchingFunc)?[...r.values()].filter((t=>t.hasDirectRole(e))).map((e=>e.name)):[]}async printRoles(){he().isEnable()&&[...this.allDomains.values()].forEach((e=>{fe(e.toString())}))}}const we={r:"request_definition",p:"policy_definition",g:"role_definition",e:"policy_effect",m:"matchers"};var ve;!function(e){e[e.PolicyAdd=0]="PolicyAdd",e[e.PolicyRemove=1]="PolicyRemove"}(ve||(ve={}));const Pe=["r","p","e","m"];class Ee{constructor(){this.model=new Map}loadAssertion(e,t,r){const n=we[t],i=e.getString(`${n}::${r}`);return this.addDef(t,r,i)}static getKeySuffix(e){return 1===e?"":e.toString()}loadSection(e,t){let r=1;for(;this.loadAssertion(e,t,t+Ee.getKeySuffix(r));)r++}addDef(e,t,r){if(""===r)return!1;const n=new Fe;if(n.key=t,n.value=r,"r"===e||"p"===e){const e=r.split(",").map((e=>e.trim()));for(let r=0;r<e.length;r++)e[r]=t+"_"+e[r];n.tokens=e}else if("m"===e){const e=r.match(/\"(.*?)\"/g)||[];e.forEach(((e,t)=>{r=r.replace(e,`$<${t}>`)})),r=M(r),e.forEach(((e,t)=>{r=r.replace(`$<${t}>`,e)})),n.value=r}else n.value=M(r);const i=this.model.get(e);if(i)i.set(t,n);else{const r=new Map;r.set(t,n),this.model.set(e,r)}return!0}loadModel(e){const t=K.newConfig(e);this.loadModelFromConfig(t)}loadModelFromText(e){const t=K.newConfigFromText(e);this.loadModelFromConfig(t)}loadModelFromConfig(e){for(const t in we)this.loadSection(e,t);const t=[];if(Pe.forEach((e=>{this.hasSection(e)||t.push(we[e])})),t.length>0)throw new Error(`missing required sections: ${t.join(",")}`)}hasSection(e){return void 0!==this.model.get(e)}printModel(){fe("Model:"),this.model.forEach(((e,t)=>{e.forEach(((e,r)=>{fe(`${t}.${r}: ${e.value}`)}))}))}async buildIncrementalRoleLinks(e,t,r,n,i){var o,s;"g"===r&&await(null===(s=null===(o=this.model.get(r))||void 0===o?void 0:o.get(n))||void 0===s?void 0:s.buildIncrementalRoleLinks(e,t,i))}async buildRoleLinks(e){const t=this.model.get("g");if(t)for(const r of t.keys()){const n=t.get(r);let i=e.get(r);i||(i=new me(10),e.set(r,i)),await(null==n?void 0:n.buildRoleLinks(i))}}clearPolicy(){this.model.forEach(((e,t)=>{"p"!==t&&"g"!==t||e.forEach((e=>{e.policy=[]}))}))}getPolicy(e,t){var r;const n=[],i=null===(r=this.model.get(e))||void 0===r?void 0:r.get(t);return i&&n.push(...i.policy),n}hasPolicy(e,t,r){var n;const i=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);return!!i&&i.policy.some((e=>U(e,r)))}addPolicy(e,t,r){var n;if(!this.hasPolicy(e,t,r)){const i=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);if(!i)return!1;const o=i.policy,s=i.tokens.indexOf("p_priority");if(-1!==s){const e=r[s],t=o.findIndex((t=>t[s]>=e));-1===s?o.push(r):o.splice(t,0,r)}else o.push(r);return!0}return!1}addPolicies(e,t,r){var n;const i=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);if(!i)return[!1,[]];for(const n of r)if(this.hasPolicy(e,t,n))return[!1,[]];return-1!==i.tokens.indexOf("p_priority")?r.forEach((r=>{this.addPolicy(e,t,r)})):i.policy=i.policy.concat(r),[!0,r]}updatePolicy(e,t,r,n){var i;const o=null===(i=this.model.get(e))||void 0===i?void 0:i.get(t);if(!o)return!1;const s=o.policy.findIndex((e=>U(e,r)));if(-1===s)return!1;const a=o.tokens.indexOf("p_priority");if(-1!==a){if(r[a]!==n[a])throw new Error("new rule should have the same priority with old rule.");o.policy[s]=n}else o.policy[s]=n;return!0}removePolicy(e,t,r){var n;if(this.hasPolicy(e,t,r)){const i=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);return!!i&&(i.policy=i.policy.filter((e=>!U(r,e))),!0)}return!1}removePolicies(e,t,r){var n;const i=[],o=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);if(!o)return[!1,[]];for(const n of r)if(!this.hasPolicy(e,t,n))return[!1,[]];for(const e of r)o.policy=o.policy.filter((t=>{const r=U(e,t);return r&&i.push(t),!r}));return[!0,i]}getFilteredPolicy(e,t,r,...n){var i;const o=[],s=null===(i=this.model.get(e))||void 0===i?void 0:i.get(t);if(!s)return o;for(const e of s.policy){let t=!0;for(let i=0;i<n.length;i++){const o=n[i];if(""!==o&&e[r+i]!==o){t=!1;break}}t&&o.push(e)}return o}removeFilteredPolicy(e,t,r,...n){var i;const o=[],s=[];let a=!1;if(0===n.length)return[!1,s];const l=null===(i=this.model.get(e))||void 0===i?void 0:i.get(t);if(!l)return[!1,[]];for(const e of l.policy){let t=!0;for(let i=0;i<n.length;i++){const o=n[i];if(""!==o&&e[r+i]!==o){t=!1;break}}t?(a=!0,s.push(e)):o.push(e)}return 0!==s.length&&(l.policy=o),[a,s]}getValuesForFieldInPolicy(e,t,r){var n;const i=[],o=null===(n=this.model.get(e))||void 0===n?void 0:n.get(t);return o?L(o.policy.map((e=>e[r]))):i}getValuesForFieldInPolicyAllTypes(e,t){const r=[],n=this.model.get(e);if(!n)return r;for(const i of n.keys())r.push(...this.getValuesForFieldInPolicy(e,i,t));return L(r)}printPolicy(){he().isEnable()&&(fe("Policy:"),this.model.forEach(((e,t)=>{"p"!==t&&"g"!==t||e.forEach((e=>{fe(`key, : ${e.value}, : , ${e.policy}`)}))})))}}function be(...e){const t=new Ee;if(2===e.length)""!==e[0]&&t.loadModel(e[0]);else if(1===e.length)t.loadModelFromText(e[0]);else if(0!==e.length)throw new Error("Invalid parameters for model.");return t}function Ae(e){const t=new Ee;return t.loadModelFromText(e),t}class Fe{constructor(){this.key="",this.value="",this.tokens=[],this.policy=[],this.rm=new me(10)}async buildIncrementalRoleLinks(e,t,r){this.rm=e;const n=(this.value.match(/_/g)||[]).length;if(n<2)throw new Error('the number of "_" in role definition should be at least 2');for(let e of r){if(e.length<n)throw new Error("grouping policy elements do not meet role definition");switch(e.length>n&&(e=e.slice(0,n)),t){case ve.PolicyAdd:await this.rm.addLink(e[0],e[1],...e.slice(2));break;case ve.PolicyRemove:await this.rm.deleteLink(e[0],e[1],...e.slice(2));break;default:throw new Error("unsupported operation")}}}async buildRoleLinks(e){this.rm=e;const t=(this.value.match(/_/g)||[]).length;if(t<2)throw new Error('the number of "_" in role definition should be at least 2');for(let e of this.policy)e.length>t&&(e=e.slice(0,t)),await this.rm.addLink(e[0],e[1],...e.slice(2));fe(`Role links for: ${this.key}`),await this.rm.printRoles()}}class Re{constructor(){this.functions=new Map}static loadFunctionMap(){const e=new Re;return e.addFunction("keyMatch",E),e.addFunction("keyGet",b),e.addFunction("keyMatch2",F),e.addFunction("keyGet2",R),e.addFunction("keyMatch3",I),e.addFunction("keyMatch4",k),e.addFunction("regexMatch",x),e.addFunction("ipMatch",B),e.addFunction("globMatch",N),e}addFunction(e,t){this.functions.get(e)||this.functions.set(e,t)}getFunctions(){return this.functions}}class Ie{constructor(e,t,r,n){this.pType=t,this.eType=r,this.mType=n,this.rType=e}}class ke{static loadPolicyLine(e,t){if(!e||"#"===e.trimStart().charAt(0))return;const r=W(e);if(!r||!r[0])return;const n=r[0][0],i=n.substring(0,1),o=t.model.get(i);if(!o)return;const s=o.get(n);s&&s.policy.push(r[0].slice(1))}}class xe{constructor(e){this.policies=[],e&&(this.policies="string"==typeof e?W(e):e)}hasPolicy(e){return this.policies.some((t=>U(t,e)))}async loadPolicy(e){this.policies.forEach((t=>{t&&ke.loadPolicyLine(q(t),e)}))}async savePolicy(e){throw new Error("not implemented")}async addPolicy(e,t,r){const n=r.slice();n.unshift(t),this.hasPolicy(r)||this.policies.push(n)}async removePolicy(e,t,r){const n=r.slice();n.unshift(t),this.policies=this.policies.filter((e=>!U(n,e)))}async removeFilteredPolicy(e,t,r,...n){throw new Error("not implemented")}async addPolicies(e,t,r){for(const n of r)this.hasPolicy(n)||await this.addPolicy(e,t,n)}async removePolicies(e,t,r){this.policies=this.policies.filter((e=>!r.some((t=>U(t,e)))))}}class Be{constructor(){this.g=[],this.p=[]}}class Ne extends xe{constructor(e){super(e),this.filtered=!1}async loadPolicy(e){this.filtered=!1,await super.loadPolicy(e)}async loadFilteredPolicy(e,t){t?(await this.loadFilteredPolicyFile(e,t,ke.loadPolicyLine),this.filtered=!0):await this.loadPolicy(e)}async loadFilteredPolicyFile(e,t,r){this.policies.forEach((n=>{const i=q(n);i&&!Ne.filterLine(i,t)&&r(i,e)}))}isFiltered(){return this.filtered}async savePolicy(e){if(this.filtered)throw new Error("cannot save a filtered policy");return await super.savePolicy(e),!0}static filterLine(e,t){if(!t)return!1;const r=e.split(",");if(0===r.length)return!0;let n=[];switch(r[0].trim()){case"p":n=t.p;break;case"g":n=t.g}return Ne.filterWords(r,n)}static filterWords(e,t){if(e.length<t.length+1)return!0;let r=!1;for(let e=0;e<t.length;e++)if(t[e]&&t[e]!==t[e+1]){r=!0;break}return r}}class Se extends class extends class extends class{constructor(){this.fm=Re.loadFunctionMap(),this.eft=new ae,this.matcherMap=new Map,this.defaultEnforceContext=new Ie("r","p","e","m"),this.watcher=null,this.enabled=!0,this.autoSave=!0,this.autoBuildRoleLinks=!0,this.autoNotifyWatcher=!0}getExpression(e,t){const r=`${e?"ASYNC[":"SYNC["}${t}]`;!function(e,t,r){r?(J.addBinaryOp(e,t),te[e]=r):(J.addBinaryOp(e,ee[e]||1),te[e]=t)}("in",1,V);let n=this.matcherMap.get(r);return n||(t=z(t),n=e?function(e){return H.bind(null,J(e))}(t):function(e){return oe.bind(null,J(e))}(t),this.matcherMap.set(r,n)),n}loadModel(){this.model=be(),this.model.loadModel(this.modelPath),this.model.printModel()}getModel(){return this.model}setModel(e){this.model=e}getAdapter(){return this.adapter}setAdapter(e){this.adapter=e}setWatcher(e){this.watcher=e,e.setUpdateCallback((async()=>await this.loadPolicy()))}setRoleManager(e){this.rmMap.set("g",e)}getRoleManager(){return this.rmMap.get("g")}getNamedRoleManager(e){return this.rmMap.get(e)}setEffector(e){this.eft=e}clearPolicy(){this.model.clearPolicy()}initRmMap(){this.rmMap=new Map;const e=this.model.model.get("g");if(e)for(const t of e.keys())this.rmMap.set(t,new me(10))}sortPolicies(){var e,t,r,n;const i=null===(t=null===(e=this.model.model.get("p"))||void 0===e?void 0:e.get("p"))||void 0===t?void 0:t.policy,o=null===(n=null===(r=this.model.model.get("p"))||void 0===r?void 0:r.get("p"))||void 0===n?void 0:n.tokens;if(i&&o){const e=o.indexOf("p_priority");-1!==e&&i.sort(((t,r)=>parseInt(t[e],10)-parseInt(r[e],10)))}}async loadPolicy(){this.model.clearPolicy(),await this.adapter.loadPolicy(this.model),this.sortPolicies(),this.autoBuildRoleLinks&&await this.buildRoleLinksInternal()}async loadFilteredPolicy(e){return this.model.clearPolicy(),this.loadIncrementalFilteredPolicy(e)}async loadIncrementalFilteredPolicy(e){if(!("isFiltered"in this.adapter))throw new Error("filtered policies are not supported by this adapter");return await this.adapter.loadFilteredPolicy(this.model,e),this.sortPolicies(),this.autoBuildRoleLinks&&await this.buildRoleLinksInternal(),!0}isFiltered(){return"isFiltered"in this.adapter&&this.adapter.isFiltered()}async savePolicy(){if(this.isFiltered())throw new Error("Cannot save a filtered policy");return!!await this.adapter.savePolicy(this.model)&&(!this.watcher||await this.watcher.update())}enableEnforce(e){this.enabled=e}enableLog(e){he().enableLog(e)}enableAutoSave(e){this.autoSave=e}enableAutoNotifyWatcher(e){this.autoNotifyWatcher=e}enableAutoBuildRoleLinks(e){this.autoBuildRoleLinks=e}async addNamedMatchingFunc(e,t){const r=this.rmMap.get(e);if(r)return await r.addMatchingFunc(t);throw Error("Target ptype not found.")}async addNamedDomainMatchingFunc(e,t){const r=this.rmMap.get(e);if(r)return await r.addDomainMatchingFunc(t)}async buildRoleLinks(){return this.buildRoleLinksInternal()}async buildIncrementalRoleLinks(e,t,r){let n=this.rmMap.get(t);n||(n=new me(10),this.rmMap.set(t,n)),await this.model.buildIncrementalRoleLinks(n,e,"g",t,r)}async buildRoleLinksInternal(){for(const e of this.rmMap.values())await e.clear(),await this.model.buildRoleLinks(this.rmMap)}*privateEnforce(e=!0,t=!1,r=new Ie("r","p","e","m"),...n){var i,o,s,a,l,c,u,h,f;if(!this.enabled)return!0;let d=-1;const p={};this.fm.getFunctions().forEach(((e,t)=>{p[t]=e}));const y=this.model.model.get("g");null==y||y.forEach(((e,t)=>{const r=e.rm;p[t]=S(r)}));const g=null===(o=null===(i=this.model.model.get("m"))||void 0===i?void 0:i.get(r.mType))||void 0===o?void 0:o.value;if(!g)throw new Error("Unable to find matchers in model");const m=null===(a=null===(s=this.model.model.get("e"))||void 0===s?void 0:s.get(r.eType))||void 0===a?void 0:a.value;if(!m)throw new Error("Unable to find policy_effect in model");const w=C(g);let v;const P=null===(l=this.model.model.get("p"))||void 0===l?void 0:l.get(r.pType),E=null===(c=null==P?void 0:P.policy)||void 0===c?void 0:c.length,b=null===(h=null===(u=this.model.model.get("r"))||void 0===u?void 0:u.get(r.rType))||void 0===h?void 0:h.tokens,A=null==b?void 0:b.length,F=this.eft.newStream(m);if(E&&0!==E)for(let t=0;t<E;t++){const r={};if((null==b?void 0:b.length)!==n.length)throw new Error(`invalid request size: expected ${A}, got ${n.length}, rvals: ${n}"`);if(b.forEach(((e,t)=>{r[e]=n[t]})),null==P||P.tokens.forEach(((e,n)=>{r[e]=null==P?void 0:P.policy[t][n]})),w){const t=$(g);let n=g;for(const e of t){if(!(e in r))throw new Error(`${e} not in ${r}`);n=O(n,e,M(r[e]))}v=this.getExpression(e,n)}else void 0===v&&(v=this.getExpression(e,g));const i=Object.assign(Object.assign({},r),p),o=e?yield v(i):v(i);let s;switch(typeof o){case"boolean":s=o?X.Allow:X.Indeterminate;break;case"number":s=0===o?X.Indeterminate:o;break;default:throw new Error("matcher result should be boolean or number")}const a=r.p_eft;a&&s===X.Allow&&(s="allow"===a?X.Allow:"deny"===a?X.Deny:X.Indeterminate);const[l,c]=F.pushEffect(s);if(c){d=t;break}}else{d=0;const t={};null==b||b.forEach(((e,r)=>{t[e]=n[r]})),null===(f=null==P?void 0:P.tokens)||void 0===f||f.forEach((e=>{t[e]=""})),v=this.getExpression(e,g);const r=Object.assign(Object.assign({},t),p);(e?yield v(r):v(r))?F.pushEffect(X.Allow):F.pushEffect(X.Indeterminate)}const R=F.current();if(he().isEnable()){let e="Request: ";for(let t=0;t<n.length;t++)t!==n.length-1?e+=`${n[t]}, `:e+=n[t];e+=` ---\x3e ${R}`,fe(e)}return t?-1===d?[R,[]]:[R,null==P?void 0:P.policy[d]]:R}enforceSync(...e){if(e[0]instanceof Ie){const t=e.shift();return G(this.privateEnforce(!1,!1,t,...e))}return G(this.privateEnforce(!1,!1,this.defaultEnforceContext,...e))}enforceExSync(...e){if(e[0]instanceof Ie){const t=e.shift();return G(this.privateEnforce(!1,!0,t,...e))}return G(this.privateEnforce(!1,!0,this.defaultEnforceContext,...e))}enforceWithSyncCompile(...e){return this.enforceSync(...e)}async enforce(...e){if(e[0]instanceof Ie){const t=e.shift();return D(this.privateEnforce(!0,!1,t,...e))}return D(this.privateEnforce(!0,!1,this.defaultEnforceContext,...e))}async enforceEx(...e){if(e[0]instanceof Ie){const t=e.shift();return D(this.privateEnforce(!0,!0,t,...e))}return D(this.privateEnforce(!0,!0,this.defaultEnforceContext,...e))}async batchEnforce(e){return await Promise.all(e.map((e=>this.enforce(...e))))}}{async addPolicyInternal(e,t,r){if(this.model.hasPolicy(e,t,r))return!1;if(this.adapter&&this.autoSave)try{await this.adapter.addPolicy(e,t,r)}catch(e){if("not implemented"!==e.message)throw e}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const n=this.model.addPolicy(e,t,r);return"g"===e&&n&&await this.buildIncrementalRoleLinks(ve.PolicyAdd,t,[r]),n}async addPoliciesInternal(e,t,r){for(const n of r)if(this.model.hasPolicy(e,t,n))return!1;if(this.autoSave){if(!("addPolicies"in this.adapter))throw new Error("cannot to save policy, the adapter does not implement the BatchAdapter");try{await this.adapter.addPolicies(e,t,r)}catch(e){if("not implemented"!==e.message)throw e}}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const[n,i]=await this.model.addPolicies(e,t,r);return"g"===e&&n&&(null==i?void 0:i.length)&&await this.buildIncrementalRoleLinks(ve.PolicyAdd,t,i),n}async updatePolicyInternal(e,t,r,n){if(!this.model.hasPolicy(e,t,r))return!1;if(this.autoSave){if(!("updatePolicy"in this.adapter))throw new Error("cannot to update policy, the adapter does not implement the UpdatableAdapter");try{await this.adapter.updatePolicy(e,t,r,n)}catch(e){if("not implemented"!==e.message)throw e}}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const i=this.model.updatePolicy(e,t,r,n);return"g"===e&&i&&(await this.buildIncrementalRoleLinks(ve.PolicyRemove,t,[r]),await this.buildIncrementalRoleLinks(ve.PolicyAdd,t,[n])),i}async removePolicyInternal(e,t,r){if(!this.model.hasPolicy(e,t,r))return!1;if(this.adapter&&this.autoSave)try{await this.adapter.removePolicy(e,t,r)}catch(e){if("not implemented"!==e.message)throw e}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const n=await this.model.removePolicy(e,t,r);return"g"===e&&n&&await this.buildIncrementalRoleLinks(ve.PolicyRemove,t,[r]),n}async removePoliciesInternal(e,t,r){for(const n of r)if(!this.model.hasPolicy(e,t,n))return!1;if(this.autoSave){if(!("removePolicies"in this.adapter))throw new Error("cannot to save policy, the adapter does not implement the BatchAdapter");try{await this.adapter.removePolicies(e,t,r)}catch(e){if("not implemented"!==e.message)throw e}}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const[n,i]=this.model.removePolicies(e,t,r);return"g"===e&&n&&(null==i?void 0:i.length)&&await this.buildIncrementalRoleLinks(ve.PolicyRemove,t,i),n}async removeFilteredPolicyInternal(e,t,r,n){if(this.adapter&&this.autoSave)try{await this.adapter.removeFilteredPolicy(e,t,r,...n)}catch(e){if("not implemented"!==e.message)throw e}this.watcher&&this.autoNotifyWatcher&&this.watcher.update();const[i,o]=this.model.removeFilteredPolicy(e,t,r,...n);return"g"===e&&i&&(null==o?void 0:o.length)&&await this.buildIncrementalRoleLinks(ve.PolicyRemove,t,o),i}}{async getAllSubjects(){return this.getAllNamedSubjects("p")}async getAllNamedSubjects(e){return this.model.getValuesForFieldInPolicy("p",e,0)}async getAllObjects(){return this.getAllNamedObjects("p")}async getAllNamedObjects(e){return this.model.getValuesForFieldInPolicy("p",e,1)}async getAllActions(){return this.getAllNamedActions("p")}async getAllNamedActions(e){return this.model.getValuesForFieldInPolicy("p",e,2)}async getAllRoles(){return this.getAllNamedRoles("g")}async getAllNamedRoles(e){return this.model.getValuesForFieldInPolicy("g",e,1)}async getPolicy(){return this.getNamedPolicy("p")}async getFilteredPolicy(e,...t){return this.getFilteredNamedPolicy("p",e,...t)}async getNamedPolicy(e){return this.model.getPolicy("p",e)}async getFilteredNamedPolicy(e,t,...r){return this.model.getFilteredPolicy("p",e,t,...r)}async getGroupingPolicy(){return this.getNamedGroupingPolicy("g")}async getFilteredGroupingPolicy(e,...t){return this.getFilteredNamedGroupingPolicy("g",e,...t)}async getNamedGroupingPolicy(e){return this.model.getPolicy("g",e)}async getFilteredNamedGroupingPolicy(e,t,...r){return this.model.getFilteredPolicy("g",e,t,...r)}async hasPolicy(...e){return this.hasNamedPolicy("p",...e)}async hasNamedPolicy(e,...t){return this.model.hasPolicy("p",e,t)}async addPolicy(...e){return this.addNamedPolicy("p",...e)}async addPolicies(e){return this.addNamedPolicies("p",e)}async addNamedPolicy(e,...t){return this.addPolicyInternal("p",e,t)}async addNamedPolicies(e,t){return this.addPoliciesInternal("p",e,t)}async updatePolicy(e,t){return this.updateNamedPolicy("p",e,t)}async updateNamedPolicy(e,t,r){return this.updatePolicyInternal("p",e,t,r)}async removePolicy(...e){return this.removeNamedPolicy("p",...e)}async removePolicies(e){return this.removeNamedPolicies("p",e)}async removeFilteredPolicy(e,...t){return this.removeFilteredNamedPolicy("p",e,...t)}async removeNamedPolicy(e,...t){return this.removePolicyInternal("p",e,t)}async removeNamedPolicies(e,t){return this.removePoliciesInternal("p",e,t)}async removeFilteredNamedPolicy(e,t,...r){return this.removeFilteredPolicyInternal("p",e,t,r)}async hasGroupingPolicy(...e){return this.hasNamedGroupingPolicy("g",...e)}async hasNamedGroupingPolicy(e,...t){return this.model.hasPolicy("g",e,t)}async addGroupingPolicy(...e){return this.addNamedGroupingPolicy("g",...e)}async addGroupingPolicies(e){return this.addNamedGroupingPolicies("g",e)}async addNamedGroupingPolicy(e,...t){return this.addPolicyInternal("g",e,t)}async addNamedGroupingPolicies(e,t){return this.addPoliciesInternal("g",e,t)}async removeGroupingPolicy(...e){return this.removeNamedGroupingPolicy("g",...e)}async removeGroupingPolicies(e){return this.removeNamedGroupingPolicies("g",e)}async removeFilteredGroupingPolicy(e,...t){return this.removeFilteredNamedGroupingPolicy("g",e,...t)}async removeNamedGroupingPolicy(e,...t){return this.removePolicyInternal("g",e,t)}async removeNamedGroupingPolicies(e,t){return this.removePoliciesInternal("g",e,t)}async removeFilteredNamedGroupingPolicy(e,t,...r){return this.removeFilteredPolicyInternal("g",e,t,r)}async addFunction(e,t){this.fm.addFunction(e,t)}}{async initWithString(e,t,r=!1){const n=new xe(t);await this.initWithAdapter(e,n,r)}async initWithAdapter(e,t,r=!1){const n=be(e,"");await this.initWithModelAndAdapter(n,t,r),this.modelPath=e}async initWithModelAndAdapter(e,t,r=!1){t&&(this.adapter=t),this.model=e,this.model.printModel(),this.initRmMap(),!r&&this.adapter&&await this.loadPolicy()}async getRolesForUser(e,t){const r=this.rmMap.get("g");if(r)return void 0===t?r.getRoles(e):r.getRoles(e,t);throw new Error("RoleManager didn't exist.")}async getUsersForRole(e,t){const r=this.rmMap.get("g");if(r)return void 0===t?r.getUsers(e):r.getUsers(e,t);throw new Error("RoleManager didn't exist.")}async hasRoleForUser(e,t,r){const n=await this.getRolesForUser(e,r);let i=!1;for(const e of n)if(e===t){i=!0;break}return i}async addRoleForUser(e,t,r){return void 0===r?this.addGroupingPolicy(e,t):this.addGroupingPolicy(e,t,r)}async addRoleForUserInDomain(e,t,r){return this.addGroupingPolicy(e,t,r)}async deleteRoleForUser(e,t,r){return void 0===r?this.removeGroupingPolicy(e,t):this.removeGroupingPolicy(e,t,r)}async deleteRoleForUserInDomain(e,t,r){return this.deleteRoleForUser(e,t,r)}async deleteRolesForUser(e,t){return void 0===t?this.removeFilteredGroupingPolicy(0,e):this.removeFilteredGroupingPolicy(0,e,"",t)}async deleteRolesForUserInDomain(e,t){return this.deleteRolesForUser(e,t)}async deleteUser(e){const t=await this.removeFilteredGroupingPolicy(0,e),r=await this.removeFilteredPolicy(0,e);return t||r}async deleteRole(e){const t=await this.removeFilteredGroupingPolicy(1,e),r=await this.removeFilteredPolicy(0,e);return t||r}async deletePermission(...e){return this.removeFilteredPolicy(1,...e)}async addPermissionForUser(e,...t){return t.unshift(e),this.addPolicy(...t)}async deletePermissionForUser(e,...t){return t.unshift(e),this.removePolicy(...t)}async deletePermissionsForUser(e){return this.removeFilteredPolicy(0,e)}async getPermissionsForUser(e){return this.getFilteredPolicy(0,e)}async hasPermissionForUser(e,...t){return t.unshift(e),this.hasPolicy(...t)}async getImplicitRolesForUser(e,...t){const r=new Set,n=[e];let i;for(;void 0!==(i=n.shift());)for(const e of this.rmMap.values()){(await e.getRoles(i,...t)).forEach((e=>{r.has(e)||(r.add(e),n.push(e))}))}return Array.from(r)}async getImplicitPermissionsForUser(e,...t){const r=await this.getImplicitRolesForUser(e,...t);r.unshift(e);const n=[],i=t&&0!==t.length;for(const e of r)if(i){const r=await this.getFilteredPolicy(0,e,...t);n.push(...r)}else{const t=await this.getPermissionsForUser(e);n.push(...t)}return n}async getPermissionsForUserInDomain(e,t){return await this.getImplicitPermissionsForUser(e,t)}async getImplicitUsersForRole(e,...t){const r=new Set,n=[e];let i;for(;void 0!==(i=n.shift());)for(const e of this.rmMap.values()){(await e.getUsers(i,...t)).forEach((e=>{r.has(e)||(r.add(e),n.push(e))}))}return Array.from(r)}async getImplicitUsersForPermission(...e){const t=[],r=L([...await this.getAllSubjects(),...this.model.getValuesForFieldInPolicyAllTypes("g",0)]),n=this.model.getValuesForFieldInPolicyAllTypes("g",1);for(const n of r){await this.enforce(n,...e)&&t.push(n)}return t.filter((e=>!n.some((t=>e===t))))}}async function Me(e,...t){const r=new e;let n=0;if(t.length>=1){const e=t[t.length-1];"boolean"==typeof e&&(he().enableLog(e),n++)}if(t.length-n==2)if("string"==typeof t[0])"string"==typeof t[1]?await r.initWithString(t[0].toString(),t[1].toString()):await r.initWithAdapter(t[0].toString(),t[1]);else{if("string"==typeof t[1])throw new Error("Invalid parameters for enforcer.");await r.initWithModelAndAdapter(t[0],t[1])}else if(t.length-n==1)"string"==typeof t[0]?await r.initWithString(t[0],""):await r.initWithModelAndAdapter(t[0]);else{if(t.length!==n)throw new Error("Invalid parameters for enforcer.");await r.initWithString("","")}return r}async function Ue(...e){return Me(Se,...e)}class Le extends Se{constructor(){super(...arguments),this.enableCache=!0,this.m=new Map}invalidateCache(){this.m=new Map}setEnableCache(e){this.enableCache=e}static canCache(...e){return e.every((e=>"string"==typeof e))}static getCacheKey(...e){return e.join("$$")}getCache(e){return this.m.get(e)}setCache(e,t){this.m.set(e,t)}async enforce(...e){if(!this.enableCache)return super.enforce(...e);let t="";const r=Le.canCache(...e);if(r){t=Le.getCacheKey(...e);const r=this.getCache(t);if(void 0!==r)return r}const n=await super.enforce(...e);return r&&this.setCache(t,n),n}}async function _e(...e){return Me(Le,...e)}var Te,Ce=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this._acquired=!1,this._waitingResolvers=[]}get acquired(){return this._acquired}acquireAsync(){return this._acquired?new Promise((e=>{this._waitingResolvers.push(e)})):(this._acquired=!0,Promise.resolve())}tryAcquire(){return!this._acquired&&(this._acquired=!0,!0)}release(){if(!this._acquired)throw new Error("Cannot release an unacquired lock");if(this._waitingResolvers.length>0){this._waitingResolvers.shift()()}else this._acquired=!1}}})),Oe=(Te=Ce)&&Te.__esModule&&Object.prototype.hasOwnProperty.call(Te,"default")?Te.default:Te;class $e extends Se{constructor(){super(...arguments),this.lock=new Oe}setWatcher(e){this.watcher=e,this.watcher.setUpdateCallback((()=>this.loadPolicy()))}async loadPolicy(){return await this.lock.acquireAsync(),super.loadPolicy().finally((()=>this.lock.release()))}clearPolicy(){this.lock.acquireAsync().then((()=>super.clearPolicy())).finally((()=>this.lock.release()))}async savePolicy(){return await this.lock.acquireAsync(),super.savePolicy().finally((()=>this.lock.release()))}async buildRoleLinks(){return await this.lock.acquireAsync(),super.buildRoleLinks().finally((()=>this.lock.release()))}enforceWithSyncCompile(...e){return super.enforceWithSyncCompile(...e)}async enforce(...e){return await this.lock.acquireAsync(),super.enforce(...e).finally((()=>this.lock.release()))}async getAllSubjects(){return this.getAllNamedSubjects("p")}async getAllNamedSubjects(e){return await this.lock.acquireAsync(),super.getAllNamedSubjects(e).finally((()=>this.lock.release()))}async getAllObjects(){return this.getAllNamedObjects("p")}async getAllNamedObjects(e){return await this.lock.acquireAsync(),super.getAllNamedObjects(e).finally((()=>this.lock.release()))}async getAllActions(){return this.getAllNamedActions("p")}async getAllNamedActions(e){return await this.lock.acquireAsync(),super.getAllNamedActions(e).finally((()=>this.lock.release()))}async getAllRoles(){return this.getAllNamedRoles("g")}async getAllNamedRoles(e){return await this.lock.acquireAsync(),super.getAllNamedRoles(e).finally((()=>this.lock.release()))}async getPolicy(){return this.getNamedPolicy("p")}async getFilteredPolicy(e,...t){return this.getFilteredNamedPolicy("p",e,...t)}async getNamedPolicy(e){return await this.lock.acquireAsync(),super.getNamedPolicy(e).finally((()=>this.lock.release()))}async getFilteredNamedPolicy(e,t,...r){return await this.lock.acquireAsync(),super.getFilteredNamedPolicy(e,t,...r).finally((()=>this.lock.release()))}async getGroupingPolicy(){return this.getNamedGroupingPolicy("g")}async getFilteredGroupingPolicy(e,...t){return this.getFilteredNamedGroupingPolicy("g",e,...t)}async getNamedGroupingPolicy(e){return await this.lock.acquireAsync(),super.getNamedGroupingPolicy(e).finally((()=>this.lock.release()))}async getFilteredNamedGroupingPolicy(e,t,...r){return await this.lock.acquireAsync(),super.getFilteredNamedGroupingPolicy(e,t,...r).finally((()=>this.lock.release()))}async hasPolicy(...e){return this.hasNamedPolicy("p",...e)}async hasNamedPolicy(e,...t){return await this.lock.acquireAsync(),super.hasNamedPolicy(e,...t).finally((()=>this.lock.release()))}async addPolicy(...e){return this.addNamedPolicy("p",...e)}async addNamedPolicy(e,...t){return await this.lock.acquireAsync(),super.addNamedPolicy(e,...t).finally((()=>this.lock.release()))}async removePolicy(...e){return this.removeNamedPolicy("p",...e)}async removeFilteredPolicy(e,...t){return this.removeFilteredNamedPolicy("p",e,...t)}async removeNamedPolicy(e,...t){return await this.lock.acquireAsync(),this.removePolicyInternal("p",e,t).finally((()=>this.lock.release()))}async removeFilteredNamedPolicy(e,t,...r){return await this.lock.acquireAsync(),super.removeFilteredNamedPolicy(e,t,...r).finally((()=>this.lock.release()))}async hasGroupingPolicy(...e){return this.hasNamedGroupingPolicy("g",...e)}async hasNamedGroupingPolicy(e,...t){return await this.lock.acquireAsync(),super.hasNamedGroupingPolicy(e,...t).finally((()=>this.lock.release()))}async addGroupingPolicy(...e){return this.addNamedGroupingPolicy("g",...e)}async addNamedGroupingPolicy(e,...t){return await this.lock.acquireAsync(),super.addNamedGroupingPolicy(e,...t).finally((()=>this.lock.release()))}async removeGroupingPolicy(...e){return this.removeNamedGroupingPolicy("g",...e)}async removeFilteredGroupingPolicy(e,...t){return this.removeFilteredNamedGroupingPolicy("g",e,...t)}async removeNamedGroupingPolicy(e,...t){return await this.lock.acquireAsync(),super.removeNamedGroupingPolicy(e,...t).finally((()=>this.lock.release()))}async removeFilteredNamedGroupingPolicy(e,t,...r){return await this.lock.acquireAsync(),super.removeFilteredNamedGroupingPolicy(e,t,...r).finally((()=>this.lock.release()))}async addNamedMatchingFunc(e,t){return await this.lock.acquireAsync(),super.addNamedMatchingFunc(e,t).finally((()=>this.lock.release()))}async addNamedDomainMatchingFunc(e,t){return await this.lock.acquireAsync(),super.addNamedDomainMatchingFunc(e,t).finally((()=>{this.lock.release()}))}}async function Ge(...e){return Me($e,...e)}async function De(e,t){var r,n,i,o,s,a,l,c,u,h,f;const d={},p=e.getModel().model;let y="";y+="[request_definition]\n",y+=`r = ${null===(n=null===(r=p.get("r"))||void 0===r?void 0:r.get("r"))||void 0===n?void 0:n.value.replace(/_/g,".")}\n`,y+="[policy_definition]\n",y+=`p = ${null===(o=null===(i=p.get("p"))||void 0===i?void 0:i.get("p"))||void 0===o?void 0:o.value.replace(/_/g,".")}\n`,void 0!==(null===(s=p.get("g"))||void 0===s?void 0:s.get("g"))&&(y+="[role_definition]\n",y+=`g = ${null===(l=null===(a=p.get("g"))||void 0===a?void 0:a.get("g"))||void 0===l?void 0:l.value}\n`),y+="[policy_effect]\n",y+=`e = ${null===(u=null===(c=p.get("e"))||void 0===c?void 0:c.get("e"))||void 0===u?void 0:u.value.replace(/_/g,".")}\n`,y+="[matchers]\n",y+=`m = ${null===(f=null===(h=p.get("m"))||void 0===h?void 0:h.get("m"))||void 0===f?void 0:f.value.replace(/_/g,".")}`,d.m=y,d.p=j(await e.getPolicy());for(const e of d.p)e.splice(0,0,"p");return JSON.stringify(d)}export{Fe as Assertion,Le as CachedEnforcer,K as Config,ae as DefaultEffector,se as DefaultEffectorStream,Ne as DefaultFilteredAdapter,le as DefaultLogger,me as DefaultRoleManager,X as Effect,Ie as EnforceContext,Se as Enforcer,Be as Filter,Re as FunctionMap,ke as Helper,xe as MemoryAdapter,Ee as Model,ve as PolicyOp,$e as SyncedEnforcer,Y as Util,De as casbinJsGetPermissionForUser,he as getLogger,fe as logPrint,de as logPrintf,_e as newCachedEnforcer,Ue as newEnforcer,Me as newEnforcerWithClass,be as newModel,Ae as newModelFromString,Ge as newSyncedEnforcer,Pe as requiredSections,we as sectionNameMap,ue as setLogger};
|
|
3
|
+
//# sourceMappingURL=casbin.esm.js.map
|