@umituz/react-native-ai-generation-content 1.72.13 → 1.72.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.72.13",
3
+ "version": "1.72.15",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -22,11 +22,14 @@ function isValidRegexPattern(pattern: string): boolean {
22
22
  }
23
23
 
24
24
  // Check for dangerous patterns that could cause ReDoS
25
+ // Note: These checks are conservative to prevent catastrophic backtracking
25
26
  const dangerousPatterns = [
26
- /\([^)]*\+\([^)]*\+\)/, // Nested repeated groups
27
- /\([^)]*\*[^)]*\*\)/, // Multiple nested stars
28
- /\.\*\.*/, // Multiple wildcards
29
- /\.\+\.+/, // Multiple repeated wildcards
27
+ /\([^)]*\+\([^)]*\+\)/, // Nested repeated groups like (x+(y+))
28
+ /\([^)]*\*[^)]*\*\)/, // Multiple nested stars in groups like (x*(y*))
29
+ /\.\*\.\*\.\*/, // Three or more consecutive .* wildcards
30
+ /\.\+\.\+\.\+/, // Three or more consecutive .+ wildcards
31
+ /\(\.\*\)\+/, // Repeated wildcard groups like (.*)+
32
+ /\(\.\+\)\+/, // Repeated wildcard groups like (.+)+
30
33
  ];
31
34
 
32
35
  for (const dangerous of dangerousPatterns) {
@@ -109,6 +109,11 @@ export class ImageExecutor
109
109
  private buildModelInput(input: ImageGenerationInput) {
110
110
  const { imageUrls, prompt, aspectRatio, outputFormat } = input;
111
111
 
112
+ // Validate required prompt field
113
+ if (!prompt || prompt.trim() === "") {
114
+ throw new Error("Prompt is required for image generation");
115
+ }
116
+
112
117
  const formattedUrls = imageUrls?.map((url) =>
113
118
  url.startsWith("data:") ? url : `data:image/jpeg;base64,${url}`,
114
119
  );
@@ -117,7 +122,7 @@ export class ImageExecutor
117
122
  ...(formattedUrls && formattedUrls.length > 0
118
123
  ? { image_urls: formattedUrls }
119
124
  : {}),
120
- prompt,
125
+ prompt: prompt.trim(),
121
126
  aspect_ratio: aspectRatio ?? "4:3",
122
127
  output_format: outputFormat ?? "jpeg",
123
128
  num_images: 1,
@@ -164,6 +164,7 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
164
164
  onTryAgain={onTryAgain}
165
165
  onDismissGenerating={handlers.handleDismissGenerating}
166
166
  t={t}
167
+ alertMessages={alertMessages}
167
168
  renderPreview={renderPreview}
168
169
  renderGenerating={renderGenerating}
169
170
  renderResult={renderResult}
@@ -34,6 +34,7 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
34
34
  onTryAgain,
35
35
  onDismissGenerating,
36
36
  t,
37
+ alertMessages,
37
38
  renderPreview,
38
39
  renderGenerating,
39
40
  renderResult,
@@ -91,7 +92,7 @@ export const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({
91
92
  return renderPhotoUploadStep({ step, customData, onBack, onPhotoContinue, t });
92
93
 
93
94
  case StepType.TEXT_INPUT:
94
- return renderTextInputStep({ step, customData, onBack, onPhotoContinue, t });
95
+ return renderTextInputStep({ step, customData, onBack, onPhotoContinue, t, alertMessages });
95
96
 
96
97
  case StepType.FEATURE_SELECTION:
97
98
  return renderSelectionStep({ step, customData, onBack, onPhotoContinue, t });
@@ -1,6 +1,7 @@
1
1
  import type { StepDefinition } from "../../../../../domain/entities/flow-config.types";
2
2
  import type { WizardScenarioData } from "../hooks/useWizardGeneration";
3
3
  import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
4
+ import type { AlertMessages } from "../../../../../presentation/hooks/generation/types";
4
5
 
5
6
  export interface WizardStepRendererProps {
6
7
  readonly step: StepDefinition | undefined;
@@ -21,6 +22,7 @@ export interface WizardStepRendererProps {
21
22
  /** Called when user dismisses generating screen - generation continues in background */
22
23
  readonly onDismissGenerating?: () => void;
23
24
  readonly t: (key: string) => string;
25
+ readonly alertMessages?: AlertMessages;
24
26
  readonly renderPreview?: (onContinue: () => void) => React.ReactElement | null;
25
27
  readonly renderGenerating?: (progress: number) => React.ReactElement | null;
26
28
  readonly renderResult?: (result: unknown) => React.ReactElement | null;
@@ -7,6 +7,7 @@ import { TextInputScreen } from "../../screens/TextInputScreen";
7
7
  import { getTextInputConfig } from "../WizardStepRenderer.utils";
8
8
  import type { StepDefinition } from "../../../../../../domain/entities/flow-config.types";
9
9
  import type { UploadedImage } from "../../../../../../presentation/hooks/generation/useAIGenerateState";
10
+ import type { AlertMessages } from "../../../../../../presentation/hooks/generation/types";
10
11
 
11
12
  export interface TextInputStepProps {
12
13
  readonly step: StepDefinition;
@@ -14,6 +15,7 @@ export interface TextInputStepProps {
14
15
  readonly onBack: () => void;
15
16
  readonly onPhotoContinue: (stepId: string, image: UploadedImage) => void;
16
17
  readonly t: (key: string) => string;
18
+ readonly alertMessages?: AlertMessages;
17
19
  }
18
20
 
19
21
  export function renderTextInputStep({
@@ -22,6 +24,7 @@ export function renderTextInputStep({
22
24
  onBack,
23
25
  onPhotoContinue,
24
26
  t,
27
+ alertMessages,
25
28
  }: TextInputStepProps): React.ReactElement {
26
29
  const textConfig = getTextInputConfig(step.config);
27
30
  const titleKey = textConfig?.titleKey ?? `wizard.steps.${step.id}.title`;
@@ -45,6 +48,8 @@ export function renderTextInputStep({
45
48
  continueButton: t("common.continue"),
46
49
  backButton: t("common.back"),
47
50
  examplesTitle: t("textInput.examplesTitle"),
51
+ contentNotAllowed: alertMessages?.errorTitle || alertMessages?.policyViolationTitle || t("common.error"),
52
+ contentNotAllowedMessage: alertMessages?.policyViolation || "This type of content is not supported. Please try a different prompt.",
48
53
  }}
49
54
  config={{
50
55
  minLength: textConfig?.minLength ?? 3,