@vritti/api-sdk 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +668 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -28
- package/dist/index.d.ts +82 -28
- package/dist/index.js +530 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,10 +37,9 @@ __export(index_exports, {
|
|
|
37
37
|
BaseFieldException: () => BaseFieldException,
|
|
38
38
|
ConflictException: () => ConflictException,
|
|
39
39
|
CorrelationIdMiddleware: () => CorrelationIdMiddleware,
|
|
40
|
-
CsrfGuard: () => CsrfGuard,
|
|
41
40
|
DEFAULT_CORRELATION_HEADER: () => DEFAULT_CORRELATION_HEADER,
|
|
42
41
|
DatabaseModule: () => DatabaseModule,
|
|
43
|
-
ForbiddenException: () =>
|
|
42
|
+
ForbiddenException: () => ForbiddenException2,
|
|
44
43
|
GoneException: () => GoneException,
|
|
45
44
|
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
46
45
|
HttpLoggerInterceptor: () => HttpLoggerInterceptor,
|
|
@@ -59,13 +58,16 @@ __export(index_exports, {
|
|
|
59
58
|
PrimaryDatabaseService: () => PrimaryDatabaseService,
|
|
60
59
|
Public: () => Public,
|
|
61
60
|
RequestTimeoutException: () => RequestTimeoutException,
|
|
61
|
+
SKIP_CSRF_KEY: () => SKIP_CSRF_KEY,
|
|
62
62
|
ServiceUnavailableException: () => ServiceUnavailableException,
|
|
63
|
+
SkipCsrf: () => SkipCsrf,
|
|
64
|
+
SseAuthGuard: () => SseAuthGuard,
|
|
63
65
|
Tenant: () => Tenant,
|
|
64
66
|
TenantBaseRepository: () => TenantBaseRepository,
|
|
65
67
|
TenantContextService: () => TenantContextService,
|
|
66
68
|
TenantDatabaseService: () => TenantDatabaseService,
|
|
67
69
|
TooManyRequestsException: () => TooManyRequestsException,
|
|
68
|
-
UnauthorizedException: () =>
|
|
70
|
+
UnauthorizedException: () => UnauthorizedException5,
|
|
69
71
|
UnprocessableEntityException: () => UnprocessableEntityException,
|
|
70
72
|
UnsupportedMediaTypeException: () => UnsupportedMediaTypeException,
|
|
71
73
|
UserId: () => UserId,
|
|
@@ -75,6 +77,7 @@ __export(index_exports, {
|
|
|
75
77
|
configureApiSdk: () => configureApiSdk,
|
|
76
78
|
correlationStorage: () => correlationStorage,
|
|
77
79
|
defineConfig: () => defineConfig,
|
|
80
|
+
extractCountryFromPhone: () => extractCountryFromPhone,
|
|
78
81
|
generateCorrelationId: () => generateCorrelationId,
|
|
79
82
|
getConfig: () => getConfig,
|
|
80
83
|
getCorrelationContext: () => getCorrelationContext,
|
|
@@ -82,6 +85,7 @@ __export(index_exports, {
|
|
|
82
85
|
getJwtExpiry: () => getJwtExpiry,
|
|
83
86
|
getRefreshCookieOptions: () => getRefreshCookieOptions,
|
|
84
87
|
hashToken: () => hashToken,
|
|
88
|
+
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
85
89
|
resetConfig: () => resetConfig,
|
|
86
90
|
runWithCorrelationContext: () => runWithCorrelationContext,
|
|
87
91
|
updateCorrelationContext: () => updateCorrelationContext,
|
|
@@ -90,7 +94,7 @@ __export(index_exports, {
|
|
|
90
94
|
module.exports = __toCommonJS(index_exports);
|
|
91
95
|
|
|
92
96
|
// src/auth/auth-config.module.ts
|
|
93
|
-
var
|
|
97
|
+
var import_common6 = require("@nestjs/common");
|
|
94
98
|
var import_config4 = require("@nestjs/config");
|
|
95
99
|
var import_core3 = require("@nestjs/core");
|
|
96
100
|
var import_jwt2 = require("@nestjs/jwt");
|
|
@@ -109,7 +113,8 @@ var defaultConfig = {
|
|
|
109
113
|
refreshCookieMaxAge: 30 * 24 * 60 * 60 * 1e3,
|
|
110
114
|
refreshCookiePath: "/",
|
|
111
115
|
refreshCookieSecure: process.env.NODE_ENV === "production",
|
|
112
|
-
refreshCookieSameSite: "strict"
|
|
116
|
+
refreshCookieSameSite: "strict",
|
|
117
|
+
refreshCookieDomain: "localhost"
|
|
113
118
|
},
|
|
114
119
|
jwt: {
|
|
115
120
|
accessTokenExpiry: "15m",
|
|
@@ -158,13 +163,17 @@ function resetConfig() {
|
|
|
158
163
|
}
|
|
159
164
|
__name(resetConfig, "resetConfig");
|
|
160
165
|
function getRefreshCookieOptions() {
|
|
161
|
-
|
|
166
|
+
const options = {
|
|
162
167
|
httpOnly: true,
|
|
163
168
|
secure: currentConfig.cookie.refreshCookieSecure,
|
|
164
169
|
sameSite: currentConfig.cookie.refreshCookieSameSite,
|
|
165
170
|
path: currentConfig.cookie.refreshCookiePath,
|
|
166
171
|
maxAge: currentConfig.cookie.refreshCookieMaxAge
|
|
167
172
|
};
|
|
173
|
+
if (currentConfig.cookie.refreshCookieDomain) {
|
|
174
|
+
options.domain = currentConfig.cookie.refreshCookieDomain;
|
|
175
|
+
}
|
|
176
|
+
return options;
|
|
168
177
|
}
|
|
169
178
|
__name(getRefreshCookieOptions, "getRefreshCookieOptions");
|
|
170
179
|
function getJwtExpiry() {
|
|
@@ -300,13 +309,18 @@ RequestModule = _ts_decorate2([
|
|
|
300
309
|
], RequestModule);
|
|
301
310
|
|
|
302
311
|
// src/auth/guards/vritti-auth.guard.ts
|
|
303
|
-
var
|
|
312
|
+
var import_common5 = require("@nestjs/common");
|
|
304
313
|
var import_config2 = require("@nestjs/config");
|
|
305
314
|
var import_core2 = require("@nestjs/core");
|
|
306
315
|
var import_jwt = require("@nestjs/jwt");
|
|
307
316
|
|
|
308
|
-
// src/
|
|
317
|
+
// src/auth/decorators/skip-csrf.decorator.ts
|
|
309
318
|
var import_common3 = require("@nestjs/common");
|
|
319
|
+
var SKIP_CSRF_KEY = "skipCsrf";
|
|
320
|
+
var SkipCsrf = /* @__PURE__ */ __name(() => (0, import_common3.SetMetadata)(SKIP_CSRF_KEY, true), "SkipCsrf");
|
|
321
|
+
|
|
322
|
+
// src/database/services/primary-database.service.ts
|
|
323
|
+
var import_common4 = require("@nestjs/common");
|
|
310
324
|
var import_drizzle_orm = require("drizzle-orm");
|
|
311
325
|
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
312
326
|
var import_pg = require("pg");
|
|
@@ -337,7 +351,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
337
351
|
__name(this, "PrimaryDatabaseService");
|
|
338
352
|
}
|
|
339
353
|
options;
|
|
340
|
-
logger = new
|
|
354
|
+
logger = new import_common4.Logger(_PrimaryDatabaseService.name);
|
|
341
355
|
/** PostgreSQL connection pool */
|
|
342
356
|
pool = null;
|
|
343
357
|
/** Drizzle database instance */
|
|
@@ -377,7 +391,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
377
391
|
this.logger.log("Connected to primary database (tenant registry)");
|
|
378
392
|
} catch (error) {
|
|
379
393
|
this.logger.error("Failed to connect to primary database", error);
|
|
380
|
-
throw new
|
|
394
|
+
throw new import_common4.InternalServerErrorException("Failed to initialize tenant registry");
|
|
381
395
|
}
|
|
382
396
|
}
|
|
383
397
|
/**
|
|
@@ -458,7 +472,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
458
472
|
return info;
|
|
459
473
|
} catch (error) {
|
|
460
474
|
this.logger.error(`Failed to fetch tenant info: ${tenantIdentifier}`, error);
|
|
461
|
-
throw new
|
|
475
|
+
throw new import_common4.InternalServerErrorException("Failed to resolve tenant");
|
|
462
476
|
}
|
|
463
477
|
}
|
|
464
478
|
/**
|
|
@@ -534,8 +548,8 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
534
548
|
}
|
|
535
549
|
};
|
|
536
550
|
PrimaryDatabaseService = _ts_decorate3([
|
|
537
|
-
(0,
|
|
538
|
-
_ts_param2(0, (0,
|
|
551
|
+
(0, import_common4.Injectable)(),
|
|
552
|
+
_ts_param2(0, (0, import_common4.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
539
553
|
_ts_metadata2("design:type", Function),
|
|
540
554
|
_ts_metadata2("design:paramtypes", [
|
|
541
555
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions
|
|
@@ -576,7 +590,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
576
590
|
jwtService;
|
|
577
591
|
primaryDatabase;
|
|
578
592
|
requestService;
|
|
579
|
-
logger = new
|
|
593
|
+
logger = new import_common5.Logger(_VrittiAuthGuard.name);
|
|
580
594
|
constructor(reflector, _configService, jwtService, primaryDatabase, requestService) {
|
|
581
595
|
this.reflector = reflector;
|
|
582
596
|
this._configService = _configService;
|
|
@@ -586,6 +600,14 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
586
600
|
}
|
|
587
601
|
async canActivate(context) {
|
|
588
602
|
const request = context.switchToHttp().getRequest();
|
|
603
|
+
const reply = context.switchToHttp().getResponse();
|
|
604
|
+
const skipCsrf = this.reflector.getAllAndOverride(SKIP_CSRF_KEY, [
|
|
605
|
+
context.getHandler(),
|
|
606
|
+
context.getClass()
|
|
607
|
+
]);
|
|
608
|
+
if (!skipCsrf) {
|
|
609
|
+
await this.validateCsrf(request, reply);
|
|
610
|
+
}
|
|
589
611
|
const isPublic = this.reflector.getAllAndOverride("isPublic", [
|
|
590
612
|
context.getHandler(),
|
|
591
613
|
context.getClass()
|
|
@@ -602,17 +624,17 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
602
624
|
const accessToken = this.requestService.getAccessToken();
|
|
603
625
|
if (!accessToken) {
|
|
604
626
|
this.logger.warn("Access token not found in Authorization header");
|
|
605
|
-
throw new
|
|
627
|
+
throw new import_common5.UnauthorizedException("Access token not found");
|
|
606
628
|
}
|
|
607
629
|
const decodedToken = this.jwtService.decode(accessToken);
|
|
608
630
|
if (!decodedToken) {
|
|
609
631
|
this.logger.warn("Failed to decode access token");
|
|
610
|
-
throw new
|
|
632
|
+
throw new import_common5.UnauthorizedException("Invalid token format");
|
|
611
633
|
}
|
|
612
634
|
if (isOnboarding) {
|
|
613
635
|
if (decodedToken.type !== "onboarding") {
|
|
614
636
|
this.logger.warn("Onboarding endpoint requires onboarding token");
|
|
615
|
-
throw new
|
|
637
|
+
throw new import_common5.UnauthorizedException("This endpoint requires an onboarding token");
|
|
616
638
|
}
|
|
617
639
|
const validatedToken2 = this.validateAccessToken(accessToken);
|
|
618
640
|
this.logger.debug("Onboarding token validated successfully");
|
|
@@ -625,7 +647,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
625
647
|
}
|
|
626
648
|
if (decodedToken.type === "onboarding") {
|
|
627
649
|
this.logger.warn("Regular endpoint accessed with onboarding token");
|
|
628
|
-
throw new
|
|
650
|
+
throw new import_common5.UnauthorizedException("Onboarding tokens cannot access this endpoint");
|
|
629
651
|
}
|
|
630
652
|
const validatedToken = this.validateAccessToken(accessToken);
|
|
631
653
|
this.logger.debug("Access token validated successfully");
|
|
@@ -637,7 +659,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
637
659
|
const tenantIdentifier = this.requestService.getTenantIdentifier();
|
|
638
660
|
if (!tenantIdentifier) {
|
|
639
661
|
this.logger.warn("Tenant identifier not found in request");
|
|
640
|
-
throw new
|
|
662
|
+
throw new import_common5.UnauthorizedException("Tenant identifier not found");
|
|
641
663
|
}
|
|
642
664
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
643
665
|
if (tenantIdentifier === "cloud") {
|
|
@@ -647,20 +669,20 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
647
669
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
648
670
|
if (!tenantInfo) {
|
|
649
671
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
650
|
-
throw new
|
|
672
|
+
throw new import_common5.UnauthorizedException("Invalid tenant");
|
|
651
673
|
}
|
|
652
674
|
if (tenantInfo.status !== "ACTIVE") {
|
|
653
675
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
654
|
-
throw new
|
|
676
|
+
throw new import_common5.UnauthorizedException(`Tenant is ${tenantInfo.status}`);
|
|
655
677
|
}
|
|
656
678
|
this.logger.debug(`Tenant validated: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
657
679
|
return true;
|
|
658
680
|
} catch (error) {
|
|
659
|
-
if (error instanceof
|
|
681
|
+
if (error instanceof import_common5.UnauthorizedException) {
|
|
660
682
|
throw error;
|
|
661
683
|
}
|
|
662
684
|
this.logger.error("Unexpected error in auth guard", error);
|
|
663
|
-
throw new
|
|
685
|
+
throw new import_common5.UnauthorizedException("Authentication failed");
|
|
664
686
|
}
|
|
665
687
|
}
|
|
666
688
|
/**
|
|
@@ -679,24 +701,24 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
679
701
|
}
|
|
680
702
|
return decoded;
|
|
681
703
|
} catch (error) {
|
|
682
|
-
if (error instanceof
|
|
704
|
+
if (error instanceof import_common5.UnauthorizedException) {
|
|
683
705
|
throw error;
|
|
684
706
|
}
|
|
685
707
|
const jwtError = error;
|
|
686
708
|
if (jwtError?.name === "TokenExpiredError") {
|
|
687
709
|
this.logger.warn(`Access token expired at: ${jwtError?.expiredAt}`);
|
|
688
|
-
throw new
|
|
710
|
+
throw new import_common5.UnauthorizedException("Access token has expired");
|
|
689
711
|
}
|
|
690
712
|
if (jwtError?.name === "JsonWebTokenError") {
|
|
691
713
|
this.logger.warn(`Access token verification failed: ${jwtError?.message}`);
|
|
692
|
-
throw new
|
|
714
|
+
throw new import_common5.UnauthorizedException("Invalid access token");
|
|
693
715
|
}
|
|
694
716
|
if (jwtError?.name === "NotBeforeError") {
|
|
695
717
|
this.logger.warn("Access token used before valid (nbf claim)");
|
|
696
|
-
throw new
|
|
718
|
+
throw new import_common5.UnauthorizedException("Access token not yet valid");
|
|
697
719
|
}
|
|
698
720
|
this.logger.error("Unexpected error validating access token", error);
|
|
699
|
-
throw new
|
|
721
|
+
throw new import_common5.UnauthorizedException("Access token validation failed");
|
|
700
722
|
}
|
|
701
723
|
}
|
|
702
724
|
/**
|
|
@@ -723,18 +745,64 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
723
745
|
const refreshToken = cookies[config.cookie.refreshCookieName];
|
|
724
746
|
if (!refreshToken) {
|
|
725
747
|
this.logger.warn("Session validation failed - refresh token cookie not found");
|
|
726
|
-
throw new
|
|
748
|
+
throw new import_common5.UnauthorizedException("Session validation failed");
|
|
727
749
|
}
|
|
728
750
|
if (!verifyTokenHash(refreshToken, validatedToken.refreshTokenHash)) {
|
|
729
751
|
this.logger.warn("Session validation failed - token binding mismatch");
|
|
730
|
-
throw new
|
|
752
|
+
throw new import_common5.UnauthorizedException("Session validation failed");
|
|
731
753
|
}
|
|
732
754
|
this.logger.debug("Token binding validated successfully");
|
|
733
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Validate CSRF token for state-changing requests
|
|
758
|
+
* Uses Fastify's csrf-protection plugin for token validation
|
|
759
|
+
*
|
|
760
|
+
* @param request - Fastify request object
|
|
761
|
+
* @param reply - Fastify reply object
|
|
762
|
+
* @throws ForbiddenException if CSRF validation fails
|
|
763
|
+
*/
|
|
764
|
+
async validateCsrf(request, reply) {
|
|
765
|
+
const safeMethods = [
|
|
766
|
+
"GET",
|
|
767
|
+
"HEAD",
|
|
768
|
+
"OPTIONS"
|
|
769
|
+
];
|
|
770
|
+
if (safeMethods.includes(request.method)) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
try {
|
|
774
|
+
const fastifyInstance = request.server;
|
|
775
|
+
if (!fastifyInstance.csrfProtection) {
|
|
776
|
+
this.logger.error("CSRF protection plugin not found. Ensure @fastify/csrf-protection is registered.");
|
|
777
|
+
throw new import_common5.ForbiddenException("CSRF protection not configured");
|
|
778
|
+
}
|
|
779
|
+
await new Promise((resolve, reject) => {
|
|
780
|
+
fastifyInstance.csrfProtection(request, reply, (err) => {
|
|
781
|
+
if (err) {
|
|
782
|
+
reject(err);
|
|
783
|
+
} else {
|
|
784
|
+
resolve();
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
this.logger.debug(`CSRF validation successful for ${request.method} ${request.url}`);
|
|
789
|
+
} catch (error) {
|
|
790
|
+
this.logger.warn(`CSRF validation failed for ${request.method} ${request.url}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
791
|
+
throw new import_common5.ForbiddenException({
|
|
792
|
+
errors: [
|
|
793
|
+
{
|
|
794
|
+
field: "csrf",
|
|
795
|
+
message: "Invalid or missing CSRF token"
|
|
796
|
+
}
|
|
797
|
+
],
|
|
798
|
+
message: "CSRF validation failed"
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
734
802
|
};
|
|
735
803
|
VrittiAuthGuard = _ts_decorate4([
|
|
736
|
-
(0,
|
|
737
|
-
scope:
|
|
804
|
+
(0, import_common5.Injectable)({
|
|
805
|
+
scope: import_common5.Scope.REQUEST
|
|
738
806
|
}),
|
|
739
807
|
_ts_metadata3("design:type", Function),
|
|
740
808
|
_ts_metadata3("design:paramtypes", [
|
|
@@ -790,6 +858,11 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
790
858
|
})
|
|
791
859
|
],
|
|
792
860
|
providers: [
|
|
861
|
+
// Required for external packages - NestJS global Reflector not available
|
|
862
|
+
{
|
|
863
|
+
provide: import_core3.Reflector,
|
|
864
|
+
useClass: import_core3.Reflector
|
|
865
|
+
},
|
|
793
866
|
{
|
|
794
867
|
provide: import_core3.APP_GUARD,
|
|
795
868
|
useClass: VrittiAuthGuard
|
|
@@ -802,21 +875,21 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
802
875
|
}
|
|
803
876
|
};
|
|
804
877
|
AuthConfigModule = _ts_decorate5([
|
|
805
|
-
(0,
|
|
806
|
-
(0,
|
|
878
|
+
(0, import_common6.Global)(),
|
|
879
|
+
(0, import_common6.Module)({})
|
|
807
880
|
], AuthConfigModule);
|
|
808
881
|
|
|
809
882
|
// src/auth/decorators/onboarding.decorator.ts
|
|
810
|
-
var
|
|
811
|
-
var Onboarding = /* @__PURE__ */ __name(() => (0,
|
|
883
|
+
var import_common7 = require("@nestjs/common");
|
|
884
|
+
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common7.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
812
885
|
|
|
813
886
|
// src/auth/decorators/public.decorator.ts
|
|
814
|
-
var
|
|
815
|
-
var Public = /* @__PURE__ */ __name(() => (0,
|
|
887
|
+
var import_common8 = require("@nestjs/common");
|
|
888
|
+
var Public = /* @__PURE__ */ __name(() => (0, import_common8.SetMetadata)("isPublic", true), "Public");
|
|
816
889
|
|
|
817
890
|
// src/auth/decorators/user-id.decorator.ts
|
|
818
|
-
var
|
|
819
|
-
var UserId = (0,
|
|
891
|
+
var import_common9 = require("@nestjs/common");
|
|
892
|
+
var UserId = (0, import_common9.createParamDecorator)((_data, ctx) => {
|
|
820
893
|
const request = ctx.switchToHttp().getRequest();
|
|
821
894
|
const user = request.user;
|
|
822
895
|
if (!user?.id) {
|
|
@@ -825,23 +898,123 @@ var UserId = (0, import_common8.createParamDecorator)((_data, ctx) => {
|
|
|
825
898
|
return user.id;
|
|
826
899
|
});
|
|
827
900
|
|
|
901
|
+
// src/auth/guards/sse-auth.guard.ts
|
|
902
|
+
var import_common10 = require("@nestjs/common");
|
|
903
|
+
var import_jwt3 = require("@nestjs/jwt");
|
|
904
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
905
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
906
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
907
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
908
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
909
|
+
}
|
|
910
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
911
|
+
function _ts_metadata4(k, v) {
|
|
912
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
913
|
+
}
|
|
914
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
915
|
+
var SSE_ALLOWED_ORIGINS = [
|
|
916
|
+
"http://localhost:5173",
|
|
917
|
+
"http://localhost:3001",
|
|
918
|
+
"http://localhost:3012",
|
|
919
|
+
"http://localhost:5174",
|
|
920
|
+
"http://local.vrittiai.com:3012",
|
|
921
|
+
"http://cloud.local.vrittiai.com:3012",
|
|
922
|
+
"https://local.vrittiai.com:3012",
|
|
923
|
+
"https://cloud.local.vrittiai.com:3012"
|
|
924
|
+
];
|
|
925
|
+
var SseAuthGuard = class _SseAuthGuard {
|
|
926
|
+
static {
|
|
927
|
+
__name(this, "SseAuthGuard");
|
|
928
|
+
}
|
|
929
|
+
jwtService;
|
|
930
|
+
logger = new import_common10.Logger(_SseAuthGuard.name);
|
|
931
|
+
constructor(jwtService) {
|
|
932
|
+
this.jwtService = jwtService;
|
|
933
|
+
}
|
|
934
|
+
async canActivate(context) {
|
|
935
|
+
const request = context.switchToHttp().getRequest();
|
|
936
|
+
const response = context.switchToHttp().getResponse();
|
|
937
|
+
this.setCorsHeaders(request, response);
|
|
938
|
+
const token = request.query?.token;
|
|
939
|
+
if (!token) {
|
|
940
|
+
this.logger.warn("SSE authentication failed: token not found in query params");
|
|
941
|
+
throw new import_common10.UnauthorizedException("Authentication required");
|
|
942
|
+
}
|
|
943
|
+
try {
|
|
944
|
+
const decodedToken = this.jwtService.decode(token);
|
|
945
|
+
if (!decodedToken) {
|
|
946
|
+
this.logger.warn("SSE authentication failed: invalid token format");
|
|
947
|
+
throw new import_common10.UnauthorizedException("Invalid token format");
|
|
948
|
+
}
|
|
949
|
+
if (decodedToken.type !== "onboarding") {
|
|
950
|
+
this.logger.warn("SSE authentication failed: endpoint requires onboarding token");
|
|
951
|
+
throw new import_common10.UnauthorizedException("This endpoint requires an onboarding token");
|
|
952
|
+
}
|
|
953
|
+
const validatedToken = this.jwtService.verify(token);
|
|
954
|
+
this.logger.debug(`SSE token validated for user: ${validatedToken.userId}`);
|
|
955
|
+
request.user = {
|
|
956
|
+
id: validatedToken.userId
|
|
957
|
+
};
|
|
958
|
+
return true;
|
|
959
|
+
} catch (error) {
|
|
960
|
+
if (error instanceof import_common10.UnauthorizedException) {
|
|
961
|
+
throw error;
|
|
962
|
+
}
|
|
963
|
+
const jwtError = error;
|
|
964
|
+
if (jwtError?.name === "TokenExpiredError") {
|
|
965
|
+
this.logger.warn("SSE authentication failed: token expired");
|
|
966
|
+
throw new import_common10.UnauthorizedException("Token has expired");
|
|
967
|
+
}
|
|
968
|
+
if (jwtError?.name === "JsonWebTokenError") {
|
|
969
|
+
this.logger.warn(`SSE authentication failed: ${jwtError?.message}`);
|
|
970
|
+
throw new import_common10.UnauthorizedException("Invalid token");
|
|
971
|
+
}
|
|
972
|
+
this.logger.error("Unexpected error in SSE auth guard", error);
|
|
973
|
+
throw new import_common10.UnauthorizedException("Authentication failed");
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Set CORS headers for SSE responses
|
|
978
|
+
* Must be called before any potential exceptions
|
|
979
|
+
*/
|
|
980
|
+
setCorsHeaders(request, response) {
|
|
981
|
+
const origin = request.headers.origin;
|
|
982
|
+
if (origin && SSE_ALLOWED_ORIGINS.includes(origin)) {
|
|
983
|
+
response.header("Access-Control-Allow-Origin", origin);
|
|
984
|
+
response.header("Access-Control-Allow-Credentials", "true");
|
|
985
|
+
this.logger.debug(`CORS headers set for origin: ${origin}`);
|
|
986
|
+
} else if (origin) {
|
|
987
|
+
this.logger.warn(`SSE request from unauthorized origin: ${origin}`);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
SseAuthGuard = _ts_decorate6([
|
|
992
|
+
(0, import_common10.Injectable)({
|
|
993
|
+
scope: import_common10.Scope.REQUEST
|
|
994
|
+
}),
|
|
995
|
+
_ts_metadata4("design:type", Function),
|
|
996
|
+
_ts_metadata4("design:paramtypes", [
|
|
997
|
+
typeof import_jwt3.JwtService === "undefined" ? Object : import_jwt3.JwtService
|
|
998
|
+
])
|
|
999
|
+
], SseAuthGuard);
|
|
1000
|
+
|
|
828
1001
|
// src/database/database.module.ts
|
|
829
|
-
var
|
|
1002
|
+
var import_common15 = require("@nestjs/common");
|
|
830
1003
|
var import_core5 = require("@nestjs/core");
|
|
831
1004
|
|
|
832
1005
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
833
|
-
var
|
|
1006
|
+
var import_common12 = require("@nestjs/common");
|
|
834
1007
|
var import_operators = require("rxjs/operators");
|
|
835
1008
|
|
|
836
1009
|
// src/database/services/tenant-context.service.ts
|
|
837
|
-
var
|
|
838
|
-
function
|
|
1010
|
+
var import_common11 = require("@nestjs/common");
|
|
1011
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
839
1012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
840
1013
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
841
1014
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
842
1015
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
843
1016
|
}
|
|
844
|
-
__name(
|
|
1017
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
845
1018
|
var TenantContextService = class {
|
|
846
1019
|
static {
|
|
847
1020
|
__name(this, "TenantContextService");
|
|
@@ -872,7 +1045,7 @@ var TenantContextService = class {
|
|
|
872
1045
|
*/
|
|
873
1046
|
getTenant() {
|
|
874
1047
|
if (!this.tenantInfo) {
|
|
875
|
-
throw new
|
|
1048
|
+
throw new import_common11.UnauthorizedException("Tenant context not set");
|
|
876
1049
|
}
|
|
877
1050
|
return this.tenantInfo;
|
|
878
1051
|
}
|
|
@@ -913,30 +1086,30 @@ var TenantContextService = class {
|
|
|
913
1086
|
return this.tenantInfo?.subdomain ?? null;
|
|
914
1087
|
}
|
|
915
1088
|
};
|
|
916
|
-
TenantContextService =
|
|
917
|
-
(0,
|
|
918
|
-
scope:
|
|
1089
|
+
TenantContextService = _ts_decorate7([
|
|
1090
|
+
(0, import_common11.Injectable)({
|
|
1091
|
+
scope: import_common11.Scope.REQUEST
|
|
919
1092
|
})
|
|
920
1093
|
], TenantContextService);
|
|
921
1094
|
|
|
922
1095
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
923
|
-
function
|
|
1096
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
924
1097
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
925
1098
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
926
1099
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
927
1100
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
928
1101
|
}
|
|
929
|
-
__name(
|
|
930
|
-
function
|
|
1102
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1103
|
+
function _ts_metadata5(k, v) {
|
|
931
1104
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
932
1105
|
}
|
|
933
|
-
__name(
|
|
1106
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
934
1107
|
var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
935
1108
|
static {
|
|
936
1109
|
__name(this, "MessageTenantContextInterceptor");
|
|
937
1110
|
}
|
|
938
1111
|
tenantContext;
|
|
939
|
-
logger = new
|
|
1112
|
+
logger = new import_common12.Logger(_MessageTenantContextInterceptor.name);
|
|
940
1113
|
constructor(tenantContext) {
|
|
941
1114
|
this.tenantContext = tenantContext;
|
|
942
1115
|
}
|
|
@@ -981,30 +1154,30 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
981
1154
|
}
|
|
982
1155
|
}
|
|
983
1156
|
};
|
|
984
|
-
MessageTenantContextInterceptor =
|
|
985
|
-
(0,
|
|
986
|
-
scope:
|
|
1157
|
+
MessageTenantContextInterceptor = _ts_decorate8([
|
|
1158
|
+
(0, import_common12.Injectable)({
|
|
1159
|
+
scope: import_common12.Scope.REQUEST
|
|
987
1160
|
}),
|
|
988
|
-
|
|
989
|
-
|
|
1161
|
+
_ts_metadata5("design:type", Function),
|
|
1162
|
+
_ts_metadata5("design:paramtypes", [
|
|
990
1163
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
991
1164
|
])
|
|
992
1165
|
], MessageTenantContextInterceptor);
|
|
993
1166
|
|
|
994
1167
|
// src/database/interceptors/tenant-context.interceptor.ts
|
|
995
|
-
var
|
|
1168
|
+
var import_common13 = require("@nestjs/common");
|
|
996
1169
|
var import_core4 = require("@nestjs/core");
|
|
997
|
-
function
|
|
1170
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
998
1171
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
999
1172
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1000
1173
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1001
1174
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1002
1175
|
}
|
|
1003
|
-
__name(
|
|
1004
|
-
function
|
|
1176
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1177
|
+
function _ts_metadata6(k, v) {
|
|
1005
1178
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1006
1179
|
}
|
|
1007
|
-
__name(
|
|
1180
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1008
1181
|
var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
1009
1182
|
static {
|
|
1010
1183
|
__name(this, "TenantContextInterceptor");
|
|
@@ -1013,7 +1186,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1013
1186
|
tenantContext;
|
|
1014
1187
|
primaryDatabase;
|
|
1015
1188
|
requestService;
|
|
1016
|
-
logger = new
|
|
1189
|
+
logger = new import_common13.Logger(_TenantContextInterceptor.name);
|
|
1017
1190
|
constructor(reflector, tenantContext, primaryDatabase, requestService) {
|
|
1018
1191
|
this.reflector = reflector;
|
|
1019
1192
|
this.tenantContext = tenantContext;
|
|
@@ -1034,7 +1207,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1034
1207
|
return next.handle();
|
|
1035
1208
|
}
|
|
1036
1209
|
if (!tenantIdentifier) {
|
|
1037
|
-
throw new
|
|
1210
|
+
throw new import_common13.UnauthorizedException("Tenant identifier not found in request");
|
|
1038
1211
|
}
|
|
1039
1212
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
1040
1213
|
if (tenantIdentifier === "cloud") {
|
|
@@ -1044,11 +1217,11 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1044
1217
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
1045
1218
|
if (!tenantInfo) {
|
|
1046
1219
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
1047
|
-
throw new
|
|
1220
|
+
throw new import_common13.UnauthorizedException("Invalid tenant");
|
|
1048
1221
|
}
|
|
1049
1222
|
if (tenantInfo.status !== "ACTIVE") {
|
|
1050
1223
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
1051
|
-
throw new
|
|
1224
|
+
throw new import_common13.UnauthorizedException(`Tenant is ${tenantInfo.status}`);
|
|
1052
1225
|
}
|
|
1053
1226
|
this.logger.debug(`Tenant config loaded: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
1054
1227
|
this.tenantContext.setTenant(tenantInfo);
|
|
@@ -1061,12 +1234,12 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1061
1234
|
return next.handle();
|
|
1062
1235
|
}
|
|
1063
1236
|
};
|
|
1064
|
-
TenantContextInterceptor =
|
|
1065
|
-
(0,
|
|
1066
|
-
scope:
|
|
1237
|
+
TenantContextInterceptor = _ts_decorate9([
|
|
1238
|
+
(0, import_common13.Injectable)({
|
|
1239
|
+
scope: import_common13.Scope.REQUEST
|
|
1067
1240
|
}),
|
|
1068
|
-
|
|
1069
|
-
|
|
1241
|
+
_ts_metadata6("design:type", Function),
|
|
1242
|
+
_ts_metadata6("design:paramtypes", [
|
|
1070
1243
|
typeof import_core4.Reflector === "undefined" ? Object : import_core4.Reflector,
|
|
1071
1244
|
typeof TenantContextService === "undefined" ? Object : TenantContextService,
|
|
1072
1245
|
typeof PrimaryDatabaseService === "undefined" ? Object : PrimaryDatabaseService,
|
|
@@ -1075,20 +1248,20 @@ TenantContextInterceptor = _ts_decorate8([
|
|
|
1075
1248
|
], TenantContextInterceptor);
|
|
1076
1249
|
|
|
1077
1250
|
// src/database/services/tenant-database.service.ts
|
|
1078
|
-
var
|
|
1251
|
+
var import_common14 = require("@nestjs/common");
|
|
1079
1252
|
var import_node_postgres2 = require("drizzle-orm/node-postgres");
|
|
1080
1253
|
var import_pg2 = require("pg");
|
|
1081
|
-
function
|
|
1254
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1082
1255
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1083
1256
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1084
1257
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1085
1258
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1086
1259
|
}
|
|
1087
|
-
__name(
|
|
1088
|
-
function
|
|
1260
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1261
|
+
function _ts_metadata7(k, v) {
|
|
1089
1262
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1090
1263
|
}
|
|
1091
|
-
__name(
|
|
1264
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1092
1265
|
function _ts_param3(paramIndex, decorator) {
|
|
1093
1266
|
return function(target, key) {
|
|
1094
1267
|
decorator(target, key, paramIndex);
|
|
@@ -1101,7 +1274,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1101
1274
|
}
|
|
1102
1275
|
options;
|
|
1103
1276
|
tenantContext;
|
|
1104
|
-
logger = new
|
|
1277
|
+
logger = new import_common14.Logger(_TenantDatabaseService.name);
|
|
1105
1278
|
/** Connection pool: Map<cacheKey, TenantConnection> */
|
|
1106
1279
|
clients = /* @__PURE__ */ new Map();
|
|
1107
1280
|
/** Track last usage time for idle connection cleanup */
|
|
@@ -1178,7 +1351,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1178
1351
|
};
|
|
1179
1352
|
} catch (error) {
|
|
1180
1353
|
this.logger.error(`Failed to create database connection for tenant: ${tenant.subdomain}`, error);
|
|
1181
|
-
throw new
|
|
1354
|
+
throw new import_common14.InternalServerErrorException("Failed to connect to tenant database");
|
|
1182
1355
|
}
|
|
1183
1356
|
}
|
|
1184
1357
|
/**
|
|
@@ -1270,24 +1443,24 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1270
1443
|
this.logger.log("All database connections closed");
|
|
1271
1444
|
}
|
|
1272
1445
|
};
|
|
1273
|
-
TenantDatabaseService =
|
|
1274
|
-
(0,
|
|
1275
|
-
_ts_param3(0, (0,
|
|
1276
|
-
|
|
1277
|
-
|
|
1446
|
+
TenantDatabaseService = _ts_decorate10([
|
|
1447
|
+
(0, import_common14.Injectable)(),
|
|
1448
|
+
_ts_param3(0, (0, import_common14.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1449
|
+
_ts_metadata7("design:type", Function),
|
|
1450
|
+
_ts_metadata7("design:paramtypes", [
|
|
1278
1451
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
1279
1452
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
1280
1453
|
])
|
|
1281
1454
|
], TenantDatabaseService);
|
|
1282
1455
|
|
|
1283
1456
|
// src/database/database.module.ts
|
|
1284
|
-
function
|
|
1457
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1285
1458
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1286
1459
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1287
1460
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1288
1461
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1289
1462
|
}
|
|
1290
|
-
__name(
|
|
1463
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1291
1464
|
var DatabaseModule = class _DatabaseModule {
|
|
1292
1465
|
static {
|
|
1293
1466
|
__name(this, "DatabaseModule");
|
|
@@ -1358,6 +1531,11 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1358
1531
|
inject: options.inject || []
|
|
1359
1532
|
};
|
|
1360
1533
|
const providers = [
|
|
1534
|
+
// Required for external packages - NestJS global Reflector not available
|
|
1535
|
+
{
|
|
1536
|
+
provide: import_core5.Reflector,
|
|
1537
|
+
useClass: import_core5.Reflector
|
|
1538
|
+
},
|
|
1361
1539
|
asyncProvider,
|
|
1362
1540
|
TenantContextService,
|
|
1363
1541
|
PrimaryDatabaseService,
|
|
@@ -1389,14 +1567,14 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1389
1567
|
};
|
|
1390
1568
|
}
|
|
1391
1569
|
};
|
|
1392
|
-
DatabaseModule =
|
|
1393
|
-
(0,
|
|
1394
|
-
(0,
|
|
1570
|
+
DatabaseModule = _ts_decorate11([
|
|
1571
|
+
(0, import_common15.Global)(),
|
|
1572
|
+
(0, import_common15.Module)({})
|
|
1395
1573
|
], DatabaseModule);
|
|
1396
1574
|
|
|
1397
1575
|
// src/database/decorators/tenant.decorator.ts
|
|
1398
|
-
var
|
|
1399
|
-
var Tenant = (0,
|
|
1576
|
+
var import_common16 = require("@nestjs/common");
|
|
1577
|
+
var Tenant = (0, import_common16.createParamDecorator)((_data, ctx) => {
|
|
1400
1578
|
const request = ctx.switchToHttp().getRequest();
|
|
1401
1579
|
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1402
1580
|
if (!tenantContext) {
|
|
@@ -1406,7 +1584,7 @@ var Tenant = (0, import_common14.createParamDecorator)((_data, ctx) => {
|
|
|
1406
1584
|
});
|
|
1407
1585
|
|
|
1408
1586
|
// src/database/repositories/primary-base.repository.ts
|
|
1409
|
-
var
|
|
1587
|
+
var import_common17 = require("@nestjs/common");
|
|
1410
1588
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
1411
1589
|
function snakeToCamel(str) {
|
|
1412
1590
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1477,7 +1655,7 @@ var PrimaryBaseRepository = class {
|
|
|
1477
1655
|
this.table = table;
|
|
1478
1656
|
const dbTableName = (0, import_drizzle_orm2.getTableName)(table);
|
|
1479
1657
|
this.tableName = snakeToCamel(dbTableName);
|
|
1480
|
-
this.logger = new
|
|
1658
|
+
this.logger = new import_common17.Logger(this.constructor.name);
|
|
1481
1659
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1482
1660
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1483
1661
|
}
|
|
@@ -1717,7 +1895,7 @@ var PrimaryBaseRepository = class {
|
|
|
1717
1895
|
};
|
|
1718
1896
|
|
|
1719
1897
|
// src/database/repositories/tenant-base.repository.ts
|
|
1720
|
-
var
|
|
1898
|
+
var import_common18 = require("@nestjs/common");
|
|
1721
1899
|
var import_drizzle_orm3 = require("drizzle-orm");
|
|
1722
1900
|
var TenantBaseRepository = class {
|
|
1723
1901
|
static {
|
|
@@ -1774,7 +1952,7 @@ var TenantBaseRepository = class {
|
|
|
1774
1952
|
this.database = database;
|
|
1775
1953
|
this.table = table;
|
|
1776
1954
|
this.tableName = (0, import_drizzle_orm3.getTableName)(table);
|
|
1777
|
-
this.logger = new
|
|
1955
|
+
this.logger = new import_common18.Logger(this.constructor.name);
|
|
1778
1956
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1779
1957
|
}
|
|
1780
1958
|
/**
|
|
@@ -2007,11 +2185,11 @@ var TenantBaseRepository = class {
|
|
|
2007
2185
|
};
|
|
2008
2186
|
|
|
2009
2187
|
// src/exceptions/bad-gateway.exception.ts
|
|
2010
|
-
var
|
|
2188
|
+
var import_common20 = require("@nestjs/common");
|
|
2011
2189
|
|
|
2012
2190
|
// src/exceptions/base-field.exception.ts
|
|
2013
|
-
var
|
|
2014
|
-
var BaseFieldException = class extends
|
|
2191
|
+
var import_common19 = require("@nestjs/common");
|
|
2192
|
+
var BaseFieldException = class extends import_common19.HttpException {
|
|
2015
2193
|
static {
|
|
2016
2194
|
__name(this, "BaseFieldException");
|
|
2017
2195
|
}
|
|
@@ -2021,7 +2199,7 @@ var BaseFieldException = class extends import_common17.HttpException {
|
|
|
2021
2199
|
let finalDetail;
|
|
2022
2200
|
if (Array.isArray(statusOrMessageOrErrors)) {
|
|
2023
2201
|
errors = statusOrMessageOrErrors;
|
|
2024
|
-
httpStatus = messageOrStatus ||
|
|
2202
|
+
httpStatus = messageOrStatus || import_common19.HttpStatus.BAD_REQUEST;
|
|
2025
2203
|
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2026
2204
|
} else if (typeof statusOrMessageOrErrors === "string" && typeof messageOrStatus === "string") {
|
|
2027
2205
|
errors = [
|
|
@@ -2066,343 +2244,343 @@ var BadGatewayException = class extends BaseFieldException {
|
|
|
2066
2244
|
}
|
|
2067
2245
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2068
2246
|
if (Array.isArray(messageOrField)) {
|
|
2069
|
-
super(messageOrField,
|
|
2247
|
+
super(messageOrField, import_common20.HttpStatus.BAD_GATEWAY, fieldMessageOrDetail);
|
|
2070
2248
|
} else if (detail !== void 0) {
|
|
2071
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2249
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.BAD_GATEWAY, detail);
|
|
2072
2250
|
} else if (fieldMessageOrDetail) {
|
|
2073
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2251
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.BAD_GATEWAY);
|
|
2074
2252
|
} else {
|
|
2075
|
-
super(messageOrField,
|
|
2253
|
+
super(messageOrField, import_common20.HttpStatus.BAD_GATEWAY);
|
|
2076
2254
|
}
|
|
2077
2255
|
}
|
|
2078
2256
|
};
|
|
2079
2257
|
|
|
2080
2258
|
// src/exceptions/bad-request.exception.ts
|
|
2081
|
-
var
|
|
2259
|
+
var import_common21 = require("@nestjs/common");
|
|
2082
2260
|
var BadRequestException = class extends BaseFieldException {
|
|
2083
2261
|
static {
|
|
2084
2262
|
__name(this, "BadRequestException");
|
|
2085
2263
|
}
|
|
2086
2264
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2087
2265
|
if (Array.isArray(messageOrField)) {
|
|
2088
|
-
super(messageOrField,
|
|
2266
|
+
super(messageOrField, import_common21.HttpStatus.BAD_REQUEST, fieldMessageOrDetail);
|
|
2089
2267
|
} else if (detail !== void 0) {
|
|
2090
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2268
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.BAD_REQUEST, detail);
|
|
2091
2269
|
} else if (fieldMessageOrDetail) {
|
|
2092
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2270
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.BAD_REQUEST);
|
|
2093
2271
|
} else {
|
|
2094
|
-
super(messageOrField,
|
|
2272
|
+
super(messageOrField, import_common21.HttpStatus.BAD_REQUEST);
|
|
2095
2273
|
}
|
|
2096
2274
|
}
|
|
2097
2275
|
};
|
|
2098
2276
|
|
|
2099
2277
|
// src/exceptions/conflict.exception.ts
|
|
2100
|
-
var
|
|
2278
|
+
var import_common22 = require("@nestjs/common");
|
|
2101
2279
|
var ConflictException = class extends BaseFieldException {
|
|
2102
2280
|
static {
|
|
2103
2281
|
__name(this, "ConflictException");
|
|
2104
2282
|
}
|
|
2105
2283
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2106
2284
|
if (Array.isArray(messageOrField)) {
|
|
2107
|
-
super(messageOrField,
|
|
2285
|
+
super(messageOrField, import_common22.HttpStatus.CONFLICT, fieldMessageOrDetail);
|
|
2108
2286
|
} else if (detail !== void 0) {
|
|
2109
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2287
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.CONFLICT, detail);
|
|
2110
2288
|
} else if (fieldMessageOrDetail) {
|
|
2111
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2289
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.CONFLICT);
|
|
2112
2290
|
} else {
|
|
2113
|
-
super(messageOrField,
|
|
2291
|
+
super(messageOrField, import_common22.HttpStatus.CONFLICT);
|
|
2114
2292
|
}
|
|
2115
2293
|
}
|
|
2116
2294
|
};
|
|
2117
2295
|
|
|
2118
2296
|
// src/exceptions/forbidden.exception.ts
|
|
2119
|
-
var
|
|
2120
|
-
var
|
|
2297
|
+
var import_common23 = require("@nestjs/common");
|
|
2298
|
+
var ForbiddenException2 = class extends BaseFieldException {
|
|
2121
2299
|
static {
|
|
2122
2300
|
__name(this, "ForbiddenException");
|
|
2123
2301
|
}
|
|
2124
2302
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2125
2303
|
if (Array.isArray(messageOrField)) {
|
|
2126
|
-
super(messageOrField,
|
|
2304
|
+
super(messageOrField, import_common23.HttpStatus.FORBIDDEN, fieldMessageOrDetail);
|
|
2127
2305
|
} else if (detail !== void 0) {
|
|
2128
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2306
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.FORBIDDEN, detail);
|
|
2129
2307
|
} else if (fieldMessageOrDetail) {
|
|
2130
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2308
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.FORBIDDEN);
|
|
2131
2309
|
} else {
|
|
2132
|
-
super(messageOrField,
|
|
2310
|
+
super(messageOrField, import_common23.HttpStatus.FORBIDDEN);
|
|
2133
2311
|
}
|
|
2134
2312
|
}
|
|
2135
2313
|
};
|
|
2136
2314
|
|
|
2137
2315
|
// src/exceptions/gone.exception.ts
|
|
2138
|
-
var
|
|
2316
|
+
var import_common24 = require("@nestjs/common");
|
|
2139
2317
|
var GoneException = class extends BaseFieldException {
|
|
2140
2318
|
static {
|
|
2141
2319
|
__name(this, "GoneException");
|
|
2142
2320
|
}
|
|
2143
2321
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2144
2322
|
if (Array.isArray(messageOrField)) {
|
|
2145
|
-
super(messageOrField,
|
|
2323
|
+
super(messageOrField, import_common24.HttpStatus.GONE, fieldMessageOrDetail);
|
|
2146
2324
|
} else if (detail !== void 0) {
|
|
2147
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2325
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.GONE, detail);
|
|
2148
2326
|
} else if (fieldMessageOrDetail) {
|
|
2149
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2327
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.GONE);
|
|
2150
2328
|
} else {
|
|
2151
|
-
super(messageOrField,
|
|
2329
|
+
super(messageOrField, import_common24.HttpStatus.GONE);
|
|
2152
2330
|
}
|
|
2153
2331
|
}
|
|
2154
2332
|
};
|
|
2155
2333
|
|
|
2156
2334
|
// src/exceptions/internal-server-error.exception.ts
|
|
2157
|
-
var
|
|
2335
|
+
var import_common25 = require("@nestjs/common");
|
|
2158
2336
|
var InternalServerErrorException3 = class extends BaseFieldException {
|
|
2159
2337
|
static {
|
|
2160
2338
|
__name(this, "InternalServerErrorException");
|
|
2161
2339
|
}
|
|
2162
2340
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2163
2341
|
if (Array.isArray(messageOrField)) {
|
|
2164
|
-
super(messageOrField,
|
|
2342
|
+
super(messageOrField, import_common25.HttpStatus.INTERNAL_SERVER_ERROR, fieldMessageOrDetail);
|
|
2165
2343
|
} else if (detail !== void 0) {
|
|
2166
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2344
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.INTERNAL_SERVER_ERROR, detail);
|
|
2167
2345
|
} else if (fieldMessageOrDetail) {
|
|
2168
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2346
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2169
2347
|
} else {
|
|
2170
|
-
super(messageOrField,
|
|
2348
|
+
super(messageOrField, import_common25.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2171
2349
|
}
|
|
2172
2350
|
}
|
|
2173
2351
|
};
|
|
2174
2352
|
|
|
2175
2353
|
// src/exceptions/method-not-allowed.exception.ts
|
|
2176
|
-
var
|
|
2354
|
+
var import_common26 = require("@nestjs/common");
|
|
2177
2355
|
var MethodNotAllowedException = class extends BaseFieldException {
|
|
2178
2356
|
static {
|
|
2179
2357
|
__name(this, "MethodNotAllowedException");
|
|
2180
2358
|
}
|
|
2181
2359
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2182
2360
|
if (Array.isArray(messageOrField)) {
|
|
2183
|
-
super(messageOrField,
|
|
2361
|
+
super(messageOrField, import_common26.HttpStatus.METHOD_NOT_ALLOWED, fieldMessageOrDetail);
|
|
2184
2362
|
} else if (detail !== void 0) {
|
|
2185
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2363
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.METHOD_NOT_ALLOWED, detail);
|
|
2186
2364
|
} else if (fieldMessageOrDetail) {
|
|
2187
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2365
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2188
2366
|
} else {
|
|
2189
|
-
super(messageOrField,
|
|
2367
|
+
super(messageOrField, import_common26.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2190
2368
|
}
|
|
2191
2369
|
}
|
|
2192
2370
|
};
|
|
2193
2371
|
|
|
2194
2372
|
// src/exceptions/not-acceptable.exception.ts
|
|
2195
|
-
var
|
|
2373
|
+
var import_common27 = require("@nestjs/common");
|
|
2196
2374
|
var NotAcceptableException = class extends BaseFieldException {
|
|
2197
2375
|
static {
|
|
2198
2376
|
__name(this, "NotAcceptableException");
|
|
2199
2377
|
}
|
|
2200
2378
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2201
2379
|
if (Array.isArray(messageOrField)) {
|
|
2202
|
-
super(messageOrField,
|
|
2380
|
+
super(messageOrField, import_common27.HttpStatus.NOT_ACCEPTABLE, fieldMessageOrDetail);
|
|
2203
2381
|
} else if (detail !== void 0) {
|
|
2204
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2382
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.NOT_ACCEPTABLE, detail);
|
|
2205
2383
|
} else if (fieldMessageOrDetail) {
|
|
2206
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2384
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.NOT_ACCEPTABLE);
|
|
2207
2385
|
} else {
|
|
2208
|
-
super(messageOrField,
|
|
2386
|
+
super(messageOrField, import_common27.HttpStatus.NOT_ACCEPTABLE);
|
|
2209
2387
|
}
|
|
2210
2388
|
}
|
|
2211
2389
|
};
|
|
2212
2390
|
|
|
2213
2391
|
// src/exceptions/not-found.exception.ts
|
|
2214
|
-
var
|
|
2392
|
+
var import_common28 = require("@nestjs/common");
|
|
2215
2393
|
var NotFoundException = class extends BaseFieldException {
|
|
2216
2394
|
static {
|
|
2217
2395
|
__name(this, "NotFoundException");
|
|
2218
2396
|
}
|
|
2219
2397
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2220
2398
|
if (Array.isArray(messageOrField)) {
|
|
2221
|
-
super(messageOrField,
|
|
2399
|
+
super(messageOrField, import_common28.HttpStatus.NOT_FOUND, fieldMessageOrDetail);
|
|
2222
2400
|
} else if (detail !== void 0) {
|
|
2223
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2401
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.NOT_FOUND, detail);
|
|
2224
2402
|
} else if (fieldMessageOrDetail) {
|
|
2225
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2403
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.NOT_FOUND);
|
|
2226
2404
|
} else {
|
|
2227
|
-
super(messageOrField,
|
|
2405
|
+
super(messageOrField, import_common28.HttpStatus.NOT_FOUND);
|
|
2228
2406
|
}
|
|
2229
2407
|
}
|
|
2230
2408
|
};
|
|
2231
2409
|
|
|
2232
2410
|
// src/exceptions/not-implemented.exception.ts
|
|
2233
|
-
var
|
|
2411
|
+
var import_common29 = require("@nestjs/common");
|
|
2234
2412
|
var NotImplementedException = class extends BaseFieldException {
|
|
2235
2413
|
static {
|
|
2236
2414
|
__name(this, "NotImplementedException");
|
|
2237
2415
|
}
|
|
2238
2416
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2239
2417
|
if (Array.isArray(messageOrField)) {
|
|
2240
|
-
super(messageOrField,
|
|
2418
|
+
super(messageOrField, import_common29.HttpStatus.NOT_IMPLEMENTED, fieldMessageOrDetail);
|
|
2241
2419
|
} else if (detail !== void 0) {
|
|
2242
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2420
|
+
super(messageOrField, fieldMessageOrDetail, import_common29.HttpStatus.NOT_IMPLEMENTED, detail);
|
|
2243
2421
|
} else if (fieldMessageOrDetail) {
|
|
2244
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2422
|
+
super(messageOrField, fieldMessageOrDetail, import_common29.HttpStatus.NOT_IMPLEMENTED);
|
|
2245
2423
|
} else {
|
|
2246
|
-
super(messageOrField,
|
|
2424
|
+
super(messageOrField, import_common29.HttpStatus.NOT_IMPLEMENTED);
|
|
2247
2425
|
}
|
|
2248
2426
|
}
|
|
2249
2427
|
};
|
|
2250
2428
|
|
|
2251
2429
|
// src/exceptions/payload-too-large.exception.ts
|
|
2252
|
-
var
|
|
2430
|
+
var import_common30 = require("@nestjs/common");
|
|
2253
2431
|
var PayloadTooLargeException = class extends BaseFieldException {
|
|
2254
2432
|
static {
|
|
2255
2433
|
__name(this, "PayloadTooLargeException");
|
|
2256
2434
|
}
|
|
2257
2435
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2258
2436
|
if (Array.isArray(messageOrField)) {
|
|
2259
|
-
super(messageOrField,
|
|
2437
|
+
super(messageOrField, import_common30.HttpStatus.PAYLOAD_TOO_LARGE, fieldMessageOrDetail);
|
|
2260
2438
|
} else if (detail !== void 0) {
|
|
2261
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2439
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.PAYLOAD_TOO_LARGE, detail);
|
|
2262
2440
|
} else if (fieldMessageOrDetail) {
|
|
2263
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2441
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2264
2442
|
} else {
|
|
2265
|
-
super(messageOrField,
|
|
2443
|
+
super(messageOrField, import_common30.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2266
2444
|
}
|
|
2267
2445
|
}
|
|
2268
2446
|
};
|
|
2269
2447
|
|
|
2270
2448
|
// src/exceptions/request-timeout.exception.ts
|
|
2271
|
-
var
|
|
2449
|
+
var import_common31 = require("@nestjs/common");
|
|
2272
2450
|
var RequestTimeoutException = class extends BaseFieldException {
|
|
2273
2451
|
static {
|
|
2274
2452
|
__name(this, "RequestTimeoutException");
|
|
2275
2453
|
}
|
|
2276
2454
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2277
2455
|
if (Array.isArray(messageOrField)) {
|
|
2278
|
-
super(messageOrField,
|
|
2456
|
+
super(messageOrField, import_common31.HttpStatus.REQUEST_TIMEOUT, fieldMessageOrDetail);
|
|
2279
2457
|
} else if (detail !== void 0) {
|
|
2280
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2458
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.REQUEST_TIMEOUT, detail);
|
|
2281
2459
|
} else if (fieldMessageOrDetail) {
|
|
2282
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2460
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.REQUEST_TIMEOUT);
|
|
2283
2461
|
} else {
|
|
2284
|
-
super(messageOrField,
|
|
2462
|
+
super(messageOrField, import_common31.HttpStatus.REQUEST_TIMEOUT);
|
|
2285
2463
|
}
|
|
2286
2464
|
}
|
|
2287
2465
|
};
|
|
2288
2466
|
|
|
2289
2467
|
// src/exceptions/service-unavailable.exception.ts
|
|
2290
|
-
var
|
|
2468
|
+
var import_common32 = require("@nestjs/common");
|
|
2291
2469
|
var ServiceUnavailableException = class extends BaseFieldException {
|
|
2292
2470
|
static {
|
|
2293
2471
|
__name(this, "ServiceUnavailableException");
|
|
2294
2472
|
}
|
|
2295
2473
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2296
2474
|
if (Array.isArray(messageOrField)) {
|
|
2297
|
-
super(messageOrField,
|
|
2475
|
+
super(messageOrField, import_common32.HttpStatus.SERVICE_UNAVAILABLE, fieldMessageOrDetail);
|
|
2298
2476
|
} else if (detail !== void 0) {
|
|
2299
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2477
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.SERVICE_UNAVAILABLE, detail);
|
|
2300
2478
|
} else if (fieldMessageOrDetail) {
|
|
2301
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2479
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.SERVICE_UNAVAILABLE);
|
|
2302
2480
|
} else {
|
|
2303
|
-
super(messageOrField,
|
|
2481
|
+
super(messageOrField, import_common32.HttpStatus.SERVICE_UNAVAILABLE);
|
|
2304
2482
|
}
|
|
2305
2483
|
}
|
|
2306
2484
|
};
|
|
2307
2485
|
|
|
2308
2486
|
// src/exceptions/too-many-requests.exception.ts
|
|
2309
|
-
var
|
|
2487
|
+
var import_common33 = require("@nestjs/common");
|
|
2310
2488
|
var TooManyRequestsException = class extends BaseFieldException {
|
|
2311
2489
|
static {
|
|
2312
2490
|
__name(this, "TooManyRequestsException");
|
|
2313
2491
|
}
|
|
2314
2492
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2315
2493
|
if (Array.isArray(messageOrField)) {
|
|
2316
|
-
super(messageOrField,
|
|
2494
|
+
super(messageOrField, import_common33.HttpStatus.TOO_MANY_REQUESTS, fieldMessageOrDetail);
|
|
2317
2495
|
} else if (detail !== void 0) {
|
|
2318
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2496
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.TOO_MANY_REQUESTS, detail);
|
|
2319
2497
|
} else if (fieldMessageOrDetail) {
|
|
2320
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2498
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.TOO_MANY_REQUESTS);
|
|
2321
2499
|
} else {
|
|
2322
|
-
super(messageOrField,
|
|
2500
|
+
super(messageOrField, import_common33.HttpStatus.TOO_MANY_REQUESTS);
|
|
2323
2501
|
}
|
|
2324
2502
|
}
|
|
2325
2503
|
};
|
|
2326
2504
|
|
|
2327
2505
|
// src/exceptions/unauthorized.exception.ts
|
|
2328
|
-
var
|
|
2329
|
-
var
|
|
2506
|
+
var import_common34 = require("@nestjs/common");
|
|
2507
|
+
var UnauthorizedException5 = class extends BaseFieldException {
|
|
2330
2508
|
static {
|
|
2331
2509
|
__name(this, "UnauthorizedException");
|
|
2332
2510
|
}
|
|
2333
2511
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2334
2512
|
if (Array.isArray(messageOrField)) {
|
|
2335
|
-
super(messageOrField,
|
|
2513
|
+
super(messageOrField, import_common34.HttpStatus.UNAUTHORIZED, fieldMessageOrDetail);
|
|
2336
2514
|
} else if (detail !== void 0) {
|
|
2337
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2515
|
+
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.UNAUTHORIZED, detail);
|
|
2338
2516
|
} else if (fieldMessageOrDetail) {
|
|
2339
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2517
|
+
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.UNAUTHORIZED);
|
|
2340
2518
|
} else {
|
|
2341
|
-
super(messageOrField,
|
|
2519
|
+
super(messageOrField, import_common34.HttpStatus.UNAUTHORIZED);
|
|
2342
2520
|
}
|
|
2343
2521
|
}
|
|
2344
2522
|
};
|
|
2345
2523
|
|
|
2346
2524
|
// src/exceptions/unprocessable-entity.exception.ts
|
|
2347
|
-
var
|
|
2525
|
+
var import_common35 = require("@nestjs/common");
|
|
2348
2526
|
var UnprocessableEntityException = class extends BaseFieldException {
|
|
2349
2527
|
static {
|
|
2350
2528
|
__name(this, "UnprocessableEntityException");
|
|
2351
2529
|
}
|
|
2352
2530
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2353
2531
|
if (Array.isArray(messageOrField)) {
|
|
2354
|
-
super(messageOrField,
|
|
2532
|
+
super(messageOrField, import_common35.HttpStatus.UNPROCESSABLE_ENTITY, fieldMessageOrDetail);
|
|
2355
2533
|
} else if (detail !== void 0) {
|
|
2356
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2534
|
+
super(messageOrField, fieldMessageOrDetail, import_common35.HttpStatus.UNPROCESSABLE_ENTITY, detail);
|
|
2357
2535
|
} else if (fieldMessageOrDetail) {
|
|
2358
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2536
|
+
super(messageOrField, fieldMessageOrDetail, import_common35.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2359
2537
|
} else {
|
|
2360
|
-
super(messageOrField,
|
|
2538
|
+
super(messageOrField, import_common35.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2361
2539
|
}
|
|
2362
2540
|
}
|
|
2363
2541
|
};
|
|
2364
2542
|
|
|
2365
2543
|
// src/exceptions/unsupported-media-type.exception.ts
|
|
2366
|
-
var
|
|
2544
|
+
var import_common36 = require("@nestjs/common");
|
|
2367
2545
|
var UnsupportedMediaTypeException = class extends BaseFieldException {
|
|
2368
2546
|
static {
|
|
2369
2547
|
__name(this, "UnsupportedMediaTypeException");
|
|
2370
2548
|
}
|
|
2371
2549
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2372
2550
|
if (Array.isArray(messageOrField)) {
|
|
2373
|
-
super(messageOrField,
|
|
2551
|
+
super(messageOrField, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE, fieldMessageOrDetail);
|
|
2374
2552
|
} else if (detail !== void 0) {
|
|
2375
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2553
|
+
super(messageOrField, fieldMessageOrDetail, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE, detail);
|
|
2376
2554
|
} else if (fieldMessageOrDetail) {
|
|
2377
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2555
|
+
super(messageOrField, fieldMessageOrDetail, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2378
2556
|
} else {
|
|
2379
|
-
super(messageOrField,
|
|
2557
|
+
super(messageOrField, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2380
2558
|
}
|
|
2381
2559
|
}
|
|
2382
2560
|
};
|
|
2383
2561
|
|
|
2384
2562
|
// src/exceptions/validation.exception.ts
|
|
2385
|
-
var
|
|
2563
|
+
var import_common37 = require("@nestjs/common");
|
|
2386
2564
|
var ValidationException = class extends BaseFieldException {
|
|
2387
2565
|
static {
|
|
2388
2566
|
__name(this, "ValidationException");
|
|
2389
2567
|
}
|
|
2390
2568
|
constructor(errors, detail) {
|
|
2391
|
-
super(errors,
|
|
2569
|
+
super(errors, import_common37.HttpStatus.BAD_REQUEST, detail);
|
|
2392
2570
|
}
|
|
2393
2571
|
};
|
|
2394
2572
|
|
|
2395
2573
|
// src/filters/http-exception.filter.ts
|
|
2396
|
-
var
|
|
2397
|
-
function
|
|
2574
|
+
var import_common38 = require("@nestjs/common");
|
|
2575
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2398
2576
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2399
2577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2400
2578
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2401
2579
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2402
2580
|
}
|
|
2403
|
-
__name(
|
|
2581
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2404
2582
|
function getHttpStatusTitle(status) {
|
|
2405
|
-
const enumKey = Object.entries(
|
|
2583
|
+
const enumKey = Object.entries(import_common38.HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2406
2584
|
if (!enumKey) {
|
|
2407
2585
|
return "Error";
|
|
2408
2586
|
}
|
|
@@ -2413,14 +2591,14 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2413
2591
|
static {
|
|
2414
2592
|
__name(this, "HttpExceptionFilter");
|
|
2415
2593
|
}
|
|
2416
|
-
logger = new
|
|
2594
|
+
logger = new import_common38.Logger(_HttpExceptionFilter.name);
|
|
2417
2595
|
catch(exception, host) {
|
|
2418
2596
|
const ctx = host.switchToHttp();
|
|
2419
2597
|
const response = ctx.getResponse();
|
|
2420
|
-
let status =
|
|
2598
|
+
let status = import_common38.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2421
2599
|
let errors = [];
|
|
2422
2600
|
let detail = "Internal server error";
|
|
2423
|
-
if (exception instanceof
|
|
2601
|
+
if (exception instanceof import_common38.HttpException) {
|
|
2424
2602
|
status = exception.getStatus();
|
|
2425
2603
|
const exceptionResponse = exception.getResponse();
|
|
2426
2604
|
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
@@ -2478,25 +2656,45 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2478
2656
|
response.status(status).send(problemDetails);
|
|
2479
2657
|
}
|
|
2480
2658
|
};
|
|
2481
|
-
HttpExceptionFilter =
|
|
2482
|
-
(0,
|
|
2659
|
+
HttpExceptionFilter = _ts_decorate12([
|
|
2660
|
+
(0, import_common38.Catch)()
|
|
2483
2661
|
], HttpExceptionFilter);
|
|
2484
2662
|
|
|
2663
|
+
// src/http/http.module.ts
|
|
2664
|
+
var import_common40 = require("@nestjs/common");
|
|
2665
|
+
|
|
2485
2666
|
// src/http/guards/csrf.guard.ts
|
|
2486
|
-
var
|
|
2487
|
-
|
|
2667
|
+
var import_common39 = require("@nestjs/common");
|
|
2668
|
+
var import_core6 = require("@nestjs/core");
|
|
2669
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2488
2670
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2489
2671
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2490
2672
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2491
2673
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2492
2674
|
}
|
|
2493
|
-
__name(
|
|
2675
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2676
|
+
function _ts_metadata8(k, v) {
|
|
2677
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2678
|
+
}
|
|
2679
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2494
2680
|
var CsrfGuard = class _CsrfGuard {
|
|
2495
2681
|
static {
|
|
2496
2682
|
__name(this, "CsrfGuard");
|
|
2497
2683
|
}
|
|
2498
|
-
|
|
2684
|
+
reflector;
|
|
2685
|
+
logger = new import_common39.Logger(_CsrfGuard.name);
|
|
2686
|
+
constructor(reflector) {
|
|
2687
|
+
this.reflector = reflector;
|
|
2688
|
+
}
|
|
2499
2689
|
async canActivate(context) {
|
|
2690
|
+
const skipCsrf = this.reflector.getAllAndOverride(SKIP_CSRF_KEY, [
|
|
2691
|
+
context.getHandler(),
|
|
2692
|
+
context.getClass()
|
|
2693
|
+
]);
|
|
2694
|
+
if (skipCsrf) {
|
|
2695
|
+
this.logger.debug("CSRF validation skipped due to @SkipCsrf decorator");
|
|
2696
|
+
return true;
|
|
2697
|
+
}
|
|
2500
2698
|
const request = context.switchToHttp().getRequest();
|
|
2501
2699
|
const reply = context.switchToHttp().getResponse();
|
|
2502
2700
|
const safeMethods = [
|
|
@@ -2511,7 +2709,7 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2511
2709
|
const fastifyInstance = request.server;
|
|
2512
2710
|
if (!fastifyInstance.csrfProtection) {
|
|
2513
2711
|
this.logger.error("CSRF protection plugin not found. Ensure @fastify/csrf-protection is registered.");
|
|
2514
|
-
throw new
|
|
2712
|
+
throw new import_common39.ForbiddenException("CSRF protection not configured");
|
|
2515
2713
|
}
|
|
2516
2714
|
await new Promise((resolve, reject) => {
|
|
2517
2715
|
fastifyInstance.csrfProtection(request, reply, (err) => {
|
|
@@ -2526,7 +2724,7 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2526
2724
|
return true;
|
|
2527
2725
|
} catch (error) {
|
|
2528
2726
|
this.logger.warn(`CSRF validation failed for ${request.method} ${request.url}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2529
|
-
throw new
|
|
2727
|
+
throw new import_common39.ForbiddenException({
|
|
2530
2728
|
errors: [
|
|
2531
2729
|
{
|
|
2532
2730
|
field: "csrf",
|
|
@@ -2538,26 +2736,29 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2538
2736
|
}
|
|
2539
2737
|
}
|
|
2540
2738
|
};
|
|
2541
|
-
CsrfGuard =
|
|
2542
|
-
(0,
|
|
2739
|
+
CsrfGuard = _ts_decorate13([
|
|
2740
|
+
(0, import_common39.Injectable)(),
|
|
2741
|
+
_ts_metadata8("design:type", Function),
|
|
2742
|
+
_ts_metadata8("design:paramtypes", [
|
|
2743
|
+
typeof import_core6.Reflector === "undefined" ? Object : import_core6.Reflector
|
|
2744
|
+
])
|
|
2543
2745
|
], CsrfGuard);
|
|
2544
2746
|
|
|
2545
2747
|
// src/http/http.module.ts
|
|
2546
|
-
|
|
2547
|
-
function _ts_decorate13(decorators, target, key, desc) {
|
|
2748
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2548
2749
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2549
2750
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2550
2751
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2551
2752
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2552
2753
|
}
|
|
2553
|
-
__name(
|
|
2754
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2554
2755
|
var HttpModule = class {
|
|
2555
2756
|
static {
|
|
2556
2757
|
__name(this, "HttpModule");
|
|
2557
2758
|
}
|
|
2558
2759
|
};
|
|
2559
|
-
HttpModule =
|
|
2560
|
-
(0,
|
|
2760
|
+
HttpModule = _ts_decorate14([
|
|
2761
|
+
(0, import_common40.Module)({
|
|
2561
2762
|
providers: [
|
|
2562
2763
|
CsrfGuard
|
|
2563
2764
|
],
|
|
@@ -2567,12 +2768,222 @@ HttpModule = _ts_decorate13([
|
|
|
2567
2768
|
})
|
|
2568
2769
|
], HttpModule);
|
|
2569
2770
|
|
|
2771
|
+
// src/utils/phone.utils.ts
|
|
2772
|
+
var CALLING_CODE_TO_COUNTRY = {
|
|
2773
|
+
// 3-digit codes
|
|
2774
|
+
"355": "AL",
|
|
2775
|
+
"213": "DZ",
|
|
2776
|
+
"376": "AD",
|
|
2777
|
+
"244": "AO",
|
|
2778
|
+
"672": "AQ",
|
|
2779
|
+
"374": "AM",
|
|
2780
|
+
"297": "AW",
|
|
2781
|
+
"994": "AZ",
|
|
2782
|
+
"973": "BH",
|
|
2783
|
+
"880": "BD",
|
|
2784
|
+
"375": "BY",
|
|
2785
|
+
"501": "BZ",
|
|
2786
|
+
"229": "BJ",
|
|
2787
|
+
"975": "BT",
|
|
2788
|
+
"591": "BO",
|
|
2789
|
+
"387": "BA",
|
|
2790
|
+
"267": "BW",
|
|
2791
|
+
"673": "BN",
|
|
2792
|
+
"359": "BG",
|
|
2793
|
+
"226": "BF",
|
|
2794
|
+
"257": "BI",
|
|
2795
|
+
"855": "KH",
|
|
2796
|
+
"237": "CM",
|
|
2797
|
+
"238": "CV",
|
|
2798
|
+
"236": "CF",
|
|
2799
|
+
"235": "TD",
|
|
2800
|
+
"269": "KM",
|
|
2801
|
+
"242": "CG",
|
|
2802
|
+
"243": "CD",
|
|
2803
|
+
"506": "CR",
|
|
2804
|
+
"385": "HR",
|
|
2805
|
+
"357": "CY",
|
|
2806
|
+
"420": "CZ",
|
|
2807
|
+
"253": "DJ",
|
|
2808
|
+
"593": "EC",
|
|
2809
|
+
"503": "SV",
|
|
2810
|
+
"240": "GQ",
|
|
2811
|
+
"291": "ER",
|
|
2812
|
+
"372": "EE",
|
|
2813
|
+
"251": "ET",
|
|
2814
|
+
"679": "FJ",
|
|
2815
|
+
"358": "FI",
|
|
2816
|
+
"241": "GA",
|
|
2817
|
+
"220": "GM",
|
|
2818
|
+
"995": "GE",
|
|
2819
|
+
"233": "GH",
|
|
2820
|
+
"350": "GI",
|
|
2821
|
+
"299": "GL",
|
|
2822
|
+
"502": "GT",
|
|
2823
|
+
"224": "GN",
|
|
2824
|
+
"245": "GW",
|
|
2825
|
+
"592": "GY",
|
|
2826
|
+
"509": "HT",
|
|
2827
|
+
"504": "HN",
|
|
2828
|
+
"354": "IS",
|
|
2829
|
+
"964": "IQ",
|
|
2830
|
+
"353": "IE",
|
|
2831
|
+
"972": "IL",
|
|
2832
|
+
"225": "CI",
|
|
2833
|
+
"962": "JO",
|
|
2834
|
+
"254": "KE",
|
|
2835
|
+
"686": "KI",
|
|
2836
|
+
"965": "KW",
|
|
2837
|
+
"996": "KG",
|
|
2838
|
+
"856": "LA",
|
|
2839
|
+
"371": "LV",
|
|
2840
|
+
"961": "LB",
|
|
2841
|
+
"266": "LS",
|
|
2842
|
+
"231": "LR",
|
|
2843
|
+
"218": "LY",
|
|
2844
|
+
"423": "LI",
|
|
2845
|
+
"370": "LT",
|
|
2846
|
+
"352": "LU",
|
|
2847
|
+
"389": "MK",
|
|
2848
|
+
"261": "MG",
|
|
2849
|
+
"265": "MW",
|
|
2850
|
+
"960": "MV",
|
|
2851
|
+
"223": "ML",
|
|
2852
|
+
"356": "MT",
|
|
2853
|
+
"692": "MH",
|
|
2854
|
+
"222": "MR",
|
|
2855
|
+
"230": "MU",
|
|
2856
|
+
"262": "YT",
|
|
2857
|
+
"691": "FM",
|
|
2858
|
+
"373": "MD",
|
|
2859
|
+
"377": "MC",
|
|
2860
|
+
"976": "MN",
|
|
2861
|
+
"382": "ME",
|
|
2862
|
+
"258": "MZ",
|
|
2863
|
+
"264": "NA",
|
|
2864
|
+
"674": "NR",
|
|
2865
|
+
"977": "NP",
|
|
2866
|
+
"505": "NI",
|
|
2867
|
+
"227": "NE",
|
|
2868
|
+
"234": "NG",
|
|
2869
|
+
"683": "NU",
|
|
2870
|
+
"968": "OM",
|
|
2871
|
+
"680": "PW",
|
|
2872
|
+
"970": "PS",
|
|
2873
|
+
"507": "PA",
|
|
2874
|
+
"675": "PG",
|
|
2875
|
+
"595": "PY",
|
|
2876
|
+
"351": "PT",
|
|
2877
|
+
"974": "QA",
|
|
2878
|
+
"250": "RW",
|
|
2879
|
+
"685": "WS",
|
|
2880
|
+
"378": "SM",
|
|
2881
|
+
"239": "ST",
|
|
2882
|
+
"966": "SA",
|
|
2883
|
+
"221": "SN",
|
|
2884
|
+
"381": "RS",
|
|
2885
|
+
"248": "SC",
|
|
2886
|
+
"232": "SL",
|
|
2887
|
+
"421": "SK",
|
|
2888
|
+
"386": "SI",
|
|
2889
|
+
"677": "SB",
|
|
2890
|
+
"252": "SO",
|
|
2891
|
+
"211": "SS",
|
|
2892
|
+
"249": "SD",
|
|
2893
|
+
"597": "SR",
|
|
2894
|
+
"268": "SZ",
|
|
2895
|
+
"963": "SY",
|
|
2896
|
+
"992": "TJ",
|
|
2897
|
+
"255": "TZ",
|
|
2898
|
+
"228": "TG",
|
|
2899
|
+
"676": "TO",
|
|
2900
|
+
"216": "TN",
|
|
2901
|
+
"993": "TM",
|
|
2902
|
+
"688": "TV",
|
|
2903
|
+
"256": "UG",
|
|
2904
|
+
"380": "UA",
|
|
2905
|
+
"971": "AE",
|
|
2906
|
+
"598": "UY",
|
|
2907
|
+
"998": "UZ",
|
|
2908
|
+
"678": "VU",
|
|
2909
|
+
"379": "VA",
|
|
2910
|
+
"967": "YE",
|
|
2911
|
+
"260": "ZM",
|
|
2912
|
+
"263": "ZW",
|
|
2913
|
+
// 2-digit codes
|
|
2914
|
+
"93": "AF",
|
|
2915
|
+
"54": "AR",
|
|
2916
|
+
"61": "AU",
|
|
2917
|
+
"43": "AT",
|
|
2918
|
+
"32": "BE",
|
|
2919
|
+
"55": "BR",
|
|
2920
|
+
"56": "CL",
|
|
2921
|
+
"86": "CN",
|
|
2922
|
+
"57": "CO",
|
|
2923
|
+
"53": "CU",
|
|
2924
|
+
"45": "DK",
|
|
2925
|
+
"20": "EG",
|
|
2926
|
+
"33": "FR",
|
|
2927
|
+
"49": "DE",
|
|
2928
|
+
"30": "GR",
|
|
2929
|
+
"36": "HU",
|
|
2930
|
+
"91": "IN",
|
|
2931
|
+
"62": "ID",
|
|
2932
|
+
"98": "IR",
|
|
2933
|
+
"39": "IT",
|
|
2934
|
+
"81": "JP",
|
|
2935
|
+
"82": "KR",
|
|
2936
|
+
"60": "MY",
|
|
2937
|
+
"52": "MX",
|
|
2938
|
+
"31": "NL",
|
|
2939
|
+
"64": "NZ",
|
|
2940
|
+
"47": "NO",
|
|
2941
|
+
"92": "PK",
|
|
2942
|
+
"51": "PE",
|
|
2943
|
+
"63": "PH",
|
|
2944
|
+
"48": "PL",
|
|
2945
|
+
"40": "RO",
|
|
2946
|
+
"65": "SG",
|
|
2947
|
+
"27": "ZA",
|
|
2948
|
+
"34": "ES",
|
|
2949
|
+
"94": "LK",
|
|
2950
|
+
"46": "SE",
|
|
2951
|
+
"41": "CH",
|
|
2952
|
+
"66": "TH",
|
|
2953
|
+
"90": "TR",
|
|
2954
|
+
"44": "GB",
|
|
2955
|
+
"58": "VE",
|
|
2956
|
+
"84": "VN",
|
|
2957
|
+
// 1-digit codes (shared codes default to most common country)
|
|
2958
|
+
"1": "US",
|
|
2959
|
+
"7": "RU"
|
|
2960
|
+
};
|
|
2961
|
+
function extractCountryFromPhone(phone) {
|
|
2962
|
+
const digits = phone.startsWith("+") ? phone.slice(1) : phone;
|
|
2963
|
+
for (const length of [
|
|
2964
|
+
3,
|
|
2965
|
+
2,
|
|
2966
|
+
1
|
|
2967
|
+
]) {
|
|
2968
|
+
const prefix = digits.slice(0, length);
|
|
2969
|
+
if (CALLING_CODE_TO_COUNTRY[prefix]) {
|
|
2970
|
+
return CALLING_CODE_TO_COUNTRY[prefix];
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
return void 0;
|
|
2974
|
+
}
|
|
2975
|
+
__name(extractCountryFromPhone, "extractCountryFromPhone");
|
|
2976
|
+
function normalizePhoneNumber(phone) {
|
|
2977
|
+
return phone.startsWith("+") ? phone : `+${phone}`;
|
|
2978
|
+
}
|
|
2979
|
+
__name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
2980
|
+
|
|
2570
2981
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2571
|
-
var
|
|
2982
|
+
var import_common42 = require("@nestjs/common");
|
|
2572
2983
|
var import_operators2 = require("rxjs/operators");
|
|
2573
2984
|
|
|
2574
2985
|
// src/logger/services/logger.service.ts
|
|
2575
|
-
var
|
|
2986
|
+
var import_common41 = require("@nestjs/common");
|
|
2576
2987
|
var import_winston = require("winston");
|
|
2577
2988
|
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
2578
2989
|
|
|
@@ -2610,17 +3021,17 @@ function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_C
|
|
|
2610
3021
|
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2611
3022
|
|
|
2612
3023
|
// src/logger/services/logger.service.ts
|
|
2613
|
-
function
|
|
3024
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2614
3025
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2615
3026
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2616
3027
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2617
3028
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2618
3029
|
}
|
|
2619
|
-
__name(
|
|
2620
|
-
function
|
|
3030
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3031
|
+
function _ts_metadata9(k, v) {
|
|
2621
3032
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2622
3033
|
}
|
|
2623
|
-
__name(
|
|
3034
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2624
3035
|
function _ts_param4(paramIndex, decorator) {
|
|
2625
3036
|
return function(target, key) {
|
|
2626
3037
|
decorator(target, key, paramIndex);
|
|
@@ -2828,29 +3239,29 @@ ${trace}`;
|
|
|
2828
3239
|
return childLogger;
|
|
2829
3240
|
}
|
|
2830
3241
|
};
|
|
2831
|
-
LoggerService =
|
|
2832
|
-
(0,
|
|
2833
|
-
_ts_param4(0, (0,
|
|
2834
|
-
_ts_param4(1, (0,
|
|
2835
|
-
|
|
2836
|
-
|
|
3242
|
+
LoggerService = _ts_decorate15([
|
|
3243
|
+
(0, import_common41.Injectable)(),
|
|
3244
|
+
_ts_param4(0, (0, import_common41.Optional)()),
|
|
3245
|
+
_ts_param4(1, (0, import_common41.Optional)()),
|
|
3246
|
+
_ts_metadata9("design:type", Function),
|
|
3247
|
+
_ts_metadata9("design:paramtypes", [
|
|
2837
3248
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2838
3249
|
typeof Logger === "undefined" ? Object : Logger
|
|
2839
3250
|
])
|
|
2840
3251
|
], LoggerService);
|
|
2841
3252
|
|
|
2842
3253
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2843
|
-
function
|
|
3254
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2844
3255
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2845
3256
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2846
3257
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2847
3258
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2848
3259
|
}
|
|
2849
|
-
__name(
|
|
2850
|
-
function
|
|
3260
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3261
|
+
function _ts_metadata10(k, v) {
|
|
2851
3262
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2852
3263
|
}
|
|
2853
|
-
__name(
|
|
3264
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2854
3265
|
function _ts_param5(paramIndex, decorator) {
|
|
2855
3266
|
return function(target, key) {
|
|
2856
3267
|
decorator(target, key, paramIndex);
|
|
@@ -2958,32 +3369,32 @@ var HttpLoggerInterceptor = class {
|
|
|
2958
3369
|
}
|
|
2959
3370
|
}
|
|
2960
3371
|
};
|
|
2961
|
-
HttpLoggerInterceptor =
|
|
2962
|
-
(0,
|
|
2963
|
-
_ts_param5(1, (0,
|
|
2964
|
-
|
|
2965
|
-
|
|
3372
|
+
HttpLoggerInterceptor = _ts_decorate16([
|
|
3373
|
+
(0, import_common42.Injectable)(),
|
|
3374
|
+
_ts_param5(1, (0, import_common42.Optional)()),
|
|
3375
|
+
_ts_metadata10("design:type", Function),
|
|
3376
|
+
_ts_metadata10("design:paramtypes", [
|
|
2966
3377
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
2967
3378
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
2968
3379
|
])
|
|
2969
3380
|
], HttpLoggerInterceptor);
|
|
2970
3381
|
|
|
2971
3382
|
// src/logger/logger.module.ts
|
|
2972
|
-
var
|
|
3383
|
+
var import_common44 = require("@nestjs/common");
|
|
2973
3384
|
|
|
2974
3385
|
// src/logger/middleware/correlation-id.middleware.ts
|
|
2975
|
-
var
|
|
2976
|
-
function
|
|
3386
|
+
var import_common43 = require("@nestjs/common");
|
|
3387
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2977
3388
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2978
3389
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2979
3390
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2980
3391
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2981
3392
|
}
|
|
2982
|
-
__name(
|
|
2983
|
-
function
|
|
3393
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3394
|
+
function _ts_metadata11(k, v) {
|
|
2984
3395
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2985
3396
|
}
|
|
2986
|
-
__name(
|
|
3397
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2987
3398
|
var CorrelationIdMiddleware = class {
|
|
2988
3399
|
static {
|
|
2989
3400
|
__name(this, "CorrelationIdMiddleware");
|
|
@@ -3026,22 +3437,22 @@ var CorrelationIdMiddleware = class {
|
|
|
3026
3437
|
}
|
|
3027
3438
|
}
|
|
3028
3439
|
};
|
|
3029
|
-
CorrelationIdMiddleware =
|
|
3030
|
-
(0,
|
|
3031
|
-
|
|
3032
|
-
|
|
3440
|
+
CorrelationIdMiddleware = _ts_decorate17([
|
|
3441
|
+
(0, import_common43.Injectable)(),
|
|
3442
|
+
_ts_metadata11("design:type", Function),
|
|
3443
|
+
_ts_metadata11("design:paramtypes", [
|
|
3033
3444
|
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
3034
3445
|
])
|
|
3035
3446
|
], CorrelationIdMiddleware);
|
|
3036
3447
|
|
|
3037
3448
|
// src/logger/logger.module.ts
|
|
3038
|
-
function
|
|
3449
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3039
3450
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3040
3451
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3041
3452
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3042
3453
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3043
3454
|
}
|
|
3044
|
-
__name(
|
|
3455
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3045
3456
|
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
3046
3457
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
3047
3458
|
provider: "winston",
|
|
@@ -3130,9 +3541,9 @@ function mergeWithDefaults(options = {}) {
|
|
|
3130
3541
|
__name(mergeWithDefaults, "mergeWithDefaults");
|
|
3131
3542
|
function createDefaultLoggerProvider(options) {
|
|
3132
3543
|
return {
|
|
3133
|
-
provide:
|
|
3544
|
+
provide: import_common44.Logger,
|
|
3134
3545
|
useFactory: /* @__PURE__ */ __name(() => {
|
|
3135
|
-
const logger = new
|
|
3546
|
+
const logger = new import_common44.Logger();
|
|
3136
3547
|
if (options.level && typeof logger.setLogLevels === "function") {
|
|
3137
3548
|
const levels = getLevelsUpTo(options.level);
|
|
3138
3549
|
logger.setLogLevels(levels);
|
|
@@ -3162,7 +3573,7 @@ function createLoggerProviders(options = {}) {
|
|
|
3162
3573
|
inject: [
|
|
3163
3574
|
LOGGER_MODULE_OPTIONS,
|
|
3164
3575
|
{
|
|
3165
|
-
token:
|
|
3576
|
+
token: import_common44.Logger,
|
|
3166
3577
|
optional: true
|
|
3167
3578
|
}
|
|
3168
3579
|
]
|
|
@@ -3313,10 +3724,10 @@ var LoggerModule = class _LoggerModule {
|
|
|
3313
3724
|
...asyncProviders,
|
|
3314
3725
|
// Default logger provider
|
|
3315
3726
|
{
|
|
3316
|
-
provide:
|
|
3727
|
+
provide: import_common44.Logger,
|
|
3317
3728
|
useFactory: /* @__PURE__ */ __name((opts) => {
|
|
3318
3729
|
if (opts.provider === "default") {
|
|
3319
|
-
const logger = new
|
|
3730
|
+
const logger = new import_common44.Logger();
|
|
3320
3731
|
if (opts.level && typeof logger.setLogLevels === "function") {
|
|
3321
3732
|
const levels = getLevelsUpTo(opts.level);
|
|
3322
3733
|
logger.setLogLevels(levels);
|
|
@@ -3338,7 +3749,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3338
3749
|
inject: [
|
|
3339
3750
|
LOGGER_MODULE_OPTIONS,
|
|
3340
3751
|
{
|
|
3341
|
-
token:
|
|
3752
|
+
token: import_common44.Logger,
|
|
3342
3753
|
optional: true
|
|
3343
3754
|
}
|
|
3344
3755
|
]
|
|
@@ -3444,9 +3855,9 @@ var LoggerModule = class _LoggerModule {
|
|
|
3444
3855
|
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3445
3856
|
}
|
|
3446
3857
|
};
|
|
3447
|
-
LoggerModule =
|
|
3448
|
-
(0,
|
|
3449
|
-
(0,
|
|
3858
|
+
LoggerModule = _ts_decorate18([
|
|
3859
|
+
(0, import_common44.Global)(),
|
|
3860
|
+
(0, import_common44.Module)({})
|
|
3450
3861
|
], LoggerModule);
|
|
3451
3862
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3452
3863
|
0 && (module.exports = {
|
|
@@ -3456,7 +3867,6 @@ LoggerModule = _ts_decorate17([
|
|
|
3456
3867
|
BaseFieldException,
|
|
3457
3868
|
ConflictException,
|
|
3458
3869
|
CorrelationIdMiddleware,
|
|
3459
|
-
CsrfGuard,
|
|
3460
3870
|
DEFAULT_CORRELATION_HEADER,
|
|
3461
3871
|
DatabaseModule,
|
|
3462
3872
|
ForbiddenException,
|
|
@@ -3478,7 +3888,10 @@ LoggerModule = _ts_decorate17([
|
|
|
3478
3888
|
PrimaryDatabaseService,
|
|
3479
3889
|
Public,
|
|
3480
3890
|
RequestTimeoutException,
|
|
3891
|
+
SKIP_CSRF_KEY,
|
|
3481
3892
|
ServiceUnavailableException,
|
|
3893
|
+
SkipCsrf,
|
|
3894
|
+
SseAuthGuard,
|
|
3482
3895
|
Tenant,
|
|
3483
3896
|
TenantBaseRepository,
|
|
3484
3897
|
TenantContextService,
|
|
@@ -3494,6 +3907,7 @@ LoggerModule = _ts_decorate17([
|
|
|
3494
3907
|
configureApiSdk,
|
|
3495
3908
|
correlationStorage,
|
|
3496
3909
|
defineConfig,
|
|
3910
|
+
extractCountryFromPhone,
|
|
3497
3911
|
generateCorrelationId,
|
|
3498
3912
|
getConfig,
|
|
3499
3913
|
getCorrelationContext,
|
|
@@ -3501,6 +3915,7 @@ LoggerModule = _ts_decorate17([
|
|
|
3501
3915
|
getJwtExpiry,
|
|
3502
3916
|
getRefreshCookieOptions,
|
|
3503
3917
|
hashToken,
|
|
3918
|
+
normalizePhoneNumber,
|
|
3504
3919
|
resetConfig,
|
|
3505
3920
|
runWithCorrelationContext,
|
|
3506
3921
|
updateCorrelationContext,
|