@entitlehub/react-native 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/package.json +21 -6
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ async function getProducts(productIds, type = "all") {
|
|
|
73
73
|
async function purchaseProduct(productId, opts = {}) {
|
|
74
74
|
const I = iap();
|
|
75
75
|
const isSub = Boolean(opts.isSubscription);
|
|
76
|
+
const isConsumable = Boolean(opts.isConsumable) && !isSub;
|
|
76
77
|
const request = { apple: { sku: productId }, google: { skus: [productId] } };
|
|
77
78
|
if (isSub) {
|
|
78
79
|
try {
|
|
@@ -104,7 +105,7 @@ async function purchaseProduct(productId, opts = {}) {
|
|
|
104
105
|
try {
|
|
105
106
|
const info = await reportToEntitleHub(purchase, productId, isSub);
|
|
106
107
|
try {
|
|
107
|
-
await I.finishTransaction({ purchase, isConsumable
|
|
108
|
+
await I.finishTransaction({ purchase, isConsumable });
|
|
108
109
|
} catch {
|
|
109
110
|
}
|
|
110
111
|
resolve(info);
|
|
@@ -143,7 +144,7 @@ function addCustomerInfoUpdateListener(fn) {
|
|
|
143
144
|
return eh().addCustomerInfoUpdateListener(fn);
|
|
144
145
|
}
|
|
145
146
|
async function reportToEntitleHub(purchase, productId, isSubscription) {
|
|
146
|
-
const jws = purchase?.jwsRepresentation ?? purchase?.jwsRepresentationIos;
|
|
147
|
+
const jws = purchase?.jwsRepresentation ?? purchase?.jwsRepresentationIos ?? (String(purchase?.platform).toLowerCase() === "ios" ? purchase?.purchaseToken : void 0);
|
|
147
148
|
if (jws) return eh().reportPurchase({ signedTransaction: jws });
|
|
148
149
|
const token = purchase?.purchaseTokenAndroid ?? purchase?.purchaseToken;
|
|
149
150
|
if (token) {
|
package/dist/index.d.cts
CHANGED
|
@@ -41,6 +41,7 @@ declare function getProducts(productIds: string[], type?: "in-app" | "subs" | "a
|
|
|
41
41
|
*/
|
|
42
42
|
declare function purchaseProduct(productId: string, opts?: {
|
|
43
43
|
isSubscription?: boolean;
|
|
44
|
+
isConsumable?: boolean;
|
|
44
45
|
}): Promise<CustomerInfo>;
|
|
45
46
|
/** Restore the user's purchases: re-validate each with EntitleHub, then return entitlements. */
|
|
46
47
|
declare function restorePurchases(): Promise<CustomerInfo>;
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ declare function getProducts(productIds: string[], type?: "in-app" | "subs" | "a
|
|
|
41
41
|
*/
|
|
42
42
|
declare function purchaseProduct(productId: string, opts?: {
|
|
43
43
|
isSubscription?: boolean;
|
|
44
|
+
isConsumable?: boolean;
|
|
44
45
|
}): Promise<CustomerInfo>;
|
|
45
46
|
/** Restore the user's purchases: re-validate each with EntitleHub, then return entitlements. */
|
|
46
47
|
declare function restorePurchases(): Promise<CustomerInfo>;
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ async function getProducts(productIds, type = "all") {
|
|
|
48
48
|
async function purchaseProduct(productId, opts = {}) {
|
|
49
49
|
const I = iap();
|
|
50
50
|
const isSub = Boolean(opts.isSubscription);
|
|
51
|
+
const isConsumable = Boolean(opts.isConsumable) && !isSub;
|
|
51
52
|
const request = { apple: { sku: productId }, google: { skus: [productId] } };
|
|
52
53
|
if (isSub) {
|
|
53
54
|
try {
|
|
@@ -79,7 +80,7 @@ async function purchaseProduct(productId, opts = {}) {
|
|
|
79
80
|
try {
|
|
80
81
|
const info = await reportToEntitleHub(purchase, productId, isSub);
|
|
81
82
|
try {
|
|
82
|
-
await I.finishTransaction({ purchase, isConsumable
|
|
83
|
+
await I.finishTransaction({ purchase, isConsumable });
|
|
83
84
|
} catch {
|
|
84
85
|
}
|
|
85
86
|
resolve(info);
|
|
@@ -118,7 +119,7 @@ function addCustomerInfoUpdateListener(fn) {
|
|
|
118
119
|
return eh().addCustomerInfoUpdateListener(fn);
|
|
119
120
|
}
|
|
120
121
|
async function reportToEntitleHub(purchase, productId, isSubscription) {
|
|
121
|
-
const jws = purchase?.jwsRepresentation ?? purchase?.jwsRepresentationIos;
|
|
122
|
+
const jws = purchase?.jwsRepresentation ?? purchase?.jwsRepresentationIos ?? (String(purchase?.platform).toLowerCase() === "ios" ? purchase?.purchaseToken : void 0);
|
|
122
123
|
if (jws) return eh().reportPurchase({ signedTransaction: jws });
|
|
123
124
|
const token = purchase?.purchaseTokenAndroid ?? purchase?.purchaseToken;
|
|
124
125
|
if (token) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entitlehub/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "EntitleHub for React Native & Expo — one call to purchase and unlock entitlements. Wraps expo-iap for the native store sheet and validates receipts via EntitleHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"entitlehub",
|
|
@@ -14,10 +14,18 @@
|
|
|
14
14
|
"entitlements"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://entitlehub.com/docs/purchases",
|
|
17
|
-
"repository": {
|
|
18
|
-
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/DanCue44/entitlehub-sdk.git",
|
|
20
|
+
"directory": "react-native"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/DanCue44/entitlehub-sdk/issues"
|
|
24
|
+
},
|
|
19
25
|
"license": "MIT",
|
|
20
|
-
"publishConfig": {
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
21
29
|
"type": "module",
|
|
22
30
|
"main": "./dist/index.cjs",
|
|
23
31
|
"module": "./dist/index.js",
|
|
@@ -29,14 +37,21 @@
|
|
|
29
37
|
"require": "./dist/index.cjs"
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
|
-
"files": [
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"CHANGELOG.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
33
46
|
"sideEffects": false,
|
|
34
47
|
"scripts": {
|
|
35
48
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
36
49
|
"typecheck": "tsc --noEmit",
|
|
37
50
|
"prepublishOnly": "npm run build"
|
|
38
51
|
},
|
|
39
|
-
"engines": {
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=18"
|
|
54
|
+
},
|
|
40
55
|
"peerDependencies": {
|
|
41
56
|
"@entitlehub/sdk": ">=0.2.0",
|
|
42
57
|
"expo-iap": "*",
|