@virex-tech/paywallo-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/MonetySdk.podspec +19 -0
- package/README.md +164 -0
- package/android/build.gradle +54 -0
- package/android/src/main/java/com/monety/sdk/MonetySdkPackage.kt +16 -0
- package/android/src/main/java/com/monety/sdk/PanelStoreKitModule.kt +315 -0
- package/android/src/main/java/com/monety/sdk/PanelWebView.kt +74 -0
- package/android/src/main/java/com/monety/sdk/PanelWebViewManager.kt +52 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloSdkPackage.kt +16 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloStoreKitModule.kt +315 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloWebView.kt +74 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloWebViewManager.kt +52 -0
- package/dist/index.d.mts +1141 -0
- package/dist/index.d.ts +1141 -0
- package/dist/index.js +4793 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4709 -0
- package/dist/index.mjs.map +1 -0
- package/ios/PanelStoreKit.m +21 -0
- package/ios/PanelStoreKit.swift +245 -0
- package/ios/PanelWebView.h +15 -0
- package/ios/PanelWebView.m +182 -0
- package/ios/PanelWebViewManager.m +41 -0
- package/ios/PanelWebViewModule.h +8 -0
- package/ios/PanelWebViewModule.m +42 -0
- package/ios/PaywalloStoreKit.m +21 -0
- package/ios/PaywalloStoreKit.swift +245 -0
- package/ios/PaywalloWebView.h +15 -0
- package/ios/PaywalloWebView.m +182 -0
- package/ios/PaywalloWebViewManager.m +41 -0
- package/ios/PaywalloWebViewModule.h +8 -0
- package/ios/PaywalloWebViewModule.m +42 -0
- package/package.json +93 -0
- package/react-native.config.js +14 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1141 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
type EntranceAnimationType = "none" | "fade" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "scale" | "bounce";
|
|
5
|
+
type LoopAnimationType = "none" | "pulse" | "glow" | "float" | "shake" | "bounce";
|
|
6
|
+
type InteractionAnimationType = "none" | "scale-down" | "opacity" | "highlight";
|
|
7
|
+
type AnimationEasing = "ease" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
|
|
8
|
+
interface EntranceAnimation {
|
|
9
|
+
type: EntranceAnimationType;
|
|
10
|
+
duration?: number;
|
|
11
|
+
delay?: number;
|
|
12
|
+
easing?: AnimationEasing;
|
|
13
|
+
}
|
|
14
|
+
interface LoopAnimation {
|
|
15
|
+
type: LoopAnimationType;
|
|
16
|
+
duration?: number;
|
|
17
|
+
repeatCount?: number;
|
|
18
|
+
}
|
|
19
|
+
interface InteractionAnimation {
|
|
20
|
+
tap?: InteractionAnimationType;
|
|
21
|
+
tapDuration?: number;
|
|
22
|
+
}
|
|
23
|
+
interface AnimationProps {
|
|
24
|
+
entrance?: EntranceAnimation;
|
|
25
|
+
loop?: LoopAnimation;
|
|
26
|
+
interaction?: InteractionAnimation;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Shared primitive types used across all block categories.
|
|
31
|
+
*/
|
|
32
|
+
interface BoxSpacing {
|
|
33
|
+
top: number;
|
|
34
|
+
right: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
left: number;
|
|
37
|
+
}
|
|
38
|
+
interface LocalizedText {
|
|
39
|
+
[languageCode: string]: string;
|
|
40
|
+
}
|
|
41
|
+
type TapBehaviorType = "none" | "close" | "select-product" | "set-variable" | "custom-placement" | "open-url" | "navigate" | "restore-purchases" | "purchase";
|
|
42
|
+
type NavigateTarget = "next" | "previous" | "first" | "last" | number;
|
|
43
|
+
interface TapBehavior {
|
|
44
|
+
type: TapBehaviorType;
|
|
45
|
+
productId?: string;
|
|
46
|
+
variableName?: string;
|
|
47
|
+
variableValue?: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
openInBrowser?: boolean;
|
|
50
|
+
target?: NavigateTarget;
|
|
51
|
+
targetStepId?: string;
|
|
52
|
+
placementName?: string;
|
|
53
|
+
}
|
|
54
|
+
type BlockType = "page" | "stack" | "text" | "button" | "image" | "icon" | "video" | "divider" | "spacer" | "lottie" | "carousel" | "navigation" | "tabs" | "fixed-footer" | "feature-card" | "bullet-item" | "timeline-item" | "simple-link" | "comparison-table" | "countdown" | "review" | "badge" | "popup" | "progress" | "social-proof" | "testimonial" | "accolades" | "sticker" | "product-card" | "toggle-option" | "delayed-close" | "close-button" | "back-button" | "trial-toggle" | "period-picker" | "product-list" | "exit-offer" | "spin-wheel";
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Layout block props — page, stack, fixed-footer, popup.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
interface PaywallNode {
|
|
61
|
+
id: string;
|
|
62
|
+
type: BlockType;
|
|
63
|
+
props: unknown;
|
|
64
|
+
children: string[];
|
|
65
|
+
parentId: string | null;
|
|
66
|
+
conditions?: BlockConditions;
|
|
67
|
+
animation?: AnimationProps;
|
|
68
|
+
}
|
|
69
|
+
interface PaywallState {
|
|
70
|
+
nodes: Record<string, PaywallNode>;
|
|
71
|
+
rootId: string;
|
|
72
|
+
}
|
|
73
|
+
type ConditionOperator = "equals" | "not_equals" | "contains" | "not_contains" | "greater_than" | "less_than" | "greater_than_or_equals" | "less_than_or_equals" | "is_empty" | "is_not_empty" | "is_true" | "is_false";
|
|
74
|
+
interface Condition {
|
|
75
|
+
id: string;
|
|
76
|
+
variable: string;
|
|
77
|
+
operator: ConditionOperator;
|
|
78
|
+
value?: string | number | boolean;
|
|
79
|
+
}
|
|
80
|
+
interface ConditionGroup {
|
|
81
|
+
id: string;
|
|
82
|
+
logic: "and" | "or";
|
|
83
|
+
conditions: Condition[];
|
|
84
|
+
}
|
|
85
|
+
interface DynamicRule {
|
|
86
|
+
id: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
conditionGroups: ConditionGroup[];
|
|
89
|
+
groupsLogic: "and" | "or";
|
|
90
|
+
}
|
|
91
|
+
interface DynamicValue<T = string> {
|
|
92
|
+
rules: DynamicValueRule<T>[];
|
|
93
|
+
defaultValue: T;
|
|
94
|
+
}
|
|
95
|
+
interface DynamicValueRule<T = string> {
|
|
96
|
+
id: string;
|
|
97
|
+
condition: DynamicRule;
|
|
98
|
+
value: T;
|
|
99
|
+
}
|
|
100
|
+
interface VisibilityCondition {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
rule?: DynamicRule;
|
|
103
|
+
showWhen: "matches" | "not_matches";
|
|
104
|
+
}
|
|
105
|
+
interface BlockConditions {
|
|
106
|
+
visibility?: VisibilityCondition;
|
|
107
|
+
dynamicProps?: Record<string, DynamicValue>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface ServerProductInfo {
|
|
111
|
+
storeProductId: string;
|
|
112
|
+
name: string;
|
|
113
|
+
price: number | null;
|
|
114
|
+
billingPeriod: string | null;
|
|
115
|
+
trialDays: number | null;
|
|
116
|
+
}
|
|
117
|
+
interface CampaignResponse {
|
|
118
|
+
campaignId: string;
|
|
119
|
+
variantKey: string;
|
|
120
|
+
paywall: {
|
|
121
|
+
id: string;
|
|
122
|
+
placement: string;
|
|
123
|
+
config: Record<string, unknown>;
|
|
124
|
+
primaryProductId?: string;
|
|
125
|
+
secondaryProductId?: string;
|
|
126
|
+
primaryProduct?: ServerProductInfo;
|
|
127
|
+
secondaryProduct?: ServerProductInfo;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
interface CampaignResult {
|
|
131
|
+
presented: boolean;
|
|
132
|
+
purchased: boolean;
|
|
133
|
+
productId?: string;
|
|
134
|
+
transactionId?: string;
|
|
135
|
+
cancelled: boolean;
|
|
136
|
+
restored: boolean;
|
|
137
|
+
campaignId?: string;
|
|
138
|
+
variantKey?: string;
|
|
139
|
+
error?: Error;
|
|
140
|
+
}
|
|
141
|
+
interface CampaignPresentOptions {
|
|
142
|
+
placement: string;
|
|
143
|
+
context?: Record<string, unknown>;
|
|
144
|
+
onDismiss?: () => void;
|
|
145
|
+
onPurchase?: (productId: string) => void;
|
|
146
|
+
onError?: (error: Error) => void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface PaywallConfig {
|
|
150
|
+
id: string;
|
|
151
|
+
placement: string;
|
|
152
|
+
config: {
|
|
153
|
+
craftData: string;
|
|
154
|
+
} | PaywallBlockConfig;
|
|
155
|
+
content?: string | Record<string, unknown>;
|
|
156
|
+
primaryProductId?: string;
|
|
157
|
+
secondaryProductId?: string;
|
|
158
|
+
}
|
|
159
|
+
interface PaywallBlockConfig {
|
|
160
|
+
type: string;
|
|
161
|
+
props: Record<string, unknown>;
|
|
162
|
+
children?: PaywallBlockConfig[];
|
|
163
|
+
}
|
|
164
|
+
interface PaywallResult {
|
|
165
|
+
presented: boolean;
|
|
166
|
+
purchased: boolean;
|
|
167
|
+
productId?: string;
|
|
168
|
+
transactionId?: string;
|
|
169
|
+
cancelled: boolean;
|
|
170
|
+
restored: boolean;
|
|
171
|
+
error?: Error;
|
|
172
|
+
}
|
|
173
|
+
interface PaywallPresentOptions {
|
|
174
|
+
placement: string;
|
|
175
|
+
onDismiss?: () => void;
|
|
176
|
+
onPurchase?: (productId: string) => void;
|
|
177
|
+
onError?: (error: Error) => void;
|
|
178
|
+
}
|
|
179
|
+
interface EmergencyPaywallResponse {
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
paywallId?: string;
|
|
182
|
+
paywall?: PaywallConfig;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface Product {
|
|
186
|
+
productId: string;
|
|
187
|
+
title: string;
|
|
188
|
+
description: string;
|
|
189
|
+
price: string;
|
|
190
|
+
priceValue: number;
|
|
191
|
+
currency: string;
|
|
192
|
+
localizedPrice: string;
|
|
193
|
+
type: "subscription" | "consumable" | "non_consumable";
|
|
194
|
+
subscriptionPeriod?: string;
|
|
195
|
+
introductoryPrice?: string;
|
|
196
|
+
introductoryPriceValue?: number;
|
|
197
|
+
freeTrialPeriod?: string;
|
|
198
|
+
pricePerMonth?: string;
|
|
199
|
+
pricePerWeek?: string;
|
|
200
|
+
pricePerDay?: string;
|
|
201
|
+
savings?: string;
|
|
202
|
+
savingsPercent?: string;
|
|
203
|
+
}
|
|
204
|
+
interface Purchase {
|
|
205
|
+
productId: string;
|
|
206
|
+
transactionId: string;
|
|
207
|
+
transactionDate: number;
|
|
208
|
+
receipt: string;
|
|
209
|
+
platform: "ios" | "android";
|
|
210
|
+
}
|
|
211
|
+
interface PurchaseResult {
|
|
212
|
+
success: boolean;
|
|
213
|
+
purchase?: Purchase;
|
|
214
|
+
error?: Error;
|
|
215
|
+
}
|
|
216
|
+
interface ValidatePurchaseResponse {
|
|
217
|
+
success: boolean;
|
|
218
|
+
subscription: {
|
|
219
|
+
productId: string;
|
|
220
|
+
status: string;
|
|
221
|
+
expiresAt: string | null;
|
|
222
|
+
} | null;
|
|
223
|
+
error?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
type SubscriptionStatus$1 = "active" | "expired" | "in_billing_retry" | "in_grace_period" | "revoked" | "cancelled";
|
|
227
|
+
type SubscriptionPlatform = "ios" | "android";
|
|
228
|
+
interface Subscription {
|
|
229
|
+
productId: string;
|
|
230
|
+
status: SubscriptionStatus$1;
|
|
231
|
+
expiresAt: Date | null;
|
|
232
|
+
platform: SubscriptionPlatform;
|
|
233
|
+
autoRenewEnabled: boolean;
|
|
234
|
+
inGracePeriod: boolean;
|
|
235
|
+
}
|
|
236
|
+
interface SubscriptionStatusResponse$1 {
|
|
237
|
+
hasActiveSubscription: boolean;
|
|
238
|
+
subscription: Subscription | null;
|
|
239
|
+
}
|
|
240
|
+
interface RestoreResult {
|
|
241
|
+
success: boolean;
|
|
242
|
+
restoredProducts: string[];
|
|
243
|
+
error?: Error;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type Environment = "Production" | "Sandbox";
|
|
247
|
+
interface ApiClientConfig {
|
|
248
|
+
appKey: string;
|
|
249
|
+
baseUrl?: string;
|
|
250
|
+
debug?: boolean;
|
|
251
|
+
environment?: Environment;
|
|
252
|
+
offlineQueueEnabled?: boolean;
|
|
253
|
+
timeout?: number;
|
|
254
|
+
}
|
|
255
|
+
interface PaywalloConfig {
|
|
256
|
+
appKey: string;
|
|
257
|
+
baseUrl?: string;
|
|
258
|
+
debug?: boolean;
|
|
259
|
+
environment?: Environment;
|
|
260
|
+
}
|
|
261
|
+
interface UserProperties {
|
|
262
|
+
[key: string]: string | number | boolean | null;
|
|
263
|
+
}
|
|
264
|
+
interface IdentifyOptions {
|
|
265
|
+
email?: string;
|
|
266
|
+
properties?: UserProperties;
|
|
267
|
+
}
|
|
268
|
+
interface TrackEventOptions {
|
|
269
|
+
properties?: UserProperties;
|
|
270
|
+
timestamp?: number;
|
|
271
|
+
}
|
|
272
|
+
interface FlagVariant {
|
|
273
|
+
variant: string | null;
|
|
274
|
+
payload?: Record<string, unknown>;
|
|
275
|
+
}
|
|
276
|
+
interface ConditionalFlagResult {
|
|
277
|
+
value: boolean;
|
|
278
|
+
flagKey: string;
|
|
279
|
+
}
|
|
280
|
+
interface ConditionalFlagContext {
|
|
281
|
+
platform?: string;
|
|
282
|
+
appVersion?: string;
|
|
283
|
+
country?: string;
|
|
284
|
+
distinctId?: string;
|
|
285
|
+
}
|
|
286
|
+
interface AffiliateCoupon {
|
|
287
|
+
code: string;
|
|
288
|
+
status: string;
|
|
289
|
+
createdAt: Date;
|
|
290
|
+
}
|
|
291
|
+
interface AffiliateCommission {
|
|
292
|
+
id: string;
|
|
293
|
+
referredDistinctId: string;
|
|
294
|
+
purchaseAmount: number;
|
|
295
|
+
commissionAmount: number;
|
|
296
|
+
status: "pending" | "eligible" | "ineligible" | "withdrawn";
|
|
297
|
+
createdAt: Date;
|
|
298
|
+
}
|
|
299
|
+
interface AffiliateBalance {
|
|
300
|
+
total: number;
|
|
301
|
+
pending: number;
|
|
302
|
+
available: number;
|
|
303
|
+
withdrawn: number;
|
|
304
|
+
}
|
|
305
|
+
interface WithdrawalRequest {
|
|
306
|
+
id: string;
|
|
307
|
+
amount: number;
|
|
308
|
+
status: "pending" | "approved" | "rejected" | "paid";
|
|
309
|
+
createdAt: Date;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
interface PaywallModalProps {
|
|
313
|
+
placement: string;
|
|
314
|
+
visible: boolean;
|
|
315
|
+
onResult: (result: PaywallResult) => void;
|
|
316
|
+
paywallConfig?: {
|
|
317
|
+
id: string;
|
|
318
|
+
placement: string;
|
|
319
|
+
config: Record<string, unknown>;
|
|
320
|
+
primaryProductId?: string;
|
|
321
|
+
secondaryProductId?: string;
|
|
322
|
+
};
|
|
323
|
+
preloadedProducts?: Map<string, Product>;
|
|
324
|
+
variantKey?: string;
|
|
325
|
+
campaignId?: string;
|
|
326
|
+
}
|
|
327
|
+
declare function PaywallModal({ placement, visible, onResult, paywallConfig: preloadedConfig, preloadedProducts, variantKey, campaignId, }: PaywallModalProps): React__default.ReactElement | null;
|
|
328
|
+
|
|
329
|
+
interface PaywallContextValue {
|
|
330
|
+
nodes: Record<string, PaywallNode>;
|
|
331
|
+
rootId: string;
|
|
332
|
+
language: string;
|
|
333
|
+
defaultLanguage: string;
|
|
334
|
+
products: Map<string, Product>;
|
|
335
|
+
selectedProductId: string | null;
|
|
336
|
+
primaryProductId: string | null;
|
|
337
|
+
secondaryProductId: string | null;
|
|
338
|
+
currentNavigationIndex: number;
|
|
339
|
+
currentTabIndex: number;
|
|
340
|
+
trialEnabled: boolean;
|
|
341
|
+
selectedPeriod: string | null;
|
|
342
|
+
isPurchasing: boolean;
|
|
343
|
+
exitOfferVisible: boolean;
|
|
344
|
+
exitOfferTriggeredByBackButton: boolean;
|
|
345
|
+
onClose: () => void;
|
|
346
|
+
onTryClose: () => void;
|
|
347
|
+
onSelectProduct: (productId: string) => void;
|
|
348
|
+
onPurchase: (productId: string) => void;
|
|
349
|
+
onRestore: () => void;
|
|
350
|
+
onNavigate: (target: "next" | "previous" | "first" | "last" | number) => void;
|
|
351
|
+
onSetTab: (index: number) => void;
|
|
352
|
+
onSetVariable: (name: string, value: string) => void;
|
|
353
|
+
onToggleTrial: (enabled: boolean) => void;
|
|
354
|
+
onSelectPeriod: (value: string) => void;
|
|
355
|
+
onOpenUrl: (url: string, inBrowser?: boolean) => void;
|
|
356
|
+
onTapBehavior: (behavior: TapBehavior) => void;
|
|
357
|
+
onShowExitOffer: () => void;
|
|
358
|
+
onDismissExitOffer: () => void;
|
|
359
|
+
onTriggerBackButton: () => void;
|
|
360
|
+
}
|
|
361
|
+
declare const PaywallContext: React.Context<PaywallContextValue | null>;
|
|
362
|
+
declare function usePaywallContext(): PaywallContextValue;
|
|
363
|
+
|
|
364
|
+
interface PreloadResult {
|
|
365
|
+
success: boolean;
|
|
366
|
+
error?: Error;
|
|
367
|
+
}
|
|
368
|
+
interface PaywalloContextValue {
|
|
369
|
+
config: PaywalloConfig | null;
|
|
370
|
+
isInitialized: boolean;
|
|
371
|
+
initError: Error | null;
|
|
372
|
+
distinctId: string | null;
|
|
373
|
+
subscription: Subscription | null;
|
|
374
|
+
products: Map<string, Product>;
|
|
375
|
+
isLoadingProducts: boolean;
|
|
376
|
+
presentPaywall: (placement: string) => Promise<PaywallResult>;
|
|
377
|
+
presentCampaign: (placement: string, context?: Record<string, unknown>) => Promise<CampaignResult>;
|
|
378
|
+
preloadCampaign: (placement: string, context?: Record<string, unknown>) => Promise<PreloadResult>;
|
|
379
|
+
hasActiveSubscription: () => Promise<boolean>;
|
|
380
|
+
getSubscription: () => Promise<Subscription | null>;
|
|
381
|
+
restorePurchases: () => Promise<{
|
|
382
|
+
success: boolean;
|
|
383
|
+
error?: Error;
|
|
384
|
+
}>;
|
|
385
|
+
getPaywallConfig: (placement: string) => Promise<PaywallConfig | null>;
|
|
386
|
+
refreshProducts: (productIds: string[]) => Promise<void>;
|
|
387
|
+
}
|
|
388
|
+
declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
|
|
389
|
+
|
|
390
|
+
declare class PaywalloError extends Error {
|
|
391
|
+
readonly code: string;
|
|
392
|
+
readonly domain: string;
|
|
393
|
+
constructor(domain: string, code: string, message: string);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
declare class PaywallError extends PaywalloError {
|
|
397
|
+
constructor(code: string, message: string);
|
|
398
|
+
}
|
|
399
|
+
declare const PAYWALL_ERROR_CODES: {
|
|
400
|
+
readonly NOT_INITIALIZED: "PAYWALL_NOT_INITIALIZED";
|
|
401
|
+
readonly NOT_FOUND: "PAYWALL_NOT_FOUND";
|
|
402
|
+
readonly RENDER_FAILED: "PAYWALL_RENDER_FAILED";
|
|
403
|
+
readonly LOAD_FAILED: "PAYWALL_LOAD_FAILED";
|
|
404
|
+
readonly DISMISS_FAILED: "PAYWALL_DISMISS_FAILED";
|
|
405
|
+
readonly INVALID_CONFIG: "PAYWALL_INVALID_CONFIG";
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
interface RetryConfig {
|
|
409
|
+
maxRetries: number;
|
|
410
|
+
baseDelay: number;
|
|
411
|
+
maxDelay: number;
|
|
412
|
+
retryableStatusCodes: number[];
|
|
413
|
+
}
|
|
414
|
+
interface HttpClientConfig {
|
|
415
|
+
baseUrl: string;
|
|
416
|
+
timeout: number;
|
|
417
|
+
retry: RetryConfig;
|
|
418
|
+
debug: boolean;
|
|
419
|
+
}
|
|
420
|
+
interface RequestOptions {
|
|
421
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
422
|
+
headers?: Record<string, string>;
|
|
423
|
+
body?: unknown;
|
|
424
|
+
skipRetry?: boolean;
|
|
425
|
+
timeout?: number;
|
|
426
|
+
}
|
|
427
|
+
interface HttpResponse<T = unknown> {
|
|
428
|
+
ok: boolean;
|
|
429
|
+
status: number;
|
|
430
|
+
data: T;
|
|
431
|
+
headers: Record<string, string>;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare class HttpClient {
|
|
435
|
+
private config;
|
|
436
|
+
constructor(baseUrl: string, config?: Partial<Omit<HttpClientConfig, "baseUrl">>);
|
|
437
|
+
get<T>(path: string, options?: Partial<RequestOptions>): Promise<HttpResponse<T>>;
|
|
438
|
+
post<T>(path: string, body?: unknown, options?: Partial<RequestOptions>): Promise<HttpResponse<T>>;
|
|
439
|
+
request<T>(path: string, options: RequestOptions): Promise<HttpResponse<T>>;
|
|
440
|
+
private executeWithRetry;
|
|
441
|
+
private executeRequest;
|
|
442
|
+
private buildUrl;
|
|
443
|
+
private buildFetchOptions;
|
|
444
|
+
private shouldRetry;
|
|
445
|
+
private isNetworkError;
|
|
446
|
+
private calculateDelay;
|
|
447
|
+
private sleep;
|
|
448
|
+
private log;
|
|
449
|
+
setDebug(debug: boolean): void;
|
|
450
|
+
getConfig(): Readonly<HttpClientConfig>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare class ApiClient {
|
|
454
|
+
private baseUrl;
|
|
455
|
+
private webUrl;
|
|
456
|
+
private appKey;
|
|
457
|
+
private debug;
|
|
458
|
+
private environment;
|
|
459
|
+
private offlineQueueEnabled;
|
|
460
|
+
private httpClient;
|
|
461
|
+
private readonly cache;
|
|
462
|
+
constructor(appKey: string, baseUrl?: string, debug?: boolean, environment?: Environment, offlineQueueEnabled?: boolean, timeout?: number);
|
|
463
|
+
/** Exposed only for QueueProcessor initialization. Prefer get()/post() for requests. */
|
|
464
|
+
getHttpClient(): HttpClient;
|
|
465
|
+
getWebUrl(): string;
|
|
466
|
+
getEnvironment(): Environment;
|
|
467
|
+
getQueueSize(): number;
|
|
468
|
+
setofflineQueueEnabled(enabled: boolean): void;
|
|
469
|
+
isofflineQueueEnabled(): boolean;
|
|
470
|
+
setEnvironment(environment: Environment): void;
|
|
471
|
+
setDebug(debug: boolean): void;
|
|
472
|
+
clearQueue(): Promise<void>;
|
|
473
|
+
get<T>(path: string): Promise<HttpResponse<T>>;
|
|
474
|
+
post<T>(path: string, body: unknown, skipRetry?: boolean): Promise<HttpResponse<T>>;
|
|
475
|
+
reportError(errorType: string, message: string, context?: Record<string, unknown>): Promise<void>;
|
|
476
|
+
trackEvent(eventName: string, distinctId: string, properties?: UserProperties, timestamp?: number): Promise<void>;
|
|
477
|
+
identify(distinctId: string, properties?: UserProperties, email?: string): Promise<void>;
|
|
478
|
+
startSession(distinctId: string, sessionId: string, platform?: string): Promise<{
|
|
479
|
+
success: boolean;
|
|
480
|
+
}>;
|
|
481
|
+
endSession(sessionId: string, durationSeconds: number): Promise<{
|
|
482
|
+
success: boolean;
|
|
483
|
+
}>;
|
|
484
|
+
getVariant(flagKey: string, distinctId: string): Promise<FlagVariant>;
|
|
485
|
+
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
486
|
+
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
487
|
+
getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
488
|
+
validatePurchase(platform: "ios" | "android", receipt: string, productId: string, transactionId: string, priceLocal: number, currency: string, country: string, distinctId?: string, paywallPlacement?: string, variantKey?: string): Promise<ValidatePurchaseResponse>;
|
|
489
|
+
getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
|
|
490
|
+
getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
|
|
491
|
+
/**
|
|
492
|
+
* POST with offline queue fallback. Enqueues when offline or on network failure.
|
|
493
|
+
* Throws only when offlineQueueEnabled is false and the request fails.
|
|
494
|
+
*/
|
|
495
|
+
private postWithQueue;
|
|
496
|
+
private log;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
declare class AffiliateManager {
|
|
500
|
+
private apiClient;
|
|
501
|
+
private debug;
|
|
502
|
+
initialize(apiClient: ApiClient, debug?: boolean): void;
|
|
503
|
+
registerCoupon(code: string): Promise<{
|
|
504
|
+
success: boolean;
|
|
505
|
+
coupon?: AffiliateCoupon;
|
|
506
|
+
error?: string;
|
|
507
|
+
}>;
|
|
508
|
+
applyCoupon(code: string): Promise<{
|
|
509
|
+
success: boolean;
|
|
510
|
+
applied?: boolean;
|
|
511
|
+
error?: string;
|
|
512
|
+
}>;
|
|
513
|
+
getMyCoupon(): Promise<{
|
|
514
|
+
coupon: AffiliateCoupon | null;
|
|
515
|
+
}>;
|
|
516
|
+
getAppliedCoupon(): Promise<{
|
|
517
|
+
coupon: {
|
|
518
|
+
code: string;
|
|
519
|
+
} | null;
|
|
520
|
+
}>;
|
|
521
|
+
getBalance(): Promise<AffiliateBalance>;
|
|
522
|
+
getCommissions(): Promise<AffiliateCommission[]>;
|
|
523
|
+
requestWithdrawal(amount: number): Promise<{
|
|
524
|
+
success: boolean;
|
|
525
|
+
withdrawal?: WithdrawalRequest;
|
|
526
|
+
error?: string;
|
|
527
|
+
}>;
|
|
528
|
+
getWithdrawals(): Promise<WithdrawalRequest[]>;
|
|
529
|
+
private get;
|
|
530
|
+
private post;
|
|
531
|
+
private ensureInitialized;
|
|
532
|
+
private log;
|
|
533
|
+
}
|
|
534
|
+
declare const affiliateManager: AffiliateManager;
|
|
535
|
+
|
|
536
|
+
declare const PaywalloAffiliate: {
|
|
537
|
+
registerCoupon: (code: string) => Promise<{
|
|
538
|
+
success: boolean;
|
|
539
|
+
coupon?: AffiliateCoupon;
|
|
540
|
+
error?: string;
|
|
541
|
+
}>;
|
|
542
|
+
applyCoupon: (code: string) => Promise<{
|
|
543
|
+
success: boolean;
|
|
544
|
+
applied?: boolean;
|
|
545
|
+
error?: string;
|
|
546
|
+
}>;
|
|
547
|
+
getMyCoupon: () => Promise<{
|
|
548
|
+
coupon: AffiliateCoupon | null;
|
|
549
|
+
}>;
|
|
550
|
+
getAppliedCoupon: () => Promise<{
|
|
551
|
+
coupon: {
|
|
552
|
+
code: string;
|
|
553
|
+
} | null;
|
|
554
|
+
}>;
|
|
555
|
+
getBalance: () => Promise<AffiliateBalance>;
|
|
556
|
+
getCommissions: () => Promise<AffiliateCommission[]>;
|
|
557
|
+
requestWithdrawal: (amount: number) => Promise<{
|
|
558
|
+
success: boolean;
|
|
559
|
+
withdrawal?: WithdrawalRequest;
|
|
560
|
+
error?: string;
|
|
561
|
+
}>;
|
|
562
|
+
getWithdrawals: () => Promise<WithdrawalRequest[]>;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
declare class AffiliateError extends PaywalloError {
|
|
566
|
+
constructor(code: string, message: string);
|
|
567
|
+
}
|
|
568
|
+
declare const AFFILIATE_ERROR_CODES: {
|
|
569
|
+
readonly NOT_INITIALIZED: "AFFILIATE_NOT_INITIALIZED";
|
|
570
|
+
readonly COUPON_REGISTER_FAILED: "AFFILIATE_COUPON_REGISTER_FAILED";
|
|
571
|
+
readonly COUPON_APPLY_FAILED: "AFFILIATE_COUPON_APPLY_FAILED";
|
|
572
|
+
readonly BALANCE_FETCH_FAILED: "AFFILIATE_BALANCE_FETCH_FAILED";
|
|
573
|
+
readonly WITHDRAWAL_FAILED: "AFFILIATE_WITHDRAWAL_FAILED";
|
|
574
|
+
readonly NETWORK_ERROR: "AFFILIATE_NETWORK_ERROR";
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
declare class IAPService {
|
|
578
|
+
private productsCache;
|
|
579
|
+
private apiClient;
|
|
580
|
+
constructor(apiClient?: ApiClient);
|
|
581
|
+
private get debug();
|
|
582
|
+
private getDeviceCountry;
|
|
583
|
+
private getApiClient;
|
|
584
|
+
isAvailable(): boolean;
|
|
585
|
+
loadProducts(productIds: string[]): Promise<Product[]>;
|
|
586
|
+
getProduct(productId: string): Product | undefined;
|
|
587
|
+
getCachedProducts(): Map<string, Product>;
|
|
588
|
+
private validateWithServer;
|
|
589
|
+
private finishTransaction;
|
|
590
|
+
purchase(productId: string, options?: {
|
|
591
|
+
paywallPlacement?: string;
|
|
592
|
+
variantKey?: string;
|
|
593
|
+
}): Promise<PurchaseResult>;
|
|
594
|
+
restore(): Promise<Purchase[]>;
|
|
595
|
+
}
|
|
596
|
+
declare function getIAPService(): IAPService;
|
|
597
|
+
|
|
598
|
+
declare function isAvailable(): boolean;
|
|
599
|
+
declare const nativeStoreKit: {
|
|
600
|
+
isAvailable: typeof isAvailable;
|
|
601
|
+
getProducts(productIds: string[]): Promise<Product[]>;
|
|
602
|
+
purchase(productId: string): Promise<Purchase | null>;
|
|
603
|
+
finishTransaction(transactionId: string): Promise<void>;
|
|
604
|
+
getActiveTransactions(): Promise<Purchase[]>;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
type PurchaseState = "idle" | "loading" | "purchasing" | "restoring" | "error";
|
|
608
|
+
interface IAPProduct {
|
|
609
|
+
productId: string;
|
|
610
|
+
price: string;
|
|
611
|
+
currency: string;
|
|
612
|
+
localizedPrice: string;
|
|
613
|
+
title: string;
|
|
614
|
+
description: string;
|
|
615
|
+
type: "inapp" | "subs";
|
|
616
|
+
subscriptionPeriodAndroid?: string;
|
|
617
|
+
subscriptionPeriodNumberIOS?: string;
|
|
618
|
+
subscriptionPeriodUnitIOS?: string;
|
|
619
|
+
introductoryPrice?: string;
|
|
620
|
+
introductoryPricePaymentModeIOS?: string;
|
|
621
|
+
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
622
|
+
introductoryPriceSubscriptionPeriodIOS?: string;
|
|
623
|
+
freeTrialPeriodAndroid?: string;
|
|
624
|
+
}
|
|
625
|
+
interface IAPPurchase {
|
|
626
|
+
productId: string;
|
|
627
|
+
transactionId?: string;
|
|
628
|
+
transactionDate: number;
|
|
629
|
+
transactionReceipt: string;
|
|
630
|
+
purchaseToken?: string;
|
|
631
|
+
}
|
|
632
|
+
interface PurchaseControllerConfig {
|
|
633
|
+
debug?: boolean;
|
|
634
|
+
validateOnServer?: boolean;
|
|
635
|
+
serverValidationUrl?: string;
|
|
636
|
+
}
|
|
637
|
+
interface ProductPriceInfo {
|
|
638
|
+
price: string;
|
|
639
|
+
priceValue: number;
|
|
640
|
+
currency: string;
|
|
641
|
+
localizedPrice: string;
|
|
642
|
+
pricePerMonth?: string;
|
|
643
|
+
pricePerWeek?: string;
|
|
644
|
+
pricePerDay?: string;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
declare class PurchaseError extends PaywalloError {
|
|
648
|
+
readonly userCancelled: boolean;
|
|
649
|
+
constructor(code: string, message: string, userCancelled?: boolean);
|
|
650
|
+
}
|
|
651
|
+
declare const PURCHASE_ERROR_CODES: {
|
|
652
|
+
readonly NOT_INITIALIZED: "PURCHASE_NOT_INITIALIZED";
|
|
653
|
+
readonly PRODUCT_NOT_FOUND: "PRODUCT_NOT_FOUND";
|
|
654
|
+
readonly PURCHASE_FAILED: "PURCHASE_FAILED";
|
|
655
|
+
readonly RESTORE_FAILED: "RESTORE_FAILED";
|
|
656
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
657
|
+
readonly USER_CANCELLED: "USER_CANCELLED";
|
|
658
|
+
readonly NETWORK_ERROR: "PURCHASE_NETWORK_ERROR";
|
|
659
|
+
readonly STORE_ERROR: "PURCHASE_STORE_ERROR";
|
|
660
|
+
readonly PENDING_PURCHASE: "PURCHASE_PENDING";
|
|
661
|
+
readonly DEFERRED_PURCHASE: "PURCHASE_DEFERRED";
|
|
662
|
+
readonly STORE_NOT_AVAILABLE: "PURCHASE_STORE_NOT_AVAILABLE";
|
|
663
|
+
};
|
|
664
|
+
declare function createPurchaseError(code: keyof typeof PURCHASE_ERROR_CODES, message?: string): PurchaseError;
|
|
665
|
+
|
|
666
|
+
interface IdentityState {
|
|
667
|
+
deviceId: string;
|
|
668
|
+
email: string | null;
|
|
669
|
+
properties: UserProperties;
|
|
670
|
+
}
|
|
671
|
+
declare class IdentityManager {
|
|
672
|
+
private deviceId;
|
|
673
|
+
private email;
|
|
674
|
+
private properties;
|
|
675
|
+
private apiClient;
|
|
676
|
+
private secureStorage;
|
|
677
|
+
private debug;
|
|
678
|
+
private initialized;
|
|
679
|
+
initialize(apiClient: ApiClient, debug?: boolean): Promise<string>;
|
|
680
|
+
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
681
|
+
getDistinctId(): string;
|
|
682
|
+
getDeviceId(): string | null;
|
|
683
|
+
getEmail(): string | null;
|
|
684
|
+
getProperties(): UserProperties;
|
|
685
|
+
updateProperties(properties: UserProperties): Promise<void>;
|
|
686
|
+
reset(): Promise<void>;
|
|
687
|
+
getState(): IdentityState;
|
|
688
|
+
isSecureStorageAvailable(): boolean;
|
|
689
|
+
private loadPersistedState;
|
|
690
|
+
private ensureInitialized;
|
|
691
|
+
private log;
|
|
692
|
+
}
|
|
693
|
+
declare const identityManager: IdentityManager;
|
|
694
|
+
|
|
695
|
+
declare class IdentityError extends PaywalloError {
|
|
696
|
+
constructor(code: string, message: string);
|
|
697
|
+
}
|
|
698
|
+
declare const IDENTITY_ERROR_CODES: {
|
|
699
|
+
readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
|
|
700
|
+
readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
|
|
701
|
+
readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
|
|
702
|
+
readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
|
|
703
|
+
readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
type NetworkState = "online" | "offline" | "unknown";
|
|
707
|
+
type NetworkListener = (state: NetworkState) => void;
|
|
708
|
+
interface NetworkMonitorConfig {
|
|
709
|
+
debug: boolean;
|
|
710
|
+
checkInterval: number;
|
|
711
|
+
checkUrl: string;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
declare class NetworkMonitorClass {
|
|
715
|
+
private config;
|
|
716
|
+
private listeners;
|
|
717
|
+
private currentState;
|
|
718
|
+
private netInfoModule;
|
|
719
|
+
private netInfoSubscription;
|
|
720
|
+
private appStateSubscription;
|
|
721
|
+
private initialized;
|
|
722
|
+
private checkIntervalId;
|
|
723
|
+
initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
|
|
724
|
+
private setupNetInfoListener;
|
|
725
|
+
private setupFallbackDetection;
|
|
726
|
+
private setupAppStateListener;
|
|
727
|
+
private checkConnectivity;
|
|
728
|
+
private netInfoStateToNetworkState;
|
|
729
|
+
private updateState;
|
|
730
|
+
private notifyListeners;
|
|
731
|
+
isOnline(): boolean;
|
|
732
|
+
getState(): NetworkState;
|
|
733
|
+
isInitialized(): boolean;
|
|
734
|
+
addListener(listener: NetworkListener): () => void;
|
|
735
|
+
removeListener(listener: NetworkListener): void;
|
|
736
|
+
forceCheck(): Promise<NetworkState>;
|
|
737
|
+
dispose(): void;
|
|
738
|
+
private log;
|
|
739
|
+
setDebug(debug: boolean): void;
|
|
740
|
+
}
|
|
741
|
+
declare const networkMonitor: NetworkMonitorClass;
|
|
742
|
+
|
|
743
|
+
interface SessionState {
|
|
744
|
+
sessionId: string | null;
|
|
745
|
+
startedAt: Date | null;
|
|
746
|
+
isActive: boolean;
|
|
747
|
+
duration: number;
|
|
748
|
+
}
|
|
749
|
+
interface SessionConfig {
|
|
750
|
+
sessionTimeoutMs?: number;
|
|
751
|
+
trackAppState?: boolean;
|
|
752
|
+
}
|
|
753
|
+
type EmergencyPaywallHandler = (paywallId: string) => Promise<void>;
|
|
754
|
+
|
|
755
|
+
declare class SessionManager {
|
|
756
|
+
private sessionId;
|
|
757
|
+
private sessionStartedAt;
|
|
758
|
+
private appState;
|
|
759
|
+
private apiClient;
|
|
760
|
+
private debug;
|
|
761
|
+
private initialized;
|
|
762
|
+
private config;
|
|
763
|
+
private backgroundTimestamp;
|
|
764
|
+
private appStateSubscription;
|
|
765
|
+
private emergencyPaywallHandler;
|
|
766
|
+
private emergencyPaywallShownInSession;
|
|
767
|
+
private secureStorage;
|
|
768
|
+
initialize(apiClient: ApiClient, config?: SessionConfig, debug?: boolean): Promise<void>;
|
|
769
|
+
startSession(): Promise<string>;
|
|
770
|
+
endSession(): Promise<void>;
|
|
771
|
+
getSessionId(): string | null;
|
|
772
|
+
getSessionDuration(): number;
|
|
773
|
+
isSessionActive(): boolean;
|
|
774
|
+
getState(): SessionState;
|
|
775
|
+
destroy(): void;
|
|
776
|
+
registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
|
|
777
|
+
private restoreSession;
|
|
778
|
+
private setupAppStateListener;
|
|
779
|
+
private handleAppStateChange;
|
|
780
|
+
private handleForeground;
|
|
781
|
+
private handleBackground;
|
|
782
|
+
private checkEmergencyPaywall;
|
|
783
|
+
private trackSessionStart;
|
|
784
|
+
private trackSessionEnd;
|
|
785
|
+
private trackAppOpen;
|
|
786
|
+
private trackAppBackground;
|
|
787
|
+
private ensureInitialized;
|
|
788
|
+
private log;
|
|
789
|
+
}
|
|
790
|
+
declare const sessionManager: SessionManager;
|
|
791
|
+
|
|
792
|
+
declare class SessionError extends PaywalloError {
|
|
793
|
+
constructor(code: string, message: string);
|
|
794
|
+
}
|
|
795
|
+
declare const SESSION_ERROR_CODES: {
|
|
796
|
+
readonly NOT_INITIALIZED: "SESSION_NOT_INITIALIZED";
|
|
797
|
+
readonly START_FAILED: "SESSION_START_FAILED";
|
|
798
|
+
readonly END_FAILED: "SESSION_END_FAILED";
|
|
799
|
+
readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
interface PreloadCampaignResult {
|
|
803
|
+
success: boolean;
|
|
804
|
+
error?: Error;
|
|
805
|
+
}
|
|
806
|
+
interface PaywalloInitConfig extends PaywalloConfig {
|
|
807
|
+
sessionConfig?: SessionConfig;
|
|
808
|
+
autoStartSession?: boolean;
|
|
809
|
+
offlineQueueEnabled?: boolean;
|
|
810
|
+
timeout?: number;
|
|
811
|
+
/** Request ATT permission during init (iOS only). Default: false. */
|
|
812
|
+
requestATT?: boolean;
|
|
813
|
+
}
|
|
814
|
+
interface IPaywalloClient {
|
|
815
|
+
init(config: PaywalloInitConfig): Promise<void>;
|
|
816
|
+
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
817
|
+
track(eventName: string, options?: TrackEventOptions): Promise<void>;
|
|
818
|
+
getVariant(flagKey: string): Promise<FlagVariant>;
|
|
819
|
+
getConditionalFlag(flagKey: string, context?: Partial<ConditionalFlagContext>): Promise<boolean>;
|
|
820
|
+
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
821
|
+
presentPaywall(placement: string): Promise<PaywallResult>;
|
|
822
|
+
getCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
823
|
+
presentCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResult>;
|
|
824
|
+
hasActiveSubscription(): Promise<boolean>;
|
|
825
|
+
getSubscription(): Promise<Subscription | null>;
|
|
826
|
+
restorePurchases(): Promise<RestoreResult>;
|
|
827
|
+
requireSubscription(paywallPlacement?: string): Promise<boolean>;
|
|
828
|
+
requireSubscriptionWithCampaign(placement: string, context?: Record<string, unknown>): Promise<boolean>;
|
|
829
|
+
gateContent<T>(content: () => T | Promise<T>, paywallPlacement?: string): Promise<T | null>;
|
|
830
|
+
gateContentWithCampaign<T>(content: () => T | Promise<T>, placement: string, context?: Record<string, unknown>): Promise<T | null>;
|
|
831
|
+
preloadCampaign(placement: string, context?: Record<string, unknown>): Promise<PreloadCampaignResult>;
|
|
832
|
+
getPreloadedCampaign(placement: string): CampaignResponse | null;
|
|
833
|
+
reset(): Promise<void>;
|
|
834
|
+
fullReset(): Promise<void>;
|
|
835
|
+
getConfig(): PaywalloConfig | null;
|
|
836
|
+
getDistinctId(): string;
|
|
837
|
+
getDeviceId(): string | null;
|
|
838
|
+
getEmail(): string | null;
|
|
839
|
+
getEnvironment(): Environment;
|
|
840
|
+
setEnvironment(environment: Environment): void;
|
|
841
|
+
getApiClient(): ApiClient | null;
|
|
842
|
+
getWebUrl(): string | null;
|
|
843
|
+
getIdentityState(): IdentityState;
|
|
844
|
+
getSessionState(): SessionState;
|
|
845
|
+
getSessionId(): string | null;
|
|
846
|
+
startSession(): Promise<string>;
|
|
847
|
+
endSession(): Promise<void>;
|
|
848
|
+
registerPaywallPresenter(presenter: (placement: string) => Promise<PaywallResult>): void;
|
|
849
|
+
registerCampaignPresenter(presenter: (campaign: CampaignResponse) => Promise<CampaignResult>): void;
|
|
850
|
+
registerSubscriptionGetter(getter: () => Promise<Subscription | null>): void;
|
|
851
|
+
registerActiveChecker(checker: () => Promise<boolean>): void;
|
|
852
|
+
registerRestoreHandler(handler: () => Promise<RestoreResult>): void;
|
|
853
|
+
registerEmergencyPaywallHandler(handler: EmergencyPaywallHandler): void;
|
|
854
|
+
isOnline(): boolean;
|
|
855
|
+
getOfflineQueueSize(): number;
|
|
856
|
+
clearOfflineQueue(): Promise<void>;
|
|
857
|
+
processOfflineQueue(): Promise<{
|
|
858
|
+
processed: number;
|
|
859
|
+
failed: number;
|
|
860
|
+
}>;
|
|
861
|
+
onboardingStep(index: number, name: string): Promise<void>;
|
|
862
|
+
coreAction(actionName: string): Promise<void>;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
declare const PaywalloClient: IPaywalloClient;
|
|
866
|
+
|
|
867
|
+
interface QueueItem {
|
|
868
|
+
id: string;
|
|
869
|
+
method: "POST" | "PUT";
|
|
870
|
+
url: string;
|
|
871
|
+
body: unknown;
|
|
872
|
+
headers?: Record<string, string>;
|
|
873
|
+
timestamp: number;
|
|
874
|
+
attempts: number;
|
|
875
|
+
maxAttempts: number;
|
|
876
|
+
}
|
|
877
|
+
interface OfflineQueueConfig {
|
|
878
|
+
maxItems: number;
|
|
879
|
+
maxAge: number;
|
|
880
|
+
maxAttempts: number;
|
|
881
|
+
storageKey: string;
|
|
882
|
+
debug: boolean;
|
|
883
|
+
}
|
|
884
|
+
type QueueEventType = "item:added" | "item:removed" | "item:success" | "item:failed" | "item:evicted" | "processing:start" | "processing:end";
|
|
885
|
+
interface QueueEvent {
|
|
886
|
+
type: QueueEventType;
|
|
887
|
+
item?: QueueItem;
|
|
888
|
+
error?: Error;
|
|
889
|
+
queueSize: number;
|
|
890
|
+
}
|
|
891
|
+
type QueueListener = (event: QueueEvent) => void;
|
|
892
|
+
|
|
893
|
+
declare class OfflineQueueClass {
|
|
894
|
+
private config;
|
|
895
|
+
private queue;
|
|
896
|
+
private listeners;
|
|
897
|
+
private initialized;
|
|
898
|
+
private processing;
|
|
899
|
+
private processingLock;
|
|
900
|
+
private cleanupTimer;
|
|
901
|
+
initialize(config?: Partial<OfflineQueueConfig>): Promise<void>;
|
|
902
|
+
private loadFromStorage;
|
|
903
|
+
private saveToStorage;
|
|
904
|
+
private cleanupExpired;
|
|
905
|
+
enqueue(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>): Promise<QueueItem>;
|
|
906
|
+
private findDuplicateIndex;
|
|
907
|
+
dequeue(): Promise<QueueItem | null>;
|
|
908
|
+
removeItem(id: string): Promise<boolean>;
|
|
909
|
+
processQueue(processor: (item: QueueItem) => Promise<boolean | {
|
|
910
|
+
success: boolean;
|
|
911
|
+
permanent?: boolean;
|
|
912
|
+
}>, options?: {
|
|
913
|
+
delayBetweenItems?: number;
|
|
914
|
+
}): Promise<{
|
|
915
|
+
processed: number;
|
|
916
|
+
failed: number;
|
|
917
|
+
}>;
|
|
918
|
+
/** Returns true if the item was permanently removed (counted as failed). */
|
|
919
|
+
private handleItemFailure;
|
|
920
|
+
private sleep;
|
|
921
|
+
getQueue(): ReadonlyArray<QueueItem>;
|
|
922
|
+
getSize(): number;
|
|
923
|
+
isEmpty(): boolean;
|
|
924
|
+
isProcessing(): boolean;
|
|
925
|
+
clear(): Promise<void>;
|
|
926
|
+
clearItemsWithInvalidAppKey(validAppKey: string): Promise<number>;
|
|
927
|
+
addListener(listener: QueueListener): () => void;
|
|
928
|
+
removeListener(listener: QueueListener): void;
|
|
929
|
+
private emit;
|
|
930
|
+
private log;
|
|
931
|
+
setDebug(debug: boolean): void;
|
|
932
|
+
dispose(): void;
|
|
933
|
+
}
|
|
934
|
+
declare const offlineQueue: OfflineQueueClass;
|
|
935
|
+
|
|
936
|
+
interface QueueProcessorConfig {
|
|
937
|
+
debounceMs: number;
|
|
938
|
+
debug: boolean;
|
|
939
|
+
}
|
|
940
|
+
declare class QueueProcessorClass {
|
|
941
|
+
private config;
|
|
942
|
+
private httpClient;
|
|
943
|
+
private networkUnsubscribe;
|
|
944
|
+
private debounceTimeout;
|
|
945
|
+
private retryIntervalId;
|
|
946
|
+
private initialized;
|
|
947
|
+
initialize(httpClient: HttpClient, config?: Partial<QueueProcessorConfig>): void;
|
|
948
|
+
private scheduleProcessing;
|
|
949
|
+
processQueue(): Promise<{
|
|
950
|
+
processed: number;
|
|
951
|
+
failed: number;
|
|
952
|
+
}>;
|
|
953
|
+
private processItem;
|
|
954
|
+
enqueueIfOffline(method: "POST" | "PUT", url: string, body: unknown, headers?: Record<string, string>): Promise<{
|
|
955
|
+
queued: boolean;
|
|
956
|
+
item?: QueueItem;
|
|
957
|
+
}>;
|
|
958
|
+
getQueueSize(): number;
|
|
959
|
+
clearQueue(): Promise<void>;
|
|
960
|
+
dispose(): void;
|
|
961
|
+
private log;
|
|
962
|
+
setDebug(debug: boolean): void;
|
|
963
|
+
}
|
|
964
|
+
declare const queueProcessor: QueueProcessorClass;
|
|
965
|
+
|
|
966
|
+
declare class AnalyticsError extends PaywalloError {
|
|
967
|
+
constructor(code: string, message: string);
|
|
968
|
+
}
|
|
969
|
+
declare const ANALYTICS_ERROR_CODES: {
|
|
970
|
+
readonly NOT_INITIALIZED: "ANALYTICS_NOT_INITIALIZED";
|
|
971
|
+
readonly INVALID_STEP_INDEX: "ANALYTICS_INVALID_STEP_INDEX";
|
|
972
|
+
readonly INVALID_ACTION_NAME: "ANALYTICS_INVALID_ACTION_NAME";
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
declare class CampaignError extends PaywalloError {
|
|
976
|
+
constructor(code: string, message: string);
|
|
977
|
+
}
|
|
978
|
+
declare const CAMPAIGN_ERROR_CODES: {
|
|
979
|
+
readonly NOT_INITIALIZED: "CAMPAIGN_NOT_INITIALIZED";
|
|
980
|
+
readonly FETCH_FAILED: "CAMPAIGN_FETCH_FAILED";
|
|
981
|
+
readonly PRELOAD_FAILED: "CAMPAIGN_PRELOAD_FAILED";
|
|
982
|
+
readonly NOT_FOUND: "CAMPAIGN_NOT_FOUND";
|
|
983
|
+
readonly PRESENT_FAILED: "CAMPAIGN_PRESENT_FAILED";
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
declare function usePaywallo(): PaywalloContextValue;
|
|
987
|
+
|
|
988
|
+
interface FormattedProduct extends ProductPriceInfo {
|
|
989
|
+
productId: string;
|
|
990
|
+
title: string;
|
|
991
|
+
description: string;
|
|
992
|
+
subscriptionPeriod?: string;
|
|
993
|
+
introductoryPrice?: string;
|
|
994
|
+
freeTrialPeriod?: string;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
interface UseProductsResult {
|
|
998
|
+
products: IAPProduct[];
|
|
999
|
+
formattedProducts: FormattedProduct[];
|
|
1000
|
+
isLoading: boolean;
|
|
1001
|
+
error: Error | null;
|
|
1002
|
+
loadProducts: (productIds: string[]) => Promise<void>;
|
|
1003
|
+
getProduct: (productId: string) => IAPProduct | undefined;
|
|
1004
|
+
getFormattedProduct: (productId: string) => FormattedProduct | undefined;
|
|
1005
|
+
getPriceInfo: (productId: string) => ProductPriceInfo | undefined;
|
|
1006
|
+
}
|
|
1007
|
+
declare function useProducts(initialProductIds?: string[]): UseProductsResult;
|
|
1008
|
+
|
|
1009
|
+
interface UsePurchaseResult {
|
|
1010
|
+
state: PurchaseState;
|
|
1011
|
+
purchase: (productId: string) => Promise<IAPPurchase>;
|
|
1012
|
+
restore: () => Promise<IAPPurchase[]>;
|
|
1013
|
+
error: PurchaseError | null;
|
|
1014
|
+
isLoading: boolean;
|
|
1015
|
+
isPurchasing: boolean;
|
|
1016
|
+
isRestoring: boolean;
|
|
1017
|
+
}
|
|
1018
|
+
declare function usePurchase(): UsePurchaseResult;
|
|
1019
|
+
|
|
1020
|
+
type SubscriptionStatus = "active" | "expired" | "grace_period" | "billing_retry" | "canceled" | "paused" | "unknown";
|
|
1021
|
+
interface SubscriptionInfo {
|
|
1022
|
+
id: string;
|
|
1023
|
+
productId: string;
|
|
1024
|
+
status: SubscriptionStatus;
|
|
1025
|
+
expiresAt: Date;
|
|
1026
|
+
originalPurchaseDate: Date;
|
|
1027
|
+
latestPurchaseDate: Date;
|
|
1028
|
+
willRenew: boolean;
|
|
1029
|
+
isTrial: boolean;
|
|
1030
|
+
isIntroductoryPeriod: boolean;
|
|
1031
|
+
platform: "ios" | "android";
|
|
1032
|
+
storeTransactionId?: string;
|
|
1033
|
+
cancellationDate?: Date;
|
|
1034
|
+
gracePeriodExpiresAt?: Date;
|
|
1035
|
+
}
|
|
1036
|
+
interface SubscriptionStatusResponse {
|
|
1037
|
+
hasActiveSubscription: boolean;
|
|
1038
|
+
subscription: SubscriptionInfo | null;
|
|
1039
|
+
entitlements: string[];
|
|
1040
|
+
}
|
|
1041
|
+
interface CachedSubscription {
|
|
1042
|
+
data: SubscriptionStatusResponse;
|
|
1043
|
+
cachedAt: number;
|
|
1044
|
+
isStale: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
interface SubscriptionManagerConfig {
|
|
1047
|
+
cacheTTL?: number;
|
|
1048
|
+
serverUrl: string;
|
|
1049
|
+
appKey: string;
|
|
1050
|
+
debug?: boolean;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
interface UseSubscriptionResult {
|
|
1054
|
+
subscription: SubscriptionInfo | null;
|
|
1055
|
+
isActive: boolean;
|
|
1056
|
+
isLoading: boolean;
|
|
1057
|
+
error: Error | null;
|
|
1058
|
+
entitlements: string[];
|
|
1059
|
+
refresh: () => Promise<void>;
|
|
1060
|
+
restore: () => Promise<void>;
|
|
1061
|
+
}
|
|
1062
|
+
declare function useSubscription(): UseSubscriptionResult;
|
|
1063
|
+
|
|
1064
|
+
interface PaywalloProviderProps {
|
|
1065
|
+
children: React__default.ReactNode;
|
|
1066
|
+
config: PaywalloConfig;
|
|
1067
|
+
}
|
|
1068
|
+
declare function PaywalloProvider({ children, config }: PaywalloProviderProps): React__default.ReactElement;
|
|
1069
|
+
|
|
1070
|
+
declare class SubscriptionCache {
|
|
1071
|
+
private ttl;
|
|
1072
|
+
private memoryCache;
|
|
1073
|
+
private storage;
|
|
1074
|
+
constructor(ttl?: number);
|
|
1075
|
+
get(): Promise<CachedSubscription | null>;
|
|
1076
|
+
set(data: SubscriptionStatusResponse): Promise<void>;
|
|
1077
|
+
invalidate(): Promise<void>;
|
|
1078
|
+
private isExpired;
|
|
1079
|
+
setTTL(ttl: number): void;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
type SubscriptionListener = (subscription: SubscriptionStatusResponse) => void;
|
|
1083
|
+
declare class SubscriptionManagerClass {
|
|
1084
|
+
private config;
|
|
1085
|
+
private cache;
|
|
1086
|
+
private listeners;
|
|
1087
|
+
private userId;
|
|
1088
|
+
constructor();
|
|
1089
|
+
init(config: SubscriptionManagerConfig): void;
|
|
1090
|
+
setUserId(userId: string | null): void;
|
|
1091
|
+
hasActiveSubscription(forceRefresh?: boolean): Promise<boolean>;
|
|
1092
|
+
getSubscription(forceRefresh?: boolean): Promise<SubscriptionInfo | null>;
|
|
1093
|
+
getEntitlements(forceRefresh?: boolean): Promise<string[]>;
|
|
1094
|
+
getSubscriptionStatus(forceRefresh?: boolean): Promise<SubscriptionStatusResponse>;
|
|
1095
|
+
restorePurchases(): Promise<SubscriptionStatusResponse>;
|
|
1096
|
+
private fetchSubscriptionStatus;
|
|
1097
|
+
private getEmptyStatus;
|
|
1098
|
+
addListener(listener: SubscriptionListener): () => void;
|
|
1099
|
+
private notifyListeners;
|
|
1100
|
+
onPurchaseComplete(): Promise<void>;
|
|
1101
|
+
private log;
|
|
1102
|
+
}
|
|
1103
|
+
declare const subscriptionManager: SubscriptionManagerClass;
|
|
1104
|
+
|
|
1105
|
+
declare function setCurrentLanguage(language: string): void;
|
|
1106
|
+
declare function setDefaultLanguage(language: string): void;
|
|
1107
|
+
declare function getCurrentLanguage(): string;
|
|
1108
|
+
declare function getDefaultLanguage(): string;
|
|
1109
|
+
declare function getLocalizedString(text: string | LocalizedText | undefined): string;
|
|
1110
|
+
declare function detectDeviceLanguage(): string;
|
|
1111
|
+
declare function initLocalization(options?: {
|
|
1112
|
+
defaultLanguage?: string;
|
|
1113
|
+
detectDevice?: boolean;
|
|
1114
|
+
}): void;
|
|
1115
|
+
|
|
1116
|
+
interface VariableContext {
|
|
1117
|
+
selectedProductId?: string;
|
|
1118
|
+
primaryProductId?: string;
|
|
1119
|
+
secondaryProductId?: string;
|
|
1120
|
+
products: Map<string, Product>;
|
|
1121
|
+
customVariables?: Record<string, string>;
|
|
1122
|
+
deviceInfo?: {
|
|
1123
|
+
name?: string;
|
|
1124
|
+
model?: string;
|
|
1125
|
+
os?: string;
|
|
1126
|
+
osVersion?: string;
|
|
1127
|
+
locale?: string;
|
|
1128
|
+
};
|
|
1129
|
+
userInfo?: {
|
|
1130
|
+
id?: string;
|
|
1131
|
+
name?: string;
|
|
1132
|
+
email?: string;
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
declare function resolveText(text: string, context: VariableContext): string;
|
|
1136
|
+
declare function parseVariables(text: string): string[];
|
|
1137
|
+
declare function hasVariables(text: string): boolean;
|
|
1138
|
+
|
|
1139
|
+
declare const Paywallo: IPaywalloClient;
|
|
1140
|
+
|
|
1141
|
+
export { AFFILIATE_ERROR_CODES, ANALYTICS_ERROR_CODES, type AffiliateBalance, type AffiliateCommission, type AffiliateCoupon, AffiliateError, AffiliateManager, AnalyticsError, ApiClient, type ApiClientConfig, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, PURCHASE_ERROR_CODES as ERROR_CODES, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type OfflineQueueConfig, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloAffiliate, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, type WithdrawalRequest, affiliateManager, createPurchaseError, Paywallo as default, detectDeviceLanguage, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, nativeStoreKit, networkMonitor, offlineQueue, parseVariables, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, usePaywallContext, usePaywallo, useProducts, usePurchase, useSubscription };
|