@miguelmorales13/nestkit 0.11.0 → 0.18.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 (126) hide show
  1. package/README.md +619 -35
  2. package/dist/audit/audit.module.d.ts +23 -0
  3. package/dist/audit/audit.options.d.ts +16 -0
  4. package/dist/audit/audit.port.d.ts +37 -0
  5. package/dist/audit/audit.service.d.ts +29 -0
  6. package/dist/audit/index.cjs +72 -0
  7. package/dist/audit/index.d.ts +7 -0
  8. package/dist/audit/index.js +72 -0
  9. package/dist/audit/sinks.d.ts +18 -0
  10. package/dist/auth/index.cjs +12 -10
  11. package/dist/auth/index.js +5 -3
  12. package/dist/auth/oauth/http.d.ts +10 -3
  13. package/dist/auth/oauth/index.cjs +189 -29
  14. package/dist/auth/oauth/index.d.ts +6 -4
  15. package/dist/auth/oauth/index.js +169 -9
  16. package/dist/auth/oauth/magic-link.dto.d.ts +6 -0
  17. package/dist/auth/oauth/memory-magic-link.store.d.ts +19 -0
  18. package/dist/auth/oauth/oauth-auth.service.d.ts +46 -5
  19. package/dist/auth/oauth/oauth.controller.d.ts +5 -1
  20. package/dist/auth/oauth/oauth.options.d.ts +34 -1
  21. package/dist/auth/oauth/oauth.ports.d.ts +38 -0
  22. package/dist/bootstrap/index.cjs +9 -6
  23. package/dist/bootstrap/index.js +8 -5
  24. package/dist/{chunk-TJHRABML.cjs → chunk-3AUOOEQO.cjs} +12 -7
  25. package/dist/{chunk-NVCI3CQI.cjs → chunk-4HHZFOVC.cjs} +10 -5
  26. package/dist/{chunk-EYURGACO.js → chunk-4PFAKLT3.js} +1 -1
  27. package/dist/chunk-52IOOHNX.cjs +205 -0
  28. package/dist/chunk-6RAPVLJM.js +212 -0
  29. package/dist/{chunk-7I2Y7V52.js → chunk-A2DGK4ZL.js} +26 -3
  30. package/dist/chunk-APUFKA4K.cjs +212 -0
  31. package/dist/chunk-AXMW5JF7.cjs +83 -0
  32. package/dist/{chunk-KDAA6GFF.js → chunk-DYHSOULW.js} +12 -7
  33. package/dist/chunk-ETRUVZTJ.js +43 -0
  34. package/dist/{chunk-54ZXIB5T.cjs → chunk-FNUZGYUF.cjs} +4 -4
  35. package/dist/{chunk-FDNGAYTZ.cjs → chunk-HDFPSA2V.cjs} +6 -6
  36. package/dist/{chunk-V2M75FN3.cjs → chunk-HVHYZXBB.cjs} +2 -2
  37. package/dist/chunk-IFNYRZP2.js +205 -0
  38. package/dist/{chunk-A3B2EY4V.js → chunk-IKXSVEJ7.js} +7 -2
  39. package/dist/{chunk-YFYHLYHN.js → chunk-M3GQDRWR.js} +7 -1
  40. package/dist/{chunk-J7TURDAL.cjs → chunk-MSTXS3MU.cjs} +28 -5
  41. package/dist/chunk-PNK5WMPP.cjs +30 -0
  42. package/dist/chunk-Q5Y33L7B.cjs +19 -0
  43. package/dist/{chunk-ZA56XBCK.cjs → chunk-SDWHKPXI.cjs} +23 -0
  44. package/dist/chunk-TCAMLNUZ.js +27 -0
  45. package/dist/{chunk-AOCF5QCZ.js → chunk-UNEVXCFW.js} +2 -2
  46. package/dist/chunk-VVMRZEIW.js +30 -0
  47. package/dist/chunk-W2T2VFLC.cjs +57 -0
  48. package/dist/chunk-X4PQJZ4G.js +83 -0
  49. package/dist/chunk-Y72D5L6I.cjs +27 -0
  50. package/dist/{chunk-ORWJ7LES.js → chunk-ZFIDAX7K.js} +1 -1
  51. package/dist/chunk-ZJMLEP5H.js +57 -0
  52. package/dist/crud/crud.controller.d.ts +3 -1
  53. package/dist/crud/crud.service.d.ts +63 -4
  54. package/dist/crud/index.cjs +7 -2
  55. package/dist/crud/index.d.ts +2 -1
  56. package/dist/crud/index.js +6 -1
  57. package/dist/crud/list-query.dto.d.ts +23 -0
  58. package/dist/crud/repository.port.d.ts +33 -1
  59. package/dist/errors/app.exception.d.ts +9 -1
  60. package/dist/errors/common.exceptions.d.ts +6 -5
  61. package/dist/errors/global-exception.filter.d.ts +9 -0
  62. package/dist/errors/index.cjs +8 -5
  63. package/dist/errors/index.js +9 -6
  64. package/dist/i18n/i18n.interceptor.d.ts +16 -0
  65. package/dist/i18n/i18n.module.d.ts +49 -3
  66. package/dist/i18n/index.cjs +26 -2
  67. package/dist/i18n/index.d.ts +8 -0
  68. package/dist/i18n/index.js +25 -1
  69. package/dist/i18n/locale.d.ts +53 -0
  70. package/dist/i18n/message.d.ts +36 -0
  71. package/dist/i18n/nestjs-i18n.translator.d.ts +9 -0
  72. package/dist/i18n/runtime.d.ts +55 -0
  73. package/dist/i18n/translator.port.d.ts +29 -0
  74. package/dist/idempotency/idempotency.interceptor.d.ts +35 -0
  75. package/dist/idempotency/idempotency.module.d.ts +27 -0
  76. package/dist/idempotency/idempotency.options.d.ts +29 -0
  77. package/dist/idempotency/idempotency.port.d.ts +43 -0
  78. package/dist/idempotency/index.cjs +207 -0
  79. package/dist/idempotency/index.d.ts +7 -0
  80. package/dist/idempotency/index.js +207 -0
  81. package/dist/idempotency/memory.store.d.ts +24 -0
  82. package/dist/index.cjs +48 -15
  83. package/dist/index.js +51 -18
  84. package/dist/invoicing/adapters/facturama.invoicing.d.ts +50 -0
  85. package/dist/invoicing/adapters/facturapi.invoicing.d.ts +35 -0
  86. package/dist/invoicing/amounts.d.ts +52 -0
  87. package/dist/invoicing/index.cjs +578 -0
  88. package/dist/invoicing/index.d.ts +11 -0
  89. package/dist/invoicing/index.js +578 -0
  90. package/dist/invoicing/invoicing.module.d.ts +42 -0
  91. package/dist/invoicing/invoicing.options.d.ts +51 -0
  92. package/dist/invoicing/invoicing.port.d.ts +156 -0
  93. package/dist/invoicing/lines.d.ts +21 -0
  94. package/dist/invoicing/provider-http.d.ts +21 -0
  95. package/dist/payments/adapters/clip.terminal.d.ts +101 -0
  96. package/dist/payments/adapters/mercadopago.terminal.d.ts +74 -0
  97. package/dist/payments/index.cjs +796 -0
  98. package/dist/payments/index.d.ts +12 -0
  99. package/dist/payments/index.js +796 -0
  100. package/dist/payments/money.d.ts +20 -0
  101. package/dist/payments/payments-webhook.controller.d.ts +30 -0
  102. package/dist/payments/payments.module.d.ts +45 -0
  103. package/dist/payments/payments.options.d.ts +84 -0
  104. package/dist/payments/payments.port.d.ts +174 -0
  105. package/dist/payments/provider-http.d.ts +26 -0
  106. package/dist/response/api-response.d.ts +7 -0
  107. package/dist/response/index.cjs +12 -4
  108. package/dist/response/index.d.ts +2 -0
  109. package/dist/response/index.js +12 -4
  110. package/dist/response/paginated.d.ts +25 -0
  111. package/dist/response/response.interceptor.d.ts +4 -0
  112. package/dist/stripe/index.cjs +4 -3
  113. package/dist/stripe/index.js +3 -2
  114. package/dist/tracking/index.cjs +3 -3
  115. package/dist/tracking/index.d.ts +1 -1
  116. package/dist/tracking/index.js +2 -2
  117. package/dist/tracking/request-context.d.ts +32 -0
  118. package/package.json +25 -3
  119. package/dist/chunk-3CLYZC3T.cjs +0 -104
  120. package/dist/chunk-EBO6UKHL.js +0 -20
  121. package/dist/chunk-IYUUYCP5.js +0 -36
  122. package/dist/chunk-JOVBJDJ2.js +0 -104
  123. package/dist/chunk-M3EL5O6T.cjs +0 -36
  124. package/dist/chunk-R7BVS6CI.cjs +0 -13
  125. /package/dist/{chunk-MR2IFCZE.cjs → chunk-H2EHN366.cjs} +0 -0
  126. /package/dist/{chunk-NAK4WDKS.js → chunk-ODPSIFOB.js} +0 -0
