@miguelmorales13/nestkit 0.25.0 → 0.28.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 (281) hide show
  1. package/README.md +5 -0
  2. package/dist/alerts/alert-on-failure.decorator.d.ts +5 -0
  3. package/dist/alerts/alert-sinks.d.ts +29 -0
  4. package/dist/alerts/alerts.module.d.ts +19 -0
  5. package/dist/alerts/alerts.options.d.ts +1 -0
  6. package/dist/alerts/alerts.service.d.ts +28 -0
  7. package/dist/alerts/alerts.types.d.ts +66 -0
  8. package/dist/alerts/index.cjs +276 -0
  9. package/dist/alerts/index.d.ts +10 -0
  10. package/dist/alerts/index.js +276 -0
  11. package/dist/alerts/logger-with-alerts.d.ts +18 -0
  12. package/dist/alerts/process-guards.d.ts +21 -0
  13. package/dist/alerts/runtime.d.ts +4 -0
  14. package/dist/audit/index.cjs +13 -13
  15. package/dist/audit/index.js +2 -2
  16. package/dist/auth/index.cjs +21 -21
  17. package/dist/auth/index.js +3 -3
  18. package/dist/auth/oauth/index.cjs +123 -115
  19. package/dist/auth/oauth/index.js +25 -17
  20. package/dist/auth/oauth/oauth-provider.d.ts +9 -0
  21. package/dist/auth/oauth/providers/apple.d.ts +3 -1
  22. package/dist/bootstrap/apply-defaults.d.ts +9 -0
  23. package/dist/bootstrap/index.cjs +6 -5
  24. package/dist/bootstrap/index.js +5 -4
  25. package/dist/chunk-3TUMVLPJ.js +14 -0
  26. package/dist/{chunk-PA24P76K.js → chunk-45SW7FBE.js} +1 -1
  27. package/dist/{chunk-RF75KC63.cjs → chunk-47IYXZHW.cjs} +2 -2
  28. package/dist/{chunk-TUNDBBQF.js → chunk-4WWOKZIO.js} +4 -4
  29. package/dist/{chunk-A2DGK4ZL.js → chunk-5LVGCTJ3.js} +1 -1
  30. package/dist/chunk-A6YGIZCQ.cjs +14 -0
  31. package/dist/chunk-A7FI6HXV.js +40 -0
  32. package/dist/chunk-CU4FUIVJ.cjs +8 -0
  33. package/dist/{chunk-FH5UNWWW.cjs → chunk-D35TBVRO.cjs} +4 -4
  34. package/dist/{chunk-4MGIQFAJ.js → chunk-D3DDJWUD.js} +5 -0
  35. package/dist/chunk-DVGPEBUL.js +8 -0
  36. package/dist/{chunk-VKOPDDCC.js → chunk-ENZ7LQRE.js} +1 -1
  37. package/dist/{chunk-3AUOOEQO.cjs → chunk-F77X4QUN.cjs} +2 -2
  38. package/dist/chunk-FBNV5X6C.js +61 -0
  39. package/dist/{chunk-APUFKA4K.cjs → chunk-FDZQCLLK.cjs} +6 -6
  40. package/dist/{chunk-DYHSOULW.js → chunk-IGSNB5BX.js} +1 -1
  41. package/dist/chunk-IVWPA6QH.cjs +90 -0
  42. package/dist/{chunk-MSTXS3MU.cjs → chunk-JJKGQNGD.cjs} +2 -2
  43. package/dist/{chunk-FNUZGYUF.cjs → chunk-JRFE7NSO.cjs} +12 -4
  44. package/dist/{chunk-HVHYZXBB.cjs → chunk-KNU5RN3O.cjs} +3 -3
  45. package/dist/{chunk-52IOOHNX.cjs → chunk-KQPJCVN3.cjs} +26 -26
  46. package/dist/chunk-LGFHLAY3.cjs +61 -0
  47. package/dist/{chunk-2REOCMUD.cjs → chunk-LRX7AMSS.cjs} +6 -1
  48. package/dist/{chunk-4PFAKLT3.js → chunk-MUWHGBIB.js} +1 -1
  49. package/dist/{chunk-ZJMLEP5H.js → chunk-NJYLQDB3.js} +1 -1
  50. package/dist/{chunk-IFNYRZP2.js → chunk-OSRH6KYZ.js} +4 -4
  51. package/dist/{chunk-6RAPVLJM.js → chunk-OTE77ONL.js} +1 -1
  52. package/dist/chunk-UDACUMLO.cjs +40 -0
  53. package/dist/{chunk-UNEVXCFW.js → chunk-UGAAJRPO.js} +10 -2
  54. package/dist/{chunk-SPTDXUED.cjs → chunk-URLDTS2Q.cjs} +2 -2
  55. package/dist/{chunk-W2T2VFLC.cjs → chunk-VALDHJOO.cjs} +5 -5
  56. package/dist/chunk-WFCQDOSN.js +90 -0
  57. package/dist/consent/consent.interceptor.d.ts +20 -0
  58. package/dist/consent/consent.module.d.ts +25 -0
  59. package/dist/consent/consent.options.d.ts +30 -0
  60. package/dist/consent/consent.port.d.ts +17 -0
  61. package/dist/consent/consent.service.d.ts +44 -0
  62. package/dist/consent/guard/index.cjs +13 -0
  63. package/dist/consent/guard/index.d.ts +31 -0
  64. package/dist/consent/guard/index.js +13 -0
  65. package/dist/consent/index.cjs +271 -0
  66. package/dist/consent/index.d.ts +13 -0
  67. package/dist/consent/index.js +271 -0
  68. package/dist/consent/memory.store.d.ts +7 -0
  69. package/dist/consent/shared/index.cjs +11 -0
  70. package/dist/consent/shared/index.d.ts +19 -0
  71. package/dist/consent/shared/index.js +11 -0
  72. package/dist/consent/typeorm.store.d.ts +22 -0
  73. package/dist/crud/index.cjs +4 -4
  74. package/dist/crud/index.js +3 -3
  75. package/dist/database/postgres/index.cjs +3 -3
  76. package/dist/database/postgres/index.js +2 -2
  77. package/dist/database/supabase/index.cjs +3 -3
  78. package/dist/database/supabase/index.js +2 -2
  79. package/dist/database/typeorm/index.cjs +2 -2
  80. package/dist/database/typeorm/index.js +1 -1
  81. package/dist/devices/device-check.interceptor.d.ts +20 -0
  82. package/dist/devices/devices.module.d.ts +28 -0
  83. package/dist/devices/devices.options.d.ts +53 -0
  84. package/dist/devices/devices.port.d.ts +62 -0
  85. package/dist/devices/devices.service.d.ts +58 -0
  86. package/dist/devices/index.cjs +327 -0
  87. package/dist/devices/index.d.ts +8 -0
  88. package/dist/devices/index.js +327 -0
  89. package/dist/devices/memory.store.d.ts +12 -0
  90. package/dist/email/index.cjs +2 -2
  91. package/dist/email/index.js +1 -1
  92. package/dist/email/nodemailer/index.cjs +2 -2
  93. package/dist/email/nodemailer/index.js +1 -1
  94. package/dist/email/resend/index.cjs +2 -2
  95. package/dist/email/resend/index.js +1 -1
  96. package/dist/entities/index.cjs +1 -1
  97. package/dist/entities/index.js +1 -1
  98. package/dist/errors/index.cjs +7 -7
  99. package/dist/errors/index.js +7 -7
  100. package/dist/events/buses.d.ts +27 -0
  101. package/dist/events/events.controller.d.ts +15 -0
  102. package/dist/events/events.module.d.ts +29 -0
  103. package/dist/events/events.options.d.ts +50 -0
  104. package/dist/events/events.service.d.ts +49 -0
  105. package/dist/events/events.types.d.ts +77 -0
  106. package/dist/events/index.cjs +557 -0
  107. package/dist/events/index.d.ts +10 -0
  108. package/dist/events/index.js +557 -0
  109. package/dist/events/memory-ticket.store.d.ts +9 -0
  110. package/dist/google-business/google-business-http.d.ts +41 -0
  111. package/dist/google-business/google-business.errors.d.ts +75 -0
  112. package/dist/google-business/google-business.mappers.d.ts +52 -0
  113. package/dist/google-business/google-business.module.d.ts +26 -0
  114. package/dist/google-business/google-business.options.d.ts +40 -0
  115. package/dist/google-business/google-business.ports.d.ts +18 -0
  116. package/dist/google-business/google-business.service.d.ts +120 -0
  117. package/dist/google-business/google-business.types.d.ts +155 -0
  118. package/dist/google-business/index.cjs +1025 -0
  119. package/dist/google-business/index.d.ts +15 -0
  120. package/dist/google-business/index.js +1025 -0
  121. package/dist/google-business/testing/google-simulator.d.ts +61 -0
  122. package/dist/hardening/body-limits.d.ts +24 -0
  123. package/dist/hardening/http.types.d.ts +26 -0
  124. package/dist/hardening/index.cjs +179 -0
  125. package/dist/hardening/index.d.ts +19 -0
  126. package/dist/hardening/index.js +179 -0
  127. package/dist/hardening/memory-rate-limit.store.d.ts +10 -0
  128. package/dist/hardening/origin-secret.d.ts +29 -0
  129. package/dist/hardening/rate-limit.decorator.d.ts +8 -0
  130. package/dist/hardening/rate-limit.guard.d.ts +18 -0
  131. package/dist/hardening/rate-limit.module.d.ts +23 -0
  132. package/dist/hardening/rate-limit.options.d.ts +35 -0
  133. package/dist/hardening/rate-limit.port.d.ts +11 -0
  134. package/dist/hardening/redis-rate-limit.store.d.ts +23 -0
  135. package/dist/hardening/trust-proxy.d.ts +22 -0
  136. package/dist/health/health.controller.d.ts +32 -0
  137. package/dist/health/health.module.d.ts +15 -0
  138. package/dist/health/health.options.d.ts +24 -0
  139. package/dist/health/index.cjs +103 -0
  140. package/dist/health/index.d.ts +5 -0
  141. package/dist/health/index.js +103 -0
  142. package/dist/i18n/index.cjs +3 -3
  143. package/dist/i18n/index.js +2 -2
  144. package/dist/idempotency/idempotency.interceptor.d.ts +1 -0
  145. package/dist/idempotency/idempotency.options.d.ts +15 -0
  146. package/dist/idempotency/index.cjs +214 -7
  147. package/dist/idempotency/index.d.ts +5 -0
  148. package/dist/idempotency/index.js +210 -3
  149. package/dist/idempotency/no-idempotency.decorator.d.ts +8 -0
  150. package/dist/idempotency/postgres.store.d.ts +49 -0
  151. package/dist/idempotency/redis.store.d.ts +59 -0
  152. package/dist/index.cjs +21 -20
  153. package/dist/index.js +31 -30
  154. package/dist/invoicing/index.cjs +2 -2
  155. package/dist/invoicing/index.js +1 -1
  156. package/dist/jobs/defer-job.d.ts +10 -0
  157. package/dist/jobs/index.cjs +318 -0
  158. package/dist/jobs/index.d.ts +8 -0
  159. package/dist/jobs/index.js +318 -0
  160. package/dist/jobs/jobs-admin.controller.d.ts +18 -0
  161. package/dist/jobs/jobs.module.d.ts +33 -0
  162. package/dist/jobs/jobs.options.d.ts +62 -0
  163. package/dist/jobs/jobs.service.d.ts +53 -0
  164. package/dist/jobs/jobs.sql.d.ts +11 -0
  165. package/dist/media/index.cjs +14 -14
  166. package/dist/media/index.js +1 -1
  167. package/dist/meta/index.cjs +3 -3
  168. package/dist/meta/index.js +1 -1
  169. package/dist/notifications/index.cjs +375 -0
  170. package/dist/notifications/index.d.ts +8 -0
  171. package/dist/notifications/index.js +375 -0
  172. package/dist/notifications/memory.stores.d.ts +23 -0
  173. package/dist/notifications/notifications.controller.d.ts +11 -0
  174. package/dist/notifications/notifications.module.d.ts +31 -0
  175. package/dist/notifications/notifications.options.d.ts +33 -0
  176. package/dist/notifications/notifications.port.d.ts +97 -0
  177. package/dist/notifications/notifier.service.d.ts +31 -0
  178. package/dist/payments/index.cjs +7 -7
  179. package/dist/payments/index.js +1 -1
  180. package/dist/pinterest/index.cjs +3 -3
  181. package/dist/pinterest/index.js +1 -1
  182. package/dist/privacy/anonymizer.d.ts +14 -0
  183. package/dist/privacy/index.cjs +768 -0
  184. package/dist/privacy/index.d.ts +13 -0
  185. package/dist/privacy/index.js +768 -0
  186. package/dist/privacy/memory.store.d.ts +15 -0
  187. package/dist/privacy/privacy.module.d.ts +30 -0
  188. package/dist/privacy/privacy.options.d.ts +43 -0
  189. package/dist/privacy/privacy.port.d.ts +25 -0
  190. package/dist/privacy/privacy.service.d.ts +69 -0
  191. package/dist/privacy/privacy.types.d.ts +125 -0
  192. package/dist/privacy/sql.d.ts +7 -0
  193. package/dist/privacy/sql.store.d.ts +21 -0
  194. package/dist/privacy/zip.d.ts +23 -0
  195. package/dist/push/index.cjs +13 -13
  196. package/dist/push/index.js +5 -5
  197. package/dist/resilience/alert-channels.d.ts +39 -0
  198. package/dist/resilience/alert-errors.interceptor.d.ts +10 -0
  199. package/dist/resilience/alert-on-failure.decorator.d.ts +10 -0
  200. package/dist/resilience/alert.service.d.ts +77 -0
  201. package/dist/resilience/index.cjs +863 -0
  202. package/dist/resilience/index.d.ts +18 -0
  203. package/dist/resilience/index.js +863 -0
  204. package/dist/resilience/memory-alert-store.d.ts +26 -0
  205. package/dist/resilience/provider-health.controller.d.ts +14 -0
  206. package/dist/resilience/provider-unavailable.exception.d.ts +11 -0
  207. package/dist/resilience/resilience.module.d.ts +34 -0
  208. package/dist/resilience/resilience.options.d.ts +28 -0
  209. package/dist/resilience/resilience.types.d.ts +167 -0
  210. package/dist/resilience/resilient-fetch.d.ts +38 -0
  211. package/dist/resilience/runtime.d.ts +24 -0
  212. package/dist/resilience/typeorm/alert.entity.d.ts +21 -0
  213. package/dist/resilience/typeorm/index.cjs +102 -0
  214. package/dist/resilience/typeorm/index.d.ts +3 -0
  215. package/dist/resilience/typeorm/index.js +102 -0
  216. package/dist/resilience/typeorm/typeorm-alert-store.d.ts +39 -0
  217. package/dist/resilience/validate-destination.d.ts +63 -0
  218. package/dist/response/index.cjs +3 -3
  219. package/dist/response/index.js +2 -2
  220. package/dist/scheduling/cron-lock.service.d.ts +36 -0
  221. package/dist/scheduling/cron-unico.decorator.d.ts +27 -0
  222. package/dist/scheduling/fallback.store.d.ts +34 -0
  223. package/dist/scheduling/index.cjs +392 -0
  224. package/dist/scheduling/index.d.ts +18 -0
  225. package/dist/scheduling/index.js +392 -0
  226. package/dist/scheduling/lock-store.port.d.ts +19 -0
  227. package/dist/scheduling/memory.store.d.ts +15 -0
  228. package/dist/scheduling/redis.module.d.ts +31 -0
  229. package/dist/scheduling/redis.store.d.ts +24 -0
  230. package/dist/scheduling/scheduling.module.d.ts +24 -0
  231. package/dist/scheduling/scheduling.options.d.ts +27 -0
  232. package/dist/scheduling/sql.store.d.ts +26 -0
  233. package/dist/secrets/index.cjs +274 -0
  234. package/dist/secrets/index.d.ts +8 -0
  235. package/dist/secrets/index.js +274 -0
  236. package/dist/secrets/secrets.errors.d.ts +6 -0
  237. package/dist/secrets/secrets.module.d.ts +21 -0
  238. package/dist/secrets/secrets.options.d.ts +32 -0
  239. package/dist/secrets/secrets.service.d.ts +54 -0
  240. package/dist/secrets/secrets.transformer.d.ts +33 -0
  241. package/dist/security/hash.d.ts +8 -0
  242. package/dist/security/index.cjs +119 -2
  243. package/dist/security/index.d.ts +5 -0
  244. package/dist/security/index.js +119 -2
  245. package/dist/security/mask.d.ts +22 -0
  246. package/dist/security/signed-grant.d.ts +30 -0
  247. package/dist/storage/index.cjs +2 -2
  248. package/dist/storage/index.js +1 -1
  249. package/dist/stripe/index.cjs +7 -7
  250. package/dist/stripe/index.js +1 -1
  251. package/dist/telegram/index.cjs +2 -2
  252. package/dist/telegram/index.js +1 -1
  253. package/dist/tenancy/app-role.d.ts +24 -0
  254. package/dist/tenancy/db-helpers.d.ts +12 -0
  255. package/dist/tenancy/index.cjs +205 -0
  256. package/dist/tenancy/index.d.ts +14 -0
  257. package/dist/tenancy/index.js +205 -0
  258. package/dist/tenancy/pg/index.cjs +34 -0
  259. package/dist/tenancy/pg/index.d.ts +2 -0
  260. package/dist/tenancy/pg/index.js +34 -0
  261. package/dist/tenancy/pg/with-tenant.d.ts +23 -0
  262. package/dist/tenancy/request-context.d.ts +18 -0
  263. package/dist/tenancy/rls-guardrail.d.ts +38 -0
  264. package/dist/tenancy/scope.d.ts +5 -0
  265. package/dist/tenancy/tenancy.errors.d.ts +5 -0
  266. package/dist/tenancy/tenancy.middleware.d.ts +8 -0
  267. package/dist/tenancy/tenancy.module.d.ts +37 -0
  268. package/dist/tenancy/tenancy.options.d.ts +34 -0
  269. package/dist/tenancy/typeorm/index.cjs +41 -0
  270. package/dist/tenancy/typeorm/index.d.ts +2 -0
  271. package/dist/tenancy/typeorm/index.js +41 -0
  272. package/dist/tenancy/typeorm/with-tenant.d.ts +23 -0
  273. package/dist/tiktok/index.cjs +3 -3
  274. package/dist/tiktok/index.js +1 -1
  275. package/dist/tracking/index.cjs +3 -3
  276. package/dist/tracking/index.js +2 -2
  277. package/dist/umami/index.cjs +4 -4
  278. package/dist/umami/index.js +1 -1
  279. package/dist/whatsapp/index.cjs +2 -2
  280. package/dist/whatsapp/index.js +1 -1
  281. package/package.json +107 -2
