@umituz/react-native-ai-fal-provider 3.2.21 → 3.2.23
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/package.json +1 -1
- package/src/infrastructure/utils/fal-storage.util.ts +1 -3
- package/src/infrastructure/utils/input-validator.util.ts +14 -19
- package/src/infrastructure/validators/nsfw-validator.ts +3 -1
- package/src/init/createAiProviderInitModule.ts +2 -1
- package/src/init/initializeFalProvider.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-fal-provider",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.23",
|
|
4
4
|
"description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -19,8 +19,7 @@ export async function uploadToFalStorage(base64: string): Promise<string> {
|
|
|
19
19
|
console.log(`[fal-storage] Uploading base64 image to FAL (first 50 chars): ${base64.substring(0, 50)}...`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const tempUri = (await base64ToTempFile(base64));
|
|
22
|
+
const tempUri = await base64ToTempFile(base64);
|
|
24
23
|
|
|
25
24
|
if (!tempUri) {
|
|
26
25
|
throw new Error("Failed to create temporary file from base64 data");
|
|
@@ -38,7 +37,6 @@ export async function uploadToFalStorage(base64: string): Promise<string> {
|
|
|
38
37
|
return url;
|
|
39
38
|
} finally {
|
|
40
39
|
try {
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
42
40
|
await deleteTempFile(tempUri);
|
|
43
41
|
} catch (cleanupError) {
|
|
44
42
|
// Log cleanup errors to prevent disk space leaks
|
|
@@ -8,23 +8,19 @@ import { IMAGE_URL_FIELDS } from './constants/image-fields.constants';
|
|
|
8
8
|
import { isImageDataUri } from './validators/data-uri-validator.util';
|
|
9
9
|
import { isNonEmptyString } from './validators/string-validator.util';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const SUSPICIOUS_PATTERNS = [
|
|
12
|
+
/<script/i,
|
|
13
|
+
/javascript:/i,
|
|
14
|
+
/on\w+\s*=/i,
|
|
15
|
+
/<iframe/i,
|
|
16
|
+
/<embed/i,
|
|
17
|
+
/<object/i,
|
|
18
|
+
/data:(?!image\/)/i,
|
|
19
|
+
/vbscript:/i,
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
15
22
|
function hasSuspiciousContent(value: string): boolean {
|
|
16
|
-
|
|
17
|
-
/<script/i, // Script tags
|
|
18
|
-
/javascript:/i, // javascript: protocol
|
|
19
|
-
/on\w+\s*=/i, // Event handlers (onclick=, onerror=, etc.)
|
|
20
|
-
/<iframe/i, // iframes
|
|
21
|
-
/<embed/i, // embed tags
|
|
22
|
-
/<object/i, // object tags
|
|
23
|
-
/data:(?!image\/)/i, // data URLs that aren't images
|
|
24
|
-
/vbscript:/i, // vbscript protocol
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
return suspiciousPatterns.some(pattern => pattern.test(value));
|
|
23
|
+
return SUSPICIOUS_PATTERNS.some(pattern => pattern.test(value));
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
/**
|
|
@@ -37,12 +33,11 @@ function isValidAndSafeUrl(value: string): boolean {
|
|
|
37
33
|
try {
|
|
38
34
|
const url = new URL(value);
|
|
39
35
|
// Reject URLs with @ (potential auth bypass: http://attacker.com@internal.server/)
|
|
40
|
-
|
|
41
|
-
if (url.href.includes('@') && urlAny.username) {
|
|
36
|
+
if (url.href.includes('@') && url.username) {
|
|
42
37
|
return false;
|
|
43
38
|
}
|
|
44
39
|
// Ensure domain exists
|
|
45
|
-
if (!
|
|
40
|
+
if (!url.hostname || url.hostname.length === 0) {
|
|
46
41
|
return false;
|
|
47
42
|
}
|
|
48
43
|
return true;
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { NSFWContentError } from "../services/nsfw-content-error";
|
|
7
7
|
|
|
8
|
+
const NSFW_SCORE_THRESHOLD = 0.5;
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Check if value indicates NSFW content
|
|
10
12
|
*/
|
|
@@ -49,7 +51,7 @@ export function validateNSFWContent(result: Record<string, unknown>): void {
|
|
|
49
51
|
|
|
50
52
|
// Format 4: nsfw_score number (> 0.5 threshold)
|
|
51
53
|
const nsfwScore = result?.nsfw_score as number | undefined;
|
|
52
|
-
if (typeof nsfwScore === "number" && nsfwScore >
|
|
54
|
+
if (typeof nsfwScore === "number" && nsfwScore > NSFW_SCORE_THRESHOLD) {
|
|
53
55
|
throw new NSFWContentError();
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -28,7 +28,8 @@ export function initializeFalProvider(config: {
|
|
|
28
28
|
providerRegistry.setActiveProvider(falProvider.providerId);
|
|
29
29
|
|
|
30
30
|
return true;
|
|
31
|
-
} catch {
|
|
32
|
-
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('[initializeFalProvider] Initialization failed:', error);
|
|
33
|
+
throw error;
|
|
33
34
|
}
|
|
34
35
|
}
|