@@ -0,0 +1,23 @@
1
+ import { type DynamicModule } from '@nestjs/common';
2
+ import { type AuditOptions } from './audit.options.js';
3
+ /**
4
+ * Who changed what.
5
+ *
6
+ * ```ts
7
+ * AuditModule.forRoot({ sink: new PostgresAuditSink(pool) })
8
+ * AuditModule.forRoot() // al log de la aplicación, para empezar
9
+ * ```
10
+ *
11
+ * The sink is the integration: a trail belongs in the consumer's database,
12
+ * under its retention rules, usually in a table that nothing is allowed to
13
+ * update. The library only decides what an entry contains and fills in who and
14
+ * which request from the context.
15
+ */
16
+ export declare class AuditModule {
17
+ static forRoot(options?: AuditOptions): DynamicModule;
18
+ static forRootAsync(config: {
19
+ imports?: any[];
20
+ inject?: any[];
21
+ useFactory: (...args: any[]) => AuditOptions | Promise<AuditOptions>;
22
+ }): DynamicModule;
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { AuditSinkPort } from './audit.port.js';
2
+ /** DI token carrying the resolved {@link AuditOptions}. */
3
+ export declare const AUDIT_OPTIONS: unique symbol;
4
+ export interface AuditOptions {
5
+ /** Where entries go. Defaults to the application log. */
6
+ sink?: AuditSinkPort;
7
+ /**
8
+ * What happens when the sink throws.
9
+ *
10
+ * `'continue'` (default) logs and carries on: the operation already
11
+ * succeeded, and losing the entry is better than losing the sale.
12
+ * `'fail'` propagates, for the rule that says an unrecorded action did not
13
+ * happen.
14
+ */
15
+ onError?: 'continue' | 'fail';
16
+ }
@@ -0,0 +1,37 @@
1
+ /** DI token for the audit sink. Inject with `@Inject(AUDIT_SINK)`. */
2
+ export declare const AUDIT_SINK: unique symbol;
3
+ /**
4
+ * Something that happened and that someone may have to answer for later.
5
+ *
6
+ * `actorId` and `requestId` are filled in from the request context when they
7
+ * are not passed explicitly, which is what makes this usable from a service
8
+ * that never received the user as an argument.
9
+ */
10
+ export interface AuditEvent {
11
+ /** What happened, as a verb the business would recognise: `created`, `deleted`, `refunded`. */
12
+ action: string;
13
+ /** What it happened to: the entity or resource name. */
14
+ resource: string;
15
+ resourceId?: string;
16
+ /** Who did it. Defaults to the actor on the request context. */
17
+ actorId?: string;
18
+ tenantId?: string;
19
+ /** Ties the entry to everything else logged for the same request. */
20
+ requestId?: string;
21
+ at?: Date;
22
+ /** State before and after, when the caller has both. */
23
+ before?: unknown;
24
+ after?: unknown;
25
+ /** Anything else worth keeping: an IP, a reason, the ticket that justified it. */
26
+ metadata?: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Where the trail is written.
30
+ *
31
+ * The library does not persist anything: a trail belongs in the consumer's
32
+ * database, under its retention rules, and often in a table nobody is allowed
33
+ * to update. Implementing this against that table is the whole integration.
34
+ */
35
+ export interface AuditSinkPort {
36
+ record(event: AuditEvent): Promise<void>;
37
+ }
@@ -0,0 +1,29 @@
1
+ import { type AuditEvent, type AuditSinkPort } from './audit.port.js';
2
+ import { type AuditOptions } from './audit.options.js';
3
+ /**
4
+ * Fills in what the caller should not have to carry: who, which request, when.
5
+ *
6
+ * Pure and exported because `BaseCrudService` needs the same defaults without
7
+ * taking a dependency on the service.
8
+ */
9
+ export declare function withRequestContext(event: AuditEvent): AuditEvent;
10
+ /**
11
+ * Records what happened.
12
+ *
13
+ * ```ts
14
+ * await this.audit.record({ action: 'refunded', resource: 'invoice', resourceId: id,
15
+ * metadata: { motive: '02' } });
16
+ * ```
17
+ *
18
+ * A failing sink does **not** fail the operation by default. An audit trail
19
+ * that takes the API down turns a logging outage into a business outage, and
20
+ * the write it was recording already happened. Consumers under a rule that
21
+ * says otherwise — no entry, no operation — set `onError: 'fail'`.
22
+ */
23
+ export declare class AuditService {
24
+ private readonly sink;
25
+ private readonly options;
26
+ private readonly logger;
27
+ constructor(sink: AuditSinkPort, options?: AuditOptions);
28
+ record(event: AuditEvent): Promise<void>;
29
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+
5
+
6
+ var _chunkW2T2VFLCcjs = require('../chunk-W2T2VFLC.cjs');
7
+ require('../chunk-SDWHKPXI.cjs');
8
+
9
+
10
+ var _chunk2REOCMUDcjs = require('../chunk-2REOCMUD.cjs');
11
+
12
+ // src/audit/sinks.ts
13
+ var _common = require('@nestjs/common');
14
+ var LoggerAuditSink = class {
15
+ constructor() {
16
+ this.logger = new (0, _common.Logger)("Audit");
17
+ }
18
+ async record(event) {
19
+ this.logger.log(JSON.stringify({ ...event, at: (_nullishCoalesce(event.at, () => ( /* @__PURE__ */ new Date()))).toISOString() }));
20
+ }
21
+ };
22
+ var MemoryAuditSink = class {
23
+ constructor() {
24
+ this.events = [];
25
+ }
26
+ async record(event) {
27
+ this.events.push(event);
28
+ }
29
+ };
30
+
31
+ // src/audit/audit.module.ts
32
+
33
+ var AuditModule = class {
34
+ static forRoot(options = {}) {
35
+ const providers = [
36
+ { provide: _chunkW2T2VFLCcjs.AUDIT_OPTIONS, useValue: options },
37
+ { provide: _chunkW2T2VFLCcjs.AUDIT_SINK, useFactory: () => _nullishCoalesce(options.sink, () => ( new LoggerAuditSink())) },
38
+ _chunkW2T2VFLCcjs.AuditService
39
+ ];
40
+ return { module: AuditModule, providers, exports: [_chunkW2T2VFLCcjs.AUDIT_SINK, _chunkW2T2VFLCcjs.AUDIT_OPTIONS, _chunkW2T2VFLCcjs.AuditService] };
41
+ }
42
+ static forRootAsync(config) {
43
+ const providers = [
44
+ { provide: _chunkW2T2VFLCcjs.AUDIT_OPTIONS, useFactory: config.useFactory, inject: _nullishCoalesce(config.inject, () => ( [])) },
45
+ {
46
+ provide: _chunkW2T2VFLCcjs.AUDIT_SINK,
47
+ useFactory: (options) => _nullishCoalesce(options.sink, () => ( new LoggerAuditSink())),
48
+ inject: [_chunkW2T2VFLCcjs.AUDIT_OPTIONS]
49
+ },
50
+ _chunkW2T2VFLCcjs.AuditService
51
+ ];
52
+ return {
53
+ module: AuditModule,
54
+ imports: _nullishCoalesce(config.imports, () => ( [])),
55
+ providers,
56
+ exports: [_chunkW2T2VFLCcjs.AUDIT_SINK, _chunkW2T2VFLCcjs.AUDIT_OPTIONS, _chunkW2T2VFLCcjs.AuditService]
57
+ };
58
+ }
59
+ };
60
+ AuditModule = exports.AuditModule = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
61
+ _common.Global.call(void 0, ),
62
+ _common.Module.call(void 0, {})
63
+ ], AuditModule);
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+ exports.AUDIT_OPTIONS = _chunkW2T2VFLCcjs.AUDIT_OPTIONS; exports.AUDIT_SINK = _chunkW2T2VFLCcjs.AUDIT_SINK; exports.AuditModule = AuditModule; exports.AuditService = _chunkW2T2VFLCcjs.AuditService; exports.LoggerAuditSink = LoggerAuditSink; exports.MemoryAuditSink = MemoryAuditSink; exports.withRequestContext = _chunkW2T2VFLCcjs.withRequestContext;
@@ -0,0 +1,7 @@
1
+ export { AUDIT_SINK } from './audit.port.js';
2
+ export type { AuditEvent, AuditSinkPort } from './audit.port.js';
3
+ export { AUDIT_OPTIONS } from './audit.options.js';
4
+ export type { AuditOptions } from './audit.options.js';
5
+ export { AuditService, withRequestContext } from './audit.service.js';
6
+ export { LoggerAuditSink, MemoryAuditSink } from './sinks.js';
7
+ export { AuditModule } from './audit.module.js';
@@ -0,0 +1,72 @@
1
+ import {
2
+ AUDIT_OPTIONS,
3
+ AUDIT_SINK,
4
+ AuditService,
5
+ withRequestContext
6
+ } from "../chunk-ZJMLEP5H.js";
7
+ import "../chunk-ETRUVZTJ.js";
8
+ import {
9
+ __decorateClass
10
+ } from "../chunk-4MGIQFAJ.js";
11
+
12
+ // src/audit/sinks.ts
13
+ import { Logger } from "@nestjs/common";
14
+ var LoggerAuditSink = class {
15
+ constructor() {
16
+ this.logger = new Logger("Audit");
17
+ }
18
+ async record(event) {
19
+ this.logger.log(JSON.stringify({ ...event, at: (event.at ?? /* @__PURE__ */ new Date()).toISOString() }));
20
+ }
21
+ };
22
+ var MemoryAuditSink = class {
23
+ constructor() {
24
+ this.events = [];
25
+ }
26
+ async record(event) {
27
+ this.events.push(event);
28
+ }
29
+ };
30
+
31
+ // src/audit/audit.module.ts
32
+ import { Global, Module } from "@nestjs/common";
33
+ var AuditModule = class {
34
+ static forRoot(options = {}) {
35
+ const providers = [
36
+ { provide: AUDIT_OPTIONS, useValue: options },
37
+ { provide: AUDIT_SINK, useFactory: () => options.sink ?? new LoggerAuditSink() },
38
+ AuditService
39
+ ];
40
+ return { module: AuditModule, providers, exports: [AUDIT_SINK, AUDIT_OPTIONS, AuditService] };
41
+ }
42
+ static forRootAsync(config) {
43
+ const providers = [
44
+ { provide: AUDIT_OPTIONS, useFactory: config.useFactory, inject: config.inject ?? [] },
45
+ {
46
+ provide: AUDIT_SINK,
47
+ useFactory: (options) => options.sink ?? new LoggerAuditSink(),
48
+ inject: [AUDIT_OPTIONS]
49
+ },
50
+ AuditService
51
+ ];
52
+ return {
53
+ module: AuditModule,
54
+ imports: config.imports ?? [],
55
+ providers,
56
+ exports: [AUDIT_SINK, AUDIT_OPTIONS, AuditService]
57
+ };
58
+ }
59
+ };
60
+ AuditModule = __decorateClass([
61
+ Global(),
62
+ Module({})
63
+ ], AuditModule);
64
+ export {
65
+ AUDIT_OPTIONS,
66
+ AUDIT_SINK,
67
+ AuditModule,
68
+ AuditService,
69
+ LoggerAuditSink,
70
+ MemoryAuditSink,
71
+ withRequestContext
72
+ };
@@ -0,0 +1,18 @@
1
+ import type { AuditEvent, AuditSinkPort } from './audit.port.js';
2
+ /**
3
+ * Writes the trail to the application log as one JSON line per event.
4
+ *
5
+ * A reasonable default and a poor final answer: logs rotate, and the question
6
+ * an audit trail exists to answer ("who deleted this, in March") is asked long
7
+ * after the log is gone. Good for development and for shipping to a log
8
+ * pipeline; not a substitute for a table.
9
+ */
10
+ export declare class LoggerAuditSink implements AuditSinkPort {
11
+ private readonly logger;
12
+ record(event: AuditEvent): Promise<void>;
13
+ }
14
+ /** Keeps events in memory. For tests, and for seeing the shape in development. */
15
+ export declare class MemoryAuditSink implements AuditSinkPort {
16
+ readonly events: AuditEvent[];
17
+ record(event: AuditEvent): Promise<void>;
18
+ }
@@ -2,13 +2,15 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkNVCI3CQIcjs = require('../chunk-NVCI3CQI.cjs');
5
+ var _chunk4HHZFOVCcjs = require('../chunk-4HHZFOVC.cjs');
6
+ require('../chunk-SDWHKPXI.cjs');
6
7
 
7
8
 
8
9
 
9
10
 
10
- var _chunkFDNGAYTZcjs = require('../chunk-FDNGAYTZ.cjs');
11
- require('../chunk-R7BVS6CI.cjs');
11
+ var _chunkHDFPSA2Vcjs = require('../chunk-HDFPSA2V.cjs');
12
+ require('../chunk-Q5Y33L7B.cjs');
13
+ require('../chunk-PNK5WMPP.cjs');
12
14
 
13
15
 
14
16
 
@@ -45,7 +47,7 @@ var RolesGuard = class {
45
47
  const req = context.switchToHttp().getRequest();
46
48
  const has = _nullishCoalesce(_optionalChain([req, 'access', _2 => _2.user, 'optionalAccess', _3 => _3.roles, 'access', _4 => _4.some, 'call', _5 => _5((role) => required.includes(role))]), () => ( false));
47
49
  if (!has) {
48
- throw new (0, _chunkFDNGAYTZcjs.ForbiddenAppException)("Insufficient role");
50
+ throw new (0, _chunkHDFPSA2Vcjs.ForbiddenAppException)("Insufficient role");
49
51
  }
50
52
  return true;
51
53
  }
@@ -66,7 +68,7 @@ var RequireTenantGuard = class {
66
68
  canActivate(context) {
67
69
  const req = context.switchToHttp().getRequest();
68
70
  if (!_optionalChain([req, 'access', _12 => _12.user, 'optionalAccess', _13 => _13.tenantId])) {
69
- throw new (0, _chunkFDNGAYTZcjs.ForbiddenAppException)("This action requires a company account");
71
+ throw new (0, _chunkHDFPSA2Vcjs.ForbiddenAppException)("This action requires a company account");
70
72
  }
71
73
  return true;
72
74
  }
@@ -106,14 +108,14 @@ _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
106
108
 
107
109
  // src/auth/auth.service.ts
108
110
  var BaseAuthService = class {
109
- constructor(users, tokens = new (0, _chunkNVCI3CQIcjs.TokenService)()) {
111
+ constructor(users, tokens = new (0, _chunk4HHZFOVCcjs.TokenService)()) {
110
112
  this.users = users;
111
113
  this.tokens = tokens;
112
114
  }
113
115
  async register(data) {
114
116
  const existing = await this.users.findByEmail(data.email);
115
117
  if (existing) {
116
- throw new (0, _chunkFDNGAYTZcjs.ConflictAppException)("Email already registered", { email: data.email }, "EMAIL_TAKEN");
118
+ throw new (0, _chunkHDFPSA2Vcjs.ConflictAppException)("Email already registered", { email: data.email }, "EMAIL_TAKEN");
117
119
  }
118
120
  const passwordHash = await hashPassword(data.password);
119
121
  const user = await this.users.create({
@@ -127,7 +129,7 @@ var BaseAuthService = class {
127
129
  async login(email, password) {
128
130
  const user = await this.users.findByEmail(email);
129
131
  if (!user || !await verifyPassword(password, user.passwordHash)) {
130
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("Invalid credentials");
132
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("Invalid credentials");
131
133
  }
132
134
  return { user, ...this.issueTokens(user) };
133
135
  }
@@ -135,7 +137,7 @@ var BaseAuthService = class {
135
137
  const payload = this.tokens.verifyRefreshToken(refreshToken);
136
138
  const user = await this.users.findById(payload.sub);
137
139
  if (!user) {
138
- throw new (0, _chunkFDNGAYTZcjs.UnauthorizedAppException)("User no longer exists");
140
+ throw new (0, _chunkHDFPSA2Vcjs.UnauthorizedAppException)("User no longer exists");
139
141
  }
140
142
  return this.issueTokens(user);
141
143
  }
@@ -204,4 +206,4 @@ function createAuthController(serviceToken, options = {}) {
204
206
 
205
207
 
206
208
 
207
- exports.BaseAuthService = BaseAuthService; exports.CurrentTenant = CurrentTenant; exports.CurrentUser = _chunkNVCI3CQIcjs.CurrentUser; exports.JwtAuthGuard = _chunkNVCI3CQIcjs.JwtAuthGuard; exports.LoginDto = LoginDto; exports.ROLES_KEY = ROLES_KEY; exports.RefreshDto = RefreshDto; exports.RegisterDto = RegisterDto; exports.RequireTenantGuard = RequireTenantGuard; exports.Roles = Roles; exports.RolesGuard = RolesGuard; exports.TokenService = _chunkNVCI3CQIcjs.TokenService; exports.createAuthController = createAuthController; exports.hashPassword = hashPassword; exports.verifyPassword = verifyPassword;
209
+ exports.BaseAuthService = BaseAuthService; exports.CurrentTenant = CurrentTenant; exports.CurrentUser = _chunk4HHZFOVCcjs.CurrentUser; exports.JwtAuthGuard = _chunk4HHZFOVCcjs.JwtAuthGuard; exports.LoginDto = LoginDto; exports.ROLES_KEY = ROLES_KEY; exports.RefreshDto = RefreshDto; exports.RegisterDto = RegisterDto; exports.RequireTenantGuard = RequireTenantGuard; exports.Roles = Roles; exports.RolesGuard = RolesGuard; exports.TokenService = _chunk4HHZFOVCcjs.TokenService; exports.createAuthController = createAuthController; exports.hashPassword = hashPassword; exports.verifyPassword = verifyPassword;
@@ -2,13 +2,15 @@ import {
2
2
  CurrentUser,
3
3
  JwtAuthGuard,
4
4
  TokenService
5
- } from "../chunk-A3B2EY4V.js";
5
+ } from "../chunk-IKXSVEJ7.js";
6
+ import "../chunk-ETRUVZTJ.js";
6
7
  import {
7
8
  ConflictAppException,
8
9
  ForbiddenAppException,
9
10
  UnauthorizedAppException
10
- } from "../chunk-ORWJ7LES.js";
11
- import "../chunk-YFYHLYHN.js";
11
+ } from "../chunk-ZFIDAX7K.js";
12
+ import "../chunk-M3GQDRWR.js";
13
+ import "../chunk-VVMRZEIW.js";
12
14
  import {
13
15
  __decorateClass,
14
16
  __decorateParam
@@ -16,7 +16,9 @@ export interface CookieOptions {
16
16
  expires?: Date;
17
17
  }
18
18
  export interface ReplyLike {
19
- redirect: ((url: string, statusCode?: number) => unknown) & ((...args: never[]) => unknown);
19
+ redirect: (...args: never[]) => unknown;
20
+ /** Fastify only. Its presence is how the two adapters are told apart. */
21
+ code?(statusCode: number): unknown;
20
22
  setCookie?(name: string, value: string, options?: CookieOptions): unknown;
21
23
  cookie?(name: string, value: string, options?: CookieOptions): unknown;
22
24
  clearCookie?(name: string, options?: CookieOptions): unknown;
@@ -32,7 +34,12 @@ export declare function clearCookie(reply: ReplyLike, name: string, options: Coo
32
34
  *
33
35
  * Not optional: Nest's Fastify adapter answers `reply.redirect(url)` with a
34
36
  * 200 carrying a Location header, which no browser follows — the sign-in
35
- * simply stops on a blank page. Express ignores the second argument when the
36
- * first is a URL, so the same call is correct on both.
37
+ * simply stops on a blank page.
38
+ *
39
+ * The argument order is the adapter's, and they disagree: Fastify (4 and 5)
40
+ * takes `(url, code)`; Express takes `(code, url)`. Express 4 tolerated
41
+ * `(url, code)` as a deprecated form, Express 5 does not — it reads the URL
42
+ * as the status code and throws, which took the whole OAuth callback down.
43
+ * Fastify's reply is the one with a `code()` method, so that is the test.
37
44
  */
38
45
  export declare function redirect(reply: ReplyLike, url: string): void;