@@ -0,0 +1,90 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/hardening/http.types.ts
2
+ function pathOf(req) {
3
+ const raw = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(req.path, () => ( req.originalUrl)), () => ( req.url)), () => ( ""));
4
+ const q = raw.indexOf("?");
5
+ return q === -1 ? raw : raw.slice(0, q);
6
+ }
7
+ function headerOf(req, name) {
8
+ const v = _optionalChain([req, 'access', _ => _.headers, 'optionalAccess', _2 => _2[name.toLowerCase()]]);
9
+ return Array.isArray(v) ? v[0] : v;
10
+ }
11
+ function matchesPath(rule, path) {
12
+ if (rule instanceof RegExp) return rule.test(path);
13
+ if (rule.endsWith("*")) return path.startsWith(rule.slice(0, -1));
14
+ return path === rule;
15
+ }
16
+
17
+ // src/hardening/body-limits.ts
18
+ var _module = require('module');
19
+ var _path = require('path');
20
+ var DEFAULT_BODY_LIMIT = "1mb";
21
+ var expressJson = (limit) => {
22
+ const req = _module.createRequire.call(void 0, _path.join.call(void 0, process.cwd(), "noop.js"));
23
+ return req("express").json({ limit });
24
+ };
25
+ function applyBodyLimits(app, options, factory = expressJson) {
26
+ const routes = _nullishCoalesce(options.routes, () => ( []));
27
+ if (routes.length) {
28
+ const parsers = /* @__PURE__ */ new Map();
29
+ const parserFor = (limit) => {
30
+ let p = parsers.get(limit);
31
+ if (!p) parsers.set(limit, p = factory(limit));
32
+ return p;
33
+ };
34
+ app.use((req, res, next) => {
35
+ const path = pathOf(req);
36
+ const rule = routes.find((r) => matchesPath(r.match, path));
37
+ return rule ? parserFor(rule.limit)(req, res, next) : next();
38
+ });
39
+ }
40
+ _optionalChain([app, 'access', _3 => _3.useBodyParser, 'optionalCall', _4 => _4("json", { limit: _nullishCoalesce(options.default, () => ( DEFAULT_BODY_LIMIT)) })]);
41
+ }
42
+
43
+ // src/hardening/origin-secret.ts
44
+ var _crypto = require('crypto');
45
+ var digest = (v) => _crypto.createHash.call(void 0, "sha256").update(v).digest();
46
+ function sameSecret(received, expected) {
47
+ return typeof received === "string" && _crypto.timingSafeEqual.call(void 0, digest(received), expected);
48
+ }
49
+ function originSecretMiddleware(options) {
50
+ const expected = options.value ? digest(options.value) : null;
51
+ const scoped = (_nullishCoalesce(options.scoped, () => ( []))).filter((s) => s.value).map((s) => ({ header: s.header, paths: s.paths, expected: digest(s.value) }));
52
+ const exclude = _nullishCoalesce(options.exclude, () => ( []));
53
+ return (req, res, next) => {
54
+ if (!expected) return next();
55
+ const path = pathOf(req);
56
+ if (exclude.some((r) => matchesPath(r, path))) return next();
57
+ if (sameSecret(headerOf(req, options.header), expected)) return next();
58
+ if (scoped.some(
59
+ (s) => s.paths.some((r) => matchesPath(r, path)) && sameSecret(headerOf(req, s.header), s.expected)
60
+ ))
61
+ return next();
62
+ res.status(_nullishCoalesce(options.status, () => ( 403))).json({
63
+ success: false,
64
+ error: { code: _nullishCoalesce(options.code, () => ( "UNTRUSTED_ORIGIN")), message: _nullishCoalesce(options.message, () => ( "Access not allowed.")) }
65
+ });
66
+ };
67
+ }
68
+
69
+ // src/hardening/trust-proxy.ts
70
+ function trustedIp(req, options = {}) {
71
+ for (const name of _nullishCoalesce(options.trustedHeaders, () => ( []))) {
72
+ const v = headerOf(req, name);
73
+ if (v) return v;
74
+ }
75
+ return _optionalChain([req, 'access', _5 => _5.ips, 'optionalAccess', _6 => _6.length]) ? req.ips[0] : _nullishCoalesce(req.ip, () => ( ""));
76
+ }
77
+ function applyTrustProxy(app, value) {
78
+ const instance = app.getHttpAdapter().getInstance();
79
+ _optionalChain([instance, 'access', _7 => _7.set, 'optionalCall', _8 => _8("trust proxy", value)]);
80
+ }
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ exports.pathOf = pathOf; exports.matchesPath = matchesPath; exports.DEFAULT_BODY_LIMIT = DEFAULT_BODY_LIMIT; exports.applyBodyLimits = applyBodyLimits; exports.originSecretMiddleware = originSecretMiddleware; exports.trustedIp = trustedIp; exports.applyTrustProxy = applyTrustProxy;
@@ -11,7 +11,7 @@ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
11
11
  var _chunkQ5Y33L7Bcjs = require('./chunk-Q5Y33L7B.cjs');
