expo-iap 3.0.2-rc.1 → 3.0.3

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 (63) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +4 -6
  3. package/build/ExpoIap.types.d.ts +49 -36
  4. package/build/ExpoIap.types.d.ts.map +1 -1
  5. package/build/ExpoIap.types.js +79 -70
  6. package/build/ExpoIap.types.js.map +1 -1
  7. package/build/index.d.ts +2 -2
  8. package/build/index.js +2 -2
  9. package/build/index.js.map +1 -1
  10. package/build/types/ExpoIapAndroid.types.d.ts +2 -3
  11. package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
  12. package/build/types/ExpoIapAndroid.types.js.map +1 -1
  13. package/build/types/ExpoIapIOS.types.d.ts +7 -1
  14. package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
  15. package/build/types/ExpoIapIOS.types.js +7 -1
  16. package/build/types/ExpoIapIOS.types.js.map +1 -1
  17. package/build/useIAP.d.ts +2 -2
  18. package/build/useIAP.d.ts.map +1 -1
  19. package/build/useIAP.js +13 -2
  20. package/build/useIAP.js.map +1 -1
  21. package/build/utils/errorMapping.d.ts +10 -4
  22. package/build/utils/errorMapping.d.ts.map +1 -1
  23. package/build/utils/errorMapping.js +54 -46
  24. package/build/utils/errorMapping.js.map +1 -1
  25. package/bun.lock +340 -137
  26. package/ios/ExpoIapModule.swift +24 -11
  27. package/package.json +1 -1
  28. package/plugin/src/withIAP.ts +5 -1
  29. package/plugin/src/withLocalOpenIAP.ts +3 -1
  30. package/plugin/tsconfig.tsbuildinfo +1 -1
  31. package/src/ExpoIap.types.ts +89 -74
  32. package/src/index.ts +6 -6
  33. package/src/types/ExpoIapAndroid.types.ts +2 -5
  34. package/src/types/ExpoIapIOS.types.ts +8 -3
  35. package/src/useIAP.ts +21 -10
  36. package/src/utils/errorMapping.ts +67 -54
  37. package/coverage/clover.xml +0 -358
  38. package/coverage/coverage-final.json +0 -7
  39. package/coverage/lcov-report/base.css +0 -224
  40. package/coverage/lcov-report/block-navigation.js +0 -87
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +0 -176
  43. package/coverage/lcov-report/prettify.css +0 -1
  44. package/coverage/lcov-report/prettify.js +0 -2
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +0 -196
  47. package/coverage/lcov-report/src/ExpoIap.types.ts.html +0 -1396
  48. package/coverage/lcov-report/src/helpers/index.html +0 -116
  49. package/coverage/lcov-report/src/helpers/subscription.ts.html +0 -532
  50. package/coverage/lcov-report/src/index.html +0 -116
  51. package/coverage/lcov-report/src/index.ts.html +0 -1945
  52. package/coverage/lcov-report/src/modules/android.ts.html +0 -496
  53. package/coverage/lcov-report/src/modules/index.html +0 -131
  54. package/coverage/lcov-report/src/modules/ios.ts.html +0 -1012
  55. package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +0 -502
  56. package/coverage/lcov-report/src/types/index.html +0 -116
  57. package/coverage/lcov-report/src/useIAP.ts.html +0 -1654
  58. package/coverage/lcov-report/src/utils/constants.ts.html +0 -127
  59. package/coverage/lcov-report/src/utils/errorMapping.ts.html +0 -427
  60. package/coverage/lcov-report/src/utils/index.html +0 -116
  61. package/coverage/lcov.info +0 -685
  62. package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  63. package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
@@ -3,19 +3,22 @@
3
3
  * Provides helper functions for handling platform-specific errors
4
4
  */
5
5
  import { ErrorCode } from '../ExpoIap.types';
6
+ function extractCode(error) {
7
+ if (typeof error === 'string') {
8
+ return error;
9
+ }
10
+ if (error && typeof error === 'object' && 'code' in error) {
11
+ return error.code;
12
+ }
13
+ return undefined;
14
+ }
6
15
  /**
7
16
  * Checks if an error is a user cancellation
8
17
  * @param error Error object or error code
9
18
  * @returns True if the error represents user cancellation
10
19
  */
11
20
  export function isUserCancelledError(error) {
12
- if (typeof error === 'string') {
13
- return error === ErrorCode.E_USER_CANCELLED;
14
- }
15
- if (error && error.code) {
16
- return error.code === ErrorCode.E_USER_CANCELLED;
17
- }
18
- return false;
21
+ return extractCode(error) === ErrorCode.UserCancelled;
19
22
  }
20
23
  /**
21
24
  * Checks if an error is related to network connectivity
@@ -24,14 +27,14 @@ export function isUserCancelledError(error) {
24
27
  */
