expo-iap 3.0.7-rc.1 → 3.0.8

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 (67) hide show
  1. package/CHANGELOG.md +1 -310
  2. package/CLAUDE.md +12 -0
  3. package/android/build.gradle +1 -1
  4. package/build/index.d.ts +14 -66
  5. package/build/index.d.ts.map +1 -1
  6. package/build/index.js +149 -154
  7. package/build/index.js.map +1 -1
  8. package/build/modules/android.d.ts +7 -12
  9. package/build/modules/android.d.ts.map +1 -1
  10. package/build/modules/android.js +13 -11
  11. package/build/modules/android.js.map +1 -1
  12. package/build/modules/ios.d.ts +19 -35
  13. package/build/modules/ios.d.ts.map +1 -1
  14. package/build/modules/ios.js +86 -33
  15. package/build/modules/ios.js.map +1 -1
  16. package/build/types.d.ts +99 -76
  17. package/build/types.d.ts.map +1 -1
  18. package/build/types.js +1 -0
  19. package/build/types.js.map +1 -1
  20. package/build/useIAP.d.ts +6 -11
  21. package/build/useIAP.d.ts.map +1 -1
  22. package/build/useIAP.js +44 -15
  23. package/build/useIAP.js.map +1 -1
  24. package/build/utils/purchase.d.ts +9 -0
  25. package/build/utils/purchase.d.ts.map +1 -0
  26. package/build/utils/purchase.js +34 -0
  27. package/build/utils/purchase.js.map +1 -0
  28. package/package.json +2 -2
  29. package/plugin/build/withIAP.js +3 -3
  30. package/plugin/src/withIAP.ts +3 -3
  31. package/plugin/tsconfig.tsbuildinfo +1 -1
  32. package/src/index.ts +217 -255
  33. package/src/modules/android.ts +23 -22
  34. package/src/modules/ios.ts +123 -45
  35. package/src/types.ts +131 -85
  36. package/src/useIAP.ts +83 -42
  37. package/src/utils/purchase.ts +52 -0
  38. package/.copilot-instructions.md +0 -321
  39. package/.cursorrules +0 -321
  40. package/coverage/clover.xml +0 -440
  41. package/coverage/coverage-final.json +0 -7
  42. package/coverage/lcov-report/base.css +0 -224
  43. package/coverage/lcov-report/block-navigation.js +0 -87
  44. package/coverage/lcov-report/favicon.png +0 -0
  45. package/coverage/lcov-report/index.html +0 -161
  46. package/coverage/lcov-report/prettify.css +0 -1
  47. package/coverage/lcov-report/prettify.js +0 -2
  48. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  49. package/coverage/lcov-report/sorter.js +0 -196
  50. package/coverage/lcov-report/src/ExpoIap.types.ts.html +0 -1243
  51. package/coverage/lcov-report/src/PurchaseError.ts.html +0 -787
  52. package/coverage/lcov-report/src/helpers/index.html +0 -116
  53. package/coverage/lcov-report/src/helpers/subscription.ts.html +0 -496
  54. package/coverage/lcov-report/src/index.html +0 -131
  55. package/coverage/lcov-report/src/index.ts.html +0 -2236
  56. package/coverage/lcov-report/src/modules/android.ts.html +0 -544
  57. package/coverage/lcov-report/src/modules/index.html +0 -131
  58. package/coverage/lcov-report/src/modules/ios.ts.html +0 -952
  59. package/coverage/lcov-report/src/purchase-error.ts.html +0 -880
  60. package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +0 -493
  61. package/coverage/lcov-report/src/types/index.html +0 -116
  62. package/coverage/lcov-report/src/useIap.ts.html +0 -1483
  63. package/coverage/lcov-report/src/utils/errorMapping.ts.html +0 -529
  64. package/coverage/lcov-report/src/utils/index.html +0 -116
  65. package/coverage/lcov.info +0 -852
  66. package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  67. package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