12
12
 
13
13
 
14
- var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');
14
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
15
15
 
16
16
  // src/errors/global-exception.filter.ts
17
17
 
@@ -87,7 +87,7 @@ var GlobalExceptionFilter = class {
87
87
  };
88
88
  }
89
89
  };
90
- GlobalExceptionFilter = exports.GlobalExceptionFilter = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
90
+ GlobalExceptionFilter = exports.GlobalExceptionFilter = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
91
91
  _common.Catch.call(void 0, )
92
92
  ], GlobalExceptionFilter);
93
93
 
@@ -1,9 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk3AUOOEQOcjs = require('./chunk-3AUOOEQO.cjs');
3
+ var _chunkF77X4QUNcjs = require('./chunk-F77X4QUN.cjs');
4
4
 
5
5
 
6
- var _chunkMSTXS3MUcjs = require('./chunk-MSTXS3MU.cjs');
6
+ var _chunkJJKGQNGDcjs = require('./chunk-JJKGQNGD.cjs');
7
+
8
+
9
+
10
+
11
+ var _chunkIVWPA6QHcjs = require('./chunk-IVWPA6QH.cjs');
7
12
 
8
13
  // src/bootstrap/apply-defaults.ts
9
14
 
@@ -12,13 +17,16 @@ var _common = require('@nestjs/common');
12
17
  var _swagger = require('@nestjs/swagger');
