expo-iap 4.6.0 → 4.7.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/.prettierignore +0 -1
- package/CLAUDE.md +1 -1
- package/CONTRIBUTING.md +6 -6
- package/android/src/main/java/expo/modules/iap/ExpoIapHelper.kt +78 -7
- package/android/src/main/java/expo/modules/iap/ExpoIapLog.kt +46 -28
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +36 -2
- package/build/ExpoIapModule.d.ts.map +1 -1
- package/build/ExpoIapModule.js +8 -22
- package/build/ExpoIapModule.js.map +1 -1
- package/build/index.d.ts +5 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +23 -13
- package/build/index.js.map +1 -1
- package/build/index.kepler.d.ts +40 -5
- package/build/index.kepler.d.ts.map +1 -1
- package/build/index.kepler.js +46 -3
- package/build/index.kepler.js.map +1 -1
- package/build/kit-api.d.ts +18 -8
- package/build/kit-api.d.ts.map +1 -1
- package/build/kit-api.js +90 -3
- package/build/kit-api.js.map +1 -1
- package/build/modules/android.d.ts +19 -6
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +23 -6
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +27 -5
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +20 -16
- package/build/modules/ios.js.map +1 -1
- package/build/types.d.ts +119 -175
- package/build/types.d.ts.map +1 -1
- package/build/types.js +4 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts +20 -4
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +5 -2
- package/build/useIAP.js.map +1 -1
- package/build/utils/deprecation.d.ts +3 -0
- package/build/utils/deprecation.d.ts.map +1 -0
- package/build/utils/deprecation.js +13 -0
- package/build/utils/deprecation.js.map +1 -0
- package/build/vega-adapter.d.ts +1 -0
- package/build/vega-adapter.d.ts.map +1 -1
- package/build/vega-adapter.js +20 -13
- package/build/vega-adapter.js.map +1 -1
- package/expo-module.config.json +1 -0
- package/ios/ExpoIapHelper.swift +42 -7
- package/ios/ExpoIapLog.swift +15 -0
- package/ios/onside/OnsideIapModule.swift +127 -16
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/plugin/build/onsidePodfile.d.ts +1 -0
- package/plugin/build/onsidePodfile.js +16 -0
- package/plugin/build/withIAP.d.ts +12 -2
- package/plugin/build/withIAP.js +124 -59
- package/plugin/build/withLocalOpenIAP.d.ts +2 -0
- package/plugin/build/withLocalOpenIAP.js +18 -0
- package/plugin/src/expoConfig.augmentation.d.ts +16 -5
- package/plugin/src/onsidePodfile.ts +15 -0
- package/plugin/src/withIAP.ts +195 -77
- package/plugin/src/withLocalOpenIAP.ts +23 -0
- package/scripts/update-types.mjs +112 -81
- package/src/ExpoIapModule.ts +19 -23
- package/src/index.kepler.ts +75 -5
- package/src/index.ts +35 -30
- package/src/kit-api.ts +136 -13
- package/src/modules/android.ts +26 -7
- package/src/modules/ios.ts +26 -22
- package/src/types.ts +130 -203
- package/src/useIAP.ts +25 -5
- package/src/utils/deprecation.ts +16 -0
- package/src/vega-adapter.ts +23 -12
- package/build/useWebhookEvents.d.ts +0 -26
- package/build/useWebhookEvents.d.ts.map +0 -1
- package/build/useWebhookEvents.js +0 -105
- package/build/useWebhookEvents.js.map +0 -1
- package/build/webhook-client.d.ts +0 -82
- package/build/webhook-client.d.ts.map +0 -1
- package/build/webhook-client.js +0 -176
- package/build/webhook-client.js.map +0 -1
- package/src/useWebhookEvents.ts +0 -155
- package/src/webhook-client.ts +0 -312
package/.prettierignore
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -87,7 +87,7 @@ For complete type definitions and documentation, see: <https://openiap.dev/docs/
|
|
|
87
87
|
|
|
88
88
|
The library follows the OpenIAP type specifications with platform-specific extensions using iOS/Android suffixes.
|
|
89
89
|
|
|
90
|
-
> **Important:** `src/types.ts` is generated from the OpenIAP schema. Never edit this file manually or commit hand-written changes.
|
|
90
|
+
> **Important:** `src/types.ts` is generated from the OpenIAP schema. Never edit this file manually or commit hand-written changes. In this monorepo, run `cd packages/gql && bun run generate` from the repository root so every platform copy stays synchronized. The Expo-local `bun run generate:types` command is only for a standalone checkout: it atomically refreshes the platform-ready file from the raw `docs-${spec}` tag pinned by `openiap-versions.json` (or the version passed with `--tag`).
|
|
91
91
|
|
|
92
92
|
- Whenever you need Request/Params/Result types in the JS API surface (`src/index.ts`, hooks, modules, examples), import them directly from the generated `src/types.ts` (e.g., `MutationRequestPurchaseArgs`, `QueryFetchProductsArgs`). Bind exported functions with the generated `QueryField` / `MutationField` helpers so their signatures stay in lockstep with `types.ts` instead of redefining ad-hoc unions like `ProductTypeInput`.
|
|
93
93
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -216,28 +216,28 @@ For detailed code conventions, naming standards, and implementation guidelines,
|
|
|
216
216
|
|
|
217
217
|
### Updating OpenIAP Types
|
|
218
218
|
|
|
219
|
-
The generated TypeScript definitions in `src/types.ts` come from the [OpenIAP](https://github.com/hyodotdev/openiap)
|
|
219
|
+
The generated TypeScript definitions in `src/types.ts` come from the platform-ready file committed in the [OpenIAP](https://github.com/hyodotdev/openiap) raw `docs-${spec}` tag. Never edit this file by hand. When the schema changes or you need to pull newer published types:
|
|
220
220
|
|
|
221
|
-
- Run `bun run generate:types` to download the
|
|
222
|
-
- To target a specific
|
|
221
|
+
- Run `bun run generate:types` to download the version pinned by `openiap-versions.json`, validate it, and atomically replace `src/types.ts`.
|
|
222
|
+
- To target a specific published spec, pass its version: `bun run generate:types --tag <version>` (the script resolves it to `docs-<version>`).
|
|
223
223
|
- Commit the updated file alongside any related schema or documentation changes.
|
|
224
224
|
|
|
225
225
|
Always ensure the repository builds and tests succeed after regenerating the types.
|
|
226
226
|
|
|
227
227
|
## 🔢 OpenIAP Version Management
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
The native dependency and OpenIAP specification versions are sourced from `openiap-versions.json` at the repository root:
|
|
230
230
|
|
|
231
231
|
- `apple` → iOS Pod dependency (`ios/ExpoIap.podspec`).
|
|
232
232
|
- `google` → Android artifact (`android/build.gradle`, Expo config plugin).
|
|
233
|
-
- `
|
|
233
|
+
- `spec` → published OpenIAP specification/types release (`scripts/update-types.mjs`).
|
|
234
234
|
|
|
235
235
|
When bumping dependencies:
|
|
236
236
|
|
|
237
237
|
1. Update the relevant fields in `openiap-versions.json`.
|
|
238
238
|
2. For iOS changes, run `cd ios && pod install` (and commit the Pod.lock if required by the workflow).
|
|
239
239
|
3. For Android, re-run Gradle (`bun run android`) so the new artifact is pulled down.
|
|
240
|
-
4. When the `
|
|
240
|
+
4. When the `spec` value changes, run `bun run generate:types` to refresh `src/types.ts` from the matching raw `docs-${spec}` tag.
|
|
241
241
|
5. Commit the updated JSON, regenerated files, and any resulting lockfile changes together.
|
|
242
242
|
|
|
243
243
|
If the JSON file is missing or malformed, build scripts (Gradle, Podspec, the type generator) will fail fast — fix the JSON rather than hard-coding version strings in multiple locations.
|
|
@@ -78,6 +78,41 @@ object ExpoIapHelper {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
internal fun parseDeepLinkSubscriptionParams(params: Map<String, Any?>): DeepLinkSubscriptionParams {
|
|
82
|
+
val hasCanonicalSku = params.containsKey("skuAndroid")
|
|
83
|
+
val hasCanonicalPackageName = params.containsKey("packageNameAndroid")
|
|
84
|
+
val legacySku = params["sku"] as? String
|
|
85
|
+
val legacyPackageName = params["packageName"] as? String
|
|
86
|
+
|
|
87
|
+
if (!hasCanonicalSku && legacySku != null) {
|
|
88
|
+
ExpoIapLog.deprecation(
|
|
89
|
+
"deep-link.sku",
|
|
90
|
+
"`sku` is deprecated and will be removed in expo-iap 5.0.0. Use `skuAndroid` instead.",
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
if (!hasCanonicalPackageName && legacyPackageName != null) {
|
|
94
|
+
ExpoIapLog.deprecation(
|
|
95
|
+
"deep-link.packageName",
|
|
96
|
+
"`packageName` is deprecated and will be removed in expo-iap 5.0.0. Use `packageNameAndroid` instead.",
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return DeepLinkSubscriptionParams(
|
|
101
|
+
sku =
|
|
102
|
+
if (hasCanonicalSku) {
|
|
103
|
+
params["skuAndroid"] as? String
|
|
104
|
+
} else {
|
|
105
|
+
legacySku
|
|
106
|
+
},
|
|
107
|
+
packageName =
|
|
108
|
+
if (hasCanonicalPackageName) {
|
|
109
|
+
params["packageNameAndroid"] as? String
|
|
110
|
+
} else {
|
|
111
|
+
legacyPackageName
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
81
116
|
fun parseRequestPurchaseParams(params: Map<String, Any?>): RequestPurchaseParams {
|
|
82
117
|
// Support nested request.google / request.android structure
|
|
83
118
|
// If the params contain a "request" key with nested platform-specific data,
|
|
@@ -86,9 +121,16 @@ object ExpoIapHelper {
|
|
|
86
121
|
run {
|
|
87
122
|
val request = params["request"] as? Map<*, *>
|
|
88
123
|
if (request != null) {
|
|
89
|
-
val
|
|
90
|
-
|
|
91
|
-
|
|
124
|
+
val hasCanonicalGoogle = request.containsKey("google")
|
|
125
|
+
val canonicalGoogle = request["google"] as? Map<*, *>
|
|
126
|
+
val legacyAndroid = request["android"] as? Map<*, *>
|
|
127
|
+
if (!hasCanonicalGoogle && legacyAndroid != null) {
|
|
128
|
+
ExpoIapLog.deprecation(
|
|
129
|
+
"request-purchase.android",
|
|
130
|
+
"`request.android` is deprecated and will be removed in expo-iap 5.0.0. Use `request.google` instead.",
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
val nested = if (hasCanonicalGoogle) canonicalGoogle else legacyAndroid
|
|
92
134
|
if (nested != null) {
|
|
93
135
|
val flat = mutableMapOf<String, Any?>()
|
|
94
136
|
// Carry over top-level fields like type, useAlternativeBilling
|
|
@@ -109,15 +151,33 @@ object ExpoIapHelper {
|
|
|
109
151
|
}
|
|
110
152
|
|
|
111
153
|
val type = effective["type"] as? String
|
|
154
|
+
val hasCanonicalSkus = effective.containsKey("skus")
|
|
155
|
+
val canonicalSkus = (effective["skus"] as? List<*>)?.filterIsInstance<String>()
|
|
156
|
+
val legacySkuArr = (effective["skuArr"] as? List<*>)?.filterIsInstance<String>()
|
|
157
|
+
if (!hasCanonicalSkus && legacySkuArr != null) {
|
|
158
|
+
ExpoIapLog.deprecation(
|
|
159
|
+
"request-purchase.skuArr",
|
|
160
|
+
"`skuArr` is deprecated and will be removed in expo-iap 5.0.0. Use `skus` instead.",
|
|
161
|
+
)
|
|
162
|
+
}
|
|
112
163
|
val skus: List<String> =
|
|
113
|
-
|
|
114
|
-
?: (
|
|
115
|
-
|
|
164
|
+
if (hasCanonicalSkus) {
|
|
165
|
+
canonicalSkus ?: emptyList()
|
|
166
|
+
} else {
|
|
167
|
+
legacySkuArr ?: emptyList()
|
|
168
|
+
}
|
|
116
169
|
val obfuscatedAccountId = effective["obfuscatedAccountId"] as? String
|
|
117
170
|
val obfuscatedProfileId = effective["obfuscatedProfileId"] as? String
|
|
118
171
|
val isOfferPersonalized = effective["isOfferPersonalized"] as? Boolean ?: false
|
|
119
|
-
val
|
|
172
|
+
val hasCanonicalSubscriptionOffers = effective.containsKey("subscriptionOffers")
|
|
173
|
+
val legacyOfferTokenArr =
|
|
120
174
|
(effective["offerTokenArr"] as? List<*>)?.filterIsInstance<String>() ?: emptyList()
|
|
175
|
+
val offerTokenArr =
|
|
176
|
+
if (hasCanonicalSubscriptionOffers) {
|
|
177
|
+
emptyList()
|
|
178
|
+
} else {
|
|
179
|
+
legacyOfferTokenArr
|
|
180
|
+
}
|
|
121
181
|
val explicitSubscriptionOffers =
|
|
122
182
|
(effective["subscriptionOffers"] as? List<*>)?.mapNotNull { rawOffer ->
|
|
123
183
|
val offerMap = rawOffer as? Map<*, *> ?: return@mapNotNull null
|
|
@@ -129,6 +189,12 @@ object ExpoIapHelper {
|
|
|
129
189
|
AndroidSubscriptionOfferInput(offerToken = offerToken, sku = sku)
|
|
130
190
|
}
|
|
131
191
|
} ?: emptyList()
|
|
192
|
+
if (!hasCanonicalSubscriptionOffers && offerTokenArr.isNotEmpty()) {
|
|
193
|
+
ExpoIapLog.deprecation(
|
|
194
|
+
"request-purchase.offerTokenArr",
|
|
195
|
+
"`offerTokenArr` is deprecated and will be removed in expo-iap 5.0.0. Use `subscriptionOffers` instead.",
|
|
196
|
+
)
|
|
197
|
+
}
|
|
132
198
|
val purchaseToken = effective["purchaseToken"] as? String
|
|
133
199
|
val originalExternalTransactionId = effective["originalExternalTransactionId"] as? String
|
|
134
200
|
val replacementMode = effective["replacementMode"] as? Number
|
|
@@ -202,6 +268,11 @@ object ExpoIapHelper {
|
|
|
202
268
|
val subscriptionProductReplacementParams: SubscriptionProductReplacementParamsAndroid?,
|
|
203
269
|
)
|
|
204
270
|
|
|
271
|
+
internal data class DeepLinkSubscriptionParams(
|
|
272
|
+
val sku: String?,
|
|
273
|
+
val packageName: String?,
|
|
274
|
+
)
|
|
275
|
+
|
|
205
276
|
fun addPurchasePromise(promise: Promise) {
|
|
206
277
|
PromiseUtils.addPromiseForKey(PromiseUtils.PROMISE_BUY_ITEM, promise)
|
|
207
278
|
}
|
|
@@ -3,28 +3,34 @@ package expo.modules.iap
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import org.json.JSONArray
|
|
5
5
|
import org.json.JSONObject
|
|
6
|
+
import java.util.Collections
|
|
6
7
|
import java.util.Locale
|
|
8
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
7
9
|
|
|
8
10
|
internal object ExpoIapLog {
|
|
9
11
|
private const val TAG = "ExpoIap"
|
|
10
|
-
private val
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
private val emittedDeprecations: MutableSet<String> =
|
|
13
|
+
Collections.newSetFromMap(ConcurrentHashMap())
|
|
14
|
+
private val SENSITIVE_KEY_FRAGMENTS =
|
|
15
|
+
setOf(
|
|
16
|
+
"token",
|
|
17
|
+
"apikey",
|
|
18
|
+
"secret",
|
|
19
|
+
"jws",
|
|
20
|
+
"receipt",
|
|
21
|
+
"clientpayload",
|
|
22
|
+
"dataandroid",
|
|
23
|
+
"signatureandroid",
|
|
24
|
+
"userid",
|
|
25
|
+
"password",
|
|
26
|
+
"bearer",
|
|
27
|
+
)
|
|
28
|
+
private val SENSITIVE_AUTH_KEYS =
|
|
29
|
+
setOf(
|
|
30
|
+
"auth",
|
|
31
|
+
"authorization",
|
|
32
|
+
"authheader",
|
|
33
|
+
)
|
|
28
34
|
|
|
29
35
|
fun payload(
|
|
30
36
|
name: String,
|
|
@@ -51,6 +57,16 @@ internal object ExpoIapLog {
|
|
|
51
57
|
Log.w(TAG, message)
|
|
52
58
|
}
|
|
53
59
|
|
|
60
|
+
fun deprecation(
|
|
61
|
+
key: String,
|
|
62
|
+
message: String,
|
|
63
|
+
) {
|
|
64
|
+
if (!emittedDeprecations.add(key)) {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
Log.w(TAG, message)
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
fun debug(message: String) {
|
|
55
71
|
if (BuildConfig.DEBUG || Log.isLoggable(TAG, Log.DEBUG)) {
|
|
56
72
|
Log.d(TAG, message)
|
|
@@ -73,9 +89,10 @@ internal object ExpoIapLog {
|
|
|
73
89
|
|
|
74
90
|
return when (value) {
|
|
75
91
|
is String -> sanitizeJsonString(value)
|
|
76
|
-
is JSONObject ->
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
is JSONObject ->
|
|
93
|
+
sanitizeMap(
|
|
94
|
+
value.keys().asSequence().associateWith(value::opt),
|
|
95
|
+
)
|
|
79
96
|
is JSONArray -> (0 until value.length()).mapNotNull { sanitize(value.opt(it)) }
|
|
80
97
|
is Map<*, *> -> sanitizeMap(value)
|
|
81
98
|
is List<*> -> value.mapNotNull { sanitize(it) }
|
|
@@ -86,13 +103,14 @@ internal object ExpoIapLog {
|
|
|
86
103
|
|
|
87
104
|
private fun sanitizeJsonString(value: String): Any {
|
|
88
105
|
val trimmed = value.trim()
|
|
89
|
-
val json =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
val json =
|
|
107
|
+
runCatching {
|
|
108
|
+
when (trimmed.firstOrNull()) {
|
|
109
|
+
'{' -> JSONObject(trimmed)
|
|
110
|
+
'[' -> JSONArray(trimmed)
|
|
111
|
+
else -> null
|
|
112
|
+
}
|
|
113
|
+
}.getOrNull() ?: return value
|
|
96
114
|
return sanitize(json) ?: value
|
|
97
115
|
}
|
|
98
116
|
|
|
@@ -265,8 +265,9 @@ class ExpoIapModule : Module() {
|
|
|
265
265
|
|
|
266
266
|
// Deep link to Manage Subscriptions screen (Android)
|
|
267
267
|
AsyncFunction("deepLinkToSubscriptionsAndroid") { params: Map<String, Any?>, promise: Promise ->
|
|
268
|
-
val
|
|
269
|
-
val
|
|
268
|
+
val deepLinkParams = ExpoIapHelper.parseDeepLinkSubscriptionParams(params)
|
|
269
|
+
val sku = deepLinkParams.sku
|
|
270
|
+
val packageName = deepLinkParams.packageName
|
|
270
271
|
ExpoIapLog.payload("deepLinkToSubscriptionsAndroid", mapOf("sku" to sku, "packageName" to packageName))
|
|
271
272
|
scope.launch {
|
|
272
273
|
try {
|
|
@@ -280,6 +281,39 @@ class ExpoIapModule : Module() {
|
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
283
|
|
|
284
|
+
AsyncFunction("openRedeemOfferCodeAndroid") { promise: Promise ->
|
|
285
|
+
ExpoIapLog.payload("openRedeemOfferCodeAndroid", null)
|
|
286
|
+
scope.launch {
|
|
287
|
+
try {
|
|
288
|
+
runCatching { currentActivity }.getOrNull()?.let(openIap::setActivity)
|
|
289
|
+
val handler = openIap.mutationHandlers.openRedeemOfferCodeAndroid
|
|
290
|
+
?: throw OpenIapError.FeatureNotSupported()
|
|
291
|
+
val launched = handler()
|
|
292
|
+
ExpoIapLog.result("openRedeemOfferCodeAndroid", launched)
|
|
293
|
+
promise.resolve(launched)
|
|
294
|
+
} catch (e: Exception) {
|
|
295
|
+
ExpoIapLog.failure("openRedeemOfferCodeAndroid", e)
|
|
296
|
+
val errorMap =
|
|
297
|
+
if (e is OpenIapError) {
|
|
298
|
+
ExpoIapHelper.serializeOpenIapError(e)
|
|
299
|
+
} else {
|
|
300
|
+
mapOf(
|
|
301
|
+
"code" to OpenIapError.ServiceUnavailable.CODE,
|
|
302
|
+
"message" to (e.message ?: OpenIapError.ServiceUnavailable.MESSAGE),
|
|
303
|
+
"platform" to "android",
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
val errorCode =
|
|
307
|
+
errorMap["code"] as? String ?: OpenIapError.ServiceUnavailable.CODE
|
|
308
|
+
promise.reject(
|
|
309
|
+
errorCode,
|
|
310
|
+
ExpoIapHelper.serializeErrorEnvelope(errorMap),
|
|
311
|
+
e,
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
283
317
|
// Get storefront country code (Android implementation)
|
|
284
318
|
AsyncFunction("getStorefront") { promise: Promise ->
|
|
285
319
|
ExpoIapLog.payload("getStorefront", null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AA6FA,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAQtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,QAE9B;;AAED,wBAyBG"}
|
package/build/ExpoIapModule.js
CHANGED
|
@@ -3,7 +3,6 @@ import { installedFromOnside } from './onside';
|
|
|
3
3
|
import { getVegaIapModule, isVegaOS } from './vega';
|
|
4
4
|
const ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';
|
|
5
5
|
let cached = null;
|
|
6
|
-
let expoIapFallback;
|
|
7
6
|
let onsideModuleUnavailable = false;
|
|
8
7
|
function getResolved() {
|
|
9
8
|
function shouldUseOnsideModule() {
|
|
@@ -20,9 +19,7 @@ function getResolved() {
|
|
|
20
19
|
if (isVegaOS()) {
|
|
21
20
|
return 'ExpoIapVega';
|
|
22
21
|
}
|
|
23
|
-
return shouldUseOnsideModule()
|
|
24
|
-
? 'ExpoIapOnside'
|
|
25
|
-
: 'ExpoIap';
|
|
22
|
+
return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';
|
|
26
23
|
}
|
|
27
24
|
function resolveNativeModule() {
|
|
28
25
|
if (isVegaOS()) {
|
|
@@ -33,6 +30,9 @@ function getResolved() {
|
|
|
33
30
|
return { module: vegaModule, name: 'ExpoIapVega' };
|
|
34
31
|
}
|
|
35
32
|
if (shouldUseOnsideModule()) {
|
|
33
|
+
if (onsideModuleUnavailable) {
|
|
34
|
+
throw new UnavailabilityError('expo-iap', 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.');
|
|
35
|
+
}
|
|
36
36
|
try {
|
|
37
37
|
return {
|
|
38
38
|
module: requireNativeModule('ExpoIapOnside'),
|
|
@@ -44,6 +44,7 @@ function getResolved() {
|
|
|
44
44
|
throw error;
|
|
45
45
|
}
|
|
46
46
|
onsideModuleUnavailable = true;
|
|
47
|
+
throw new UnavailabilityError('expo-iap', 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.');
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
return { module: requireNativeModule('ExpoIap'), name: 'ExpoIap' };
|
|
@@ -63,23 +64,6 @@ function isMissingModuleError(error, moduleName) {
|
|
|
63
64
|
}
|
|
64
65
|
return false;
|
|
65
66
|
}
|
|
66
|
-
function getExpoIapFallbackModule() {
|
|
67
|
-
if (expoIapFallback !== undefined) {
|
|
68
|
-
return expoIapFallback;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
expoIapFallback = requireNativeModule('ExpoIap');
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
if (isMissingModuleError(error, 'ExpoIap')) {
|
|
75
|
-
expoIapFallback = null;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return expoIapFallback;
|
|
82
|
-
}
|
|
83
67
|
export const NATIVE_ERROR_CODES = new Proxy({}, {
|
|
84
68
|
get(target, prop) {
|
|
85
69
|
if (typeof prop === 'symbol')
|
|
@@ -111,7 +95,9 @@ export default new Proxy({}, {
|
|
|
111
95
|
if (value !== undefined || resolved.name !== 'ExpoIapOnside') {
|
|
112
96
|
return value;
|
|
113
97
|
}
|
|
114
|
-
return
|
|
98
|
+
return () => {
|
|
99
|
+
throw new UnavailabilityError('expo-iap', `The Onside marketplace does not support ${String(prop)}. The call was not routed through Apple StoreKit.`);
|
|
100
|
+
};
|
|
115
101
|
},
|
|
116
102
|
});
|
|
117
103
|
//# sourceMappingURL=ExpoIapModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAGlD,MAAM,qBAAqB,GAAG,4BA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nimport {installedFromOnside} from './onside';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\nlet cached: {module: any; name: NativeIapModuleName} | null = null;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): {module: any; name: NativeIapModuleName} {\n function shouldUseOnsideModule(): boolean {\n if (installedFromOnside === true) {\n return true;\n }\n\n if (typeof installedFromOnside !== 'string') {\n return false;\n }\n\n const normalized = installedFromOnside.trim().toLowerCase();\n return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;\n }\n\n function getExpectedModuleName(): NativeIapModuleName {\n if (isVegaOS()) {\n return 'ExpoIapVega';\n }\n\n return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';\n }\n\n function resolveNativeModule(): {\n module: any;\n name: NativeIapModuleName;\n } {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'Amazon Vega IAP module is unavailable. Install @amazon-devices/keplerscript-appstore-iap-lib in the Vega app target and build with the React Native for Vega kepler platform.',\n );\n }\n return {module: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n if (onsideModuleUnavailable) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n try {\n return {\n module: requireNativeModule('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n }\n\n return {module: requireNativeModule('ExpoIap'), name: 'ExpoIap'};\n }\n\n const expectedName = getExpectedModuleName();\n if (!cached || cached.name !== expectedName) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction isMissingModuleError(error: unknown, moduleName: string): boolean {\n if (error instanceof UnavailabilityError) {\n return true;\n }\n\n if (error instanceof Error) {\n return error.message.includes(`Cannot find native module '${moduleName}'`);\n }\n\n return false;\n}\n\nexport const NATIVE_ERROR_CODES: Record<string, unknown> = new Proxy(\n {} as Record<string, unknown>,\n {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n return (getResolved().module.ERROR_CODES || {})[prop as string];\n },\n },\n);\n\n/**\n * Returns the raw native module (not wrapped in a Proxy).\n * Use this for EventEmitter / addListener calls — JSI HostObjects\n * require the real native module as `this`; a Proxy triggers\n * \"native state unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule() {\n return getResolved().module;\n}\n\nexport default new Proxy({} as any, {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const resolved = getResolved();\n if (prop === 'USING_ONSIDE_SDK') {\n return resolved.name === 'ExpoIapOnside';\n }\n if (prop === 'USING_VEGA_SDK') {\n return resolved.name === 'ExpoIapVega';\n }\n\n const value = resolved.module[prop];\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return () => {\n throw new UnavailabilityError(\n 'expo-iap',\n `The Onside marketplace does not support ${String(\n prop,\n )}. The call was not routed through Apple StoreKit.`,\n );\n };\n },\n});\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -42,7 +42,8 @@ type ExpoIapEmitter = {
|
|
|
42
42
|
};
|
|
43
43
|
export declare const emitter: ExpoIapEmitter;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Accepts the legacy 'inapp' alias for backward compatibility. The alias is
|
|
46
|
+
* deprecated and scheduled for removal in expo-iap 5.0.0 — use 'in-app'.
|
|
46
47
|
*/
|
|
47
48
|
export type ProductTypeInput = ProductQueryType | 'inapp';
|
|
48
49
|
export declare const purchaseUpdatedListener: (listener: (event: Purchase) => void, options?: PurchaseUpdatedListenerOptions | null) => {
|
|
@@ -380,7 +381,8 @@ export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscript
|
|
|
380
381
|
* - iOS: Send receipt data to Apple's verification endpoint from your server
|
|
381
382
|
* - Android: Use Google Play Developer API with service account credentials
|
|
382
383
|
*
|
|
383
|
-
* @deprecated Use verifyPurchase instead
|
|
384
|
+
* @deprecated Use verifyPurchase instead. This function will be removed in
|
|
385
|
+
* expo-iap 5.0.0.
|
|
384
386
|
*
|
|
385
387
|
* @see {@link https://openiap.dev/docs/apis/validate-receipt}
|
|
386
388
|
*/
|
|
@@ -428,12 +430,8 @@ export declare const verifyPurchase: MutationField<'verifyPurchase'>;
|
|
|
428
430
|
*/
|
|
429
431
|
export declare const verifyPurchaseWithProvider: MutationField<'verifyPurchaseWithProvider'>;
|
|
430
432
|
export * from './useIAP';
|
|
431
|
-
export { useWebhookEvents } from './useWebhookEvents';
|
|
432
|
-
export type { UseWebhookEventsOptions, UseWebhookEventsResult, } from './useWebhookEvents';
|
|
433
|
-
export { connectWebhookStream, parseWebhookEventData } from './webhook-client';
|
|
434
|
-
export type { WebhookEventPayload, WebhookEventStream, WebhookEventType as WebhookEventTypeName, WebhookListener, WebhookListenerError, WebhookListenerOptions, } from './webhook-client';
|
|
435
433
|
export { kitApi, KitApiError } from './kit-api';
|
|
436
|
-
export type { KitApiOptions, KitClientPayloadResponse, KitProduct, KitProductClientPayload, KitProductOffer, KitProductPlatform, KitProductsOptions, KitProductsResponse, KitSubscription, EntitlementsResponse, StatusResponse, } from './kit-api';
|
|
434
|
+
export type { KitApiOptions, KitClientPayloadCache, KitClientPayloadOptions, KitClientPayloadResponse, KitProduct, KitProductClientPayload, KitProductOffer, KitProductPlatform, KitProductsOptions, KitProductsResponse, KitSubscription, EntitlementsResponse, StatusResponse, } from './kit-api';
|
|
437
435
|
export { ErrorCodeUtils, ErrorCodeMapping, createPurchaseError, createPurchaseErrorFromPlatform, } from './utils/errorMapping';
|
|
438
436
|
export type { PurchaseError as ExpoPurchaseError, PurchaseErrorProps, } from './utils/errorMapping';
|
|
439
437
|
export { ExpoIapConsole } from './utils/debug';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAGV,sCAAsC,EAEtC,aAAa,EAGb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,8BAA8B,EAC9B,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAG9B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAGvB,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,wBAAwB,gCAAgC;IACxD;;;OAGG;IACH,+BAA+B,uCAAuC;IACtE;;;;OAIG;IACH,wBAAwB,+BAA+B;CACxD;AAED,KAAK,oBAAoB,GAAG;IAC1B,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC;IACzC,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC5C,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAC7B,OAAO,GACP,MAAM,GACN;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACtC,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAClE,CAAC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AC,kBAAkB,CAkB9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CACjD,yBAAyB,CAa1B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAkC5D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAQ1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAAa,CACpD,4BAA4B,CAmD7B,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAC9C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { isVegaOS } from './vega';
|
|
|
6
6
|
import { isProductIOS, validateReceiptIOS, deepLinkToSubscriptionsIOS, syncIOS, } from './modules/ios';
|
|
7
7
|
import { isProductAndroid, validateReceiptAndroid, deepLinkToSubscriptionsAndroid, } from './modules/android';
|
|
8
8
|
import { ExpoIapConsole } from './utils/debug';
|
|
9
|
+
import { warnLegacyOnce } from './utils/deprecation';
|
|
9
10
|
import { ErrorCode } from './types';
|
|
10
11
|
import { createPurchaseError, createPurchaseErrorFromNativeException, OPENIAP_ERROR_ENVELOPE_PREFIX, } from './utils/errorMapping';
|
|
11
12
|
// Export all types
|
|
@@ -118,7 +119,7 @@ const configurePurchaseUpdatedListenerOptionsIOS = (dedupeTransactionIOS) => {
|
|
|
118
119
|
};
|
|
119
120
|
const normalizeProductType = (type) => {
|
|
120
121
|
if (type === 'inapp') {
|
|
121
|
-
|
|
122
|
+
warnLegacyOnce('product-type.inapp', "'inapp' product type is deprecated and will be removed in expo-iap 5.0.0. Use 'in-app' instead.");
|
|
122
123
|
}
|
|
123
124
|
if (!type || type === 'inapp' || type === 'in-app') {
|
|
124
125
|
return {
|
|
@@ -663,12 +664,24 @@ export const getStorefront = async () => {
|
|
|
663
664
|
return storefront;
|
|
664
665
|
};
|
|
665
666
|
function normalizeRequestProps(request, platform) {
|
|
666
|
-
// Support both new (apple/google) and legacy (ios/android) field names
|
|
667
|
-
// New fields take precedence over deprecated ones
|
|
668
667
|
if (platform === 'ios') {
|
|
669
|
-
|
|
668
|
+
if (Object.prototype.hasOwnProperty.call(request, 'apple')) {
|
|
669
|
+
return request.apple;
|
|
670
|
+
}
|
|
671
|
+
if (Object.prototype.hasOwnProperty.call(request, 'ios')) {
|
|
672
|
+
warnLegacyOnce('request-purchase.ios', '`request.ios` is deprecated and will be removed in expo-iap 5.0.0. Use `request.apple` instead.');
|
|
673
|
+
return request.ios;
|
|
674
|
+
}
|
|
675
|
+
return undefined;
|
|
676
|
+
}
|
|
677
|
+
if (Object.prototype.hasOwnProperty.call(request, 'google')) {
|
|
678
|
+
return request.google;
|
|
679
|
+
}
|
|
680
|
+
if (Object.prototype.hasOwnProperty.call(request, 'android')) {
|
|
681
|
+
warnLegacyOnce('request-purchase.android', '`request.android` is deprecated and will be removed in expo-iap 5.0.0. Use `request.google` instead.');
|
|
682
|
+
return request.android;
|
|
670
683
|
}
|
|
671
|
-
return
|
|
684
|
+
return undefined;
|
|
672
685
|
}
|
|
673
686
|
/**
|
|
674
687
|
* Initiate a purchase or subscription flow. The result is delivered through
|
|
@@ -719,7 +732,7 @@ export const requestPurchase = async (args) => {
|
|
|
719
732
|
}
|
|
720
733
|
const payload = {
|
|
721
734
|
type: canonical === 'in-app' ? 'in-app' : 'subs',
|
|
722
|
-
request: {
|
|
735
|
+
request: { apple: normalizedRequest },
|
|
723
736
|
useAlternativeBilling: args.useAlternativeBilling,
|
|
724
737
|
};
|
|
725
738
|
const purchase = (await invokeNativeWithPurchaseError(() => ExpoIapModule.requestPurchase(payload), 'ios', {
|
|
@@ -755,14 +768,13 @@ export const requestPurchase = async (args) => {
|
|
|
755
768
|
const { skus, obfuscatedAccountId, obfuscatedProfileId, isOfferPersonalized, offerToken, developerBillingOption, } = normalizedRequest;
|
|
756
769
|
const result = (await invokeNativeWithPurchaseError(() => ExpoIapModule.requestPurchase({
|
|
757
770
|
type: native,
|
|
758
|
-
|
|
771
|
+
skus,
|
|
759
772
|
purchaseToken: undefined,
|
|
760
773
|
replacementMode: -1,
|
|
761
774
|
obfuscatedAccountId: obfuscatedAccountId,
|
|
762
775
|
obfuscatedProfileId: obfuscatedProfileId,
|
|
763
776
|
offerToken: offerToken,
|
|
764
777
|
developerBillingOption: developerBillingOption ?? undefined,
|
|
765
|
-
offerTokenArr: [],
|
|
766
778
|
isOfferPersonalized: isOfferPersonalized ?? false,
|
|
767
779
|
}), 'android', {
|
|
768
780
|
code: ErrorCode.PurchaseError,
|
|
@@ -793,13 +805,12 @@ export const requestPurchase = async (args) => {
|
|
|
793
805
|
const purchaseToken = purchaseTokenInput ?? undefined;
|
|
794
806
|
const result = (await invokeNativeWithPurchaseError(() => ExpoIapModule.requestPurchase({
|
|
795
807
|
type: native,
|
|
796
|
-
|
|
808
|
+
skus,
|
|
797
809
|
purchaseToken,
|
|
798
810
|
originalExternalTransactionId: originalExternalTransactionId ?? undefined,
|
|
799
811
|
replacementMode,
|
|
800
812
|
obfuscatedAccountId: obfuscatedAccountId,
|
|
801
813
|
obfuscatedProfileId: obfuscatedProfileId,
|
|
802
|
-
offerTokenArr: normalizedOffers.map((offer) => offer.offerToken),
|
|
803
814
|
subscriptionOffers: normalizedOffers,
|
|
804
815
|
isOfferPersonalized: isOfferPersonalized ?? false,
|
|
805
816
|
developerBillingOption: developerBillingOption ?? undefined,
|
|
@@ -931,7 +942,8 @@ export const deepLinkToSubscriptions = async (options) => {
|
|
|
931
942
|
* - iOS: Send receipt data to Apple's verification endpoint from your server
|
|
932
943
|
* - Android: Use Google Play Developer API with service account credentials
|
|
933
944
|
*
|
|
934
|
-
* @deprecated Use verifyPurchase instead
|
|
945
|
+
* @deprecated Use verifyPurchase instead. This function will be removed in
|
|
946
|
+
* expo-iap 5.0.0.
|
|
935
947
|
*
|
|
936
948
|
* @see {@link https://openiap.dev/docs/apis/validate-receipt}
|
|
937
949
|
*/
|
|
@@ -1050,8 +1062,6 @@ export const verifyPurchaseWithProvider = async (options) => {
|
|
|
1050
1062
|
};
|
|
1051
1063
|
};
|
|
1052
1064
|
export * from './useIAP';
|
|
1053
|
-
export { useWebhookEvents } from './useWebhookEvents';
|
|
1054
|
-
export { connectWebhookStream, parseWebhookEventData } from './webhook-client';
|
|
1055
1065
|
export { kitApi, KitApiError } from './kit-api';
|
|
1056
1066
|
export { ErrorCodeUtils, ErrorCodeMapping, createPurchaseError, createPurchaseErrorFromPlatform, } from './utils/errorMapping';
|
|
1057
1067
|
export { ExpoIapConsole } from './utils/debug';
|