@virex-tech/paywallo-sdk 1.1.3 → 1.4.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.
@@ -16,4 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.swift_version = "5.5"
17
17
 
18
18
  s.dependency "React-Core"
19
+ s.dependency "FBSDKCoreKit", "~> 17.0"
19
20
  end
package/README.md CHANGED
@@ -1,43 +1,35 @@
1
1
  # @virex-tech/paywallo-sdk
2
2
 
3
- SDK oficial para integração com Paywallo em aplicações React Native. Oferece Analytics, Feature Flags, Paywalls dinâmicas e gerenciamento de In-App Purchases.
3
+ Paywalls, subscriptions, analytics and feature flags for React Native.
4
4
 
5
- ## Instalação
5
+ ## Install
6
6
 
7
7
  ```bash
8
8
  npm install @virex-tech/paywallo-sdk
9
9
  ```
10
10
 
11
- ### Peer Dependencies
12
-
13
- O SDK requer as seguintes dependências instaladas no seu projeto:
11
+ Peer dependencies:
14
12
 
15
13
  ```bash
16
14
  npm install @react-native-async-storage/async-storage @react-native-community/netinfo react-native-iap react-native-device-info
17
15
  ```
18
16
 
19
- #### Persistência de Device ID (Recomendado)
20
-
21
- Para melhor persistência do device ID entre reinstalações do app (especialmente no iOS), instale também:
17
+ Optional but recommended persists device ID across reinstalls via Keychain (iOS) and Keystore (Android):
22
18
 
23
19
  ```bash
24
20
  npm install react-native-keychain
25
21
  ```
26
22
 
27
- Esta dependência é opcional, mas **altamente recomendada**. Com ela:
28
- - **iOS**: Device ID persiste no Keychain mesmo após desinstalar o app
29
- - **Android**: Device ID é armazenado de forma segura no Keystore
30
-
31
- Sem ela, o SDK usa AsyncStorage como fallback (funciona, mas não persiste após desinstalação).
23
+ Without it, the SDK falls back to AsyncStorage (works, but device ID resets on reinstall).
32
24
 
33
- Para iOS:
25
+ iOS only:
34
26
  ```bash
35
27
  cd ios && pod install
36
28
  ```
37
29
 
38
- ## Quick Start
30
+ ## Quick start
39
31
 
40
- ### 1. Configure o Provider
32
+ ### 1. Wrap your app
41
33
 
42
34
  ```tsx
43
35
  import { PaywalloProvider } from '@virex-tech/paywallo-sdk';
@@ -46,7 +38,7 @@ export default function App() {
46
38
  return (
47
39
  <PaywalloProvider
48
40
  config={{
49
- appKey: 'sua_app_key',
41
+ appKey: 'your_app_key',
50
42
  debug: __DEV__,
51
43
  }}
52
44
  >
@@ -56,7 +48,7 @@ export default function App() {
56
48
  }
57
49
  ```
58
50
 
59
- ### 2. Use os Hooks
51
+ ### 2. Show a paywall
60
52
 
61
53
  ```tsx
62
54
  import { usePaywallo, useSubscription } from '@virex-tech/paywallo-sdk';
@@ -80,55 +72,42 @@ function MyComponent() {
80
72
  }
81
73
  ```
82
74
 
83
- ## API Principal
84
-
85
- ### PaywalloProvider
86
-
87
- Provider que inicializa o SDK e disponibiliza o contexto para toda a aplicação.
88
-
89
- ```tsx
90
- <PaywalloProvider config={PaywalloConfig}>
91
- {children}
92
- </PaywalloProvider>
93
- ```
75
+ ## Hooks
94
76
 
95
77
  ### usePaywallo()
96
78
 