25
28
  export function isNetworkError(error) {
26
29
  const networkErrors = [
27
- ErrorCode.E_NETWORK_ERROR,
28
- ErrorCode.E_REMOTE_ERROR,
29
- ErrorCode.E_SERVICE_ERROR,
30
- ErrorCode.E_SERVICE_DISCONNECTED,
31
- ErrorCode.E_BILLING_UNAVAILABLE,
30
+ ErrorCode.NetworkError,
31
+ ErrorCode.RemoteError,
32
+ ErrorCode.ServiceError,
33
+ ErrorCode.ServiceDisconnected,
34
+ ErrorCode.BillingUnavailable,
32
35
  ];
33
- const errorCode = typeof error === 'string' ? error : error?.code;
34
- return networkErrors.includes(errorCode);
36
+ const code = extractCode(error);
37
+ return !!code && networkErrors.includes(code);
35
38
  }
36
39
  /**
37
40
  * Checks if an error is recoverable (user can retry)
@@ -40,17 +43,17 @@ export function isNetworkError(error) {
40
43
  */
41
44
  export function isRecoverableError(error) {
42
45
  const recoverableErrors = [
43
- ErrorCode.E_NETWORK_ERROR,
44
- ErrorCode.E_REMOTE_ERROR,
45
- ErrorCode.E_SERVICE_ERROR,
46
- ErrorCode.E_INTERRUPTED,
47
- ErrorCode.E_SERVICE_DISCONNECTED,
48
- ErrorCode.E_BILLING_UNAVAILABLE,
49
- ErrorCode.E_QUERY_PRODUCT,
50
- ErrorCode.E_INIT_CONNECTION,
46
+ ErrorCode.NetworkError,
47
+ ErrorCode.RemoteError,
48
+ ErrorCode.ServiceError,
49
+ ErrorCode.Interrupted,
50
+ ErrorCode.ServiceDisconnected,
51
+ ErrorCode.BillingUnavailable,
52
+ ErrorCode.QueryProduct,
53
+ ErrorCode.InitConnection,
51
54
  ];
52
- const errorCode = typeof error === 'string' ? error : error?.code;
53
- return recoverableErrors.includes(errorCode);
55
+ const code = extractCode(error);
56
+ return !!code && recoverableErrors.includes(code);
54
57
  }
55
58
  /**
56
59
  * Gets a user-friendly error message for display
@@ -58,48 +61,53 @@ export function isRecoverableError(error) {
58
61
  * @returns User-friendly error message
59
62
  */
60
63
  export function getUserFriendlyErrorMessage(error) {
61
- const errorCode = typeof error === 'string' ? error : error?.code;
64
+ const errorCode = extractCode(error);
62
65
  switch (errorCode) {
63
- case ErrorCode.E_USER_CANCELLED:
66
+ case ErrorCode.UserCancelled:
64
67
  return 'Purchase was cancelled by user';
65
- case ErrorCode.E_NETWORK_ERROR:
68
+ case ErrorCode.NetworkError:
66
69
  return 'Network connection error. Please check your internet connection and try again.';
67
- case ErrorCode.E_RECEIPT_FINISHED:
70
+ case ErrorCode.ReceiptFinished:
68
71
  return 'Receipt already finished';
69
- case ErrorCode.E_SERVICE_DISCONNECTED:
72
+ case ErrorCode.ServiceDisconnected:
70
73
  return 'Billing service disconnected. Please try again.';
71
- case ErrorCode.E_BILLING_UNAVAILABLE:
74
+ case ErrorCode.BillingUnavailable:
72
75
  return 'Billing is unavailable on this device or account.';
73
- case ErrorCode.E_ITEM_UNAVAILABLE:
76
+ case ErrorCode.ItemUnavailable:
74
77
  return 'This item is not available for purchase';
75
- case ErrorCode.E_ITEM_NOT_OWNED:
78
+ case ErrorCode.ItemNotOwned:
76
79
  return "You don't own this item";
77
- case ErrorCode.E_ALREADY_OWNED:
80
+ case ErrorCode.AlreadyOwned:
78
81
  return 'You already own this item';
79
- case ErrorCode.E_SKU_NOT_FOUND:
82
+ case ErrorCode.SkuNotFound:
80
83
  return 'Requested product could not be found';
81
- case ErrorCode.E_SKU_OFFER_MISMATCH:
84
+ case ErrorCode.SkuOfferMismatch:
82
85
  return 'Selected offer does not match the SKU';
83
- case ErrorCode.E_DEFERRED_PAYMENT:
86
+ case ErrorCode.DeferredPayment:
84
87
  return 'Payment is pending approval';
85
- case ErrorCode.E_NOT_PREPARED:
88
+ case ErrorCode.NotPrepared:
86
89
  return 'In-app purchase is not ready. Please try again later.';
87
- case ErrorCode.E_SERVICE_ERROR:
90
+ case ErrorCode.ServiceError:
88
91
  return 'Store service error. Please try again later.';
89
- case ErrorCode.E_FEATURE_NOT_SUPPORTED:
92
+ case ErrorCode.FeatureNotSupported:
90
93
  return 'This feature is not supported on this device.';
91
- case ErrorCode.E_TRANSACTION_VALIDATION_FAILED:
94
+ case ErrorCode.TransactionValidationFailed:
92
95
  return 'Transaction could not be verified';
93
- case ErrorCode.E_RECEIPT_FAILED:
96
+ case ErrorCode.ReceiptFailed:
94
97
  return 'Receipt processing failed';
95
- case ErrorCode.E_EMPTY_SKU_LIST:
98
+ case ErrorCode.EmptySkuList:
96
99
  return 'No product IDs provided';
97
- case ErrorCode.E_INIT_CONNECTION:
100
+ case ErrorCode.InitConnection:
98
101
  return 'Failed to initialize billing connection';
99
- case ErrorCode.E_QUERY_PRODUCT:
102
+ case ErrorCode.QueryProduct:
100
103
  return 'Failed to query products. Please try again later.';
101
- default:
102
- return error?.message || 'An unexpected error occurred';
104
+ default: {
105
+ if (error && typeof error === 'object' && 'message' in error) {
106
+ return (error.message ??
107
+ 'An unexpected error occurred');
108
+ }
109
+ return 'An unexpected error occurred';
110
+ }
103
111
  }
104
112
  }