13
18
  var _helmet = require('helmet'); var _helmet2 = _interopRequireDefault(_helmet);
14
19
  function applyNestKitDefaults(app, options = {}) {
20
+ if (options.trustProxy !== void 0) _chunkIVWPA6QHcjs.applyTrustProxy.call(void 0, app, options.trustProxy);
21
+ if (options.originSecret) app.use(_chunkIVWPA6QHcjs.originSecretMiddleware.call(void 0, options.originSecret));
22
+ if (options.bodyLimits) _chunkIVWPA6QHcjs.applyBodyLimits.call(void 0, app, options.bodyLimits);
15
23
  app.use(_helmet2.default.call(void 0, ));
16
24
  app.enableCors(_nullishCoalesce(options.cors, () => ( { origin: _nullishCoalesce(_optionalChain([process, 'access', _ => _.env, 'access', _2 => _2.CORS_ORIGIN, 'optionalAccess', _3 => _3.split, 'call', _4 => _4(",")]), () => ( true)) })));
17
25
  app.useGlobalPipes(
18
26
  new (0, _common.ValidationPipe)({ whitelist: true, transform: true, ...options.validation })
19
27
  );
20
- app.useGlobalFilters(new (0, _chunkMSTXS3MUcjs.GlobalExceptionFilter)());
21
- app.useGlobalInterceptors(new (0, _chunk3AUOOEQOcjs.ResponseInterceptor)());
28
+ app.useGlobalFilters(new (0, _chunkJJKGQNGDcjs.GlobalExceptionFilter)());
29
+ app.useGlobalInterceptors(new (0, _chunkF77X4QUNcjs.ResponseInterceptor)());
22
30
  if (options.swagger !== false) {
23
31
  const swaggerOptions = _nullishCoalesce(options.swagger, () => ( { title: "API" }));
24
32
  const config = new (0, _swagger.DocumentBuilder)().setTitle(swaggerOptions.title).build();
@@ -3,7 +3,7 @@
3
3
  var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
4
4
 
5
5
 
6
- var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');
6
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
7
7
 
8
8
  // src/tracking/request-id.middleware.ts
9
9
  var _crypto = require('crypto');
@@ -18,7 +18,7 @@ var RequestIdMiddleware = class {
18
18
  _chunkSDWHKPXIcjs.RequestContext.run({ requestId }, () => next());
19
19
  }
20
20
  };
21
- RequestIdMiddleware = exports.RequestIdMiddleware = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
21
+ RequestIdMiddleware = exports.RequestIdMiddleware = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
22
22
  _common.Injectable.call(void 0, )
23
23
  ], RequestIdMiddleware);
