expo-iap 3.0.7 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CLAUDE.md +14 -2
  2. package/CONTRIBUTING.md +19 -0
  3. package/README.md +18 -6
  4. package/android/build.gradle +24 -1
  5. package/android/src/main/java/expo/modules/iap/ExpoIapLog.kt +69 -0
  6. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +190 -59
  7. package/build/index.d.ts +32 -111
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +198 -243
  10. package/build/index.js.map +1 -1
  11. package/build/modules/android.d.ts +7 -12
  12. package/build/modules/android.d.ts.map +1 -1
  13. package/build/modules/android.js +15 -12
  14. package/build/modules/android.js.map +1 -1
  15. package/build/modules/ios.d.ts +35 -36
  16. package/build/modules/ios.d.ts.map +1 -1
  17. package/build/modules/ios.js +101 -35
  18. package/build/modules/ios.js.map +1 -1
  19. package/build/types.d.ts +107 -82
  20. package/build/types.d.ts.map +1 -1
  21. package/build/types.js +1 -0
  22. package/build/types.js.map +1 -1
  23. package/build/useIAP.d.ts +7 -12
  24. package/build/useIAP.d.ts.map +1 -1
  25. package/build/useIAP.js +49 -23
  26. package/build/useIAP.js.map +1 -1
  27. package/build/utils/errorMapping.d.ts +32 -23
  28. package/build/utils/errorMapping.d.ts.map +1 -1
  29. package/build/utils/errorMapping.js +117 -22
  30. package/build/utils/errorMapping.js.map +1 -1
  31. package/ios/ExpoIap.podspec +3 -2
  32. package/ios/ExpoIapHelper.swift +96 -0
  33. package/ios/ExpoIapLog.swift +127 -0
  34. package/ios/ExpoIapModule.swift +218 -340
  35. package/openiap-versions.json +5 -0
  36. package/package.json +2 -2
  37. package/plugin/build/withIAP.js +6 -4
  38. package/plugin/src/withIAP.ts +14 -4
  39. package/scripts/update-types.mjs +20 -1
  40. package/src/index.ts +280 -356
  41. package/src/modules/android.ts +25 -23
  42. package/src/modules/ios.ts +138 -48
  43. package/src/types.ts +139 -91
  44. package/src/useIAP.ts +91 -58
  45. package/src/utils/errorMapping.ts +203 -23
  46. package/.copilot-instructions.md +0 -321
  47. package/.cursorrules +0 -321
  48. package/build/purchase-error.d.ts +0 -67
  49. package/build/purchase-error.d.ts.map +0 -1
  50. package/build/purchase-error.js +0 -166
  51. package/build/purchase-error.js.map +0 -1
  52. package/src/purchase-error.ts +0 -265
@@ -2,14 +2,15 @@
2
2
  // Internal modules
3
3
  // import removed: use purchaseUpdatedListener directly in app code
4
4
  import ExpoIapModule from '../ExpoIapModule';
5
- import { Linking } from 'react-native';
5
+ import { Linking, Platform } from 'react-native';
6
6
  // Listeners
7
7
  // Type guards
8
8
  export function isProductIOS(item) {
9
9
  return (item != null &&
10
10
  typeof item === 'object' &&
11
11
  'platform' in item &&
12
- item.platform === 'ios');
12
+ typeof item.platform === 'string' &&
13
+ item.platform.toLowerCase() === 'ios');
13
14
  }
14
15
  // Functions
15
16
  /**
@@ -21,8 +22,8 @@ export function isProductIOS(item) {
21
22
  *
22
23
  * @platform iOS
23
24
  */
