@blinkdotnew/sdk 0.18.7 β†’ 0.19.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/README.md CHANGED
@@ -145,7 +145,7 @@ const { publicUrl } = await blink.storage.upload(
145
145
  This SDK powers every Blink-generated app with:
146
146
 
147
147
  - **πŸ” Authentication**: Flexible auth system with managed (redirect) and headless (custom UI) modes, email/password, social providers (Google, GitHub, Apple, Microsoft), magic links, RBAC, and custom email branding
148
- - **πŸ—„οΈ Database**: PostgREST-compatible CRUD operations with advanced filtering
148
+ - **πŸ—„οΈ Database**: PostgREST-compatible CRUD operations with advanced filtering
149
149
  - **πŸ€– AI**: Text generation with web search, object generation, image creation (Gemini 2.5 Flash), speech synthesis, and transcription
150
150
  - **πŸ“„ Data**: Extract text content from documents, secure API proxy with secret substitution, web scraping, screenshots, and web search
151
151
  - **πŸ“ Storage**: File upload, download, and management
@@ -153,7 +153,8 @@ This SDK powers every Blink-generated app with:
153
153
  - **⚑ Realtime**: WebSocket-based pub/sub messaging, presence tracking, and live updates
154
154
  - **πŸ“Š Analytics**: Automatic pageview tracking, custom event logging, session management, and privacy-first design
155
155
  - **🌐 Universal**: Works on client-side and server-side
156
- - **πŸ“± Framework Agnostic**: React, Vue, Svelte, vanilla JS, Node.js, Deno
156
+ - **πŸ“± Framework Agnostic**: React, Vue, Svelte, vanilla JS, Node.js, Deno, **React Native**
157
+ - **πŸ“± React Native**: First-class mobile support with AsyncStorage integration and platform-aware features
157
158
  - **πŸ”„ Real-time**: Built-in auth state management and token refresh
158
159
  - **⚑ Zero Boilerplate**: Everything works out of the box
159
160
 
@@ -187,8 +188,53 @@ const blink = createClient({
187
188
  auth: { mode: 'managed' } // Manual token management
188
189
  })
189
190
 
190
- // Set JWT manually
191
- blink.auth.setToken(jwtFromHeader)
191
+ // Token injection is only needed when calling blink.auth.* methods on the server
192
+ ```
193
+
194
+ ### πŸ“± React Native (iOS & Android)
195
+
196
+ The SDK has **first-class React Native support** with platform-aware features that automatically adapt to mobile environments.
197
+
198
+ ```bash
199
+ npm install @blinkdotnew/sdk @react-native-async-storage/async-storage
200
+ ```
201
+
202
+ ```typescript
203
+ import { createClient, AsyncStorageAdapter } from '@blinkdotnew/sdk'
204
+ import AsyncStorage from '@react-native-async-storage/async-storage'
205
+
206
+ const blink = createClient({
207
+ projectId: 'your-project-id',
208
+ authRequired: false,
209
+ // Use AsyncStorage for secure token persistence on mobile
210
+ storage: new AsyncStorageAdapter(AsyncStorage)
211
+ })
212
+
213
+ // All features work seamlessly in React Native!
214
+ const { data } = await blink.ai.generateImage({
215
+ prompt: 'A beautiful sunset over mountains',
216
+ n: 1
217
+ })
218
+ ```
219
+
220
+ **Platform-Aware Features:**
221
+ - βœ… **AsyncStorage integration** for secure token persistence
222
+ - βœ… **Automatic platform detection** - skips browser-only features (analytics tracking, cross-tab sync)
223
+ - βœ… **No polyfills needed** - works out of the box
224
+ - βœ… **Optimized for mobile** - reduced memory footprint
225
+
226
+ **Configuration Options:**
227
+ ```typescript
228
+ // With AsyncStorage (recommended for token persistence)
229
+ const blink = createClient({
230
+ projectId: 'your-project-id',
231
+ storage: new AsyncStorageAdapter(AsyncStorage)
232
+ })
233
+
234
+ // Without persistence (tokens in memory only)
235
+ const blink = createClient({
236
+ projectId: 'your-project-id'
237
+ })
192
238
  ```
193
239
 
194
240
  ## πŸ“– API Reference
@@ -235,6 +281,22 @@ const user = await blink.auth.signInWithGitHub()
235
281
  const user = await blink.auth.signInWithApple()
236
282
  const user = await blink.auth.signInWithMicrosoft()
237
283
 
284
+ // βœ… Store custom signup fields inside metadata
285
+ await blink.auth.signUp({
286
+ email: 'founder@example.com',
287
+ password: 'SuperSecret123',
288
+ displayName: 'Alex Founder',
289
+ role: 'operations',
290
+ metadata: {
291
+ company: 'Acme Freight',
292
+ marketingConsent: true
293
+ }
294
+ })
295
+ // `displayName`, `avatar`, and `role` map to dedicated auth columns.
296
+ // Everything else goes into auth.users.metadata automatically.
297
+ // Keep custom fields in metadata or your own profile tableβ€”avoid adding NOT NULL
298
+ // columns directly to auth tables.
299
+
238
300
  // Magic links (passwordless)
239
301
  await blink.auth.sendMagicLink(email)
240
302
 
@@ -427,6 +489,8 @@ function EditButton() {
427
489
 
428
490
  #### Core Methods
429
491
 
492
+ > ⚠️ Tokens are managed automatically for Blink APIs. Use `getValidToken()` only if you must manually pass a token to your own backend or third-party services.
493
+
430
494
  ```typescript
431
495
  // User management
432
496
  const user = await blink.auth.me()
@@ -435,6 +499,7 @@ await blink.auth.updateMe({ displayName: 'New Name' })
435
499
  // Token management
436
500
  blink.auth.setToken(jwt, persist?)
437
501
  const isAuth = blink.auth.isAuthenticated()
502
+ const token = await blink.auth.getValidToken() // Get valid token (auto-refreshes)
438
503
 
439
504
  // Password management
440
505
  await blink.auth.sendPasswordResetEmail('user@example.com')
@@ -2356,9 +2421,6 @@ const blink = createClient({
2356
2421
  })
2357
2422
 
2358
2423
  export default async function handler(req, res) {
2359
- const jwt = req.headers.authorization?.replace('Bearer ', '')
2360
- blink.auth.setToken(jwt)
2361
-
2362
2424
  const todos = await blink.db.todos.list()
2363
2425
  res.json(todos)
2364
2426
  }
@@ -2376,9 +2438,6 @@ const blink = createClient({
2376
2438
  })
2377
2439
 
2378
2440
  Deno.serve(async (req) => {
2379
- const jwt = req.headers.get('authorization')?.replace('Bearer ', '')
2380
- blink.auth.setToken(jwt)
2381
-
2382
2441
  const todos = await blink.db.todos.list()
2383
2442
  return Response.json(todos)
2384
2443
  })
package/dist/index.d.mts CHANGED
@@ -1,10 +1,84 @@
1
+ /**
2
+ * Storage adapter for cross-platform compatibility
3
+ * Allows using AsyncStorage on React Native and localStorage on web
4
+ */
5
+ /**
6
+ * Storage adapter interface
7
+ * Supports both synchronous (web localStorage) and asynchronous (React Native AsyncStorage) implementations
8
+ */
9
+ interface StorageAdapter {
10
+ getItem(key: string): Promise<string | null> | string | null;
11
+ setItem(key: string, value: string): Promise<void> | void;
12
+ removeItem(key: string): Promise<void> | void;
13
+ clear(): Promise<void> | void;
14
+ }
15
+ /**
16
+ * Web localStorage adapter (synchronous)
17
+ * Used automatically on web browsers
18
+ */
19
+ declare class WebStorageAdapter implements StorageAdapter {
20
+ getItem(key: string): string | null;
21
+ setItem(key: string, value: string): void;
22
+ removeItem(key: string): void;
23
+ clear(): void;
24
+ }
25
+ /**
26
+ * Async storage adapter wrapper (for React Native AsyncStorage)
27
+ * Usage:
28
+ * ```typescript
29
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
30
+ * const storage = new AsyncStorageAdapter(AsyncStorage)
31
+ * ```
32
+ */
33
+ declare class AsyncStorageAdapter implements StorageAdapter {
34
+ private asyncStorage;
35
+ constructor(asyncStorage: any);
36
+ getItem(key: string): Promise<string | null>;
37
+ setItem(key: string, value: string): Promise<void>;
38
+ removeItem(key: string): Promise<void>;
39
+ clear(): Promise<void>;
40
+ }
41
+ /**
42
+ * No-op storage adapter (for server-side or when storage is disabled)
43
+ * Used automatically on Node.js or when no storage is available
44
+ */
45
+ declare class NoOpStorageAdapter implements StorageAdapter {
46
+ getItem(_key: string): null;
47
+ setItem(_key: string, _value: string): void;
48
+ removeItem(_key: string): void;
49
+ clear(): void;
50
+ }
51
+ /**
52
+ * Get default storage adapter based on platform
53
+ */
54
+ declare function getDefaultStorageAdapter(): StorageAdapter;
55
+
1
56
  /**
2
57
  * Core type definitions for Blink SDK
3
58
  */
59
+
4
60
  interface BlinkClientConfig {
5
61
  projectId: string;
6
62
  authRequired?: boolean;
7
63
  auth?: BlinkAuthConfig;
64
+ /**
65
+ * Storage adapter for cross-platform token persistence
66
+ *
67
+ * Web: Uses localStorage by default
68
+ * React Native: Pass AsyncStorageAdapter(AsyncStorage)
69
+ * Node.js: Uses NoOpStorageAdapter by default
70
+ *
71
+ * @example
72
+ * // React Native
73
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
74
+ * import { AsyncStorageAdapter } from '@blinkdotnew/sdk'
75
+ *
76
+ * const blink = createClient({
77
+ * projectId: 'your-project',
78
+ * storage: new AsyncStorageAdapter(AsyncStorage)
79
+ * })
80
+ */
81
+ storage?: StorageAdapter;
8
82
  }
9
83
  interface BlinkAuthConfig {
10
84
  mode?: 'managed' | 'headless';
@@ -34,6 +108,11 @@ interface BlinkAuthConfig {
34
108
  redirectUrl?: string;
35
109
  authUrl?: string;
36
110
  coreUrl?: string;
111
+ /**
112
+ * Storage adapter for auth token persistence (overrides global storage)
113
+ * If not provided, uses the global storage from BlinkClientConfig
114
+ */
115
+ storage?: StorageAdapter;
37
116
  }
38
117
  type AuthProvider = 'email' | 'google' | 'github' | 'apple' | 'microsoft' | 'twitter' | 'linkedin' | 'discord';
39
118
  interface AuthOptions {
@@ -808,6 +887,23 @@ declare class HttpClient {
808
887
  private parseDataStream;
809
888
  }
810
889
 
890
+ /**
891
+ * Platform detection for cross-platform compatibility
892
+ * Detects whether code is running on web, React Native, or Node.js
893
+ */
894
+ type Platform = 'web' | 'react-native' | 'node';
895
+ /**
896
+ * Current platform
897
+ */
898
+ declare const platform: Platform;
899
+ /**
900
+ * Platform detection helpers
901
+ */
902
+ declare const isWeb: boolean;
903
+ declare const isReactNative: boolean;
904
+ declare const isNode: boolean;
905
+ declare const isBrowser: boolean;
906
+
811
907
  /**
812
908
  * Blink Auth Module - Client-side authentication management
813
909
  * Handles token storage, user state, and authentication flows
@@ -825,6 +921,7 @@ declare class BlinkAuth {
825
921
  private isIframe;
826
922
  private initializationPromise;
827
923
  private isInitialized;
924
+ private storage;
828
925
  constructor(config: BlinkClientConfig);
829
926
  /**
830
927
  * Generate project-scoped storage key
@@ -1636,55 +1733,99 @@ declare class BlinkAIImpl implements BlinkAI {
1636
1733
  */
1637
1734
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
1638
1735
  /**
1639
- * Generates images from text descriptions using Gemini 2.5 Flash Image.
1736
+ * Generates images from text descriptions using AI image models.
1640
1737
  *
1641
1738
  * @param options - Object containing:
1642
1739
  * - `prompt`: Text description of the desired image (required, up to 100k characters)
1740
+ * - `model`: AI model to use (optional). Available models:
1741
+ * **Fal.ai Models (Recommended):**
1742
+ * - `"fal-ai/nano-banana"` (default) - Gemini 2.5 Flash Image (Fast)
1743
+ * - `"fal-ai/nano-banana-pro"` - Gemini 3 Pro Image (High quality)
1744
+ * - `"fal-ai/gemini-25-flash-image"` - Alias for nano-banana
1745
+ * - `"fal-ai/gemini-3-pro-image-preview"` - Alias for nano-banana-pro
1746
+ * **Legacy Gemini Models:**
1747
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1748
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1643
1749
  * - `n`: Number of images to generate (default: 1)
1750
+ * - `size`: Image dimensions (e.g., "1024x1024", "512x512")
1644
1751
  * - Plus optional signal parameter
1645
1752
  *
1646
1753
  * @example
1647
1754
  * ```ts
1648
- * // Basic image generation
1755
+ * // Basic image generation (uses default fast model)
1649
1756
  * const { data } = await blink.ai.generateImage({
1650
1757
  * prompt: "A serene landscape with mountains and a lake at sunset"
1651
1758
  * });
1652
1759
  * console.log("Image URL:", data[0].url);
1653
1760
  *
1654
- * // Multiple images
1761
+ * // High quality generation with Pro model
1762
+ * const { data } = await blink.ai.generateImage({
1763
+ * prompt: "A detailed infographic about AI with charts and diagrams",
1764
+ * model: "fal-ai/nano-banana-pro",
1765
+ * n: 2
1766
+ * });
1767
+ *
1768
+ * // Fast generation with specific size
1655
1769
  * const { data } = await blink.ai.generateImage({
1656
1770
  * prompt: "A futuristic city skyline with flying cars",
1771
+ * model: "fal-ai/nano-banana",
1772
+ * size: "1024x1024",
1657
1773
  * n: 3
1658
1774
  * });
1659
1775
  * data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
1660
1776
  *
1661
- * // Detailed prompt for better results
1777
+ * // Using legacy Gemini model
1662
1778
  * const { data } = await blink.ai.generateImage({
1663
- * prompt: "A cute robot mascot for a tech company, digital art style, vibrant colors, modern design, friendly expression"
1779
+ * prompt: "A cute robot mascot for a tech company",
1780
+ * model: "gemini-2.5-flash-image-preview"
1664
1781
  * });
1665
1782
  * ```
1666
1783
  *
1667
1784
  * @returns Promise<ImageGenerationResponse> - Object containing:
1668
1785
  * - `data`: Array of generated images with URLs
1669
1786
  * - `created`: Timestamp of generation
1670
- * - `model`: Always "gemini-2.5-flash-image-preview"
1787
+ * - `model`: The model used for generation
1671
1788
  */
1672
1789
  generateImage(options: {
1673
1790
  prompt: string;
1791
+ model?: string;
1674
1792
  n?: number;
1793
+ size?: string;
1675
1794
  signal?: AbortSignal;
1676
1795
  }): Promise<ImageGenerationResponse>;
1677
1796
  /**
1678
- * Modifies existing images using Gemini 2.5 Flash Image with text prompts for image-to-image editing.
1797
+ * Modifies existing images using AI image editing models with text prompts for image-to-image editing.
1679
1798
  *
1680
1799
  * @param options - Object containing:
1681
1800
  * - `images`: Array of public image URLs to modify (required, up to 50 images)
1682
1801
  * - `prompt`: Text description of desired modifications (required, up to 100k characters)
1802
+ * - `model`: AI model to use (optional). Available editing models:
1803
+ * **Fal.ai Editing Models (Recommended):**
1804
+ * - `"fal-ai/nano-banana/edit"` (default) - Flash editing (Fast)
1805
+ * - `"fal-ai/nano-banana-pro/edit"` - Pro editing (High quality)
1806
+ * - `"fal-ai/gemini-25-flash-image/edit"` - Alias for nano-banana/edit
1807
+ * - `"fal-ai/gemini-3-pro-image-preview/edit"` - Alias for nano-banana-pro/edit
1808
+ * **Legacy Gemini Models:**
1809
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1810
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1683
1811
  * - `n`: Number of output images to generate (default: 1)
1684
1812
  * - Plus optional signal parameter
1685
1813
  *
1686
1814
  * @example
1687
1815
  * ```ts
1816
+ * // Fast editing with default model
1817
+ * const { data } = await blink.ai.modifyImage({
1818
+ * images: ["https://storage.example.com/photo.jpg"],
1819
+ * prompt: "make it green"
1820
+ * });
1821
+ *
1822
+ * // High quality editing with Pro model
1823
+ * const { data } = await blink.ai.modifyImage({
1824
+ * images: ["https://storage.example.com/landscape.jpg"],
1825
+ * prompt: "add a tree in the background",
1826
+ * model: "fal-ai/nano-banana-pro/edit"
1827
+ * });
1828
+ *
1688
1829
  * // Professional headshots from casual photos
1689
1830
  * const { data } = await blink.ai.modifyImage({
1690
1831
  * images: [
@@ -1692,6 +1833,7 @@ declare class BlinkAIImpl implements BlinkAI {
1692
1833
  * "https://storage.example.com/user-photo-2.jpg"
1693
1834
  * ],
1694
1835
  * prompt: "Transform into professional business headshots with studio lighting",
1836
+ * model: "fal-ai/nano-banana/edit",
1695
1837
  * n: 4
1696
1838
  * });
1697
1839
  * data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
@@ -1699,7 +1841,8 @@ declare class BlinkAIImpl implements BlinkAI {
1699
1841
  * // Artistic style transformation
1700
1842
  * const { data } = await blink.ai.modifyImage({
1701
1843
  * images: ["https://storage.example.com/portrait.jpg"],
1702
- * prompt: "Transform into oil painting style with dramatic lighting"
1844
+ * prompt: "Transform into oil painting style with dramatic lighting",
1845
+ * model: "fal-ai/nano-banana-pro/edit"
1703
1846
  * });
1704
1847
  *
1705
1848
  * // Background replacement
@@ -1737,11 +1880,12 @@ declare class BlinkAIImpl implements BlinkAI {
1737
1880
  * @returns Promise<ImageGenerationResponse> - Object containing:
1738
1881
  * - `data`: Array of modified images with URLs
1739
1882
  * - `created`: Timestamp of generation
1740
- * - `model`: Always "gemini-2.5-flash-image-preview"
1883
+ * - `model`: The model used for editing
1741
1884
  */
1742
1885
  modifyImage(options: {
1743
1886
  images: string[];
1744
1887
  prompt: string;
1888
+ model?: string;
1745
1889
  n?: number;
1746
1890
  signal?: AbortSignal;
1747
1891
  }): Promise<ImageGenerationResponse>;
@@ -1920,4 +2064,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
1920
2064
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
1921
2065
  }
1922
2066
 
1923
- export { type AnalyticsEvent, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, createClient };
2067
+ export { type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, WebStorageAdapter, createClient, getDefaultStorageAdapter, isBrowser, isNode, isReactNative, isWeb, platform };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,84 @@
1
+ /**
2
+ * Storage adapter for cross-platform compatibility
3
+ * Allows using AsyncStorage on React Native and localStorage on web
4
+ */
5
+ /**
6
+ * Storage adapter interface
7
+ * Supports both synchronous (web localStorage) and asynchronous (React Native AsyncStorage) implementations
8
+ */
9
+ interface StorageAdapter {
10
+ getItem(key: string): Promise<string | null> | string | null;
11
+ setItem(key: string, value: string): Promise<void> | void;
12
+ removeItem(key: string): Promise<void> | void;
13
+ clear(): Promise<void> | void;
14
+ }
15
+ /**
16
+ * Web localStorage adapter (synchronous)
17
+ * Used automatically on web browsers
18
+ */
19
+ declare class WebStorageAdapter implements StorageAdapter {
20
+ getItem(key: string): string | null;
21
+ setItem(key: string, value: string): void;
22
+ removeItem(key: string): void;
23
+ clear(): void;
24
+ }
25
+ /**
26
+ * Async storage adapter wrapper (for React Native AsyncStorage)
27
+ * Usage:
28
+ * ```typescript
29
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
30
+ * const storage = new AsyncStorageAdapter(AsyncStorage)
31
+ * ```
32
+ */
33
+ declare class AsyncStorageAdapter implements StorageAdapter {
34
+ private asyncStorage;
35
+ constructor(asyncStorage: any);
36
+ getItem(key: string): Promise<string | null>;
37
+ setItem(key: string, value: string): Promise<void>;
38
+ removeItem(key: string): Promise<void>;
39
+ clear(): Promise<void>;
40
+ }
41
+ /**
42
+ * No-op storage adapter (for server-side or when storage is disabled)
43
+ * Used automatically on Node.js or when no storage is available
44
+ */
45
+ declare class NoOpStorageAdapter implements StorageAdapter {
46
+ getItem(_key: string): null;
47
+ setItem(_key: string, _value: string): void;
48
+ removeItem(_key: string): void;
49
+ clear(): void;
50
+ }
51
+ /**
52
+ * Get default storage adapter based on platform
53
+ */
54
+ declare function getDefaultStorageAdapter(): StorageAdapter;
55
+
1
56
  /**
2
57
  * Core type definitions for Blink SDK
3
58
  */
59
+
4
60
  interface BlinkClientConfig {
5
61
  projectId: string;
6
62
  authRequired?: boolean;
7
63
  auth?: BlinkAuthConfig;
64
+ /**
65
+ * Storage adapter for cross-platform token persistence
66
+ *
67
+ * Web: Uses localStorage by default
68
+ * React Native: Pass AsyncStorageAdapter(AsyncStorage)
69
+ * Node.js: Uses NoOpStorageAdapter by default
70
+ *
71
+ * @example
72
+ * // React Native
73
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
74
+ * import { AsyncStorageAdapter } from '@blinkdotnew/sdk'
75
+ *
76
+ * const blink = createClient({
77
+ * projectId: 'your-project',
78
+ * storage: new AsyncStorageAdapter(AsyncStorage)
79
+ * })
80
+ */
81
+ storage?: StorageAdapter;
8
82
  }
9
83
  interface BlinkAuthConfig {
10
84
  mode?: 'managed' | 'headless';
@@ -34,6 +108,11 @@ interface BlinkAuthConfig {
34
108
  redirectUrl?: string;
35
109
  authUrl?: string;
36
110
  coreUrl?: string;
111
+ /**
112
+ * Storage adapter for auth token persistence (overrides global storage)
113
+ * If not provided, uses the global storage from BlinkClientConfig
114
+ */
115
+ storage?: StorageAdapter;
37
116
  }
38
117
  type AuthProvider = 'email' | 'google' | 'github' | 'apple' | 'microsoft' | 'twitter' | 'linkedin' | 'discord';
39
118
  interface AuthOptions {
@@ -808,6 +887,23 @@ declare class HttpClient {
808
887
  private parseDataStream;
809
888
  }
810
889
 
890
+ /**
891
+ * Platform detection for cross-platform compatibility
892
+ * Detects whether code is running on web, React Native, or Node.js
893
+ */
894
+ type Platform = 'web' | 'react-native' | 'node';
895
+ /**
896
+ * Current platform
897
+ */
898
+ declare const platform: Platform;
899
+ /**
900
+ * Platform detection helpers
901
+ */
902
+ declare const isWeb: boolean;
903
+ declare const isReactNative: boolean;
904
+ declare const isNode: boolean;
905
+ declare const isBrowser: boolean;
906
+
811
907
  /**
812
908
  * Blink Auth Module - Client-side authentication management
813
909
  * Handles token storage, user state, and authentication flows
@@ -825,6 +921,7 @@ declare class BlinkAuth {
825
921
  private isIframe;
826
922
  private initializationPromise;
827
923
  private isInitialized;
924
+ private storage;
828
925
  constructor(config: BlinkClientConfig);
829
926
  /**
830
927
  * Generate project-scoped storage key
@@ -1636,55 +1733,99 @@ declare class BlinkAIImpl implements BlinkAI {
1636
1733
  */
1637
1734
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
1638
1735
  /**
1639
- * Generates images from text descriptions using Gemini 2.5 Flash Image.
1736
+ * Generates images from text descriptions using AI image models.
1640
1737
  *
1641
1738
  * @param options - Object containing:
1642
1739
  * - `prompt`: Text description of the desired image (required, up to 100k characters)
1740
+ * - `model`: AI model to use (optional). Available models:
1741
+ * **Fal.ai Models (Recommended):**
1742
+ * - `"fal-ai/nano-banana"` (default) - Gemini 2.5 Flash Image (Fast)
1743
+ * - `"fal-ai/nano-banana-pro"` - Gemini 3 Pro Image (High quality)
1744
+ * - `"fal-ai/gemini-25-flash-image"` - Alias for nano-banana
1745
+ * - `"fal-ai/gemini-3-pro-image-preview"` - Alias for nano-banana-pro
1746
+ * **Legacy Gemini Models:**
1747
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1748
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1643
1749
  * - `n`: Number of images to generate (default: 1)
1750
+ * - `size`: Image dimensions (e.g., "1024x1024", "512x512")
1644
1751
  * - Plus optional signal parameter
1645
1752
  *
1646
1753
  * @example
1647
1754
  * ```ts
1648
- * // Basic image generation
1755
+ * // Basic image generation (uses default fast model)
1649
1756
  * const { data } = await blink.ai.generateImage({
1650
1757
  * prompt: "A serene landscape with mountains and a lake at sunset"
1651
1758
  * });
1652
1759
  * console.log("Image URL:", data[0].url);
1653
1760
  *
1654
- * // Multiple images
1761
+ * // High quality generation with Pro model
1762
+ * const { data } = await blink.ai.generateImage({
1763
+ * prompt: "A detailed infographic about AI with charts and diagrams",
1764
+ * model: "fal-ai/nano-banana-pro",
1765
+ * n: 2
1766
+ * });
1767
+ *
1768
+ * // Fast generation with specific size
1655
1769
  * const { data } = await blink.ai.generateImage({
1656
1770
  * prompt: "A futuristic city skyline with flying cars",
1771
+ * model: "fal-ai/nano-banana",
1772
+ * size: "1024x1024",
1657
1773
  * n: 3
1658
1774
  * });
1659
1775
  * data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
1660
1776
  *
1661
- * // Detailed prompt for better results
1777
+ * // Using legacy Gemini model
1662
1778
  * const { data } = await blink.ai.generateImage({
1663
- * prompt: "A cute robot mascot for a tech company, digital art style, vibrant colors, modern design, friendly expression"
1779
+ * prompt: "A cute robot mascot for a tech company",
1780
+ * model: "gemini-2.5-flash-image-preview"
1664
1781
  * });
1665
1782
  * ```
1666
1783
  *
1667
1784
  * @returns Promise<ImageGenerationResponse> - Object containing:
1668
1785
  * - `data`: Array of generated images with URLs
1669
1786
  * - `created`: Timestamp of generation
1670
- * - `model`: Always "gemini-2.5-flash-image-preview"
1787
+ * - `model`: The model used for generation
1671
1788
  */
1672
1789
  generateImage(options: {
1673
1790
  prompt: string;
1791
+ model?: string;
1674
1792
  n?: number;
1793
+ size?: string;
1675
1794
  signal?: AbortSignal;
1676
1795
  }): Promise<ImageGenerationResponse>;
1677
1796
  /**
1678
- * Modifies existing images using Gemini 2.5 Flash Image with text prompts for image-to-image editing.
1797
+ * Modifies existing images using AI image editing models with text prompts for image-to-image editing.
1679
1798
  *
1680
1799
  * @param options - Object containing:
1681
1800
  * - `images`: Array of public image URLs to modify (required, up to 50 images)
1682
1801
  * - `prompt`: Text description of desired modifications (required, up to 100k characters)
1802
+ * - `model`: AI model to use (optional). Available editing models:
1803
+ * **Fal.ai Editing Models (Recommended):**
1804
+ * - `"fal-ai/nano-banana/edit"` (default) - Flash editing (Fast)
1805
+ * - `"fal-ai/nano-banana-pro/edit"` - Pro editing (High quality)
1806
+ * - `"fal-ai/gemini-25-flash-image/edit"` - Alias for nano-banana/edit
1807
+ * - `"fal-ai/gemini-3-pro-image-preview/edit"` - Alias for nano-banana-pro/edit
1808
+ * **Legacy Gemini Models:**
1809
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1810
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1683
1811
  * - `n`: Number of output images to generate (default: 1)
1684
1812
  * - Plus optional signal parameter
1685
1813
  *
1686
1814
  * @example
1687
1815
  * ```ts
1816
+ * // Fast editing with default model
1817
+ * const { data } = await blink.ai.modifyImage({
1818
+ * images: ["https://storage.example.com/photo.jpg"],
1819
+ * prompt: "make it green"
1820
+ * });
1821
+ *
1822
+ * // High quality editing with Pro model
1823
+ * const { data } = await blink.ai.modifyImage({
1824
+ * images: ["https://storage.example.com/landscape.jpg"],
1825
+ * prompt: "add a tree in the background",
1826
+ * model: "fal-ai/nano-banana-pro/edit"
1827
+ * });
1828
+ *
1688
1829
  * // Professional headshots from casual photos
1689
1830
  * const { data } = await blink.ai.modifyImage({
1690
1831
  * images: [
@@ -1692,6 +1833,7 @@ declare class BlinkAIImpl implements BlinkAI {
1692
1833
  * "https://storage.example.com/user-photo-2.jpg"
1693
1834
  * ],
1694
1835
  * prompt: "Transform into professional business headshots with studio lighting",
1836
+ * model: "fal-ai/nano-banana/edit",
1695
1837
  * n: 4
1696
1838
  * });
1697
1839
  * data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
@@ -1699,7 +1841,8 @@ declare class BlinkAIImpl implements BlinkAI {
1699
1841
  * // Artistic style transformation
1700
1842
  * const { data } = await blink.ai.modifyImage({
1701
1843
  * images: ["https://storage.example.com/portrait.jpg"],
1702
- * prompt: "Transform into oil painting style with dramatic lighting"
1844
+ * prompt: "Transform into oil painting style with dramatic lighting",
1845
+ * model: "fal-ai/nano-banana-pro/edit"
1703
1846
  * });
1704
1847
  *
1705
1848
  * // Background replacement
@@ -1737,11 +1880,12 @@ declare class BlinkAIImpl implements BlinkAI {
1737
1880
  * @returns Promise<ImageGenerationResponse> - Object containing:
1738
1881
  * - `data`: Array of modified images with URLs
1739
1882
  * - `created`: Timestamp of generation
1740
- * - `model`: Always "gemini-2.5-flash-image-preview"
1883
+ * - `model`: The model used for editing
1741
1884
  */
1742
1885
  modifyImage(options: {
1743
1886
  images: string[];
1744
1887
  prompt: string;
1888
+ model?: string;
1745
1889
  n?: number;
1746
1890
  signal?: AbortSignal;
1747
1891
  }): Promise<ImageGenerationResponse>;
@@ -1920,4 +2064,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
1920
2064
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
1921
2065
  }
1922
2066
 
1923
- export { type AnalyticsEvent, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, createClient };
2067
+ export { type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, WebStorageAdapter, createClient, getDefaultStorageAdapter, isBrowser, isNode, isReactNative, isWeb, platform };