@vritti/api-sdk 0.1.6 → 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 +661 -251
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -21
- package/dist/index.d.ts +75 -21
- package/dist/index.js +523 -117
- 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");
|
|
@@ -305,13 +309,18 @@ RequestModule = _ts_decorate2([
|
|
|
305
309
|
], RequestModule);
|
|
306
310
|
|
|
307
311
|
// src/auth/guards/vritti-auth.guard.ts
|
|
308
|
-
var
|
|
312
|
+
var import_common5 = require("@nestjs/common");
|
|
309
313
|
var import_config2 = require("@nestjs/config");
|
|
310
314
|
var import_core2 = require("@nestjs/core");
|
|
311
315
|
var import_jwt = require("@nestjs/jwt");
|
|
312
316
|
|
|
313
|
-
// src/
|
|
317
|
+
// src/auth/decorators/skip-csrf.decorator.ts
|
|
314
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");
|
|
315
324
|
var import_drizzle_orm = require("drizzle-orm");
|
|
316
325
|
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
317
326
|
var import_pg = require("pg");
|
|
@@ -342,7 +351,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
342
351
|
__name(this, "PrimaryDatabaseService");
|
|
343
352
|
}
|
|
344
353
|
options;
|
|
345
|
-
logger = new
|
|
354
|
+
logger = new import_common4.Logger(_PrimaryDatabaseService.name);
|
|
346
355
|
/** PostgreSQL connection pool */
|
|
347
356
|
pool = null;
|
|
348
357
|
/** Drizzle database instance */
|
|
@@ -382,7 +391,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
382
391
|
this.logger.log("Connected to primary database (tenant registry)");
|
|
383
392
|
} catch (error) {
|
|
384
393
|
this.logger.error("Failed to connect to primary database", error);
|
|
385
|
-
throw new
|
|
394
|
+
throw new import_common4.InternalServerErrorException("Failed to initialize tenant registry");
|
|
386
395
|
}
|
|
387
396
|
}
|
|
388
397
|
/**
|
|
@@ -463,7 +472,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
463
472
|
return info;
|
|
464
473
|
} catch (error) {
|
|
465
474
|
this.logger.error(`Failed to fetch tenant info: ${tenantIdentifier}`, error);
|
|
466
|
-
throw new
|
|
475
|
+
throw new import_common4.InternalServerErrorException("Failed to resolve tenant");
|
|
467
476
|
}
|
|
468
477
|
}
|
|
469
478
|
/**
|
|
@@ -539,8 +548,8 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
539
548
|
}
|
|
540
549
|
};
|
|
541
550
|
PrimaryDatabaseService = _ts_decorate3([
|
|
542
|
-
(0,
|
|
543
|
-
_ts_param2(0, (0,
|
|
551
|
+
(0, import_common4.Injectable)(),
|
|
552
|
+
_ts_param2(0, (0, import_common4.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
544
553
|
_ts_metadata2("design:type", Function),
|
|
545
554
|
_ts_metadata2("design:paramtypes", [
|
|
546
555
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions
|
|
@@ -581,7 +590,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
581
590
|
jwtService;
|
|
582
591
|
primaryDatabase;
|
|
583
592
|
requestService;
|
|
584
|
-
logger = new
|
|
593
|
+
logger = new import_common5.Logger(_VrittiAuthGuard.name);
|
|
585
594
|
constructor(reflector, _configService, jwtService, primaryDatabase, requestService) {
|
|
586
595
|
this.reflector = reflector;
|
|
587
596
|
this._configService = _configService;
|
|
@@ -591,6 +600,14 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
591
600
|
}
|
|
592
601
|
async canActivate(context) {
|
|
593
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
|
+
}
|
|
594
611
|
const isPublic = this.reflector.getAllAndOverride("isPublic", [
|
|
595
612
|
context.getHandler(),
|
|
596
613
|
context.getClass()
|
|
@@ -607,17 +624,17 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
607
624
|
const accessToken = this.requestService.getAccessToken();
|
|
608
625
|
if (!accessToken) {
|
|
609
626
|
this.logger.warn("Access token not found in Authorization header");
|
|
610
|
-
throw new
|
|
627
|
+
throw new import_common5.UnauthorizedException("Access token not found");
|
|
611
628
|
}
|
|
612
629
|
const decodedToken = this.jwtService.decode(accessToken);
|
|
613
630
|
if (!decodedToken) {
|
|
614
631
|
this.logger.warn("Failed to decode access token");
|
|
615
|
-
throw new
|
|
632
|
+
throw new import_common5.UnauthorizedException("Invalid token format");
|
|
616
633
|
}
|
|
617
634
|
if (isOnboarding) {
|
|
618
635
|
if (decodedToken.type !== "onboarding") {
|
|
619
636
|
this.logger.warn("Onboarding endpoint requires onboarding token");
|
|
620
|
-
throw new
|
|
637
|
+
throw new import_common5.UnauthorizedException("This endpoint requires an onboarding token");
|
|
621
638
|
}
|
|
622
639
|
const validatedToken2 = this.validateAccessToken(accessToken);
|
|
623
640
|
this.logger.debug("Onboarding token validated successfully");
|
|
@@ -630,7 +647,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
630
647
|
}
|
|
631
648
|
if (decodedToken.type === "onboarding") {
|
|
632
649
|
this.logger.warn("Regular endpoint accessed with onboarding token");
|
|
633
|
-
throw new
|
|
650
|
+
throw new import_common5.UnauthorizedException("Onboarding tokens cannot access this endpoint");
|
|
634
651
|
}
|
|
635
652
|
const validatedToken = this.validateAccessToken(accessToken);
|
|
636
653
|
this.logger.debug("Access token validated successfully");
|
|
@@ -642,7 +659,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
642
659
|
const tenantIdentifier = this.requestService.getTenantIdentifier();
|
|
643
660
|
if (!tenantIdentifier) {
|
|
644
661
|
this.logger.warn("Tenant identifier not found in request");
|
|
645
|
-
throw new
|
|
662
|
+
throw new import_common5.UnauthorizedException("Tenant identifier not found");
|
|
646
663
|
}
|
|
647
664
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
648
665
|
if (tenantIdentifier === "cloud") {
|
|
@@ -652,20 +669,20 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
652
669
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
653
670
|
if (!tenantInfo) {
|
|
654
671
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
655
|
-
throw new
|
|
672
|
+
throw new import_common5.UnauthorizedException("Invalid tenant");
|
|
656
673
|
}
|
|
657
674
|
if (tenantInfo.status !== "ACTIVE") {
|
|
658
675
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
659
|
-
throw new
|
|
676
|
+
throw new import_common5.UnauthorizedException(`Tenant is ${tenantInfo.status}`);
|
|
660
677
|
}
|
|
661
678
|
this.logger.debug(`Tenant validated: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
662
679
|
return true;
|
|
663
680
|
} catch (error) {
|
|
664
|
-
if (error instanceof
|
|
681
|
+
if (error instanceof import_common5.UnauthorizedException) {
|
|
665
682
|
throw error;
|
|
666
683
|
}
|
|
667
684
|
this.logger.error("Unexpected error in auth guard", error);
|
|
668
|
-
throw new
|
|
685
|
+
throw new import_common5.UnauthorizedException("Authentication failed");
|
|
669
686
|
}
|
|
670
687
|
}
|
|
671
688
|
/**
|
|
@@ -684,24 +701,24 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
684
701
|
}
|
|
685
702
|
return decoded;
|
|
686
703
|
} catch (error) {
|
|
687
|
-
if (error instanceof
|
|
704
|
+
if (error instanceof import_common5.UnauthorizedException) {
|
|
688
705
|
throw error;
|
|
689
706
|
}
|
|
690
707
|
const jwtError = error;
|
|
691
708
|
if (jwtError?.name === "TokenExpiredError") {
|
|
692
709
|
this.logger.warn(`Access token expired at: ${jwtError?.expiredAt}`);
|
|
693
|
-
throw new
|
|
710
|
+
throw new import_common5.UnauthorizedException("Access token has expired");
|
|
694
711
|
}
|
|
695
712
|
if (jwtError?.name === "JsonWebTokenError") {
|
|
696
713
|
this.logger.warn(`Access token verification failed: ${jwtError?.message}`);
|
|
697
|
-
throw new
|
|
714
|
+
throw new import_common5.UnauthorizedException("Invalid access token");
|
|
698
715
|
}
|
|
699
716
|
if (jwtError?.name === "NotBeforeError") {
|
|
700
717
|
this.logger.warn("Access token used before valid (nbf claim)");
|
|
701
|
-
throw new
|
|
718
|
+
throw new import_common5.UnauthorizedException("Access token not yet valid");
|
|
702
719
|
}
|
|
703
720
|
this.logger.error("Unexpected error validating access token", error);
|
|
704
|
-
throw new
|
|
721
|
+
throw new import_common5.UnauthorizedException("Access token validation failed");
|
|
705
722
|
}
|
|
706
723
|
}
|
|
707
724
|
/**
|
|
@@ -728,18 +745,64 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
728
745
|
const refreshToken = cookies[config.cookie.refreshCookieName];
|
|
729
746
|
if (!refreshToken) {
|
|
730
747
|
this.logger.warn("Session validation failed - refresh token cookie not found");
|
|
731
|
-
throw new
|
|
748
|
+
throw new import_common5.UnauthorizedException("Session validation failed");
|
|
732
749
|
}
|
|
733
750
|
if (!verifyTokenHash(refreshToken, validatedToken.refreshTokenHash)) {
|
|
734
751
|
this.logger.warn("Session validation failed - token binding mismatch");
|
|
735
|
-
throw new
|
|
752
|
+
throw new import_common5.UnauthorizedException("Session validation failed");
|
|
736
753
|
}
|
|
737
754
|
this.logger.debug("Token binding validated successfully");
|
|
738
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
|
+
}
|
|
739
802
|
};
|
|
740
803
|
VrittiAuthGuard = _ts_decorate4([
|
|
741
|
-
(0,
|
|
742
|
-
scope:
|
|
804
|
+
(0, import_common5.Injectable)({
|
|
805
|
+
scope: import_common5.Scope.REQUEST
|
|
743
806
|
}),
|
|
744
807
|
_ts_metadata3("design:type", Function),
|
|
745
808
|
_ts_metadata3("design:paramtypes", [
|
|
@@ -795,6 +858,11 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
795
858
|
})
|
|
796
859
|
],
|
|
797
860
|
providers: [
|
|
861
|
+
// Required for external packages - NestJS global Reflector not available
|
|
862
|
+
{
|
|
863
|
+
provide: import_core3.Reflector,
|
|
864
|
+
useClass: import_core3.Reflector
|
|
865
|
+
},
|
|
798
866
|
{
|
|
799
867
|
provide: import_core3.APP_GUARD,
|
|
800
868
|
useClass: VrittiAuthGuard
|
|
@@ -807,21 +875,21 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
807
875
|
}
|
|
808
876
|
};
|
|
809
877
|
AuthConfigModule = _ts_decorate5([
|
|
810
|
-
(0,
|
|
811
|
-
(0,
|
|
878
|
+
(0, import_common6.Global)(),
|
|
879
|
+
(0, import_common6.Module)({})
|
|
812
880
|
], AuthConfigModule);
|
|
813
881
|
|
|
814
882
|
// src/auth/decorators/onboarding.decorator.ts
|
|
815
|
-
var
|
|
816
|
-
var Onboarding = /* @__PURE__ */ __name(() => (0,
|
|
883
|
+
var import_common7 = require("@nestjs/common");
|
|
884
|
+
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common7.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
817
885
|
|
|
818
886
|
// src/auth/decorators/public.decorator.ts
|
|
819
|
-
var
|
|
820
|
-
var Public = /* @__PURE__ */ __name(() => (0,
|
|
887
|
+
var import_common8 = require("@nestjs/common");
|
|
888
|
+
var Public = /* @__PURE__ */ __name(() => (0, import_common8.SetMetadata)("isPublic", true), "Public");
|
|
821
889
|
|
|
822
890
|
// src/auth/decorators/user-id.decorator.ts
|
|
823
|
-
var
|
|
824
|
-
var UserId = (0,
|
|
891
|
+
var import_common9 = require("@nestjs/common");
|
|
892
|
+
var UserId = (0, import_common9.createParamDecorator)((_data, ctx) => {
|
|
825
893
|
const request = ctx.switchToHttp().getRequest();
|
|
826
894
|
const user = request.user;
|
|
827
895
|
if (!user?.id) {
|
|
@@ -830,23 +898,123 @@ var UserId = (0, import_common8.createParamDecorator)((_data, ctx) => {
|
|
|
830
898
|
return user.id;
|
|
831
899
|
});
|
|
832
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
|
+
|
|
833
1001
|
// src/database/database.module.ts
|
|
834
|
-
var
|
|
1002
|
+
var import_common15 = require("@nestjs/common");
|
|
835
1003
|
var import_core5 = require("@nestjs/core");
|
|
836
1004
|
|
|
837
1005
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
838
|
-
var
|
|
1006
|
+
var import_common12 = require("@nestjs/common");
|
|
839
1007
|
var import_operators = require("rxjs/operators");
|
|
840
1008
|
|
|
841
1009
|
// src/database/services/tenant-context.service.ts
|
|
842
|
-
var
|
|
843
|
-
function
|
|
1010
|
+
var import_common11 = require("@nestjs/common");
|
|
1011
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
844
1012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
845
1013
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
846
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;
|
|
847
1015
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
848
1016
|
}
|
|
849
|
-
__name(
|
|
1017
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
850
1018
|
var TenantContextService = class {
|
|
851
1019
|
static {
|
|
852
1020
|
__name(this, "TenantContextService");
|
|
@@ -877,7 +1045,7 @@ var TenantContextService = class {
|
|
|
877
1045
|
*/
|
|
878
1046
|
getTenant() {
|
|
879
1047
|
if (!this.tenantInfo) {
|
|
880
|
-
throw new
|
|
1048
|
+
throw new import_common11.UnauthorizedException("Tenant context not set");
|
|
881
1049
|
}
|
|
882
1050
|
return this.tenantInfo;
|
|
883
1051
|
}
|
|
@@ -918,30 +1086,30 @@ var TenantContextService = class {
|
|
|
918
1086
|
return this.tenantInfo?.subdomain ?? null;
|
|
919
1087
|
}
|
|
920
1088
|
};
|
|
921
|
-
TenantContextService =
|
|
922
|
-
(0,
|
|
923
|
-
scope:
|
|
1089
|
+
TenantContextService = _ts_decorate7([
|
|
1090
|
+
(0, import_common11.Injectable)({
|
|
1091
|
+
scope: import_common11.Scope.REQUEST
|
|
924
1092
|
})
|
|
925
1093
|
], TenantContextService);
|
|
926
1094
|
|
|
927
1095
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
928
|
-
function
|
|
1096
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
929
1097
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
930
1098
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
931
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;
|
|
932
1100
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
933
1101
|
}
|
|
934
|
-
__name(
|
|
935
|
-
function
|
|
1102
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1103
|
+
function _ts_metadata5(k, v) {
|
|
936
1104
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
937
1105
|
}
|
|
938
|
-
__name(
|
|
1106
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
939
1107
|
var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
940
1108
|
static {
|
|
941
1109
|
__name(this, "MessageTenantContextInterceptor");
|
|
942
1110
|
}
|
|
943
1111
|
tenantContext;
|
|
944
|
-
logger = new
|
|
1112
|
+
logger = new import_common12.Logger(_MessageTenantContextInterceptor.name);
|
|
945
1113
|
constructor(tenantContext) {
|
|
946
1114
|
this.tenantContext = tenantContext;
|
|
947
1115
|
}
|
|
@@ -986,30 +1154,30 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
986
1154
|
}
|
|
987
1155
|
}
|
|
988
1156
|
};
|
|
989
|
-
MessageTenantContextInterceptor =
|
|
990
|
-
(0,
|
|
991
|
-
scope:
|
|
1157
|
+
MessageTenantContextInterceptor = _ts_decorate8([
|
|
1158
|
+
(0, import_common12.Injectable)({
|
|
1159
|
+
scope: import_common12.Scope.REQUEST
|
|
992
1160
|
}),
|
|
993
|
-
|
|
994
|
-
|
|
1161
|
+
_ts_metadata5("design:type", Function),
|
|
1162
|
+
_ts_metadata5("design:paramtypes", [
|
|
995
1163
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
996
1164
|
])
|
|
997
1165
|
], MessageTenantContextInterceptor);
|
|
998
1166
|
|
|
999
1167
|
// src/database/interceptors/tenant-context.interceptor.ts
|
|
1000
|
-
var
|
|
1168
|
+
var import_common13 = require("@nestjs/common");
|
|
1001
1169
|
var import_core4 = require("@nestjs/core");
|
|
1002
|
-
function
|
|
1170
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1003
1171
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1004
1172
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1005
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;
|
|
1006
1174
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1007
1175
|
}
|
|
1008
|
-
__name(
|
|
1009
|
-
function
|
|
1176
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1177
|
+
function _ts_metadata6(k, v) {
|
|
1010
1178
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1011
1179
|
}
|
|
1012
|
-
__name(
|
|
1180
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1013
1181
|
var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
1014
1182
|
static {
|
|
1015
1183
|
__name(this, "TenantContextInterceptor");
|
|
@@ -1018,7 +1186,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1018
1186
|
tenantContext;
|
|
1019
1187
|
primaryDatabase;
|
|
1020
1188
|
requestService;
|
|
1021
|
-
logger = new
|
|
1189
|
+
logger = new import_common13.Logger(_TenantContextInterceptor.name);
|
|
1022
1190
|
constructor(reflector, tenantContext, primaryDatabase, requestService) {
|
|
1023
1191
|
this.reflector = reflector;
|
|
1024
1192
|
this.tenantContext = tenantContext;
|
|
@@ -1039,7 +1207,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1039
1207
|
return next.handle();
|
|
1040
1208
|
}
|
|
1041
1209
|
if (!tenantIdentifier) {
|
|
1042
|
-
throw new
|
|
1210
|
+
throw new import_common13.UnauthorizedException("Tenant identifier not found in request");
|
|
1043
1211
|
}
|
|
1044
1212
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
1045
1213
|
if (tenantIdentifier === "cloud") {
|
|
@@ -1049,11 +1217,11 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1049
1217
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
1050
1218
|
if (!tenantInfo) {
|
|
1051
1219
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
1052
|
-
throw new
|
|
1220
|
+
throw new import_common13.UnauthorizedException("Invalid tenant");
|
|
1053
1221
|
}
|
|
1054
1222
|
if (tenantInfo.status !== "ACTIVE") {
|
|
1055
1223
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
1056
|
-
throw new
|
|
1224
|
+
throw new import_common13.UnauthorizedException(`Tenant is ${tenantInfo.status}`);
|
|
1057
1225
|
}
|
|
1058
1226
|
this.logger.debug(`Tenant config loaded: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
1059
1227
|
this.tenantContext.setTenant(tenantInfo);
|
|
@@ -1066,12 +1234,12 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1066
1234
|
return next.handle();
|
|
1067
1235
|
}
|
|
1068
1236
|
};
|
|
1069
|
-
TenantContextInterceptor =
|
|
1070
|
-
(0,
|
|
1071
|
-
scope:
|
|
1237
|
+
TenantContextInterceptor = _ts_decorate9([
|
|
1238
|
+
(0, import_common13.Injectable)({
|
|
1239
|
+
scope: import_common13.Scope.REQUEST
|
|
1072
1240
|
}),
|
|
1073
|
-
|
|
1074
|
-
|
|
1241
|
+
_ts_metadata6("design:type", Function),
|
|
1242
|
+
_ts_metadata6("design:paramtypes", [
|
|
1075
1243
|
typeof import_core4.Reflector === "undefined" ? Object : import_core4.Reflector,
|
|
1076
1244
|
typeof TenantContextService === "undefined" ? Object : TenantContextService,
|
|
1077
1245
|
typeof PrimaryDatabaseService === "undefined" ? Object : PrimaryDatabaseService,
|
|
@@ -1080,20 +1248,20 @@ TenantContextInterceptor = _ts_decorate8([
|
|
|
1080
1248
|
], TenantContextInterceptor);
|
|
1081
1249
|
|
|
1082
1250
|
// src/database/services/tenant-database.service.ts
|
|
1083
|
-
var
|
|
1251
|
+
var import_common14 = require("@nestjs/common");
|
|
1084
1252
|
var import_node_postgres2 = require("drizzle-orm/node-postgres");
|
|
1085
1253
|
var import_pg2 = require("pg");
|
|
1086
|
-
function
|
|
1254
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1087
1255
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1088
1256
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1089
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;
|
|
1090
1258
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1091
1259
|
}
|
|
1092
|
-
__name(
|
|
1093
|
-
function
|
|
1260
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1261
|
+
function _ts_metadata7(k, v) {
|
|
1094
1262
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1095
1263
|
}
|
|
1096
|
-
__name(
|
|
1264
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1097
1265
|
function _ts_param3(paramIndex, decorator) {
|
|
1098
1266
|
return function(target, key) {
|
|
1099
1267
|
decorator(target, key, paramIndex);
|
|
@@ -1106,7 +1274,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1106
1274
|
}
|
|
1107
1275
|
options;
|
|
1108
1276
|
tenantContext;
|
|
1109
|
-
logger = new
|
|
1277
|
+
logger = new import_common14.Logger(_TenantDatabaseService.name);
|
|
1110
1278
|
/** Connection pool: Map<cacheKey, TenantConnection> */
|
|
1111
1279
|
clients = /* @__PURE__ */ new Map();
|
|
1112
1280
|
/** Track last usage time for idle connection cleanup */
|
|
@@ -1183,7 +1351,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1183
1351
|
};
|
|
1184
1352
|
} catch (error) {
|
|
1185
1353
|
this.logger.error(`Failed to create database connection for tenant: ${tenant.subdomain}`, error);
|
|
1186
|
-
throw new
|
|
1354
|
+
throw new import_common14.InternalServerErrorException("Failed to connect to tenant database");
|
|
1187
1355
|
}
|
|
1188
1356
|
}
|
|
1189
1357
|
/**
|
|
@@ -1275,24 +1443,24 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1275
1443
|
this.logger.log("All database connections closed");
|
|
1276
1444
|
}
|
|
1277
1445
|
};
|
|
1278
|
-
TenantDatabaseService =
|
|
1279
|
-
(0,
|
|
1280
|
-
_ts_param3(0, (0,
|
|
1281
|
-
|
|
1282
|
-
|
|
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", [
|
|
1283
1451
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
1284
1452
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
1285
1453
|
])
|
|
1286
1454
|
], TenantDatabaseService);
|
|
1287
1455
|
|
|
1288
1456
|
// src/database/database.module.ts
|
|
1289
|
-
function
|
|
1457
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1290
1458
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1291
1459
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1292
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;
|
|
1293
1461
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1294
1462
|
}
|
|
1295
|
-
__name(
|
|
1463
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1296
1464
|
var DatabaseModule = class _DatabaseModule {
|
|
1297
1465
|
static {
|
|
1298
1466
|
__name(this, "DatabaseModule");
|
|
@@ -1363,6 +1531,11 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1363
1531
|
inject: options.inject || []
|
|
1364
1532
|
};
|
|
1365
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
|
+
},
|
|
1366
1539
|
asyncProvider,
|
|
1367
1540
|
TenantContextService,
|
|
1368
1541
|
PrimaryDatabaseService,
|
|
@@ -1394,14 +1567,14 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1394
1567
|
};
|
|
1395
1568
|
}
|
|
1396
1569
|
};
|
|
1397
|
-
DatabaseModule =
|
|
1398
|
-
(0,
|
|
1399
|
-
(0,
|
|
1570
|
+
DatabaseModule = _ts_decorate11([
|
|
1571
|
+
(0, import_common15.Global)(),
|
|
1572
|
+
(0, import_common15.Module)({})
|
|
1400
1573
|
], DatabaseModule);
|
|
1401
1574
|
|
|
1402
1575
|
// src/database/decorators/tenant.decorator.ts
|
|
1403
|
-
var
|
|
1404
|
-
var Tenant = (0,
|
|
1576
|
+
var import_common16 = require("@nestjs/common");
|
|
1577
|
+
var Tenant = (0, import_common16.createParamDecorator)((_data, ctx) => {
|
|
1405
1578
|
const request = ctx.switchToHttp().getRequest();
|
|
1406
1579
|
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1407
1580
|
if (!tenantContext) {
|
|
@@ -1411,7 +1584,7 @@ var Tenant = (0, import_common14.createParamDecorator)((_data, ctx) => {
|
|
|
1411
1584
|
});
|
|
1412
1585
|
|
|
1413
1586
|
// src/database/repositories/primary-base.repository.ts
|
|
1414
|
-
var
|
|
1587
|
+
var import_common17 = require("@nestjs/common");
|
|
1415
1588
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
1416
1589
|
function snakeToCamel(str) {
|
|
1417
1590
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1482,7 +1655,7 @@ var PrimaryBaseRepository = class {
|
|
|
1482
1655
|
this.table = table;
|
|
1483
1656
|
const dbTableName = (0, import_drizzle_orm2.getTableName)(table);
|
|
1484
1657
|
this.tableName = snakeToCamel(dbTableName);
|
|
1485
|
-
this.logger = new
|
|
1658
|
+
this.logger = new import_common17.Logger(this.constructor.name);
|
|
1486
1659
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1487
1660
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1488
1661
|
}
|
|
@@ -1722,7 +1895,7 @@ var PrimaryBaseRepository = class {
|
|
|
1722
1895
|
};
|
|
1723
1896
|
|
|
1724
1897
|
// src/database/repositories/tenant-base.repository.ts
|
|
1725
|
-
var
|
|
1898
|
+
var import_common18 = require("@nestjs/common");
|
|
1726
1899
|
var import_drizzle_orm3 = require("drizzle-orm");
|
|
1727
1900
|
var TenantBaseRepository = class {
|
|
1728
1901
|
static {
|
|
@@ -1779,7 +1952,7 @@ var TenantBaseRepository = class {
|
|
|
1779
1952
|
this.database = database;
|
|
1780
1953
|
this.table = table;
|
|
1781
1954
|
this.tableName = (0, import_drizzle_orm3.getTableName)(table);
|
|
1782
|
-
this.logger = new
|
|
1955
|
+
this.logger = new import_common18.Logger(this.constructor.name);
|
|
1783
1956
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1784
1957
|
}
|
|
1785
1958
|
/**
|
|
@@ -2012,11 +2185,11 @@ var TenantBaseRepository = class {
|
|
|
2012
2185
|
};
|
|
2013
2186
|
|
|
2014
2187
|
// src/exceptions/bad-gateway.exception.ts
|
|
2015
|
-
var
|
|
2188
|
+
var import_common20 = require("@nestjs/common");
|
|
2016
2189
|
|
|
2017
2190
|
// src/exceptions/base-field.exception.ts
|
|
2018
|
-
var
|
|
2019
|
-
var BaseFieldException = class extends
|
|
2191
|
+
var import_common19 = require("@nestjs/common");
|
|
2192
|
+
var BaseFieldException = class extends import_common19.HttpException {
|
|
2020
2193
|
static {
|
|
2021
2194
|
__name(this, "BaseFieldException");
|
|
2022
2195
|
}
|
|
@@ -2026,7 +2199,7 @@ var BaseFieldException = class extends import_common17.HttpException {
|
|
|
2026
2199
|
let finalDetail;
|
|
2027
2200
|
if (Array.isArray(statusOrMessageOrErrors)) {
|
|
2028
2201
|
errors = statusOrMessageOrErrors;
|
|
2029
|
-
httpStatus = messageOrStatus ||
|
|
2202
|
+
httpStatus = messageOrStatus || import_common19.HttpStatus.BAD_REQUEST;
|
|
2030
2203
|
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2031
2204
|
} else if (typeof statusOrMessageOrErrors === "string" && typeof messageOrStatus === "string") {
|
|
2032
2205
|
errors = [
|
|
@@ -2071,343 +2244,343 @@ var BadGatewayException = class extends BaseFieldException {
|
|
|
2071
2244
|
}
|
|
2072
2245
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2073
2246
|
if (Array.isArray(messageOrField)) {
|
|
2074
|
-
super(messageOrField,
|
|
2247
|
+
super(messageOrField, import_common20.HttpStatus.BAD_GATEWAY, fieldMessageOrDetail);
|
|
2075
2248
|
} else if (detail !== void 0) {
|
|
2076
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2249
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.BAD_GATEWAY, detail);
|
|
2077
2250
|
} else if (fieldMessageOrDetail) {
|
|
2078
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2251
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.BAD_GATEWAY);
|
|
2079
2252
|
} else {
|
|
2080
|
-
super(messageOrField,
|
|
2253
|
+
super(messageOrField, import_common20.HttpStatus.BAD_GATEWAY);
|
|
2081
2254
|
}
|
|
2082
2255
|
}
|
|
2083
2256
|
};
|
|
2084
2257
|
|
|
2085
2258
|
// src/exceptions/bad-request.exception.ts
|
|
2086
|
-
var
|
|
2259
|
+
var import_common21 = require("@nestjs/common");
|
|
2087
2260
|
var BadRequestException = class extends BaseFieldException {
|
|
2088
2261
|
static {
|
|
2089
2262
|
__name(this, "BadRequestException");
|
|
2090
2263
|
}
|
|
2091
2264
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2092
2265
|
if (Array.isArray(messageOrField)) {
|
|
2093
|
-
super(messageOrField,
|
|
2266
|
+
super(messageOrField, import_common21.HttpStatus.BAD_REQUEST, fieldMessageOrDetail);
|
|
2094
2267
|
} else if (detail !== void 0) {
|
|
2095
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2268
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.BAD_REQUEST, detail);
|
|
2096
2269
|
} else if (fieldMessageOrDetail) {
|
|
2097
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2270
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.BAD_REQUEST);
|
|
2098
2271
|
} else {
|
|
2099
|
-
super(messageOrField,
|
|
2272
|
+
super(messageOrField, import_common21.HttpStatus.BAD_REQUEST);
|
|
2100
2273
|
}
|
|
2101
2274
|
}
|
|
2102
2275
|
};
|
|
2103
2276
|
|
|
2104
2277
|
// src/exceptions/conflict.exception.ts
|
|
2105
|
-
var
|
|
2278
|
+
var import_common22 = require("@nestjs/common");
|
|
2106
2279
|
var ConflictException = class extends BaseFieldException {
|
|
2107
2280
|
static {
|
|
2108
2281
|
__name(this, "ConflictException");
|
|
2109
2282
|
}
|
|
2110
2283
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2111
2284
|
if (Array.isArray(messageOrField)) {
|
|
2112
|
-
super(messageOrField,
|
|
2285
|
+
super(messageOrField, import_common22.HttpStatus.CONFLICT, fieldMessageOrDetail);
|
|
2113
2286
|
} else if (detail !== void 0) {
|
|
2114
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2287
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.CONFLICT, detail);
|
|
2115
2288
|
} else if (fieldMessageOrDetail) {
|
|
2116
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2289
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.CONFLICT);
|
|
2117
2290
|
} else {
|
|
2118
|
-
super(messageOrField,
|
|
2291
|
+
super(messageOrField, import_common22.HttpStatus.CONFLICT);
|
|
2119
2292
|
}
|
|
2120
2293
|
}
|
|
2121
2294
|
};
|
|
2122
2295
|
|
|
2123
2296
|
// src/exceptions/forbidden.exception.ts
|
|
2124
|
-
var
|
|
2125
|
-
var
|
|
2297
|
+
var import_common23 = require("@nestjs/common");
|
|
2298
|
+
var ForbiddenException2 = class extends BaseFieldException {
|
|
2126
2299
|
static {
|
|
2127
2300
|
__name(this, "ForbiddenException");
|
|
2128
2301
|
}
|
|
2129
2302
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2130
2303
|
if (Array.isArray(messageOrField)) {
|
|
2131
|
-
super(messageOrField,
|
|
2304
|
+
super(messageOrField, import_common23.HttpStatus.FORBIDDEN, fieldMessageOrDetail);
|
|
2132
2305
|
} else if (detail !== void 0) {
|
|
2133
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2306
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.FORBIDDEN, detail);
|
|
2134
2307
|
} else if (fieldMessageOrDetail) {
|
|
2135
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2308
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.FORBIDDEN);
|
|
2136
2309
|
} else {
|
|
2137
|
-
super(messageOrField,
|
|
2310
|
+
super(messageOrField, import_common23.HttpStatus.FORBIDDEN);
|
|
2138
2311
|
}
|
|
2139
2312
|
}
|
|
2140
2313
|
};
|
|
2141
2314
|
|
|
2142
2315
|
// src/exceptions/gone.exception.ts
|
|
2143
|
-
var
|
|
2316
|
+
var import_common24 = require("@nestjs/common");
|
|
2144
2317
|
var GoneException = class extends BaseFieldException {
|
|
2145
2318
|
static {
|
|
2146
2319
|
__name(this, "GoneException");
|
|
2147
2320
|
}
|
|
2148
2321
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2149
2322
|
if (Array.isArray(messageOrField)) {
|
|
2150
|
-
super(messageOrField,
|
|
2323
|
+
super(messageOrField, import_common24.HttpStatus.GONE, fieldMessageOrDetail);
|
|
2151
2324
|
} else if (detail !== void 0) {
|
|
2152
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2325
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.GONE, detail);
|
|
2153
2326
|
} else if (fieldMessageOrDetail) {
|
|
2154
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2327
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.GONE);
|
|
2155
2328
|
} else {
|
|
2156
|
-
super(messageOrField,
|
|
2329
|
+
super(messageOrField, import_common24.HttpStatus.GONE);
|
|
2157
2330
|
}
|
|
2158
2331
|
}
|
|
2159
2332
|
};
|
|
2160
2333
|
|
|
2161
2334
|
// src/exceptions/internal-server-error.exception.ts
|
|
2162
|
-
var
|
|
2335
|
+
var import_common25 = require("@nestjs/common");
|
|
2163
2336
|
var InternalServerErrorException3 = class extends BaseFieldException {
|
|
2164
2337
|
static {
|
|
2165
2338
|
__name(this, "InternalServerErrorException");
|
|
2166
2339
|
}
|
|
2167
2340
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2168
2341
|
if (Array.isArray(messageOrField)) {
|
|
2169
|
-
super(messageOrField,
|
|
2342
|
+
super(messageOrField, import_common25.HttpStatus.INTERNAL_SERVER_ERROR, fieldMessageOrDetail);
|
|
2170
2343
|
} else if (detail !== void 0) {
|
|
2171
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2344
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.INTERNAL_SERVER_ERROR, detail);
|
|
2172
2345
|
} else if (fieldMessageOrDetail) {
|
|
2173
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2346
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2174
2347
|
} else {
|
|
2175
|
-
super(messageOrField,
|
|
2348
|
+
super(messageOrField, import_common25.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2176
2349
|
}
|
|
2177
2350
|
}
|
|
2178
2351
|
};
|
|
2179
2352
|
|
|
2180
2353
|
// src/exceptions/method-not-allowed.exception.ts
|
|
2181
|
-
var
|
|
2354
|
+
var import_common26 = require("@nestjs/common");
|
|
2182
2355
|
var MethodNotAllowedException = class extends BaseFieldException {
|
|
2183
2356
|
static {
|
|
2184
2357
|
__name(this, "MethodNotAllowedException");
|
|
2185
2358
|
}
|
|
2186
2359
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2187
2360
|
if (Array.isArray(messageOrField)) {
|
|
2188
|
-
super(messageOrField,
|
|
2361
|
+
super(messageOrField, import_common26.HttpStatus.METHOD_NOT_ALLOWED, fieldMessageOrDetail);
|
|
2189
2362
|
} else if (detail !== void 0) {
|
|
2190
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2363
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.METHOD_NOT_ALLOWED, detail);
|
|
2191
2364
|
} else if (fieldMessageOrDetail) {
|
|
2192
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2365
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2193
2366
|
} else {
|
|
2194
|
-
super(messageOrField,
|
|
2367
|
+
super(messageOrField, import_common26.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2195
2368
|
}
|
|
2196
2369
|
}
|
|
2197
2370
|
};
|
|
2198
2371
|
|
|
2199
2372
|
// src/exceptions/not-acceptable.exception.ts
|
|
2200
|
-
var
|
|
2373
|
+
var import_common27 = require("@nestjs/common");
|
|
2201
2374
|
var NotAcceptableException = class extends BaseFieldException {
|
|
2202
2375
|
static {
|
|
2203
2376
|
__name(this, "NotAcceptableException");
|
|
2204
2377
|
}
|
|
2205
2378
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2206
2379
|
if (Array.isArray(messageOrField)) {
|
|
2207
|
-
super(messageOrField,
|
|
2380
|
+
super(messageOrField, import_common27.HttpStatus.NOT_ACCEPTABLE, fieldMessageOrDetail);
|
|
2208
2381
|
} else if (detail !== void 0) {
|
|
2209
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2382
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.NOT_ACCEPTABLE, detail);
|
|
2210
2383
|
} else if (fieldMessageOrDetail) {
|
|
2211
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2384
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.NOT_ACCEPTABLE);
|
|
2212
2385
|
} else {
|
|
2213
|
-
super(messageOrField,
|
|
2386
|
+
super(messageOrField, import_common27.HttpStatus.NOT_ACCEPTABLE);
|
|
2214
2387
|
}
|
|
2215
2388
|
}
|
|
2216
2389
|
};
|
|
2217
2390
|
|
|
2218
2391
|
// src/exceptions/not-found.exception.ts
|
|
2219
|
-
var
|
|
2392
|
+
var import_common28 = require("@nestjs/common");
|
|
2220
2393
|
var NotFoundException = class extends BaseFieldException {
|
|
2221
2394
|
static {
|
|
2222
2395
|
__name(this, "NotFoundException");
|
|
2223
2396
|
}
|
|
2224
2397
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2225
2398
|
if (Array.isArray(messageOrField)) {
|
|
2226
|
-
super(messageOrField,
|
|
2399
|
+
super(messageOrField, import_common28.HttpStatus.NOT_FOUND, fieldMessageOrDetail);
|
|
2227
2400
|
} else if (detail !== void 0) {
|
|
2228
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2401
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.NOT_FOUND, detail);
|
|
2229
2402
|
} else if (fieldMessageOrDetail) {
|
|
2230
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2403
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.NOT_FOUND);
|
|
2231
2404
|
} else {
|
|
2232
|
-
super(messageOrField,
|
|
2405
|
+
super(messageOrField, import_common28.HttpStatus.NOT_FOUND);
|
|
2233
2406
|
}
|
|
2234
2407
|
}
|
|
2235
2408
|
};
|
|
2236
2409
|
|
|
2237
2410
|
// src/exceptions/not-implemented.exception.ts
|
|
2238
|
-
var
|
|
2411
|
+
var import_common29 = require("@nestjs/common");
|
|
2239
2412
|
var NotImplementedException = class extends BaseFieldException {
|
|
2240
2413
|
static {
|
|
2241
2414
|
__name(this, "NotImplementedException");
|
|
2242
2415
|
}
|
|
2243
2416
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2244
2417
|
if (Array.isArray(messageOrField)) {
|
|
2245
|
-
super(messageOrField,
|
|
2418
|
+
super(messageOrField, import_common29.HttpStatus.NOT_IMPLEMENTED, fieldMessageOrDetail);
|
|
2246
2419
|
} else if (detail !== void 0) {
|
|
2247
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2420
|
+
super(messageOrField, fieldMessageOrDetail, import_common29.HttpStatus.NOT_IMPLEMENTED, detail);
|
|
2248
2421
|
} else if (fieldMessageOrDetail) {
|
|
2249
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2422
|
+
super(messageOrField, fieldMessageOrDetail, import_common29.HttpStatus.NOT_IMPLEMENTED);
|
|
2250
2423
|
} else {
|
|
2251
|
-
super(messageOrField,
|
|
2424
|
+
super(messageOrField, import_common29.HttpStatus.NOT_IMPLEMENTED);
|
|
2252
2425
|
}
|
|
2253
2426
|
}
|
|
2254
2427
|
};
|
|
2255
2428
|
|
|
2256
2429
|
// src/exceptions/payload-too-large.exception.ts
|
|
2257
|
-
var
|
|
2430
|
+
var import_common30 = require("@nestjs/common");
|
|
2258
2431
|
var PayloadTooLargeException = class extends BaseFieldException {
|
|
2259
2432
|
static {
|
|
2260
2433
|
__name(this, "PayloadTooLargeException");
|
|
2261
2434
|
}
|
|
2262
2435
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2263
2436
|
if (Array.isArray(messageOrField)) {
|
|
2264
|
-
super(messageOrField,
|
|
2437
|
+
super(messageOrField, import_common30.HttpStatus.PAYLOAD_TOO_LARGE, fieldMessageOrDetail);
|
|
2265
2438
|
} else if (detail !== void 0) {
|
|
2266
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2439
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.PAYLOAD_TOO_LARGE, detail);
|
|
2267
2440
|
} else if (fieldMessageOrDetail) {
|
|
2268
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2441
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2269
2442
|
} else {
|
|
2270
|
-
super(messageOrField,
|
|
2443
|
+
super(messageOrField, import_common30.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2271
2444
|
}
|
|
2272
2445
|
}
|
|
2273
2446
|
};
|
|
2274
2447
|
|
|
2275
2448
|
// src/exceptions/request-timeout.exception.ts
|
|
2276
|
-
var
|
|
2449
|
+
var import_common31 = require("@nestjs/common");
|
|
2277
2450
|
var RequestTimeoutException = class extends BaseFieldException {
|
|
2278
2451
|
static {
|
|
2279
2452
|
__name(this, "RequestTimeoutException");
|
|
2280
2453
|
}
|
|
2281
2454
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2282
2455
|
if (Array.isArray(messageOrField)) {
|
|
2283
|
-
super(messageOrField,
|
|
2456
|
+
super(messageOrField, import_common31.HttpStatus.REQUEST_TIMEOUT, fieldMessageOrDetail);
|
|
2284
2457
|
} else if (detail !== void 0) {
|
|
2285
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2458
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.REQUEST_TIMEOUT, detail);
|
|
2286
2459
|
} else if (fieldMessageOrDetail) {
|
|
2287
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2460
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.REQUEST_TIMEOUT);
|
|
2288
2461
|
} else {
|
|
2289
|
-
super(messageOrField,
|
|
2462
|
+
super(messageOrField, import_common31.HttpStatus.REQUEST_TIMEOUT);
|
|
2290
2463
|
}
|
|
2291
2464
|
}
|
|
2292
2465
|
};
|
|
2293
2466
|
|
|
2294
2467
|
// src/exceptions/service-unavailable.exception.ts
|
|
2295
|
-
var
|
|
2468
|
+
var import_common32 = require("@nestjs/common");
|
|
2296
2469
|
var ServiceUnavailableException = class extends BaseFieldException {
|
|
2297
2470
|
static {
|
|
2298
2471
|
__name(this, "ServiceUnavailableException");
|
|
2299
2472
|
}
|
|
2300
2473
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2301
2474
|
if (Array.isArray(messageOrField)) {
|
|
2302
|
-
super(messageOrField,
|
|
2475
|
+
super(messageOrField, import_common32.HttpStatus.SERVICE_UNAVAILABLE, fieldMessageOrDetail);
|
|
2303
2476
|
} else if (detail !== void 0) {
|
|
2304
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2477
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.SERVICE_UNAVAILABLE, detail);
|
|
2305
2478
|
} else if (fieldMessageOrDetail) {
|
|
2306
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2479
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.SERVICE_UNAVAILABLE);
|
|
2307
2480
|
} else {
|
|
2308
|
-
super(messageOrField,
|
|
2481
|
+
super(messageOrField, import_common32.HttpStatus.SERVICE_UNAVAILABLE);
|
|
2309
2482
|
}
|
|
2310
2483
|
}
|
|
2311
2484
|
};
|
|
2312
2485
|
|
|
2313
2486
|
// src/exceptions/too-many-requests.exception.ts
|
|
2314
|
-
var
|
|
2487
|
+
var import_common33 = require("@nestjs/common");
|
|
2315
2488
|
var TooManyRequestsException = class extends BaseFieldException {
|
|
2316
2489
|
static {
|
|
2317
2490
|
__name(this, "TooManyRequestsException");
|
|
2318
2491
|
}
|
|
2319
2492
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2320
2493
|
if (Array.isArray(messageOrField)) {
|
|
2321
|
-
super(messageOrField,
|
|
2494
|
+
super(messageOrField, import_common33.HttpStatus.TOO_MANY_REQUESTS, fieldMessageOrDetail);
|
|
2322
2495
|
} else if (detail !== void 0) {
|
|
2323
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2496
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.TOO_MANY_REQUESTS, detail);
|
|
2324
2497
|
} else if (fieldMessageOrDetail) {
|
|
2325
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2498
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.TOO_MANY_REQUESTS);
|
|
2326
2499
|
} else {
|
|
2327
|
-
super(messageOrField,
|
|
2500
|
+
super(messageOrField, import_common33.HttpStatus.TOO_MANY_REQUESTS);
|
|
2328
2501
|
}
|
|
2329
2502
|
}
|
|
2330
2503
|
};
|
|
2331
2504
|
|
|
2332
2505
|
// src/exceptions/unauthorized.exception.ts
|
|
2333
|
-
var
|
|
2334
|
-
var
|
|
2506
|
+
var import_common34 = require("@nestjs/common");
|
|
2507
|
+
var UnauthorizedException5 = class extends BaseFieldException {
|
|
2335
2508
|
static {
|
|
2336
2509
|
__name(this, "UnauthorizedException");
|
|
2337
2510
|
}
|
|
2338
2511
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2339
2512
|
if (Array.isArray(messageOrField)) {
|
|
2340
|
-
super(messageOrField,
|
|
2513
|
+
super(messageOrField, import_common34.HttpStatus.UNAUTHORIZED, fieldMessageOrDetail);
|
|
2341
2514
|
} else if (detail !== void 0) {
|
|
2342
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2515
|
+
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.UNAUTHORIZED, detail);
|
|
2343
2516
|
} else if (fieldMessageOrDetail) {
|
|
2344
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2517
|
+
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.UNAUTHORIZED);
|
|
2345
2518
|
} else {
|
|
2346
|
-
super(messageOrField,
|
|
2519
|
+
super(messageOrField, import_common34.HttpStatus.UNAUTHORIZED);
|
|
2347
2520
|
}
|
|
2348
2521
|
}
|
|
2349
2522
|
};
|
|
2350
2523
|
|
|
2351
2524
|
// src/exceptions/unprocessable-entity.exception.ts
|
|
2352
|
-
var
|
|
2525
|
+
var import_common35 = require("@nestjs/common");
|
|
2353
2526
|
var UnprocessableEntityException = class extends BaseFieldException {
|
|
2354
2527
|
static {
|
|
2355
2528
|
__name(this, "UnprocessableEntityException");
|
|
2356
2529
|
}
|
|
2357
2530
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2358
2531
|
if (Array.isArray(messageOrField)) {
|
|
2359
|
-
super(messageOrField,
|
|
2532
|
+
super(messageOrField, import_common35.HttpStatus.UNPROCESSABLE_ENTITY, fieldMessageOrDetail);
|
|
2360
2533
|
} else if (detail !== void 0) {
|
|
2361
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2534
|
+
super(messageOrField, fieldMessageOrDetail, import_common35.HttpStatus.UNPROCESSABLE_ENTITY, detail);
|
|
2362
2535
|
} else if (fieldMessageOrDetail) {
|
|
2363
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2536
|
+
super(messageOrField, fieldMessageOrDetail, import_common35.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2364
2537
|
} else {
|
|
2365
|
-
super(messageOrField,
|
|
2538
|
+
super(messageOrField, import_common35.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2366
2539
|
}
|
|
2367
2540
|
}
|
|
2368
2541
|
};
|
|
2369
2542
|
|
|
2370
2543
|
// src/exceptions/unsupported-media-type.exception.ts
|
|
2371
|
-
var
|
|
2544
|
+
var import_common36 = require("@nestjs/common");
|
|
2372
2545
|
var UnsupportedMediaTypeException = class extends BaseFieldException {
|
|
2373
2546
|
static {
|
|
2374
2547
|
__name(this, "UnsupportedMediaTypeException");
|
|
2375
2548
|
}
|
|
2376
2549
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2377
2550
|
if (Array.isArray(messageOrField)) {
|
|
2378
|
-
super(messageOrField,
|
|
2551
|
+
super(messageOrField, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE, fieldMessageOrDetail);
|
|
2379
2552
|
} else if (detail !== void 0) {
|
|
2380
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2553
|
+
super(messageOrField, fieldMessageOrDetail, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE, detail);
|
|
2381
2554
|
} else if (fieldMessageOrDetail) {
|
|
2382
|
-
super(messageOrField, fieldMessageOrDetail,
|
|
2555
|
+
super(messageOrField, fieldMessageOrDetail, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2383
2556
|
} else {
|
|
2384
|
-
super(messageOrField,
|
|
2557
|
+
super(messageOrField, import_common36.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2385
2558
|
}
|
|
2386
2559
|
}
|
|
2387
2560
|
};
|
|
2388
2561
|
|
|
2389
2562
|
// src/exceptions/validation.exception.ts
|
|
2390
|
-
var
|
|
2563
|
+
var import_common37 = require("@nestjs/common");
|
|
2391
2564
|
var ValidationException = class extends BaseFieldException {
|
|
2392
2565
|
static {
|
|
2393
2566
|
__name(this, "ValidationException");
|
|
2394
2567
|
}
|
|
2395
2568
|
constructor(errors, detail) {
|
|
2396
|
-
super(errors,
|
|
2569
|
+
super(errors, import_common37.HttpStatus.BAD_REQUEST, detail);
|
|
2397
2570
|
}
|
|
2398
2571
|
};
|
|
2399
2572
|
|
|
2400
2573
|
// src/filters/http-exception.filter.ts
|
|
2401
|
-
var
|
|
2402
|
-
function
|
|
2574
|
+
var import_common38 = require("@nestjs/common");
|
|
2575
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2403
2576
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2404
2577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2405
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;
|
|
2406
2579
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2407
2580
|
}
|
|
2408
|
-
__name(
|
|
2581
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2409
2582
|
function getHttpStatusTitle(status) {
|
|
2410
|
-
const enumKey = Object.entries(
|
|
2583
|
+
const enumKey = Object.entries(import_common38.HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2411
2584
|
if (!enumKey) {
|
|
2412
2585
|
return "Error";
|
|
2413
2586
|
}
|
|
@@ -2418,14 +2591,14 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2418
2591
|
static {
|
|
2419
2592
|
__name(this, "HttpExceptionFilter");
|
|
2420
2593
|
}
|
|
2421
|
-
logger = new
|
|
2594
|
+
logger = new import_common38.Logger(_HttpExceptionFilter.name);
|
|
2422
2595
|
catch(exception, host) {
|
|
2423
2596
|
const ctx = host.switchToHttp();
|
|
2424
2597
|
const response = ctx.getResponse();
|
|
2425
|
-
let status =
|
|
2598
|
+
let status = import_common38.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2426
2599
|
let errors = [];
|
|
2427
2600
|
let detail = "Internal server error";
|
|
2428
|
-
if (exception instanceof
|
|
2601
|
+
if (exception instanceof import_common38.HttpException) {
|
|
2429
2602
|
status = exception.getStatus();
|
|
2430
2603
|
const exceptionResponse = exception.getResponse();
|
|
2431
2604
|
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
@@ -2483,25 +2656,45 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2483
2656
|
response.status(status).send(problemDetails);
|
|
2484
2657
|
}
|
|
2485
2658
|
};
|
|
2486
|
-
HttpExceptionFilter =
|
|
2487
|
-
(0,
|
|
2659
|
+
HttpExceptionFilter = _ts_decorate12([
|
|
2660
|
+
(0, import_common38.Catch)()
|
|
2488
2661
|
], HttpExceptionFilter);
|
|
2489
2662
|
|
|
2663
|
+
// src/http/http.module.ts
|
|
2664
|
+
var import_common40 = require("@nestjs/common");
|
|
2665
|
+
|
|
2490
2666
|
// src/http/guards/csrf.guard.ts
|
|
2491
|
-
var
|
|
2492
|
-
|
|
2667
|
+
var import_common39 = require("@nestjs/common");
|
|
2668
|
+
var import_core6 = require("@nestjs/core");
|
|
2669
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2493
2670
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2494
2671
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2495
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;
|
|
2496
2673
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2497
2674
|
}
|
|
2498
|
-
__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");
|
|
2499
2680
|
var CsrfGuard = class _CsrfGuard {
|
|
2500
2681
|
static {
|
|
2501
2682
|
__name(this, "CsrfGuard");
|
|
2502
2683
|
}
|
|
2503
|
-
|
|
2684
|
+
reflector;
|
|
2685
|
+
logger = new import_common39.Logger(_CsrfGuard.name);
|
|
2686
|
+
constructor(reflector) {
|
|
2687
|
+
this.reflector = reflector;
|
|
2688
|
+
}
|
|
2504
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
|
+
}
|
|
2505
2698
|
const request = context.switchToHttp().getRequest();
|
|
2506
2699
|
const reply = context.switchToHttp().getResponse();
|
|
2507
2700
|
const safeMethods = [
|
|
@@ -2516,7 +2709,7 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2516
2709
|
const fastifyInstance = request.server;
|
|
2517
2710
|
if (!fastifyInstance.csrfProtection) {
|
|
2518
2711
|
this.logger.error("CSRF protection plugin not found. Ensure @fastify/csrf-protection is registered.");
|
|
2519
|
-
throw new
|
|
2712
|
+
throw new import_common39.ForbiddenException("CSRF protection not configured");
|
|
2520
2713
|
}
|
|
2521
2714
|
await new Promise((resolve, reject) => {
|
|
2522
2715
|
fastifyInstance.csrfProtection(request, reply, (err) => {
|
|
@@ -2531,7 +2724,7 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2531
2724
|
return true;
|
|
2532
2725
|
} catch (error) {
|
|
2533
2726
|
this.logger.warn(`CSRF validation failed for ${request.method} ${request.url}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2534
|
-
throw new
|
|
2727
|
+
throw new import_common39.ForbiddenException({
|
|
2535
2728
|
errors: [
|
|
2536
2729
|
{
|
|
2537
2730
|
field: "csrf",
|
|
@@ -2543,26 +2736,29 @@ var CsrfGuard = class _CsrfGuard {
|
|
|
2543
2736
|
}
|
|
2544
2737
|
}
|
|
2545
2738
|
};
|
|
2546
|
-
CsrfGuard =
|
|
2547
|
-
(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
|
+
])
|
|
2548
2745
|
], CsrfGuard);
|
|
2549
2746
|
|
|
2550
2747
|
// src/http/http.module.ts
|
|
2551
|
-
|
|
2552
|
-
function _ts_decorate13(decorators, target, key, desc) {
|
|
2748
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2553
2749
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2554
2750
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2555
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;
|
|
2556
2752
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2557
2753
|
}
|
|
2558
|
-
__name(
|
|
2754
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2559
2755
|
var HttpModule = class {
|
|
2560
2756
|
static {
|
|
2561
2757
|
__name(this, "HttpModule");
|
|
2562
2758
|
}
|
|
2563
2759
|
};
|
|
2564
|
-
HttpModule =
|
|
2565
|
-
(0,
|
|
2760
|
+
HttpModule = _ts_decorate14([
|
|
2761
|
+
(0, import_common40.Module)({
|
|
2566
2762
|
providers: [
|
|
2567
2763
|
CsrfGuard
|
|
2568
2764
|
],
|
|
@@ -2572,12 +2768,222 @@ HttpModule = _ts_decorate13([
|
|
|
2572
2768
|
})
|
|
2573
2769
|
], HttpModule);
|
|
2574
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
|
+
|
|
2575
2981
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2576
|
-
var
|
|
2982
|
+
var import_common42 = require("@nestjs/common");
|
|
2577
2983
|
var import_operators2 = require("rxjs/operators");
|
|
2578
2984
|
|
|
2579
2985
|
// src/logger/services/logger.service.ts
|
|
2580
|
-
var
|
|
2986
|
+
var import_common41 = require("@nestjs/common");
|
|
2581
2987
|
var import_winston = require("winston");
|
|
2582
2988
|
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
2583
2989
|
|
|
@@ -2615,17 +3021,17 @@ function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_C
|
|
|
2615
3021
|
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2616
3022
|
|
|
2617
3023
|
// src/logger/services/logger.service.ts
|
|
2618
|
-
function
|
|
3024
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2619
3025
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2620
3026
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2621
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;
|
|
2622
3028
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2623
3029
|
}
|
|
2624
|
-
__name(
|
|
2625
|
-
function
|
|
3030
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3031
|
+
function _ts_metadata9(k, v) {
|
|
2626
3032
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2627
3033
|
}
|
|
2628
|
-
__name(
|
|
3034
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2629
3035
|
function _ts_param4(paramIndex, decorator) {
|
|
2630
3036
|
return function(target, key) {
|
|
2631
3037
|
decorator(target, key, paramIndex);
|
|
@@ -2833,29 +3239,29 @@ ${trace}`;
|
|
|
2833
3239
|
return childLogger;
|
|
2834
3240
|
}
|
|
2835
3241
|
};
|
|
2836
|
-
LoggerService =
|
|
2837
|
-
(0,
|
|
2838
|
-
_ts_param4(0, (0,
|
|
2839
|
-
_ts_param4(1, (0,
|
|
2840
|
-
|
|
2841
|
-
|
|
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", [
|
|
2842
3248
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2843
3249
|
typeof Logger === "undefined" ? Object : Logger
|
|
2844
3250
|
])
|
|
2845
3251
|
], LoggerService);
|
|
2846
3252
|
|
|
2847
3253
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2848
|
-
function
|
|
3254
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2849
3255
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2850
3256
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2851
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;
|
|
2852
3258
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2853
3259
|
}
|
|
2854
|
-
__name(
|
|
2855
|
-
function
|
|
3260
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3261
|
+
function _ts_metadata10(k, v) {
|
|
2856
3262
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2857
3263
|
}
|
|
2858
|
-
__name(
|
|
3264
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2859
3265
|
function _ts_param5(paramIndex, decorator) {
|
|
2860
3266
|
return function(target, key) {
|
|
2861
3267
|
decorator(target, key, paramIndex);
|
|
@@ -2963,32 +3369,32 @@ var HttpLoggerInterceptor = class {
|
|
|
2963
3369
|
}
|
|
2964
3370
|
}
|
|
2965
3371
|
};
|
|
2966
|
-
HttpLoggerInterceptor =
|
|
2967
|
-
(0,
|
|
2968
|
-
_ts_param5(1, (0,
|
|
2969
|
-
|
|
2970
|
-
|
|
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", [
|
|
2971
3377
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
2972
3378
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
2973
3379
|
])
|
|
2974
3380
|
], HttpLoggerInterceptor);
|
|
2975
3381
|
|
|
2976
3382
|
// src/logger/logger.module.ts
|
|
2977
|
-
var
|
|
3383
|
+
var import_common44 = require("@nestjs/common");
|
|
2978
3384
|
|
|
2979
3385
|
// src/logger/middleware/correlation-id.middleware.ts
|
|
2980
|
-
var
|
|
2981
|
-
function
|
|
3386
|
+
var import_common43 = require("@nestjs/common");
|
|
3387
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2982
3388
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2983
3389
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2984
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;
|
|
2985
3391
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2986
3392
|
}
|
|
2987
|
-
__name(
|
|
2988
|
-
function
|
|
3393
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3394
|
+
function _ts_metadata11(k, v) {
|
|
2989
3395
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2990
3396
|
}
|
|
2991
|
-
__name(
|
|
3397
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2992
3398
|
var CorrelationIdMiddleware = class {
|
|
2993
3399
|
static {
|
|
2994
3400
|
__name(this, "CorrelationIdMiddleware");
|
|
@@ -3031,22 +3437,22 @@ var CorrelationIdMiddleware = class {
|
|
|
3031
3437
|
}
|
|
3032
3438
|
}
|
|
3033
3439
|
};
|
|
3034
|
-
CorrelationIdMiddleware =
|
|
3035
|
-
(0,
|
|
3036
|
-
|
|
3037
|
-
|
|
3440
|
+
CorrelationIdMiddleware = _ts_decorate17([
|
|
3441
|
+
(0, import_common43.Injectable)(),
|
|
3442
|
+
_ts_metadata11("design:type", Function),
|
|
3443
|
+
_ts_metadata11("design:paramtypes", [
|
|
3038
3444
|
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
3039
3445
|
])
|
|
3040
3446
|
], CorrelationIdMiddleware);
|
|
3041
3447
|
|
|
3042
3448
|
// src/logger/logger.module.ts
|
|
3043
|
-
function
|
|
3449
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3044
3450
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3045
3451
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3046
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;
|
|
3047
3453
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3048
3454
|
}
|
|
3049
|
-
__name(
|
|
3455
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3050
3456
|
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
3051
3457
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
3052
3458
|
provider: "winston",
|
|
@@ -3135,9 +3541,9 @@ function mergeWithDefaults(options = {}) {
|
|
|
3135
3541
|
__name(mergeWithDefaults, "mergeWithDefaults");
|
|
3136
3542
|
function createDefaultLoggerProvider(options) {
|
|
3137
3543
|
return {
|
|
3138
|
-
provide:
|
|
3544
|
+
provide: import_common44.Logger,
|
|
3139
3545
|
useFactory: /* @__PURE__ */ __name(() => {
|
|
3140
|
-
const logger = new
|
|
3546
|
+
const logger = new import_common44.Logger();
|
|
3141
3547
|
if (options.level && typeof logger.setLogLevels === "function") {
|
|
3142
3548
|
const levels = getLevelsUpTo(options.level);
|
|
3143
3549
|
logger.setLogLevels(levels);
|
|
@@ -3167,7 +3573,7 @@ function createLoggerProviders(options = {}) {
|
|
|
3167
3573
|
inject: [
|
|
3168
3574
|
LOGGER_MODULE_OPTIONS,
|
|
3169
3575
|
{
|
|
3170
|
-
token:
|
|
3576
|
+
token: import_common44.Logger,
|
|
3171
3577
|
optional: true
|
|
3172
3578
|
}
|
|
3173
3579
|
]
|
|
@@ -3318,10 +3724,10 @@ var LoggerModule = class _LoggerModule {
|
|
|
3318
3724
|
...asyncProviders,
|
|
3319
3725
|
// Default logger provider
|
|
3320
3726
|
{
|
|
3321
|
-
provide:
|
|
3727
|
+
provide: import_common44.Logger,
|
|
3322
3728
|
useFactory: /* @__PURE__ */ __name((opts) => {
|
|
3323
3729
|
if (opts.provider === "default") {
|
|
3324
|
-
const logger = new
|
|
3730
|
+
const logger = new import_common44.Logger();
|
|
3325
3731
|
if (opts.level && typeof logger.setLogLevels === "function") {
|
|
3326
3732
|
const levels = getLevelsUpTo(opts.level);
|
|
3327
3733
|
logger.setLogLevels(levels);
|
|
@@ -3343,7 +3749,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3343
3749
|
inject: [
|
|
3344
3750
|
LOGGER_MODULE_OPTIONS,
|
|
3345
3751
|
{
|
|
3346
|
-
token:
|
|
3752
|
+
token: import_common44.Logger,
|
|
3347
3753
|
optional: true
|
|
3348
3754
|
}
|
|
3349
3755
|
]
|
|
@@ -3449,9 +3855,9 @@ var LoggerModule = class _LoggerModule {
|
|
|
3449
3855
|
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3450
3856
|
}
|
|
3451
3857
|
};
|
|
3452
|
-
LoggerModule =
|
|
3453
|
-
(0,
|
|
3454
|
-
(0,
|
|
3858
|
+
LoggerModule = _ts_decorate18([
|
|
3859
|
+
(0, import_common44.Global)(),
|
|
3860
|
+
(0, import_common44.Module)({})
|
|
3455
3861
|
], LoggerModule);
|
|
3456
3862
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3457
3863
|
0 && (module.exports = {
|
|
@@ -3461,7 +3867,6 @@ LoggerModule = _ts_decorate17([
|
|
|
3461
3867
|
BaseFieldException,
|
|
3462
3868
|
ConflictException,
|
|
3463
3869
|
CorrelationIdMiddleware,
|
|
3464
|
-
CsrfGuard,
|
|
3465
3870
|
DEFAULT_CORRELATION_HEADER,
|
|
3466
3871
|
DatabaseModule,
|
|
3467
3872
|
ForbiddenException,
|
|
@@ -3483,7 +3888,10 @@ LoggerModule = _ts_decorate17([
|
|
|
3483
3888
|
PrimaryDatabaseService,
|
|
3484
3889
|
Public,
|
|
3485
3890
|
RequestTimeoutException,
|
|
3891
|
+
SKIP_CSRF_KEY,
|
|
3486
3892
|
ServiceUnavailableException,
|
|
3893
|
+
SkipCsrf,
|
|
3894
|
+
SseAuthGuard,
|
|
3487
3895
|
Tenant,
|
|
3488
3896
|
TenantBaseRepository,
|
|
3489
3897
|
TenantContextService,
|
|
@@ -3499,6 +3907,7 @@ LoggerModule = _ts_decorate17([
|
|
|
3499
3907
|
configureApiSdk,
|
|
3500
3908
|
correlationStorage,
|
|
3501
3909
|
defineConfig,
|
|
3910
|
+
extractCountryFromPhone,
|
|
3502
3911
|
generateCorrelationId,
|
|
3503
3912
|
getConfig,
|
|
3504
3913
|
getCorrelationContext,
|
|
@@ -3506,6 +3915,7 @@ LoggerModule = _ts_decorate17([
|
|
|
3506
3915
|
getJwtExpiry,
|
|
3507
3916
|
getRefreshCookieOptions,
|
|
3508
3917
|
hashToken,
|
|
3918
|
+
normalizePhoneNumber,
|
|
3509
3919
|
resetConfig,
|
|
3510
3920
|
runWithCorrelationContext,
|
|
3511
3921
|
updateCorrelationContext,
|