@aeriajs/common 0.0.72 → 0.0.74
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/dist/arraysIntersect.d.ts +1 -0
- package/dist/{arraysIntersects.js → arraysIntersect.js} +3 -3
- package/dist/{arraysIntersects.mjs → arraysIntersect.mjs} +1 -1
- package/dist/evaluateCondition.js +2 -2
- package/dist/evaluateCondition.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/isGranted.js +2 -2
- package/dist/isGranted.mjs +2 -2
- package/package.json +2 -2
- package/dist/arraysIntersects.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const arraysIntersect: <T extends any[] | readonly any[]>(subject: T | string, arr: T | undefined) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.arraysIntersect = void 0;
|
|
4
|
+
const arraysIntersect = (subject, arr) => {
|
|
5
5
|
if (!arr) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
@@ -9,4 +9,4 @@ const arraysIntersects = (subject, arr) => {
|
|
|
9
9
|
? subject.some((e) => arr.includes(e))
|
|
10
10
|
: arr.includes(subject);
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
12
|
+
exports.arraysIntersect = arraysIntersect;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.evaluateCondition = void 0;
|
|
4
|
-
const
|
|
4
|
+
const arraysIntersect_js_1 = require("./arraysIntersect.js");
|
|
5
5
|
const equalOrContains = (term1, term2) => {
|
|
6
6
|
if (Array.isArray(term1) && Array.isArray(term2)) {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, arraysIntersect_js_1.arraysIntersect)(term1, term2);
|
|
8
8
|
}
|
|
9
9
|
if (Array.isArray(term1)) {
|
|
10
10
|
return term1.includes(term2);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {
|
|
2
|
+
import { arraysIntersect } from "./arraysIntersect.mjs";
|
|
3
3
|
const equalOrContains = (term1, term2) => {
|
|
4
4
|
if (Array.isArray(term1) && Array.isArray(term2)) {
|
|
5
|
-
return
|
|
5
|
+
return arraysIntersect(term1, term2);
|
|
6
6
|
}
|
|
7
7
|
if (Array.isArray(term1)) {
|
|
8
8
|
return term1.includes(term2);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./arraysIntersect.js"), exports);
|
|
18
18
|
__exportStar(require("./checkForUndefined.js"), exports);
|
|
19
19
|
__exportStar(require("./convertConditionToQuery.js"), exports);
|
|
20
20
|
__exportStar(require("./date.js"), exports);
|
package/dist/index.mjs
CHANGED
package/dist/isGranted.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isGranted = void 0;
|
|
4
|
-
const
|
|
4
|
+
const arraysIntersect_js_1 = require("./arraysIntersect.js");
|
|
5
5
|
const isGranted = (condition, token) => {
|
|
6
6
|
if (Array.isArray(condition)) {
|
|
7
7
|
return token.authenticated
|
|
8
|
-
? (0,
|
|
8
|
+
? (0, arraysIntersect_js_1.arraysIntersect)(token.roles, condition)
|
|
9
9
|
: condition.includes('unauthenticated');
|
|
10
10
|
}
|
|
11
11
|
switch (condition) {
|
package/dist/isGranted.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {
|
|
2
|
+
import { arraysIntersect } from "./arraysIntersect.mjs";
|
|
3
3
|
export const isGranted = (condition, token) => {
|
|
4
4
|
if (Array.isArray(condition)) {
|
|
5
|
-
return token.authenticated ?
|
|
5
|
+
return token.authenticated ? arraysIntersect(token.roles, condition) : condition.includes("unauthenticated");
|
|
6
6
|
}
|
|
7
7
|
switch (condition) {
|
|
8
8
|
case false:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"bson": "^6.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@aeriajs/types": "^0.0.
|
|
34
|
+
"@aeriajs/types": "^0.0.64",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const arraysIntersects: <T extends any[] | readonly any[]>(subject: T | string, arr: T | undefined) => boolean;
|