expo-iap 3.0.4 → 3.0.5

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 (44) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.js +1 -0
  3. package/.prettierignore +1 -0
  4. package/CHANGELOG.md +6 -0
  5. package/CLAUDE.md +1 -1
  6. package/CONTRIBUTING.md +10 -0
  7. package/android/build.gradle +1 -1
  8. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +12 -12
  9. package/android/src/main/java/expo/modules/iap/PromiseUtils.kt +2 -2
  10. package/build/index.d.ts +28 -14
  11. package/build/index.d.ts.map +1 -1
  12. package/build/index.js +36 -15
  13. package/build/index.js.map +1 -1
  14. package/build/modules/android.d.ts +3 -4
  15. package/build/modules/android.d.ts.map +1 -1
  16. package/build/modules/android.js +2 -4
  17. package/build/modules/android.js.map +1 -1
  18. package/build/modules/ios.d.ts +2 -3
  19. package/build/modules/ios.d.ts.map +1 -1
  20. package/build/modules/ios.js +1 -3
  21. package/build/modules/ios.js.map +1 -1
  22. package/build/purchase-error.d.ts +8 -10
  23. package/build/purchase-error.d.ts.map +1 -1
  24. package/build/purchase-error.js +4 -2
  25. package/build/purchase-error.js.map +1 -1
  26. package/build/types.d.ts +159 -204
  27. package/build/types.d.ts.map +1 -1
  28. package/build/types.js +1 -59
  29. package/build/types.js.map +1 -1
  30. package/build/useIAP.d.ts +5 -8
  31. package/build/useIAP.d.ts.map +1 -1
  32. package/build/useIAP.js.map +1 -1
  33. package/ios/ExpoIap.podspec +1 -1
  34. package/ios/ExpoIapModule.swift +103 -89
  35. package/package.json +2 -1
  36. package/plugin/build/withIAP.js +4 -5
  37. package/plugin/src/withIAP.ts +4 -5
  38. package/scripts/update-types.mjs +61 -0
  39. package/src/index.ts +77 -29
  40. package/src/modules/android.ts +5 -7
  41. package/src/modules/ios.ts +3 -5
  42. package/src/purchase-error.ts +13 -16
  43. package/src/types.ts +183 -216
  44. package/src/useIAP.ts +10 -10
package/src/useIAP.ts CHANGED
@@ -18,6 +18,8 @@ import {
18
18
  getActiveSubscriptions,
19
19
  hasActiveSubscriptions,
20
20
  type ActiveSubscription,
21
+ type ProductTypeInput,
22
+ type PurchaseRequestInput,
21
23
  restorePurchases,
22
24
  } from './index';
23
25
  import {
@@ -30,10 +32,9 @@ import {
30
32
  Product,
31
33
  Purchase,
32
34
  ProductSubscription,
33
- RequestPurchaseProps,
34
- RequestSubscriptionPropsByPlatforms,
35
35
  ErrorCode,
36
36
  VoidResult,
37
+ ReceiptValidationResult,
37
38
  } from './types';
38
39
  import {PurchaseError} from './purchase-error';
39
40
  import {
@@ -69,13 +70,12 @@ type UseIap = {
69
70
  getAvailablePurchases: () => Promise<void>;
70
71
  fetchProducts: (params: {
71
72
  skus: string[];
72
- type?: 'inapp' | 'subs';
73
+ type?: ProductTypeInput;
73
74
  }) => Promise<void>;
74
75
 
75
- requestPurchase: (params: {
76
- request: RequestPurchaseProps | RequestSubscriptionPropsByPlatforms;
77
- type?: 'inapp' | 'subs';
78
- }) => Promise<any>;
76
+ requestPurchase: (
77
+ params: PurchaseRequestInput,
78
+ ) => ReturnType<typeof requestPurchaseInternal>;
79
79
  validateReceipt: (
80
80
  sku: string,
81
81
  androidOptions?: {
@@ -84,7 +84,7 @@ type UseIap = {
84
84
  accessToken: string;
85
85
  isSub?: boolean;
86
86
  },
87
- ) => Promise<any>;
87
+ ) => Promise<ReceiptValidationResult>;
88
88
  restorePurchases: () => Promise<void>;
89
89
  getPromotedProductIOS: () => Promise<Product | null>;
90
90
  requestPurchaseOnPromotedProductIOS: () => Promise<void>;
@@ -194,7 +194,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
194
194
  const fetchProductsInternal = useCallback(
195
195
  async (params: {
196
196
  skus: string[];
197
- type?: 'inapp' | 'subs';
197
+ type?: ProductTypeInput;
198
198
  }): Promise<void> => {
199
199
  try {
200
200
  const result = await fetchProducts(params);
@@ -293,7 +293,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
293
293
  );
294
294
 
295
295
  const requestPurchaseWithReset = useCallback(
296
- async (requestObj: {request: any; type?: 'inapp' | 'subs'}) => {
296
+ async (requestObj: PurchaseRequestInput) => {
297
297
  clearCurrentPurchase();
298
298
  clearCurrentPurchaseError();
299
299