@virex-tech/paywallo-sdk 1.4.1 → 1.5.2

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.
@@ -13,6 +13,7 @@ import android.webkit.WebView
13
13
  import android.webkit.WebViewClient
14
14
  import com.facebook.react.bridge.Arguments
15
15
  import com.facebook.react.bridge.ReactContext
16
+ import com.facebook.react.uimanager.UIManagerHelper
16
17
  import com.facebook.react.uimanager.events.RCTEventEmitter
17
18
  import org.json.JSONObject
18
19
 
@@ -30,11 +31,36 @@ class PaywalloWebView(context: ReactContext) : WebView(context) {
30
31
  javaScriptEnabled = true
31
32
  domStorageEnabled = true
32
33
  mediaPlaybackRequiresUserGesture = false
33
- mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
34
+ mixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW
34
35
  cacheMode = WebSettings.LOAD_DEFAULT
35
36
  }
36
37
 
37
38
  webViewClient = object : WebViewClient() {
39
+ // Allow HTTPS and about: (initial blank) to load inside the WebView.
40
+ // Redirect mailto:, intent:, and market: to the OS. Block everything else
41
+ // (plain HTTP, javascript:, data:, blob:) to prevent mixed-content and injection.
42
+ override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
43
+ val uri = request?.url ?: return true
44
+ val scheme = uri.scheme?.lowercase()
45
+
46
+ val osSchemes = setOf("mailto", "intent", "market")
47
+ if (scheme != null && scheme in osSchemes) {
48
+ try {
49
+ val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, uri)
50
+ intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
51
+ context.startActivity(intent)
52
+ } catch (_: Exception) {
53
+ // No app installed to handle this scheme — silently ignore.
54
+ }
55
+ return true // prevent WebView from loading it
56
+ }
57
+
58
+ if (scheme != null && scheme != "https" && scheme != "about") {
59
+ return true // block the navigation
60
+ }
61
+ return false
62
+ }
63
+
38
64
  override fun onPageFinished(view: WebView?, url: String?) {
39
65
  super.onPageFinished(view, url)
40
66
  dispatchEvent("onLoadEnd", null)
@@ -88,6 +114,7 @@ class PaywalloWebView(context: ReactContext) : WebView(context) {
88
114
  private var pendingHtml: String? = null
89
115
 
90
116
  fun setSourceUrl(url: String?) {
117
+ // Only load URL if no inline HTML has been set — HTML takes precedence over URL
91
118
  if (pendingHtml.isNullOrEmpty()) {
92
119
  url?.let { loadUrl(it) }
93
120
  }
@@ -106,8 +133,17 @@ class PaywalloWebView(context: ReactContext) : WebView(context) {
106
133
  val event = Arguments.createMap().apply {
107
134
  data?.let { putString("data", it) }
108
135
  }
109
- reactContext.getJSModule(RCTEventEmitter::class.java)
110
- .receiveEvent(id, eventName, event)
136
+ // UIManagerHelper is the New Architecture path; fall back to legacy RCTEventEmitter
137
+ // for compatibility with React Native < 0.71 (Old Architecture)
138
+ val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)
139
+ if (dispatcher != null) {
140
+ val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
141
+ dispatcher.dispatchEvent(PaywalloWebViewEvent(surfaceId, id, eventName, event))
142
+ } else {
143
+ @Suppress("DEPRECATION")
144
+ reactContext.getJSModule(RCTEventEmitter::class.java)
145
+ ?.receiveEvent(id, eventName, event)
146
+ }
111
147
  }
112
148
 
113
149
  inner class WebAppInterface {
@@ -0,0 +1,20 @@
1
+ package com.paywallo.sdk
2
+
3
+ import com.facebook.react.bridge.WritableMap
4
+ import com.facebook.react.uimanager.events.Event
5
+
6
+ /**
7
+ * Custom event that works with both Old Architecture (RCTEventEmitter) and
8
+ * New Architecture (EventDispatcher via UIManagerHelper).
9
+ */
10
+ class PaywalloWebViewEvent(
11
+ surfaceId: Int,
12
+ viewId: Int,
13
+ private val eventName: String,
14
+ private val payload: WritableMap
15
+ ) : Event<PaywalloWebViewEvent>(surfaceId, viewId) {
16
+
17
+ override fun getEventName(): String = eventName
18
+
19
+ override fun getEventData(): WritableMap = payload
20
+ }
package/dist/index.d.mts CHANGED
@@ -51,7 +51,7 @@ interface TapBehavior {
51
51
  targetStepId?: string;
52
52
  placementName?: string;
53
53
  }
54
- type BlockType = "page" | "stack" | "text" | "button" | "image" | "icon" | "video" | "divider" | "spacer" | "lottie" | "carousel" | "navigation" | "tabs" | "fixed-footer" | "feature-card" | "bullet-item" | "timeline-item" | "simple-link" | "comparison-table" | "countdown" | "review" | "badge" | "popup" | "progress" | "social-proof" | "testimonial" | "accolades" | "sticker" | "product-card" | "toggle-option" | "delayed-close" | "close-button" | "back-button" | "trial-toggle" | "period-picker" | "product-list" | "exit-offer" | "spin-wheel";
54
+ type BlockType = "page" | "stack" | "container" | "text" | "button" | "purchase-button" | "restore-button" | "image" | "icon" | "video" | "divider" | "spacer" | "lottie" | "carousel" | "navigation" | "tabs" | "fixed-footer" | "feature-card" | "bullet-item" | "timeline-item" | "simple-link" | "comparison-table" | "countdown" | "review" | "badge" | "popup" | "progress" | "social-proof" | "testimonial" | "accolades" | "sticker" | "product-card" | "product-cards" | "toggle-option" | "delayed-close" | "close-button" | "back-button" | "trial-toggle" | "period-picker" | "product-list" | "exit-offer" | "spin-wheel" | "form-input" | "rating-input" | "chart" | "gif" | "scroll-list" | "shared-block-ref";
55
55
 
56
56
  /**
57
57
  * Layout block props — page, stack, fixed-footer, popup.
@@ -116,7 +116,7 @@ interface ServerProductInfo {
116
116
  }
117
117
  interface CampaignResponse {
118
118
  campaignId: string;
119
- placement?: string;
119
+ placement: string;
120
120
  variantKey: string;
121
121
  paywall: {
122
122
  id: string;
@@ -264,6 +264,7 @@ interface Subscription {
264
264
  interface SubscriptionStatusResponse$1 {
265
265
  hasActiveSubscription: boolean;
266
266
  subscription: Subscription | null;
267
+ entitlements: string[];
267
268
  }
268
269
  interface RestoreResult {
269
270
  success: boolean;
@@ -316,31 +317,6 @@ interface ConditionalFlagContext {
316
317
  country?: string;
317
318
  distinctId?: string;
318
319
  }
319
- interface AffiliateCoupon {
320
- code: string;
321
- status: string;
322
- createdAt: Date;
323
- }
324
- interface AffiliateCommission {
325
- id: string;
326
- referredDistinctId: string;
327
- purchaseAmount: number;
328
- commissionAmount: number;
329
- status: "pending" | "eligible" | "ineligible" | "withdrawn";
330
- createdAt: Date;
331
- }
332
- interface AffiliateBalance {
333
- total: number;
334
- pending: number;
335
- available: number;
336
- withdrawn: number;
337
- }
338
- interface WithdrawalRequest {
339
- id: string;
340
- amount: number;
341
- status: "pending" | "approved" | "rejected" | "paid";
342
- createdAt: Date;
343
- }
344
320
 
345
321
  interface PaywallModalProps {
346
322
  placement: string;
@@ -472,7 +448,10 @@ declare class HttpClient {
472
448
  private shouldRetry;
473
449
  private isNetworkError;
474
450
  private calculateDelay;
451
+ private calculateDelayForResponse;
475
452
  private sleep;
453
+ /** Strips path segments that look like app keys (alphanumeric, 20–64 chars) from URLs before logging. */
454
+ private redactUrl;
476
455
  private log;
477
456
  setDebug(debug: boolean): void;
478
457
  getConfig(): Readonly<HttpClientConfig>;
@@ -487,10 +466,12 @@ declare class ApiClient {
487
466
  private offlineQueueEnabled;
488
467
  private httpClient;
489
468
  private readonly cache;
469
+ private readonly batcher;
490
470
  constructor(appKey: string, apiUrl: string, debug?: boolean, environment?: Environment, offlineQueueEnabled?: boolean, timeout?: number);
491
471
  getHttpClient(): HttpClient;
492
472
  getBaseUrl(): string;
493
473
  getWebUrl(): string;
474
+ getAppKey(): string;
494
475
  getEnvironment(): Environment;
495
476
  getQueueSize(): number;
496
477
  setofflineQueueEnabled(enabled: boolean): void;
@@ -502,8 +483,10 @@ declare class ApiClient {
502
483
  post<T>(path: string, body: unknown, skipRetry?: boolean): Promise<HttpResponse<T>>;
503
484
  reportError(errorType: string, message: string, context?: Record<string, unknown>): Promise<void>;
504
485
  trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number): Promise<void>;
486
+ flushEventBatch(): Promise<void>;
487
+ dispose(): void;
505
488
  identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string): Promise<void>;
506
- startSession(distinctId: string, sessionId: string, platform?: string): Promise<{
489
+ startSession(distinctId: string, sessionId: string, platform?: string, appVersion?: string, deviceModel?: string, osVersion?: string): Promise<{
507
490
  success: boolean;
508
491
  }>;
509
492
  endSession(sessionId: string, durationSeconds: number): Promise<{
@@ -519,94 +502,14 @@ declare class ApiClient {
519
502
  evaluateFlags(keys: string[], distinctId: string): Promise<Record<string, string | null>>;
520
503
  getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
521
504
  getVariantFromCache(flagKey: string, distinctId: string): Promise<FlagVariant | null>;
522
- private static readonly FLAG_MAX_AGE_MS;
523
- private readFlagFromStorage;
524
- private writeFlagToStorage;
525
505
  private postWithQueue;
526
506
  private log;
527
507
  }
528
508
 
529
- declare class AffiliateManager {
530
- private apiClient;
531
- private debug;
532
- initialize(apiClient: ApiClient, debug?: boolean): void;
533
- registerCoupon(code: string): Promise<{
534
- success: boolean;
535
- coupon?: AffiliateCoupon;
536
- error?: string;
537
- }>;
538
- applyCoupon(code: string): Promise<{
539
- success: boolean;
540
- applied?: boolean;
541
- error?: string;
542
- }>;
543
- getMyCoupon(): Promise<{
544
- coupon: AffiliateCoupon | null;
545
- }>;
546
- getAppliedCoupon(): Promise<{
547
- coupon: {
548
- code: string;
549
- } | null;
550
- }>;
551
- getBalance(): Promise<AffiliateBalance>;
552
- getCommissions(): Promise<AffiliateCommission[]>;
553
- requestWithdrawal(amount: number): Promise<{
554
- success: boolean;
555
- withdrawal?: WithdrawalRequest;
556
- error?: string;
557
- }>;
558
- getWithdrawals(): Promise<WithdrawalRequest[]>;
559
- private get;
560
- private post;
561
- private ensureInitialized;
562
- private log;
563
- }
564
- declare const affiliateManager: AffiliateManager;
565
-
566
- declare const PaywalloAffiliate: {
567
- registerCoupon: (code: string) => Promise<{
568
- success: boolean;
569
- coupon?: AffiliateCoupon;
570
- error?: string;
571
- }>;
572
- applyCoupon: (code: string) => Promise<{
573
- success: boolean;
574
- applied?: boolean;
575
- error?: string;
576
- }>;
577
- getMyCoupon: () => Promise<{
578
- coupon: AffiliateCoupon | null;
579
- }>;
580
- getAppliedCoupon: () => Promise<{
581
- coupon: {
582
- code: string;
583
- } | null;
584
- }>;
585
- getBalance: () => Promise<AffiliateBalance>;
586
- getCommissions: () => Promise<AffiliateCommission[]>;
587
- requestWithdrawal: (amount: number) => Promise<{
588
- success: boolean;
589
- withdrawal?: WithdrawalRequest;
590
- error?: string;
591
- }>;
592
- getWithdrawals: () => Promise<WithdrawalRequest[]>;
593
- };
594
-
595
- declare class AffiliateError extends PaywalloError {
596
- constructor(code: string, message: string);
597
- }
598
- declare const AFFILIATE_ERROR_CODES: {
599
- readonly NOT_INITIALIZED: "AFFILIATE_NOT_INITIALIZED";
600
- readonly COUPON_REGISTER_FAILED: "AFFILIATE_COUPON_REGISTER_FAILED";
601
- readonly COUPON_APPLY_FAILED: "AFFILIATE_COUPON_APPLY_FAILED";
602
- readonly BALANCE_FETCH_FAILED: "AFFILIATE_BALANCE_FETCH_FAILED";
603
- readonly WITHDRAWAL_FAILED: "AFFILIATE_WITHDRAWAL_FAILED";
604
- readonly NETWORK_ERROR: "AFFILIATE_NETWORK_ERROR";
605
- };
606
-
607
509
  declare class IAPService {
608
510
  private productsCache;
609
511
  private apiClient;
512
+ private purchaseInFlight;
610
513
  constructor(apiClient?: ApiClient);
611
514
  private get debug();
612
515
  private getDeviceCountry;
@@ -690,7 +593,9 @@ declare class IdentityManager {
690
593
  private secureStorage;
691
594
  private debug;
692
595
  private initialized;
596
+ private initPromise;
693
597
  initialize(apiClient: ApiClient, debug?: boolean): Promise<string>;
598
+ private _doInitialize;
694
599
  identify(options?: IdentifyOptions | UserProperties): Promise<void>;
695
600
  getDistinctId(): string;
696
601
  getDeviceId(): string | null;
@@ -791,7 +696,7 @@ declare class SessionManager {
791
696
  isSessionActive(): boolean;
792
697
  getState(): SessionState;
793
698
  destroy(): void;
794
- registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
699
+ registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
795
700
  private restoreSession;
796
701
  private setupAppStateListener;
797
702
  private handleAppStateChange;
@@ -875,12 +780,13 @@ interface IPaywalloClient {
875
780
  getSessionId(): string | null;
876
781
  startSession(): Promise<string>;
877
782
  endSession(): Promise<void>;
878
- registerPaywallPresenter(presenter: (placement: string) => Promise<PaywallResult>): void;
879
- registerCampaignPresenter(presenter: (campaign: CampaignResponse) => Promise<CampaignResult>): void;
880
- registerSubscriptionGetter(getter: () => Promise<Subscription | null>): void;
881
- registerActiveChecker(checker: () => Promise<boolean>): void;
882
- registerRestoreHandler(handler: () => Promise<RestoreResult>): void;
883
- registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
783
+ registerPaywallPresenter(presenter: ((placement: string) => Promise<PaywallResult>) | null): void;
784
+ registerCampaignPresenter(presenter: ((campaign: CampaignResponse) => Promise<CampaignResult>) | null): void;
785
+ registerSubscriptionGetter(getter: (() => Promise<Subscription | null>) | null): void;
786
+ registerActiveChecker(checker: (() => Promise<boolean>) | null): void;
787
+ registerRestoreHandler(handler: (() => Promise<RestoreResult>) | null): void;
788
+ registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
789
+ getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
884
790
  getSessionFlag(key: string): string | null;
885
791
  isOnline(): boolean;
886
792
  getOfflineQueueSize(): number;
@@ -983,6 +889,7 @@ declare class QueueProcessorClass {
983
889
  processed: number;
984
890
  failed: number;
985
891
  }>;
892
+ private processEventBatches;
986
893
  private processItem;
987
894
  enqueueIfOffline(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>): Promise<{
988
895
  queued: boolean;
@@ -1114,6 +1021,8 @@ declare class SubscriptionCache {
1114
1021
  private cleanupLegacyCache;
1115
1022
  get(distinctId: string): Promise<CachedSubscription | null>;
1116
1023
  set(distinctId: string, data: SubscriptionStatusResponse): Promise<void>;
1024
+ private addToIndex;
1025
+ private readIndex;
1117
1026
  invalidate(distinctId: string): Promise<void>;
1118
1027
  invalidateAll(): Promise<void>;
1119
1028
  private isExpired;
@@ -1180,4 +1089,4 @@ declare function hasVariables(text: string): boolean;
1180
1089
 
1181
1090
  declare const Paywallo: IPaywalloClient;
1182
1091
 
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 };
1092
+ export { ANALYTICS_ERROR_CODES, 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 EmergencyPaywallResponse, 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, 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, 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 };
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ interface TapBehavior {
51
51
  targetStepId?: string;
52
52
  placementName?: string;
53
53
  }
54
- type BlockType = "page" | "stack" | "text" | "button" | "image" | "icon" | "video" | "divider" | "spacer" | "lottie" | "carousel" | "navigation" | "tabs" | "fixed-footer" | "feature-card" | "bullet-item" | "timeline-item" | "simple-link" | "comparison-table" | "countdown" | "review" | "badge" | "popup" | "progress" | "social-proof" | "testimonial" | "accolades" | "sticker" | "product-card" | "toggle-option" | "delayed-close" | "close-button" | "back-button" | "trial-toggle" | "period-picker" | "product-list" | "exit-offer" | "spin-wheel";
54
+ type BlockType = "page" | "stack" | "container" | "text" | "button" | "purchase-button" | "restore-button" | "image" | "icon" | "video" | "divider" | "spacer" | "lottie" | "carousel" | "navigation" | "tabs" | "fixed-footer" | "feature-card" | "bullet-item" | "timeline-item" | "simple-link" | "comparison-table" | "countdown" | "review" | "badge" | "popup" | "progress" | "social-proof" | "testimonial" | "accolades" | "sticker" | "product-card" | "product-cards" | "toggle-option" | "delayed-close" | "close-button" | "back-button" | "trial-toggle" | "period-picker" | "product-list" | "exit-offer" | "spin-wheel" | "form-input" | "rating-input" | "chart" | "gif" | "scroll-list" | "shared-block-ref";
55
55
 
56
56
  /**
57
57
  * Layout block props — page, stack, fixed-footer, popup.
@@ -116,7 +116,7 @@ interface ServerProductInfo {
116
116
  }
117
117
  interface CampaignResponse {
118
118
  campaignId: string;
119
- placement?: string;
119
+ placement: string;
120
120
  variantKey: string;
121
121
  paywall: {
122
122
  id: string;
@@ -264,6 +264,7 @@ interface Subscription {
264
264
  interface SubscriptionStatusResponse$1 {
265
265
  hasActiveSubscription: boolean;
266
266
  subscription: Subscription | null;
267
+ entitlements: string[];
267
268
  }
268
269
  interface RestoreResult {
269
270
  success: boolean;
@@ -316,31 +317,6 @@ interface ConditionalFlagContext {
316
317
  country?: string;
317
318
  distinctId?: string;
318
319
  }
319
- interface AffiliateCoupon {
320
- code: string;
321
- status: string;
322
- createdAt: Date;
323
- }
324
- interface AffiliateCommission {
325
- id: string;
326
- referredDistinctId: string;
327
- purchaseAmount: number;
328
- commissionAmount: number;
329
- status: "pending" | "eligible" | "ineligible" | "withdrawn";
330
- createdAt: Date;
331
- }
332
- interface AffiliateBalance {
333
- total: number;
334
- pending: number;
335
- available: number;
336
- withdrawn: number;
337
- }
338
- interface WithdrawalRequest {
339
- id: string;
340
- amount: number;
341
- status: "pending" | "approved" | "rejected" | "paid";
342
- createdAt: Date;
343
- }
344
320
 
345
321
  interface PaywallModalProps {
346
322
  placement: string;
@@ -472,7 +448,10 @@ declare class HttpClient {
472
448
  private shouldRetry;
473
449
  private isNetworkError;
474
450
  private calculateDelay;
451
+ private calculateDelayForResponse;
475
452
  private sleep;
453
+ /** Strips path segments that look like app keys (alphanumeric, 20–64 chars) from URLs before logging. */
454
+ private redactUrl;
476
455
  private log;
477
456
  setDebug(debug: boolean): void;
478
457
  getConfig(): Readonly<HttpClientConfig>;
@@ -487,10 +466,12 @@ declare class ApiClient {
487
466
  private offlineQueueEnabled;
488
467
  private httpClient;
489
468
  private readonly cache;
469
+ private readonly batcher;
490
470
  constructor(appKey: string, apiUrl: string, debug?: boolean, environment?: Environment, offlineQueueEnabled?: boolean, timeout?: number);
491
471
  getHttpClient(): HttpClient;
492
472
  getBaseUrl(): string;
493
473
  getWebUrl(): string;
474
+ getAppKey(): string;
494
475
  getEnvironment(): Environment;
495
476
  getQueueSize(): number;
496
477
  setofflineQueueEnabled(enabled: boolean): void;
@@ -502,8 +483,10 @@ declare class ApiClient {
502
483
  post<T>(path: string, body: unknown, skipRetry?: boolean): Promise<HttpResponse<T>>;
503
484
  reportError(errorType: string, message: string, context?: Record<string, unknown>): Promise<void>;
504
485
  trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number): Promise<void>;
486
+ flushEventBatch(): Promise<void>;
487
+ dispose(): void;
505
488
  identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string): Promise<void>;
506
- startSession(distinctId: string, sessionId: string, platform?: string): Promise<{
489
+ startSession(distinctId: string, sessionId: string, platform?: string, appVersion?: string, deviceModel?: string, osVersion?: string): Promise<{
507
490
  success: boolean;
508
491
  }>;
509
492
  endSession(sessionId: string, durationSeconds: number): Promise<{
@@ -519,94 +502,14 @@ declare class ApiClient {
519
502
  evaluateFlags(keys: string[], distinctId: string): Promise<Record<string, string | null>>;
520
503
  getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
521
504
  getVariantFromCache(flagKey: string, distinctId: string): Promise<FlagVariant | null>;
522
- private static readonly FLAG_MAX_AGE_MS;
523
- private readFlagFromStorage;
524
- private writeFlagToStorage;
525
505
  private postWithQueue;
526
506
  private log;
527
507
  }
528
508
 
529
- declare class AffiliateManager {
530
- private apiClient;
531
- private debug;
532
- initialize(apiClient: ApiClient, debug?: boolean): void;
533
- registerCoupon(code: string): Promise<{
534
- success: boolean;
535
- coupon?: AffiliateCoupon;
536
- error?: string;
537
- }>;
538
- applyCoupon(code: string): Promise<{
539
- success: boolean;
540
- applied?: boolean;
541
- error?: string;
542
- }>;
543
- getMyCoupon(): Promise<{
544
- coupon: AffiliateCoupon | null;
545
- }>;
546
- getAppliedCoupon(): Promise<{
547
- coupon: {
548
- code: string;
549
- } | null;
550
- }>;
551
- getBalance(): Promise<AffiliateBalance>;
552
- getCommissions(): Promise<AffiliateCommission[]>;
553
- requestWithdrawal(amount: number): Promise<{
554
- success: boolean;
555
- withdrawal?: WithdrawalRequest;
556
- error?: string;
557
- }>;
558
- getWithdrawals(): Promise<WithdrawalRequest[]>;
559
- private get;
560
- private post;
561
- private ensureInitialized;
562
- private log;
563
- }
564
- declare const affiliateManager: AffiliateManager;
565
-
566
- declare const PaywalloAffiliate: {
567
- registerCoupon: (code: string) => Promise<{
568
- success: boolean;
569
- coupon?: AffiliateCoupon;
570
- error?: string;
571
- }>;
572
- applyCoupon: (code: string) => Promise<{
573
- success: boolean;
574
- applied?: boolean;
575
- error?: string;
576
- }>;
577
- getMyCoupon: () => Promise<{
578
- coupon: AffiliateCoupon | null;
579
- }>;
580
- getAppliedCoupon: () => Promise<{
581
- coupon: {
582
- code: string;
583
- } | null;
584
- }>;
585
- getBalance: () => Promise<AffiliateBalance>;
586
- getCommissions: () => Promise<AffiliateCommission[]>;
587
- requestWithdrawal: (amount: number) => Promise<{
588
- success: boolean;
589
- withdrawal?: WithdrawalRequest;
590
- error?: string;
591
- }>;
592
- getWithdrawals: () => Promise<WithdrawalRequest[]>;
593
- };
594
-
595
- declare class AffiliateError extends PaywalloError {
596
- constructor(code: string, message: string);
597
- }
598
- declare const AFFILIATE_ERROR_CODES: {
599
- readonly NOT_INITIALIZED: "AFFILIATE_NOT_INITIALIZED";
600
- readonly COUPON_REGISTER_FAILED: "AFFILIATE_COUPON_REGISTER_FAILED";
601
- readonly COUPON_APPLY_FAILED: "AFFILIATE_COUPON_APPLY_FAILED";
602
- readonly BALANCE_FETCH_FAILED: "AFFILIATE_BALANCE_FETCH_FAILED";
603
- readonly WITHDRAWAL_FAILED: "AFFILIATE_WITHDRAWAL_FAILED";
604
- readonly NETWORK_ERROR: "AFFILIATE_NETWORK_ERROR";
605
- };
606
-
607
509
  declare class IAPService {
608
510
  private productsCache;
609
511
  private apiClient;
512
+ private purchaseInFlight;
610
513
  constructor(apiClient?: ApiClient);
611
514
  private get debug();
612
515
  private getDeviceCountry;
@@ -690,7 +593,9 @@ declare class IdentityManager {
690
593
  private secureStorage;
691
594
  private debug;
692
595
  private initialized;
596
+ private initPromise;
693
597
  initialize(apiClient: ApiClient, debug?: boolean): Promise<string>;
598
+ private _doInitialize;
694
599
  identify(options?: IdentifyOptions | UserProperties): Promise<void>;
695
600
  getDistinctId(): string;
696
601
  getDeviceId(): string | null;
@@ -791,7 +696,7 @@ declare class SessionManager {
791
696
  isSessionActive(): boolean;
792
697
  getState(): SessionState;
793
698
  destroy(): void;
794
- registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
699
+ registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
795
700
  private restoreSession;
796
701
  private setupAppStateListener;
797
702
  private handleAppStateChange;
@@ -875,12 +780,13 @@ interface IPaywalloClient {
875
780
  getSessionId(): string | null;
876
781
  startSession(): Promise<string>;
877
782
  endSession(): Promise<void>;
878
- registerPaywallPresenter(presenter: (placement: string) => Promise<PaywallResult>): void;
879
- registerCampaignPresenter(presenter: (campaign: CampaignResponse) => Promise<CampaignResult>): void;
880
- registerSubscriptionGetter(getter: () => Promise<Subscription | null>): void;
881
- registerActiveChecker(checker: () => Promise<boolean>): void;
882
- registerRestoreHandler(handler: () => Promise<RestoreResult>): void;
883
- registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
783
+ registerPaywallPresenter(presenter: ((placement: string) => Promise<PaywallResult>) | null): void;
784
+ registerCampaignPresenter(presenter: ((campaign: CampaignResponse) => Promise<CampaignResult>) | null): void;
785
+ registerSubscriptionGetter(getter: (() => Promise<Subscription | null>) | null): void;
786
+ registerActiveChecker(checker: (() => Promise<boolean>) | null): void;
787
+ registerRestoreHandler(handler: (() => Promise<RestoreResult>) | null): void;
788
+ registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
789
+ getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
884
790
  getSessionFlag(key: string): string | null;
885
791
  isOnline(): boolean;
886
792
  getOfflineQueueSize(): number;
@@ -983,6 +889,7 @@ declare class QueueProcessorClass {
983
889
  processed: number;
984
890
  failed: number;
985
891
  }>;
892
+ private processEventBatches;
986
893
  private processItem;
987
894
  enqueueIfOffline(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>): Promise<{
988
895
  queued: boolean;
@@ -1114,6 +1021,8 @@ declare class SubscriptionCache {
1114
1021
  private cleanupLegacyCache;
1115
1022
  get(distinctId: string): Promise<CachedSubscription | null>;
1116
1023
  set(distinctId: string, data: SubscriptionStatusResponse): Promise<void>;
1024
+ private addToIndex;
1025
+ private readIndex;
1117
1026
  invalidate(distinctId: string): Promise<void>;
1118
1027
  invalidateAll(): Promise<void>;
1119
1028
  private isExpired;
@@ -1180,4 +1089,4 @@ declare function hasVariables(text: string): boolean;
1180
1089
 
1181
1090
  declare const Paywallo: IPaywalloClient;
1182
1091
 
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 };
1092
+ export { ANALYTICS_ERROR_CODES, 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 EmergencyPaywallResponse, 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, 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, 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 };