97
- Hook principal com acesso a todas as funcionalidades:
98
-
99
- - `isInitialized` - Se o SDK foi inicializado
100
- - `distinctId` - ID único do usuário
101
- - `presentPaywall(placement)` - Apresenta uma paywall
102
- - `hasActiveSubscription()` - Verifica se assinatura ativa
103
- - `getSubscription()` - Obtém dados da assinatura
104
- - `restorePurchases()` - Restaura compras anteriores
79
+ | Property | Type | Description |
80
+ |---|---|---|
81
+ | `isInitialized` | `boolean` | SDK ready |
82
+ | `distinctId` | `string` | Current user ID |
83
+ | `presentPaywall(placement)` | `Promise<PaywallResult>` | Show a paywall |
84
+ | `hasActiveSubscription()` | `Promise<boolean>` | Check subscription status |
85
+ | `getSubscription()` | `Promise<Subscription>` | Get subscription data |
86
+ | `restorePurchases()` | `Promise<void>` | Restore previous purchases |
105
87
 
106
88
  ### useSubscription()
107
89
 
108
- Hook para gerenciamento de assinaturas:
90
+ | Property | Type | Description |
91
+ |---|---|---|
92
+ | `subscription` | `Subscription \| null` | Current subscription |
93
+ | `isLoading` | `boolean` | Loading state |
94
+ | `refresh()` | `() => void` | Refetch subscription data |
109
95
 
110
- - `subscription` - Dados da assinatura atual
111
- - `isLoading` - Estado de carregamento
112
- - `refresh()` - Atualiza dados da assinatura
96
+ ## Imperative API
113
97
 
114
- ### PaywalloClient (API Imperativa)
115
-
116
- Para uso fora de componentes React:
98
+ For use outside React components:
117
99
 
118
100
  ```tsx
119
101
  import { PaywalloClient } from '@virex-tech/paywallo-sdk';
120
102
 
121
- // Identificar usuário
122
103
  await PaywalloClient.identify('user_123', { email: 'user@example.com' });
123
104
 
124
- // Rastrear evento
125
105
  await PaywalloClient.track('purchase_completed', { product: 'premium' });
126
106
 
127
- // Feature Flags
128
107
  const variant = await PaywalloClient.getVariant('new_feature');
129
108
  ```
130
109
 
131
- ## Tipos
110
+ ## Types
132
111
 
133
112
  ```tsx
134
113
  interface PaywalloConfig {
@@ -155,10 +134,6 @@ interface PaywallResult {
155
134
  }
156
135
  ```
157
136
 
158
- ## Suporte
159
-
160
- Para dúvidas ou problemas, entre em contato com o suporte Paywallo.
161
-
162
- ## Licença
137
+ ## License
163
138
 
164
139
  MIT
@@ -51,4 +51,5 @@ dependencies {
51
51
  implementation "com.android.billingclient:billing-ktx:7.0.0"
52
52
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
53
53
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
54
+ implementation "com.facebook.android:facebook-android-sdk:17.+"
54
55
  }