24
24
 
@@ -29,7 +29,7 @@ var TrackingModule = class {
29
29
  consumer.apply(RequestIdMiddleware).forRoutes("*");
30
30
  }
31
31
  };
32
- TrackingModule = exports.TrackingModule = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
32
+ TrackingModule = exports.TrackingModule = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
33
33
  _common.Module.call(void 0, {})
34
34
  ], TrackingModule);
35
35
 
@@ -1,38 +1,38 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkW2T2VFLCcjs = require('./chunk-W2T2VFLC.cjs');
4
3
 
4
+ var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
5
5
 
6
6
 
7
- var _chunkY72D5L6Icjs = require('./chunk-Y72D5L6I.cjs');
7
+ var _chunkVALDHJOOcjs = require('./chunk-VALDHJOO.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');
11
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
12
12
 
13
13
  // src/crud/list-query.dto.ts
14
14
  var _classtransformer = require('class-transformer');
15
15
  var _classvalidator = require('class-validator');
16
16
  var ListQuery = class {
17
17
  };
18
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
18
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
19
19
  _classvalidator.IsOptional.call(void 0, ),
20
20
  _classtransformer.Type.call(void 0, () => Number),
21
21
  _classvalidator.IsInt.call(void 0, ),
22
22
  _classvalidator.Min.call(void 0, 1)
23
23
  ], ListQuery.prototype, "page", 2);
24
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
24
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
25
25
  _classvalidator.IsOptional.call(void 0, ),
26
26
  _classtransformer.Type.call(void 0, () => Number),
27
27
  _classvalidator.IsInt.call(void 0, ),
28
28
  _classvalidator.Min.call(void 0, 1),
29
29
  _classvalidator.Max.call(void 0, 200)
30
30
  ], ListQuery.prototype, "limit", 2);
31
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
31
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
32
32
  _classvalidator.IsOptional.call(void 0, ),
33
33
  _classvalidator.IsString.call(void 0, )
34
34
  ], ListQuery.prototype, "sortBy", 2);
35
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
35
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
36
36
  _classvalidator.IsOptional.call(void 0, ),
