@umituz/react-native-ai-fal-provider 3.2.11 → 3.2.13

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-fal-provider",
3
- "version": "3.2.11",
3
+ "version": "3.2.13",
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",
7
7
  "scripts": {
8
- "typecheck": "tsc --noEmit",
8
+ "typecheck": "tsc --noEmit --project tsconfig.typecheck.json",
9
9
  "lint": "eslint src --ext .ts,.tsx --max-warnings 0",
10
10
  "lint:fix": "eslint src --ext .ts,.tsx --fix"
11
11
  },
@@ -9,6 +9,37 @@ import { DEFAULT_FAL_CONFIG } from "./fal-provider.constants";
9
9
  import { mapFalStatusToJobStatus } from "./fal-status-mapper";
10
10
  import { validateNSFWContent } from "../validators/nsfw-validator";
11
11
  import { NSFWContentError } from "./nsfw-content-error";
12
+ import { isBase64DataUri } from "../utils/validators/data-uri-validator.util";
13
+
14
+ /**
15
+ * Validate that FAL response images contain HTTPS URLs, never base64 data URIs.
16
+ * FAL models should always return CDN URLs. If base64 is returned, it means the model
17
+ * was called with sync_mode:true or wrong parameters. Throw an explicit error to catch early.
18
+ */
19
+ function validateNoBase64InResponse(data: unknown): void {
20
+ if (!data || typeof data !== "object") return;
21
+ const record = data as Record<string, unknown>;
22
+
23
+ const checkUrl = (url: unknown, field: string) => {
24
+ if (typeof url === "string" && isBase64DataUri(url)) {
25
+ throw new Error(
26
+ `[fal-provider] Model returned base64 data URI in '${field}' instead of an HTTPS URL. ` +
27
+ `Do not use sync_mode:true. Use falProvider.subscribe() to get CDN URLs.`
28
+ );
29
+ }
30
+ };
31
+
32
+ if (Array.isArray(record.images)) {
33
+ for (const img of record.images) {
34
+ if (img && typeof img === "object") {
35
+ checkUrl((img as Record<string, unknown>).url, "images[].url");
36
+ }
37
+ }
38
+ }
39
+ if (record.image && typeof record.image === "object") {
40
+ checkUrl((record.image as Record<string, unknown>).url, "image.url");
41
+ }
42
+ }
12
43
 
13
44
  /**
14
45
  * Unwrap fal.subscribe / fal.run Result<T> = { data: T, requestId: string }
@@ -151,6 +182,7 @@ export async function handleFalSubscription<T = unknown>(
151
182
  const rawResult = await Promise.race(promises);
152
183
  const { data, requestId } = unwrapFalResult<T>(rawResult);
153
184
 
185
+ validateNoBase64InResponse(data);
154
186
  validateNSFWContent(data as Record<string, unknown>);
155
187
 
156
188
  options?.onResult?.(data);
@@ -186,6 +218,7 @@ export async function handleFalRun<T = unknown>(
186
218
  const rawResult = await fal.run(model, { input });
187
219
  const { data } = unwrapFalResult<T>(rawResult);
188
220
 
221
+ validateNoBase64InResponse(data);
189
222
  validateNSFWContent(data as Record<string, unknown>);
190
223
 
191
224
  options?.onProgress?.({ progress: 100, status: "COMPLETED" as const });