@virex-tech/paywallo-sdk 2.1.0 → 2.2.3

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/dist/index.d.mts CHANGED
@@ -282,7 +282,7 @@ interface SubscriptionStatusResponse$1 {
282
282
  subscription: Subscription | null;
283
283
  entitlements: string[];
284
284
  }
285
- interface RestoreResult {
285
+ interface RestoreResult$1 {
286
286
  success: boolean;
287
287
  restoredProducts: string[];
288
288
  error?: Error;
@@ -314,6 +314,11 @@ interface UserProperties {
314
314
  interface IdentifyOptions {
315
315
  email?: string;
316
316
  properties?: UserProperties;
317
+ phone?: string;
318
+ firstName?: string;
319
+ lastName?: string;
320
+ dateOfBirth?: string;
321
+ gender?: "m" | "f";
317
322
  }
318
323
  interface TrackEventOptions {
319
324
  properties?: UserProperties;
@@ -341,60 +346,6 @@ interface ConditionalFlagContext {
341
346
  distinctId?: string;
342
347
  }
343
348
 
344
- interface PaywallModalProps {
345
- placement: string;
346
- visible: boolean;
347
- onResult: (result: PaywallResult) => void;
348
- paywallConfig?: {
349
- id: string;
350
- placement: string;
351
- config: Record<string, unknown>;
352
- primaryProductId?: string;
353
- secondaryProductId?: string;
354
- };
355
- preloadedProducts?: Map<string, Product>;
356
- variantKey?: string;
357
- campaignId?: string;
358
- /** UUID de `paywall_variants` (sub-fase 2.14). */
359
- variantId?: string;
360
- }
361
- declare function PaywallModal({ placement, visible, onResult, paywallConfig: preloadedConfig, preloadedProducts, variantKey, campaignId, variantId, }: PaywallModalProps): React__default.ReactElement | null;
362
-
363
- interface PaywallContextValue {
364
- nodes: Record<string, PaywallNode>;
365
- rootId: string;
366
- language: string;
367
- defaultLanguage: string;
368
- products: Map<string, Product>;
369
- selectedProductId: string | null;
370
- primaryProductId: string | null;
371
- secondaryProductId: string | null;
372
- currentNavigationIndex: number;
373
- currentTabIndex: number;
374
- trialEnabled: boolean;
375
- selectedPeriod: string | null;
376
- isPurchasing: boolean;
377
- exitOfferVisible: boolean;
378
- exitOfferTriggeredByBackButton: boolean;
379
- onClose: () => void;
380
- onTryClose: () => void;
381
- onSelectProduct: (productId: string) => void;
382
- onPurchase: (productId: string) => void;
383
- onRestore: () => void;
384
- onNavigate: (target: "next" | "previous" | "first" | "last" | number) => void;
385
- onSetTab: (index: number) => void;
386
- onSetVariable: (name: string, value: string) => void;
387
- onToggleTrial: (enabled: boolean) => void;
388
- onSelectPeriod: (value: string) => void;
389
- onOpenUrl: (url: string, inBrowser?: boolean) => void;
390
- onTapBehavior: (behavior: TapBehavior) => void;
391
- onShowExitOffer: () => void;
392
- onDismissExitOffer: () => void;
393
- onTriggerBackButton: () => void;
394
- }
395
- declare const PaywallContext: React.Context<PaywallContextValue | null>;
396
- declare function usePaywallContext(): PaywallContextValue;
397
-
398
349
  interface PreloadResult {
399
350
  success: boolean;
400
351
  error?: Error;
@@ -422,17 +373,53 @@ interface PaywalloContextValue {
422
373
  }
423
374
  declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
424
375
 
425
- declare class PaywallError extends PaywalloError {
426
- constructor(code: string, message: string);
376
+ /**
377
+ * Shared context resolved once per batch and hoisted out of every individual
378
+ * event in the V2 ingest envelope. The provider is called at flush time so
379
+ * each field reflects the most recent SDK state.
380
+ *
381
+ * The shape mirrors the server-side `/api/v2/ingest/batch` contract (Phase
382
+ * 3.1). Fields declared here are deduplicated across the batch — they exist
383
+ * once on the envelope instead of `N` times on each `events[]` entry.
384
+ */
385
+ interface EventContext {
386
+ distinct_id?: string;
387
+ session_id?: string;
388
+ device_id?: string;
389
+ app_version?: string;
390
+ sdk_version?: string;
391
+ platform?: string;
392
+ os_version?: string;
393
+ device_model?: string;
394
+ timezone?: string;
395
+ locale?: string;
396
+ attribution?: Record<string, unknown>;
397
+ ids?: Record<string, unknown>;
398
+ }
399
+
400
+ /**
401
+ * Event priority controls flush semantics:
402
+ *
403
+ * - `"critical"` → flushed as a batch-of-1 on the next microtask (via
404
+ * `queueMicrotask`). Used for events where loss is unacceptable:
405
+ * `transaction`, `identify`, `lifecycle {type: "install"}`,
406
+ * `subscription_*`, `refund`, `checkout_started`.
407
+ * - `"normal"` → buffered and flushed on a rolling window (whichever fires
408
+ * first): `BATCH_MAX_SIZE` events OR `BATCH_FLUSH_MS`. Used for events
409
+ * where batching amortizes network cost: `paywall`, non-install
410
+ * `lifecycle` (foreground/background/session), `onboarding`,
411
+ * `notification`, `custom`.
412
+ *
413
+ * Both priorities post to `/sdk/ingest/batch` (Phase 3.1 envelope) with
414
+ * automatic fallback to `/sdk/events/batch` when the V2 endpoint is
415
+ * absent (old server) or rejects the request. `OfflineQueue` handles
416
+ * network-failure durability for both queues via the `PostFn` injected by
417
+ * `ApiClient.postWithQueue`.
418
+ */
419
+ type EventPriority = "critical" | "normal";
420
+ interface TrackOptions {
421
+ priority?: EventPriority;
427
422
  }
428
- declare const PAYWALL_ERROR_CODES: {
429
- readonly NOT_INITIALIZED: "PAYWALL_NOT_INITIALIZED";
430
- readonly NOT_FOUND: "PAYWALL_NOT_FOUND";
431
- readonly RENDER_FAILED: "PAYWALL_RENDER_FAILED";
432
- readonly LOAD_FAILED: "PAYWALL_LOAD_FAILED";
433
- readonly DISMISS_FAILED: "PAYWALL_DISMISS_FAILED";
434
- readonly INVALID_CONFIG: "PAYWALL_INVALID_CONFIG";
435
- };
436
423
 
437
424
  interface RetryConfig {
438
425
  maxRetries: number;
@@ -493,54 +480,6 @@ declare class HttpClient {
493
480
  getConfig(): Readonly<HttpClientConfig>;
494
481
  }
495
482
 
496
- /**
497
- * Shared context resolved once per batch and hoisted out of every individual
498
- * event in the V2 ingest envelope. The provider is called at flush time so
499
- * each field reflects the most recent SDK state.
500
- *
501
- * The shape mirrors the server-side `/api/v2/ingest/batch` contract (Phase
502
- * 3.1). Fields declared here are deduplicated across the batch — they exist
503
- * once on the envelope instead of `N` times on each `events[]` entry.
504
- */
505
- interface EventContext {
506
- distinct_id?: string;
507
- session_id?: string;
508
- device_id?: string;
509
- app_version?: string;
510
- sdk_version?: string;
511
- platform?: string;
512
- os_version?: string;
513
- device_model?: string;
514
- timezone?: string;
515
- locale?: string;
516
- attribution?: Record<string, unknown>;
517
- ids?: Record<string, unknown>;
518
- }
519
-
520
- /**
521
- * Event priority controls flush semantics:
522
- *
523
- * - `"critical"` → flushed as a batch-of-1 on the next microtask (via
524
- * `queueMicrotask`). Used for events where loss is unacceptable:
525
- * `transaction`, `identify`, `lifecycle {type: "install"}`,
526
- * `subscription_*`, `refund`, `checkout_started`.
527
- * - `"normal"` → buffered and flushed on a rolling window (whichever fires
528
- * first): `BATCH_MAX_SIZE` events OR `BATCH_FLUSH_MS`. Used for events
529
- * where batching amortizes network cost: `paywall`, non-install
530
- * `lifecycle` (foreground/background/session), `onboarding`,
531
- * `notification`, `custom`.
532
- *
533
- * Both priorities post to `/ingest/batch` (Phase 3.1 envelope) with
534
- * automatic fallback to `/events/batch` when the V2 endpoint is
535
- * absent (old server) or rejects the request. `OfflineQueue` handles
536
- * network-failure durability for both queues via the `PostFn` injected by
537
- * `ApiClient.postWithQueue`.
538
- */
539
- type EventPriority = "critical" | "normal";
540
- interface TrackOptions {
541
- priority?: EventPriority;
542
- }
543
-
544
483
  declare class ApiClient {
545
484
  private baseUrl;
546
485
  private webUrl;
@@ -585,11 +524,18 @@ declare class ApiClient {
585
524
  trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number, options?: TrackOptions): Promise<void>;
586
525
  flushEventBatch(): Promise<void>;
587
526
  dispose(): void;
588
- identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string): Promise<void>;
527
+ identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string, pii?: {
528
+ phone?: string;
529
+ firstName?: string;
530
+ lastName?: string;
531
+ dateOfBirth?: string;
532
+ gender?: string;
533
+ }): Promise<void>;
589
534
  getVariant(flagKey: string, distinctId: string): Promise<FlagVariant>;
590
535
  getPaywall(placement: string): Promise<PaywallConfig | null>;
591
536
  getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
592
537
  getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
538
+ getActivePlacements(): Promise<string[]>;
593
539
  getPrimaryCampaign(distinctId: string): Promise<CampaignResponse | null>;
594
540
  validatePurchase(platform: "ios" | "android", receipt: string, productId: string, transactionId: string, priceLocal: number, currency: string, country: string, distinctId?: string, paywallPlacement?: string, variantKey?: string): Promise<ValidatePurchaseResponse>;
595
541
  getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
@@ -599,130 +545,80 @@ declare class ApiClient {
599
545
  private flagDeps;
600
546
  }
601
547
 
548
+ type NetworkState = "online" | "offline" | "unknown";
549
+ type NetworkListener = (state: NetworkState) => void;
550
+ interface NetworkMonitorConfig {
551
+ debug: boolean;
552
+ checkInterval: number;
553
+ checkUrl: string;
554
+ }
555
+
556
+ declare class NetworkMonitorClass {
557
+ private config;
558
+ private listeners;
559
+ private currentState;
560
+ private appStateSubscription;
561
+ private initialized;
562
+ private checkIntervalId;
563
+ initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
564
+ private setupFallbackDetection;
565
+ private setupAppStateListener;
566
+ private checkConnectivity;
567
+ private updateState;
568
+ private notifyListeners;
569
+ isOnline(): boolean;
570
+ getState(): NetworkState;
571
+ isInitialized(): boolean;
572
+ addListener(listener: NetworkListener): () => void;
573
+ removeListener(listener: NetworkListener): void;
574
+ forceCheck(): Promise<NetworkState>;
575
+ dispose(): void;
576
+ private log;
577
+ setDebug(debug: boolean): void;
578
+ }
579
+ declare const networkMonitor: NetworkMonitorClass;
580
+
602
581
  /**
603
- * Event payload emitted by the native module whenever StoreKit 2
604
- * (`Transaction.updates`) or Google Play Billing (`onPurchasesUpdated` +
605
- * refund diff) detects a renewal, refund, or cancellation.
582
+ * Guard usado pelo SessionManager.startSession() aguarda distinctId ficar
583
+ * disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
584
+ * era session.startSession rodando em paralelo com identity.initialize() e
585
+ * batendo em distinctId vazio. Agora sessão só inicia depois da identity
586
+ * estar pronta; este guard é uma defesa extra caso alguém chame startSession
587
+ * manualmente antes do init terminar.
606
588
  */
607
- interface NativeTransactionUpdate {
608
- type: "renewed" | "refunded" | "canceled";
609
- transactionId: string;
610
- productId: string;
611
- amount?: number;
612
- currency?: string;
613
- }
614
- type TransactionUpdateListener = (update: NativeTransactionUpdate) => void;
615
- interface TransactionUpdateSubscription {
616
- remove(): void;
589
+ type DistinctIdProvider = () => string;
590
+
591
+ declare class IdentityError extends PaywalloError {
592
+ constructor(code: string, message: string);
617
593
  }
618
- declare function isAvailable(): boolean;
619
- declare const nativeStoreKit: {
620
- isAvailable: typeof isAvailable;
621
- getProducts(productIds: string[]): Promise<Product[]>;
622
- purchase(productId: string): Promise<Purchase | null>;
623
- finishTransaction(transactionId: string): Promise<void>;
624
- getActiveTransactions(): Promise<Purchase[]>;
625
- /**
626
- * Subscribes to native transaction update events (renewals, refunds,
627
- * cancellations) from StoreKit 2 (`Transaction.updates`) on iOS or
628
- * `PurchasesUpdatedListener` + refund diff on Android.
629
- *
630
- * Returns a subscription with a `remove()` method. The caller is
631
- * responsible for cleanup (typically on `Paywallo.reset()`).
632
- *
633
- * Returns `null` when the native module isn't available (non-mobile env,
634
- * native module not linked) — callers should treat null as a no-op.
635
- */
636
- subscribeToTransactionUpdates(listener: TransactionUpdateListener): TransactionUpdateSubscription | null;
594
+ declare const IDENTITY_ERROR_CODES: {
595
+ readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
596
+ readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
597
+ readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
598
+ readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
599
+ readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
637
600
  };
638
601
 
639
- interface ValidateOptions {
640
- paywallPlacement?: string;
641
- variantKey?: string;
642
- paywallId?: string;
643
- variantId?: string;
602
+ interface IdentityState {
603
+ deviceId: string;
604
+ email: string | null;
605
+ properties: UserProperties;
606
+ phone: string | null;
607
+ firstName: string | null;
608
+ lastName: string | null;
609
+ dateOfBirth: string | null;
610
+ gender: string | null;
644
611
  }
645
-
646
- declare class IAPService {
647
- private productsCache;
648
- private apiClient;
649
- private purchaseInFlight;
650
- /**
651
- * Idempotency guard against double-finish. Populated with transaction IDs
652
- * that have already been forwarded to `NativeStoreKit.finishTransaction`.
653
- */
654
- private finishedTransactions;
655
- private validator;
656
- private emitter;
657
- constructor(apiClient?: ApiClient);
658
- private get debug();
659
- private getDeviceCountry;
660
- private getApiClient;
661
- isAvailable(): boolean;
662
- loadProducts(productIds: string[]): Promise<Product[]>;
663
- getProduct(productId: string): Product | undefined;
664
- getCachedProducts(): Map<string, Product>;
665
- private finishTransaction;
666
- startTransactionListener(): void;
667
- stopTransactionListener(): void;
668
- emitTransactionUpdate(update: NativeTransactionUpdate): Promise<void>;
669
- purchase(productId: string, options?: ValidateOptions): Promise<PurchaseResult>;
670
- restore(): Promise<Purchase[]>;
671
- reset(): void;
672
- }
673
- declare function getIAPService(): IAPService;
674
-
675
- type PurchaseState = "idle" | "purchasing" | "restoring" | "error";
676
- interface IAPProduct {
677
- productId: string;
678
- price: string;
679
- currency: string;
680
- localizedPrice: string;
681
- title: string;
682
- description: string;
683
- type: "inapp" | "subs";
684
- subscriptionPeriodAndroid?: string;
685
- subscriptionPeriodNumberIOS?: string;
686
- subscriptionPeriodUnitIOS?: string;
687
- introductoryPrice?: string;
688
- introductoryPricePaymentModeIOS?: string;
689
- introductoryPriceNumberOfPeriodsIOS?: string;
690
- introductoryPriceSubscriptionPeriodIOS?: string;
691
- freeTrialPeriodAndroid?: string;
692
- trialDays: number;
693
- }
694
- interface IAPPurchase {
695
- productId: string;
696
- transactionId?: string;
697
- transactionDate: number;
698
- transactionReceipt: string;
699
- purchaseToken?: string;
700
- }
701
- interface PurchaseControllerConfig {
702
- debug?: boolean;
703
- validateOnServer?: boolean;
704
- serverValidationUrl?: string;
705
- }
706
- interface ProductPriceInfo {
707
- price: string;
708
- priceValue: number;
709
- currency: string;
710
- localizedPrice: string;
711
- pricePerMonth?: string;
712
- pricePerWeek?: string;
713
- pricePerDay?: string;
714
- }
715
-
716
- interface IdentityState {
717
- deviceId: string;
718
- email: string | null;
719
- properties: UserProperties;
720
- }
721
- declare class IdentityManager {
722
- private deviceId;
723
- private anonId;
724
- private email;
725
- private properties;
612
+ declare class IdentityManager {
613
+ private deviceId;
614
+ private anonId;
615
+ private email;
616
+ private properties;
617
+ private phone;
618
+ private firstName;
619
+ private lastName;
620
+ private dateOfBirth;
621
+ private gender;
726
622
  private apiClient;
727
623
  private secureStorage;
728
624
  private debug;
@@ -745,28 +641,12 @@ declare class IdentityManager {
745
641
  }
746
642
  declare const identityManager: IdentityManager;
747
643
 
748
- /**
749
- * Guard usado pelo SessionManager.startSession() — aguarda distinctId ficar
750
- * disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
751
- * era session.startSession rodando em paralelo com identity.initialize() e
752
- * batendo em distinctId vazio. Agora sessão só inicia depois da identity
753
- * estar pronta; este guard é uma defesa extra caso alguém chame startSession
754
- * manualmente antes do init terminar.
755
- */
756
- type DistinctIdProvider = () => string;
757
-
758
- declare class IdentityError extends PaywalloError {
759
- constructor(code: string, message: string);
760
- }
761
- declare const IDENTITY_ERROR_CODES: {
762
- readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
763
- readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
764
- readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
765
- readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
766
- readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
767
- };
768
-
769
644
  declare class MetaBridge {
645
+ private cachedAnonId;
646
+ private debug;
647
+ setDebug(debug: boolean): void;
648
+ /** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
649
+ getCachedAnonymousID(): string | null;
770
650
  getAnonymousID(): Promise<string | null>;
771
651
  logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
772
652
  logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
@@ -775,38 +655,64 @@ declare class MetaBridge {
775
655
  }
776
656
  declare const metaBridge: MetaBridge;
777
657
 
778
- type NetworkState = "online" | "offline" | "unknown";
779
- type NetworkListener = (state: NetworkState) => void;
780
- interface NetworkMonitorConfig {
781
- debug: boolean;
782
- checkInterval: number;
783
- checkUrl: string;
658
+ interface FcmRemoteMessage {
659
+ messageId?: string;
660
+ data?: Record<string, string>;
661
+ notification?: {
662
+ title?: string;
663
+ body?: string;
664
+ };
665
+ sentTime?: number;
666
+ }
667
+ /**
668
+ * Minimal interface satisfied by NativePushBridge (and any custom bridge).
669
+ * Use this type instead of concrete classes to keep code bridge-agnostic.
670
+ */
671
+ interface IPushBridge {
672
+ getToken(): Promise<string | null>;
673
+ getAPNSToken(): Promise<string | null>;
674
+ requestPermission(options?: {
675
+ provisional?: boolean;
676
+ }): Promise<number>;
677
+ hasPermission(): Promise<number>;
678
+ onTokenRefresh(cb: (token: string) => void): () => void;
679
+ onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
680
+ setBackgroundMessageHandler(cb: (message: FcmRemoteMessage) => Promise<void>): void;
681
+ getInitialNotification(): Promise<FcmRemoteMessage | null>;
784
682
  }
785
683
 
786
- declare class NetworkMonitorClass {
787
- private config;
788
- private listeners;
789
- private currentState;
790
- private appStateSubscription;
791
- private initialized;
792
- private checkIntervalId;
793
- initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
794
- private setupFallbackDetection;
795
- private setupAppStateListener;
796
- private checkConnectivity;
797
- private updateState;
798
- private notifyListeners;
799
- isOnline(): boolean;
800
- getState(): NetworkState;
801
- isInitialized(): boolean;
802
- addListener(listener: NetworkListener): () => void;
803
- removeListener(listener: NetworkListener): void;
804
- forceCheck(): Promise<NetworkState>;
805
- dispose(): void;
806
- private log;
807
- setDebug(debug: boolean): void;
684
+ declare class NativePushBridge implements IPushBridge {
685
+ getToken(): Promise<string | null>;
686
+ getAPNSToken(): Promise<string | null>;
687
+ requestPermission(options?: {
688
+ provisional?: boolean;
689
+ }): Promise<number>;
690
+ hasPermission(): Promise<number>;
691
+ onTokenRefresh(cb: (token: string) => void): () => void;
692
+ onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
693
+ setBackgroundMessageHandler(_cb: (message: FcmRemoteMessage) => Promise<void>): void;
694
+ getInitialNotification(): Promise<FcmRemoteMessage | null>;
695
+ }
696
+
697
+ type NotificationsEnvironment = "sandbox" | "production";
698
+ interface NotificationsConfig {
699
+ debug?: boolean;
700
+ environment?: NotificationsEnvironment;
701
+ apiBaseUrl?: string;
702
+ }
703
+
704
+ declare const NOTIFICATIONS_ERROR_CODES: {
705
+ readonly TOKEN_UNAVAILABLE: "TOKEN_UNAVAILABLE";
706
+ readonly PERMISSION_DENIED: "PERMISSION_DENIED";
707
+ readonly REGISTRATION_FAILED: "REGISTRATION_FAILED";
708
+ readonly NOT_INITIALIZED: "NOT_INITIALIZED";
709
+ readonly ABORTED: "ABORTED";
710
+ };
711
+ type NotificationsErrorCode = (typeof NOTIFICATIONS_ERROR_CODES)[keyof typeof NOTIFICATIONS_ERROR_CODES];
712
+ declare class NotificationsError extends PaywalloError {
713
+ readonly details?: unknown;
714
+ constructor(code: NotificationsErrorCode, message: string, details?: unknown);
808
715
  }
809
- declare const networkMonitor: NetworkMonitorClass;
810
716
 
811
717
  declare class SecureStorage {
812
718
  constructor(_debug?: boolean);
@@ -861,32 +767,6 @@ type NotificationListener = (event: {
861
767
  messageId: string;
862
768
  }) => void;
863
769
 
864
- interface FcmRemoteMessage {
865
- messageId?: string;
866
- data?: Record<string, string>;
867
- notification?: {
868
- title?: string;
869
- body?: string;
870
- };
871
- sentTime?: number;
872
- }
873
- /**
874
- * Minimal interface satisfied by NativePushBridge (and any custom bridge).
875
- * Use this type instead of concrete classes to keep code bridge-agnostic.
876
- */
877
- interface IPushBridge {
878
- getToken(): Promise<string | null>;
879
- getAPNSToken(): Promise<string | null>;
880
- requestPermission(options?: {
881
- provisional?: boolean;
882
- }): Promise<number>;
883
- hasPermission(): Promise<number>;
884
- onTokenRefresh(cb: (token: string) => void): () => void;
885
- onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
886
- setBackgroundMessageHandler(cb: (message: FcmRemoteMessage) => Promise<void>): void;
887
- getInitialNotification(): Promise<FcmRemoteMessage | null>;
888
- }
889
-
890
770
  /**
891
771
  * Minimal surface the facade needs from the SDK's unified event pipeline.
892
772
  * `PaywalloClient` implements it (forwarding to `ApiClient.trackEvent`
@@ -919,13 +799,6 @@ interface RNPlatform {
919
799
  Version?: number | string;
920
800
  }
921
801
 
922
- type NotificationsEnvironment = "sandbox" | "production";
923
- interface NotificationsConfig {
924
- debug?: boolean;
925
- environment?: NotificationsEnvironment;
926
- apiBaseUrl?: string;
927
- }
928
-
929
802
  interface HandlersConfig {
930
803
  eventBatcher: EventBatcherLike;
931
804
  }
@@ -1008,43 +881,90 @@ declare class NotificationsManager {
1008
881
 
1009
882
  declare const notificationsManager: NotificationsManager;
1010
883
 
1011
- declare class NativePushBridge implements IPushBridge {
1012
- getToken(): Promise<string | null>;
1013
- getAPNSToken(): Promise<string | null>;
1014
- requestPermission(options?: {
1015
- provisional?: boolean;
1016
- }): Promise<number>;
1017
- hasPermission(): Promise<number>;
1018
- onTokenRefresh(cb: (token: string) => void): () => void;
1019
- onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
1020
- setBackgroundMessageHandler(_cb: (message: FcmRemoteMessage) => Promise<void>): void;
1021
- getInitialNotification(): Promise<FcmRemoteMessage | null>;
884
+ interface PlanProduct {
885
+ id: string;
886
+ name: string;
887
+ description: string | null;
888
+ type: string;
889
+ appleProductId: string | null;
890
+ googleProductId: string | null;
891
+ billingPeriod: string | null;
892
+ trialDays: number | null;
893
+ priceUsd: number | null;
894
+ regionalPrices: unknown;
895
+ displayOrder: number;
896
+ isActive: boolean;
1022
897
  }
1023
-
1024
- declare const NOTIFICATIONS_ERROR_CODES: {
1025
- readonly TOKEN_UNAVAILABLE: "TOKEN_UNAVAILABLE";
1026
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
1027
- readonly REGISTRATION_FAILED: "REGISTRATION_FAILED";
1028
- readonly NOT_INITIALIZED: "NOT_INITIALIZED";
1029
- readonly ABORTED: "ABORTED";
1030
- };
1031
- type NotificationsErrorCode = (typeof NOTIFICATIONS_ERROR_CODES)[keyof typeof NOTIFICATIONS_ERROR_CODES];
1032
- declare class NotificationsError extends PaywalloError {
1033
- readonly details?: unknown;
1034
- constructor(code: NotificationsErrorCode, message: string, details?: unknown);
898
+ interface Plan {
899
+ id: string;
900
+ identifier: string;
901
+ name: string;
902
+ description: string | null;
903
+ metadata: unknown;
904
+ products: PlanProduct[];
1035
905
  }
1036
-
1037
- interface SessionState {
1038
- sessionId: string | null;
1039
- startedAt: Date | null;
1040
- isActive: boolean;
1041
- duration: number;
906
+ interface PlansResponse {
907
+ plan: Plan | null;
1042
908
  }
1043
- interface SessionConfig {
1044
- sessionTimeoutMs?: number;
1045
- trackAppState?: boolean;
909
+ interface AllPlansResponse {
910
+ plans: Plan[];
911
+ currentIdentifier: string | null;
1046
912
  }
1047
- type EmergencyPaywallHandler = (paywallId: string) => Promise<void>;
913
+ interface PlanServiceConfig {
914
+ apiClient: ApiClient;
915
+ debug: boolean;
916
+ }
917
+ interface CachedPlans {
918
+ data: AllPlansResponse;
919
+ cachedAt: number;
920
+ isStale: boolean;
921
+ }
922
+
923
+ declare class PlanCache {
924
+ private cache;
925
+ private ttl;
926
+ get(): CachedPlans | null;
927
+ set(data: AllPlansResponse): void;
928
+ invalidate(): void;
929
+ setTTL(ttl: number): void;
930
+ }
931
+ declare const planCache: PlanCache;
932
+
933
+ declare class PlanService {
934
+ private config;
935
+ private cache;
936
+ init(config: PlanServiceConfig): void;
937
+ getCurrentPlan(forceRefresh?: boolean): Promise<Plan | null>;
938
+ getAllPlans(forceRefresh?: boolean): Promise<AllPlansResponse>;
939
+ invalidateCache(): void;
940
+ private getApiClient;
941
+ private fetchCurrentPlan;
942
+ private fetchAllPlans;
943
+ private log;
944
+ }
945
+ declare const planService: PlanService;
946
+
947
+ declare class SessionError extends PaywalloError {
948
+ constructor(code: string, message: string);
949
+ }
950
+ declare const SESSION_ERROR_CODES: {
951
+ readonly NOT_INITIALIZED: "SESSION_NOT_INITIALIZED";
952
+ readonly START_FAILED: "SESSION_START_FAILED";
953
+ readonly END_FAILED: "SESSION_END_FAILED";
954
+ readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
955
+ };
956
+
957
+ interface SessionState {
958
+ sessionId: string | null;
959
+ startedAt: Date | null;
960
+ isActive: boolean;
961
+ duration: number;
962
+ }
963
+ interface SessionConfig {
964
+ sessionTimeoutMs?: number;
965
+ trackAppState?: boolean;
966
+ }
967
+ type EmergencyPaywallHandler = (paywallId: string) => Promise<void>;
1048
968
 
1049
969
  declare class SessionManager {
1050
970
  private sessionId;
@@ -1086,16 +1006,6 @@ declare class SessionManager {
1086
1006
  }
1087
1007
  declare const sessionManager: SessionManager;
1088
1008
 
1089
- declare class SessionError extends PaywalloError {
1090
- constructor(code: string, message: string);
1091
- }
1092
- declare const SESSION_ERROR_CODES: {
1093
- readonly NOT_INITIALIZED: "SESSION_NOT_INITIALIZED";
1094
- readonly START_FAILED: "SESSION_START_FAILED";
1095
- readonly END_FAILED: "SESSION_END_FAILED";
1096
- readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
1097
- };
1098
-
1099
1009
  interface PreloadCampaignResult {
1100
1010
  success: boolean;
1101
1011
  error?: Error;
@@ -1117,6 +1027,8 @@ interface PaywalloInitConfig extends PaywalloConfig {
1117
1027
  autoPreloadCampaign?: string;
1118
1028
  /** Called when the SDK silently swallows an API error. Useful for logging/monitoring in production. */
1119
1029
  onError?: (error: unknown) => void;
1030
+ /** Set to false to disable Paywallo push notifications even if the native module is available. Default: auto-detect (enabled if PaywalloNotifications native module is linked). */
1031
+ notifications?: boolean;
1120
1032
  }
1121
1033
  interface IPaywalloClient {
1122
1034
  init(config: PaywalloInitConfig): Promise<void>;
@@ -1134,7 +1046,7 @@ interface IPaywalloClient {
1134
1046
  presentCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResult>;
1135
1047
  hasActiveSubscription(): Promise<boolean>;
1136
1048
  getSubscription(): Promise<Subscription | null>;
1137
- restorePurchases(): Promise<RestoreResult>;
1049
+ restorePurchases(): Promise<RestoreResult$1>;
1138
1050
  requireSubscription(paywallPlacement?: string): Promise<boolean>;
1139
1051
  requireSubscriptionWithCampaign(placement: string, context?: Record<string, unknown>): Promise<boolean>;
1140
1052
  gateContent<T>(content: () => T | Promise<T>, paywallPlacement?: string): Promise<T | null>;
@@ -1163,7 +1075,7 @@ interface IPaywalloClient {
1163
1075
  registerCampaignPresenter(presenter: ((campaign: CampaignResponse) => Promise<CampaignResult>) | null): void;
1164
1076
  registerSubscriptionGetter(getter: (() => Promise<Subscription | null>) | null): void;
1165
1077
  registerActiveChecker(checker: (() => Promise<boolean>) | null): void;
1166
- registerRestoreHandler(handler: (() => Promise<RestoreResult>) | null): void;
1078
+ registerRestoreHandler(handler: (() => Promise<RestoreResult$1>) | null): void;
1167
1079
  registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
1168
1080
  getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
1169
1081
  getSessionFlag(key: string): string | null;
@@ -1179,6 +1091,8 @@ interface IPaywalloClient {
1179
1091
  isPreloaded(placement: string): boolean;
1180
1092
  getAutoPreloadedPlacement(): string | null;
1181
1093
  waitForAutoPreloadedPlacement(): Promise<string | null>;
1094
+ getPlans(): Promise<AllPlansResponse>;
1095
+ getCurrentPlan(): Promise<Plan | null>;
1182
1096
  }
1183
1097
 
1184
1098
  declare const PaywalloClient: IPaywalloClient;
@@ -1355,6 +1269,174 @@ declare class QueueProcessorClass {
1355
1269
  }
1356
1270
  declare const queueProcessor: QueueProcessorClass;
1357
1271
 
1272
+ interface ValidateOptions {
1273
+ paywallPlacement?: string;
1274
+ variantKey?: string;
1275
+ paywallId?: string;
1276
+ variantId?: string;
1277
+ }
1278
+
1279
+ /**
1280
+ * Event payload emitted by the native module whenever StoreKit 2
1281
+ * (`Transaction.updates`) or Google Play Billing (`onPurchasesUpdated` +
1282
+ * refund diff) detects a renewal, refund, or cancellation.
1283
+ */
1284
+ interface NativeTransactionUpdate {
1285
+ type: "renewed" | "refunded" | "canceled";
1286
+ transactionId: string;
1287
+ productId: string;
1288
+ amount?: number;
1289
+ currency?: string;
1290
+ }
1291
+ type TransactionUpdateListener = (update: NativeTransactionUpdate) => void;
1292
+ interface TransactionUpdateSubscription {
1293
+ remove(): void;
1294
+ }
1295
+ declare function isAvailable(): boolean;
1296
+ declare const nativeStoreKit: {
1297
+ isAvailable: typeof isAvailable;
1298
+ getProducts(productIds: string[]): Promise<Product[]>;
1299
+ purchase(productId: string): Promise<Purchase | null>;
1300
+ finishTransaction(transactionId: string): Promise<void>;
1301
+ getActiveTransactions(): Promise<Purchase[]>;
1302
+ /**
1303
+ * Subscribes to native transaction update events (renewals, refunds,
1304
+ * cancellations) from StoreKit 2 (`Transaction.updates`) on iOS or
1305
+ * `PurchasesUpdatedListener` + refund diff on Android.
1306
+ *
1307
+ * Returns a subscription with a `remove()` method. The caller is
1308
+ * responsible for cleanup (typically on `Paywallo.reset()`).
1309
+ *
1310
+ * Returns `null` when the native module isn't available (non-mobile env,
1311
+ * native module not linked) — callers should treat null as a no-op.
1312
+ */
1313
+ subscribeToTransactionUpdates(listener: TransactionUpdateListener): TransactionUpdateSubscription | null;
1314
+ };
1315
+
1316
+ declare class IAPService {
1317
+ private productsCache;
1318
+ private apiClient;
1319
+ private purchaseInFlight;
1320
+ /**
1321
+ * Idempotency guard against double-finish. Populated with transaction IDs
1322
+ * that have already been forwarded to `NativeStoreKit.finishTransaction`.
1323
+ */
1324
+ private finishedTransactions;
1325
+ private validator;
1326
+ private emitter;
1327
+ constructor(apiClient?: ApiClient);
1328
+ private get debug();
1329
+ private getDeviceCountry;
1330
+ private getApiClient;
1331
+ isAvailable(): boolean;
1332
+ loadProducts(productIds: string[]): Promise<Product[]>;
1333
+ getProduct(productId: string): Product | undefined;
1334
+ getCachedProducts(): Map<string, Product>;
1335
+ private finishTransaction;
1336
+ startTransactionListener(): void;
1337
+ stopTransactionListener(): void;
1338
+ emitTransactionUpdate(update: NativeTransactionUpdate): Promise<void>;
1339
+ purchase(productId: string, options?: ValidateOptions): Promise<PurchaseResult>;
1340
+ restore(): Promise<Purchase[]>;
1341
+ reset(): void;
1342
+ }
1343
+ declare function getIAPService(): IAPService;
1344
+
1345
+ type PurchaseState = "idle" | "purchasing" | "restoring" | "error";
1346
+ interface IAPProduct {
1347
+ productId: string;
1348
+ price: string;
1349
+ currency: string;
1350
+ localizedPrice: string;
1351
+ title: string;
1352
+ description: string;
1353
+ type: "inapp" | "subs";
1354
+ subscriptionPeriodAndroid?: string;
1355
+ subscriptionPeriodNumberIOS?: string;
1356
+ subscriptionPeriodUnitIOS?: string;
1357
+ introductoryPrice?: string;
1358
+ introductoryPricePaymentModeIOS?: string;
1359
+ introductoryPriceNumberOfPeriodsIOS?: string;
1360
+ introductoryPriceSubscriptionPeriodIOS?: string;
1361
+ freeTrialPeriodAndroid?: string;
1362
+ trialDays: number;
1363
+ }
1364
+ interface IAPPurchase {
1365
+ productId: string;
1366
+ transactionId?: string;
1367
+ transactionDate: number;
1368
+ transactionReceipt: string;
1369
+ purchaseToken?: string;
1370
+ }
1371
+ interface PurchaseControllerConfig {
1372
+ debug?: boolean;
1373
+ validateOnServer?: boolean;
1374
+ serverValidationUrl?: string;
1375
+ }
1376
+ interface ProductPriceInfo {
1377
+ price: string;
1378
+ priceValue: number;
1379
+ currency: string;
1380
+ localizedPrice: string;
1381
+ pricePerMonth?: string;
1382
+ pricePerWeek?: string;
1383
+ pricePerDay?: string;
1384
+ }
1385
+
1386
+ interface OfferingProduct {
1387
+ id: string;
1388
+ name: string;
1389
+ description: string | null;
1390
+ type: string;
1391
+ productId: string;
1392
+ billingPeriod: string | null;
1393
+ trialDays: number | null;
1394
+ priceUsd: number | null;
1395
+ regionalPrices: unknown;
1396
+ isActive: boolean;
1397
+ }
1398
+ interface Offering {
1399
+ id: string;
1400
+ identifier: string;
1401
+ name: string;
1402
+ description: string | null;
1403
+ metadata: unknown;
1404
+ product: OfferingProduct;
1405
+ }
1406
+ interface OfferingServiceConfig {
1407
+ apiClient: ApiClient;
1408
+ debug: boolean;
1409
+ }
1410
+ interface CachedOfferings {
1411
+ data: Offering[];
1412
+ cachedAt: number;
1413
+ isStale: boolean;
1414
+ }
1415
+
1416
+ declare class OfferingService {
1417
+ private config;
1418
+ private cache;
1419
+ private ttl;
1420
+ init(config: OfferingServiceConfig): void;
1421
+ getOfferings(ids?: string[]): Promise<Offering[]>;
1422
+ invalidateCache(): void;
1423
+ private getMemCache;
1424
+ private setMemCache;
1425
+ private filterByIds;
1426
+ private getApiClient;
1427
+ private fetchOfferings;
1428
+ private log;
1429
+ }
1430
+ declare const offeringService: OfferingService;
1431
+
1432
+ declare class OnboardingError extends PaywalloError {
1433
+ constructor(code: string, message: string);
1434
+ }
1435
+ declare const ONBOARDING_ERROR_CODES: {
1436
+ readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1437
+ readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1438
+ };
1439
+
1358
1440
  /**
1359
1441
  * Minimal surface the OnboardingManager needs from the unified event pipeline.
1360
1442
  * `PaywalloClient` satisfies this interface (forwarding to
@@ -1406,14 +1488,6 @@ declare class OnboardingManager {
1406
1488
  }
1407
1489
  declare const onboardingManager: OnboardingManager;
1408
1490
 
1409
- declare class OnboardingError extends PaywalloError {
1410
- constructor(code: string, message: string);
1411
- }
1412
- declare const ONBOARDING_ERROR_CODES: {
1413
- readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1414
- readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1415
- };
1416
-
1417
1491
  /** Payload sent with onboarding.step events. */
1418
1492
  interface OnboardingStepPayload {
1419
1493
  step_name: string;
@@ -1423,66 +1497,71 @@ interface OnboardingDropPayload {
1423
1497
  step_name: string;
1424
1498
  }
1425
1499
 
1426
- interface UseOnboardingResult {
1427
- step: (stepName: string) => Promise<void>;
1428
- complete: () => Promise<void>;
1429
- drop: (stepName: string) => Promise<void>;
1500
+ interface PaywallContextValue {
1501
+ nodes: Record<string, PaywallNode>;
1502
+ rootId: string;
1503
+ language: string;
1504
+ defaultLanguage: string;
1505
+ products: Map<string, Product>;
1506
+ selectedProductId: string | null;
1507
+ primaryProductId: string | null;
1508
+ secondaryProductId: string | null;
1509
+ currentNavigationIndex: number;
1510
+ currentTabIndex: number;
1511
+ trialEnabled: boolean;
1512
+ selectedPeriod: string | null;
1513
+ isPurchasing: boolean;
1514
+ exitOfferVisible: boolean;
1515
+ exitOfferTriggeredByBackButton: boolean;
1516
+ onClose: () => void;
1517
+ onTryClose: () => void;
1518
+ onSelectProduct: (productId: string) => void;
1519
+ onPurchase: (productId: string) => void;
1520
+ onRestore: () => void;
1521
+ onNavigate: (target: "next" | "previous" | "first" | "last" | number) => void;
1522
+ onSetTab: (index: number) => void;
1523
+ onSetVariable: (name: string, value: string) => void;
1524
+ onToggleTrial: (enabled: boolean) => void;
1525
+ onSelectPeriod: (value: string) => void;
1526
+ onOpenUrl: (url: string, inBrowser?: boolean) => void;
1527
+ onTapBehavior: (behavior: TapBehavior) => void;
1528
+ onShowExitOffer: () => void;
1529
+ onDismissExitOffer: () => void;
1530
+ onTriggerBackButton: () => void;
1430
1531
  }
1431
- /**
1432
- * React hook that exposes bound onboarding tracking methods.
1433
- * Wraps `onboardingManager` with stable `useCallback` references.
1434
- */
1435
- declare function useOnboarding(): UseOnboardingResult;
1532
+ declare const PaywallContext: React.Context<PaywallContextValue | null>;
1533
+ declare function usePaywallContext(): PaywallContextValue;
1436
1534
 
1437
- declare class CampaignError extends PaywalloError {
1535
+ declare class PaywallError extends PaywalloError {
1438
1536
  constructor(code: string, message: string);
1439
1537
  }
1440
- declare const CAMPAIGN_ERROR_CODES: {
1441
- readonly NOT_INITIALIZED: "CAMPAIGN_NOT_INITIALIZED";
1442
- readonly FETCH_FAILED: "CAMPAIGN_FETCH_FAILED";
1443
- readonly PRELOAD_FAILED: "CAMPAIGN_PRELOAD_FAILED";
1444
- readonly NOT_FOUND: "CAMPAIGN_NOT_FOUND";
1445
- readonly PRESENT_FAILED: "CAMPAIGN_PRESENT_FAILED";
1538
+ declare const PAYWALL_ERROR_CODES: {
1539
+ readonly NOT_INITIALIZED: "PAYWALL_NOT_INITIALIZED";
1540
+ readonly NOT_FOUND: "PAYWALL_NOT_FOUND";
1541
+ readonly RENDER_FAILED: "PAYWALL_RENDER_FAILED";
1542
+ readonly LOAD_FAILED: "PAYWALL_LOAD_FAILED";
1543
+ readonly DISMISS_FAILED: "PAYWALL_DISMISS_FAILED";
1544
+ readonly INVALID_CONFIG: "PAYWALL_INVALID_CONFIG";
1446
1545
  };
1447
1546
 
1448
- declare function usePaywallo(): PaywalloContextValue;
1449
-
1450
- interface FormattedProduct extends ProductPriceInfo {
1451
- productId: string;
1452
- title: string;
1453
- description: string;
1454
- subscriptionPeriod?: string;
1455
- introductoryPrice?: string;
1456
- freeTrialPeriod?: string;
1457
- trialDays: number;
1458
- }
1459
-
1460
- interface UseProductsResult {
1461
- products: IAPProduct[];
1462
- formattedProducts: FormattedProduct[];
1463
- isLoading: boolean;
1464
- error: Error | null;
1465
- loadProducts: (productIds: string[]) => Promise<void>;
1466
- getProduct: (productId: string) => IAPProduct | undefined;
1467
- getFormattedProduct: (productId: string) => FormattedProduct | undefined;
1468
- getPriceInfo: (productId: string) => ProductPriceInfo | undefined;
1469
- }
1470
- declare function useProducts(initialProductIds?: string[]): UseProductsResult;
1471
-
1472
- interface PurchaseOutcome {
1473
- status: "success" | "cancelled" | "failed";
1474
- purchase?: IAPPurchase;
1475
- error?: PurchaseError;
1476
- }
1477
- interface UsePurchaseResult {
1478
- state: PurchaseState;
1479
- purchase: (productId: string) => Promise<PurchaseOutcome>;
1480
- restore: () => Promise<IAPPurchase[]>;
1481
- error: PurchaseError | null;
1482
- isPurchasing: boolean;
1483
- isRestoring: boolean;
1547
+ interface PaywallModalProps {
1548
+ placement: string;
1549
+ visible: boolean;
1550
+ onResult: (result: PaywallResult) => void;
1551
+ paywallConfig?: {
1552
+ id: string;
1553
+ placement: string;
1554
+ config: Record<string, unknown>;
1555
+ primaryProductId?: string;
1556
+ secondaryProductId?: string;
1557
+ };
1558
+ preloadedProducts?: Map<string, Product>;
1559
+ variantKey?: string;
1560
+ campaignId?: string;
1561
+ /** UUID de `paywall_variants` (sub-fase 2.14). */
1562
+ variantId?: string;
1484
1563
  }
1485
- declare function usePurchase(): UsePurchaseResult;
1564
+ declare function PaywallModal({ placement, visible, onResult, paywallConfig: preloadedConfig, preloadedProducts, variantKey, campaignId, variantId, }: PaywallModalProps): React__default.ReactElement | null;
1486
1565
 
1487
1566
  type SubscriptionStatus = "active" | "expired" | "grace_period" | "billing_retry" | "canceled" | "paused" | "unknown";
1488
1567
  interface SubscriptionInfo {
@@ -1517,23 +1596,6 @@ interface SubscriptionManagerConfig {
1517
1596
  debug?: boolean;
1518
1597
  }
1519
1598
 
1520
- interface UseSubscriptionResult {
1521
- subscription: SubscriptionInfo | null;
1522
- isActive: boolean;
1523
- isLoading: boolean;
1524
- error: Error | null;
1525
- entitlements: string[];
1526
- refresh: () => Promise<void>;
1527
- restore: () => Promise<void>;
1528
- }
1529
- declare function useSubscription(): UseSubscriptionResult;
1530
-
1531
- interface PaywalloProviderProps {
1532
- children: React__default.ReactNode;
1533
- config: PaywalloConfig;
1534
- }
1535
- declare function PaywalloProvider({ children, config }: PaywalloProviderProps): React__default.ReactElement;
1536
-
1537
1599
  declare class SubscriptionCache {
1538
1600
  private ttl;
1539
1601
  private memoryCache;
@@ -1575,6 +1637,118 @@ declare class SubscriptionManagerClass {
1575
1637
  }
1576
1638
  declare const subscriptionManager: SubscriptionManagerClass;
1577
1639
 
1640
+ declare class CampaignError extends PaywalloError {
1641
+ constructor(code: string, message: string);
1642
+ }
1643
+ declare const CAMPAIGN_ERROR_CODES: {
1644
+ readonly NOT_INITIALIZED: "CAMPAIGN_NOT_INITIALIZED";
1645
+ readonly FETCH_FAILED: "CAMPAIGN_FETCH_FAILED";
1646
+ readonly PRELOAD_FAILED: "CAMPAIGN_PRELOAD_FAILED";
1647
+ readonly NOT_FOUND: "CAMPAIGN_NOT_FOUND";
1648
+ readonly PRESENT_FAILED: "CAMPAIGN_PRESENT_FAILED";
1649
+ };
1650
+
1651
+ interface UseOfferingPurchaseResult {
1652
+ purchase: (productId: string) => Promise<void>;
1653
+ isPurchasing: boolean;
1654
+ }
1655
+ declare function useOfferingPurchase(): UseOfferingPurchaseResult;
1656
+
1657
+ interface UseOfferingsResult {
1658
+ offerings: Offering[];
1659
+ isLoading: boolean;
1660
+ }
1661
+ declare function useOfferings(ids?: string[]): UseOfferingsResult;
1662
+
1663
+ interface UseOnboardingResult {
1664
+ step: (stepName: string) => Promise<void>;
1665
+ complete: () => Promise<void>;
1666
+ drop: (stepName: string) => Promise<void>;
1667
+ }
1668
+ /**
1669
+ * React hook that exposes bound onboarding tracking methods.
1670
+ * Wraps `onboardingManager` with stable `useCallback` references.
1671
+ */
1672
+ declare function useOnboarding(): UseOnboardingResult;
1673
+
1674
+ declare function usePaywallo(): PaywalloContextValue;
1675
+
1676
+ interface RestoreResult {
1677
+ restoredCount: number;
1678
+ productIds: string[];
1679
+ }
1680
+ interface UsePlanPurchaseResult {
1681
+ purchase: (productId: string) => Promise<PurchaseResult | null>;
1682
+ restore: () => Promise<RestoreResult | null>;
1683
+ isPurchasing: boolean;
1684
+ isRestoring: boolean;
1685
+ error: Error | null;
1686
+ }
1687
+ declare function usePlanPurchase(): UsePlanPurchaseResult;
1688
+
1689
+ interface UsePlansResult {
1690
+ currentPlan: Plan | null;
1691
+ allPlans: Plan[];
1692
+ isLoading: boolean;
1693
+ error: Error | null;
1694
+ refresh: () => Promise<void>;
1695
+ }
1696
+ declare function usePlans(): UsePlansResult;
1697
+
1698
+ interface FormattedProduct extends ProductPriceInfo {
1699
+ productId: string;
1700
+ title: string;
1701
+ description: string;
1702
+ subscriptionPeriod?: string;
1703
+ introductoryPrice?: string;
1704
+ freeTrialPeriod?: string;
1705
+ trialDays: number;
1706
+ }
1707
+
1708
+ interface UseProductsResult {
1709
+ products: IAPProduct[];
1710
+ formattedProducts: FormattedProduct[];
1711
+ isLoading: boolean;
1712
+ error: Error | null;
1713
+ loadProducts: (productIds: string[]) => Promise<void>;
1714
+ getProduct: (productId: string) => IAPProduct | undefined;
1715
+ getFormattedProduct: (productId: string) => FormattedProduct | undefined;
1716
+ getPriceInfo: (productId: string) => ProductPriceInfo | undefined;
1717
+ }
1718
+ declare function useProducts(initialProductIds?: string[]): UseProductsResult;
1719
+
1720
+ interface PurchaseOutcome {
1721
+ status: "success" | "cancelled" | "failed";
1722
+ purchase?: IAPPurchase;
1723
+ error?: PurchaseError;
1724
+ }
1725
+ interface UsePurchaseResult {
1726
+ state: PurchaseState;
1727
+ purchase: (productId: string) => Promise<PurchaseOutcome>;
1728
+ restore: () => Promise<IAPPurchase[]>;
1729
+ error: PurchaseError | null;
1730
+ isPurchasing: boolean;
1731
+ isRestoring: boolean;
1732
+ }
1733
+ declare function usePurchase(): UsePurchaseResult;
1734
+
1735
+ interface UseSubscriptionResult {
1736
+ subscription: SubscriptionInfo | null;
1737
+ isActive: boolean;
1738
+ isLoading: boolean;
1739
+ error: Error | null;
1740
+ entitlements: string[];
1741
+ refresh: () => Promise<void>;
1742
+ restore: () => Promise<void>;
1743
+ }
1744
+ declare function useSubscription(): UseSubscriptionResult;
1745
+
1746
+ interface PaywalloProviderProps {
1747
+ children: React__default.ReactNode;
1748
+ config: PaywalloConfig;
1749
+ }
1750
+ declare function PaywalloProvider({ children, config }: PaywalloProviderProps): React__default.ReactElement;
1751
+
1578
1752
  declare function setCurrentLanguage(language: string): void;
1579
1753
  declare function setDefaultLanguage(language: string): void;
1580
1754
  declare function getCurrentLanguage(): string;
@@ -1611,4 +1785,4 @@ declare function hasVariables(text: string): boolean;
1611
1785
 
1612
1786
  declare const Paywallo: IPaywalloClient;
1613
1787
 
1614
- export { ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, 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 IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, 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 PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, 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, notificationsManager, offlineQueue, onboardingManager, parseVariables, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOnboarding, usePaywallContext, usePaywallo, useProducts, usePurchase, useSubscription };
1788
+ export { type AllPlansResponse, ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, 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 IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, 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 Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as 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, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };