@zorionapp/gg-core 4.14.0

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.
Files changed (239) hide show
  1. package/README.md +11 -0
  2. package/package.json +58 -0
  3. package/src/gg-auth/decorators/protected.decorator.d.ts +9 -0
  4. package/src/gg-auth/decorators/protected.decorator.js +8 -0
  5. package/src/gg-auth/decorators/protected.decorator.js.map +1 -0
  6. package/src/gg-auth/exceptions/merchant-ip-mismatch.exception.d.ts +7 -0
  7. package/src/gg-auth/exceptions/merchant-ip-mismatch.exception.js +15 -0
  8. package/src/gg-auth/exceptions/merchant-ip-mismatch.exception.js.map +1 -0
  9. package/src/gg-auth/exceptions/user-blocked.exception.d.ts +9 -0
  10. package/src/gg-auth/exceptions/user-blocked.exception.js +17 -0
  11. package/src/gg-auth/exceptions/user-blocked.exception.js.map +1 -0
  12. package/src/gg-auth/exceptions/user-inactive.exception.d.ts +9 -0
  13. package/src/gg-auth/exceptions/user-inactive.exception.js +17 -0
  14. package/src/gg-auth/exceptions/user-inactive.exception.js.map +1 -0
  15. package/src/gg-auth/exceptions/user-otp-blocked.exception.d.ts +9 -0
  16. package/src/gg-auth/exceptions/user-otp-blocked.exception.js +17 -0
  17. package/src/gg-auth/exceptions/user-otp-blocked.exception.js.map +1 -0
  18. package/src/gg-auth/exceptions/user-password-blocked.exception.d.ts +9 -0
  19. package/src/gg-auth/exceptions/user-password-blocked.exception.js +17 -0
  20. package/src/gg-auth/exceptions/user-password-blocked.exception.js.map +1 -0
  21. package/src/gg-auth/exceptions/user-password-recovery-blocked.exception.d.ts +9 -0
  22. package/src/gg-auth/exceptions/user-password-recovery-blocked.exception.js +17 -0
  23. package/src/gg-auth/exceptions/user-password-recovery-blocked.exception.js.map +1 -0
  24. package/src/gg-auth/gg-auth.module-options.d.ts +41 -0
  25. package/src/gg-auth/gg-auth.module-options.js +16 -0
  26. package/src/gg-auth/gg-auth.module-options.js.map +1 -0
  27. package/src/gg-auth/gg-auth.module.d.ts +5 -0
  28. package/src/gg-auth/gg-auth.module.js +68 -0
  29. package/src/gg-auth/gg-auth.module.js.map +1 -0
  30. package/src/gg-auth/guards/auth.guard.d.ts +69 -0
  31. package/src/gg-auth/guards/auth.guard.js +175 -0
  32. package/src/gg-auth/guards/auth.guard.js.map +1 -0
  33. package/src/gg-auth/index.d.ts +8 -0
  34. package/src/gg-auth/index.js +13 -0
  35. package/src/gg-auth/index.js.map +1 -0
  36. package/src/gg-auth/injectable-proxy/authorized-merchant.d.ts +10 -0
  37. package/src/gg-auth/injectable-proxy/authorized-merchant.js +28 -0
  38. package/src/gg-auth/injectable-proxy/authorized-merchant.js.map +1 -0
  39. package/src/gg-auth/injectable-proxy/authorized-user.d.ts +24 -0
  40. package/src/gg-auth/injectable-proxy/authorized-user.js +56 -0
  41. package/src/gg-auth/injectable-proxy/authorized-user.js.map +1 -0
  42. package/src/gg-auth/interfaces/authorized.interface.d.ts +5 -0
  43. package/src/gg-auth/interfaces/authorized.interface.js +3 -0
  44. package/src/gg-auth/interfaces/authorized.interface.js.map +1 -0
  45. package/src/gg-auth/services/auth-service.interface.d.ts +4 -0
  46. package/src/gg-auth/services/auth-service.interface.js +3 -0
  47. package/src/gg-auth/services/auth-service.interface.js.map +1 -0
  48. package/src/gg-auth/services/gg-bearer-auth.service.d.ts +39 -0
  49. package/src/gg-auth/services/gg-bearer-auth.service.js +84 -0
  50. package/src/gg-auth/services/gg-bearer-auth.service.js.map +1 -0
  51. package/src/gg-auth/services/gg-merchant-auth.service.d.ts +8 -0
  52. package/src/gg-auth/services/gg-merchant-auth.service.js +24 -0
  53. package/src/gg-auth/services/gg-merchant-auth.service.js.map +1 -0
  54. package/src/gg-auth/utils/get-rpc-user.util.d.ts +3 -0
  55. package/src/gg-auth/utils/get-rpc-user.util.js +14 -0
  56. package/src/gg-auth/utils/get-rpc-user.util.js.map +1 -0
  57. package/src/gg-cache/gg-cache.module.d.ts +4 -0
  58. package/src/gg-cache/gg-cache.module.js +55 -0
  59. package/src/gg-cache/gg-cache.module.js.map +1 -0
  60. package/src/gg-cache/gg-cache.service.d.ts +23 -0
  61. package/src/gg-cache/gg-cache.service.js +58 -0
  62. package/src/gg-cache/gg-cache.service.js.map +1 -0
  63. package/src/gg-cache/index.d.ts +2 -0
  64. package/src/gg-cache/index.js +6 -0
  65. package/src/gg-cache/index.js.map +1 -0
  66. package/src/gg-cache/redis.config.d.ts +6 -0
  67. package/src/gg-cache/redis.config.js +23 -0
  68. package/src/gg-cache/redis.config.js.map +1 -0
  69. package/src/gg-cls/gg-cls.module.d.ts +4 -0
  70. package/src/gg-cls/gg-cls.module.js +54 -0
  71. package/src/gg-cls/gg-cls.module.js.map +1 -0
  72. package/src/gg-cls/index.d.ts +1 -0
  73. package/src/gg-cls/index.js +5 -0
  74. package/src/gg-cls/index.js.map +1 -0
  75. package/src/gg-config/app.config.d.ts +16 -0
  76. package/src/gg-config/app.config.js +78 -0
  77. package/src/gg-config/app.config.js.map +1 -0
  78. package/src/gg-config/gg-config.module-options.d.ts +4 -0
  79. package/src/gg-config/gg-config.module-options.js +3 -0
  80. package/src/gg-config/gg-config.module-options.js.map +1 -0
  81. package/src/gg-config/gg-config.module.d.ts +5 -0
  82. package/src/gg-config/gg-config.module.js +22 -0
  83. package/src/gg-config/gg-config.module.js.map +1 -0
  84. package/src/gg-config/index.d.ts +3 -0
  85. package/src/gg-config/index.js +7 -0
  86. package/src/gg-config/index.js.map +1 -0
  87. package/src/gg-config/validate-config.d.ts +2 -0
  88. package/src/gg-config/validate-config.js +31 -0
  89. package/src/gg-config/validate-config.js.map +1 -0
  90. package/src/gg-core/gg-core-module-options.d.ts +12 -0
  91. package/src/gg-core/gg-core-module-options.js +3 -0
  92. package/src/gg-core/gg-core-module-options.js.map +1 -0
  93. package/src/gg-core/gg-core.middleware.d.ts +8 -0
  94. package/src/gg-core/gg-core.middleware.js +31 -0
  95. package/src/gg-core/gg-core.middleware.js.map +1 -0
  96. package/src/gg-core/gg-core.module.d.ts +9 -0
  97. package/src/gg-core/gg-core.module.js +58 -0
  98. package/src/gg-core/gg-core.module.js.map +1 -0
  99. package/src/gg-core/index.d.ts +2 -0
  100. package/src/gg-core/index.js +6 -0
  101. package/src/gg-core/index.js.map +1 -0
  102. package/src/gg-database/config/db-entities.config.d.ts +5 -0
  103. package/src/gg-database/config/db-entities.config.js +7 -0
  104. package/src/gg-database/config/db-entities.config.js.map +1 -0
  105. package/src/gg-database/config/mikroorm.config.d.ts +9 -0
  106. package/src/gg-database/config/mikroorm.config.js +38 -0
  107. package/src/gg-database/config/mikroorm.config.js.map +1 -0
  108. package/src/gg-database/database.adapter.d.ts +24 -0
  109. package/src/gg-database/database.adapter.js +50 -0
  110. package/src/gg-database/database.adapter.js.map +1 -0
  111. package/src/gg-database/database.connector.d.ts +27 -0
  112. package/src/gg-database/database.connector.js +54 -0
  113. package/src/gg-database/database.connector.js.map +1 -0
  114. package/src/gg-database/index.d.ts +3 -0
  115. package/src/gg-database/index.js +7 -0
  116. package/src/gg-database/index.js.map +1 -0
  117. package/src/gg-database/modules/mikroorm.module.d.ts +37 -0
  118. package/src/gg-database/modules/mikroorm.module.js +111 -0
  119. package/src/gg-database/modules/mikroorm.module.js.map +1 -0
  120. package/src/gg-errors/exception.domain-codes.d.ts +12 -0
  121. package/src/gg-errors/exception.domain-codes.js +17 -0
  122. package/src/gg-errors/exception.domain-codes.js.map +1 -0
  123. package/src/gg-errors/exceptions/gg.exception.d.ts +12 -0
  124. package/src/gg-errors/exceptions/gg.exception.js +27 -0
  125. package/src/gg-errors/exceptions/gg.exception.js.map +1 -0
  126. package/src/gg-errors/gcp-error-event.interface.d.ts +18 -0
  127. package/src/gg-errors/gcp-error-event.interface.js +3 -0
  128. package/src/gg-errors/gcp-error-event.interface.js.map +1 -0
  129. package/src/gg-errors/gcp-error-reporting.service.d.ts +11 -0
  130. package/src/gg-errors/gcp-error-reporting.service.js +71 -0
  131. package/src/gg-errors/gcp-error-reporting.service.js.map +1 -0
  132. package/src/gg-errors/gg-errors-exception.filter.d.ts +9 -0
  133. package/src/gg-errors/gg-errors-exception.filter.js +26 -0
  134. package/src/gg-errors/gg-errors-exception.filter.js.map +1 -0
  135. package/src/gg-errors/gg-errors.module-options.d.ts +8 -0
  136. package/src/gg-errors/gg-errors.module-options.js +5 -0
  137. package/src/gg-errors/gg-errors.module-options.js.map +1 -0
  138. package/src/gg-errors/gg-errors.module.d.ts +5 -0
  139. package/src/gg-errors/gg-errors.module.js +35 -0
  140. package/src/gg-errors/gg-errors.module.js.map +1 -0
  141. package/src/gg-errors/gg-exception.service.d.ts +50 -0
  142. package/src/gg-errors/gg-exception.service.js +213 -0
  143. package/src/gg-errors/gg-exception.service.js.map +1 -0
  144. package/src/gg-errors/index.d.ts +1 -0
  145. package/src/gg-errors/index.js +5 -0
  146. package/src/gg-errors/index.js.map +1 -0
  147. package/src/gg-gcp/gcp-trace-and-profiler.d.ts +1 -0
  148. package/src/gg-gcp/gcp-trace-and-profiler.js +52 -0
  149. package/src/gg-gcp/gcp-trace-and-profiler.js.map +1 -0
  150. package/src/gg-gcp/index.d.ts +1 -0
  151. package/src/gg-gcp/index.js +5 -0
  152. package/src/gg-gcp/index.js.map +1 -0
  153. package/src/gg-healthchecks/gg-healthchecks.controller.d.ts +7 -0
  154. package/src/gg-healthchecks/gg-healthchecks.controller.js +31 -0
  155. package/src/gg-healthchecks/gg-healthchecks.controller.js.map +1 -0
  156. package/src/gg-healthchecks/gg-healthchecks.module.d.ts +4 -0
  157. package/src/gg-healthchecks/gg-healthchecks.module.js +17 -0
  158. package/src/gg-healthchecks/gg-healthchecks.module.js.map +1 -0
  159. package/src/gg-kernel/index.d.ts +2 -0
  160. package/src/gg-kernel/index.js +6 -0
  161. package/src/gg-kernel/index.js.map +1 -0
  162. package/src/gg-kernel/kernel.d.ts +36 -0
  163. package/src/gg-kernel/kernel.js +86 -0
  164. package/src/gg-kernel/kernel.js.map +1 -0
  165. package/src/gg-kernel/service-providers/base-service-provider.d.ts +15 -0
  166. package/src/gg-kernel/service-providers/base-service-provider.js +25 -0
  167. package/src/gg-kernel/service-providers/base-service-provider.js.map +1 -0
  168. package/src/gg-kernel/service-providers/global-prefix.service-provider.d.ts +4 -0
  169. package/src/gg-kernel/service-providers/global-prefix.service-provider.js +17 -0
  170. package/src/gg-kernel/service-providers/global-prefix.service-provider.js.map +1 -0
  171. package/src/gg-kernel/service-providers/helmet.service-provider.d.ts +4 -0
  172. package/src/gg-kernel/service-providers/helmet.service-provider.js +12 -0
  173. package/src/gg-kernel/service-providers/helmet.service-provider.js.map +1 -0
  174. package/src/gg-kernel/service-providers/index.d.ts +8 -0
  175. package/src/gg-kernel/service-providers/index.js +12 -0
  176. package/src/gg-kernel/service-providers/index.js.map +1 -0
  177. package/src/gg-kernel/service-providers/logger.service-provider.d.ts +8 -0
  178. package/src/gg-kernel/service-providers/logger.service-provider.js +20 -0
  179. package/src/gg-kernel/service-providers/logger.service-provider.js.map +1 -0
  180. package/src/gg-kernel/service-providers/shutdown-hooks.service-provider.d.ts +7 -0
  181. package/src/gg-kernel/service-providers/shutdown-hooks.service-provider.js +14 -0
  182. package/src/gg-kernel/service-providers/shutdown-hooks.service-provider.js.map +1 -0
  183. package/src/gg-kernel/service-providers/swagger.service-provider.d.ts +13 -0
  184. package/src/gg-kernel/service-providers/swagger.service-provider.js +35 -0
  185. package/src/gg-kernel/service-providers/swagger.service-provider.js.map +1 -0
  186. package/src/gg-kernel/service-providers/validation.service-provider.d.ts +10 -0
  187. package/src/gg-kernel/service-providers/validation.service-provider.js +22 -0
  188. package/src/gg-kernel/service-providers/validation.service-provider.js.map +1 -0
  189. package/src/gg-kernel/service-providers/versioning.service-provider.d.ts +10 -0
  190. package/src/gg-kernel/service-providers/versioning.service-provider.js +17 -0
  191. package/src/gg-kernel/service-providers/versioning.service-provider.js.map +1 -0
  192. package/src/gg-logger/gg-logger.module.d.ts +4 -0
  193. package/src/gg-logger/gg-logger.module.js +48 -0
  194. package/src/gg-logger/gg-logger.module.js.map +1 -0
  195. package/src/gg-metrics/gg-metrics.controller.d.ts +3 -0
  196. package/src/gg-metrics/gg-metrics.controller.js +15 -0
  197. package/src/gg-metrics/gg-metrics.controller.js.map +1 -0
  198. package/src/gg-metrics/gg-metrics.module.d.ts +4 -0
  199. package/src/gg-metrics/gg-metrics.module.js +31 -0
  200. package/src/gg-metrics/gg-metrics.module.js.map +1 -0
  201. package/src/gg-metrics/index.d.ts +1 -0
  202. package/src/gg-metrics/index.js +5 -0
  203. package/src/gg-metrics/index.js.map +1 -0
  204. package/src/gg-micro/gg-micro.module.d.ts +5 -0
  205. package/src/gg-micro/gg-micro.module.js +62 -0
  206. package/src/gg-micro/gg-micro.module.js.map +1 -0
  207. package/src/gg-micro/gg-rmq-service.injector.d.ts +19 -0
  208. package/src/gg-micro/gg-rmq-service.injector.js +29 -0
  209. package/src/gg-micro/gg-rmq-service.injector.js.map +1 -0
  210. package/src/gg-micro/gg-rmq.configurator.d.ts +16 -0
  211. package/src/gg-micro/gg-rmq.configurator.js +34 -0
  212. package/src/gg-micro/gg-rmq.configurator.js.map +1 -0
  213. package/src/gg-micro/index.d.ts +4 -0
  214. package/src/gg-micro/index.js +8 -0
  215. package/src/gg-micro/index.js.map +1 -0
  216. package/src/gg-micro/micro.client.d.ts +62 -0
  217. package/src/gg-micro/micro.client.js +101 -0
  218. package/src/gg-micro/micro.client.js.map +1 -0
  219. package/src/gg-micro/rmq.config.d.ts +10 -0
  220. package/src/gg-micro/rmq.config.js +50 -0
  221. package/src/gg-micro/rmq.config.js.map +1 -0
  222. package/src/gg-micro/rmq.connector.d.ts +12 -0
  223. package/src/gg-micro/rmq.connector.js +25 -0
  224. package/src/gg-micro/rmq.connector.js.map +1 -0
  225. package/src/gg-micro/rmq.queue-map.d.ts +2 -0
  226. package/src/gg-micro/rmq.queue-map.js +24 -0
  227. package/src/gg-micro/rmq.queue-map.js.map +1 -0
  228. package/src/gg-throttler/gg-throttler.module-options.d.ts +4 -0
  229. package/src/gg-throttler/gg-throttler.module-options.js +3 -0
  230. package/src/gg-throttler/gg-throttler.module-options.js.map +1 -0
  231. package/src/gg-throttler/gg-throttler.module.d.ts +5 -0
  232. package/src/gg-throttler/gg-throttler.module.js +24 -0
  233. package/src/gg-throttler/gg-throttler.module.js.map +1 -0
  234. package/src/gg-throttler/throttler.guard.d.ts +13 -0
  235. package/src/gg-throttler/throttler.guard.js +28 -0
  236. package/src/gg-throttler/throttler.guard.js.map +1 -0
  237. package/src/index.d.ts +10 -0
  238. package/src/index.js +14 -0
  239. package/src/index.js.map +1 -0
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthGuard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const dto_1 = require("@zorionapp/gg-toolkit/dto");
6
+ const enum_1 = require("@zorionapp/gg-toolkit/enum");
7
+ const common_1 = require("@nestjs/common");
8
+ const core_1 = require("@nestjs/core");
9
+ const lodash_1 = require("lodash");
10
+ const nestjs_cls_1 = require("nestjs-cls");
11
+ const nestjs_pino_1 = require("nestjs-pino");
12
+ const merchant_ip_mismatch_exception_1 = require("../exceptions/merchant-ip-mismatch.exception");
13
+ const user_blocked_exception_1 = require("../exceptions/user-blocked.exception");
14
+ const user_inactive_exception_1 = require("../exceptions/user-inactive.exception");
15
+ const user_otp_blocked_exception_1 = require("../exceptions/user-otp-blocked.exception");
16
+ const user_password_blocked_exception_1 = require("../exceptions/user-password-blocked.exception");
17
+ const user_password_recovery_blocked_exception_1 = require("../exceptions/user-password-recovery-blocked.exception");
18
+ const gg_auth_module_options_1 = require("../gg-auth.module-options");
19
+ const authorized_merchant_1 = require("../injectable-proxy/authorized-merchant");
20
+ const authorized_user_1 = require("../injectable-proxy/authorized-user");
21
+ const get_rpc_user_util_1 = require("../utils/get-rpc-user.util");
22
+ let AuthGuard = class AuthGuard {
23
+ constructor(ggAuthMerchantService, ggAuthBearerService, reflector, user, merchant, logger, cls) {
24
+ this.ggAuthMerchantService = ggAuthMerchantService;
25
+ this.ggAuthBearerService = ggAuthBearerService;
26
+ this.reflector = reflector;
27
+ this.user = user;
28
+ this.merchant = merchant;
29
+ this.logger = logger;
30
+ this.cls = cls;
31
+ this.userStatusExceptionMap = {
32
+ [enum_1.User.Status.Blocked]: user_blocked_exception_1.UserBlockedException,
33
+ [enum_1.User.Status.InActive]: user_inactive_exception_1.UserInactiveException,
34
+ [enum_1.User.Status.IncorrectOtpBlocked]: user_otp_blocked_exception_1.UserOtpBlockedException,
35
+ [enum_1.User.Status.IncorrectPasswordBlocked]: user_password_blocked_exception_1.UserPasswordBlockedException,
36
+ [enum_1.User.Status.PasswordRecoveryBlocked]: user_password_recovery_blocked_exception_1.UserPasswordRecoveryBlockedException,
37
+ };
38
+ }
39
+ /**
40
+ * Check if user is authorized to access endpoint
41
+ *
42
+ * @param context
43
+ */
44
+ async canActivate(context) {
45
+ if (context.getType() === 'http')
46
+ return this.handleHttp(context);
47
+ if (context.getType() === 'rpc')
48
+ return this.handleRpc(context);
49
+ }
50
+ /**
51
+ * Check user status and throw exception if user is blocked
52
+ */
53
+ checkUserStatus(allowedUserStatuses = []) {
54
+ const whitelistedStatuses = [enum_1.User.Status.Active, ...allowedUserStatuses];
55
+ if (whitelistedStatuses.includes(this.user.dto.status))
56
+ return true;
57
+ if (this.userStatusExceptionMap[this.user.dto.status]) {
58
+ throw new this.userStatusExceptionMap[this.user.dto.status]();
59
+ }
60
+ }
61
+ /**
62
+ * Check merchant allowed IPs and throw exception if it's not allowed
63
+ */
64
+ checkMerchantIP() {
65
+ const allowedIps = this.merchant?.dto?.allowedIps;
66
+ if (!allowedIps || allowedIps.length === 0 || allowedIps[0] === '')
67
+ return;
68
+ if (!allowedIps.includes(this.user.ip)) {
69
+ throw new merchant_ip_mismatch_exception_1.MerchantIpMismatchException({ merchantId: this.merchant.dto.id });
70
+ }
71
+ }
72
+ async handleRpc(context) {
73
+ this.user.dto = (0, get_rpc_user_util_1.getRpcUser)(context.switchToRpc().getContext());
74
+ return true;
75
+ }
76
+ async handleHttp(context) {
77
+ const contextTargets = [context.getHandler(), context.getClass()];
78
+ const roles = this.getRoles(contextTargets);
79
+ const authType = this.getAuthType(contextTargets);
80
+ const allowedUserStatuses = this.getAllowedUserStatuses(contextTargets);
81
+ await this.authAttempt(authType);
82
+ if (this.shouldSkipAuth(contextTargets))
83
+ return true;
84
+ if (this.isAuthenticated())
85
+ this.checkUserStatus(allowedUserStatuses);
86
+ if (this.merchant.isAuthenticated)
87
+ this.checkMerchantIP();
88
+ if (!roles.length)
89
+ return this.isAuthenticated();
90
+ return this.isAuthenticated() && this.user.hasRole(roles);
91
+ }
92
+ /**
93
+ * Try to authorize user by auth type
94
+ *
95
+ * @param authType
96
+ * @protected
97
+ */
98
+ async authAttempt(authType) {
99
+ const authServiceMap = {
100
+ [gg_auth_module_options_1.AuthType.Bearer]: this.ggAuthBearerService,
101
+ [gg_auth_module_options_1.AuthType.Merchant]: this.ggAuthMerchantService,
102
+ };
103
+ const serviceList = authType.map((t) => authServiceMap[t].authorize());
104
+ const responses = await Promise.allSettled(serviceList);
105
+ const fulfilled = responses.filter((r) => r.status !== 'rejected');
106
+ if (fulfilled.length === 0) {
107
+ this.merchant.dto = new dto_1.MerchantDto();
108
+ this.user.dto = new dto_1.UserDto();
109
+ this.user.setIp(this.cls.get(nestjs_cls_1.CLS_REQ));
110
+ return;
111
+ }
112
+ // get filled user if received multiple fulfills
113
+ const filteredUser = fulfilled.filter((f) => (0, lodash_1.get)(f, 'value.user')?.id !== null);
114
+ const filteredMerchant = fulfilled.filter((f) => (0, lodash_1.get)(f, 'value.merchant')?.id !== null);
115
+ this.merchant.dto = (0, lodash_1.get)(filteredMerchant[0], 'value.merchant', new dto_1.MerchantDto());
116
+ this.user.dto = (0, lodash_1.get)(filteredUser[0], 'value.user', new dto_1.UserDto());
117
+ this.user.setIp(this.cls.get(nestjs_cls_1.CLS_REQ));
118
+ }
119
+ /**
120
+ * Depends on auth type will be used different user query services
121
+ */
122
+ getAuthType(contextTargets) {
123
+ const types = this.reflector.getAllAndMerge(gg_auth_module_options_1.GG_AUTH_AUTH_TYPE_TOKEN, contextTargets);
124
+ return types.length > 0 ? types : [gg_auth_module_options_1.AuthType.Bearer];
125
+ }
126
+ /**
127
+ * Return active roles for currently queried user
128
+ */
129
+ getRoles(contextTargets) {
130
+ return this.reflector.getAllAndMerge(gg_auth_module_options_1.GG_AUTH_ROLES_TOKEN, contextTargets) ?? [];
131
+ }
132
+ /**
133
+ * Return allowed user statuses for currently queried user
134
+ */
135
+ getAllowedUserStatuses(contextTargets) {
136
+ return this.reflector.getAllAndMerge(gg_auth_module_options_1.GG_AUTH_ALLOWED_USER_STATUS_TOKEN, contextTargets) ?? [];
137
+ }
138
+ /**
139
+ * Skip authentication if controller hasn't @Protected decorator
140
+ */
141
+ shouldSkipAuth(contextTargets) {
142
+ const isEndpointProtected = this.reflector.getAllAndMerge(gg_auth_module_options_1.GG_AUTH_PROTECTED_TOKEN, contextTargets) ?? false;
143
+ if (!isEndpointProtected || Array.isArray(isEndpointProtected))
144
+ return true;
145
+ }
146
+ /**
147
+ * Check UserDTO for having required fields after auth queries
148
+ */
149
+ isAuthenticated() {
150
+ if (!this.user.isAuthenticated)
151
+ throw new common_1.UnauthorizedException();
152
+ this.setLoggerContext();
153
+ return this.user.isAuthenticated;
154
+ }
155
+ /**
156
+ * Set context in logger to track all user's requests
157
+ */
158
+ setLoggerContext() {
159
+ const user = (0, lodash_1.pick)(this.user.dto, ['id', 'ggId', 'uuid', 'roles']);
160
+ const merchant = (0, lodash_1.pick)(this.merchant.dto, ['id']);
161
+ this.logger.assign({ user, merchant });
162
+ }
163
+ };
164
+ exports.AuthGuard = AuthGuard;
165
+ exports.AuthGuard = AuthGuard = tslib_1.__decorate([
166
+ (0, common_1.Injectable)(),
167
+ tslib_1.__param(0, (0, common_1.Inject)(gg_auth_module_options_1.GG_AUTH_AUTH_TYPE_MERCHANT_TOKEN)),
168
+ tslib_1.__param(1, (0, common_1.Inject)(gg_auth_module_options_1.GG_AUTH_AUTH_TYPE_BEARER_TOKEN)),
169
+ tslib_1.__metadata("design:paramtypes", [Object, Object, core_1.Reflector,
170
+ authorized_user_1.AuthorizedUser,
171
+ authorized_merchant_1.AuthorizedMerchant,
172
+ nestjs_pino_1.PinoLogger,
173
+ nestjs_cls_1.ClsService])
174
+ ], AuthGuard);
175
+ //# sourceMappingURL=auth.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/guards/auth.guard.ts"],"names":[],"mappings":";;;;AAAA,mDAAiE;AACjE,qDAAkD;AAClD,2CAA0G;AAC1G,uCAAyC;AACzC,mCAAmC;AACnC,2CAAiD;AACjD,6CAAyC;AACzC,iGAA2F;AAC3F,iFAA4E;AAC5E,mFAA8E;AAC9E,yFAAmF;AACnF,mGAA6F;AAC7F,qHAA8G;AAC9G,sEAQmC;AACnC,iFAA6E;AAC7E,yEAAqE;AAErE,kEAAwD;AAKjD,IAAM,SAAS,GAAf,MAAM,SAAS;IASpB,YAC4C,qBAAmD,EACrD,mBAAiD,EACxE,SAAoB,EACpB,IAAoB,EACpB,QAA4B,EAC5B,MAAkB,EAClB,GAAe;QAN2B,0BAAqB,GAArB,qBAAqB,CAAa;QACpC,wBAAmB,GAAnB,mBAAmB,CAAa;QACxE,cAAS,GAAT,SAAS,CAAW;QACpB,SAAI,GAAJ,IAAI,CAAgB;QACpB,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,WAAM,GAAN,MAAM,CAAY;QAClB,QAAG,GAAH,GAAG,CAAY;QAf1B,2BAAsB,GAAG;YAC/B,CAAC,WAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,6CAAoB;YAC3C,CAAC,WAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,+CAAqB;YAC7C,CAAC,WAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,oDAAu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C,IAAI,CAAC,eAAe,CAAC;IACnC,CAAC;IAED;;OAEG;IACO,gBAAgB;QACxB,MAAM,IAAI,GAAG,IAAA,aAAI,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAA,aAAI,EAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAEjD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AArKY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;IAWR,mBAAA,IAAA,eAAM,EAAC,yDAAgC,CAAC,CAAA;IACxC,mBAAA,IAAA,eAAM,EAAC,uDAA8B,CAAC,CAAA;6DACX,gBAAS;QACd,gCAAc;QACV,wCAAkB;QACpB,wBAAU;QACb,uBAAU;GAhBvB,SAAS,CAqKrB"}
@@ -0,0 +1,8 @@
1
+ export * from './decorators/protected.decorator';
2
+ export { AuthType } from './gg-auth.module-options';
3
+ export * from './injectable-proxy/authorized-merchant';
4
+ export * from './injectable-proxy/authorized-user';
5
+ export * from './interfaces/authorized.interface';
6
+ export { AuthService } from './services/auth-service.interface';
7
+ export * from './services/gg-bearer-auth.service';
8
+ export * from './utils/get-rpc-user.util';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./decorators/protected.decorator"), exports);
6
+ var gg_auth_module_options_1 = require("./gg-auth.module-options");
7
+ Object.defineProperty(exports, "AuthType", { enumerable: true, get: function () { return gg_auth_module_options_1.AuthType; } });
8
+ tslib_1.__exportStar(require("./injectable-proxy/authorized-merchant"), exports);
9
+ tslib_1.__exportStar(require("./injectable-proxy/authorized-user"), exports);
10
+ tslib_1.__exportStar(require("./interfaces/authorized.interface"), exports);
11
+ tslib_1.__exportStar(require("./services/gg-bearer-auth.service"), exports);
12
+ tslib_1.__exportStar(require("./utils/get-rpc-user.util"), exports);
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-auth/index.ts"],"names":[],"mappings":";;;;AAAA,2EAAiD;AACjD,mEAAoD;AAA3C,kHAAA,QAAQ,OAAA;AACjB,iFAAuD;AACvD,6EAAmD;AACnD,4EAAkD;AAElD,4EAAkD;AAClD,oEAA0C"}
@@ -0,0 +1,10 @@
1
+ import { MerchantDto, WalletDto } from '@zorionapp/gg-toolkit/dto';
2
+ /**
3
+ * Injectable Merchant Wallet instance with auto-bootstrapping by gg-auth-service
4
+ */
5
+ export declare class AuthorizedMerchant {
6
+ dto: MerchantDto;
7
+ get merchant(): MerchantDto;
8
+ get wallet(): WalletDto;
9
+ get isAuthenticated(): boolean;
10
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizedMerchant = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const dto_1 = require("@zorionapp/gg-toolkit/dto");
6
+ const nestjs_cls_1 = require("nestjs-cls");
7
+ /**
8
+ * Injectable Merchant Wallet instance with auto-bootstrapping by gg-auth-service
9
+ */
10
+ let AuthorizedMerchant = class AuthorizedMerchant {
11
+ constructor() {
12
+ this.dto = new dto_1.MerchantDto();
13
+ }
14
+ get merchant() {
15
+ return this.dto ?? null;
16
+ }
17
+ get wallet() {
18
+ return this.dto?.wallet ?? null;
19
+ }
20
+ get isAuthenticated() {
21
+ return this.dto.id !== null;
22
+ }
23
+ };
24
+ exports.AuthorizedMerchant = AuthorizedMerchant;
25
+ exports.AuthorizedMerchant = AuthorizedMerchant = tslib_1.__decorate([
26
+ (0, nestjs_cls_1.InjectableProxy)()
27
+ ], AuthorizedMerchant);
28
+ //# sourceMappingURL=authorized-merchant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-merchant.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/injectable-proxy/authorized-merchant.ts"],"names":[],"mappings":";;;;AAAA,mDAAmE;AACnE,2CAA6C;AAE7C;;GAEG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAAxB;QACE,QAAG,GAAgB,IAAI,iBAAW,EAAE,CAAC;IAa9C,CAAC;IAXC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC;IAClC,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC;IAC9B,CAAC;CACF,CAAA;AAdY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,4BAAe,GAAE;GACL,kBAAkB,CAc9B"}
@@ -0,0 +1,24 @@
1
+ import { UserDto } from '@zorionapp/gg-toolkit/dto';
2
+ import { User } from '@zorionapp/gg-toolkit/enum';
3
+ import { Request } from 'express';
4
+ /**
5
+ * Injectable User instance with auto-bootstrapping by gg-auth-service
6
+ * todo: probably can be changed to something like AppCtx
7
+ *
8
+ * @example
9
+ * class SomeService {
10
+ * public constructor(private user: AuthorizedUser) {
11
+ * this.user.isAuthenticated() // true/false
12
+ * }
13
+ * }
14
+ */
15
+ export declare class AuthorizedUser {
16
+ dto: UserDto;
17
+ ip: string;
18
+ get isAuthenticated(): boolean;
19
+ setIp(req: Request): void;
20
+ hasRole(roles: User.Role[] | User.Role): boolean;
21
+ isOwnerOf(entity: {
22
+ userId: string | number;
23
+ }): boolean;
24
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizedUser = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const dto_1 = require("@zorionapp/gg-toolkit/dto");
6
+ const nestjs_cls_1 = require("nestjs-cls");
7
+ /**
8
+ * Injectable User instance with auto-bootstrapping by gg-auth-service
9
+ * todo: probably can be changed to something like AppCtx
10
+ *
11
+ * @example
12
+ * class SomeService {
13
+ * public constructor(private user: AuthorizedUser) {
14
+ * this.user.isAuthenticated() // true/false
15
+ * }
16
+ * }
17
+ */
18
+ let AuthorizedUser = class AuthorizedUser {
19
+ constructor() {
20
+ this.dto = new dto_1.UserDto();
21
+ }
22
+ get isAuthenticated() {
23
+ return this.dto.id !== null;
24
+ }
25
+ setIp(req) {
26
+ {
27
+ let cfHeader = req.headers['cf-connecting-ip'];
28
+ let xForwardedHeader = req.headers['x-forwarded-for'];
29
+ if (cfHeader !== undefined && Array.isArray(cfHeader)) {
30
+ cfHeader = cfHeader[0];
31
+ }
32
+ if (xForwardedHeader !== undefined && Array.isArray(xForwardedHeader)) {
33
+ xForwardedHeader = xForwardedHeader[0];
34
+ }
35
+ this.ip = cfHeader || xForwardedHeader || req.socket.remoteAddress;
36
+ this.dto.ip = this.ip;
37
+ }
38
+ }
39
+ hasRole(roles) {
40
+ if (!this.dto.roles)
41
+ return false;
42
+ if (Array.isArray(roles))
43
+ return roles.some((role) => this.dto.roles.includes(role));
44
+ return this.dto.roles.includes(roles);
45
+ }
46
+ isOwnerOf(entity) {
47
+ if (!entity.userId)
48
+ return false;
49
+ return this.dto.uuid === entity.userId || this.dto.id === entity.userId;
50
+ }
51
+ };
52
+ exports.AuthorizedUser = AuthorizedUser;
53
+ exports.AuthorizedUser = AuthorizedUser = tslib_1.__decorate([
54
+ (0, nestjs_cls_1.InjectableProxy)()
55
+ ], AuthorizedUser);
56
+ //# sourceMappingURL=authorized-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-user.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/inj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;QAErF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,SAAS,CAAC,MAAmC;QAClD,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAEjC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC;IAC1E,CAAC;CACF,CAAA;AAvCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,4BAAe,GAAE;GACL,cAAc,CAuC1B"}
@@ -0,0 +1,5 @@
1
+ import { MerchantDto, UserDto } from '@zorionapp/gg-toolkit/dto';
2
+ export interface Authorized {
3
+ user?: UserDto;
4
+ merchant?: MerchantDto;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=authorized.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized.interface.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/interfaces/authorized.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { Authorized } from '../interfaces/authorized.interface';
2
+ export interface AuthService {
3
+ authorize(): Promise<Authorized>;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=auth-service.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-service.interface.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/services/auth-service.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node/http" />
3
+ /// <reference types="pino-http" />
4
+ import { UserDto } from '@zorionapp/gg-toolkit/dto';
5
+ import { HttpService } from '@nestjs/axios';
6
+ import { Request } from 'express';
7
+ import { IncomingHttpHeaders } from 'http';
8
+ import { GgCacheService } from '../../gg-cache';
9
+ import { GgAuthOptions } from '../gg-auth.module-options';
10
+ import { Authorized } from '../interfaces/authorized.interface';
11
+ import { AuthService } from './auth-service.interface';
12
+ export declare class GgBearerAuthService implements AuthService {
13
+ private readonly options;
14
+ private readonly request;
15
+ private readonly http;
16
+ private readonly ggCache;
17
+ private readonly baseUrl;
18
+ private readonly logger;
19
+ constructor(options: GgAuthOptions, request: Request, http: HttpService, ggCache: GgCacheService);
20
+ /**
21
+ * @param accessToken
22
+ */
23
+ authorize(accessToken?: string): Promise<Authorized>;
24
+ /**
25
+ * Extract JWT token from given headers
26
+ * Actual only for AuthType.Bearer
27
+ */
28
+ protected getJWTHeader(headers: IncomingHttpHeaders): string | null;
29
+ private getCacheKey;
30
+ /**
31
+ * Caches UserDto in case if error between 400 & 500 codes
32
+ * Skip caching in other cases
33
+ *
34
+ * @param accessToken
35
+ * @param cacheKey
36
+ * @protected
37
+ */
38
+ protected fetchAndCacheUserDto(accessToken: string, cacheKey: string): Promise<UserDto>;
39
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var GgBearerAuthService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GgBearerAuthService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const dto_1 = require("@zorionapp/gg-toolkit/dto");
7
+ const axios_1 = require("@nestjs/axios");
8
+ const common_1 = require("@nestjs/common");
9
+ const class_transformer_1 = require("class-transformer");
10
+ const class_validator_1 = require("class-validator");
11
+ const nestjs_cls_1 = require("nestjs-cls");
12
+ const rxjs_1 = require("rxjs");
13
+ const gg_cache_1 = require("../../gg-cache");
14
+ const gg_auth_module_options_1 = require("../gg-auth.module-options");
15
+ let GgBearerAuthService = GgBearerAuthService_1 = class GgBearerAuthService {
16
+ constructor(options, request, http, ggCache) {
17
+ this.options = options;
18
+ this.request = request;
19
+ this.http = http;
20
+ this.ggCache = ggCache;
21
+ this.logger = new common_1.Logger(GgBearerAuthService_1.name);
22
+ this.baseUrl = `http://${this.options.ggUsersHost}/users/api/v1`;
23
+ }
24
+ /**
25
+ * @param accessToken
26
+ */
27
+ async authorize(accessToken = this.getJWTHeader(this.request.headers)) {
28
+ const cacheKey = this.getCacheKey(accessToken);
29
+ const cachedDto = await this.ggCache.get(cacheKey, false);
30
+ if (cachedDto)
31
+ return { user: cachedDto };
32
+ const user = await this.fetchAndCacheUserDto(accessToken, cacheKey);
33
+ return { user };
34
+ }
35
+ /**
36
+ * Extract JWT token from given headers
37
+ * Actual only for AuthType.Bearer
38
+ */
39
+ getJWTHeader(headers) {
40
+ const jwt = headers['authorization']?.replace('Bearer ', '');
41
+ return (0, class_validator_1.isJWT)(jwt) ? jwt : null;
42
+ }
43
+ getCacheKey(accessToken) {
44
+ return `auth:${accessToken}`;
45
+ }
46
+ /**
47
+ * Caches UserDto in case if error between 400 & 500 codes
48
+ * Skip caching in other cases
49
+ *
50
+ * @param accessToken
51
+ * @param cacheKey
52
+ * @protected
53
+ */
54
+ fetchAndCacheUserDto(accessToken, cacheKey) {
55
+ const onSuccess = async (value) => {
56
+ this.logger.log({ msg: `User queried successfully`, userId: value.data.user.ggId });
57
+ await this.ggCache.set(cacheKey, value.data.user, { namespaced: false });
58
+ };
59
+ const onError = async (error) => {
60
+ if (error.code === 'ECONNREFUSED') {
61
+ this.logger.error(`User service response fail: ${error}. Check your network connection or port mapping`);
62
+ return error;
63
+ }
64
+ if (error.code === 'ERR_BAD_REQUEST') {
65
+ this.logger.warn({ msg: `User authentication declined with given JWT`, error: error.message });
66
+ await this.ggCache.set(cacheKey, new dto_1.UserDto(), { namespaced: false });
67
+ return error;
68
+ }
69
+ this.logger.error({ msg: `Internal server error`, error });
70
+ };
71
+ return (0, rxjs_1.firstValueFrom)(this.http.post(`${this.baseUrl}/jwt/check`, { accessToken }).pipe((0, rxjs_1.tap)({ next: onSuccess, error: onError }), (0, rxjs_1.map)((res) => (0, class_transformer_1.plainToInstance)(dto_1.UserDto, res.data.user))));
72
+ }
73
+ };
74
+ exports.GgBearerAuthService = GgBearerAuthService;
75
+ exports.GgBearerAuthService = GgBearerAuthService = GgBearerAuthService_1 = tslib_1.__decorate([
76
+ (0, common_1.Injectable)()
77
+ // todo: move to RPC call to users service
78
+ ,
79
+ tslib_1.__param(0, (0, common_1.Inject)(gg_auth_module_options_1.GG_AUTH_MODULE_OPTIONS_TOKEN)),
80
+ tslib_1.__param(1, (0, common_1.Inject)(nestjs_cls_1.CLS_REQ)),
81
+ tslib_1.__metadata("design:paramtypes", [Object, Object, axios_1.HttpService,
82
+ gg_cache_1.GgCacheService])
83
+ ], GgBearerAuthService);
84
+ //# sourceMappingURL=gg-bearer-auth.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gg-bearer-auth.service.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/services/gg-bearer-auth.service.ts"],"names":[],"mappings":";;;;;AAAA,mDAAoD;AACpD,yCAA4C;AAC5C,2CAA4D;AAE5D,yDAAoD;AACpD,qDAAwC;AAGxC,2CAAqC;AACrC,+BAAgD;AAChD,6CAAgD;AAChD,sEAAwF;AAMjF,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAI9B,YACwC,OAAuC,EAC5D,OAAiC,EACjC,IAAiB,EACjB,OAAuB;QAHe,YAAO,GAAP,OAAO,CAAe;QAC3C,YAAO,GAAP,OAAO,CAAS;QACjC,SAAI,GAAJ,IAAI,CAAa;QACjB,YAAO,GAAP,OAAO,CAAgB;QANzB,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAQ7D,IAAI,CAAC,OAAO,GAAG,UAAU,IAAI,CAAC,OAAO,CAAC,WAAW,eAAe,CAAC;IACnE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,cAAsB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAClF,MAAM,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2
+ import { AuthService } from './auth-service.interface';
3
+ export declare class GgMerchantAuthService implements AuthService {
4
+ private readonly options;
5
+ private readonly logger;
6
+ constructor(options: GgAuthOptions);
7
+ authorize(): Promise<never>;
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var GgMerchantAuthService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GgMerchantAuthService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const gg_auth_module_options_1 = require("../gg-auth.module-options");
8
+ let GgMerchantAuthService = GgMerchantAuthService_1 = class GgMerchantAuthService {
9
+ constructor(options) {
10
+ this.options = options;
11
+ this.logger = new common_1.Logger(GgMerchantAuthService_1.name);
12
+ }
13
+ async authorize() {
14
+ this.logger.log(`Attempt to auth with "${gg_auth_module_options_1.AuthType.Merchant}" auth`);
15
+ throw new common_1.NotImplementedException(`Merchant auth-service not implemented. Add code here if it needed for other services (except gg-wallets) for default auth`);
16
+ }
17
+ };
18
+ exports.GgMerchantAuthService = GgMerchantAuthService;
19
+ exports.GgMerchantAuthService = GgMerchantAuthService = GgMerchantAuthService_1 = tslib_1.__decorate([
20
+ (0, common_1.Injectable)(),
21
+ tslib_1.__param(0, (0, common_1.Inject)(gg_auth_module_options_1.GG_AUTH_MODULE_OPTIONS_TOKEN)),
22
+ tslib_1.__metadata("design:paramtypes", [Object])
23
+ ], GgMerchantAuthService);
24
+ //# sourceMappingURL=gg-merchant-auth.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gg-merchant-auth.service.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/services/gg-merchant-auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAqF;AACrF,sEAAkG;AAI3F,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAAyD,OAAuC;QAAtB,YAAO,GAAP,OAAO,CAAe;QAF/E,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEkC,CAAC;IAE7F,KAAK,CAAC,SAAS;QACpB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,iCAAQ,CAAC,QAAQ,QAAQ,CAAC,CAAC;QAEpE,MAAM,IAAI,gCAAuB,CAC/B,2HAA2H,CAC5H,CAAC;IACJ,CAAC;CACF,CAAA;AAZY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAIS,mBAAA,IAAA,eAAM,EAAC,qDAA4B,CAAC,CAAA;;GAH7C,qBAAqB,CAYjC"}
@@ -0,0 +1,3 @@
1
+ import { UserDto } from '@zorionapp/gg-toolkit/dto';
2
+ import { RmqContext } from '@nestjs/microservices';
3
+ export declare const getRpcUser: (ctx: RmqContext) => UserDto;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRpcUser = void 0;
4
+ const dto_1 = require("@zorionapp/gg-toolkit/dto");
5
+ const class_transformer_1 = require("class-transformer");
6
+ const lodash_1 = require("lodash");
7
+ const getRpcUser = (ctx) => {
8
+ const userJson = (0, lodash_1.get)(ctx.getArgs(), `[0].properties.headers.user`, '');
9
+ if (!userJson)
10
+ return new dto_1.UserDto();
11
+ return (0, class_transformer_1.plainToInstance)(dto_1.UserDto, JSON.parse(userJson));
12
+ };
13
+ exports.getRpcUser = getRpcUser;
14
+ //# sourceMappingURL=get-rpc-user.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-rpc-user.util.js","sourceRoot":"","sources":["../../../../../../libs/gg-core/src/gg-auth/utils/get-rpc-user.util.ts"],"names":[],"mappings":";;;AAAA,mDAAoD;AAEpD,yDAAoD;AACpD,mCAA6B;AAEtB,MAAM,UAAU,GAAG,CAAC,GAAe,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAG,IAAA,YAAG,EAAC,GAAG,CAAC,OAAO,EAAE,EAAE,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAEvE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,aAAO,EAAE,CAAC;IAEpC,OAAO,IAAA,mCAAe,EAAC,aAAO,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB"}
@@ -0,0 +1,4 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export declare class GgCacheModule {
3
+ static forRoot(): DynamicModule;
4
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var GgCacheModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GgCacheModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const cache_manager_1 = require("@nestjs/cache-manager");
7
+ const common_1 = require("@nestjs/common");
8
+ const exceptions_1 = require("@nestjs/core/errors/exceptions");
9
+ const cache_manager_redis_yet_1 = require("cache-manager-redis-yet");
10
+ const luxon_1 = require("luxon");
11
+ const redis_1 = require("redis");
12
+ const gg_cache_service_1 = require("./gg-cache.service");
13
+ const redis_config_1 = require("./redis.config");
14
+ let GgCacheModule = GgCacheModule_1 = class GgCacheModule {
15
+ static forRoot() {
16
+ return {
17
+ module: GgCacheModule_1,
18
+ global: true,
19
+ providers: [gg_cache_service_1.GgCacheService],
20
+ exports: [gg_cache_service_1.GgCacheService],
21
+ imports: [
22
+ cache_manager_1.CacheModule.registerAsync({
23
+ inject: [redis_config_1.redisConfig.KEY],
24
+ isGlobal: true,
25
+ useFactory: async (redisConf) => {
26
+ const client = (0, redis_1.createClient)({
27
+ socket: { host: redisConf.host, port: redisConf.port },
28
+ });
29
+ client.on('error', (err) => {
30
+ console.error('Redis Client Error', err);
31
+ });
32
+ try {
33
+ await client.connect();
34
+ }
35
+ catch (error) {
36
+ throw new exceptions_1.RuntimeException('Error connecting to Redis');
37
+ }
38
+ return {
39
+ socket: { host: redisConf.host, port: redisConf.port },
40
+ client,
41
+ store: cache_manager_redis_yet_1.redisStore,
42
+ ttl: luxon_1.Duration.fromObject({ minute: 1 }).as('milliseconds'),
43
+ pingInterval: luxon_1.Duration.fromObject({ second: 1 }).as('milliseconds'),
44
+ };
45
+ },
46
+ }),
47
+ ],
48
+ };
49
+ }
50
+ };
51
+ exports.GgCacheModule = GgCacheModule;
52
+ exports.GgCacheModule = GgCacheModule = GgCacheModule_1 = tslib_1.__decorate([
53
+ (0, common_1.Module)({})
54
+ ], GgCacheModule);
55
+ //# sourceMappingURL=gg-cache.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gg-cache.module.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/gg-cache.module.ts"],"names":[],"mappings":";;;;;AAAA,yDAAoD;AACpD,2CAAuD;AAEvD,+DAAkE;AAClE,qEAAqD;AACrD,iCAAiC;AACjC,iCAAyD;AACzD,yDAAoD;AACpD,iDAA6C;AAGtC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACjB,MAAM,CAAC,OAAO;QACnB,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,CAAC,iCAAc,CAAC;YAC3B,OAAO,EAAE,CAAC,iCAAc,CAAC;YACzB,OAAO,EAAE;gBACP,2BAAW,CAAC,aAAa,CAAqB;oBAC5C,MAAM,EAAE,CAAC,0BAAW,CAAC,GAAG,CAAC;oBACzB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,KAAK,EAAE,SAAyC,EAAE,EAAE;wBAC9D,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAC;4BAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE;yBACvD,CAAC,CAAC;wBAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;4BACzB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;wBAC3C,CAAC,CA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