@ridwan-retainer/paywall 0.1.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/README.md +64 -0
- package/dist/__mocks__/async-storage.d.ts +12 -0
- package/dist/__mocks__/async-storage.d.ts.map +1 -0
- package/dist/__mocks__/async-storage.js +14 -0
- package/dist/__mocks__/react-native-purchases-ui.d.ts +17 -0
- package/dist/__mocks__/react-native-purchases-ui.d.ts.map +1 -0
- package/dist/__mocks__/react-native-purchases-ui.js +16 -0
- package/dist/__mocks__/react-native-purchases.d.ts +22 -0
- package/dist/__mocks__/react-native-purchases.d.ts.map +1 -0
- package/dist/__mocks__/react-native-purchases.js +25 -0
- package/dist/components/Paywall.d.ts +13 -0
- package/dist/components/Paywall.d.ts.map +1 -0
- package/dist/components/Paywall.js +18 -0
- package/dist/components/PaywallFooter.d.ts +13 -0
- package/dist/components/PaywallFooter.d.ts.map +1 -0
- package/dist/components/PaywallFooter.js +60 -0
- package/dist/components/PaywallGate.d.ts +12 -0
- package/dist/components/PaywallGate.d.ts.map +1 -0
- package/dist/components/PaywallGate.js +66 -0
- package/dist/components/PurchaseButton.d.ts +13 -0
- package/dist/components/PurchaseButton.d.ts.map +1 -0
- package/dist/components/PurchaseButton.js +30 -0
- package/dist/components/RestoreButton.d.ts +16 -0
- package/dist/components/RestoreButton.d.ts.map +1 -0
- package/dist/components/RestoreButton.js +35 -0
- package/dist/components/SubscriptionGate.d.ts +14 -0
- package/dist/components/SubscriptionGate.d.ts.map +1 -0
- package/dist/components/SubscriptionGate.js +22 -0
- package/dist/config/RevenueCatConfig.d.ts +4 -0
- package/dist/config/RevenueCatConfig.d.ts.map +1 -0
- package/dist/config/RevenueCatConfig.js +61 -0
- package/dist/config/environment.d.ts +3 -0
- package/dist/config/environment.d.ts.map +1 -0
- package/dist/config/environment.js +16 -0
- package/dist/config/types.d.ts +16 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/entitlements/CustomerInfoManager.d.ts +14 -0
- package/dist/entitlements/CustomerInfoManager.d.ts.map +1 -0
- package/dist/entitlements/CustomerInfoManager.js +59 -0
- package/dist/entitlements/EntitlementCache.d.ts +5 -0
- package/dist/entitlements/EntitlementCache.d.ts.map +1 -0
- package/dist/entitlements/EntitlementCache.js +39 -0
- package/dist/entitlements/subscriptionUtils.d.ts +10 -0
- package/dist/entitlements/subscriptionUtils.d.ts.map +1 -0
- package/dist/entitlements/subscriptionUtils.js +34 -0
- package/dist/entitlements/types.d.ts +13 -0
- package/dist/entitlements/types.d.ts.map +1 -0
- package/dist/entitlements/types.js +2 -0
- package/dist/hooks/useCurrentOffering.d.ts +11 -0
- package/dist/hooks/useCurrentOffering.d.ts.map +1 -0
- package/dist/hooks/useCurrentOffering.js +46 -0
- package/dist/hooks/useCustomerInfo.d.ts +8 -0
- package/dist/hooks/useCustomerInfo.d.ts.map +1 -0
- package/dist/hooks/useCustomerInfo.js +34 -0
- package/dist/hooks/useEntitlement.d.ts +10 -0
- package/dist/hooks/useEntitlement.d.ts.map +1 -0
- package/dist/hooks/useEntitlement.js +48 -0
- package/dist/hooks/useOfferings.d.ts +9 -0
- package/dist/hooks/useOfferings.d.ts.map +1 -0
- package/dist/hooks/useOfferings.js +58 -0
- package/dist/hooks/usePaywall.d.ts +6 -0
- package/dist/hooks/usePaywall.d.ts.map +1 -0
- package/dist/hooks/usePaywall.js +23 -0
- package/dist/hooks/usePurchase.d.ts +14 -0
- package/dist/hooks/usePurchase.d.ts.map +1 -0
- package/dist/hooks/usePurchase.js +48 -0
- package/dist/hooks/useRestorePurchases.d.ts +14 -0
- package/dist/hooks/useRestorePurchases.d.ts.map +1 -0
- package/dist/hooks/useRestorePurchases.js +48 -0
- package/dist/hooks/useRevenueCatInitialization.d.ts +5 -0
- package/dist/hooks/useRevenueCatInitialization.d.ts.map +1 -0
- package/dist/hooks/useRevenueCatInitialization.js +44 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/offerings/OfferingsManager.d.ts +12 -0
- package/dist/offerings/OfferingsManager.d.ts.map +1 -0
- package/dist/offerings/OfferingsManager.js +44 -0
- package/dist/offerings/packageUtils.d.ts +11 -0
- package/dist/offerings/packageUtils.d.ts.map +1 -0
- package/dist/offerings/packageUtils.js +44 -0
- package/dist/offerings/types.d.ts +8 -0
- package/dist/offerings/types.d.ts.map +1 -0
- package/dist/offerings/types.js +2 -0
- package/dist/paywall/PaywallController.d.ts +21 -0
- package/dist/paywall/PaywallController.d.ts.map +1 -0
- package/dist/paywall/PaywallController.js +61 -0
- package/dist/paywall/types.d.ts +60 -0
- package/dist/paywall/types.d.ts.map +1 -0
- package/dist/paywall/types.js +10 -0
- package/dist/purchase/PurchaseManager.d.ts +10 -0
- package/dist/purchase/PurchaseManager.d.ts.map +1 -0
- package/dist/purchase/PurchaseManager.js +45 -0
- package/dist/purchase/errorHandling.d.ts +5 -0
- package/dist/purchase/errorHandling.d.ts.map +1 -0
- package/dist/purchase/errorHandling.js +36 -0
- package/dist/purchase/purchaseCache.d.ts +19 -0
- package/dist/purchase/purchaseCache.d.ts.map +1 -0
- package/dist/purchase/purchaseCache.js +57 -0
- package/dist/purchase/types.d.ts +23 -0
- package/dist/purchase/types.d.ts.map +1 -0
- package/dist/purchase/types.js +11 -0
- package/dist/restore/RestoreManager.d.ts +26 -0
- package/dist/restore/RestoreManager.d.ts.map +1 -0
- package/dist/restore/RestoreManager.js +72 -0
- package/dist/restore/autoRestore.d.ts +13 -0
- package/dist/restore/autoRestore.d.ts.map +1 -0
- package/dist/restore/autoRestore.js +37 -0
- package/dist/restore/errorHandling.d.ts +10 -0
- package/dist/restore/errorHandling.d.ts.map +1 -0
- package/dist/restore/errorHandling.js +30 -0
- package/dist/restore/types.d.ts +22 -0
- package/dist/restore/types.d.ts.map +1 -0
- package/dist/restore/types.js +11 -0
- package/package.json +60 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cachePurchaseAttempt = cachePurchaseAttempt;
|
|
7
|
+
exports.getLastPurchaseAttempt = getLastPurchaseAttempt;
|
|
8
|
+
exports.clearPurchaseAttempt = clearPurchaseAttempt;
|
|
9
|
+
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
10
|
+
const PURCHASE_ATTEMPT_KEY = '@paywall/purchase-attempt';
|
|
11
|
+
/**
|
|
12
|
+
* Cache last purchase attempt for retry on network failure
|
|
13
|
+
*/
|
|
14
|
+
async function cachePurchaseAttempt(pkg) {
|
|
15
|
+
try {
|
|
16
|
+
const attempt = {
|
|
17
|
+
packageIdentifier: pkg.identifier,
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
};
|
|
20
|
+
await async_storage_1.default.setItem(PURCHASE_ATTEMPT_KEY, JSON.stringify(attempt));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.warn('[PurchaseCache] Failed to cache purchase attempt:', error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get last purchase attempt
|
|
28
|
+
*/
|
|
29
|
+
async function getLastPurchaseAttempt() {
|
|
30
|
+
try {
|
|
31
|
+
const cached = await async_storage_1.default.getItem(PURCHASE_ATTEMPT_KEY);
|
|
32
|
+
if (!cached)
|
|
33
|
+
return null;
|
|
34
|
+
const attempt = JSON.parse(cached);
|
|
35
|
+
// Only return if attempt is less than 5 minutes old
|
|
36
|
+
const fiveMinutes = 5 * 60 * 1000;
|
|
37
|
+
if (Date.now() - attempt.timestamp < fiveMinutes) {
|
|
38
|
+
return attempt;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.warn('[PurchaseCache] Failed to get purchase attempt:', error);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear purchase attempt cache
|
|
49
|
+
*/
|
|
50
|
+
async function clearPurchaseAttempt() {
|
|
51
|
+
try {
|
|
52
|
+
await async_storage_1.default.removeItem(PURCHASE_ATTEMPT_KEY);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.warn('[PurchaseCache] Failed to clear purchase attempt:', error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CustomerInfo } from 'react-native-purchases';
|
|
2
|
+
export interface PurchaseResult {
|
|
3
|
+
customerInfo: CustomerInfo;
|
|
4
|
+
productIdentifier: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PurchaseError {
|
|
7
|
+
message: string;
|
|
8
|
+
userCancelled: boolean;
|
|
9
|
+
code?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare enum PurchaseState {
|
|
12
|
+
IDLE = "IDLE",
|
|
13
|
+
PURCHASING = "PURCHASING",
|
|
14
|
+
SUCCESS = "SUCCESS",
|
|
15
|
+
ERROR = "ERROR",
|
|
16
|
+
CANCELLED = "CANCELLED"
|
|
17
|
+
}
|
|
18
|
+
export interface PurchaseStatus {
|
|
19
|
+
state: PurchaseState;
|
|
20
|
+
error: PurchaseError | null;
|
|
21
|
+
customerInfo: CustomerInfo | null;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/purchase/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,SAAS,cAAc;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CACnC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PurchaseState = void 0;
|
|
4
|
+
var PurchaseState;
|
|
5
|
+
(function (PurchaseState) {
|
|
6
|
+
PurchaseState["IDLE"] = "IDLE";
|
|
7
|
+
PurchaseState["PURCHASING"] = "PURCHASING";
|
|
8
|
+
PurchaseState["SUCCESS"] = "SUCCESS";
|
|
9
|
+
PurchaseState["ERROR"] = "ERROR";
|
|
10
|
+
PurchaseState["CANCELLED"] = "CANCELLED";
|
|
11
|
+
})(PurchaseState || (exports.PurchaseState = PurchaseState = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CustomerInfo } from 'react-native-purchases';
|
|
2
|
+
import type { RestoreResult } from './types';
|
|
3
|
+
export declare class RestoreManager {
|
|
4
|
+
/**
|
|
5
|
+
* Restore purchases from App Store / Play Store
|
|
6
|
+
* Official docs: https://www.revenuecat.com/docs/getting-started/restoring-purchases
|
|
7
|
+
*
|
|
8
|
+
* From docs: "Reactivates previously purchased content.
|
|
9
|
+
* May trigger OS-level sign-in prompts."
|
|
10
|
+
*/
|
|
11
|
+
restorePurchases(): Promise<RestoreResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Sync purchases programmatically (no OS prompts)
|
|
14
|
+
* Official docs: https://www.revenuecat.com/docs/getting-started/restoring-purchases
|
|
15
|
+
*
|
|
16
|
+
* From docs: "Used for programmatic restoration without user interaction
|
|
17
|
+
* and without OS prompts. Respects logged-in user's ID."
|
|
18
|
+
*/
|
|
19
|
+
syncPurchases(): Promise<CustomerInfo>;
|
|
20
|
+
/**
|
|
21
|
+
* Handle restore errors
|
|
22
|
+
*/
|
|
23
|
+
private handleRestoreError;
|
|
24
|
+
}
|
|
25
|
+
export declare const restoreManager: RestoreManager;
|
|
26
|
+
//# sourceMappingURL=RestoreManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestoreManager.d.ts","sourceRoot":"","sources":["../../src/restore/RestoreManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,SAAS,CAAC;AAG3D,qBAAa,cAAc;IACzB;;;;;;OAMG;IACG,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAoBhD;;;;;;OAMG;IACG,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAiB5C;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAa3B;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.restoreManager = exports.RestoreManager = void 0;
|
|
7
|
+
const react_native_purchases_1 = __importDefault(require("react-native-purchases"));
|
|
8
|
+
const CustomerInfoManager_1 = require("../entitlements/CustomerInfoManager");
|
|
9
|
+
class RestoreManager {
|
|
10
|
+
/**
|
|
11
|
+
* Restore purchases from App Store / Play Store
|
|
12
|
+
* Official docs: https://www.revenuecat.com/docs/getting-started/restoring-purchases
|
|
13
|
+
*
|
|
14
|
+
* From docs: "Reactivates previously purchased content.
|
|
15
|
+
* May trigger OS-level sign-in prompts."
|
|
16
|
+
*/
|
|
17
|
+
async restorePurchases() {
|
|
18
|
+
try {
|
|
19
|
+
// Official restore method
|
|
20
|
+
const customerInfo = await react_native_purchases_1.default.restorePurchases();
|
|
21
|
+
// Clear cache to force refresh with restored purchases
|
|
22
|
+
CustomerInfoManager_1.customerInfoManager.clearCache();
|
|
23
|
+
// Check if any entitlements were restored
|
|
24
|
+
const hasActiveEntitlements = Object.keys(customerInfo.entitlements.active).length > 0;
|
|
25
|
+
return {
|
|
26
|
+
customerInfo,
|
|
27
|
+
entitlementsRestored: hasActiveEntitlements,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw this.handleRestoreError(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sync purchases programmatically (no OS prompts)
|
|
36
|
+
* Official docs: https://www.revenuecat.com/docs/getting-started/restoring-purchases
|
|
37
|
+
*
|
|
38
|
+
* From docs: "Used for programmatic restoration without user interaction
|
|
39
|
+
* and without OS prompts. Respects logged-in user's ID."
|
|
40
|
+
*/
|
|
41
|
+
async syncPurchases() {
|
|
42
|
+
try {
|
|
43
|
+
// Sync purchases for current logged-in user
|
|
44
|
+
await react_native_purchases_1.default.syncPurchases();
|
|
45
|
+
// Get updated customer info
|
|
46
|
+
const customerInfo = await react_native_purchases_1.default.getCustomerInfo();
|
|
47
|
+
// Clear cache
|
|
48
|
+
CustomerInfoManager_1.customerInfoManager.clearCache();
|
|
49
|
+
return customerInfo;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw this.handleRestoreError(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handle restore errors
|
|
57
|
+
*/
|
|
58
|
+
handleRestoreError(error) {
|
|
59
|
+
const err = error;
|
|
60
|
+
const restoreError = {
|
|
61
|
+
message: err.message || 'Failed to restore purchases',
|
|
62
|
+
code: err.code,
|
|
63
|
+
};
|
|
64
|
+
if (__DEV__) {
|
|
65
|
+
console.error('[RestoreManager] Restore error:', restoreError);
|
|
66
|
+
}
|
|
67
|
+
return restoreError;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.RestoreManager = RestoreManager;
|
|
71
|
+
// Singleton instance
|
|
72
|
+
exports.restoreManager = new RestoreManager();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatically sync purchases when user signs in
|
|
3
|
+
* Use syncPurchases() to avoid OS prompts
|
|
4
|
+
*
|
|
5
|
+
* Note: This should be called by auth integration, not in this package directly
|
|
6
|
+
*/
|
|
7
|
+
export declare function syncPurchasesOnSignIn(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Automatically sync purchases when app becomes active
|
|
10
|
+
* Useful for detecting external purchases (e.g., from App Store listing)
|
|
11
|
+
*/
|
|
12
|
+
export declare function syncPurchasesOnAppActive(): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=autoRestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoRestore.d.ts","sourceRoot":"","sources":["../../src/restore/autoRestore.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAS3D;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAS9D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncPurchasesOnSignIn = syncPurchasesOnSignIn;
|
|
4
|
+
exports.syncPurchasesOnAppActive = syncPurchasesOnAppActive;
|
|
5
|
+
const RestoreManager_1 = require("./RestoreManager");
|
|
6
|
+
/**
|
|
7
|
+
* Automatically sync purchases when user signs in
|
|
8
|
+
* Use syncPurchases() to avoid OS prompts
|
|
9
|
+
*
|
|
10
|
+
* Note: This should be called by auth integration, not in this package directly
|
|
11
|
+
*/
|
|
12
|
+
async function syncPurchasesOnSignIn() {
|
|
13
|
+
try {
|
|
14
|
+
await RestoreManager_1.restoreManager.syncPurchases();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// Log error but don't throw - sign-in should succeed even if sync fails
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
console.warn('[AutoRestore] Failed to sync purchases on sign-in:', error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Automatically sync purchases when app becomes active
|
|
25
|
+
* Useful for detecting external purchases (e.g., from App Store listing)
|
|
26
|
+
*/
|
|
27
|
+
async function syncPurchasesOnAppActive() {
|
|
28
|
+
try {
|
|
29
|
+
await RestoreManager_1.restoreManager.syncPurchases();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
// Silent fail - don't interrupt user
|
|
33
|
+
if (__DEV__) {
|
|
34
|
+
console.warn('[AutoRestore] Failed to sync purchases on app active:', error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RestoreError } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get user-friendly error message for restore failures
|
|
4
|
+
*/
|
|
5
|
+
export declare function getRestoreErrorMessage(error: RestoreError): string;
|
|
6
|
+
/**
|
|
7
|
+
* Check if restore error is recoverable
|
|
8
|
+
*/
|
|
9
|
+
export declare function isRecoverableRestoreError(error: RestoreError): boolean;
|
|
10
|
+
//# sourceMappingURL=errorHandling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/restore/errorHandling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAelE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOtE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRestoreErrorMessage = getRestoreErrorMessage;
|
|
4
|
+
exports.isRecoverableRestoreError = isRecoverableRestoreError;
|
|
5
|
+
/**
|
|
6
|
+
* Get user-friendly error message for restore failures
|
|
7
|
+
*/
|
|
8
|
+
function getRestoreErrorMessage(error) {
|
|
9
|
+
switch (error.code) {
|
|
10
|
+
case 'NETWORK_ERROR':
|
|
11
|
+
return 'Network connection error. Please check your internet and try again.';
|
|
12
|
+
case 'INVALID_CREDENTIALS':
|
|
13
|
+
return 'Unable to verify your account. Please sign in and try again.';
|
|
14
|
+
case 'STORE_PROBLEM':
|
|
15
|
+
return 'There was a problem connecting to the App Store. Please try again later.';
|
|
16
|
+
case 'UNKNOWN':
|
|
17
|
+
default:
|
|
18
|
+
return error.message || 'Failed to restore purchases. Please try again.';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if restore error is recoverable
|
|
23
|
+
*/
|
|
24
|
+
function isRecoverableRestoreError(error) {
|
|
25
|
+
const recoverableCodes = [
|
|
26
|
+
'NETWORK_ERROR',
|
|
27
|
+
'UNKNOWN',
|
|
28
|
+
];
|
|
29
|
+
return recoverableCodes.includes(error.code || '');
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CustomerInfo } from 'react-native-purchases';
|
|
2
|
+
export interface RestoreResult {
|
|
3
|
+
customerInfo: CustomerInfo;
|
|
4
|
+
entitlementsRestored: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface RestoreError {
|
|
7
|
+
message: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare enum RestoreState {
|
|
11
|
+
IDLE = "IDLE",
|
|
12
|
+
RESTORING = "RESTORING",
|
|
13
|
+
SUCCESS = "SUCCESS",
|
|
14
|
+
ERROR = "ERROR",
|
|
15
|
+
NO_PURCHASES = "NO_PURCHASES"
|
|
16
|
+
}
|
|
17
|
+
export interface RestoreStatus {
|
|
18
|
+
state: RestoreState;
|
|
19
|
+
error: RestoreError | null;
|
|
20
|
+
customerInfo: CustomerInfo | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/restore/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CACnC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestoreState = void 0;
|
|
4
|
+
var RestoreState;
|
|
5
|
+
(function (RestoreState) {
|
|
6
|
+
RestoreState["IDLE"] = "IDLE";
|
|
7
|
+
RestoreState["RESTORING"] = "RESTORING";
|
|
8
|
+
RestoreState["SUCCESS"] = "SUCCESS";
|
|
9
|
+
RestoreState["ERROR"] = "ERROR";
|
|
10
|
+
RestoreState["NO_PURCHASES"] = "NO_PURCHASES";
|
|
11
|
+
})(RestoreState || (exports.RestoreState = RestoreState = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ridwan-retainer/paywall",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Revenue-first monetization layer using RevenueCat for in-app purchases and subscriptions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/RidwanHamid501/app-factory.git",
|
|
15
|
+
"directory": "packages/paywall"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"test:watch": "jest --watch",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
24
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
25
|
+
"typecheck": "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@react-native-async-storage/async-storage": "^2.1.0",
|
|
29
|
+
"react-native-purchases": "^9.10.5",
|
|
30
|
+
"react-native-purchases-ui": "^9.10.5"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=19.0.0",
|
|
34
|
+
"react-native": ">=0.78.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@testing-library/react-native": "^13.3.3",
|
|
38
|
+
"@types/jest": "^30.0.0",
|
|
39
|
+
"@types/react": "^19.0.0",
|
|
40
|
+
"@types/react-native": "^0.73.0",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
42
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"react": "^19.0.0",
|
|
46
|
+
"react-native": "^0.73.0",
|
|
47
|
+
"react-test-renderer": "^19.1.0",
|
|
48
|
+
"ts-jest": "^29.4.6",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"typescript-eslint": "^8.55.0"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"revenuecat",
|
|
54
|
+
"subscriptions",
|
|
55
|
+
"in-app-purchases",
|
|
56
|
+
"paywall",
|
|
57
|
+
"monetization"
|
|
58
|
+
],
|
|
59
|
+
"license": "MIT"
|
|
60
|
+
}
|