@@ -0,0 +1,84 @@
1
+ package com.paywallo.sdk
2
+
3
+ import com.facebook.react.bridge.*
4
+ import com.facebook.appevents.AppEventsLogger
5
+ import java.math.BigDecimal
6
+ import java.util.Currency
7
+ import android.os.Bundle
8
+
9
+ class PaywalloFBBridgeModule(private val reactContext: ReactApplicationContext) :
10
+ ReactContextBaseJavaModule(reactContext) {
11
+
12
+ override fun getName() = "PaywalloFBBridge"
13
+
14
+ @ReactMethod
15
+ fun getAnonymousID(promise: Promise) {
16
+ try {
17
+ val anonId = AppEventsLogger.getAnonymousAppDeviceGUID(reactApplicationContext)
18
+ if (anonId.isNullOrEmpty()) {
19
+ promise.resolve(null)
20
+ } else {
21
+ promise.resolve(anonId)
22
+ }
23
+ } catch (e: Exception) {
24
+ promise.resolve(null)
25
+ }
26
+ }
27
+
28
+ @ReactMethod
29
+ fun logEvent(name: String, params: ReadableMap, promise: Promise) {
30
+ try {
31
+ val bundle = toBundle(params)
32
+ val logger = AppEventsLogger.newLogger(reactApplicationContext)
33
+ logger.logEvent(name, bundle)
34
+ promise.resolve(null)
35
+ } catch (e: Exception) {
36
+ promise.resolve(null)
37
+ }
38
+ }
39
+
40
+ @ReactMethod
41
+ fun logPurchase(amount: Double, currency: String, params: ReadableMap, promise: Promise) {
42
+ try {
43
+ val bundle = toBundle(params)
44
+ val logger = AppEventsLogger.newLogger(reactApplicationContext)
45
+ logger.logPurchase(BigDecimal.valueOf(amount), Currency.getInstance(currency), bundle)
46
+ promise.resolve(null)
47
+ } catch (e: Exception) {
48
+ promise.resolve(null)
49
+ }
50
+ }
51
+
52
+ @ReactMethod
53
+ fun setUserID(userId: String) {
54
+ try {
55
+ AppEventsLogger.setUserID(userId)
56
+ } catch (e: Exception) {
57
+ // never crash
58
+ }
59
+ }
60
+
61
+ @ReactMethod
62
+ fun flush() {
63
+ try {
64
+ AppEventsLogger.newLogger(reactApplicationContext).flush()
65
+ } catch (e: Exception) {
66
+ // never crash
67
+ }
68
+ }
69
+
70
+ private fun toBundle(map: ReadableMap): Bundle {
71
+ val bundle = Bundle()
72
+ val iterator = map.keySetIterator()
73
+ while (iterator.hasNextKey()) {
74
+ val key = iterator.nextKey()
75
+ when (map.getType(key)) {
76
+ ReadableType.String -> bundle.putString(key, map.getString(key))
77
+ ReadableType.Number -> bundle.putDouble(key, map.getDouble(key))
78
+ ReadableType.Boolean -> bundle.putBoolean(key, map.getBoolean(key))
79
+ else -> {}
80
+ }
81
+ }
82
+ return bundle
83
+ }
84
+ }
@@ -7,7 +7,10 @@ import com.facebook.react.uimanager.ViewManager
7
7
 
8
8
  class PaywalloSdkPackage : ReactPackage {
9
9
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
- return listOf(PaywalloStoreKitModule(reactContext))
10
+ return listOf(
11
+ PaywalloStoreKitModule(reactContext),
12
+ PaywalloFBBridgeModule(reactContext)
13
+ )
11
14
  }
12
15
 
13
16
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
package/dist/index.d.mts CHANGED
@@ -116,6 +116,7 @@ interface ServerProductInfo {
116
116
  }