105
113
  //# sourceMappingURL=errorMapping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorMapping.js","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAU;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,SAAS,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IAED,IAA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o-iap\n * Provides helper functions for handling platform-specific errors\n */\n\nimport {ErrorCode} from '../ExpoIap.types';\n\n/**\n * Checks if an error is a user cancellation\n * @param error Error object or error code\n * @returns True if the error represents user cancellation\n */\nexport function isUserCancelledError(error: any): boolean {\n if (typeof error === 'string') {\n return error === ErrorCode.E_USER_CANCELLED;\n }\n\n if (error && error.code) {\n return error.code === ErrorCode.E_USER_CANCELLED;\n }\n\n return false;\n}\n\n/**\n * Checks if an error is related to network connectivity\n * @param error Error object or error code\n * @returns True if the error is network-related\n */\nexport function isNetworkError(error: any): boolean {\n const networkErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return networkErrors.includes(errorCode);\n}\n\n/**\n * Checks if an error is recoverable (user can retry)\n * @param error Error object or error code\n * @returns True if the error is potentially recoverable\n */\nexport function isRecoverableError(error: any): boolean {\n const recoverableErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_INTERRUPTED,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ErrorCode.E_QUERY_PRODUCT,\n ErrorCode.E_INIT_CONNECTION,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return recoverableErrors.includes(errorCode);\n}\n\n/**\n * Gets a user-friendly error message for display\n * @param error Error object or error code\n * @returns User-friendly error message\n */\nexport function getUserFriendlyErrorMessage(error: any): string {\n const errorCode = typeof error === 'string' ? error : error?.code;\n\n switch (errorCode) {\n case ErrorCode.E_USER_CANCELLED:\n return 'Purchase was cancelled by user';\n case ErrorCode.E_NETWORK_ERROR:\n return 'Network connection error. Please check your internet connection and try again.';\n case ErrorCode.E_RECEIPT_FINISHED:\n return 'Receipt already finished';\n case ErrorCode.E_SERVICE_DISCONNECTED:\n return 'Billing service disconnected. Please try again.';\n case ErrorCode.E_BILLING_UNAVAILABLE:\n return 'Billing is unavailable on this device or account.';\n case ErrorCode.E_ITEM_UNAVAILABLE:\n return 'This item is not available for purchase';\n case ErrorCode.E_ITEM_NOT_OWNED:\n return \"You don't own this item\";\n case ErrorCode.E_ALREADY_OWNED:\n return 'You already own this item';\n case ErrorCode.E_SKU_NOT_FOUND:\n return 'Requested product could not be found';\n case ErrorCode.E_SKU_OFFER_MISMATCH:\n return 'Selected offer does not match the SKU';\n case ErrorCode.E_DEFERRED_PAYMENT:\n return 'Payment is pending approval';\n case ErrorCode.E_NOT_PREPARED:\n return 'In-app purchase is not ready. Please try again later.';\n case ErrorCode.E_SERVICE_ERROR:\n return 'Store service error. Please try again later.';\n case ErrorCode.E_FEATURE_NOT_SUPPORTED:\n return 'This feature is not supported on this device.';\n case ErrorCode.E_TRANSACTION_VALIDATION_FAILED:\n return 'Transaction could not be verified';\n case ErrorCode.E_RECEIPT_FAILED:\n return 'Receipt processing failed';\n case ErrorCode.E_EMPTY_SKU_LIST:\n return 'No product IDs provided';\n case ErrorCode.E_INIT_CONNECTION:\n return 'Failed to initialize billing connection';\n case ErrorCode.E_QUERY_PRODUCT:\n return 'Failed to query products. Please try again later.';\n default:\n return error?.message || 'An unexpected error occurred';\n }\n}\n"]}
