@virex-tech/paywallo-sdk 2.0.2 → 2.2.1
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 +122 -7
- package/dist/index.d.ts +122 -7
- package/dist/index.js +1170 -617
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1144 -597
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloDevice.swift +29 -1
- package/package.json +2 -2
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;
|
|
@@ -530,8 +535,8 @@ interface EventContext {
|
|
|
530
535
|
* `lifecycle` (foreground/background/session), `onboarding`,
|
|
531
536
|
* `notification`, `custom`.
|
|
532
537
|
*
|
|
533
|
-
* Both priorities post to `/ingest/batch` (Phase 3.1 envelope) with
|
|
534
|
-
* automatic fallback to `/events/batch` when the V2 endpoint is
|
|
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
|
|
535
540
|
* absent (old server) or rejects the request. `OfflineQueue` handles
|
|
536
541
|
* network-failure durability for both queues via the `PostFn` injected by
|
|
537
542
|
* `ApiClient.postWithQueue`.
|
|
@@ -585,11 +590,18 @@ declare class ApiClient {
|
|
|
585
590
|
trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number, options?: TrackOptions): Promise<void>;
|
|
586
591
|
flushEventBatch(): Promise<void>;
|
|
587
592
|
dispose(): void;
|
|
588
|
-
identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string
|
|
593
|
+
identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string, pii?: {
|
|
594
|
+
phone?: string;
|
|
595
|
+
firstName?: string;
|
|
596
|
+
lastName?: string;
|
|
597
|
+
dateOfBirth?: string;
|
|
598
|
+
gender?: string;
|
|
599
|
+
}): Promise<void>;
|
|
589
600
|
getVariant(flagKey: string, distinctId: string): Promise<FlagVariant>;
|
|
590
601
|
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
591
602
|
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
592
603
|
getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
604
|
+
getActivePlacements(): Promise<string[]>;
|
|
593
605
|
getPrimaryCampaign(distinctId: string): Promise<CampaignResponse | null>;
|
|
594
606
|
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
607
|
getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
|
|
@@ -717,12 +729,22 @@ interface IdentityState {
|
|
|
717
729
|
deviceId: string;
|
|
718
730
|
email: string | null;
|
|
719
731
|
properties: UserProperties;
|
|
732
|
+
phone: string | null;
|
|
733
|
+
firstName: string | null;
|
|
734
|
+
lastName: string | null;
|
|
735
|
+
dateOfBirth: string | null;
|
|
736
|
+
gender: string | null;
|
|
720
737
|
}
|
|
721
738
|
declare class IdentityManager {
|
|
722
739
|
private deviceId;
|
|
723
740
|
private anonId;
|
|
724
741
|
private email;
|
|
725
742
|
private properties;
|
|
743
|
+
private phone;
|
|
744
|
+
private firstName;
|
|
745
|
+
private lastName;
|
|
746
|
+
private dateOfBirth;
|
|
747
|
+
private gender;
|
|
726
748
|
private apiClient;
|
|
727
749
|
private secureStorage;
|
|
728
750
|
private debug;
|
|
@@ -767,6 +789,9 @@ declare const IDENTITY_ERROR_CODES: {
|
|
|
767
789
|
};
|
|
768
790
|
|
|
769
791
|
declare class MetaBridge {
|
|
792
|
+
private cachedAnonId;
|
|
793
|
+
/** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
|
|
794
|
+
getCachedAnonymousID(): string | null;
|
|
770
795
|
getAnonymousID(): Promise<string | null>;
|
|
771
796
|
logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
|
|
772
797
|
logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
|
|
@@ -808,6 +833,69 @@ declare class NetworkMonitorClass {
|
|
|
808
833
|
}
|
|
809
834
|
declare const networkMonitor: NetworkMonitorClass;
|
|
810
835
|
|
|
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;
|
|
873
|
+
}
|
|
874
|
+
|
|
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;
|
|
882
|
+
}
|
|
883
|
+
declare const planCache: PlanCache;
|
|
884
|
+
|
|
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;
|
|
896
|
+
}
|
|
897
|
+
declare const planService: PlanService;
|
|
898
|
+
|
|
811
899
|
declare class SecureStorage {
|
|
812
900
|
constructor(_debug?: boolean);
|
|
813
901
|
get(key: string): Promise<string | null>;
|
|
@@ -843,6 +931,7 @@ interface DeviceTokenRegistration {
|
|
|
843
931
|
deviceId?: string;
|
|
844
932
|
locale?: string;
|
|
845
933
|
timezone?: string;
|
|
934
|
+
environment?: "sandbox" | "production";
|
|
846
935
|
}
|
|
847
936
|
interface NotificationPayload {
|
|
848
937
|
notificationId: string;
|
|
@@ -1116,6 +1205,8 @@ interface PaywalloInitConfig extends PaywalloConfig {
|
|
|
1116
1205
|
autoPreloadCampaign?: string;
|
|
1117
1206
|
/** Called when the SDK silently swallows an API error. Useful for logging/monitoring in production. */
|
|
1118
1207
|
onError?: (error: unknown) => void;
|
|
1208
|
+
/** 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). */
|
|
1209
|
+
notifications?: boolean;
|
|
1119
1210
|
}
|
|
1120
1211
|
interface IPaywalloClient {
|
|
1121
1212
|
init(config: PaywalloInitConfig): Promise<void>;
|
|
@@ -1133,7 +1224,7 @@ interface IPaywalloClient {
|
|
|
1133
1224
|
presentCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResult>;
|
|
1134
1225
|
hasActiveSubscription(): Promise<boolean>;
|
|
1135
1226
|
getSubscription(): Promise<Subscription | null>;
|
|
1136
|
-
restorePurchases(): Promise<RestoreResult>;
|
|
1227
|
+
restorePurchases(): Promise<RestoreResult$1>;
|
|
1137
1228
|
requireSubscription(paywallPlacement?: string): Promise<boolean>;
|
|
1138
1229
|
requireSubscriptionWithCampaign(placement: string, context?: Record<string, unknown>): Promise<boolean>;
|
|
1139
1230
|
gateContent<T>(content: () => T | Promise<T>, paywallPlacement?: string): Promise<T | null>;
|
|
@@ -1162,7 +1253,7 @@ interface IPaywalloClient {
|
|
|
1162
1253
|
registerCampaignPresenter(presenter: ((campaign: CampaignResponse) => Promise<CampaignResult>) | null): void;
|
|
1163
1254
|
registerSubscriptionGetter(getter: (() => Promise<Subscription | null>) | null): void;
|
|
1164
1255
|
registerActiveChecker(checker: (() => Promise<boolean>) | null): void;
|
|
1165
|
-
registerRestoreHandler(handler: (() => Promise<RestoreResult>) | null): void;
|
|
1256
|
+
registerRestoreHandler(handler: (() => Promise<RestoreResult$1>) | null): void;
|
|
1166
1257
|
registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
|
|
1167
1258
|
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
1168
1259
|
getSessionFlag(key: string): string | null;
|
|
@@ -1178,6 +1269,8 @@ interface IPaywalloClient {
|
|
|
1178
1269
|
isPreloaded(placement: string): boolean;
|
|
1179
1270
|
getAutoPreloadedPlacement(): string | null;
|
|
1180
1271
|
waitForAutoPreloadedPlacement(): Promise<string | null>;
|
|
1272
|
+
getPlans(): Promise<AllPlansResponse>;
|
|
1273
|
+
getCurrentPlan(): Promise<Plan | null>;
|
|
1181
1274
|
}
|
|
1182
1275
|
|
|
1183
1276
|
declare const PaywalloClient: IPaywalloClient;
|
|
@@ -1446,6 +1539,28 @@ declare const CAMPAIGN_ERROR_CODES: {
|
|
|
1446
1539
|
|
|
1447
1540
|
declare function usePaywallo(): PaywalloContextValue;
|
|
1448
1541
|
|
|
1542
|
+
interface UsePlansResult {
|
|
1543
|
+
currentPlan: Plan | null;
|
|
1544
|
+
allPlans: Plan[];
|
|
1545
|
+
isLoading: boolean;
|
|
1546
|
+
error: Error | null;
|
|
1547
|
+
refresh: () => Promise<void>;
|
|
1548
|
+
}
|
|
1549
|
+
declare function usePlans(): UsePlansResult;
|
|
1550
|
+
|
|
1551
|
+
interface RestoreResult {
|
|
1552
|
+
restoredCount: number;
|
|
1553
|
+
productIds: string[];
|
|
1554
|
+
}
|
|
1555
|
+
interface UsePlanPurchaseResult {
|
|
1556
|
+
purchase: (productId: string) => Promise<PurchaseResult | null>;
|
|
1557
|
+
restore: () => Promise<RestoreResult | null>;
|
|
1558
|
+
isPurchasing: boolean;
|
|
1559
|
+
isRestoring: boolean;
|
|
1560
|
+
error: Error | null;
|
|
1561
|
+
}
|
|
1562
|
+
declare function usePlanPurchase(): UsePlanPurchaseResult;
|
|
1563
|
+
|
|
1449
1564
|
interface FormattedProduct extends ProductPriceInfo {
|
|
1450
1565
|
productId: string;
|
|
1451
1566
|
title: string;
|
|
@@ -1610,4 +1725,4 @@ declare function hasVariables(text: string): boolean;
|
|
|
1610
1725
|
|
|
1611
1726
|
declare const Paywallo: IPaywalloClient;
|
|
1612
1727
|
|
|
1613
|
-
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 };
|
|
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 };
|
package/dist/index.d.ts
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;
|
|
@@ -530,8 +535,8 @@ interface EventContext {
|
|
|
530
535
|
* `lifecycle` (foreground/background/session), `onboarding`,
|
|
531
536
|
* `notification`, `custom`.
|
|
532
537
|
*
|
|
533
|
-
* Both priorities post to `/ingest/batch` (Phase 3.1 envelope) with
|
|
534
|
-
* automatic fallback to `/events/batch` when the V2 endpoint is
|
|
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
|
|
535
540
|
* absent (old server) or rejects the request. `OfflineQueue` handles
|
|
536
541
|
* network-failure durability for both queues via the `PostFn` injected by
|
|
537
542
|
* `ApiClient.postWithQueue`.
|
|
@@ -585,11 +590,18 @@ declare class ApiClient {
|
|
|
585
590
|
trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number, options?: TrackOptions): Promise<void>;
|
|
586
591
|
flushEventBatch(): Promise<void>;
|
|
587
592
|
dispose(): void;
|
|
588
|
-
identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string
|
|
593
|
+
identify(distinctId: string, properties?: UserProperties, email?: string, deviceId?: string, pii?: {
|
|
594
|
+
phone?: string;
|
|
595
|
+
firstName?: string;
|
|
596
|
+
lastName?: string;
|
|
597
|
+
dateOfBirth?: string;
|
|
598
|
+
gender?: string;
|
|
599
|
+
}): Promise<void>;
|
|
589
600
|
getVariant(flagKey: string, distinctId: string): Promise<FlagVariant>;
|
|
590
601
|
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
591
602
|
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
592
603
|
getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
604
|
+
getActivePlacements(): Promise<string[]>;
|
|
593
605
|
getPrimaryCampaign(distinctId: string): Promise<CampaignResponse | null>;
|
|
594
606
|
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
607
|
getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
|
|
@@ -717,12 +729,22 @@ interface IdentityState {
|
|
|
717
729
|
deviceId: string;
|
|
718
730
|
email: string | null;
|
|
719
731
|
properties: UserProperties;
|
|
732
|
+
phone: string | null;
|
|
733
|
+
firstName: string | null;
|
|
734
|
+
lastName: string | null;
|
|
735
|
+
dateOfBirth: string | null;
|
|
736
|
+
gender: string | null;
|
|
720
737
|
}
|
|
721
738
|
declare class IdentityManager {
|
|
722
739
|
private deviceId;
|
|
723
740
|
private anonId;
|
|
724
741
|
private email;
|
|
725
742
|
private properties;
|
|
743
|
+
private phone;
|
|
744
|
+
private firstName;
|
|
745
|
+
private lastName;
|
|
746
|
+
private dateOfBirth;
|
|
747
|
+
private gender;
|
|
726
748
|
private apiClient;
|
|
727
749
|
private secureStorage;
|
|
728
750
|
private debug;
|
|
@@ -767,6 +789,9 @@ declare const IDENTITY_ERROR_CODES: {
|
|
|
767
789
|
};
|
|
768
790
|
|
|
769
791
|
declare class MetaBridge {
|
|
792
|
+
private cachedAnonId;
|
|
793
|
+
/** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
|
|
794
|
+
getCachedAnonymousID(): string | null;
|
|
770
795
|
getAnonymousID(): Promise<string | null>;
|
|
771
796
|
logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
|
|
772
797
|
logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
|
|
@@ -808,6 +833,69 @@ declare class NetworkMonitorClass {
|
|
|
808
833
|
}
|
|
809
834
|
declare const networkMonitor: NetworkMonitorClass;
|
|
810
835
|
|
|
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;
|
|
873
|
+
}
|
|
874
|
+
|
|
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;
|
|
882
|
+
}
|
|
883
|
+
declare const planCache: PlanCache;
|
|
884
|
+
|
|
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;
|
|
896
|
+
}
|
|
897
|
+
declare const planService: PlanService;
|
|
898
|
+
|
|
811
899
|
declare class SecureStorage {
|
|
812
900
|
constructor(_debug?: boolean);
|
|
813
901
|
get(key: string): Promise<string | null>;
|
|
@@ -843,6 +931,7 @@ interface DeviceTokenRegistration {
|
|
|
843
931
|
deviceId?: string;
|
|
844
932
|
locale?: string;
|
|
845
933
|
timezone?: string;
|
|
934
|
+
environment?: "sandbox" | "production";
|
|
846
935
|
}
|
|
847
936
|
interface NotificationPayload {
|
|
848
937
|
notificationId: string;
|
|
@@ -1116,6 +1205,8 @@ interface PaywalloInitConfig extends PaywalloConfig {
|
|
|
1116
1205
|
autoPreloadCampaign?: string;
|
|
1117
1206
|
/** Called when the SDK silently swallows an API error. Useful for logging/monitoring in production. */
|
|
1118
1207
|
onError?: (error: unknown) => void;
|
|
1208
|
+
/** 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). */
|
|
1209
|
+
notifications?: boolean;
|
|
1119
1210
|
}
|
|
1120
1211
|
interface IPaywalloClient {
|
|
1121
1212
|
init(config: PaywalloInitConfig): Promise<void>;
|
|
@@ -1133,7 +1224,7 @@ interface IPaywalloClient {
|
|
|
1133
1224
|
presentCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResult>;
|
|
1134
1225
|
hasActiveSubscription(): Promise<boolean>;
|
|
1135
1226
|
getSubscription(): Promise<Subscription | null>;
|
|
1136
|
-
restorePurchases(): Promise<RestoreResult>;
|
|
1227
|
+
restorePurchases(): Promise<RestoreResult$1>;
|
|
1137
1228
|
requireSubscription(paywallPlacement?: string): Promise<boolean>;
|
|
1138
1229
|
requireSubscriptionWithCampaign(placement: string, context?: Record<string, unknown>): Promise<boolean>;
|
|
1139
1230
|
gateContent<T>(content: () => T | Promise<T>, paywallPlacement?: string): Promise<T | null>;
|
|
@@ -1162,7 +1253,7 @@ interface IPaywalloClient {
|
|
|
1162
1253
|
registerCampaignPresenter(presenter: ((campaign: CampaignResponse) => Promise<CampaignResult>) | null): void;
|
|
1163
1254
|
registerSubscriptionGetter(getter: (() => Promise<Subscription | null>) | null): void;
|
|
1164
1255
|
registerActiveChecker(checker: (() => Promise<boolean>) | null): void;
|
|
1165
|
-
registerRestoreHandler(handler: (() => Promise<RestoreResult>) | null): void;
|
|
1256
|
+
registerRestoreHandler(handler: (() => Promise<RestoreResult$1>) | null): void;
|
|
1166
1257
|
registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler | null): void;
|
|
1167
1258
|
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
1168
1259
|
getSessionFlag(key: string): string | null;
|
|
@@ -1178,6 +1269,8 @@ interface IPaywalloClient {
|
|
|
1178
1269
|
isPreloaded(placement: string): boolean;
|
|
1179
1270
|
getAutoPreloadedPlacement(): string | null;
|
|
1180
1271
|
waitForAutoPreloadedPlacement(): Promise<string | null>;
|
|
1272
|
+
getPlans(): Promise<AllPlansResponse>;
|
|
1273
|
+
getCurrentPlan(): Promise<Plan | null>;
|
|
1181
1274
|
}
|
|
1182
1275
|
|
|
1183
1276
|
declare const PaywalloClient: IPaywalloClient;
|
|
@@ -1446,6 +1539,28 @@ declare const CAMPAIGN_ERROR_CODES: {
|
|
|
1446
1539
|
|
|
1447
1540
|
declare function usePaywallo(): PaywalloContextValue;
|
|
1448
1541
|
|
|
1542
|
+
interface UsePlansResult {
|
|
1543
|
+
currentPlan: Plan | null;
|
|
1544
|
+
allPlans: Plan[];
|
|
1545
|
+
isLoading: boolean;
|
|
1546
|
+
error: Error | null;
|
|
1547
|
+
refresh: () => Promise<void>;
|
|
1548
|
+
}
|
|
1549
|
+
declare function usePlans(): UsePlansResult;
|
|
1550
|
+
|
|
1551
|
+
interface RestoreResult {
|
|
1552
|
+
restoredCount: number;
|
|
1553
|
+
productIds: string[];
|
|
1554
|
+
}
|
|
1555
|
+
interface UsePlanPurchaseResult {
|
|
1556
|
+
purchase: (productId: string) => Promise<PurchaseResult | null>;
|
|
1557
|
+
restore: () => Promise<RestoreResult | null>;
|
|
1558
|
+
isPurchasing: boolean;
|
|
1559
|
+
isRestoring: boolean;
|
|
1560
|
+
error: Error | null;
|
|
1561
|
+
}
|
|
1562
|
+
declare function usePlanPurchase(): UsePlanPurchaseResult;
|
|
1563
|
+
|
|
1449
1564
|
interface FormattedProduct extends ProductPriceInfo {
|
|
1450
1565
|
productId: string;
|
|
1451
1566
|
title: string;
|
|
@@ -1610,4 +1725,4 @@ declare function hasVariables(text: string): boolean;
|
|
|
1610
1725
|
|
|
1611
1726
|
declare const Paywallo: IPaywalloClient;
|
|
1612
1727
|
|
|
1613
|
-
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 };
|
|
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 };
|