@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 CHANGED
@@ -5,3 +5,4 @@ export * from './internal-service';
5
5
  export * from './user-middlewares';
6
6
  export * from './emit-internal-event';
7
7
  export * from './response-error';
8
+ export * from './request-utils';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qelos/api-kit",
3
- "version": "3.11.9",
3
+ "version": "3.11.10",
4
4
  "description": "API-Kit package to help with qelos infrastructure and reuse capabilities across services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -4,4 +4,5 @@ export * from './router'
4
4
  export * from './internal-service'
5
5
  export * from './user-middlewares'
6
6
  export * from './emit-internal-event'
7
- export * from './response-error';
7
+ export * from './response-error';
8
+ export * from './request-utils';
@@ -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
+ }