@saihu/common 1.4.6 → 1.4.8

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.
@@ -1,10 +1,9 @@
1
1
  import { PermissionEvaluator } from './rbac.interface';
2
+ import { AuthUser } from './auth.types';
2
3
  import { RedisService } from '../interfaces/service.interface';
3
4
  export declare class RedisPermissionEvaluator implements PermissionEvaluator {
4
5
  private readonly redis;
5
6
  constructor(redis: RedisService);
6
- hasPerms(user: {
7
- sub: number;
8
- }, required: string[]): Promise<boolean>;
7
+ hasPerms(user: AuthUser, required: string[]): Promise<boolean>;
9
8
  }
10
9
  //# sourceMappingURL=redis-permission.evaluator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redis-permission.evaluator.d.ts","sourceRoot":"","sources":["../../src/auth/redis-permission.evaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,qBACa,wBAAyB,YAAW,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,YAAY;IAEjE,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ5E"}
1
+ {"version":3,"file":"redis-permission.evaluator.d.ts","sourceRoot":"","sources":["../../src/auth/redis-permission.evaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,qBACa,wBAAyB,YAAW,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,YAAY;IAEjE,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAYrE"}
@@ -20,8 +20,12 @@ let RedisPermissionEvaluator = class RedisPermissionEvaluator {
20
20
  this.redis = redis;
21
21
  }
22
22
  async hasPerms(user, required) {
23
+ var _a;
23
24
  if (!required.length)
24
25
  return true;
26
+ // Super admin bypass — skip all permission checks
27
+ if ((_a = user.roles) === null || _a === void 0 ? void 0 : _a.includes('admin'))
28
+ return true;
25
29
  const cached = await this.redis.get(`auth:perms:staff:${user.sub}`);
26
30
  if (!cached)
27
31
  return false;
@@ -30,9 +30,11 @@ export declare const RoutingKeys: {
30
30
  };
31
31
  readonly "scm.job": {
32
32
  readonly SCM_EXPORT_REQUESTED: "scm.export.requested";
33
+ readonly SCM_EMAIL_REQUESTED: "scm.email.requested";
33
34
  };
34
35
  readonly "scm.job.dlx": {
35
36
  readonly SCM_EXPORT_REQUESTED: "scm.export.requested.dlq";
37
+ readonly SCM_EMAIL_REQUESTED: "scm.email.requested.dlq";
36
38
  };
37
39
  readonly "im.procurement.order": {
38
40
  readonly ORDER_CREATED: "procurement.order.created";
@@ -1 +1 @@
1
- {"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/messaging/topology.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErE,oBAAY,SAAS;IACnB,oBAAoB,yBAAyB;IAC7C,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,OAAO,YAAY;IACnB,iBAAiB,sBAAsB;IACvC,QAAQ,aAAa;IACrB,qBAAqB,0BAA0B;IAC/C,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,MAAM,WAAW;IAGjB,wBAAwB,6BAA6B;IACrD,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,WAAW,gBAAgB;IAC3B,qBAAq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REQUESTED: 'scm.export.requested.dlq',
41
+ SCM_EMAIL_REQUESTED: 'scm.email.requested.dlq',
40
42
  },
41
43
  [Exchanges.IM_PROCUREMENT_ORDER]: {
42
44
  ORDER_CREATED: 'procurement.order.created',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saihu/common",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "Common utilities for NestJS applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",