37
37
  _classvalidator.IsIn.call(void 0, ["asc", "desc"])
38
38
  ], ListQuery.prototype, "sortOrder", 2);
@@ -117,7 +117,7 @@ var BaseCrudService = class {
117
117
  const audit = this.options.audit;
118
118
  if (!audit) return;
119
119
  await audit.recorder.record(
120
- _chunkW2T2VFLCcjs.withRequestContext.call(void 0, {
120
+ _chunkVALDHJOOcjs.withRequestContext.call(void 0, {
121
121
  action,
122
122
  resource: audit.resource,
123
123
  resourceId,
@@ -165,35 +165,35 @@ function createCrudController(serviceToken, options = {}) {
165
165
  return this.service.delete(id, tenantIdOf(req));
166
166
  }
167
167
  };
168
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
168
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
169
169
  _common.Get.call(void 0, ),
170
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Query.call(void 0, )),
171
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
170
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Query.call(void 0, )),
171
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
172
172
  ], CrudControllerHost.prototype, "findAll", 1);
173
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
173
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
174
174
  _common.Get.call(void 0, ":id"),
175
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
176
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
175
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
176
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
177
177
  ], CrudControllerHost.prototype, "findById", 1);
178
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
178
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
179
179
  _common.Post.call(void 0, ),
180
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Body.call(void 0, )),
181
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
180
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Body.call(void 0, )),
181
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
182
182
  ], CrudControllerHost.prototype, "create", 1);
183
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
183
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
184
184
  _common.Patch.call(void 0, ":id"),
185
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
186
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Body.call(void 0, )),
187
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 2, _common.Req.call(void 0, ))
185
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
186
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Body.call(void 0, )),
187
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 2, _common.Req.call(void 0, ))
188
188
  ], CrudControllerHost.prototype, "update", 1);
189
- _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
189
+ _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
190
190
  _common.Delete.call(void 0, ":id"),
191
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
192
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
191
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Param.call(void 0, "id")),
192
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Req.call(void 0, ))
193
193
  ], CrudControllerHost.prototype, "remove", 1);
194
- CrudControllerHost = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
194
+ CrudControllerHost = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
195
195
  _common.Controller.call(void 0, _nullishCoalesce(options.path, () => ( ""))),
196
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, serviceToken))
196
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, serviceToken))
197
197
  ], CrudControllerHost);
198
198
  return CrudControllerHost;
199
199
  }
@@ -0,0 +1,61 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/tenancy/tenancy.options.ts
2
+ var TENANCY_OPTIONS = /* @__PURE__ */ Symbol("TENANCY_OPTIONS");
3
+ var DEFAULT_GUCS = { tenant: "app.tenant_id", actor: "app.actor_id" };
4
+
5
+ // src/tenancy/request-context.ts
6
+ var _async_hooks = require('async_hooks');
7
+ var storage = new (0, _async_hooks.AsyncLocalStorage)();
8
+ var TenancyContext = {
9
+ run(fn, initial = {}) {
10
+ return storage.run({ ...initial }, fn);
11
+ },
12
+ setTenant(tenantId) {
13
+ const s = storage.getStore();
14
+ if (s) s.tenantId = tenantId;
15
+ },
16
+ setActor(actorId) {
17
+ const s = storage.getStore();
18
+ if (s) s.actorId = actorId;
19
+ },
20
+ tenantId() {
21
+ return _optionalChain([storage, 'access', _ => _.getStore, 'call', _2 => _2(), 'optionalAccess', _3 => _3.tenantId]);
22
+ },
23
+ actorId() {
24
+ return _optionalChain([storage, 'access', _4 => _4.getStore, 'call', _5 => _5(), 'optionalAccess', _6 => _6.actorId]);
25
+ }
26
+ };
27
+
28
+ // src/tenancy/tenancy.errors.ts
29
+ var TenantRequiredError = class extends Error {
30
+ constructor(message = "No tenant in scope: refusing to run a tenant query without one.") {
31
+ super(message);
32
+ this.code = "TENANT_REQUIRED";
33
+ this.name = "TenantRequiredError";
34
+ }
35
+ };
36
+
37
+ // src/tenancy/scope.ts
38
+ var GUC_NAME = /^[a-zA-Z_][\w]*(\.[\w-]+)+$/;
39
+ async function applyScope(query, scope, options = {}) {
40
+ const gucs = _nullishCoalesce(options.gucs, () => ( DEFAULT_GUCS));
41
+ const tenantId = _nullishCoalesce(scope.tenantId, () => ( TenancyContext.tenantId()));
42
+ const actorId = _nullishCoalesce(scope.actorId, () => ( TenancyContext.actorId()));
43
+ if (!tenantId && options.failClosed !== false) throw new TenantRequiredError();
44
+ const pairs = [];
45
+ if (tenantId) pairs.push([gucs.tenant, tenantId]);
46
+ if (gucs.actor && actorId) pairs.push([gucs.actor, actorId]);
47
+ for (const [name] of pairs) {
48
+ if (!GUC_NAME.test(name)) throw new Error(`Invalid GUC name: ${name}`);
49
+ }
50
+ for (const [name, value] of pairs) {
51
+ await query("SELECT set_config($1, $2, true)", [name, value]);
52
+ }
53
+ }
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ exports.TENANCY_OPTIONS = TENANCY_OPTIONS; exports.DEFAULT_GUCS = DEFAULT_GUCS; exports.TenancyContext = TenancyContext; exports.TenantRequiredError = TenantRequiredError; exports.applyScope = applyScope;
@@ -1,5 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
3
7
  var __decorateClass = (decorators, target, key, kind) => {
4
8
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
9
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -13,4 +17,5 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
13
17
 
14
18
 
15
19
 
16
- exports.__decorateClass = __decorateClass; exports.__decorateParam = __decorateParam;
20
+
21
+ exports.__export = __export; exports.__decorateClass = __decorateClass; exports.__decorateParam = __decorateParam;
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-ETRUVZTJ.js";
4
4
  import {
5
5
  __decorateClass
6
- } from "./chunk-4MGIQFAJ.js";
6
+ } from "./chunk-D3DDJWUD.js";
7
7
 