1
+ {"version":3,"file":"errorMapping.js","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAI3C,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QAC1D,OAAQ,K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AC;QACxC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Error mapping utilities for expo-iap\n * Provides helper functions for handling platform-specific errors\n */\n\nimport {ErrorCode} from '../ExpoIap.types';\n\ntype ErrorLike = string | {code?: ErrorCode | string; message?: string};\n\nfunction extractCode(error: unknown): string | undefined {\n if (typeof error === 'string') {\n return error;\n }\n\n if (error && typeof error === 'object' && 'code' in error) {\n return (error as {code?: string}).code;\n }\n\n return undefined;\n}\n\n/**\n * Checks if an error is a user cancellation\n * @param error Error object or error code\n * @returns True if the error represents user cancellation\n */\nexport function isUserCancelledError(error: unknown): boolean {\n return extractCode(error) === ErrorCode.UserCancelled;\n}\n\n/**\n * Checks if an error is related to network connectivity\n * @param error Error object or error code\n * @returns True if the error is network-related\n */\nexport function isNetworkError(error: unknown): boolean {\n const networkErrors: ErrorCode[] = [\n ErrorCode.NetworkError,\n ErrorCode.RemoteError,\n ErrorCode.ServiceError,\n ErrorCode.ServiceDisconnected,\n ErrorCode.BillingUnavailable,\n ];\n\n const code = extractCode(error);\n return !!code && (networkErrors as string[]).includes(code);\n}\n\n/**\n * Checks if an error is recoverable (user can retry)\n * @param error Error object or error code\n * @returns True if the error is potentially recoverable\n */\nexport function isRecoverableError(error: unknown): boolean {\n const recoverableErrors: ErrorCode[] = [\n ErrorCode.NetworkError,\n ErrorCode.RemoteError,\n ErrorCode.ServiceError,\n ErrorCode.Interrupted,\n ErrorCode.ServiceDisconnected,\n ErrorCode.BillingUnavailable,\n ErrorCode.QueryProduct,\n ErrorCode.InitConnection,\n ];\n\n const code = extractCode(error);\n return !!code && (recoverableErrors as string[]).includes(code);\n}\n\n/**\n * Gets a user-friendly error message for display\n * @param error Error object or error code\n * @returns User-friendly error message\n */\nexport function getUserFriendlyErrorMessage(error: ErrorLike): string {\n const errorCode = extractCode(error);\n\n switch (errorCode) {\n case ErrorCode.UserCancelled:\n return 'Purchase was cancelled by user';\n case ErrorCode.NetworkError:\n return 'Network connection error. Please check your internet connection and try again.';\n case ErrorCode.ReceiptFinished:\n return 'Receipt already finished';\n case ErrorCode.ServiceDisconnected:\n return 'Billing service disconnected. Please try again.';\n case ErrorCode.BillingUnavailable:\n return 'Billing is unavailable on this device or account.';\n case ErrorCode.ItemUnavailable:\n return 'This item is not available for purchase';\n case ErrorCode.ItemNotOwned:\n return \"You don't own this item\";\n case ErrorCode.AlreadyOwned:\n return 'You already own this item';\n case ErrorCode.SkuNotFound:\n return 'Requested product could not be found';\n case ErrorCode.SkuOfferMismatch:\n return 'Selected offer does not match the SKU';\n case ErrorCode.DeferredPayment:\n return 'Payment is pending approval';\n case ErrorCode.NotPrepared:\n return 'In-app purchase is not ready. Please try again later.';\n case ErrorCode.ServiceError:\n return 'Store service error. Please try again later.';\n case ErrorCode.FeatureNotSupported:\n return 'This feature is not supported on this device.';\n case ErrorCode.TransactionValidationFailed:\n return 'Transaction could not be verified';\n case ErrorCode.ReceiptFailed:\n return 'Receipt processing failed';\n case ErrorCode.EmptySkuList:\n return 'No product IDs provided';\n case ErrorCode.InitConnection:\n return 'Failed to initialize billing connection';\n case ErrorCode.QueryProduct:\n return 'Failed to query products. Please try again later.';\n default: {\n if (error && typeof error === 'object' && 'message' in error) {\n return (\n (error as {message?: string}).message ??\n 'An unexpected error occurred'\n );\n }\n return 'An unexpected error occurred';\n }\n }\n}\n"]}