@ecency/sdk 1.5.6 → 1.5.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/browser/index.js +9 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +22 -8
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +22 -8
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -183,35 +183,48 @@ exports.ConfigManager = void 0;
|
|
|
183
183
|
return { safe: true };
|
|
184
184
|
}
|
|
185
185
|
function safeCompileRegex(pattern, maxLength = 200) {
|
|
186
|
+
const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
186
187
|
try {
|
|
187
188
|
if (!pattern) {
|
|
188
|
-
|
|
189
|
+
if (isDevelopment) {
|
|
190
|
+
console.warn(`[SDK] DMCA pattern rejected: empty pattern`);
|
|
191
|
+
}
|
|
189
192
|
return null;
|
|
190
193
|
}
|
|
191
194
|
if (pattern.length > maxLength) {
|
|
192
|
-
|
|
195
|
+
if (isDevelopment) {
|
|
196
|
+
console.warn(`[SDK] DMCA pattern rejected: length ${pattern.length} exceeds max ${maxLength} - pattern: ${pattern.substring(0, 50)}...`);
|
|
197
|
+
}
|
|
193
198
|
return null;
|
|
194
199
|
}
|
|
195
200
|
const staticAnalysis = analyzeRedosRisk(pattern);
|
|
196
201
|
if (!staticAnalysis.safe) {
|
|
197
|
-
|
|
202
|
+
if (isDevelopment) {
|
|
203
|
+
console.warn(`[SDK] DMCA pattern rejected: static analysis failed (${staticAnalysis.reason}) - pattern: ${pattern.substring(0, 50)}...`);
|
|
204
|
+
}
|
|
198
205
|
return null;
|
|
199
206
|
}
|
|
200
207
|
let regex;
|
|
201
208
|
try {
|
|
202
209
|
regex = new RegExp(pattern);
|
|
203
210
|
} catch (compileErr) {
|
|
204
|
-
|
|
211
|
+
if (isDevelopment) {
|
|
212
|
+
console.warn(`[SDK] DMCA pattern rejected: compilation failed - pattern: ${pattern.substring(0, 50)}...`, compileErr);
|
|
213
|
+
}
|
|
205
214
|
return null;
|
|
206
215
|
}
|
|
207
216
|
const runtimeTest = testRegexPerformance(regex);
|
|
208
217
|
if (!runtimeTest.safe) {
|
|
209
|
-
|
|
218
|
+
if (isDevelopment) {
|
|
219
|
+
console.warn(`[SDK] DMCA pattern rejected: runtime test failed (${runtimeTest.reason}) - pattern: ${pattern.substring(0, 50)}...`);
|
|
220
|
+
}
|
|
210
221
|
return null;
|
|
211
222
|
}
|
|
212
223
|
return regex;
|
|
213
224
|
} catch (err) {
|
|
214
|
-
|
|
225
|
+
if (isDevelopment) {
|
|
226
|
+
console.warn(`[SDK] DMCA pattern rejected: unexpected error - pattern: ${pattern.substring(0, 50)}...`, err);
|
|
227
|
+
}
|
|
215
228
|
return null;
|
|
216
229
|
}
|
|
217
230
|
}
|
|
@@ -222,7 +235,8 @@ exports.ConfigManager = void 0;
|
|
|
222
235
|
CONFIG.dmcaTagRegexes = tags.map((pattern) => safeCompileRegex(pattern)).filter((r) => r !== null);
|
|
223
236
|
CONFIG.dmcaPatternRegexes = [];
|
|
224
237
|
const rejectedTagCount = tags.length - CONFIG.dmcaTagRegexes.length;
|
|
225
|
-
|
|
238
|
+
const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
239
|
+
if (!CONFIG._dmcaInitialized && isDevelopment) {
|
|
226
240
|
console.log(`[SDK] DMCA configuration loaded:`);
|
|
227
241
|
console.log(` - Accounts: ${accounts.length}`);
|
|
228
242
|
console.log(` - Tag patterns: ${CONFIG.dmcaTagRegexes.length}/${tags.length} compiled (${rejectedTagCount} rejected)`);
|
|
@@ -230,8 +244,8 @@ exports.ConfigManager = void 0;
|
|
|
230
244
|
if (rejectedTagCount > 0) {
|
|
231
245
|
console.warn(`[SDK] ${rejectedTagCount} DMCA tag patterns were rejected due to security validation. Check warnings above for details.`);
|
|
232
246
|
}
|
|
233
|
-
CONFIG._dmcaInitialized = true;
|
|
234
247
|
}
|
|
248
|
+
CONFIG._dmcaInitialized = true;
|
|
235
249
|
}
|
|
236
250
|
ConfigManager2.setDmcaLists = setDmcaLists;
|
|
237
251
|
})(exports.ConfigManager || (exports.ConfigManager = {}));
|