8
8
  // src/tracking/request-id.middleware.ts
9
9
  import { randomUUID } from "crypto";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  __decorateClass,
6
6
  __decorateParam
7
- } from "./chunk-4MGIQFAJ.js";
7
+ } from "./chunk-D3DDJWUD.js";
8
8
 
9
9
  // src/audit/audit.port.ts
10
10
  var AUDIT_SINK = /* @__PURE__ */ Symbol("AUDIT_SINK");
@@ -1,14 +1,14 @@
1
- import {
2
- withRequestContext
3
- } from "./chunk-ZJMLEP5H.js";
4
1
  import {
5
2
  buildPageMeta,
6
3
  paginated
7
4
  } from "./chunk-TCAMLNUZ.js";
5
+ import {
6
+ withRequestContext
7
+ } from "./chunk-NJYLQDB3.js";
8
8
  import {
9
9
  __decorateClass,
10
10
  __decorateParam
11
- } from "./chunk-4MGIQFAJ.js";
11
+ } from "./chunk-D3DDJWUD.js";
12
12
 
13
13
  // src/crud/list-query.dto.ts
14
14
  import { Type } from "class-transformer";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  __decorateClass,
11
11
  __decorateParam
12
- } from "./chunk-4MGIQFAJ.js";
12
+ } from "./chunk-D3DDJWUD.js";
13
13
 
14
14
  // src/i18n/i18n.module.ts
15
15
  import {
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
4
+
5
+ // src/consent/guard/index.ts
6
+ var guard_exports = {};
7
+ _chunkLRX7AMSScjs.__export.call(void 0, guard_exports, {
8
+ bundleContains: () => bundleContains,
9
+ checkParity: () => checkParity,
10
+ extractVersion: () => extractVersion,
11
+ verifyRelease: () => verifyRelease
12
+ });
13
+ function extractVersion(source, pattern) {
14
+ return _nullishCoalesce(_optionalChain([pattern, 'access', _ => _.exec, 'call', _2 => _2(source), 'optionalAccess', _3 => _3[1]]), () => ( null));
15
+ }
16
+ function checkParity(mobile, server) {
17
+ if (!mobile || !server) return { ok: false, message: "No se pudo leer la versi\xF3n m\xEDnima (m\xF3vil o servidor)." };
18
+ return mobile === server ? { ok: true, message: `Paridad correcta: ${server}.` } : { ok: false, message: `La m\xEDnima del m\xF3vil (${mobile}) no coincide con la del servidor (${server}).` };
19
+ }
20
+ function bundleContains(bundleText, minimum) {
21
+ return bundleText.includes(minimum) ? { ok: true, message: `El bundle web trae ${minimum}.` } : { ok: false, message: `El bundle web publicado NO trae ${minimum}: publ\xEDcalo antes de desplegar la API.` };
22
+ }
23
+ function verifyRelease(input) {
24
+ const results = [checkParity(input.mobile, input.server)];
25
+ if (input.webBundle !== void 0 && input.server)
26
+ results.push(bundleContains(input.webBundle, input.server));
27
+ if (input.mobilePublished !== void 0)
28
+ results.push(
29
+ input.mobilePublished === input.server ? { ok: true, message: "M\xF3vil publicado confirmado." } : { ok: false, message: `M\xF3vil publicado (${input.mobilePublished}) distinto de la m\xEDnima (${input.server}).` }
30
+ );
31
+ return { ok: results.every((r) => r.ok), results };
32
+ }
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ exports.extractVersion = extractVersion; exports.checkParity = checkParity; exports.bundleContains = bundleContains; exports.verifyRelease = verifyRelease; exports.guard_exports = guard_exports;
@@ -1,9 +1,14 @@
1
1
  import {
2
2
  ResponseInterceptor
3
- } from "./chunk-DYHSOULW.js";
3
+ } from "./chunk-IGSNB5BX.js";
4
4
  import {
5
5
  GlobalExceptionFilter
6
- } from "./chunk-A2DGK4ZL.js";
6
+ } from "./chunk-5LVGCTJ3.js";
7
+ import {
8
+ applyBodyLimits,
9
+ applyTrustProxy,
10
+ originSecretMiddleware
11
+ } from "./chunk-WFCQDOSN.js";
7
12
 
8
13
  // src/bootstrap/apply-defaults.ts
9
14
  import {
@@ -12,6 +17,9 @@ import {
12
17
  import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
13
18
  import helmet from "helmet";
14
19
  function applyNestKitDefaults(app, options = {}) {
20
+ if (options.trustProxy !== void 0) applyTrustProxy(app, options.trustProxy);
21
+ if (options.originSecret) app.use(originSecretMiddleware(options.originSecret));
22
+ if (options.bodyLimits) applyBodyLimits(app, options.bodyLimits);
15
23
  app.use(helmet());
16
24
  app.enableCors(options.cors ?? { origin: process.env.CORS_ORIGIN?.split(",") ?? true });
17
25
  app.useGlobalPipes(
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');
3
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
4
4
 
5
5
  // src/database/supabase/supabase.module.ts
6
6
  var _common = require('@nestjs/common');
@@ -16,7 +16,7 @@ function requireEnv(name) {
16
16
  }
17
17
  var SupabaseModule = class {
18
18
  };
19
- SupabaseModule = exports.SupabaseModule = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
19
+ SupabaseModule = exports.SupabaseModule = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
20
20
  _common.Module.call(void 0, {
21
21
  providers: [
22
22
  {
@@ -4,7 +4,7 @@ var _chunkSDWHKPXIcjs = require('./chunk-SDWHKPXI.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunk2REOCMUDcjs = require('./chunk-2REOCMUD.cjs');
7
+ var _chunkLRX7AMSScjs = require('./chunk-LRX7AMSS.cjs');
8
8
 
9
9
  // src/audit/audit.port.ts
10
10
  var AUDIT_SINK = /* @__PURE__ */ Symbol("AUDIT_SINK");
@@ -42,11 +42,11 @@ var AuditService = class {
42
42
  }
43
43
  }
44
44
  };
45
- AuditService = exports.AuditService = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
45
+ AuditService = exports.AuditService = _chunkLRX7AMSScjs.__decorateClass.call(void 0, [
46
46
  _common.Injectable.call(void 0, ),
47
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, AUDIT_SINK)),
48
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Optional.call(void 0, )),
49
- _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Inject.call(void 0, AUDIT_OPTIONS))
47
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, AUDIT_SINK)),
48
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Optional.call(void 0, )),
49
+ _chunkLRX7AMSScjs.__decorateParam.call(void 0, 1, _common.Inject.call(void 0, AUDIT_OPTIONS))
50
50
  ], AuditService);
