expo-iap 3.4.13 → 4.0.0-rc.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.
Files changed (57) hide show
  1. package/CLAUDE.md +1 -1
  2. package/CONTRIBUTING.md +2 -2
  3. package/README.md +17 -6
  4. package/android/src/main/java/expo/modules/iap/ExpoIapHelper.kt +43 -15
  5. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +12 -14
  6. package/android/src/main/java/expo/modules/iap/MissingCurrentActivityException.kt +1 -1
  7. package/android/src/main/java/expo/modules/iap/PromiseUtils.kt +2 -4
  8. package/build/ExpoIapModule.d.ts.map +1 -1
  9. package/build/ExpoIapModule.js +6 -2
  10. package/build/ExpoIapModule.js.map +1 -1
  11. package/build/modules/ios.d.ts +1 -1
  12. package/build/modules/ios.js +5 -5
  13. package/build/modules/ios.js.map +1 -1
  14. package/build/types.d.ts +1 -0
  15. package/build/types.d.ts.map +1 -1
  16. package/build/types.js +2 -1
  17. package/build/types.js.map +1 -1
  18. package/build/utils/errorMapping.d.ts.map +1 -1
  19. package/build/utils/errorMapping.js +1 -0
  20. package/build/utils/errorMapping.js.map +1 -1
  21. package/codecov.yml +0 -1
  22. package/ios/ExpoIap.podspec +1 -1
  23. package/ios/ExpoIapModule.swift +1 -10
  24. package/ios/onside/OnsideAppDelegateSubscriber.swift +0 -5
  25. package/ios/onside/OnsideIapModule.swift +33 -23
  26. package/openiap-versions.json +4 -3
  27. package/package.json +7 -7
  28. package/plugin/build/withIosAlternativeBilling.js +8 -18
  29. package/plugin/jest.config.js +1 -1
  30. package/plugin/src/withIosAlternativeBilling.ts +25 -27
  31. package/scripts/test-coverage.sh +3 -3
  32. package/src/ExpoIapModule.ts +4 -2
  33. package/src/modules/ios.ts +5 -5
  34. package/src/types.ts +2 -1
  35. package/src/utils/errorMapping.ts +1 -0
  36. package/coverage/clover.xml +0 -567
  37. package/coverage/coverage-final.json +0 -8
  38. package/coverage/lcov-report/base.css +0 -224
  39. package/coverage/lcov-report/block-navigation.js +0 -87
  40. package/coverage/lcov-report/favicon.png +0 -0
  41. package/coverage/lcov-report/index.html +0 -161
  42. package/coverage/lcov-report/prettify.css +0 -1
  43. package/coverage/lcov-report/prettify.js +0 -2
  44. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  45. package/coverage/lcov-report/sorter.js +0 -210
  46. package/coverage/lcov-report/src/index.html +0 -116
  47. package/coverage/lcov-report/src/index.ts.html +0 -2857
  48. package/coverage/lcov-report/src/modules/android.ts.html +0 -1048
  49. package/coverage/lcov-report/src/modules/index.html +0 -131
  50. package/coverage/lcov-report/src/modules/ios.ts.html +0 -1528
  51. package/coverage/lcov-report/src/onside/ExpoOnsideMarketplaceAvailabilityModule.ts.html +0 -145
  52. package/coverage/lcov-report/src/onside/index.html +0 -131
  53. package/coverage/lcov-report/src/onside/index.ts.html +0 -256
  54. package/coverage/lcov-report/src/utils/debug.ts.html +0 -283
  55. package/coverage/lcov-report/src/utils/errorMapping.ts.html +0 -1141
  56. package/coverage/lcov-report/src/utils/index.html +0 -131
  57. package/coverage/lcov.info +0 -1097
package/CLAUDE.md CHANGED
@@ -127,7 +127,7 @@ All implementations must follow the OpenIAP specification:
127
127
 
128
128
  For new feature proposals:
129
129
 
130
- 1. Before implementing, discuss at: <https://github.com/hyochan/openiap.dev/discussions>
130
+ 1. Before implementing, discuss at: <https://github.com/hyodotdev/openiap/discussions>
131
131
  2. Get community feedback and consensus
132
132
  3. Ensure alignment with OpenIAP standards
133
133
  4. Implement following the agreed specification
package/CONTRIBUTING.md CHANGED
@@ -31,8 +31,8 @@ Thank you for your interest in contributing to expo-iap! This guide will help yo
31
31
  1. Clone the repository:
32
32
 
33
33
  ```bash
34
- git clone https://github.com/hyochan/expo-iap.git
35
- cd expo-iap
34
+ git clone https://github.com/hyodotdev/openiap.git
35
+ cd openiap/libraries/expo-iap
36
36
  ```
37
37
 
38
38
  1. Install dependencies using Bun:
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <div align="center">
4
4
  <img src="https://hyochan.github.io/expo-iap/img/icon.png" alt="Expo IAP Logo" width="150" />
5
5
 
