@virex-tech/paywallo-sdk 2.2.1 → 2.2.4

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
@@ -346,60 +346,6 @@ interface ConditionalFlagContext {
346
346
  distinctId?: string;
347
347
  }
348
348
 
349
- interface PaywallModalProps {
350
- placement: string;
351
- visible: boolean;
352
- onResult: (result: PaywallResult) => void;
353
- paywallConfig?: {
354
- id: string;
355
- placement: string;
356
- config: Record<string, unknown>;
357
- primaryProductId?: string;
358
- secondaryProductId?: string;
359
- };
360
- preloadedProducts?: Map<string, Product>;
361
- variantKey?: string;
362
- campaignId?: string;
363
- /** UUID de `paywall_variants` (sub-fase 2.14). */
364
- variantId?: string;
365
- }
366
- declare function PaywallModal({ placement, visible, onResult, paywallConfig: preloadedConfig, preloadedProducts, variantKey, campaignId, variantId, }: PaywallModalProps): React__default.ReactElement | null;
367
-
368
- interface PaywallContextValue {
369
- nodes: Record<string, PaywallNode>;
370
- rootId: string;
371
- language: string;
372
- defaultLanguage: string;
373
- products: Map<string, Product>;
374
- selectedProductId: string | null;
375
- primaryProductId: string | null;
376
- secondaryProductId: string | null;
377
- currentNavigationIndex: number;
378
- currentTabIndex: number;
379
- trialEnabled: boolean;
380
- selectedPeriod: string | null;
381
- isPurchasing: boolean;
382
- exitOfferVisible: boolean;
383
- exitOfferTriggeredByBackButton: boolean;
384
- onClose: () => void;
385
- onTryClose: () => void;
386
- onSelectProduct: (productId: string) => void;
387
- onPurchase: (productId: string) => void;
388
- onRestore: () => void;
389
- onNavigate: (target: "next" | "previous" | "first" | "last" | number) => void;
390
- onSetTab: (index: number) => void;
391
- onSetVariable: (name: string, value: string) => void;
392
- onToggleTrial: (enabled: boolean) => void;
393
- onSelectPeriod: (value: string) => void;
394
- onOpenUrl: (url: string, inBrowser?: boolean) => void;
395
- onTapBehavior: (behavior: TapBehavior) => void;
396
- onShowExitOffer: () => void;
397
- onDismissExitOffer: () => void;
398
- onTriggerBackButton: () => void;
399
- }
400
- declare const PaywallContext: React.Context<PaywallContextValue | null>;
401
- declare function usePaywallContext(): PaywallContextValue;
402
-
403
349
  interface PreloadResult {
404
350
  success: boolean;
405
351
  error?: Error;
@@ -427,17 +373,51 @@ interface PaywalloContextValue {
427
373
  }
428
374
  declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
429
375
 
430
- declare class PaywallError extends PaywalloError {
431
- 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 `/sdk/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`. On 4xx the event is dropped.
414
+ * On 5xx or network failure, `OfflineQueue` handles durability via the
415
+ * `PostFn` injected by `ApiClient.postWithQueue`.
416
+ */
417
+ type EventPriority = "critical" | "normal";
418
+ interface TrackOptions {
419
+ priority?: EventPriority;
432
420
  }
433
- declare const PAYWALL_ERROR_CODES: {
434
- readonly NOT_INITIALIZED: "PAYWALL_NOT_INITIALIZED";
435
- readonly NOT_FOUND: "PAYWALL_NOT_FOUND";
436
- readonly RENDER_FAILED: "PAYWALL_RENDER_FAILED";
437
- readonly LOAD_FAILED: "PAYWALL_LOAD_FAILED";
438
- readonly DISMISS_FAILED: "PAYWALL_DISMISS_FAILED";
439
- readonly INVALID_CONFIG: "PAYWALL_INVALID_CONFIG";
440
- };
441
421
 
442
422
  interface RetryConfig {
443
423
  maxRetries: number;
@@ -498,54 +478,6 @@ declare class HttpClient {
498
478
  getConfig(): Readonly<HttpClientConfig>;
499
479
  }
500
480
 
501
- /**
502
- * Shared context resolved once per batch and hoisted out of every individual
503
- * event in the V2 ingest envelope. The provider is called at flush time so
504
- * each field reflects the most recent SDK state.
505
- *
506
- * The shape mirrors the server-side `/api/v2/ingest/batch` contract (Phase
507
- * 3.1). Fields declared here are deduplicated across the batch — they exist
508
- * once on the envelope instead of `N` times on each `events[]` entry.
509
- */
510
- interface EventContext {
511
- distinct_id?: string;
512
- session_id?: string;
513
- device_id?: string;
514
- app_version?: string;
515
- sdk_version?: string;
516
- platform?: string;
517
- os_version?: string;
518
- device_model?: string;
519
- timezone?: string;
520
- locale?: string;
521
- attribution?: Record<string, unknown>;
522
- ids?: Record<string, unknown>;
523
- }
524
-
525
- /**
526
- * Event priority controls flush semantics:
527
- *
528
- * - `"critical"` → flushed as a batch-of-1 on the next microtask (via
529
- * `queueMicrotask`). Used for events where loss is unacceptable:
530
- * `transaction`, `identify`, `lifecycle {type: "install"}`,
531
- * `subscription_*`, `refund`, `checkout_started`.
532
- * - `"normal"` → buffered and flushed on a rolling window (whichever fires
533
- * first): `BATCH_MAX_SIZE` events OR `BATCH_FLUSH_MS`. Used for events
534
- * where batching amortizes network cost: `paywall`, non-install
535
- * `lifecycle` (foreground/background/session), `onboarding`,
536
- * `notification`, `custom`.
537
- *
538
- * Both priorities post to `/sdk/ingest/batch` (Phase 3.1 envelope) with
539
- * automatic fallback to `/sdk/events/batch` when the V2 endpoint is
540
- * absent (old server) or rejects the request. `OfflineQueue` handles
541
- * network-failure durability for both queues via the `PostFn` injected by
542
- * `ApiClient.postWithQueue`.
543
- */
544
- type EventPriority = "critical" | "normal";
545
- interface TrackOptions {
546
- priority?: EventPriority;
547
- }
548
-
549
481
  declare class ApiClient {
550
482
  private baseUrl;
551
483
  private webUrl;
@@ -611,119 +543,121 @@ declare class ApiClient {
611
543
  private flagDeps;
612
544
  }
613
545
 
614
- /**
615
- * Event payload emitted by the native module whenever StoreKit 2
616
- * (`Transaction.updates`) or Google Play Billing (`onPurchasesUpdated` +
617
- * refund diff) detects a renewal, refund, or cancellation.
618
- */
619
- interface NativeTransactionUpdate {
620
- type: "renewed" | "refunded" | "canceled";
621
- transactionId: string;
622
- productId: string;
623
- amount?: number;
624
- currency?: string;
546
+ type NetworkState = "online" | "offline" | "unknown";
547
+ type NetworkListener = (state: NetworkState) => void;
548
+ interface NetworkMonitorConfig {
549
+ debug: boolean;
550
+ checkInterval: number;
551
+ checkUrl: string;
625
552
  }
626
- type TransactionUpdateListener = (update: NativeTransactionUpdate) => void;
627
- interface TransactionUpdateSubscription {
628
- remove(): void;
553
+
554
+ declare class NetworkMonitorClass {
555
+ private config;
556
+ private listeners;
557
+ private currentState;
558
+ private appStateSubscription;
559
+ private initialized;
560
+ private checkIntervalId;
561
+ initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
562
+ private setupFallbackDetection;
563
+ private setupAppStateListener;
564
+ private checkConnectivity;
565
+ private updateState;
566
+ private notifyListeners;
567
+ isOnline(): boolean;
568
+ getState(): NetworkState;
569
+ isInitialized(): boolean;
570
+ addListener(listener: NetworkListener): () => void;
571
+ removeListener(listener: NetworkListener): void;
572
+ forceCheck(): Promise<NetworkState>;
573
+ dispose(): void;
574
+ private log;
575
+ setDebug(debug: boolean): void;
629
576
  }
630
- declare function isAvailable(): boolean;
631
- declare const nativeStoreKit: {
632
- isAvailable: typeof isAvailable;
633
- getProducts(productIds: string[]): Promise<Product[]>;
634
- purchase(productId: string): Promise<Purchase | null>;
635
- finishTransaction(transactionId: string): Promise<void>;
636
- getActiveTransactions(): Promise<Purchase[]>;
577
+ declare const networkMonitor: NetworkMonitorClass;
578
+
579
+ /**
580
+ * Guard usado pelo SessionManager.startSession() — aguarda distinctId ficar
581
+ * disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
582
+ * era session.startSession rodando em paralelo com identity.initialize() e
583
+ * batendo em distinctId vazio. Agora sessão só inicia depois da identity
584
+ * estar pronta; este guard é uma defesa extra caso alguém chame startSession
585
+ * manualmente antes do init terminar.
586
+ */
587
+ type DistinctIdProvider = () => string;
588
+
589
+ /**
590
+ * Attribution data captured at first touch (UTM params, click IDs, referrer).
591
+ * `capturedAt` is ISO 8601 UTC — generated automatically by `capture()`.
592
+ */
593
+ interface AttributionCapture {
594
+ readonly utmSource?: string;
595
+ readonly utmMedium?: string;
596
+ readonly utmCampaign?: string;
597
+ readonly utmContent?: string;
598
+ readonly utmTerm?: string;
599
+ readonly fbclid?: string;
600
+ readonly gclid?: string;
601
+ readonly ttclid?: string;
602
+ readonly tiktokCampaignId?: string;
603
+ readonly tiktokAdgroupId?: string;
604
+ readonly tiktokAdId?: string;
605
+ readonly installReferrerRaw?: string;
606
+ readonly installReferrerSource?: string;
607
+ readonly referrer?: string;
608
+ readonly capturedAt: string;
609
+ }
610
+ type AttributionInput = Omit<AttributionCapture, "capturedAt">;
611
+ /**
612
+ * Attribution module — first-write-wins persistence of UTM / click-ID data.
613
+ *
614
+ * Once a capture is stored, subsequent `capture()` calls are silently ignored.
615
+ * Use `clear()` to reset (e.g. on logout or in tests).
616
+ *
617
+ * @example
618
+ * await attributionTracker.capture({ utmSource: "google", gclid: "Cj0KCQ..." });
619
+ * const attr = attributionTracker.get(); // { utmSource: "google", capturedAt: "..." }
620
+ */
621
+ declare class AttributionTracker {
622
+ private cache;
623
+ private captureInProgress;
624
+ private readonly storage;
625
+ constructor(debug?: boolean);
637
626
  /**
638
- * Subscribes to native transaction update events (renewals, refunds,
639
- * cancellations) from StoreKit 2 (`Transaction.updates`) on iOS or
640
- * `PurchasesUpdatedListener` + refund diff on Android.
641
- *
642
- * Returns a subscription with a `remove()` method. The caller is
643
- * responsible for cleanup (typically on `Paywallo.reset()`).
627
+ * Load persisted attribution from storage into in-memory cache.
628
+ * Called once on SDK init. Subsequent `get()` reads are synchronous.
629
+ */
630
+ loadFromStorage(): Promise<void>;
631
+ /**
632
+ * Persist attribution data. First-write wins — ignores if already captured
633
+ * or if all fields are absent (empty capture).
644
634
  *
645
- * Returns `null` when the native module isn't available (non-mobile env,
646
- * native module not linked) — callers should treat null as a no-op.
635
+ * @param data - Attribution fields without `capturedAt` (generated internally).
647
636
  */
648
- subscribeToTransactionUpdates(listener: TransactionUpdateListener): TransactionUpdateSubscription | null;
649
- };
637
+ capture(data: AttributionInput): Promise<void>;
638
+ /**
639
+ * Returns the persisted attribution capture, or `null` if none exists.
640
+ * Synchronous — reads from in-memory cache (populated via `loadFromStorage()`).
641
+ */
642
+ get(): AttributionCapture | null;
643
+ /**
644
+ * Clears the persisted attribution from storage and in-memory cache.
645
+ * After `clear()`, `get()` returns `null` and the next `capture()` writes normally.
646
+ */
647
+ clear(): Promise<void>;
648
+ }
649
+ declare const attributionTracker: AttributionTracker;
650
650
 
651
- interface ValidateOptions {
652
- paywallPlacement?: string;
653
- variantKey?: string;
654
- paywallId?: string;
655
- variantId?: string;
656
- }
657
-
658
- declare class IAPService {
659
- private productsCache;
660
- private apiClient;
661
- private purchaseInFlight;
662
- /**
663
- * Idempotency guard against double-finish. Populated with transaction IDs
664
- * that have already been forwarded to `NativeStoreKit.finishTransaction`.
665
- */
666
- private finishedTransactions;
667
- private validator;
668
- private emitter;
669
- constructor(apiClient?: ApiClient);
670
- private get debug();
671
- private getDeviceCountry;
672
- private getApiClient;
673
- isAvailable(): boolean;
674
- loadProducts(productIds: string[]): Promise<Product[]>;
675
- getProduct(productId: string): Product | undefined;
676
- getCachedProducts(): Map<string, Product>;
677
- private finishTransaction;
678
- startTransactionListener(): void;
679
- stopTransactionListener(): void;
680
- emitTransactionUpdate(update: NativeTransactionUpdate): Promise<void>;
681
- purchase(productId: string, options?: ValidateOptions): Promise<PurchaseResult>;
682
- restore(): Promise<Purchase[]>;
683
- reset(): void;
684
- }
685
- declare function getIAPService(): IAPService;
686
-
687
- type PurchaseState = "idle" | "purchasing" | "restoring" | "error";
688
- interface IAPProduct {
689
- productId: string;
690
- price: string;
691
- currency: string;
692
- localizedPrice: string;
693
- title: string;
694
- description: string;
695
- type: "inapp" | "subs";
696
- subscriptionPeriodAndroid?: string;
697
- subscriptionPeriodNumberIOS?: string;
698
- subscriptionPeriodUnitIOS?: string;
699
- introductoryPrice?: string;
700
- introductoryPricePaymentModeIOS?: string;
701
- introductoryPriceNumberOfPeriodsIOS?: string;
702
- introductoryPriceSubscriptionPeriodIOS?: string;
703
- freeTrialPeriodAndroid?: string;
704
- trialDays: number;
705
- }
706
- interface IAPPurchase {
707
- productId: string;
708
- transactionId?: string;
709
- transactionDate: number;
710
- transactionReceipt: string;
711
- purchaseToken?: string;
712
- }
713
- interface PurchaseControllerConfig {
714
- debug?: boolean;
715
- validateOnServer?: boolean;
716
- serverValidationUrl?: string;
717
- }
718
- interface ProductPriceInfo {
719
- price: string;
720
- priceValue: number;
721
- currency: string;
722
- localizedPrice: string;
723
- pricePerMonth?: string;
724
- pricePerWeek?: string;
725
- pricePerDay?: string;
651
+ declare class IdentityError extends PaywalloError {
652
+ constructor(code: string, message: string);
726
653
  }
654
+ declare const IDENTITY_ERROR_CODES: {
655
+ readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
656
+ readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
657
+ readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
658
+ readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
659
+ readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
660
+ };
727
661
 
728
662
  interface IdentityState {
729
663
  deviceId: string;
@@ -767,29 +701,10 @@ declare class IdentityManager {
767
701
  }
768
702
  declare const identityManager: IdentityManager;
769
703
 
770
- /**
771
- * Guard usado pelo SessionManager.startSession() — aguarda distinctId ficar
772
- * disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
773
- * era session.startSession rodando em paralelo com identity.initialize() e
774
- * batendo em distinctId vazio. Agora sessão só inicia depois da identity
775
- * estar pronta; este guard é uma defesa extra caso alguém chame startSession
776
- * manualmente antes do init terminar.
777
- */
778
- type DistinctIdProvider = () => string;
779
-
780
- declare class IdentityError extends PaywalloError {
781
- constructor(code: string, message: string);
782
- }
783
- declare const IDENTITY_ERROR_CODES: {
784
- readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
785
- readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
786
- readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
787
- readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
788
- readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
789
- };
790
-
791
704
  declare class MetaBridge {
792
705
  private cachedAnonId;
706
+ private debug;
707
+ setDebug(debug: boolean): void;
793
708
  /** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
794
709
  getCachedAnonymousID(): string | null;
795
710
  getAnonymousID(): Promise<string | null>;
@@ -800,101 +715,64 @@ declare class MetaBridge {
800
715
  }
801
716
  declare const metaBridge: MetaBridge;
802
717
 
803
- type NetworkState = "online" | "offline" | "unknown";
804
- type NetworkListener = (state: NetworkState) => void;
805
- interface NetworkMonitorConfig {
806
- debug: boolean;
807
- checkInterval: number;
808
- checkUrl: string;
718
+ interface FcmRemoteMessage {
719
+ messageId?: string;
720
+ data?: Record<string, string>;
721
+ notification?: {
722
+ title?: string;
723
+ body?: string;
724
+ };
725
+ sentTime?: number;
809
726
  }
810
-
811
- declare class NetworkMonitorClass {
812
- private config;
813
- private listeners;
814
- private currentState;
815
- private appStateSubscription;
816
- private initialized;
817
- private checkIntervalId;
818
- initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
819
- private setupFallbackDetection;
820
- private setupAppStateListener;
821
- private checkConnectivity;
822
- private updateState;
823
- private notifyListeners;
824
- isOnline(): boolean;
825
- getState(): NetworkState;
826
- isInitialized(): boolean;
827
- addListener(listener: NetworkListener): () => void;
828
- removeListener(listener: NetworkListener): void;
829
- forceCheck(): Promise<NetworkState>;
830
- dispose(): void;
831
- private log;
832
- setDebug(debug: boolean): void;
727
+ /**
728
+ * Minimal interface satisfied by NativePushBridge (and any custom bridge).
729
+ * Use this type instead of concrete classes to keep code bridge-agnostic.
730
+ */
731
+ interface IPushBridge {
732
+ getToken(): Promise<string | null>;
733
+ getAPNSToken(): Promise<string | null>;
734
+ requestPermission(options?: {
735
+ provisional?: boolean;
736
+ }): Promise<number>;
737
+ hasPermission(): Promise<number>;
738
+ onTokenRefresh(cb: (token: string) => void): () => void;
739
+ onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
740
+ setBackgroundMessageHandler(cb: (message: FcmRemoteMessage) => Promise<void>): void;
741
+ getInitialNotification(): Promise<FcmRemoteMessage | null>;
833
742
  }
834
- declare const networkMonitor: NetworkMonitorClass;
835
743
 
836
- interface PlanProduct {
837
- id: string;
838
- name: string;
839
- description: string | null;
840
- type: string;
841
- appleProductId: string | null;
842
- googleProductId: string | null;
843
- billingPeriod: string | null;
844
- trialDays: number | null;
845
- priceUsd: number | null;
846
- regionalPrices: unknown;
847
- displayOrder: number;
848
- isActive: boolean;
849
- }
850
- interface Plan {
851
- id: string;
852
- identifier: string;
853
- name: string;
854
- description: string | null;
855
- metadata: unknown;
856
- products: PlanProduct[];
857
- }
858
- interface PlansResponse {
859
- plan: Plan | null;
860
- }
861
- interface AllPlansResponse {
862
- plans: Plan[];
863
- currentIdentifier: string | null;
864
- }
865
- interface PlanServiceConfig {
866
- apiClient: ApiClient;
867
- debug: boolean;
868
- }
869
- interface CachedPlans {
870
- data: AllPlansResponse;
871
- cachedAt: number;
872
- isStale: boolean;
744
+ declare class NativePushBridge implements IPushBridge {
745
+ getToken(): Promise<string | null>;
746
+ getAPNSToken(): Promise<string | null>;
747
+ requestPermission(options?: {
748
+ provisional?: boolean;
749
+ }): Promise<number>;
750
+ hasPermission(): Promise<number>;
751
+ onTokenRefresh(cb: (token: string) => void): () => void;
752
+ onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
753
+ setBackgroundMessageHandler(_cb: (message: FcmRemoteMessage) => Promise<void>): void;
754
+ getInitialNotification(): Promise<FcmRemoteMessage | null>;
873
755
  }
874
756
 
875
- declare class PlanCache {
876
- private cache;
877
- private ttl;
878
- get(): CachedPlans | null;
879
- set(data: AllPlansResponse): void;
880
- invalidate(): void;
881
- setTTL(ttl: number): void;
757
+ type NotificationsEnvironment = "sandbox" | "production";
758
+ interface NotificationsConfig {
759
+ debug?: boolean;
760
+ environment?: NotificationsEnvironment;
761
+ apiBaseUrl?: string;
882
762
  }
883
- declare const planCache: PlanCache;
884
763
 
885
- declare class PlanService {
886
- private config;
887
- private cache;
888
- init(config: PlanServiceConfig): void;
889
- getCurrentPlan(forceRefresh?: boolean): Promise<Plan | null>;
890
- getAllPlans(forceRefresh?: boolean): Promise<AllPlansResponse>;
891
- invalidateCache(): void;
892
- private getApiClient;
893
- private fetchCurrentPlan;
894
- private fetchAllPlans;
895
- private log;
764
+ declare const NOTIFICATIONS_ERROR_CODES: {
765
+ readonly TOKEN_UNAVAILABLE: "TOKEN_UNAVAILABLE";
766
+ readonly PERMISSION_DENIED: "PERMISSION_DENIED";
767
+ readonly REGISTRATION_FAILED: "REGISTRATION_FAILED";
768
+ readonly NOT_INITIALIZED: "NOT_INITIALIZED";
769
+ readonly ABORTED: "ABORTED";
770
+ };
771
+ type NotificationsErrorCode = (typeof NOTIFICATIONS_ERROR_CODES)[keyof typeof NOTIFICATIONS_ERROR_CODES];
772
+ declare class NotificationsError extends PaywalloError {
773
+ readonly details?: unknown;
774
+ constructor(code: NotificationsErrorCode, message: string, details?: unknown);
896
775
  }
897
- declare const planService: PlanService;
898
776
 
899
777
  declare class SecureStorage {
900
778
  constructor(_debug?: boolean);
@@ -916,7 +794,7 @@ type PushPermissionStatus = "granted" | "denied" | "provisional" | "notDetermine
916
794
  */
917
795
  type NotificationEventType = "notification_sent" | "notification_delivered" | "notification_displayed" | "notification_clicked" | "notification_dismissed" | "notification_failed" | "notification_converted";
918
796
  /**
919
- * Payload sent to `POST /api/v2/push-tokens`. Server schema matches 1:1:
797
+ * Payload sent to `POST /sdk/push-tokens`. Server schema matches 1:1:
920
798
  * `{ token, platform, distinct_id, app_version, sdk_version }`.
921
799
  *
922
800
  * Optional client-side extras (deviceId/locale/timezone) are kept for context
@@ -935,6 +813,7 @@ interface DeviceTokenRegistration {
935
813
  }
936
814
  interface NotificationPayload {
937
815
  notificationId: string;
816
+ messageId?: string;
938
817
  campaignId: string;
939
818
  variantKey?: string;
940
819
  title: string;
@@ -949,32 +828,6 @@ type NotificationListener = (event: {
949
828
  messageId: string;
950
829
  }) => void;
951
830
 
952
- interface FcmRemoteMessage {
953
- messageId?: string;
954
- data?: Record<string, string>;
955
- notification?: {
956
- title?: string;
957
- body?: string;
958
- };
959
- sentTime?: number;
960
- }
961
- /**
962
- * Minimal interface satisfied by NativePushBridge (and any custom bridge).
963
- * Use this type instead of concrete classes to keep code bridge-agnostic.
964
- */
965
- interface IPushBridge {
966
- getToken(): Promise<string | null>;
967
- getAPNSToken(): Promise<string | null>;
968
- requestPermission(options?: {
969
- provisional?: boolean;
970
- }): Promise<number>;
971
- hasPermission(): Promise<number>;
972
- onTokenRefresh(cb: (token: string) => void): () => void;
973
- onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
974
- setBackgroundMessageHandler(cb: (message: FcmRemoteMessage) => Promise<void>): void;
975
- getInitialNotification(): Promise<FcmRemoteMessage | null>;
976
- }
977
-
978
831
  /**
979
832
  * Minimal surface the facade needs from the SDK's unified event pipeline.
980
833
  * `PaywalloClient` implements it (forwarding to `ApiClient.trackEvent`
@@ -1007,13 +860,6 @@ interface RNPlatform {
1007
860
  Version?: number | string;
1008
861
  }
1009
862
 
1010
- type NotificationsEnvironment = "sandbox" | "production";
1011
- interface NotificationsConfig {
1012
- debug?: boolean;
1013
- environment?: NotificationsEnvironment;
1014
- apiBaseUrl?: string;
1015
- }
1016
-
1017
863
  interface HandlersConfig {
1018
864
  eventBatcher: EventBatcherLike;
1019
865
  }
@@ -1096,31 +942,78 @@ declare class NotificationsManager {
1096
942
 
1097
943
  declare const notificationsManager: NotificationsManager;
1098
944
 
1099
- declare class NativePushBridge implements IPushBridge {
1100
- getToken(): Promise<string | null>;
1101
- getAPNSToken(): Promise<string | null>;
1102
- requestPermission(options?: {
1103
- provisional?: boolean;
1104
- }): Promise<number>;
1105
- hasPermission(): Promise<number>;
1106
- onTokenRefresh(cb: (token: string) => void): () => void;
1107
- onMessage(cb: (message: FcmRemoteMessage) => Promise<void>): () => void;
1108
- setBackgroundMessageHandler(_cb: (message: FcmRemoteMessage) => Promise<void>): void;
1109
- getInitialNotification(): Promise<FcmRemoteMessage | null>;
945
+ interface PlanProduct {
946
+ id: string;
947
+ name: string;
948
+ description: string | null;
949
+ type: string;
950
+ appleProductId: string | null;
951
+ googleProductId: string | null;
952
+ billingPeriod: string | null;
953
+ trialDays: number | null;
954
+ priceUsd: number | null;
955
+ regionalPrices: unknown;
956
+ displayOrder: number;
957
+ isActive: boolean;
958
+ }
959
+ interface Plan {
960
+ id: string;
961
+ identifier: string;
962
+ name: string;
963
+ description: string | null;
964
+ metadata: unknown;
965
+ products: PlanProduct[];
966
+ }
967
+ interface PlansResponse {
968
+ plan: Plan | null;
969
+ }
970
+ interface AllPlansResponse {
971
+ plans: Plan[];
972
+ currentIdentifier: string | null;
973
+ }
974
+ interface PlanServiceConfig {
975
+ apiClient: ApiClient;
976
+ debug: boolean;
977
+ }
978
+ interface CachedPlans {
979
+ data: AllPlansResponse;
980
+ cachedAt: number;
981
+ isStale: boolean;
1110
982
  }
1111
983
 
1112
- declare const NOTIFICATIONS_ERROR_CODES: {
1113
- readonly TOKEN_UNAVAILABLE: "TOKEN_UNAVAILABLE";
1114
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
1115
- readonly REGISTRATION_FAILED: "REGISTRATION_FAILED";
1116
- readonly NOT_INITIALIZED: "NOT_INITIALIZED";
1117
- readonly ABORTED: "ABORTED";
1118
- };
1119
- type NotificationsErrorCode = (typeof NOTIFICATIONS_ERROR_CODES)[keyof typeof NOTIFICATIONS_ERROR_CODES];
1120
- declare class NotificationsError extends PaywalloError {
1121
- readonly details?: unknown;
1122
- constructor(code: NotificationsErrorCode, message: string, details?: unknown);
984
+ declare class PlanCache {
985
+ private cache;
986
+ private ttl;
987
+ get(): CachedPlans | null;
988
+ set(data: AllPlansResponse): void;
989
+ invalidate(): void;
990
+ setTTL(ttl: number): void;
991
+ }
992
+ declare const planCache: PlanCache;
993
+
994
+ declare class PlanService {
995
+ private config;
996
+ private cache;
997
+ init(config: PlanServiceConfig): void;
998
+ getCurrentPlan(forceRefresh?: boolean): Promise<Plan | null>;
999
+ getAllPlans(forceRefresh?: boolean): Promise<AllPlansResponse>;
1000
+ invalidateCache(): void;
1001
+ private getApiClient;
1002
+ private fetchCurrentPlan;
1003
+ private fetchAllPlans;
1004
+ private log;
1005
+ }
1006
+ declare const planService: PlanService;
1007
+
1008
+ declare class SessionError extends PaywalloError {
1009
+ constructor(code: string, message: string);
1123
1010
  }
1011
+ declare const SESSION_ERROR_CODES: {
1012
+ readonly NOT_INITIALIZED: "SESSION_NOT_INITIALIZED";
1013
+ readonly START_FAILED: "SESSION_START_FAILED";
1014
+ readonly END_FAILED: "SESSION_END_FAILED";
1015
+ readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
1016
+ };
1124
1017
 
1125
1018
  interface SessionState {
1126
1019
  sessionId: string | null;
@@ -1174,16 +1067,6 @@ declare class SessionManager {
1174
1067
  }
1175
1068
  declare const sessionManager: SessionManager;
1176
1069
 
1177
- declare class SessionError extends PaywalloError {
1178
- constructor(code: string, message: string);
1179
- }
1180
- declare const SESSION_ERROR_CODES: {
1181
- readonly NOT_INITIALIZED: "SESSION_NOT_INITIALIZED";
1182
- readonly START_FAILED: "SESSION_START_FAILED";
1183
- readonly END_FAILED: "SESSION_END_FAILED";
1184
- readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
1185
- };
1186
-
1187
1070
  interface PreloadCampaignResult {
1188
1071
  success: boolean;
1189
1072
  error?: Error;
@@ -1447,10 +1330,178 @@ declare class QueueProcessorClass {
1447
1330
  }
1448
1331
  declare const queueProcessor: QueueProcessorClass;
1449
1332
 
1333
+ interface ValidateOptions {
1334
+ paywallPlacement?: string;
1335
+ variantKey?: string;
1336
+ paywallId?: string;
1337
+ variantId?: string;
1338
+ }
1339
+
1340
+ /**
1341
+ * Event payload emitted by the native module whenever StoreKit 2
1342
+ * (`Transaction.updates`) or Google Play Billing (`onPurchasesUpdated` +
1343
+ * refund diff) detects a renewal, refund, or cancellation.
1344
+ */
1345
+ interface NativeTransactionUpdate {
1346
+ type: "renewed" | "refunded" | "canceled";
1347
+ transactionId: string;
1348
+ productId: string;
1349
+ amount?: number;
1350
+ currency?: string;
1351
+ }
1352
+ type TransactionUpdateListener = (update: NativeTransactionUpdate) => void;
1353
+ interface TransactionUpdateSubscription {
1354
+ remove(): void;
1355
+ }
1356
+ declare function isAvailable(): boolean;
1357
+ declare const nativeStoreKit: {
1358
+ isAvailable: typeof isAvailable;
1359
+ getProducts(productIds: string[]): Promise<Product[]>;
1360
+ purchase(productId: string): Promise<Purchase | null>;
1361
+ finishTransaction(transactionId: string): Promise<void>;
1362
+ getActiveTransactions(): Promise<Purchase[]>;
1363
+ /**
1364
+ * Subscribes to native transaction update events (renewals, refunds,
1365
+ * cancellations) from StoreKit 2 (`Transaction.updates`) on iOS or
1366
+ * `PurchasesUpdatedListener` + refund diff on Android.
1367
+ *
1368
+ * Returns a subscription with a `remove()` method. The caller is
1369
+ * responsible for cleanup (typically on `Paywallo.reset()`).
1370
+ *
1371
+ * Returns `null` when the native module isn't available (non-mobile env,
1372
+ * native module not linked) — callers should treat null as a no-op.
1373
+ */
1374
+ subscribeToTransactionUpdates(listener: TransactionUpdateListener): TransactionUpdateSubscription | null;
1375
+ };
1376
+
1377
+ declare class IAPService {
1378
+ private productsCache;
1379
+ private apiClient;
1380
+ private purchaseInFlight;
1381
+ /**
1382
+ * Idempotency guard against double-finish. Populated with transaction IDs
1383
+ * that have already been forwarded to `NativeStoreKit.finishTransaction`.
1384
+ */
1385
+ private finishedTransactions;
1386
+ private validator;
1387
+ private emitter;
1388
+ constructor(apiClient?: ApiClient);
1389
+ private get debug();
1390
+ private getDeviceCountry;
1391
+ private getApiClient;
1392
+ isAvailable(): boolean;
1393
+ loadProducts(productIds: string[]): Promise<Product[]>;
1394
+ getProduct(productId: string): Product | undefined;
1395
+ getCachedProducts(): Map<string, Product>;
1396
+ private finishTransaction;
1397
+ startTransactionListener(): void;
1398
+ stopTransactionListener(): void;
1399
+ emitTransactionUpdate(update: NativeTransactionUpdate): Promise<void>;
1400
+ purchase(productId: string, options?: ValidateOptions): Promise<PurchaseResult>;
1401
+ restore(): Promise<Purchase[]>;
1402
+ reset(): void;
1403
+ }
1404
+ declare function getIAPService(): IAPService;
1405
+
1406
+ type PurchaseState = "idle" | "purchasing" | "restoring" | "error";
1407
+ interface IAPProduct {
1408
+ productId: string;
1409
+ price: string;
1410
+ currency: string;
1411
+ localizedPrice: string;
1412
+ title: string;
1413
+ description: string;
1414
+ type: "inapp" | "subs";
1415
+ subscriptionPeriodAndroid?: string;
1416
+ subscriptionPeriodNumberIOS?: string;
1417
+ subscriptionPeriodUnitIOS?: string;
1418
+ introductoryPrice?: string;
1419
+ introductoryPricePaymentModeIOS?: string;
1420
+ introductoryPriceNumberOfPeriodsIOS?: string;
1421
+ introductoryPriceSubscriptionPeriodIOS?: string;
1422
+ freeTrialPeriodAndroid?: string;
1423
+ trialDays: number;
1424
+ }
1425
+ interface IAPPurchase {
1426
+ productId: string;
1427
+ transactionId?: string;
1428
+ transactionDate: number;
1429
+ transactionReceipt: string;
1430
+ purchaseToken?: string;
1431
+ }
1432
+ interface PurchaseControllerConfig {
1433
+ debug?: boolean;
1434
+ validateOnServer?: boolean;
1435
+ serverValidationUrl?: string;
1436
+ }
1437
+ interface ProductPriceInfo {
1438
+ price: string;
1439
+ priceValue: number;
1440
+ currency: string;
1441
+ localizedPrice: string;
1442
+ pricePerMonth?: string;
1443
+ pricePerWeek?: string;
1444
+ pricePerDay?: string;
1445
+ }
1446
+
1447
+ interface OfferingProduct {
1448
+ id: string;
1449
+ name: string;
1450
+ description: string | null;
1451
+ type: string;
1452
+ productId: string;
1453
+ billingPeriod: string | null;
1454
+ trialDays: number | null;
1455
+ priceUsd: number | null;
1456
+ regionalPrices: unknown;
1457
+ isActive: boolean;
1458
+ }
1459
+ interface Offering {
1460
+ id: string;
1461
+ identifier: string;
1462
+ name: string;
1463
+ description: string | null;
1464
+ metadata: unknown;
1465
+ product: OfferingProduct;
1466
+ }
1467
+ interface OfferingServiceConfig {
1468
+ apiClient: ApiClient;
1469
+ debug: boolean;
1470
+ }
1471
+ interface CachedOfferings {
1472
+ data: Offering[];
1473
+ cachedAt: number;
1474
+ isStale: boolean;
1475
+ }
1476
+
1477
+ declare class OfferingService {
1478
+ private config;
1479
+ private cache;
1480
+ private ttl;
1481
+ init(config: OfferingServiceConfig): void;
1482
+ getOfferings(ids?: string[]): Promise<Offering[]>;
1483
+ invalidateCache(): void;
1484
+ private getMemCache;
1485
+ private setMemCache;
1486
+ private filterByIds;
1487
+ private getApiClient;
1488
+ private fetchOfferings;
1489
+ private log;
1490
+ }
1491
+ declare const offeringService: OfferingService;
1492
+
1493
+ declare class OnboardingError extends PaywalloError {
1494
+ constructor(code: string, message: string);
1495
+ }
1496
+ declare const ONBOARDING_ERROR_CODES: {
1497
+ readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1498
+ readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1499
+ };
1500
+
1450
1501
  /**
1451
1502
  * Minimal surface the OnboardingManager needs from the unified event pipeline.
1452
1503
  * `PaywalloClient` satisfies this interface (forwarding to
1453
- * `ApiClient.trackEvent` → `EventBatcher` → `/api/v1/events/batch`).
1504
+ * `ApiClient.trackEvent` → `EventBatcher` → `/sdk/ingest/batch`).
1454
1505
  */
1455
1506
  interface OnboardingEventPipeline {
1456
1507
  trackEvent(eventName: string, distinctId: string, properties?: Record<string, unknown>, timestamp?: number): Promise<void>;
@@ -1498,14 +1549,6 @@ declare class OnboardingManager {
1498
1549
  }
1499
1550
  declare const onboardingManager: OnboardingManager;
1500
1551
 
1501
- declare class OnboardingError extends PaywalloError {
1502
- constructor(code: string, message: string);
1503
- }
1504
- declare const ONBOARDING_ERROR_CODES: {
1505
- readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1506
- readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1507
- };
1508
-
1509
1552
  /** Payload sent with onboarding.step events. */
1510
1553
  interface OnboardingStepPayload {
1511
1554
  step_name: string;
@@ -1515,16 +1558,145 @@ interface OnboardingDropPayload {
1515
1558
  step_name: string;
1516
1559
  }
1517
1560
 
1518
- interface UseOnboardingResult {
1519
- step: (stepName: string) => Promise<void>;
1520
- complete: () => Promise<void>;
1521
- drop: (stepName: string) => Promise<void>;
1561
+ interface PaywallContextValue {
1562
+ nodes: Record<string, PaywallNode>;
1563
+ rootId: string;
1564
+ language: string;
1565
+ defaultLanguage: string;
1566
+ products: Map<string, Product>;
1567
+ selectedProductId: string | null;
1568
+ primaryProductId: string | null;
1569
+ secondaryProductId: string | null;
1570
+ currentNavigationIndex: number;
1571
+ currentTabIndex: number;
1572
+ trialEnabled: boolean;
1573
+ selectedPeriod: string | null;
1574
+ isPurchasing: boolean;
1575
+ exitOfferVisible: boolean;
1576
+ exitOfferTriggeredByBackButton: boolean;
1577
+ onClose: () => void;
1578
+ onTryClose: () => void;
1579
+ onSelectProduct: (productId: string) => void;
1580
+ onPurchase: (productId: string) => void;
1581
+ onRestore: () => void;
1582
+ onNavigate: (target: "next" | "previous" | "first" | "last" | number) => void;
1583
+ onSetTab: (index: number) => void;
1584
+ onSetVariable: (name: string, value: string) => void;
1585
+ onToggleTrial: (enabled: boolean) => void;
1586
+ onSelectPeriod: (value: string) => void;
1587
+ onOpenUrl: (url: string, inBrowser?: boolean) => void;
1588
+ onTapBehavior: (behavior: TapBehavior) => void;
1589
+ onShowExitOffer: () => void;
1590
+ onDismissExitOffer: () => void;
1591
+ onTriggerBackButton: () => void;
1592
+ }
1593
+ declare const PaywallContext: React.Context<PaywallContextValue | null>;
1594
+ declare function usePaywallContext(): PaywallContextValue;
1595
+
1596
+ declare class PaywallError extends PaywalloError {
1597
+ constructor(code: string, message: string);
1598
+ }
1599
+ declare const PAYWALL_ERROR_CODES: {
1600
+ readonly NOT_INITIALIZED: "PAYWALL_NOT_INITIALIZED";
1601
+ readonly NOT_FOUND: "PAYWALL_NOT_FOUND";
1602
+ readonly RENDER_FAILED: "PAYWALL_RENDER_FAILED";
1603
+ readonly LOAD_FAILED: "PAYWALL_LOAD_FAILED";
1604
+ readonly DISMISS_FAILED: "PAYWALL_DISMISS_FAILED";
1605
+ readonly INVALID_CONFIG: "PAYWALL_INVALID_CONFIG";
1606
+ };
1607
+
1608
+ interface PaywallModalProps {
1609
+ placement: string;
1610
+ visible: boolean;
1611
+ onResult: (result: PaywallResult) => void;
1612
+ paywallConfig?: {
1613
+ id: string;
1614
+ placement: string;
1615
+ config: Record<string, unknown>;
1616
+ primaryProductId?: string;
1617
+ secondaryProductId?: string;
1618
+ };
1619
+ preloadedProducts?: Map<string, Product>;
1620
+ variantKey?: string;
1621
+ campaignId?: string;
1622
+ /** UUID de `paywall_variants` (sub-fase 2.14). */
1623
+ variantId?: string;
1624
+ }
1625
+ declare function PaywallModal({ placement, visible, onResult, paywallConfig: preloadedConfig, preloadedProducts, variantKey, campaignId, variantId, }: PaywallModalProps): React__default.ReactElement | null;
1626
+
1627
+ type SubscriptionStatus = "active" | "expired" | "grace_period" | "billing_retry" | "canceled" | "paused" | "unknown";
1628
+ interface SubscriptionInfo {
1629
+ id: string;
1630
+ productId: string;
1631
+ status: SubscriptionStatus;
1632
+ expiresAt: Date;
1633
+ originalPurchaseDate: Date;
1634
+ latestPurchaseDate: Date;
1635
+ willRenew: boolean;
1636
+ isTrial: boolean;
1637
+ isIntroductoryPeriod: boolean;
1638
+ platform: "ios" | "android";
1639
+ storeTransactionId?: string;
1640
+ cancellationDate?: Date;
1641
+ gracePeriodExpiresAt?: Date;
1642
+ }
1643
+ interface SubscriptionStatusResponse {
1644
+ hasActiveSubscription: boolean;
1645
+ subscription: SubscriptionInfo | null;
1646
+ entitlements: string[];
1647
+ }
1648
+ interface CachedSubscription {
1649
+ data: SubscriptionStatusResponse;
1650
+ cachedAt: number;
1651
+ isStale: boolean;
1652
+ }
1653
+ interface SubscriptionManagerConfig {
1654
+ cacheTTL?: number;
1655
+ serverUrl: string;
1656
+ appKey: string;
1657
+ debug?: boolean;
1658
+ }
1659
+
1660
+ declare class SubscriptionCache {
1661
+ private ttl;
1662
+ private memoryCache;
1663
+ private storage;
1664
+ private legacyCleanupDone;
1665
+ constructor(ttl?: number);
1666
+ private cleanupLegacyCache;
1667
+ get(distinctId: string): Promise<CachedSubscription | null>;
1668
+ set(distinctId: string, data: SubscriptionStatusResponse): Promise<void>;
1669
+ private addToIndex;
1670
+ private readIndex;
1671
+ invalidate(distinctId: string): Promise<void>;
1672
+ invalidateAll(): Promise<void>;
1673
+ private isExpired;
1674
+ setTTL(ttl: number): void;
1522
1675
  }
1523
- /**
1524
- * React hook that exposes bound onboarding tracking methods.
1525
- * Wraps `onboardingManager` with stable `useCallback` references.
1526
- */
1527
- declare function useOnboarding(): UseOnboardingResult;
1676
+
1677
+ type SubscriptionListener = (subscription: SubscriptionStatusResponse) => void;
1678
+ declare class SubscriptionManagerClass {
1679
+ private config;
1680
+ private cache;
1681
+ private listeners;
1682
+ private userId;
1683
+ constructor();
1684
+ private cacheKey;
1685
+ init(config: SubscriptionManagerConfig): void;
1686
+ setUserId(userId: string | null): void;
1687
+ hasActiveSubscription(forceRefresh?: boolean): Promise<boolean>;
1688
+ getSubscription(forceRefresh?: boolean): Promise<SubscriptionInfo | null>;
1689
+ getEntitlements(forceRefresh?: boolean): Promise<string[]>;
1690
+ getSubscriptionStatus(forceRefresh?: boolean): Promise<SubscriptionStatusResponse>;
1691
+ restorePurchases(): Promise<SubscriptionStatusResponse>;
1692
+ private fetchSubscriptionStatus;
1693
+ private getEmptyStatus;
1694
+ addListener(listener: SubscriptionListener): () => void;
1695
+ private notifyListeners;
1696
+ onPurchaseComplete(): Promise<void>;
1697
+ private log;
1698
+ }
1699
+ declare const subscriptionManager: SubscriptionManagerClass;
1528
1700
 
1529
1701
  declare class CampaignError extends PaywalloError {
1530
1702
  constructor(code: string, message: string);
@@ -1537,16 +1709,30 @@ declare const CAMPAIGN_ERROR_CODES: {
1537
1709
  readonly PRESENT_FAILED: "CAMPAIGN_PRESENT_FAILED";
1538
1710
  };
1539
1711
 
1540
- declare function usePaywallo(): PaywalloContextValue;
1712
+ interface UseOfferingPurchaseResult {
1713
+ purchase: (productId: string) => Promise<void>;
1714
+ isPurchasing: boolean;
1715
+ }
1716
+ declare function useOfferingPurchase(): UseOfferingPurchaseResult;
1541
1717
 
1542
- interface UsePlansResult {
1543
- currentPlan: Plan | null;
1544
- allPlans: Plan[];
1718
+ interface UseOfferingsResult {
1719
+ offerings: Offering[];
1545
1720
  isLoading: boolean;
1546
- error: Error | null;
1547
- refresh: () => Promise<void>;
1548
1721
  }
1549
- declare function usePlans(): UsePlansResult;
1722
+ declare function useOfferings(ids?: string[]): UseOfferingsResult;
1723
+
1724
+ interface UseOnboardingResult {
1725
+ step: (stepName: string) => Promise<void>;
1726
+ complete: () => Promise<void>;
1727
+ drop: (stepName: string) => Promise<void>;
1728
+ }
1729
+ /**
1730
+ * React hook that exposes bound onboarding tracking methods.
1731
+ * Wraps `onboardingManager` with stable `useCallback` references.
1732
+ */
1733
+ declare function useOnboarding(): UseOnboardingResult;
1734
+
1735
+ declare function usePaywallo(): PaywalloContextValue;
1550
1736
 
1551
1737
  interface RestoreResult {
1552
1738
  restoredCount: number;
@@ -1561,6 +1747,15 @@ interface UsePlanPurchaseResult {
1561
1747
  }
1562
1748
  declare function usePlanPurchase(): UsePlanPurchaseResult;
1563
1749
 
1750
+ interface UsePlansResult {
1751
+ currentPlan: Plan | null;
1752
+ allPlans: Plan[];
1753
+ isLoading: boolean;
1754
+ error: Error | null;
1755
+ refresh: () => Promise<void>;
1756
+ }
1757
+ declare function usePlans(): UsePlansResult;
1758
+
1564
1759
  interface FormattedProduct extends ProductPriceInfo {
1565
1760
  productId: string;
1566
1761
  title: string;
@@ -1598,39 +1793,6 @@ interface UsePurchaseResult {
1598
1793
  }
1599
1794
  declare function usePurchase(): UsePurchaseResult;
1600
1795
 
1601
- type SubscriptionStatus = "active" | "expired" | "grace_period" | "billing_retry" | "canceled" | "paused" | "unknown";
1602
- interface SubscriptionInfo {
1603
- id: string;
1604
- productId: string;
1605
- status: SubscriptionStatus;
1606
- expiresAt: Date;
1607
- originalPurchaseDate: Date;
1608
- latestPurchaseDate: Date;
1609
- willRenew: boolean;
1610
- isTrial: boolean;
1611
- isIntroductoryPeriod: boolean;
1612
- platform: "ios" | "android";
1613
- storeTransactionId?: string;
1614
- cancellationDate?: Date;
1615
- gracePeriodExpiresAt?: Date;
1616
- }
1617
- interface SubscriptionStatusResponse {
1618
- hasActiveSubscription: boolean;
1619
- subscription: SubscriptionInfo | null;
1620
- entitlements: string[];
1621
- }
1622
- interface CachedSubscription {
1623
- data: SubscriptionStatusResponse;
1624
- cachedAt: number;
1625
- isStale: boolean;
1626
- }
1627
- interface SubscriptionManagerConfig {
1628
- cacheTTL?: number;
1629
- serverUrl: string;
1630
- appKey: string;
1631
- debug?: boolean;
1632
- }
1633
-
1634
1796
  interface UseSubscriptionResult {
1635
1797
  subscription: SubscriptionInfo | null;
1636
1798
  isActive: boolean;
@@ -1648,47 +1810,6 @@ interface PaywalloProviderProps {
1648
1810
  }
1649
1811
  declare function PaywalloProvider({ children, config }: PaywalloProviderProps): React__default.ReactElement;
1650
1812
 
1651
- declare class SubscriptionCache {
1652
- private ttl;
1653
- private memoryCache;
1654
- private storage;
1655
- private legacyCleanupDone;
1656
- constructor(ttl?: number);
1657
- private cleanupLegacyCache;
1658
- get(distinctId: string): Promise<CachedSubscription | null>;
1659
- set(distinctId: string, data: SubscriptionStatusResponse): Promise<void>;
1660
- private addToIndex;
1661
- private readIndex;
1662
- invalidate(distinctId: string): Promise<void>;
1663
- invalidateAll(): Promise<void>;
1664
- private isExpired;
1665
- setTTL(ttl: number): void;
1666
- }
1667
-
1668
- type SubscriptionListener = (subscription: SubscriptionStatusResponse) => void;
1669
- declare class SubscriptionManagerClass {
1670
- private config;
1671
- private cache;
1672
- private listeners;
1673
- private userId;
1674
- constructor();
1675
- private cacheKey;
1676
- init(config: SubscriptionManagerConfig): void;
1677
- setUserId(userId: string | null): void;
1678
- hasActiveSubscription(forceRefresh?: boolean): Promise<boolean>;
1679
- getSubscription(forceRefresh?: boolean): Promise<SubscriptionInfo | null>;
1680
- getEntitlements(forceRefresh?: boolean): Promise<string[]>;
1681
- getSubscriptionStatus(forceRefresh?: boolean): Promise<SubscriptionStatusResponse>;
1682
- restorePurchases(): Promise<SubscriptionStatusResponse>;
1683
- private fetchSubscriptionStatus;
1684
- private getEmptyStatus;
1685
- addListener(listener: SubscriptionListener): () => void;
1686
- private notifyListeners;
1687
- onPurchaseComplete(): Promise<void>;
1688
- private log;
1689
- }
1690
- declare const subscriptionManager: SubscriptionManagerClass;
1691
-
1692
1813
  declare function setCurrentLanguage(language: string): void;
1693
1814
  declare function setDefaultLanguage(language: string): void;
1694
1815
  declare function getCurrentLanguage(): string;
@@ -1725,4 +1846,4 @@ declare function hasVariables(text: string): boolean;
1725
1846
 
1726
1847
  declare const Paywallo: IPaywalloClient;
1727
1848
 
1728
- export { type AllPlansResponse, ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, 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 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, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOnboarding, usePaywallContext, usePaywallo, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
1849
+ export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, 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, attributionTracker, 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 };