cadenlane-cli-2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +333 -0
- package/bin.js +2 -0
- package/dist/application/config/config.manager.d.ts +62 -0
- package/dist/application/config/config.manager.d.ts.map +1 -0
- package/dist/application/config/config.manager.js +146 -0
- package/dist/application/config/config.manager.js.map +1 -0
- package/dist/application/services/application.service.d.ts +35 -0
- package/dist/application/services/application.service.d.ts.map +1 -0
- package/dist/application/services/application.service.js +174 -0
- package/dist/application/services/application.service.js.map +1 -0
- package/dist/application/services/download.service.d.ts +27 -0
- package/dist/application/services/download.service.d.ts.map +1 -0
- package/dist/application/services/download.service.js +197 -0
- package/dist/application/services/download.service.js.map +1 -0
- package/dist/application/services/file-naming.service.d.ts +34 -0
- package/dist/application/services/file-naming.service.d.ts.map +1 -0
- package/dist/application/services/file-naming.service.js +142 -0
- package/dist/application/services/file-naming.service.js.map +1 -0
- package/dist/application/services/queue.service.d.ts +53 -0
- package/dist/application/services/queue.service.d.ts.map +1 -0
- package/dist/application/services/queue.service.js +82 -0
- package/dist/application/services/queue.service.js.map +1 -0
- package/dist/cli/commands/start.command.d.ts +39 -0
- package/dist/cli/commands/start.command.d.ts.map +1 -0
- package/dist/cli/commands/start.command.js +196 -0
- package/dist/cli/commands/start.command.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +86 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/domain/constants/config.constants.d.ts +54 -0
- package/dist/domain/constants/config.constants.d.ts.map +1 -0
- package/dist/domain/constants/config.constants.js +142 -0
- package/dist/domain/constants/config.constants.js.map +1 -0
- package/dist/domain/dtos/index.d.ts +4 -0
- package/dist/domain/dtos/index.d.ts.map +1 -0
- package/dist/domain/dtos/index.js +10 -0
- package/dist/domain/dtos/index.js.map +1 -0
- package/dist/domain/dtos/log-entry.dto.d.ts +15 -0
- package/dist/domain/dtos/log-entry.dto.d.ts.map +1 -0
- package/dist/domain/dtos/log-entry.dto.js +64 -0
- package/dist/domain/dtos/log-entry.dto.js.map +1 -0
- package/dist/domain/dtos/message.dto.d.ts +27 -0
- package/dist/domain/dtos/message.dto.d.ts.map +1 -0
- package/dist/domain/dtos/message.dto.js +140 -0
- package/dist/domain/dtos/message.dto.js.map +1 -0
- package/dist/domain/dtos/queue-message.dto.d.ts +10 -0
- package/dist/domain/dtos/queue-message.dto.d.ts.map +1 -0
- package/dist/domain/dtos/queue-message.dto.js +39 -0
- package/dist/domain/dtos/queue-message.dto.js.map +1 -0
- package/dist/domain/entities/cli-instance.entity.d.ts +55 -0
- package/dist/domain/entities/cli-instance.entity.d.ts.map +1 -0
- package/dist/domain/entities/cli-instance.entity.js +132 -0
- package/dist/domain/entities/cli-instance.entity.js.map +1 -0
- package/dist/domain/entities/index.d.ts +3 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +8 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/entities/log-entry.entity.d.ts +60 -0
- package/dist/domain/entities/log-entry.entity.d.ts.map +1 -0
- package/dist/domain/entities/log-entry.entity.js +101 -0
- package/dist/domain/entities/log-entry.entity.js.map +1 -0
- package/dist/domain/entities/message.entity.d.ts +64 -0
- package/dist/domain/entities/message.entity.d.ts.map +1 -0
- package/dist/domain/entities/message.entity.js +110 -0
- package/dist/domain/entities/message.entity.js.map +1 -0
- package/dist/domain/enums/error-category.enum.d.ts +11 -0
- package/dist/domain/enums/error-category.enum.d.ts.map +1 -0
- package/dist/domain/enums/error-category.enum.js +15 -0
- package/dist/domain/enums/error-category.enum.js.map +1 -0
- package/dist/domain/enums/index.d.ts +4 -0
- package/dist/domain/enums/index.d.ts.map +1 -0
- package/dist/domain/enums/index.js +10 -0
- package/dist/domain/enums/index.js.map +1 -0
- package/dist/domain/enums/log-level.enum.d.ts +11 -0
- package/dist/domain/enums/log-level.enum.d.ts.map +1 -0
- package/dist/domain/enums/log-level.enum.js +15 -0
- package/dist/domain/enums/log-level.enum.js.map +1 -0
- package/dist/domain/enums/message-status.enum.d.ts +11 -0
- package/dist/domain/enums/message-status.enum.d.ts.map +1 -0
- package/dist/domain/enums/message-status.enum.js +15 -0
- package/dist/domain/enums/message-status.enum.js.map +1 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.d.ts +34 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.js.map +1 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.d.ts +22 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.js.map +1 -0
- package/dist/domain/interfaces/adapters/index.d.ts +4 -0
- package/dist/domain/interfaces/adapters/index.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/index.js +3 -0
- package/dist/domain/interfaces/adapters/index.js.map +1 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.d.ts +27 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.js.map +1 -0
- package/dist/domain/interfaces/repositories/ilog.repository.d.ts +32 -0
- package/dist/domain/interfaces/repositories/ilog.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/ilog.repository.js +3 -0
- package/dist/domain/interfaces/repositories/ilog.repository.js.map +1 -0
- package/dist/domain/interfaces/repositories/imessage.repository.d.ts +39 -0
- package/dist/domain/interfaces/repositories/imessage.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/imessage.repository.js +3 -0
- package/dist/domain/interfaces/repositories/imessage.repository.js.map +1 -0
- package/dist/domain/interfaces/repositories/index.d.ts +4 -0
- package/dist/domain/interfaces/repositories/index.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/index.js +3 -0
- package/dist/domain/interfaces/repositories/index.js.map +1 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.d.ts +75 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.js +3 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.js.map +1 -0
- package/dist/domain/interfaces/services/idownload.service.d.ts +28 -0
- package/dist/domain/interfaces/services/idownload.service.d.ts.map +1 -0
- package/dist/domain/interfaces/services/idownload.service.js +3 -0
- package/dist/domain/interfaces/services/idownload.service.js.map +1 -0
- package/dist/domain/interfaces/services/iqueue.service.d.ts +35 -0
- package/dist/domain/interfaces/services/iqueue.service.d.ts.map +1 -0
- package/dist/domain/interfaces/services/iqueue.service.js +3 -0
- package/dist/domain/interfaces/services/iqueue.service.js.map +1 -0
- package/dist/domain/services/path-resolver.service.d.ts +94 -0
- package/dist/domain/services/path-resolver.service.d.ts.map +1 -0
- package/dist/domain/services/path-resolver.service.js +332 -0
- package/dist/domain/services/path-resolver.service.js.map +1 -0
- package/dist/domain/validators/index.d.ts +4 -0
- package/dist/domain/validators/index.d.ts.map +1 -0
- package/dist/domain/validators/index.js +10 -0
- package/dist/domain/validators/index.js.map +1 -0
- package/dist/domain/validators/message.validator.d.ts +20 -0
- package/dist/domain/validators/message.validator.d.ts.map +1 -0
- package/dist/domain/validators/message.validator.js +31 -0
- package/dist/domain/validators/message.validator.js.map +1 -0
- package/dist/domain/validators/path.validator.d.ts +44 -0
- package/dist/domain/validators/path.validator.d.ts.map +1 -0
- package/dist/domain/validators/path.validator.js +156 -0
- package/dist/domain/validators/path.validator.js.map +1 -0
- package/dist/domain/validators/url.validator.d.ts +19 -0
- package/dist/domain/validators/url.validator.d.ts.map +1 -0
- package/dist/domain/validators/url.validator.js +46 -0
- package/dist/domain/validators/url.validator.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/adapters/filesystem.adapter.d.ts +35 -0
- package/dist/infrastructure/adapters/filesystem.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/filesystem.adapter.js +103 -0
- package/dist/infrastructure/adapters/filesystem.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/http.adapter.d.ts +15 -0
- package/dist/infrastructure/adapters/http.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/http.adapter.js +80 -0
- package/dist/infrastructure/adapters/http.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/index.d.ts +4 -0
- package/dist/infrastructure/adapters/index.d.ts.map +1 -0
- package/dist/infrastructure/adapters/index.js +10 -0
- package/dist/infrastructure/adapters/index.js.map +1 -0
- package/dist/infrastructure/adapters/pgmq.adapter.d.ts +29 -0
- package/dist/infrastructure/adapters/pgmq.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/pgmq.adapter.js +84 -0
- package/dist/infrastructure/adapters/pgmq.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/supabase.adapter.d.ts +79 -0
- package/dist/infrastructure/adapters/supabase.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/supabase.adapter.js +97 -0
- package/dist/infrastructure/adapters/supabase.adapter.js.map +1 -0
- package/dist/infrastructure/database/supabase.client.d.ts +20 -0
- package/dist/infrastructure/database/supabase.client.d.ts.map +1 -0
- package/dist/infrastructure/database/supabase.client.js +36 -0
- package/dist/infrastructure/database/supabase.client.js.map +1 -0
- package/dist/infrastructure/di/container.d.ts +18 -0
- package/dist/infrastructure/di/container.d.ts.map +1 -0
- package/dist/infrastructure/di/container.js +103 -0
- package/dist/infrastructure/di/container.js.map +1 -0
- package/dist/infrastructure/repositories/cli-instance.repository.d.ts +64 -0
- package/dist/infrastructure/repositories/cli-instance.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/cli-instance.repository.js +154 -0
- package/dist/infrastructure/repositories/cli-instance.repository.js.map +1 -0
- package/dist/infrastructure/repositories/config.repository.d.ts +52 -0
- package/dist/infrastructure/repositories/config.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/config.repository.js +130 -0
- package/dist/infrastructure/repositories/config.repository.js.map +1 -0
- package/dist/infrastructure/repositories/index.d.ts +4 -0
- package/dist/infrastructure/repositories/index.d.ts.map +1 -0
- package/dist/infrastructure/repositories/index.js +10 -0
- package/dist/infrastructure/repositories/index.js.map +1 -0
- package/dist/infrastructure/repositories/log.repository.d.ts +44 -0
- package/dist/infrastructure/repositories/log.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/log.repository.js +108 -0
- package/dist/infrastructure/repositories/log.repository.js.map +1 -0
- package/dist/infrastructure/repositories/message.repository.d.ts +51 -0
- package/dist/infrastructure/repositories/message.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/message.repository.js +161 -0
- package/dist/infrastructure/repositories/message.repository.js.map +1 -0
- package/dist/infrastructure/repositories/queue.repository.d.ts +69 -0
- package/dist/infrastructure/repositories/queue.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/queue.repository.js +130 -0
- package/dist/infrastructure/repositories/queue.repository.js.map +1 -0
- package/dist/infrastructure/utils/connection-health.util.d.ts +23 -0
- package/dist/infrastructure/utils/connection-health.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/connection-health.util.js +64 -0
- package/dist/infrastructure/utils/connection-health.util.js.map +1 -0
- package/package.json +105 -0
- package/pm2.config.js +104 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PathResolverService = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const os = __importStar(require("os"));
|
|
39
|
+
/**
|
|
40
|
+
* PathResolver Service
|
|
41
|
+
* Handles cross-platform path resolution and validation
|
|
42
|
+
*
|
|
43
|
+
* Design Principles:
|
|
44
|
+
* - All paths must be absolute
|
|
45
|
+
* - Platform-specific validation (Windows drive letters, Unix root)
|
|
46
|
+
* - Home directory expansion support (~)
|
|
47
|
+
* - Environment variable expansion (%VAR% on Windows, $VAR on Unix)
|
|
48
|
+
*/
|
|
49
|
+
class PathResolverService {
|
|
50
|
+
platformInfo;
|
|
51
|
+
constructor() {
|
|
52
|
+
const platform = process.platform;
|
|
53
|
+
this.platformInfo = {
|
|
54
|
+
platform,
|
|
55
|
+
isWindows: platform === 'win32',
|
|
56
|
+
isMac: platform === 'darwin',
|
|
57
|
+
isLinux: platform === 'linux',
|
|
58
|
+
homeDir: os.homedir(),
|
|
59
|
+
separator: path.sep,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get current platform information
|
|
64
|
+
*/
|
|
65
|
+
getPlatformInfo() {
|
|
66
|
+
return { ...this.platformInfo };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a path to an absolute path with platform-specific handling
|
|
70
|
+
* @param inputPath - The path to resolve (can include ~ or env vars)
|
|
71
|
+
* @param fallbackPath - Optional fallback if resolution fails
|
|
72
|
+
* @returns Resolution result with absolute path or error
|
|
73
|
+
*/
|
|
74
|
+
resolve(inputPath, fallbackPath) {
|
|
75
|
+
try {
|
|
76
|
+
// If primary path is invalid, try fallback first
|
|
77
|
+
if (!inputPath || typeof inputPath !== 'string' || inputPath.trim() === '') {
|
|
78
|
+
if (fallbackPath) {
|
|
79
|
+
return this.resolve(fallbackPath);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
absolutePath: '',
|
|
83
|
+
isValid: false,
|
|
84
|
+
error: 'Path is empty or invalid',
|
|
85
|
+
platform: this.platformInfo.platform,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let resolvedPath = inputPath.trim();
|
|
89
|
+
// Step 1: Expand home directory (~)
|
|
90
|
+
resolvedPath = this.expandHomeDirectory(resolvedPath);
|
|
91
|
+
// Step 2: Expand environment variables
|
|
92
|
+
resolvedPath = this.expandEnvironmentVariables(resolvedPath);
|
|
93
|
+
// Step 3: Normalize path separators
|
|
94
|
+
resolvedPath = this.normalizeSeparators(resolvedPath);
|
|
95
|
+
// Step 4: Check if path is absolute (platform-aware)
|
|
96
|
+
const isAbsolute = this.isPathAbsolute(resolvedPath);
|
|
97
|
+
if (!isAbsolute) {
|
|
98
|
+
return {
|
|
99
|
+
absolutePath: resolvedPath,
|
|
100
|
+
isValid: false,
|
|
101
|
+
error: `Path must be absolute. Got: ${resolvedPath}`,
|
|
102
|
+
platform: this.platformInfo.platform,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Step 5: Normalize the path
|
|
106
|
+
resolvedPath = path.normalize(resolvedPath);
|
|
107
|
+
// Step 6: Platform-specific validation
|
|
108
|
+
const validationError = this.validatePlatformPath(resolvedPath);
|
|
109
|
+
if (validationError) {
|
|
110
|
+
// If validation fails and we have a fallback, try it
|
|
111
|
+
if (fallbackPath && fallbackPath !== inputPath) {
|
|
112
|
+
return this.resolve(fallbackPath);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
absolutePath: resolvedPath,
|
|
116
|
+
isValid: false,
|
|
117
|
+
error: validationError,
|
|
118
|
+
platform: this.platformInfo.platform,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
absolutePath: resolvedPath,
|
|
123
|
+
isValid: true,
|
|
124
|
+
platform: this.platformInfo.platform,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
129
|
+
return {
|
|
130
|
+
absolutePath: '',
|
|
131
|
+
isValid: false,
|
|
132
|
+
error: `Path resolution failed: ${message}`,
|
|
133
|
+
platform: this.platformInfo.platform,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get default download path for current platform
|
|
139
|
+
* @returns Platform-specific default download directory
|
|
140
|
+
*/
|
|
141
|
+
getDefaultDownloadPath() {
|
|
142
|
+
if (this.platformInfo.isWindows) {
|
|
143
|
+
// Windows: C:\Users\{username}\Downloads
|
|
144
|
+
return path.join(this.platformInfo.homeDir, 'Downloads');
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// Mac/Linux: ~/Downloads
|
|
148
|
+
return path.join(this.platformInfo.homeDir, 'Downloads');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Expand home directory shorthand (~)
|
|
153
|
+
* Works on all platforms
|
|
154
|
+
*/
|
|
155
|
+
expandHomeDirectory(inputPath) {
|
|
156
|
+
if (inputPath.startsWith('~/') || inputPath.startsWith('~\\')) {
|
|
157
|
+
// Join home dir with the rest of the path
|
|
158
|
+
const restOfPath = inputPath.slice(2);
|
|
159
|
+
return path.join(this.platformInfo.homeDir, restOfPath);
|
|
160
|
+
}
|
|
161
|
+
if (inputPath === '~') {
|
|
162
|
+
return this.platformInfo.homeDir;
|
|
163
|
+
}
|
|
164
|
+
return inputPath;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Expand environment variables
|
|
168
|
+
* - Windows: %VAR%
|
|
169
|
+
* - Unix: $VAR or ${VAR}
|
|
170
|
+
*/
|
|
171
|
+
expandEnvironmentVariables(inputPath) {
|
|
172
|
+
if (this.platformInfo.isWindows) {
|
|
173
|
+
// Windows: %USERPROFILE%, %APPDATA%, etc.
|
|
174
|
+
return inputPath.replace(/%([^%]+)%/g, (_, varName) => {
|
|
175
|
+
return process.env[varName] || `%${varName}%`;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// Unix: $HOME, ${HOME}, etc.
|
|
180
|
+
return inputPath
|
|
181
|
+
.replace(/\$\{([^}]+)\}/g, (_, varName) => {
|
|
182
|
+
return process.env[varName] || `\${${varName}}`;
|
|
183
|
+
})
|
|
184
|
+
.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_, varName) => {
|
|
185
|
+
return process.env[varName] || `$${varName}`;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Normalize path separators for current platform
|
|
191
|
+
*/
|
|
192
|
+
normalizeSeparators(inputPath) {
|
|
193
|
+
if (this.platformInfo.isWindows) {
|
|
194
|
+
// Convert forward slashes to backslashes on Windows
|
|
195
|
+
return inputPath.replace(/\//g, '\\');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// Convert backslashes to forward slashes on Unix
|
|
199
|
+
return inputPath.replace(/\\/g, '/');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Check if path is absolute (platform-aware)
|
|
204
|
+
* This is more reliable than path.isAbsolute() for cross-platform testing
|
|
205
|
+
*/
|
|
206
|
+
isPathAbsolute(inputPath) {
|
|
207
|
+
if (this.platformInfo.isWindows) {
|
|
208
|
+
// Windows: Check for drive letter (C:\) or UNC path (\\server\share)
|
|
209
|
+
const driveLetterRegex = /^[a-zA-Z]:\\/;
|
|
210
|
+
const uncRegex = /^\\\\[^\\]+\\[^\\]+/;
|
|
211
|
+
return driveLetterRegex.test(inputPath) || uncRegex.test(inputPath);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// Unix: Must start with /
|
|
215
|
+
return inputPath.startsWith('/');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Validate path for current platform
|
|
220
|
+
* @returns Error message if invalid, undefined if valid
|
|
221
|
+
*/
|
|
222
|
+
validatePlatformPath(absolutePath) {
|
|
223
|
+
if (this.platformInfo.isWindows) {
|
|
224
|
+
return this.validateWindowsPath(absolutePath);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return this.validateUnixPath(absolutePath);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Validate Windows-specific path requirements
|
|
232
|
+
*/
|
|
233
|
+
validateWindowsPath(absolutePath) {
|
|
234
|
+
// Check for drive letter (C:, D:, etc.)
|
|
235
|
+
const driveLetterRegex = /^[a-zA-Z]:\\/;
|
|
236
|
+
if (!driveLetterRegex.test(absolutePath)) {
|
|
237
|
+
// Check for UNC path (\\server\share)
|
|
238
|
+
const uncRegex = /^\\\\[^\\]+\\[^\\]+/;
|
|
239
|
+
if (!uncRegex.test(absolutePath)) {
|
|
240
|
+
return `Windows path must start with drive letter (e.g., C:\\) or UNC path (e.g., \\\\server\\share). Got: ${absolutePath}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Check for invalid Windows characters: < > : " | ? *
|
|
244
|
+
// Note: : is allowed in drive letter position
|
|
245
|
+
const invalidChars = /[<>"|?*]/;
|
|
246
|
+
const pathWithoutDrive = absolutePath.substring(3); // Skip C:\
|
|
247
|
+
if (invalidChars.test(pathWithoutDrive)) {
|
|
248
|
+
return `Windows path contains invalid characters (< > " | ? *): ${absolutePath}`;
|
|
249
|
+
}
|
|
250
|
+
// Check for reserved names (CON, PRN, AUX, NUL, COM1-9, LPT1-9)
|
|
251
|
+
const reservedNames = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
252
|
+
const pathParts = absolutePath.split('\\');
|
|
253
|
+
for (const part of pathParts) {
|
|
254
|
+
const nameWithoutExt = part.split('.')[0];
|
|
255
|
+
if (reservedNames.test(nameWithoutExt)) {
|
|
256
|
+
return `Windows path contains reserved name: ${part}`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Validate Unix-specific path requirements (Mac/Linux)
|
|
263
|
+
*/
|
|
264
|
+
validateUnixPath(absolutePath) {
|
|
265
|
+
// Must start with /
|
|
266
|
+
if (!absolutePath.startsWith('/')) {
|
|
267
|
+
return `Unix path must start with /. Got: ${absolutePath}`;
|
|
268
|
+
}
|
|
269
|
+
// Check for null bytes (security)
|
|
270
|
+
if (absolutePath.includes('\0')) {
|
|
271
|
+
return 'Path contains null bytes';
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Format a path example for current platform
|
|
277
|
+
* Useful for error messages and UI placeholders
|
|
278
|
+
*/
|
|
279
|
+
getPathExample(type) {
|
|
280
|
+
if (this.platformInfo.isWindows) {
|
|
281
|
+
switch (type) {
|
|
282
|
+
case 'downloads':
|
|
283
|
+
return 'C:\\Users\\YourName\\Downloads';
|
|
284
|
+
case 'documents':
|
|
285
|
+
return 'C:\\Users\\YourName\\Documents';
|
|
286
|
+
case 'desktop':
|
|
287
|
+
return 'C:\\Users\\YourName\\Desktop';
|
|
288
|
+
case 'custom':
|
|
289
|
+
return 'C:\\MyFolder\\Images';
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (this.platformInfo.isMac) {
|
|
293
|
+
switch (type) {
|
|
294
|
+
case 'downloads':
|
|
295
|
+
return '/Users/YourName/Downloads';
|
|
296
|
+
case 'documents':
|
|
297
|
+
return '/Users/YourName/Documents';
|
|
298
|
+
case 'desktop':
|
|
299
|
+
return '/Users/YourName/Desktop';
|
|
300
|
+
case 'custom':
|
|
301
|
+
return '/Users/YourName/MyFolder/Images';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// Linux
|
|
306
|
+
switch (type) {
|
|
307
|
+
case 'downloads':
|
|
308
|
+
return '/home/username/Downloads';
|
|
309
|
+
case 'documents':
|
|
310
|
+
return '/home/username/Documents';
|
|
311
|
+
case 'desktop':
|
|
312
|
+
return '/home/username/Desktop';
|
|
313
|
+
case 'custom':
|
|
314
|
+
return '/home/username/myfolder/images';
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Check if a path is safe (no directory traversal)
|
|
320
|
+
* This is a secondary check after resolution
|
|
321
|
+
*/
|
|
322
|
+
isSafePath(absolutePath) {
|
|
323
|
+
// Normalize the path first
|
|
324
|
+
const normalized = path.normalize(absolutePath);
|
|
325
|
+
// Check for .. in the path segments
|
|
326
|
+
// path.normalize should resolve these, but we check anyway
|
|
327
|
+
const segments = normalized.split(/[/\\]/);
|
|
328
|
+
return !segments.includes('..');
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.PathResolverService = PathResolverService;
|
|
332
|
+
//# sourceMappingURL=path-resolver.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-resolver.service.js","sourceRoot":"","sources":["../../../src/domain/services/path-resolver.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,uCAAyB;AAwBzB;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IACb,YAAY,CAAe;IAE5C;QACE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAwC,CAAC;QAClE,IAAI,CAAC,YAAY,GAAG;YAClB,QAAQ;YACR,SAAS,EAAE,QAAQ,KAAK,OAAO;YAC/B,KAAK,EAAE,QAAQ,KAAK,QAAQ;YAC5B,OAAO,EAAE,QAAQ,KAAK,OAAO;YAC7B,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,IAAI,CAAC,GAAG;SACpB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,SAAiB,EAAE,YAAqB;QAC9C,IAAI,CAAC;YACH,iDAAiD;YACjD,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC3E,IAAI,YAAY,EAAE,CAAC;oBACjB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACpC,CAAC;gBACD,OAAO;oBACL,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,KAAK;oBACd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,0BAA0B,CAAC;gBACpC,KAAK,WAAW;oBACd,OAAO,0BAA0B,CAAC;gBACpC,KAAK,SAAS;oBACZ,OAAO,wBAAwB,CAAC;gBAClC,KAAK,QAAQ;oBACX,OAAO,gCAAgC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,YAAoB;QAC7B,2BAA2B;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAEhD,oCAAoC;QACpC,2DAA2D;QAC3D,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA5SD,kDA4SC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PathValidator = exports.UrlValidator = exports.MessageValidator = void 0;
|
|
4
|
+
var message_validator_1 = require("./message.validator");
|
|
5
|
+
Object.defineProperty(exports, "MessageValidator", { enumerable: true, get: function () { return message_validator_1.MessageValidator; } });
|
|
6
|
+
var url_validator_1 = require("./url.validator");
|
|
7
|
+
Object.defineProperty(exports, "UrlValidator", { enumerable: true, get: function () { return url_validator_1.UrlValidator; } });
|
|
8
|
+
var path_validator_1 = require("./path.validator");
|
|
9
|
+
Object.defineProperty(exports, "PathValidator", { enumerable: true, get: function () { return path_validator_1.PathValidator; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/validators/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyE;AAAhE,qHAAA,gBAAgB,OAAA;AACzB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation result interface
|
|
3
|
+
*/
|
|
4
|
+
export interface ValidationResult {
|
|
5
|
+
isValid: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Message Validator
|
|
10
|
+
* Validates queue message structure and required fields
|
|
11
|
+
*/
|
|
12
|
+
export declare class MessageValidator {
|
|
13
|
+
/**
|
|
14
|
+
* Validates a queue message
|
|
15
|
+
* @param message - The message to validate
|
|
16
|
+
* @returns ValidationResult with isValid flag and error messages
|
|
17
|
+
*/
|
|
18
|
+
validate(message: any): ValidationResult;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=message.validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.validator.d.ts","sourceRoot":"","sources":["../../../src/domain/validators/message.validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,gBAAgB;CAkBzC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageValidator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Message Validator
|
|
6
|
+
* Validates queue message structure and required fields
|
|
7
|
+
*/
|
|
8
|
+
class MessageValidator {
|
|
9
|
+
/**
|
|
10
|
+
* Validates a queue message
|
|
11
|
+
* @param message - The message to validate
|
|
12
|
+
* @returns ValidationResult with isValid flag and error messages
|
|
13
|
+
*/
|
|
14
|
+
validate(message) {
|
|
15
|
+
const errors = [];
|
|
16
|
+
// Check if file_url exists and is a non-empty string
|
|
17
|
+
if (!message.file_url || typeof message.file_url !== 'string' || message.file_url.trim() === '') {
|
|
18
|
+
errors.push('file_url is required');
|
|
19
|
+
}
|
|
20
|
+
// Check if target_folder exists and is a non-empty string
|
|
21
|
+
if (!message.target_folder || typeof message.target_folder !== 'string' || message.target_folder.trim() === '') {
|
|
22
|
+
errors.push('target_folder is required');
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
isValid: errors.length === 0,
|
|
26
|
+
errors,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.MessageValidator = MessageValidator;
|
|
31
|
+
//# sourceMappingURL=message.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.validator.js","sourceRoot":"","sources":["../../../src/domain/validators/message.validator.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACH,MAAa,gBAAgB;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAY;QACnB,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,qDAAqD;QACrD,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;QAED,0DAA0D;QAC1D,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/G,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC5B,MAAM;SACP,CAAC;IACJ,CAAC;CACF;AAxBD,4CAwBC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Validator
|
|
3
|
+
* Validates file system paths and prevents directory traversal attacks
|
|
4
|
+
*
|
|
5
|
+
* NOTE: This validator provides basic validation.
|
|
6
|
+
* For comprehensive cross-platform path resolution and validation,
|
|
7
|
+
* use PathResolverService from @/domain/services/path-resolver.service
|
|
8
|
+
*/
|
|
9
|
+
export declare class PathValidator {
|
|
10
|
+
private readonly isWindows;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Validates if a string is a valid path
|
|
14
|
+
* @param filePath - The path to validate
|
|
15
|
+
* @returns true if valid, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
isValid(filePath: any): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validates Windows-specific path format
|
|
20
|
+
*/
|
|
21
|
+
private isValidWindowsPath;
|
|
22
|
+
/**
|
|
23
|
+
* Validates Unix-specific path format (Mac/Linux)
|
|
24
|
+
*/
|
|
25
|
+
private isValidUnixPath;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a path is safe (no directory traversal)
|
|
28
|
+
* @param filePath - The path to check
|
|
29
|
+
* @returns true if safe, false otherwise
|
|
30
|
+
*/
|
|
31
|
+
isSafe(filePath: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes a file path using platform-specific separators
|
|
34
|
+
* @param filePath - The path to normalize
|
|
35
|
+
* @returns Normalized path
|
|
36
|
+
*/
|
|
37
|
+
normalize(filePath: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Check if path is absolute
|
|
40
|
+
* Cross-platform compatible
|
|
41
|
+
*/
|
|
42
|
+
isAbsolute(filePath: string): boolean;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=path.validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.validator.d.ts","sourceRoot":"","sources":["../../../src/domain/validators/path.validator.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;;IAMpC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO;IAoB/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IA6BjC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAgBnC;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGtC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PathValidator = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
/**
|
|
39
|
+
* Path Validator
|
|
40
|
+
* Validates file system paths and prevents directory traversal attacks
|
|
41
|
+
*
|
|
42
|
+
* NOTE: This validator provides basic validation.
|
|
43
|
+
* For comprehensive cross-platform path resolution and validation,
|
|
44
|
+
* use PathResolverService from @/domain/services/path-resolver.service
|
|
45
|
+
*/
|
|
46
|
+
class PathValidator {
|
|
47
|
+
isWindows;
|
|
48
|
+
constructor() {
|
|
49
|
+
this.isWindows = process.platform === 'win32';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Validates if a string is a valid path
|
|
53
|
+
* @param filePath - The path to validate
|
|
54
|
+
* @returns true if valid, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
isValid(filePath) {
|
|
57
|
+
if (!filePath || typeof filePath !== 'string' || filePath.trim() === '') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const trimmed = filePath.trim();
|
|
61
|
+
// Check for null bytes (security)
|
|
62
|
+
if (trimmed.includes('\0')) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Platform-specific validation
|
|
66
|
+
if (this.isWindows) {
|
|
67
|
+
return this.isValidWindowsPath(trimmed);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return this.isValidUnixPath(trimmed);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Validates Windows-specific path format
|
|
75
|
+
*/
|
|
76
|
+
isValidWindowsPath(filePath) {
|
|
77
|
+
// Check for invalid Windows characters: < > : " | ? *
|
|
78
|
+
// Note: : is allowed in drive letter position (C:)
|
|
79
|
+
const invalidCharsRegex = /[<>"|?*]/;
|
|
80
|
+
// If path has drive letter, check everything after it
|
|
81
|
+
if (/^[a-zA-Z]:/.test(filePath)) {
|
|
82
|
+
const pathAfterDrive = filePath.substring(2);
|
|
83
|
+
if (invalidCharsRegex.test(pathAfterDrive)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (invalidCharsRegex.test(filePath)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validates Unix-specific path format (Mac/Linux)
|
|
94
|
+
*/
|
|
95
|
+
isValidUnixPath(_filePath) {
|
|
96
|
+
// Unix paths are generally more permissive
|
|
97
|
+
// Main check is for null bytes (already done in isValid)
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a path is safe (no directory traversal)
|
|
102
|
+
* @param filePath - The path to check
|
|
103
|
+
* @returns true if safe, false otherwise
|
|
104
|
+
*/
|
|
105
|
+
isSafe(filePath) {
|
|
106
|
+
// Check for null bytes
|
|
107
|
+
if (filePath.includes('\0')) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
// Check for directory traversal patterns
|
|
111
|
+
if (filePath.includes('..')) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// Additional Windows checks
|
|
115
|
+
if (this.isWindows) {
|
|
116
|
+
// Check for reserved device names
|
|
117
|
+
const reservedNames = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
118
|
+
const pathParts = filePath.split(/[/\\]/);
|
|
119
|
+
for (const part of pathParts) {
|
|
120
|
+
if (!part)
|
|
121
|
+
continue;
|
|
122
|
+
const nameWithoutExt = part.split('.')[0];
|
|
123
|
+
if (reservedNames.test(nameWithoutExt)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Normalizes a file path using platform-specific separators
|
|
132
|
+
* @param filePath - The path to normalize
|
|
133
|
+
* @returns Normalized path
|
|
134
|
+
*/
|
|
135
|
+
normalize(filePath) {
|
|
136
|
+
if (!filePath) {
|
|
137
|
+
return '';
|
|
138
|
+
}
|
|
139
|
+
// Normalize the path using Node.js path module
|
|
140
|
+
let normalized = path.normalize(filePath);
|
|
141
|
+
// Remove trailing slash if present (except for root)
|
|
142
|
+
if (normalized.length > 1 && normalized.endsWith(path.sep)) {
|
|
143
|
+
normalized = normalized.slice(0, -1);
|
|
144
|
+
}
|
|
145
|
+
return normalized;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if path is absolute
|
|
149
|
+
* Cross-platform compatible
|
|
150
|
+
*/
|
|
151
|
+
isAbsolute(filePath) {
|
|
152
|
+
return path.isAbsolute(filePath);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.PathValidator = PathValidator;
|
|
156
|
+
//# sourceMappingURL=path.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.validator.js","sourceRoot":"","sources":["../../../src/domain/validators/path.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,CAAC,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AA5HD,sCA4HC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL Validator
|
|
3
|
+
* Validates URLs and extracts filenames
|
|
4
|
+
*/
|
|
5
|
+
export declare class UrlValidator {
|
|
6
|
+
/**
|
|
7
|
+
* Validates if a string is a valid HTTP/HTTPS URL
|
|
8
|
+
* @param url - The URL to validate
|
|
9
|
+
* @returns true if valid, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
isValid(url: any): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Extracts filename from URL
|
|
14
|
+
* @param url - The URL to extract filename from
|
|
15
|
+
* @returns The filename or 'download' as default
|
|
16
|
+
*/
|
|
17
|
+
extractFilename(url: string): string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=url.validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.validator.d.ts","sourceRoot":"","sources":["../../../src/domain/validators/url.validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,YAAY;IACvB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAa1B;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAarC"}
|