6
- [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![OpenIAP](https://img.shields.io/badge/OpenIAP-Compliant-green?style=flat-square)](https://openiap.dev) [![CI](https://github.com/hyochan/expo-iap/actions/workflows/ci.yml/badge.svg)](https://github.com/hyochan/expo-iap/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/hyochan/expo-iap/graph/badge.svg?token=47VMTY5NyM)](https://codecov.io/gh/hyochan/expo-iap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
6
+ [![Version](http://img.shields.io/npm/v/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![Download](http://img.shields.io/npm/dm/expo-iap.svg?style=flat-square)](https://npmjs.org/package/expo-iap) [![OpenIAP](https://img.shields.io/badge/OpenIAP-Compliant-green?style=flat-square)](https://openiap.dev) [![CI](https://github.com/hyodotdev/openiap/actions/workflows/ci.yml/badge.svg)](https://github.com/hyodotdev/openiap/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/hyodotdev/openiap/graph/badge.svg?token=47VMTY5NyM)](https://codecov.io/gh/hyodotdev/openiap) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
7
7
 
8
8
  Expo IAP is a powerful in-app purchase solution for Expo and React Native applications that conforms to the Open IAP specification. It provides a unified API for handling in-app purchases across iOS and Android platforms with comprehensive error handling and modern TypeScript support.
9
9
 
@@ -46,7 +46,7 @@ Quick links:
46
46
 
47
47
  ## Notice
48
48
 
49
- The `expo-iap` module has been migrated from [react-native-iap](https://github.com/hyochan/react-native-iap). While we initially considered fully merging everything into `react-native-iap`, we ultimately decided to maintain the two libraries in parallel, each tailored to its own ecosystem.
49
+ The `expo-iap` module has been migrated from [react-native-iap](https://github.com/hyodotdev/openiap/tree/main/libraries/react-native-iap). While we initially considered fully merging everything into `react-native-iap`, we ultimately decided to maintain the two libraries in parallel, each tailored to its own ecosystem.
50
50
 
51
51
  - **`react-native-iap`** → a **Nitro Modules–based** implementation for React Native.
52
52
  - **`expo-iap`** → an **Expo Module** with tighter integration and smoother compatibility in the Expo ecosystem.
@@ -78,13 +78,24 @@ For detailed usage examples and error handling, see the [documentation](https://
78
78
 
79
79
  > Sharing your thoughts—any feedback would be greatly appreciated!
80
80
 
81
- ## Our Sponsors
81
+ ## Powered by OpenIAP
82
82
 
83
- 💼 **[View Our Sponsors](https://openiap.dev/sponsors)**
83
+ <a href="https://openiap.dev"><img src="https://github.com/hyodotdev/openiap/blob/main/logo.png" alt="OpenIAP" height="50" /></a>
84
+
85
+ Expo IAP conforms to the **[OpenIAP specification](https://openiap.dev)** — an open, vendor-neutral interoperability standard for in-app purchases. OpenIAP provides:
86
+
87
+ - **Shared specification** — Common types, error codes, and purchase flows across all platforms
88
+ - **Generated type-safe bindings** — Swift, Kotlin, Dart, and GDScript from a single GraphQL schema
89
+ - **Platform implementations** — [openiap-apple](https://github.com/hyodotdev/openiap/tree/main/packages/apple) (StoreKit 2) and [openiap-google](https://github.com/hyodotdev/openiap/tree/main/packages/google) (Play Billing 8.x)
90
+ - **Verification profiles** — Standardized receipt validation and purchase verification patterns
84
91
 
85
- We're building the OpenIAP ecosystem—defining the spec at [openiap.dev](https://www.openiap.dev), maintaining [OpenIAP](https://github.com/hyodotdev/openiap) for the shared type system, and shipping platform SDKs like [openiap-apple](https://github.com/hyodotdev/openiap/tree/main/packages/apple) and [openiap-google](https://github.com/hyodotdev/openiap/tree/main/packages/google) that power [expo-iap](https://github.com/hyochan/expo-iap), [flutter_inapp_purchase](https://github.com/hyochan/flutter_inapp_purchase), React Native, and [kmp-iap](https://github.com/hyochan/kmp-iap). The work so far has focused on untangling fragmented APIs; the next milestone is a streamlined purchase flow: `initConnection → fetchProducts → requestPurchase → (server receipt validation) → finishTransaction`.
92
+ Other libraries built on OpenIAP: [react-native-iap](https://github.com/hyodotdev/openiap/tree/main/libraries/react-native-iap) · [flutter_inapp_purchase](https://github.com/hyodotdev/openiap/tree/main/libraries/flutter_inapp_purchase) · [kmp-iap](https://github.com/hyodotdev/openiap/tree/main/libraries/kmp-iap) · [godot-iap](https://github.com/hyodotdev/openiap/tree/main/libraries/godot-iap)
86
93
 
87
- Your sponsorship helps ensure developers across platforms, OS, and frameworks can implement in-app purchases without headaches. It also fuels new plugins, payment systems, and partner integrations already being explored in the OpenIAP community. Sponsors receive shout-outs in every release and can request tailored support depending on tier. If you’re interested—or have rollout feedback to share—you can view sponsorship options at [openiap.dev/sponsors](https://openiap.dev/sponsors).
94
+ **[Learn more about the OpenIAP standard ](https://openiap.dev/docs/foundation/about)**
95
+
96
+ ## Our Sponsors
97
+
98
+ 💼 **[View Our Sponsors](https://openiap.dev/sponsors)**
88
99
 
89
100
  ### <p style="color: rgb(255, 182, 193);">Angel</p>
90
101
 
@@ -2,6 +2,7 @@ package expo.modules.iap
2
2
 
3
3
  import android.util.Log
4
4
  import dev.hyo.openiap.AndroidSubscriptionOfferInput
5
+ import dev.hyo.openiap.OpenIapError
5
6
  import dev.hyo.openiap.OpenIapModule
6
7
  import dev.hyo.openiap.ProductQueryType
7
8
  import dev.hyo.openiap.SubscriptionProductReplacementParamsAndroid
@@ -54,18 +55,45 @@ object ExpoIapHelper {
54
55
  }
55
56
 
56
57
  fun parseRequestPurchaseParams(params: Map<String, Any?>): RequestPurchaseParams {
57
- val type = params["type"] as? String
58
+ // Support nested request.google / request.android structure
59
+ // If the params contain a "request" key with nested platform-specific data,
60
+ // extract and flatten it before parsing.
61
+ val effective: Map<String, Any?> = run {
62
+ val request = params["request"] as? Map<*, *>
63
+ if (request != null) {
64
+ val nested = (request["google"] as? Map<*, *>)
65
+ ?: (request["android"] as? Map<*, *>)
66
+ if (nested != null) {
67
+ val flat = mutableMapOf<String, Any?>()
68
+ // Carry over top-level fields like type, useAlternativeBilling
69
+ for ((k, v) in params) {
70
+ if (k is String && k != "request") flat[k] = v
71
+ }
72
+ // Overlay platform-specific fields
73
+ for ((k, v) in nested) {
74
+ if (k is String) flat[k] = v
75
+ }
76
+ flat
77
+ } else {
78
+ params
79
+ }
80
+ } else {
81
+ params
82
+ }
83
+ }
84
+
85
+ val type = effective["type"] as? String
58
86
  val skus: List<String> =
59
- (params["skus"] as? List<*>)?.filterIsInstance<String>()
60
- ?: (params["skuArr"] as? List<*>)?.filterIsInstance<String>()
87
+ (effective["skus"] as? List<*>)?.filterIsInstance<String>()
88
+ ?: (effective["skuArr"] as? List<*>)?.filterIsInstance<String>()
61
89
  ?: emptyList()
62
- val obfuscatedAccountId = params["obfuscatedAccountId"] as? String
63
- val obfuscatedProfileId = params["obfuscatedProfileId"] as? String
64
- val isOfferPersonalized = params["isOfferPersonalized"] as? Boolean ?: false
90
+ val obfuscatedAccountId = effective["obfuscatedAccountId"] as? String
91
+ val obfuscatedProfileId = effective["obfuscatedProfileId"] as? String
92
+ val isOfferPersonalized = effective["isOfferPersonalized"] as? Boolean ?: false
65
93
  val offerTokenArr =
66
- (params["offerTokenArr"] as? List<*>)?.filterIsInstance<String>() ?: emptyList()
94
+ (effective["offerTokenArr"] as? List<*>)?.filterIsInstance<String>() ?: emptyList()
67
95
  val explicitSubscriptionOffers =
68
- (params["subscriptionOffers"] as? List<*>)?.mapNotNull { rawOffer ->
96
+ (effective["subscriptionOffers"] as? List<*>)?.mapNotNull { rawOffer ->
69
97
  val offerMap = rawOffer as? Map<*, *> ?: return@mapNotNull null
70
98
  val sku = offerMap["sku"] as? String
71
99
  val offerToken = offerMap["offerToken"] as? String
@@ -75,10 +103,10 @@ object ExpoIapHelper {
75
103
  AndroidSubscriptionOfferInput(offerToken = offerToken, sku = sku)
76
104
  }
77
105
  } ?: emptyList()
78
- val purchaseToken = params["purchaseToken"] as? String
79
- val replacementMode = params["replacementMode"] as? Number
106
+ val purchaseToken = effective["purchaseToken"] as? String
107
+ val replacementMode = effective["replacementMode"] as? Number
80
108
  val subscriptionProductReplacementParams =
81
- (params["subscriptionProductReplacementParams"] as? Map<*, *>)?.let { paramsMap ->
109
+ (effective["subscriptionProductReplacementParams"] as? Map<*, *>)?.let { paramsMap ->
82
110
  val oldProductId = paramsMap["oldProductId"] as? String
83
111
  val replacementModeStr = paramsMap["replacementMode"] as? String
84
112
  if (oldProductId.isNullOrEmpty() || replacementModeStr.isNullOrEmpty()) {
@@ -91,7 +119,7 @@ object ExpoIapHelper {
91
119
  }
92
120
  }
93
121
  // offerToken for one-time purchase discounts (Android 7.0+)
94
- val offerToken = params["offerToken"] as? String
122
+ val offerToken = effective["offerToken"] as? String
95
123
 
96
124
  return RequestPurchaseParams(
97
125
  type = type,
@@ -215,7 +243,7 @@ object ExpoIapHelper {
215
243
  // Emit as purchase error so user knows something went wrong
216
244
  val errorPayload =
217
245
  mapOf(
218
- "code" to "purchase-error",
246
+ "code" to OpenIapError.PurchaseFailed.CODE,
219
247
  "message" to "Failed to process purchase update: ${error.message}",
220
248
  )
221
249
  runCatching {
@@ -246,7 +274,7 @@ object ExpoIapHelper {
246
274
  // Critical: if we can't emit the original error, at least try to emit a generic one
247
275
  val fallbackPayload =
248
276
  mapOf(
249
- "code" to "unknown",
277
+ "code" to OpenIapError.UnknownError.CODE,
250
278
  "message" to "Failed to emit purchase error: ${error.message}",
251
279
  )
252
280
  runCatching {
@@ -261,7 +289,7 @@ object ExpoIapHelper {
261
289
  }.onFailure { android.util.Log.e(TAG, "Failed to send fallback error event", it) }
262
290
  }
263
291
  // Also reject any pending purchase promises to match iOS behavior
264
- val errorCode = errorJson["code"] as? String ?: "purchase-error"
292
+ val errorCode = errorJson["code"] as? String ?: OpenIapError.PurchaseFailed.CODE
265
293
  val errorMessage = errorJson["message"] as? String ?: "Purchase failed"
266
294
  rejectPurchasePromises(errorCode, errorMessage, null)
267
295
  }
@@ -166,7 +166,7 @@ class ExpoIapModule : Module() {
166
166
 
167
167
  AsyncFunction("fetchProducts") { type: String, skuArr: Array<String>, promise: Promise ->
168
168
  ExpoIapLog.payload(
169
- "fetchProductsAndroid",
169
+ "fetchProducts",
170
170
  mapOf("type" to type, "skus" to skuArr.toList()),
171
171
  )
172
172
  scope.launch {
@@ -180,26 +180,26 @@ class ExpoIapModule : Module() {
180
180
  is FetchProductsResultSubscriptions -> result.value.orEmpty().map { it.toJson() }
181
181
  else -> emptyList<Map<String, Any?>>()
182
182
  }
183
- ExpoIapLog.result("fetchProductsAndroid", payload)
183
+ ExpoIapLog.result("fetchProducts", payload)
184
184
  promise.resolve(payload)
185
185
  } catch (e: Exception) {
186
- ExpoIapLog.failure("fetchProductsAndroid", e)
186
+ ExpoIapLog.failure("fetchProducts", e)
187
187
  promise.reject(OpenIapError.QueryProduct.CODE, e.message, null)
188
188
  }
189
189
  }
190
190
  }
191
191
 
192
192
  AsyncFunction("getAvailableItems") { options: Map<String, Any?>?, promise: Promise ->
193
- ExpoIapLog.payload("getAvailableItemsAndroid", options)
193
+ ExpoIapLog.payload("getAvailableItems", options)
194
194
  scope.launch {
195
195
  try {
196
196
  val purchaseOptions = options?.let { PurchaseOptions.fromJson(it) }
197
197
  val purchases = openIap.getAvailablePurchases(purchaseOptions)
198
198
  val payload = purchases.map { it.toJson() }
199
- ExpoIapLog.result("getAvailableItemsAndroid", payload)
199
+ ExpoIapLog.result("getAvailableItems", payload)
200
200
  promise.resolve(payload)
201
201
  } catch (e: Exception) {
202
- ExpoIapLog.failure("getAvailableItemsAndroid", e)
202
+ ExpoIapLog.failure("getAvailableItems", e)
203
203
  promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, null)
204
204
  }
205
205
  }
@@ -238,7 +238,7 @@ class ExpoIapModule : Module() {
238
238
  }
239
239
 
240
240
  AsyncFunction("requestPurchase") { params: Map<String, Any?>, promise: Promise ->
241
- ExpoIapLog.payload("requestPurchaseAndroid", params)
241
+ ExpoIapLog.payload("requestPurchase", params)
242
242
  val parsedParams = ExpoIapHelper.parseRequestPurchaseParams(params)
243
243
 
244
244
  val productType =
@@ -319,18 +319,16 @@ class ExpoIapModule : Module() {
319
319
  else -> emptyList()
320
320
  }
321
321
  ExpoIapLog.result(
322
- "requestPurchaseAndroid",
322
+ "requestPurchase",
323
323
  purchases.map { it.toJson() },
324
324
  )
325
325
  ExpoIapHelper.resolvePurchasePromises(purchases.map { it.toJson() })
326
326
  } catch (e: Exception) {
327
- ExpoIapLog.failure("requestPurchaseAndroid", e)
328
- // Try to use toJSON() if available (OpenIAP PurchaseError), otherwise create a generic error map
327
+ ExpoIapLog.failure("requestPurchase", e)
329
328
  val errorMap =
330
- runCatching {
331
- @Suppress("UNCHECKED_CAST")
332
- e.javaClass.getMethod("toJSON").invoke(e) as Map<String, Any?>
333
- }.getOrElse {
329
+ if (e is OpenIapError) {
330
+ e.toJSON()
331
+ } else {
334
332
  mapOf(
335
333
  "code" to OpenIapError.PurchaseFailed.CODE,
336
334
  "message" to (e.message ?: "Purchase failed"),
@@ -3,4 +3,4 @@ package expo.modules.iap
3
3
  import expo.modules.kotlin.exception.CodedException
4
4
 
5
5
  class MissingCurrentActivityException :
6
- CodedException("Activity which was provided during module initialization is no longer available")
6
+ CodedException("Current Activity is not available. Ensure the module is used within a running Activity context (e.g., not in a background service or after the Activity has been destroyed).")
@@ -50,13 +50,11 @@ object PromiseUtils {
50
50
  }
51
51
  }
52
52
 
53
- const val TAG = "IapPromises"
54
-
55
53
  fun Promise.safeResolve(value: Any?) {
56
54
  try {
57
55
  this.resolve(value)
58
56
  } catch (e: RuntimeException) {
59
- Log.d(TAG, "Already consumed ${e.message}")
57
+ Log.d(PromiseUtils.TAG, "Already consumed ${e.message}")
60
58
  }
61
59
  }
62
60
 
@@ -80,6 +78,6 @@ fun Promise.safeReject(
80
78
  try {
81
79
  this.reject(code, message, throwable)
82
80
  } catch (e: RuntimeException) {
83
- Log.d(TAG, "Already consumed ${e.message}")
81
+ Log.d(PromiseUtils.TAG, "Already consumed ${e.message}")
84
82
  }
85
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAsDA,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAOtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,QAE9B;;AAED,wBAOG"}
1
+ {"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAsDA,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAQtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,QAE9B;;AAED,wBAQG"}
@@ -36,7 +36,9 @@ function isMissingModuleError(error, moduleName) {
36
36
  return false;
37
37
  }
38
38
  export const NATIVE_ERROR_CODES = new Proxy({}, {
39
- get(_, prop) {
39
+ get(target, prop) {
40
+ if (typeof prop === 'symbol')
41
+ return Reflect.get(target, prop);
40
42
  return (getResolved().module.ERROR_CODES || {})[prop];
41
43
  },
42
44
  });
@@ -50,7 +52,9 @@ export function getNativeModule() {
50
52
  return getResolved().module;
51
53
  }
52
54
  export default new Proxy({}, {
53
- get(_, prop) {
55
+ get(target, prop) {
56
+ if (typeof prop === 'symbol')
57
+ return Reflect.get(target, prop);
54
58
  if (prop === 'USING_ONSIDE_SDK') {
55
59
  return getResolved().name === 'ExpoIapOnside';
56
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule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AM,CAAC,MAAM,kBAAkB,GAA4B,IAAI,KAAK,CAClE,EAA6B,EAC7B;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,OAAO,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAc,CAAC,CAAC;IAClE,CAAC;CACF,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,WAAW,EAAE,CAAC,MAAM,CAAC;AAC9B,CAAC;AAED,eAAe,IAAI,KAAK,CAAC,EAAS,EAAE;IAClC,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,IAAI,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAChC,OAAO,WAAW,EAAE,CAAC,IAAI,KAAK,eAAe,CAAC;QAChD,CAAC;QACD,OAAO,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {requireNativeModule, UnavailabilityError} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\n\ntype NativeIapModuleName = 'ExpoIapOnside' | 'ExpoIap';\n\nlet cached: {module: any; name: NativeIapModuleName} | null = null;\n\nfunction getResolved(): {module: any; name: NativeIapModuleName} {\n if (!cached) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction resolveNativeModule(): {\n module: any;\n name: NativeIapModuleName;\n} {\n const candidates: NativeIapModuleName[] = ['ExpoIapOnside', 'ExpoIap'];\n\n for (const name of candidates) {\n try {\n const module = requireNativeModule(name);\n if (name === 'ExpoIapOnside' && !installedFromOnside) {\n continue;\n }\n return {module, name};\n } catch (error) {\n if (name === 'ExpoIapOnside' && isMissingModuleError(error, name)) {\n continue;\n }\n\n throw error;\n }\n }\n\n throw new UnavailabilityError(\n 'expo-iap',\n 'ExpoIap native module is unavailable',\n );\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(_, 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(_, prop) {\n if (prop === 'USING_ONSIDE_SDK') {\n return getResolved().name === 'ExpoIapOnside';\n }\n return getResolved().module[prop];\n },\n});\n"]}
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;AAI7C,IAAI,MAAM,GAAoD,IAAI,CAAC;AAEnE,SAAS,WAAW;IAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB;IAI1B,MAAM,UAAU,GAA0B,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAEvE,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,IAAI,KAAK,eAAe,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACrD,SAAS;YACX,CAAC;YACD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;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C;QAChD,CAAC;QACD,OAAO,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {requireNativeModule, UnavailabilityError} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\n\ntype NativeIapModuleName = 'ExpoIapOnside' | 'ExpoIap';\n\nlet cached: {module: any; name: NativeIapModuleName} | null = null;\n\nfunction getResolved(): {module: any; name: NativeIapModuleName} {\n if (!cached) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction resolveNativeModule(): {\n module: any;\n name: NativeIapModuleName;\n} {\n const candidates: NativeIapModuleName[] = ['ExpoIapOnside', 'ExpoIap'];\n\n for (const name of candidates) {\n try {\n const module = requireNativeModule(name);\n if (name === 'ExpoIapOnside' && !installedFromOnside) {\n continue;\n }\n return {module, name};\n } catch (error) {\n if (name === 'ExpoIapOnside' && isMissingModuleError(error, name)) {\n continue;\n }\n\n throw error;\n }\n }\n\n throw new UnavailabilityError(\n 'expo-iap',\n 'ExpoIap native module is unavailable',\n );\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 if (prop === 'USING_ONSIDE_SDK') {\n return getResolved().name === 'ExpoIapOnside';\n }\n return getResolved().module[prop];\n },\n});\n"]}
@@ -22,7 +22,7 @@ export declare const syncIOS: MutationField<'syncIOS'>;
22
22
  /**
23
23
  * Check if user is eligible for introductory offer
24
24
  *
25
- * @param groupId The subscription group ID
25
+ * @param groupId - The subscription group ID
26
26
  * @returns Promise resolving to true if eligible
27
27
  * @throws Error if called on non-iOS platform
28
28
  *
@@ -28,17 +28,17 @@ export const syncIOS = async () => {
28
28
  /**
29
29
  * Check if user is eligible for introductory offer
30
30
  *
31
- * @param groupId The subscription group ID
31
+ * @param groupId - The subscription group ID
32
32
  * @returns Promise resolving to true if eligible
33
33
  * @throws Error if called on non-iOS platform
34
34
  *
35
35
  * @platform iOS
36
36
  */
37
- export const isEligibleForIntroOfferIOS = async (groupID) => {
38
- if (!groupID) {
39
- throw new Error('isEligibleForIntroOfferIOS requires a groupID');
37
+ export const isEligibleForIntroOfferIOS = async (groupId) => {
38
+ if (!groupId) {
39
+ throw new Error('isEligibleForIntroOfferIOS requires a groupId');
40
40
  }
41
- return ExpoIapModule.isEligibleForIntroOfferIOS(groupID);
41
+ return ExpoIapModule.isEligibleForIntroOfferIOS(groupId);
42
42
  };
43
43
  /**
44
44
  * Get subscription status for a specific SKU
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAoB7C,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAOrC,YAAY;AAEZ,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KA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nD,CAAC,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAEvC,KAAK,EAAE,GAAW,EAAE,EAAE;IACxB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,8BAA8B,CAAC,GAAG,CAAC,CAAC;IACvE,OAAO,MAAuC,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0CAA0C,GACrD,KAAK,IAAsB,EAAE;IAC3B,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,0CAA0C,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC;AAEJ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,EACxD,SAAiD,EACE,EAAE;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,qCAAqC,CACtE,SAAS,CACV,CAAC;IACF,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,EAC1D,UAAmD,EACC,EAAE;IACtD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,uCAAuC,CACxE,UAAU,CACX,CAAC;IACF,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n ExternalPurchaseCustomLinkNoticeResultIOS,\n ExternalPurchaseCustomLinkTokenResultIOS,\n ExternalPurchaseCustomLinkTokenTypeIOS,\n ExternalPurchaseCustomLinkNoticeTypeIOS,\n ExternalPurchaseLinkResultIOS,\n ExternalPurchaseNoticeResultIOS,\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n VerifyPurchaseProps,\n VerifyPurchaseResultIOS,\n SubscriptionStatusIOS,\n} from '../types';\nimport type {PurchaseError} from '../utils/errorMapping';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n return !!(await ExpoIapModule.syncIOS());\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupID) => {\n if (!groupID) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupID');\n }\n return ExpoIapModule.isEligibleForIntroOfferIOS(groupID);\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await ExpoIapModule.subscriptionStatusIOS(sku);\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await ExpoIapModule.currentEntitlementIOS(sku);\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await ExpoIapModule.latestTransactionIOS(sku);\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await ExpoIapModule.beginRefundRequestIOS(sku);\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n const purchases = await ExpoIapModule.showManageSubscriptionsIOS();\n return (purchases ?? []) as PurchaseIOS[];\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n return ExpoIapModule.getReceiptDataIOS();\n};\n\nexport const getReceiptIOS = getReceiptDataIOS;\n\n/**\n * Refresh the receipt data from Apple's servers and return the updated receipt.\n * This calls AppStore.sync() before reading the receipt, ensuring the latest\n * receipt data is available. Use this after a first purchase when\n * getReceiptDataIOS() may return an empty string because the receipt file\n * has not yet been written to disk.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @platform iOS\n */\nexport const requestReceiptRefreshIOS = async (): Promise<string> => {\n return ExpoIapModule.requestReceiptRefreshIOS();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return ExpoIapModule.isTransactionVerifiedIOS(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @deprecated Use verifyPurchase instead\n * @param props The product's SKU or verification props\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nconst validateReceiptIOSImpl = async (props: VerifyPurchaseProps | string) => {\n const sku =\n typeof props === 'string'\n ? props\n : (props as VerifyPurchaseProps)?.apple?.sku;\n\n if (!sku) {\n throw new Error('validateReceiptIOS requires a SKU (via apple.sku)');\n }\n\n return (await ExpoIapModule.validateReceiptIOS(\n sku,\n )) as VerifyPurchaseResultIOS;\n};\n\nexport const validateReceiptIOS =\n validateReceiptIOSImpl as QueryField<'validateReceiptIOS'>;\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns Promise resolving to true if the sheet was presented successfully\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n return !!(await ExpoIapModule.presentCodeRedemptionSheetIOS());\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n return (await ExpoIapModule.getAppTransactionIOS()) ?? null;\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n const product = await ExpoIapModule.getPromotedProductIOS();\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @deprecated Use promotedProductListenerIOS to receive the productId,\n * then call requestPurchase with that SKU instead.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS =\n async (): Promise<boolean> => {\n const result = await ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n return result ?? true;\n };\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n const transactions = await ExpoIapModule.getPendingTransactionsIOS();\n return (transactions ?? []) as PurchaseIOS[];\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n return !!(await ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 18.2+).\n *\n * @returns Promise resolving to true if the notice sheet can be presented\n * @platform iOS\n */\nexport const canPresentExternalPurchaseNoticeIOS: QueryField<\n 'canPresentExternalPurchaseNoticeIOS'\n> = async () => {\n return !!(await ExpoIapModule.canPresentExternalPurchaseNoticeIOS());\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 15.4+).\n * This must be called before opening an external purchase link.\n * Returns the external purchase token when user continues.\n *\n * @returns Promise resolving to the result with action, token, and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseNoticeSheetIOS =\n async (): Promise<ExternalPurchaseNoticeResultIOS> => {\n const result = await ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();\n return result as ExternalPurchaseNoticeResultIOS;\n };\n\n/**\n * Present an external purchase link to redirect users to your website (iOS 16.0+).\n *\n * @param url - The external purchase URL to open\n * @returns Promise resolving to the result with success status and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async (url: string) => {\n const result = await ExpoIapModule.presentExternalPurchaseLinkIOS(url);\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n * Returns true if the app can use custom external purchase links.\n *\n * @returns Promise resolving to true if eligible\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible\n */\nexport const isEligibleForExternalPurchaseCustomLinkIOS =\n async (): Promise<boolean> => {\n return !!(await ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS());\n };\n\n/**\n * Get external purchase token for reporting to Apple (iOS 18.1+).\n * Use this token with Apple's External Purchase Server API to report transactions.\n *\n * @param tokenType - Token type: 'acquisition' (new customers) or 'services' (existing customers)\n * @returns Promise resolving to the token result with token string or error\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)\n */\nexport const getExternalPurchaseCustomLinkTokenIOS = async (\n tokenType: ExternalPurchaseCustomLinkTokenTypeIOS,\n): Promise<ExternalPurchaseCustomLinkTokenResultIOS> => {\n if (!tokenType) {\n throw new Error(\n \"getExternalPurchaseCustomLinkTokenIOS requires a tokenType ('acquisition' or 'services')\",\n );\n }\n const result = await ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(\n tokenType,\n );\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Displays the system disclosure notice sheet for custom external purchase links.\n * Call this after a deliberate customer interaction before linking out to external purchases.\n *\n * @param noticeType - Notice type: 'browser' (external purchases displayed in browser)\n * @returns Promise resolving to the result with continued status and error if any\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)\n */\nexport const showExternalPurchaseCustomLinkNoticeIOS = async (\n noticeType: ExternalPurchaseCustomLinkNoticeTypeIOS,\n): Promise<ExternalPurchaseCustomLinkNoticeResultIOS> => {\n if (!noticeType) {\n throw new Error(\n \"showExternalPurchaseCustomLinkNoticeIOS requires a noticeType ('browser')\",\n );\n }\n const result = await ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(\n noticeType,\n );\n return result as ExternalPurchaseCustomLinkNoticeResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAoB7C,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAOrC,YAAY;AAEZ,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,CAC/C,CAAC;AACJ,CAAC;AAED,YAAY;AACZ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,IAAI,EAAE;IAC1D,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAEnC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,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C,CAAC,CAAC,MAAM,aAAa,CAAC,0CAA0C,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC;AAEJ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,EACxD,SAAiD,EACE,EAAE;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,qCAAqC,CACtE,SAAS,CACV,CAAC;IACF,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,EAC1D,UAAmD,EACC,EAAE;IACtD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,uCAAuC,CACxE,UAAU,CACX,CAAC;IACF,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n ExternalPurchaseCustomLinkNoticeResultIOS,\n ExternalPurchaseCustomLinkTokenResultIOS,\n ExternalPurchaseCustomLinkTokenTypeIOS,\n ExternalPurchaseCustomLinkNoticeTypeIOS,\n ExternalPurchaseLinkResultIOS,\n ExternalPurchaseNoticeResultIOS,\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n VerifyPurchaseProps,\n VerifyPurchaseResultIOS,\n SubscriptionStatusIOS,\n} from '../types';\nimport type {PurchaseError} from '../utils/errorMapping';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n return !!(await ExpoIapModule.syncIOS());\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId - The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupId) => {\n if (!groupId) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupId');\n }\n return ExpoIapModule.isEligibleForIntroOfferIOS(groupId);\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await ExpoIapModule.subscriptionStatusIOS(sku);\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await ExpoIapModule.currentEntitlementIOS(sku);\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await ExpoIapModule.latestTransactionIOS(sku);\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await ExpoIapModule.beginRefundRequestIOS(sku);\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n const purchases = await ExpoIapModule.showManageSubscriptionsIOS();\n return (purchases ?? []) as PurchaseIOS[];\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n return ExpoIapModule.getReceiptDataIOS();\n};\n\nexport const getReceiptIOS = getReceiptDataIOS;\n\n/**\n * Refresh the receipt data from Apple's servers and return the updated receipt.\n * This calls AppStore.sync() before reading the receipt, ensuring the latest\n * receipt data is available. Use this after a first purchase when\n * getReceiptDataIOS() may return an empty string because the receipt file\n * has not yet been written to disk.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @platform iOS\n */\nexport const requestReceiptRefreshIOS = async (): Promise<string> => {\n return ExpoIapModule.requestReceiptRefreshIOS();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return ExpoIapModule.isTransactionVerifiedIOS(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @deprecated Use verifyPurchase instead\n * @param props The product's SKU or verification props\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nconst validateReceiptIOSImpl = async (props: VerifyPurchaseProps | string) => {\n const sku =\n typeof props === 'string'\n ? props\n : (props as VerifyPurchaseProps)?.apple?.sku;\n\n if (!sku) {\n throw new Error('validateReceiptIOS requires a SKU (via apple.sku)');\n }\n\n return (await ExpoIapModule.validateReceiptIOS(\n sku,\n )) as VerifyPurchaseResultIOS;\n};\n\nexport const validateReceiptIOS =\n validateReceiptIOSImpl as QueryField<'validateReceiptIOS'>;\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns Promise resolving to true if the sheet was presented successfully\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n return !!(await ExpoIapModule.presentCodeRedemptionSheetIOS());\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n return (await ExpoIapModule.getAppTransactionIOS()) ?? null;\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n const product = await ExpoIapModule.getPromotedProductIOS();\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @deprecated Use promotedProductListenerIOS to receive the productId,\n * then call requestPurchase with that SKU instead.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS =\n async (): Promise<boolean> => {\n const result = await ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n return result ?? true;\n };\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n const transactions = await ExpoIapModule.getPendingTransactionsIOS();\n return (transactions ?? []) as PurchaseIOS[];\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n return !!(await ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 18.2+).\n *\n * @returns Promise resolving to true if the notice sheet can be presented\n * @platform iOS\n */\nexport const canPresentExternalPurchaseNoticeIOS: QueryField<\n 'canPresentExternalPurchaseNoticeIOS'\n> = async () => {\n return !!(await ExpoIapModule.canPresentExternalPurchaseNoticeIOS());\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 15.4+).\n * This must be called before opening an external purchase link.\n * Returns the external purchase token when user continues.\n *\n * @returns Promise resolving to the result with action, token, and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseNoticeSheetIOS =\n async (): Promise<ExternalPurchaseNoticeResultIOS> => {\n const result = await ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();\n return result as ExternalPurchaseNoticeResultIOS;\n };\n\n/**\n * Present an external purchase link to redirect users to your website (iOS 16.0+).\n *\n * @param url - The external purchase URL to open\n * @returns Promise resolving to the result with success status and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async (url: string) => {\n const result = await ExpoIapModule.presentExternalPurchaseLinkIOS(url);\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n * Returns true if the app can use custom external purchase links.\n *\n * @returns Promise resolving to true if eligible\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible\n */\nexport const isEligibleForExternalPurchaseCustomLinkIOS =\n async (): Promise<boolean> => {\n return !!(await ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS());\n };\n\n/**\n * Get external purchase token for reporting to Apple (iOS 18.1+).\n * Use this token with Apple's External Purchase Server API to report transactions.\n *\n * @param tokenType - Token type: 'acquisition' (new customers) or 'services' (existing customers)\n * @returns Promise resolving to the token result with token string or error\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)\n */\nexport const getExternalPurchaseCustomLinkTokenIOS = async (\n tokenType: ExternalPurchaseCustomLinkTokenTypeIOS,\n): Promise<ExternalPurchaseCustomLinkTokenResultIOS> => {\n if (!tokenType) {\n throw new Error(\n \"getExternalPurchaseCustomLinkTokenIOS requires a tokenType ('acquisition' or 'services')\",\n );\n }\n const result = await ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(\n tokenType,\n );\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Displays the system disclosure notice sheet for custom external purchase links.\n * Call this after a deliberate customer interaction before linking out to external purchases.\n *\n * @param noticeType - Notice type: 'browser' (external purchases displayed in browser)\n * @returns Promise resolving to the result with continued status and error if any\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)\n */\nexport const showExternalPurchaseCustomLinkNoticeIOS = async (\n noticeType: ExternalPurchaseCustomLinkNoticeTypeIOS,\n): Promise<ExternalPurchaseCustomLinkNoticeResultIOS> => {\n if (!noticeType) {\n throw new Error(\n \"showExternalPurchaseCustomLinkNoticeIOS requires a noticeType ('browser')\",\n );\n }\n const result = await ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(\n noticeType,\n );\n return result as ExternalPurchaseCustomLinkNoticeResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
package/build/types.d.ts CHANGED
@@ -302,6 +302,7 @@ export declare enum ErrorCode {
302
302
  ConnectionClosed = "connection-closed",
303
303
  DeferredPayment = "deferred-payment",
304
304
  DeveloperError = "developer-error",
305
+ DuplicatePurchase = "duplicate-purchase",
305
306
  EmptySkuList = "empty-sku-list",
306
307
  FeatureNotSupported = "feature-not-supported",
307
308
  IapNotAvailable = "iap-not-available",