117
117
  interface CampaignResponse {
118
118
  campaignId: string;
119
+ placement?: string;
119
120
  variantKey: string;
120
121
  paywall: {
121
122
  id: string;
@@ -183,6 +184,31 @@ interface EmergencyPaywallResponse {
183
184
  paywall?: PaywallConfig;
184
185
  }
185
186
 
187
+ declare class PaywalloError extends Error {
188
+ readonly code: string;
189
+ readonly domain: string;
190
+ constructor(domain: string, code: string, message: string);
191
+ }
192
+
193
+ declare class PurchaseError extends PaywalloError {
194
+ readonly userCancelled: boolean;
195
+ constructor(code: string, message: string, userCancelled?: boolean);
196
+ }
197
+ declare const PURCHASE_ERROR_CODES: {
198
+ readonly NOT_INITIALIZED: "PURCHASE_NOT_INITIALIZED";
199
+ readonly PRODUCT_NOT_FOUND: "PRODUCT_NOT_FOUND";
200
+ readonly PURCHASE_FAILED: "PURCHASE_FAILED";
201
+ readonly RESTORE_FAILED: "RESTORE_FAILED";
202
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
203
+ readonly USER_CANCELLED: "USER_CANCELLED";
204
+ readonly NETWORK_ERROR: "PURCHASE_NETWORK_ERROR";
205
+ readonly STORE_ERROR: "PURCHASE_STORE_ERROR";
206
+ readonly PENDING_PURCHASE: "PURCHASE_PENDING";
207
+ readonly DEFERRED_PURCHASE: "PURCHASE_DEFERRED";
208
+ readonly STORE_NOT_AVAILABLE: "PURCHASE_STORE_NOT_AVAILABLE";
209
+ };
210
+ declare function createPurchaseError(code: keyof typeof PURCHASE_ERROR_CODES, message?: string): PurchaseError;
211
+
186
212
  interface Product {
187
213
  productId: string;
188
214
  title: string;
@@ -196,6 +222,7 @@ interface Product {
196
222
  introductoryPrice?: string;
197
223
  introductoryPriceValue?: number;
198
224
  freeTrialPeriod?: string;
225
+ trialDays?: number;
199
226
  pricePerMonth?: string;
200
227
  pricePerWeek?: string;
201
228
  pricePerDay?: string;
@@ -212,7 +239,7 @@ interface Purchase {
212
239
  interface PurchaseResult {
213
240
  success: boolean;
214
241
  purchase?: Purchase;
215
- error?: Error;
242
+ error?: PurchaseError;
216
243
  }
217
244
  interface ValidatePurchaseResponse {
218
245
  success: boolean;
@@ -252,10 +279,17 @@ interface ApiClientConfig {
252
279
  offlineQueueEnabled?: boolean;
253
280
  timeout?: number;
254
281
  }
282
+ interface PaywallErrorStrings$1 {
283
+ title?: string;
284
+ retry?: string;
285
+ close?: string;
286
+ }
255
287
  interface PaywalloConfig {
256
288
  appKey: string;
289
+ apiUrl?: string;
257
290
  debug?: boolean;
258
291
  environment?: Environment;
292
+ errorStrings?: PaywallErrorStrings$1;
259
293
  }
260
294
  interface UserProperties {
261
295
  [key: string]: string | number | boolean | null;
@@ -367,6 +401,7 @@ interface PreloadResult {
367
401
  interface PaywalloContextValue {
368
402
  config: PaywalloConfig | null;
369
403
  isInitialized: boolean;
404
+ isReady: boolean;
370
405
  initError: Error | null;
371
406
  distinctId: string | null;
372
407
  subscription: Subscription | null;
@@ -386,12 +421,6 @@ interface PaywalloContextValue {
386
421
  }
387
422
  declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
388
423
 
389
- declare class PaywalloError extends Error {
390
- readonly code: string;
391
- readonly domain: string;
392
- constructor(domain: string, code: string, message: string);
393
- }
394
-
395
424
  declare class PaywallError extends PaywalloError {
396
425
  constructor(code: string, message: string);
397
426
  }
@@ -458,9 +487,9 @@ declare class ApiClient {
458
487
  private offlineQueueEnabled;
459
488
  private httpClient;
460
489
  private readonly cache;
461
- constructor(appKey: string, debug?: boolean, environment?: Environment, offlineQueueEnabled?: boolean, timeout?: number);
462
- /** Exposed only for QueueProcessor initialization. Prefer get()/post() for requests. */
490
+ constructor(appKey: string, apiUrl: string, debug?: boolean, environment?: Environment, offlineQueueEnabled?: boolean, timeout?: number);
463
491
  getHttpClient(): HttpClient;
492
+ getBaseUrl(): string;
464
493
  getWebUrl(): string;
465
494
  getEnvironment(): Environment;
466
495
  getQueueSize(): number;
@@ -473,7 +502,7 @@ declare class ApiClient {
473
502
  post<T>(path: string, body: unknown, skipRetry?: boolean): Promise<HttpResponse<T>>;
474
503
  reportError(errorType: string, message: string, context?: Record<string, unknown>): Promise<void>;
475
504
  trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number): Promise<void>;
476
- identify(distinctId: string, properties?: UserProperties, email?: string): Promise<void>;
505
+ identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string): Promise<void>;
477
506
  startSession(distinctId: string, sessionId: string, platform?: string): Promise<{
478
507
  success: boolean;
479
508
  }>;
@@ -484,23 +513,15 @@ declare class ApiClient {
484
513
  getPaywall(placement: string): Promise<PaywallConfig | null>;
485
514
  getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
486
515
  getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
516
+ getPrimaryCampaign(distinctId: string): Promise<CampaignResponse | null>;
487
517
  validatePurchase(platform: "ios" | "android", receipt: string, productId: string, transactionId: string, priceLocal: number, currency: string, country: string, distinctId?: string, paywallPlacement?: string, variantKey?: string): Promise<ValidatePurchaseResponse>;
488
518
  getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
489
519
  evaluateFlags(keys: string[], distinctId: string): Promise<Record<string, string | null>>;
490
520
  getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
491
- /**
492
- * Reads a flag variant from cache layers only — no network call.
493
- * Checks in-memory cache first, then SecureStorage.
494
- * Returns null when both layers miss.
495
- */
496
521
  getVariantFromCache(flagKey: string, distinctId: string): Promise<FlagVariant | null>;
497
522
  private static readonly FLAG_MAX_AGE_MS;
498
523
  private readFlagFromStorage;
499
524
  private writeFlagToStorage;
500
- /**
501
- * POST with offline queue fallback. Enqueues when offline or on network failure.
502
- * Throws only when offlineQueueEnabled is false and the request fails.
503
- */
504
525
  private postWithQueue;
505
526
  private log;
506
527
  }
@@ -594,6 +615,7 @@ declare class IAPService {
594
615
  loadProducts(productIds: string[]): Promise<Product[]>;
595
616
  getProduct(productId: string): Product | undefined;
596
617
  getCachedProducts(): Map<string, Product>;
618
+ private validateWithRetry;
597
619
  private validateWithServer;
598
620
  private finishTransaction;
599
621
  purchase(productId: string, options?: {
@@ -613,7 +635,7 @@ declare const nativeStoreKit: {
613
635
  getActiveTransactions(): Promise<Purchase[]>;
614
636
  };
615
637
 
616
- type PurchaseState = "idle" | "loading" | "purchasing" | "restoring" | "error";
638
+ type PurchaseState = "idle" | "purchasing" | "restoring" | "error";
617
639
  interface IAPProduct {
618
640
  productId: string;
619
641
  price: string;
@@ -630,6 +652,7 @@ interface IAPProduct {
630
652
  introductoryPriceNumberOfPeriodsIOS?: string;
631
653
  introductoryPriceSubscriptionPeriodIOS?: string;
632
654
  freeTrialPeriodAndroid?: string;
655
+ trialDays: number;
633
656
  }
634
657
  interface IAPPurchase {
635
658
  productId: string;
@@ -653,25 +676,6 @@ interface ProductPriceInfo {
653
676
  pricePerDay?: string;
654
677
  }
655
678
 
656
- declare class PurchaseError extends PaywalloError {
657
- readonly userCancelled: boolean;
658
- constructor(code: string, message: string, userCancelled?: boolean);
659
- }
660
- declare const PURCHASE_ERROR_CODES: {
661
- readonly NOT_INITIALIZED: "PURCHASE_NOT_INITIALIZED";
662
- readonly PRODUCT_NOT_FOUND: "PRODUCT_NOT_FOUND";
663
- readonly PURCHASE_FAILED: "PURCHASE_FAILED";
664
- readonly RESTORE_FAILED: "RESTORE_FAILED";
665
- readonly VALIDATION_FAILED: "VALIDATION_FAILED";
666
- readonly USER_CANCELLED: "USER_CANCELLED";
667
- readonly NETWORK_ERROR: "PURCHASE_NETWORK_ERROR";
668
- readonly STORE_ERROR: "PURCHASE_STORE_ERROR";
669
- readonly PENDING_PURCHASE: "PURCHASE_PENDING";
670
- readonly DEFERRED_PURCHASE: "PURCHASE_DEFERRED";
671
- readonly STORE_NOT_AVAILABLE: "PURCHASE_STORE_NOT_AVAILABLE";
672
- };
673
- declare function createPurchaseError(code: keyof typeof PURCHASE_ERROR_CODES, message?: string): PurchaseError;
674
-
675
679
  interface IdentityState {
676
680
  deviceId: string;
677
681
  email: string | null;
@@ -679,6 +683,7 @@ interface IdentityState {
679
683
  }
680
684
  declare class IdentityManager {
681
685
  private deviceId;
686
+ private anonId;
682
687
  private email;
683
688
  private properties;
684
689
  private apiClient;
@@ -697,7 +702,6 @@ declare class IdentityManager {
697
702
  isSecureStorageAvailable(): boolean;
698
703
  private loadPersistedState;
699
704
  private ensureInitialized;
700
- private log;
701
705
  }
702
706
  declare const identityManager: IdentityManager;
703
707
 
@@ -712,6 +716,15 @@ declare const IDENTITY_ERROR_CODES: {
712
716
  readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
713
717
  };
714
718
 
719
+ declare class MetaBridge {
720
+ getAnonymousID(): Promise<string | null>;
721
+ logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
722
+ logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
723
+ setUserID(userId: string): void;
724
+ flush(): void;
725
+ }
726
+ declare const metaBridge: MetaBridge;
727
+
715
728
  type NetworkState = "online" | "offline" | "unknown";
716
729
  type NetworkListener = (state: NetworkState) => void;
717
730
  interface NetworkMonitorConfig {
@@ -724,17 +737,13 @@ declare class NetworkMonitorClass {
724
737
  private config;
725
738
  private listeners;
726
739
  private currentState;
727
- private netInfoModule;
728
- private netInfoSubscription;
729
740
  private appStateSubscription;
730
741
  private initialized;
731
742
  private checkIntervalId;
732
743
  initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
733
- private setupNetInfoListener;
734
744
  private setupFallbackDetection;
735
745
  private setupAppStateListener;
736
746
  private checkConnectivity;
737
- private netInfoStateToNetworkState;
738
747
  private updateState;
739
748
  private notifyListeners;
740
749
  isOnline(): boolean;
@@ -812,16 +821,26 @@ interface PreloadCampaignResult {
812
821
  success: boolean;
813
822
  error?: Error;
814
823
  }
824
+ interface PaywallErrorStrings {
825
+ title?: string;
826
+ retry?: string;
827
+ close?: string;
828
+ }
815
829
  interface PaywalloInitConfig extends PaywalloConfig {
816
830
  sessionConfig?: SessionConfig;
817
831
  autoStartSession?: boolean;
818
832
  offlineQueueEnabled?: boolean;
819
833
  timeout?: number;
820
- /** Request ATT permission during init (iOS only). Default: false. */
821
834
  requestATT?: boolean;
835
+ errorStrings?: PaywallErrorStrings;
836
+ sessionFlags?: string[];
837
+ subscriptionCacheTTL?: number;
838
+ autoPreloadCampaign?: string;
822
839
  }
823
840
  interface IPaywalloClient {
824
841
  init(config: PaywalloInitConfig): Promise<void>;
842
+ isReady(): boolean;
843
+ waitUntilReady(): Promise<void>;
825
844
  identify(options?: IdentifyOptions | UserProperties): Promise<void>;
826
845
  track(eventName: string, options?: TrackEventOptions): Promise<void>;
827
846
  getVariantCached(flagKey: string, defaultValue?: string): Promise<FlagVariant>;
@@ -862,6 +881,7 @@ interface IPaywalloClient {
862
881
  registerActiveChecker(checker: () => Promise<boolean>): void;
863
882
  registerRestoreHandler(handler: () => Promise<RestoreResult>): void;
864
883
  registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
884
+ getSessionFlag(key: string): string | null;
865
885
  isOnline(): boolean;
866
886
  getOfflineQueueSize(): number;
867
887
  clearOfflineQueue(): Promise<void>;
@@ -871,6 +891,9 @@ interface IPaywalloClient {
871
891
  }>;
872
892
  onboardingStep(index: number, name: string): Promise<void>;
873
893
  coreAction(actionName: string): Promise<void>;
894
+ isPreloaded(placement: string): boolean;
895
+ getAutoPreloadedPlacement(): string | null;
896
+ waitForAutoPreloadedPlacement(): Promise<string | null>;
874
897
  }
875
898
 
876
899
  declare const PaywalloClient: IPaywalloClient;
@@ -913,7 +936,7 @@ declare class OfflineQueueClass {
913
936
  private loadFromStorage;
914
937
  private saveToStorage;
915
938
  private cleanupExpired;
916
- enqueue(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>): Promise<QueueItem>;
939
+ enqueue(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>, id?: string): Promise<QueueItem>;
917
940
  private findDuplicateIndex;
918
941
  dequeue(): Promise<QueueItem | null>;
919
942
  removeItem(id: string): Promise<boolean>;
@@ -926,7 +949,6 @@ declare class OfflineQueueClass {
926
949
  processed: number;
927
950
  failed: number;
928
951
  }>;
929
- /** Returns true if the item was permanently removed (counted as failed). */
930
952
  private handleItemFailure;
931
953
  private sleep;
932
954
  getQueue(): ReadonlyArray<QueueItem>;
@@ -1003,6 +1025,7 @@ interface FormattedProduct extends ProductPriceInfo {
1003
1025
  subscriptionPeriod?: string;
1004
1026
  introductoryPrice?: string;
1005
1027
  freeTrialPeriod?: string;
1028
+ trialDays: number;
1006
1029
  }
1007
1030
 
1008
1031
  interface UseProductsResult {
@@ -1017,12 +1040,16 @@ interface UseProductsResult {
1017
1040
  }
1018
1041
  declare function useProducts(initialProductIds?: string[]): UseProductsResult;
1019
1042
 
1043
+ interface PurchaseOutcome {
1044
+ status: "success" | "cancelled" | "failed";
1045
+ purchase?: IAPPurchase;
1046
+ error?: PurchaseError;
1047
+ }
1020
1048
  interface UsePurchaseResult {
1021
1049
  state: PurchaseState;
1022
- purchase: (productId: string) => Promise<IAPPurchase>;
1050
+ purchase: (productId: string) => Promise<PurchaseOutcome>;
1023
1051
  restore: () => Promise<IAPPurchase[]>;
1024
1052
  error: PurchaseError | null;
1025
- isLoading: boolean;
1026
1053
  isPurchasing: boolean;
1027
1054
  isRestoring: boolean;
1028
1055
  }
@@ -1082,10 +1109,13 @@ declare class SubscriptionCache {
1082
1109
  private ttl;
1083
1110
  private memoryCache;
1084
1111
  private storage;
1112
+ private legacyCleanupDone;
1085
1113
  constructor(ttl?: number);
1086
- get(): Promise<CachedSubscription | null>;
1087
- set(data: SubscriptionStatusResponse): Promise<void>;
1088
- invalidate(): Promise<void>;
1114
+ private cleanupLegacyCache;
1115
+ get(distinctId: string): Promise<CachedSubscription | null>;
1116
+ set(distinctId: string, data: SubscriptionStatusResponse): Promise<void>;
1117
+ invalidate(distinctId: string): Promise<void>;
1118
+ invalidateAll(): Promise<void>;
1089
1119
  private isExpired;
1090
1120
  setTTL(ttl: number): void;
1091
1121
  }
@@ -1097,6 +1127,7 @@ declare class SubscriptionManagerClass {
1097
1127
  private listeners;
1098
1128
  private userId;
1099
1129
  constructor();
1130
+ private cacheKey;
1100
1131
  init(config: SubscriptionManagerConfig): void;
1101
1132
  setUserId(userId: string | null): void;
1102
1133
  hasActiveSubscription(forceRefresh?: boolean): Promise<boolean>;
@@ -1149,4 +1180,4 @@ declare function hasVariables(text: string): boolean;
1149
1180
 
1150
1181
  declare const Paywallo: IPaywalloClient;
1151
1182
 
1152
- export { AFFILIATE_ERROR_CODES, ANALYTICS_ERROR_CODES, type AffiliateBalance, type AffiliateCommission, type AffiliateCoupon, AffiliateError, AffiliateManager, AnalyticsError, ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, PURCHASE_ERROR_CODES as ERROR_CODES, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type OfflineQueueConfig, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloAffiliate, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, type WithdrawalRequest, affiliateManager, createPurchaseError, Paywallo as default, detectDeviceLanguage, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, nativeStoreKit, networkMonitor, offlineQueue, parseVariables, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, usePaywallContext, usePaywallo, useProducts, usePurchase, useSubscription };
1183
+ export { AFFILIATE_ERROR_CODES, ANALYTICS_ERROR_CODES, type AffiliateBalance, type AffiliateCommission, type AffiliateCoupon, AffiliateError, AffiliateManager, AnalyticsError, ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, PURCHASE_ERROR_CODES as ERROR_CODES, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type OfflineQueueConfig, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloAffiliate, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, type WithdrawalRequest, affiliateManager, createPurchaseError, Paywallo as default, detectDeviceLanguage, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, offlineQueue, parseVariables, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, usePaywallContext, usePaywallo, useProducts, usePurchase, useSubscription };