package/CHANGELOG.md CHANGED
@@ -1,312 +1,3 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 3.0.6 (Breaking: useIAP) - 2025-09-18
4
-
5
- - Hook: Remove the transient `currentPurchase` / `currentPurchaseError` state from `useIAP` so consumers rely exclusively on the `onPurchaseSuccess` and `onPurchaseError` callbacks for post-purchase handling. This is a light breaking tweak for hook callers, but keeps the root API untouched.
6
-
7
- ## 3.0.5 - 2025-09-17
8
-
9
- - Types: Normalize OpenIAP literal unions to `'in-app'`, `'ios'`, and `'android'`, update `useIAP` helpers to the new `PurchaseRequestInput`, and refresh docs/examples/tests to the lowercase schema tokens.
10
- - Tooling: Regenerate `src/types.ts` with `openiap-gql` 1.0.2, add lint/format ignores for the generated file, and document the type update workflow.
11
- - Native: Upgrade the Android fallback/config plugin to [openiap-google 1.1.10](https://github.com/hyodotdev/openiap-google/releases/tag/1.1.10), bump the iOS pod to [openiap 1.1.12](https://github.com/hyodotdev/openiap-apple/releases/tag/1.1.12), adopt PascalCase error codes, and wire the new request parameter models through the bridges and config plugin.
12
-
13
- ## 3.0.4 - 2025-09-16
14
-
15
- - Types: Regenerate the OpenIAP schema with the canonical PascalCase names (`ProductIOS`, `PurchaseIOS`, etc.) and align docs/tests/examples with the new exports.
16
- - Errors: Promote `PurchaseError` to extend `Error`, tighten typings for platform error input/output, and ensure Android acknowledgement resolves a `VoidResult {success}` object.
17
- - Docs: Refresh iOS setup examples to use platform-specific request shapes, fix legacy `ErrorCode` references in versioned guides, and trim example helpers to the updated API surface.
18
- - Build: Adopt [openiap-gql 1.0.0](https://github.com/hyodotdev/openiap-gql/releases/tag/1.0.0) for the transport layer to stay aligned with the GraphQL contract shipped across the ecosystem.
19
-
20
- ## 3.0.3 - 2025-09-14
21
-
22
- - Types: Align Expo IAP surface with [react-native-iap #3006](https://github.com/hyochan/react-native-iap/pull/3006) by renaming subscription aliases, adding StoreKit product enums, and exposing optional purchase metadata (quantity, purchaseState, isAutoRenewing).
23
- - Errors: Switch JS helpers and docs to camelCase `ErrorCode` members and tighten error inspection utilities to avoid `any` usage.
24
-
25
- ## 3.0.2 - 2025-09-13
26
-
27
- - iOS: Fix build error “cannot convert value of type '[[String : Any?]]'” in Expo bridge by returning non‑optional dictionaries and removing double‑serialization in `showManageSubscriptionsIOS` (Fixes #202).
28
- - Examples: Make `requestPurchase` fire‑and‑forget with guards for test/mock envs to avoid spurious errors.
29
- - Hook: Dedupe purchase success events across re‑mounts to avoid duplicate logs in dev.
30
-
31
- ## 3.0.1 - 2025-09-13
32
-
33
- - Android: Ensure `openiap-google:1.1.0` is added inside `dependencies {}` and replace/dedupe existing entries. In local dev, remove the Maven line and rely on `project(':openiap-google')`. Library fallback bumped to 1.1.0.
34
- - iOS: Honor `enableLocalDev: false` even when `localPath` is set. Ensure CocoaPods CDN in Podfile and remove any stale local `pod 'openiap', :path => ...` lines.
35
- - Misc: Drop legacy Billing/GMS cleanup patterns, simplify prebuild logs, and add a short release blog post.
36
-
37
- ## 3.0.0 - 2025-09-13
38
-
39
- Breaking changes:
40
-
41
- - Remove legacy APIs: `getProducts`, `getSubscriptions`, `requestProducts`, `requestSubscription`, `getPurchaseHistory`/`getPurchaseHistories`, and non‑suffixed iOS aliases
42
- - `showManageSubscriptionsIOS()` now returns `Promise<Purchase[]>` (was `boolean`)
43
- - `getAvailablePurchases()` options now only accept iOS keys: `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`
44
-
45
- Features:
46
-
47
- - Unify tokens via `purchaseToken` on `Purchase` (iOS JWS + Android token)
48
- - Add `getReceiptDataIOS` alias for iOS receipt parity
49
-
50
- Refactor:
51
-
52
- - Remove deprecated comments/tests/mocks; simplify subscription dedup to `id`
53
- - Clean up hook surface and examples to current API
54
-
55
- Fixes:
56
-
57
- - iOS parity and guards across native bridge and TS layer
58
-
59
- Docs:
60
-
61
- - Add v3 migration and update API pages to remove legacy helpers
62
-
63
- Tests:
64
-
65
- - Remove legacy specs; all root and example suites pass
66
-
67
- ## [2.9.7] - 2025-09-12
68
-
69
- ### Changed
70
-
71
- - Android: remove `ensureConnection` wrapper in favor of `BillingClient` auto-reconnect and a simpler `getBillingClientOrReject` precheck
72
- - Android: also verify `BillingClient.isReady` before proceeding to avoid sporadic failures
73
- - Android: drop deprecated product fields from mapping (`displayName`, `name`, `oneTimePurchaseOfferDetails`, `subscriptionOfferDetails`) in favor of `...Android` suffixed fields
74
- - iOS: add `ensureConnection()` guard to all public async APIs; fix main-actor state updates and minor warnings
75
-
76
- ### Fixed
77
-
78
- - Android: fix stray brace that prematurely closed `ModuleDefinition` and ktlint trailing spaces
79
-
80
- ## [2.9.6] - 2025-09-11
81
-
82
- ### Fixed
83
-
84
- - Metro bundling error when importing the hook: fix "Unable to resolve '../../..' from node_modules/expo-iap/build/useIAP.js" by changing an ambiguous `import '.'` to an explicit `import './index'` inside `useIAP`. This prevents Metro from walking up to the app root and trying to resolve `expo-router/entry`.
85
-
86
- ### Notes
87
-
88
- - No runtime behavior changes; this is a bundling path fix only.
89
- - If you cannot upgrade immediately, temporary workaround: patch `node_modules/expo-iap/build/useIAP.js` to replace `from '.'` with `from './index'`, then clear cache (`npx expo start -c`).
90
-
91
- ## [2.9.5] - 2025-09-10
92
-
93
- ### Changed
94
-
95
- - iOS: Podspec pins `openiap` to `1.1.9` to prevent CocoaPods from resolving unintended versions and to stabilize builds.
96
-
97
- ### Deprecated
98
-
99
- - Deprecated `2.9.0`–`2.9.4` due to unpinned iOS dependency behavior in the wild. Please upgrade to `2.9.5`.
100
-
101
- ### Notes
102
-
103
- - If you encounter CocoaPods CDN issues, try `pod install --repo-update`. The config plugin already hardens Podfile sources, but network flakiness can still require a repo update.
104
-
105
- ## [2.9.3] - 2025-09-10
106
-
107
- ### Fixed
108
-
109
- - iOS: replace thrown `OpenIapError.*` and nonexistent types with `OpenIapFailure` cases to resolve build errors and align with error mapping
110
- - iOS: remove explicit `OpenIapErrorEvent` annotation in Swift listener (type is inferred from OpenIAP API)
111
-
112
- ### Notes
113
-
114
- - If your CocoaPods CDN is flaky, `pod install --repo-update` or temporarily pin `openiap` in your app Podfile.
115
-
116
- ## [2.9.1] - 2025-09-09
117
-
118
- ### Added
119
-
120
- - Expanded error codes and mappings (Android parity) with friendly messages in utilities
121
- - New object-style `PurchaseError` constructor and guideline in docs (legacy positional args remain supported)
122
- - Docs site can build for GitHub Pages via dynamic `baseUrl` switch
123
- - Example iOS: pin `openiap` to `1.1.7` via Git to avoid CocoaPods index lag
124
-
125
- ### Changed
126
-
127
- - iOS: `getPromotedProductIOS` now returns a fully serialized Product (fetch by SKU then serialize)
128
- - iOS: `subscriptionStatusIOS` returns `{ state, renewalInfo? }` where `renewalInfo.willAutoRenew` is a real boolean and `autoRenewPreference` is preserved
129
- - Hook: register purchase error listener early and ignore `E_INIT_CONNECTION` until connected
130
-
131
- ## [2.9.0] - 2025-09-05
132
-
133
- ### Added
134
-
135
- - iOS: Integrated OpenIAP Apple v1.1.6
136
- - Updated types to match OpenIAP v1.1.0 specification
137
- - Enhanced error handling with `PurchaseError` type and native error code mapping
138
- - New type system: `ProductRequest`, `RequestPurchaseProps`, `ReceiptValidationProps`
139
- - Improved receipt validation with `ReceiptValidationResult`
140
- - Root-level type re-exports to avoid deep imports (e.g., `ProductAndroid`, `ProductIOS`, `PaymentDiscount`)
141
-
142
- ### Changed
143
-
144
- - Updated serializers for purchases/products to follow OpenIAP structure
145
- - Updated listener setup to use new OpenIAP methods (`purchaseUpdatedListener`, `purchaseErrorListener`)
146
- - Added unified `removeAllListeners()` for cleanup
147
- - `showManageSubscriptionsIOS()` now returns updated subscriptions array (not boolean)
148
-
149
- ### Fixed
150
-
151
- - Fixed duplicate purchase success alerts
152
- - Fixed restore purchase alerts on screen entry
153
- - Improved purchase validation logic
154
-
155
- ### Note
156
-
157
- - Android native module integration with OpenIAP Android is planned for v3.0.0
158
-
159
- ## [2.8.8] - 2025-09-05
160
-
161
- ### Added
162
-
163
- - Enhanced `ActiveSubscription` interface with backend validation fields:
164
- - `transactionId` - Transaction identifier for backend validation
165
- - `purchaseToken` - JWT token (iOS) or purchase token (Android) for backend validation
166
- - `transactionDate` - Transaction timestamp
167
- - Return subscription changes from `showManageSubscriptionsIOS()` as Promise data
168
-
169
- ### Fixed
170
-
171
- - Fixed iOS `getAvailablePurchases({ onlyIncludeActiveItemsIOS: true })` returning expired subscriptions
172
- - Now correctly uses `Transaction.currentEntitlements` for better performance and accuracy
173
- - Fixed subscription status matching to specific SKU in `showManageSubscriptionsIOS()`
174
- - Prevents picking wrong status when multiple statuses exist in a subscription group
175
-
176
- ### Changed
177
-
178
- - Removed unnecessary event sending from `getAvailableItems()` - events are only sent from `requestPurchase()`
179
- - Removed polling logic from subscription status monitoring for cleaner code
180
- - Updated to comply with OpenIAP v1.1.1 specification
181
-
182
- ## [2.8.7] - 2025-09-03
183
-
184
- ### Added
185
-
186
- - `fetchProducts` function following OpenIAP terminology (replaces `requestProducts`)
187
-
188
- ### Deprecated
189
-
190
- - `requestProducts` - Use `fetchProducts` instead (will be removed in v3.0.0)
191
-
192
- ### Changed
193
-
194
- - Internal useIAP hook now uses `fetchProducts`
195
- - Updated documentation and deprecation messages
196
-
197
- ## [2.8.6]
198
-
199
- ### Changed
200
-
201
- - **BREAKING NAMING CONVENTION**: Added platform-specific suffixes to native functions for clarity
202
- - iOS functions now use `IOS` suffix (e.g., `getPromotedProductIOS`, `clearTransactionIOS`)
203
- - Android functions now use `Android` suffix (e.g., `acknowledgePurchaseAndroid`, `consumeProductAndroid`)
204
- - Common cross-platform functions remain without suffix (`requestProducts`, `requestPurchase`)
205
- - Renamed `buyPromotedProductIOS` to `requestPurchaseOnPromotedProductIOS` for consistency
206
-
207
- ### Added
208
-
209
- - Added `getPendingTransactionsIOS` function for iOS
210
- - Added `clearTransactionIOS` function for iOS
211
-
212
- ### Deprecated
213
-
214
- - `getPurchaseHistories` - Use `getAvailablePurchases` instead (will be removed in v2.9.0)
215
- - `buyPromotedProductIOS` - Use `requestPurchaseOnPromotedProductIOS` instead (will be removed in v2.9.0)
216
- - `disable` function - No longer needed, observer management is automatic (will be removed in v2.9.0)
217
-
218
- ## [2.8.5] - 2025-09-03
219
-
220
- ### Fixed
221
-
222
- - Fixed Android `finishTransaction` null error by adding fallback to `purchaseTokenAndroid` (#180)
223
-
224
- ## [2.8.4] - 2025-08-31
225
-
226
- ### Fixed
227
-
228
- - Fixed iOS 18.4 properties build failure on Xcode 16.3 and below by adding Swift 6.1 compiler guard
229
-
230
- ### Changed
231
-
232
- - Android: Enabled automatic service reconnection (Android Billing Client v8 feature) and simplified connection logic (#178)
233
-
234
- ## [2.8.3] - 2025-08-27
235
-
236
- ### Fixed
237
-
238
- - Fixed TypeScript type issues
239
- - Added critical warning about iOS platform version in podspec (#169)
240
-
241
- ## [2.8.2] - 2025-08-26
242
-
243
- ### Added
244
-
245
- - Added `platform` field to all IAP types for improved runtime type discrimination
246
- - Consolidated `Purchase` types and deprecated legacy type aliases for consistency
247
-
248
- ### Changed
249
-
250
- - Refactored and consolidated Purchase types to follow OpenIAP specification
251
- - Improved type consistency across iOS and Android platforms
252
-
253
- ### Deprecated
254
-
255
- **Note**: The following deprecated type aliases will be removed in v2.9.0:
256
-
257
- - `ProductPurchase` (use `Purchase` instead)
258
- - `SubscriptionPurchase` (use `Purchase` instead)
259
-
260
- ## [2.8.1] - 2025-08-19
261
-
262
- ### Added
263
-
264
- - Added `debugDescription?: string` field to `ProductCommon` for debugging purposes
265
- - Added `platform?: string` field to `ProductCommon` and `PurchaseCommon` for platform identification
266
- - Added `platform: "ios"` to iOS-specific types (`ProductIOS`, `ProductSubscriptionIOS`, `PurchaseIOS`)
267
- - Added `platform: "android"` to Android-specific types (`ProductAndroid`, `ProductSubscriptionAndroid`, `PurchaseAndroid`)
268
- - Added `ids?: string[]` field to `PurchaseCommon` (moved from Android-specific types)
269
-
270
- ### Changed
271
-
272
- - Moved common fields from platform-specific types to shared Common types
273
- - Updated iOS native code to populate missing subscription fields:
274
- - `introductoryPriceAsAmountIOS`
275
- - `introductoryPricePaymentModeIOS`
276
- - `introductoryPriceNumberOfPeriodsIOS`
277
- - `introductoryPriceSubscriptionPeriodIOS`
278
- - `subscriptionPeriodNumberIOS`
279
- - `subscriptionPeriodUnitIOS`
280
- - Updated Android native code to use common `ids` field instead of platform-specific `idsAndroid`
281
-
282
- ### Fixed
283
-
284
- - Fixed type mismatches between Product and Purchase types across iOS and Android platforms
285
- - Resolved missing field mappings in iOS native subscription data extraction
286
- - Improved type consistency for cross-platform compatibility
287
-
288
- ### Deprecated
289
-
290
- **Note**: No breaking changes in this release. The following deprecated fields will be removed in v2.9.0:
291
-
292
- - Android: `idsAndroid` (use common `ids` field instead)
293
- - Android: `name`, `oneTimePurchaseOfferDetails`, `subscriptionOfferDetails` (use fields with `Android` suffix)
294
- - iOS: `displayName`, `isFamilyShareable`, `jsonRepresentation`, `subscription` (use fields with `IOS` suffix)
295
- - iOS: `discounts`, `introductoryPrice` (use fields with `IOS` suffix)
296
-
297
- ## [2.8.0] - 2025-08-18
298
-
299
- ### Breaking Changes
300
-
301
- - **iOS Field Naming Convention**: All iOS-related field names ending with "Ios" have been renamed to end with "IOS" to follow the convention that acronyms at the end of field names should be uppercase.
302
-
303
- **Migration Guide**: See the full migration guide at [hyochan.github.io/expo-iap/blog/v2-8-0-migration-guide](https://hyochan.github.io/expo-iap/blog/v2-8-0-migration-guide)
304
-
305
- Affected fields:
306
-
307
- - `quantityIos` → `quantityIOS`
308
- - `expirationDateIos` → `expirationDateIOS`
309
- - `environmentIos` → `environmentIOS`
310
- - And all other iOS-suffixed fields
311
-
312
- For older versions, checkout [Release Notes](https://github.com/hyochan/expo-iap/releases)
3
+ [Check release notes](https://github.com/hyochan/expo-iap/releases)
package/CLAUDE.md CHANGED
@@ -8,6 +8,11 @@
8
8
  - Subject must be imperative, lowercase, without a trailing period, and roughly 50 characters
9
9
  - Wrap commit body lines near 72 characters and include footers such as `BREAKING CHANGE:` or `Closes #123` when needed
10
10
 
11
+ ## Tooling & Package Management
12
+
13
+ - **Use Bun exclusively.** Run installs with `bun install`, scripts with `bun run <script>`, add deps via `bun add` / `bun add -d`.
14
+ - Do **not** suggest or create `package-lock.json` or `yarn.lock`; `bun.lock` is the single source of truth.
15
+
11
16
  ## Expo-Specific Guidelines
12
17
 
13
18
  ### iOS Pod Configuration
@@ -38,6 +43,11 @@ Before committing any changes:
38
43
 
39
44
  ### Platform-Specific Naming Conventions
40
45
 
46
+ #### Function Naming
47
+
48
+ - Functions that only operate on one platform must carry the suffix: `nameIOS` or `nameAndroid` (e.g. `getStorefrontIOS`, `deepLinkToSubscriptionsAndroid`).
49
+ - Cross-platform helpers should expose a single name and branch internally via `Platform.select` or equivalent.
50
+
41
51
  #### Field Naming
42
52
 
43
53
  - **iOS-related fields**: Use `IOS` suffix (e.g., `displayNameIOS`, `discountsIOS`, `introductoryPriceIOS`)
@@ -72,6 +82,8 @@ The library follows the OpenIAP type specifications with platform-specific exten
72
82
 
73
83
  > **Important:** `src/types.ts` is generated from the OpenIAP schema. Never edit this file manually or commit hand-written changes. After updating any `*.graphql` schema, run `bun run generate:types` (or the equivalent script in your package manager) to refresh the file.
74
84
 
85
+ - 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`.
86
+
75
87
  ### React/JSX Conventions
76
88
 
77
89
  - **Conditional Rendering**: Use ternary operator with null instead of logical AND
@@ -58,6 +58,6 @@ dependencies {
58
58
  implementation project(":openiap-google")
59
59
  } else {
60
60
  // Fallback to published artifact when local project isn't linked
61
- implementation "io.github.hyochan.openiap:openiap-google:1.1.11"
61
+ implementation "io.github.hyochan.openiap:openiap-google:1.1.12"
62
62
  }
63
63
  }
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Product, Purchase, RequestPurchaseProps, RequestPurchasePropsByPlatforms, RequestSubscriptionPropsByPlatforms, ProductSubscription, VoidResult, ReceiptValidationResult } from './types';
1
+ import type { MutationField, Product, ProductQueryType, Purchase, QueryField } from './types';
2
2
  import { PurchaseError } from './purchase-error';
3
3
  export * from './types';
4
4
  export { ErrorCodeUtils, ErrorCodeMapping } from './purchase-error';
@@ -28,24 +28,7 @@ export declare const emitter: ExpoIapEmitter;
28
28
  /**
29
29
  * TODO(v3.1.0): Remove legacy 'inapp' alias once downstream apps migrate to 'in-app'.
30
30
  */
31
- export type ProductTypeInput = 'inapp' | 'in-app' | 'subs';
32
- export type InAppTypeInput = Exclude<ProductTypeInput, 'subs'>;
33
- type PurchaseRequestInApp = {
34
- request: RequestPurchasePropsByPlatforms;
35
- type?: InAppTypeInput;
36
- };
37
- type PurchaseRequestSubscription = {
38
- request: RequestSubscriptionPropsByPlatforms;
39
- type: 'subs';
40
- };
41
- export type PurchaseRequestInput = PurchaseRequestInApp | PurchaseRequestSubscription;
42
- export type PurchaseRequest = {
43
- request: RequestPurchaseProps;
44
- type?: InAppTypeInput;
45
- } | {
46
- request: RequestSubscriptionPropsByPlatforms;
47
- type: 'subs';
48
- };
31
+ export type ProductTypeInput = ProductQueryType | 'inapp';
49
32
  export declare const purchaseUpdatedListener: (listener: (event: Purchase) => void) => {
50
33
  remove: () => void;
51
34
  };
@@ -75,38 +58,17 @@ export declare const purchaseErrorListener: (listener: (error: PurchaseError) =>
75
58
  export declare const promotedProductListenerIOS: (listener: (product: Product) => void) => {
76
59
  remove: () => void;
77
60
  };
78
- export declare function initConnection(): Promise<boolean>;
79
- export declare function endConnection(): Promise<boolean>;
61
+ export declare const initConnection: MutationField<'initConnection'>;
62
+ export declare const endConnection: MutationField<'endConnection'>;
80
63
  /**
81
64
  * Fetch products with unified API (v2.7.0+)
82
65
  *
83
- * @param params - Product fetch configuration
84
- * @param params.skus - Array of product SKUs to fetch
85
- * @param params.type - Type of products: 'in-app' for regular products (default) or 'subs' for subscriptions
86
- *
87
- * @example
88
- * ```typescript
89
- * // Regular products
90
- * const products = await fetchProducts({
91
- * skus: ['product1', 'product2'],
92
- * type: 'in-app'
93
- * });
94
- *
95
- * // Subscriptions
96
- * const subscriptions = await fetchProducts({
97
- * skus: ['sub1', 'sub2'],
98
- * type: 'subs'
99
- * });
100
- * ```
66
+ * @param request - Product fetch configuration
67
+ * @param request.skus - Array of product SKUs to fetch
68
+ * @param request.type - Product query type: 'in-app', 'subs', or 'all'
101
69
  */
102
- export declare const fetchProducts: ({ skus, type, }: {
103
- skus: string[];
104
- type?: ProductTypeInput;
105
- }) => Promise<Product[] | ProductSubscription[]>;
106
- export declare const getAvailablePurchases: ({ alsoPublishToEventListenerIOS, onlyIncludeActiveItemsIOS, }?: {
107
- alsoPublishToEventListenerIOS?: boolean;
108
- onlyIncludeActiveItemsIOS?: boolean;
109
- }) => Promise<Purchase[]>;
70
+ export declare const fetchProducts: QueryField<'fetchProducts'>;
71
+ export declare const getAvailablePurchases: QueryField<'getAvailablePurchases'>;
110
72
  /**
111
73
  * Restore completed transactions (cross-platform behavior)
112
74
  *
@@ -120,10 +82,7 @@ export declare const getAvailablePurchases: ({ alsoPublishToEventListenerIOS, on
120
82
  * @param options.onlyIncludeActiveItemsIOS - iOS only: whether to only include active items
121
83
  * @returns Promise resolving to the list of available/restored purchases
122
84
  */
123
- export declare const restorePurchases: (options?: {
124
- alsoPublishToEventListenerIOS?: boolean;
125
- onlyIncludeActiveItemsIOS?: boolean;
126
- }) => Promise<Purchase[]>;
85
+ export declare const restorePurchases: MutationField<'restorePurchases'>;
127
86
  /**
128
87
  * Request a purchase for products or subscriptions.
129
88
  *
@@ -155,11 +114,8 @@ export declare const restorePurchases: (options?: {
155
114
  * });
156
115
  * ```
157
116
  */
158
- export declare const requestPurchase: (requestObj: PurchaseRequestInput) => Promise<Purchase | Purchase[] | void>;
159
- export declare const finishTransaction: ({ purchase, isConsumable, }: {
160
- purchase: Purchase;
161
- isConsumable?: boolean;
162
- }) => Promise<VoidResult | boolean>;
117
+ export declare const requestPurchase: MutationField<'requestPurchase'>;
118
+ export declare const finishTransaction: MutationField<'finishTransaction'>;
163
119
  /**
164
120
  * Retrieves the current storefront information from iOS App Store
165
121
  *
@@ -191,12 +147,7 @@ export declare const getStorefront: () => Promise<string>;
191
147
  * - iOS: Send receipt data to Apple's verification endpoint from your server
192
148
  * - Android: Use Google Play Developer API with service account credentials
193
149
  */
194
- export declare const validateReceipt: (sku: string, androidOptions?: {
195
- packageName: string;
196
- productToken: string;
197
- accessToken: string;
198
- isSub?: boolean;
199
- }) => Promise<ReceiptValidationResult>;
150
+ export declare const validateReceipt: MutationField<'validateReceipt'>;
200
151
  /**
201
152
  * Deeplinks to native interface that allows users to manage their subscriptions
202
153
  * @param options.skuAndroid - Required for Android to locate specific subscription (ignored on iOS)
@@ -215,10 +166,7 @@ export declare const validateReceipt: (sku: string, androidOptions?: {
215
166
  * packageNameAndroid: 'com.example.app'
216
167
  * });
217
168
  */
218
- export declare const deepLinkToSubscriptions: (options: {
219
- skuAndroid?: string;
220
- packageNameAndroid?: string;
221
- }) => Promise<void>;
169
+ export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscriptions'>;
222
170
  export * from './useIAP';
223
171
  export * from './utils/errorMapping';
224
172
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,OAAO,EACP,QAAQ,EAER,oBAAoB,EACpB,+BAA+B,EAG/B,mCAAmC,EAGnC,mBAAmB,EAGnB,UAAU,EACV,uBAAuB,EAExB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAG/C,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClE,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC,eAAO,MAAM,EAAE,KAAmB,CAAC;AAEnC,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;CAC5C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAE1C;AAED,KAAK,oBAAoB,GAAG;IAC1B,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,QAAQ,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