@qelos/api-kit 3.11.9 → 3.11.10
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/request-utils.d.ts +6 -0
- package/dist/request-utils.js +18 -0
- package/dist/request-utils.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/request-utils.ts +16 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,4 +21,5 @@ __exportStar(require("./internal-service"), exports);
|
|
|
21
21
|
__exportStar(require("./user-middlewares"), exports);
|
|
22
22
|
__exportStar(require("./emit-internal-event"), exports);
|
|
23
23
|
__exportStar(require("./response-error"), exports);
|
|
24
|
+
__exportStar(require("./request-utils"), exports);
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,wCAAqB;AACrB,2CAAwB;AACxB,qDAAkC;AAClC,qDAAkC;AAClC,wDAAqC;AACrC,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,wCAAqB;AACrB,2CAAwB;AACxB,qDAAkC;AAClC,qDAAkC;AAClC,wDAAqC;AACrC,mDAAiC;AACjC,kDAAgC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Reads bypassAdmin from request body, query, or header (x-bypass-admin).
|
|
4
|
+
* When true, privileged users (e.g. admin) are treated as regular users for scope filtering.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getBypassAdmin(req: Request): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBypassAdmin = getBypassAdmin;
|
|
4
|
+
/**
|
|
5
|
+
* Reads bypassAdmin from request body, query, or header (x-bypass-admin).
|
|
6
|
+
* When true, privileged users (e.g. admin) are treated as regular users for scope filtering.
|
|
7
|
+
*/
|
|
8
|
+
function getBypassAdmin(req) {
|
|
9
|
+
if (typeof req.body?.bypassAdmin !== 'undefined') {
|
|
10
|
+
return !!req.body.bypassAdmin;
|
|
11
|
+
}
|
|
12
|
+
if (req.query?.bypassAdmin === 'true') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
const h = req.headers?.['x-bypass-admin'];
|
|
16
|
+
return h === 'true' || h === '1';
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=request-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-utils.js","sourceRoot":"","sources":["../src/request-utils.ts"],"names":[],"mappings":";;AAMA,wCASC;AAbD;;;GAGG;AACH,SAAgB,cAAc,CAAC,GAAY;IACzC,IAAI,OAAQ,GAAW,CAAC,IAAI,EAAE,WAAW,KAAK,WAAW,EAAE,CAAC;QAC1D,OAAO,CAAC,CAAE,GAAW,CAAC,IAAI,CAAC,WAAW,CAAC;IACzC,CAAC;IACD,IAAK,GAAW,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reads bypassAdmin from request body, query, or header (x-bypass-admin).
|
|
5
|
+
* When true, privileged users (e.g. admin) are treated as regular users for scope filtering.
|
|
6
|
+
*/
|
|
7
|
+
export function getBypassAdmin(req: Request): boolean {
|
|
8
|
+
if (typeof (req as any).body?.bypassAdmin !== 'undefined') {
|
|
9
|
+
return !!(req as any).body.bypassAdmin;
|
|
10
|
+
}
|
|
11
|
+
if ((req as any).query?.bypassAdmin === 'true') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
const h = req.headers?.['x-bypass-admin'];
|
|
15
|
+
return h === 'true' || h === '1';
|
|
16
|
+
}
|