24
- export const syncIOS = () => {
25
- return ExpoIapModule.syncIOS();
25
+ export const syncIOS = async () => {
26
+ return Boolean(await ExpoIapModule.syncIOS());
26
27
  };
27
28
  /**
28
29
  * Check if user is eligible for introductory offer
@@ -33,8 +34,11 @@ export const syncIOS = () => {
33
34
  *
34
35
  * @platform iOS
35
36
  */
36
- export const isEligibleForIntroOfferIOS = (groupId) => {
37
- return ExpoIapModule.isEligibleForIntroOfferIOS(groupId);
37
+ export const isEligibleForIntroOfferIOS = async (groupID) => {
38
+ if (!groupID) {
39
+ throw new Error('isEligibleForIntroOfferIOS requires a groupID');
40
+ }
41
+ return ExpoIapModule.isEligibleForIntroOfferIOS(groupID);
38
42
  };
39
43
  /**
40
44
  * Get subscription status for a specific SKU
@@ -45,8 +49,12 @@ export const isEligibleForIntroOfferIOS = (groupId) => {
45
49
  *
46
50
  * @platform iOS
47
51
  */
48
- export const subscriptionStatusIOS = (sku) => {
49
- return ExpoIapModule.subscriptionStatusIOS(sku);
52
+ export const subscriptionStatusIOS = async (sku) => {
53
+ if (!sku) {
54
+ throw new Error('subscriptionStatusIOS requires a SKU');
55
+ }
56
+ const status = await ExpoIapModule.subscriptionStatusIOS(sku);
57
+ return (status ?? []);
50
58
  };
51
59
  /**
52
60
  * Get current entitlement for a specific SKU
@@ -57,8 +65,12 @@ export const subscriptionStatusIOS = (sku) => {
57
65
  *
58
66
  * @platform iOS
59
67
  */
60
- export const currentEntitlementIOS = (sku) => {
61
- return ExpoIapModule.currentEntitlementIOS(sku);
68
+ export const currentEntitlementIOS = async (sku) => {
69
+ if (!sku) {
70
+ throw new Error('currentEntitlementIOS requires a SKU');
71
+ }
72
+ const purchase = await ExpoIapModule.currentEntitlementIOS(sku);
73
+ return (purchase ?? null);
62
74
  };
63
75
  /**
64
76
  * Get latest transaction for a specific SKU
@@ -69,11 +81,28 @@ export const currentEntitlementIOS = (sku) => {
69
81
  *
70
82
  * @platform iOS
71
83
  */
72
- export const latestTransactionIOS = (sku) => {
73
- return ExpoIapModule.latestTransactionIOS(sku);
84
+ export const latestTransactionIOS = async (sku) => {
85
+ if (!sku) {
86
+ throw new Error('latestTransactionIOS requires a SKU');
87
+ }
88
+ const transaction = await ExpoIapModule.latestTransactionIOS(sku);
89
+ return (transaction ?? null);
74
90
  };
75
- export const beginRefundRequestIOS = (sku) => {
76
- return ExpoIapModule.beginRefundRequestIOS(sku);
91
+ /**
92
+ * Begin refund request for a specific SKU
93
+ *
94
+ * @param sku The product SKU
95
+ * @returns Promise resolving to refund request status
96
+ * @throws Error if called on non-iOS platform
97
+ *
98
+ * @platform iOS
99
+ */
100
+ export const beginRefundRequestIOS = async (sku) => {
101
+ if (!sku) {
102
+ throw new Error('beginRefundRequestIOS requires a SKU');
103
+ }
104
+ const status = await ExpoIapModule.beginRefundRequestIOS(sku);
105
+ return status ?? null;
77
106
  };
78
107
  /**
79
108
  * Shows the system UI for managing subscriptions.
@@ -84,8 +113,9 @@ export const beginRefundRequestIOS = (sku) => {
84
113
  *
85
114
  * @platform iOS
86
115
  */
87
- export const showManageSubscriptionsIOS = () => {
88
- return ExpoIapModule.showManageSubscriptionsIOS();
116
+ export const showManageSubscriptionsIOS = async () => {
117
+ const purchases = await ExpoIapModule.showManageSubscriptionsIOS();
118
+ return (purchases ?? []);
89
119
  };
90
120
  /**
91
121
  * Get the receipt data from the iOS device.
@@ -97,9 +127,31 @@ export const showManageSubscriptionsIOS = () => {
97
127
  *
98
128
  * @returns {Promise<string>} Base64 encoded receipt data
99
129
  */
100
- export const getReceiptIOS = () => {
130
+ export const getReceiptDataIOS = async () => {
101
131
  return ExpoIapModule.getReceiptDataIOS();
102
132
  };
133
+ export const getReceiptIOS = getReceiptDataIOS;
134
+ /**
135
+ * Retrieves the current storefront information from the iOS App Store.
136
+ *
137
+ * @returns Promise resolving to the storefront country code
138
+ * @throws Error if called on non-iOS platform
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const storefront = await getStorefrontIOS();
143
+ * console.log(storefront); // 'US'
144
+ * ```
145
+ *
146
+ * @platform iOS
147
+ */
148
+ export const getStorefrontIOS = async () => {
149
+ if (Platform.OS !== 'ios') {
150
+ console.warn('getStorefrontIOS: This method is only available on iOS');
151
+ return '';
152
+ }
153
+ return ExpoIapModule.getStorefrontIOS();
154
+ };
103
155
  /**
104
156
  * Check if a transaction is verified through StoreKit 2.
105
157
  * StoreKit 2 performs local verification of transaction JWS signatures.
@@ -110,7 +162,10 @@ export const getReceiptIOS = () => {
110
162
  *
111
163
  * @platform iOS
112
164
  */
113
- export const isTransactionVerifiedIOS = (sku) => {
165
+ export const isTransactionVerifiedIOS = async (sku) => {
166
+ if (!sku) {
167
+ throw new Error('isTransactionVerifiedIOS requires a SKU');
168
+ }
114
169
  return ExpoIapModule.isTransactionVerifiedIOS(sku);
115
170
  };
116
171
  /**
@@ -123,8 +178,12 @@ export const isTransactionVerifiedIOS = (sku) => {
123
178
  *
124
179
  * @platform iOS
125
180
  */
126
- export const getTransactionJwsIOS = (sku) => {
127
- return ExpoIapModule.getTransactionJwsIOS(sku);
181
+ export const getTransactionJwsIOS = async (sku) => {
182
+ if (!sku) {
183
+ throw new Error('getTransactionJwsIOS requires a SKU');
184
+ }
185
+ const jws = await ExpoIapModule.getTransactionJwsIOS(sku);
186
+ return jws ?? '';
128
187
  };
129
188
  /**
130
189
  * Validate receipt for iOS using StoreKit 2's built-in verification.
@@ -141,10 +200,14 @@ export const getTransactionJwsIOS = (sku) => {
141
200
  * latestTransaction?: Purchase;
142
201
  * }>}
143
202
  */
144
- export const validateReceiptIOS = async (sku) => {
145
- const result = await ExpoIapModule.validateReceiptIOS(sku);
146
- return result;
203
+ const validateReceiptIOSImpl = async (props) => {
204
+ const sku = typeof props === 'string' ? props : props?.sku;
205
+ if (!sku) {
206
+ throw new Error('validateReceiptIOS requires a SKU');
207
+ }
208
+ return (await ExpoIapModule.validateReceiptIOS(sku));
147
209
  };
210
+ export const validateReceiptIOS = validateReceiptIOSImpl;
148
211
  /**
149
212
  * Present the code redemption sheet for offer codes (iOS only).
150
213
  * This allows users to redeem promotional codes for in-app purchases and subscriptions.
@@ -156,8 +219,8 @@ export const validateReceiptIOS = async (sku) => {
156
219
  *
157
220
  * @platform iOS
158
221
  */
159
- export const presentCodeRedemptionSheetIOS = () => {
160
- return ExpoIapModule.presentCodeRedemptionSheetIOS();
222
+ export const presentCodeRedemptionSheetIOS = async () => {
223
+ return Boolean(await ExpoIapModule.presentCodeRedemptionSheetIOS());
161
224
  };
162
225
  /**
163
226
  * Get app transaction information (iOS 16.0+).
@@ -173,8 +236,8 @@ export const presentCodeRedemptionSheetIOS = () => {
173
236
  * @platform iOS
174
237
  * @since iOS 16.0
175
238
  */
176
- export const getAppTransactionIOS = () => {
177
- return ExpoIapModule.getAppTransactionIOS();
239
+ export const getAppTransactionIOS = async () => {
240
+ return (await ExpoIapModule.getAppTransactionIOS()) ?? null;
178
241
  };
179
242
  /**
180
243
  * Get information about a promoted product if one is available (iOS only).
@@ -186,8 +249,9 @@ export const getAppTransactionIOS = () => {
186
249
  *
187
250
  * @platform iOS
188
251
  */
189
- export const getPromotedProductIOS = () => {
190
- return ExpoIapModule.getPromotedProductIOS();
252
+ export const getPromotedProductIOS = async () => {
253
+ const product = await ExpoIapModule.getPromotedProductIOS();
254
+ return (product ?? null);
191
255
  };
192
256
  /**
193
257
  * Complete the purchase of a promoted product (iOS only).
@@ -198,8 +262,9 @@ export const getPromotedProductIOS = () => {
198
262
  *
199
263
  * @platform iOS
200
264
  */
201
- export const requestPurchaseOnPromotedProductIOS = () => {
202
- return ExpoIapModule.requestPurchaseOnPromotedProductIOS();
265
+ export const requestPurchaseOnPromotedProductIOS = async () => {
266
+ await ExpoIapModule.requestPurchaseOnPromotedProductIOS();
267
+ return true;
203
268
  };
204
269
  /**
205
270
  * Get pending transactions that haven't been finished yet (iOS only).
@@ -207,8 +272,9 @@ export const requestPurchaseOnPromotedProductIOS = () => {
207
272
  * @returns Promise resolving to array of pending transactions
208
273
  * @platform iOS
209
274
  */
210
- export const getPendingTransactionsIOS = () => {
211
- return ExpoIapModule.getPendingTransactionsIOS();
275
+ export const getPendingTransactionsIOS = async () => {
276
+ const transactions = await ExpoIapModule.getPendingTransactionsIOS();
277
+ return (transactions ?? []);
212
278
  };
213
279
  /**
214
280
  * Clear a specific transaction (iOS only).
@@ -216,8 +282,8 @@ export const getPendingTransactionsIOS = () => {
216
282
  * @returns Promise resolving when transaction is cleared
217
283
  * @platform iOS
218
284
  */
219
- export const clearTransactionIOS = () => {
220
- return ExpoIapModule.clearTransactionIOS();
285
+ export const clearTransactionIOS = async () => {
286
+ return Boolean(await ExpoIapModule.clearTransactionIOS());
221
287
  };
222
288
  /**
223
289
  * Deep link to subscriptions screen on iOS.
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAA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AmC,GAAG,GAAkB,EAAE;IACrE,OAAO,aAAa,CAAC,mCAAmC,EAAE,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAmB,EAAE;IAC5D,OAAO,aAAa,CAAC,yBAAyB,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAkB,EAAE;IACrD,OAAO,aAAa,CAAC,mBAAmB,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAkB,EAAE,CAC5D,OAAO,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAElE,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 Product,\n Purchase,\n SubscriptionStatusIOS,\n AppTransaction,\n ReceiptValidationResultIOS,\n} from '../types';\nimport type {PurchaseError} from '../purchase-error';\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 (item as any).platform === '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 = (): Promise<null> => {\n return 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 = (\n groupId: string,\n): Promise<boolean> => {\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 = (\n sku: string,\n): Promise<SubscriptionStatusIOS[]> => {\n return ExpoIapModule.subscriptionStatusIOS(sku);\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 = (sku: string): Promise<Purchase> => {\n return ExpoIapModule.currentEntitlementIOS(sku);\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 = (sku: string): Promise<Purchase> => {\n return ExpoIapModule.latestTransactionIOS(sku);\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 */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequestIOS = (\n sku: string,\n): Promise<RefundRequestStatus> => {\n return ExpoIapModule.beginRefundRequestIOS(sku);\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 = (): Promise<Purchase[]> => {\n return ExpoIapModule.showManageSubscriptionsIOS();\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 getReceiptIOS = (): Promise<string> => {\n return ExpoIapModule.getReceiptDataIOS();\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 = (sku: string): Promise<boolean> => {\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 = (sku: string): Promise<string> => {\n return ExpoIapModule.getTransactionJwsIOS(sku);\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 * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nexport const validateReceiptIOS = async (\n sku: string,\n): Promise<ReceiptValidationResultIOS> => {\n const result = await ExpoIapModule.validateReceiptIOS(sku);\n return result;\n};\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 = (): Promise<boolean> => {\n return 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 = (): Promise<AppTransaction | null> => {\n return ExpoIapModule.getAppTransactionIOS();\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 = (): Promise<Product | null> => {\n return ExpoIapModule.getPromotedProductIOS();\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 * @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 = (): Promise<void> => {\n return ExpoIapModule.requestPurchaseOnPromotedProductIOS();\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 = (): Promise<any[]> => {\n return ExpoIapModule.getPendingTransactionsIOS();\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 = (): Promise<void> => {\n return 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// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/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,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAkB,EAAE,CAC5D,OAAO,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAElE,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 MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n ReceiptValidationProps,\n ReceiptValidationResultIOS,\n SubscriptionStatusIOS,\n} from '../types';\nimport type {PurchaseError} from '../utils/errorMapping';\nimport {Linking, Platform} 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 Boolean(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 * Retrieves the current storefront information from the iOS App Store.\n *\n * @returns Promise resolving to the storefront country code\n * @throws Error if called on non-iOS platform\n *\n * @example\n * ```typescript\n * const storefront = await getStorefrontIOS();\n * console.log(storefront); // 'US'\n * ```\n *\n * @platform iOS\n */\nexport const getStorefrontIOS: QueryField<'getStorefrontIOS'> = async () => {\n if (Platform.OS !== 'ios') {\n console.warn('getStorefrontIOS: This method is only available on iOS');\n return '';\n }\n return ExpoIapModule.getStorefrontIOS();\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 * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nconst validateReceiptIOSImpl = async (\n props: ReceiptValidationProps | string,\n) => {\n const sku =\n typeof props === 'string' ? props : (props as ReceiptValidationProps)?.sku;\n\n if (!sku) {\n throw new Error('validateReceiptIOS requires a SKU');\n }\n\n return (await ExpoIapModule.validateReceiptIOS(\n sku,\n )) as ReceiptValidationResultIOS;\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 Boolean(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 * @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: MutationField<\n 'requestPurchaseOnPromotedProductIOS'\n> = async () => {\n await ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n return 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 Boolean(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// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
package/build/types.d.ts CHANGED
@@ -112,66 +112,59 @@ export declare enum ErrorCode {
112
112
  UserCancelled = "USER_CANCELLED",
113
113
  UserError = "USER_ERROR"
114
114
  }
115
- export interface FetchProductsResult {
116
- products?: (Product[] | null);
117
- subscriptions?: (ProductSubscription[] | null);
118
- }
119
- export type IapEvent = 'promoted-product-ios' | 'purchase-error' | 'purchase-updated';
120
- export type IapPlatform = 'android' | 'ios';
115
+ export type FetchProductsResult = Product[] | ProductSubscription[] | null;
116
+ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios';
117
+ export type IapPlatform = 'ios' | 'android';
121
118
  export interface Mutation {
122
119
  /** Acknowledge a non-consumable purchase or subscription */
123
- acknowledgePurchaseAndroid: Promise<VoidResult>;
120
+ acknowledgePurchaseAndroid: Promise<boolean>;
124
121
  /** Initiate a refund request for a product (iOS 15+) */
125
- beginRefundRequestIOS: Promise<RefundResultIOS>;
122
+ beginRefundRequestIOS?: Promise<(string | null)>;
126
123
  /** Clear pending transactions from the StoreKit payment queue */
127
- clearTransactionIOS: Promise<VoidResult>;
124
+ clearTransactionIOS: Promise<boolean>;
128
125
  /** Consume a purchase token so it can be repurchased */
129
- consumePurchaseAndroid: Promise<VoidResult>;
126
+ consumePurchaseAndroid: Promise<boolean>;
130
127
  /** Open the native subscription management surface */
131
- deepLinkToSubscriptions: Promise<VoidResult>;
128
+ deepLinkToSubscriptions: Promise<void>;
132
129
  /** Close the platform billing connection */
133
130
  endConnection: Promise<boolean>;
134
131
  /** Finish a transaction after validating receipts */
135
- finishTransaction: Promise<VoidResult>;
132
+ finishTransaction: Promise<void>;
136
133
  /** Establish the platform billing connection */
137
134
  initConnection: Promise<boolean>;
138
135
  /** Present the App Store code redemption sheet */
139
- presentCodeRedemptionSheetIOS: Promise<VoidResult>;
136
+ presentCodeRedemptionSheetIOS: Promise<boolean>;
140
137
  /** Initiate a purchase flow; rely on events for final state */
141
- requestPurchase?: Promise<(RequestPurchaseResult | null)>;
138
+ requestPurchase?: Promise<(Purchase | Purchase[] | null)>;
142
139
  /** Purchase the promoted product surfaced by the App Store */
143
- requestPurchaseOnPromotedProductIOS: Promise<PurchaseIOS>;
140
+ requestPurchaseOnPromotedProductIOS: Promise<boolean>;
144
141
  /** Restore completed purchases across platforms */
145
- restorePurchases: Promise<VoidResult>;
142
+ restorePurchases: Promise<void>;
146
143
  /** Open subscription management UI and return changed purchases (iOS 15+) */
147
144
  showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
148
145
  /** Force a StoreKit sync for transactions (iOS 15+) */
149
- syncIOS: Promise<VoidResult>;
146
+ syncIOS: Promise<boolean>;
150
147
  /** Validate purchase receipts with the configured providers */
151
148
  validateReceipt: Promise<ReceiptValidationResult>;
152
149
  }
153
- export interface MutationAcknowledgePurchaseAndroidArgs {
154
- purchaseToken: string;
155
- }
156
- export interface MutationBeginRefundRequestIosArgs {
157
- sku: string;
158
- }
159
- export interface MutationConsumePurchaseAndroidArgs {
160
- purchaseToken: string;
161
- }
162
- export interface MutationDeepLinkToSubscriptionsArgs {
163
- options?: (DeepLinkOptions | null);
164
- }
150
+ export type MutationAcknowledgePurchaseAndroidArgs = string;
151
+ export type MutationBeginRefundRequestIosArgs = string;
152
+ export type MutationConsumePurchaseAndroidArgs = string;
153
+ export type MutationDeepLinkToSubscriptionsArgs = (DeepLinkOptions | null) | undefined;
165
154
  export interface MutationFinishTransactionArgs {
166
155
  isConsumable?: (boolean | null);
167
156
  purchase: PurchaseInput;
168
157
  }
169
- export interface MutationRequestPurchaseArgs {
170
- params: RequestPurchaseProps;
171
- }
172
- export interface MutationValidateReceiptArgs {
173
- options: ReceiptValidationProps;
174
- }
158
+ export type MutationRequestPurchaseArgs = {
159
+ /** Per-platform purchase request props */
160
+ request: RequestPurchasePropsByPlatforms;
161
+ type: 'in-app';
162
+ } | {
163
+ /** Per-platform subscription request props */
164
+ request: RequestSubscriptionPropsByPlatforms;
165
+ type: 'subs';
166
+ };
167
+ export type MutationValidateReceiptArgs = ReceiptValidationProps;
175
168
  export type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';
176
169
  export interface PricingPhaseAndroid {
177
170
  billingCycleCount: number;
@@ -234,7 +227,7 @@ export interface ProductIOS extends ProductCommon {
234
227
  type: ProductType;
235
228
  typeIOS: ProductTypeIOS;
236
229
  }
237
- export type ProductQueryType = 'all' | 'in-app' | 'subs';
230
+ export type ProductQueryType = 'in-app' | 'subs' | 'all';
238
231
  export interface ProductRequest {
239
232
  skus: string[];
240
233
  type?: (ProductQueryType | null);
@@ -288,7 +281,7 @@ export interface ProductSubscriptionIOS extends ProductCommon {
288
281
  typeIOS: ProductTypeIOS;
289
282
  }
290
283
  export type ProductType = 'in-app' | 'subs';
291
- export type ProductTypeIOS = 'auto-renewable-subscription' | 'consumable' | 'non-consumable' | 'non-renewing-subscription';
284
+ export type ProductTypeIOS = 'consumable' | 'non-consumable' | 'auto-renewable-subscription' | 'non-renewing-subscription';
292
285
  export type Purchase = PurchaseAndroid | PurchaseIOS;
293
286
  export interface PurchaseAndroid extends PurchaseCommon {
294
287
  autoRenewingAndroid?: (boolean | null);
@@ -308,6 +301,7 @@ export interface PurchaseAndroid extends PurchaseCommon {
308
301
  quantity: number;
309
302
  signatureAndroid?: (string | null);
310
303
  transactionDate: number;
304
+ transactionId?: (string | null);
311
305
  }
312
306
  export interface PurchaseCommon {
313
307
  id: string;
@@ -355,6 +349,7 @@ export interface PurchaseIOS extends PurchaseCommon {
355
349
  storefrontCountryCodeIOS?: (string | null);
356
350
  subscriptionGroupIdIOS?: (string | null);
357
351
  transactionDate: number;
352
+ transactionId: string;
358
353
  transactionReasonIOS?: (string | null);
359
354
  webOrderLineItemIdIOS?: (string | null);
360
355
  }
@@ -380,12 +375,12 @@ export interface PurchaseOptions {
380
375
  /** Limit to currently active items on iOS */
381
376
  onlyIncludeActiveItemsIOS?: (boolean | null);
382
377
  }
383
- export type PurchaseState = 'deferred' | 'failed' | 'pending' | 'purchased' | 'restored' | 'unknown';
378
+ export type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';
384
379
  export interface Query {
385
380
  /** Get current StoreKit 2 entitlements (iOS 15+) */
386
- currentEntitlementIOS: Promise<EntitlementIOS[]>;
381
+ currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;
387
382
  /** Retrieve products or subscriptions from the store */
388
- fetchProducts: Promise<FetchProductsResult>;
383
+ fetchProducts: Promise<(Product[] | ProductSubscription[] | null)>;
389
384
  /** Get active subscriptions (filters by subscriptionIds when provided) */
390
385
  getActiveSubscriptions: Promise<ActiveSubscription[]>;
391
386
  /** Fetch the current app transaction (iOS 16+) */
@@ -397,14 +392,14 @@ export interface Query {
397
392
  /** Get the currently promoted product (iOS 11+) */
398
393
  getPromotedProductIOS?: Promise<(ProductIOS | null)>;
399
394
  /** Get base64-encoded receipt data for validation */
400
- getReceiptDataIOS: Promise<string>;
395
+ getReceiptDataIOS?: Promise<(string | null)>;
401
396
  /** Get the current App Store storefront country code */
402
397
  getStorefrontIOS: Promise<string>;
403
398
  /** Get the transaction JWS (StoreKit 2) */
404
- getTransactionJwsIOS: Promise<string>;
399
+ getTransactionJwsIOS?: Promise<(string | null)>;
405
400
  /** Check whether the user has active subscriptions */
406
401
  hasActiveSubscriptions: Promise<boolean>;
407
- /** Check introductory offer eligibility for specific products */
402
+ /** Check introductory offer eligibility for a subscription group */
408
403
  isEligibleForIntroOfferIOS: Promise<boolean>;
409
404
  /** Verify a StoreKit 2 transaction signature */
410
405
  isTransactionVerifiedIOS: Promise<boolean>;
@@ -412,37 +407,20 @@ export interface Query {
412
407
  latestTransactionIOS?: Promise<(PurchaseIOS | null)>;
413
408
  /** Get StoreKit 2 subscription status details (iOS 15+) */
414
409
  subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;
415
- }
416
- export interface QueryCurrentEntitlementIosArgs {
417
- skus?: (string[] | null);
418
- }
419
- export interface QueryFetchProductsArgs {
420
- params: ProductRequest;
421
- }
422
- export interface QueryGetActiveSubscriptionsArgs {
423
- subscriptionIds?: (string[] | null);
424
- }
425
- export interface QueryGetAvailablePurchasesArgs {
426
- options?: (PurchaseOptions | null);
427
- }
428
- export interface QueryGetTransactionJwsIosArgs {
429
- transactionId: string;
430
- }
431
- export interface QueryHasActiveSubscriptionsArgs {
432
- subscriptionIds?: (string[] | null);
433
- }
434
- export interface QueryIsEligibleForIntroOfferIosArgs {
435
- productIds: string[];
436
- }
437
- export interface QueryIsTransactionVerifiedIosArgs {
438
- transactionId: string;
439
- }
440
- export interface QueryLatestTransactionIosArgs {
441
- sku: string;
442
- }
443
- export interface QuerySubscriptionStatusIosArgs {
444
- skus?: (string[] | null);
445
- }
410
+ /** Validate a receipt for a specific product */
411
+ validateReceiptIOS: Promise<ReceiptValidationResultIOS>;
412
+ }
413
+ export type QueryCurrentEntitlementIosArgs = string;
414
+ export type QueryFetchProductsArgs = ProductRequest;
415
+ export type QueryGetActiveSubscriptionsArgs = (string[] | null) | undefined;
416
+ export type QueryGetAvailablePurchasesArgs = (PurchaseOptions | null) | undefined;
417
+ export type QueryGetTransactionJwsIosArgs = string;
418
+ export type QueryHasActiveSubscriptionsArgs = (string[] | null) | undefined;
419
+ export type QueryIsEligibleForIntroOfferIosArgs = string;
420
+ export type QueryIsTransactionVerifiedIosArgs = string;
421
+ export type QueryLatestTransactionIosArgs = string;
422
+ export type QuerySubscriptionStatusIosArgs = string;
423
+ export type QueryValidateReceiptIosArgs = ReceiptValidationProps;
446
424
  export interface ReceiptValidationAndroidOptions {
447
425
  accessToken: string;
448
426
  isSub?: (boolean | null);
@@ -532,10 +510,7 @@ export interface RequestPurchasePropsByPlatforms {
532
510
  /** iOS-specific purchase parameters */
533
511
  ios?: (RequestPurchaseIosProps | null);
534
512
  }
535
- export interface RequestPurchaseResult {
536
- purchase?: (Purchase | null);
537
- purchases?: (Purchase[] | null);
538
- }
513
+ export type RequestPurchaseResult = Purchase | Purchase[] | null;
539
514
  export interface RequestSubscriptionAndroidProps {
540
515
  /** Personalized offer flag */
541
516
  isOfferPersonalized?: (boolean | null);
@@ -589,7 +564,7 @@ export interface SubscriptionOfferIOS {
589
564
  type: SubscriptionOfferTypeIOS;
590
565
  }
591
566
  export type SubscriptionOfferTypeIOS = 'introductory' | 'promotional';
592
- export type SubscriptionPeriodIOS = 'day' | 'empty' | 'month' | 'week' | 'year';
567
+ export type SubscriptionPeriodIOS = 'day' | 'week' | 'month' | 'year' | 'empty';
593
568
  export interface SubscriptionPeriodValueIOS {
594
569
  unit: SubscriptionPeriodIOS;
595
570
  value: number;
@@ -598,7 +573,57 @@ export interface SubscriptionStatusIOS {
598
573
  renewalInfo?: (RenewalInfoIOS | null);
599
574
  state: string;
600
575
  }
601
- export interface VoidResult {
602
- success: boolean;
603
- }
576
+ export type VoidResult = void;
577
+ export type QueryArgsMap = {
578
+ currentEntitlementIOS: QueryCurrentEntitlementIosArgs;
579
+ fetchProducts: QueryFetchProductsArgs;
580
+ getActiveSubscriptions: QueryGetActiveSubscriptionsArgs;
581
+ getAppTransactionIOS: never;
582
+ getAvailablePurchases: QueryGetAvailablePurchasesArgs;
583
+ getPendingTransactionsIOS: never;
584
+ getPromotedProductIOS: never;
585
+ getReceiptDataIOS: never;
586
+ getStorefrontIOS: never;
587
+ getTransactionJwsIOS: QueryGetTransactionJwsIosArgs;
588
+ hasActiveSubscriptions: QueryHasActiveSubscriptionsArgs;
589
+ isEligibleForIntroOfferIOS: QueryIsEligibleForIntroOfferIosArgs;
590
+ isTransactionVerifiedIOS: QueryIsTransactionVerifiedIosArgs;
591
+ latestTransactionIOS: QueryLatestTransactionIosArgs;
592
+ subscriptionStatusIOS: QuerySubscriptionStatusIosArgs;
593
+ validateReceiptIOS: QueryValidateReceiptIosArgs;
594
+ };
595
+ export type QueryField<K extends keyof Query> = QueryArgsMap[K] extends never ? () => NonNullable<Query[K]> : undefined extends QueryArgsMap[K] ? (args?: QueryArgsMap[K]) => NonNullable<Query[K]> : (args: QueryArgsMap[K]) => NonNullable<Query[K]>;
596
+ export type QueryFieldMap = {
597
+ [K in keyof Query]?: QueryField<K>;
598
+ };
599
+ export type MutationArgsMap = {
600
+ acknowledgePurchaseAndroid: MutationAcknowledgePurchaseAndroidArgs;
601
+ beginRefundRequestIOS: MutationBeginRefundRequestIosArgs;
602
+ clearTransactionIOS: never;
603
+ consumePurchaseAndroid: MutationConsumePurchaseAndroidArgs;
604
+ deepLinkToSubscriptions: MutationDeepLinkToSubscriptionsArgs;
605
+ endConnection: never;
606
+ finishTransaction: MutationFinishTransactionArgs;
607
+ initConnection: never;
608
+ presentCodeRedemptionSheetIOS: never;
609
+ requestPurchase: MutationRequestPurchaseArgs;
610
+ requestPurchaseOnPromotedProductIOS: never;
611
+ restorePurchases: never;
612
+ showManageSubscriptionsIOS: never;
613
+ syncIOS: never;
614
+ validateReceipt: MutationValidateReceiptArgs;
615
+ };
616
+ export type MutationField<K extends keyof Mutation> = MutationArgsMap[K] extends never ? () => NonNullable<Mutation[K]> : undefined extends MutationArgsMap[K] ? (args?: MutationArgsMap[K]) => NonNullable<Mutation[K]> : (args: MutationArgsMap[K]) => NonNullable<Mutation[K]>;
617
+ export type MutationFieldMap = {
618
+ [K in keyof Mutation]?: MutationField<K>;
619
+ };
620
+ export type SubscriptionArgsMap = {
621
+ promotedProductIOS: never;
622
+ purchaseError: never;
623
+ purchaseUpdated: never;
624
+ };
625
+ export type SubscriptionField<K extends keyof Subscription> = SubscriptionArgsMap[K] extends never ? () => NonNullable<Subscription[K]> : undefined extends SubscriptionArgsMap[K] ? (args?: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]> : (args: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>;
626
+ export type SubscriptionFieldMap = {
627
+ [K in keyof Subscription]?: SubscriptionField<K>;
628
+ };
604
629
  //# sourceMappingURL=types.d.ts.map