51
51
 
52
52
 
@@ -0,0 +1,90 @@
1
+ // src/hardening/http.types.ts
2
+ function pathOf(req) {
3
+ const raw = req.path ?? req.originalUrl ?? req.url ?? "";
4
+ const q = raw.indexOf("?");
5
+ return q === -1 ? raw : raw.slice(0, q);
6
+ }
7
+ function headerOf(req, name) {
8
+ const v = req.headers?.[name.toLowerCase()];
9
+ return Array.isArray(v) ? v[0] : v;
10
+ }
11
+ function matchesPath(rule, path) {
12
+ if (rule instanceof RegExp) return rule.test(path);
13
+ if (rule.endsWith("*")) return path.startsWith(rule.slice(0, -1));
14
+ return path === rule;
15
+ }
16
+
17
+ // src/hardening/body-limits.ts
18
+ import { createRequire } from "module";
19
+ import { join } from "path";
20
+ var DEFAULT_BODY_LIMIT = "1mb";
21
+ var expressJson = (limit) => {
22
+ const req = createRequire(join(process.cwd(), "noop.js"));
23
+ return req("express").json({ limit });
24
+ };
25
+ function applyBodyLimits(app, options, factory = expressJson) {
26
+ const routes = options.routes ?? [];
27
+ if (routes.length) {
28
+ const parsers = /* @__PURE__ */ new Map();
29
+ const parserFor = (limit) => {
30
+ let p = parsers.get(limit);
31
+ if (!p) parsers.set(limit, p = factory(limit));
32
+ return p;
33
+ };
34
+ app.use((req, res, next) => {
35
+ const path = pathOf(req);
36
+ const rule = routes.find((r) => matchesPath(r.match, path));
37
+ return rule ? parserFor(rule.limit)(req, res, next) : next();
38
+ });
39
+ }
40
+ app.useBodyParser?.("json", { limit: options.default ?? DEFAULT_BODY_LIMIT });
41
+ }
42
+
43
+ // src/hardening/origin-secret.ts
44
+ import { createHash, timingSafeEqual } from "crypto";
45
+ var digest = (v) => createHash("sha256").update(v).digest();
46
+ function sameSecret(received, expected) {
47
+ return typeof received === "string" && timingSafeEqual(digest(received), expected);
48
+ }
49
+ function originSecretMiddleware(options) {
50
+ const expected = options.value ? digest(options.value) : null;
51
+ const scoped = (options.scoped ?? []).filter((s) => s.value).map((s) => ({ header: s.header, paths: s.paths, expected: digest(s.value) }));
52
+ const exclude = options.exclude ?? [];
53
+ return (req, res, next) => {
54
+ if (!expected) return next();
55
+ const path = pathOf(req);
56
+ if (exclude.some((r) => matchesPath(r, path))) return next();
57
+ if (sameSecret(headerOf(req, options.header), expected)) return next();
58
+ if (scoped.some(
59
+ (s) => s.paths.some((r) => matchesPath(r, path)) && sameSecret(headerOf(req, s.header), s.expected)
60
+ ))
61
+ return next();
62
+ res.status(options.status ?? 403).json({
63
+ success: false,
64
+ error: { code: options.code ?? "UNTRUSTED_ORIGIN", message: options.message ?? "Access not allowed." }
65
+ });
66
+ };
67
+ }
68
+
69
+ // src/hardening/trust-proxy.ts
70
+ function trustedIp(req, options = {}) {
71
+ for (const name of options.trustedHeaders ?? []) {
72
+ const v = headerOf(req, name);
73
+ if (v) return v;
74
+ }
75
+ return req.ips?.length ? req.ips[0] : req.ip ?? "";
76
+ }
77
+ function applyTrustProxy(app, value) {
78
+ const instance = app.getHttpAdapter().getInstance();
79
+ instance.set?.("trust proxy", value);
80
+ }
81
+
82
+ export {
83
+ pathOf,
84
+ matchesPath,
85
+ DEFAULT_BODY_LIMIT,
86
+ applyBodyLimits,
87
+ originSecretMiddleware,
88
+ trustedIp,
89
+ applyTrustProxy
90
+ };
@@ -0,0 +1,20 @@
1
+ import { type CallHandler, type ExecutionContext, type NestInterceptor } from '@nestjs/common';
2
+ import type { Observable } from 'rxjs';
3
+ import { type ConsentOptions } from './consent.options.js';
4
+ import { ConsentService } from './consent.service.js';
5
+ /**
6
+ * Blocks anyone who has not accepted a version >= the minimum of each document
7
+ * with a 403 and a stable code (`CONSENT_PENDIENTE` by default). The details
8
+ * carry the current version(s) so the client can show the right screen.
9
+ *
10
+ * An interceptor and not a guard on purpose: global guards run BEFORE the
11
+ * per-controller auth guard, so `req.user` does not exist yet; interceptors run
12
+ * after every guard. Mount it globally (`app.useGlobalInterceptors(app.get(ConsentInterceptor))`
13
+ * or `APP_INTERCEPTOR`).
14
+ */
15
+ export declare class ConsentInterceptor implements NestInterceptor {
16
+ private readonly options;
17
+ private readonly consent;
18
+ constructor(options: ConsentOptions, consent: ConsentService);
19
+ intercept(ctx: ExecutionContext, next: CallHandler): Promise<Observable<unknown>>;
20
+ }