expo-iap 5.6.2 → 5.7.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 (79) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +5 -5
  3. package/README.md +2 -2
  4. package/android/build.gradle +10 -15
  5. package/android/openiap-store.gradle +365 -0
  6. package/android/src/main/java/expo/modules/iap/ExpoIapHelper.kt +2 -5
  7. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +2 -6
  8. package/build/ExpoIapModule.d.ts +51 -6
  9. package/build/ExpoIapModule.d.ts.map +1 -1
  10. package/build/ExpoIapModule.js +12 -8
  11. package/build/ExpoIapModule.js.map +1 -1
  12. package/build/index.d.ts +22 -44
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js +26 -54
  15. package/build/index.js.map +1 -1
  16. package/build/index.kepler.d.ts +2 -2
  17. package/build/index.kepler.js +2 -2
  18. package/build/index.kepler.js.map +1 -1
  19. package/build/kit-api.d.ts +10 -10
  20. package/build/kit-api.d.ts.map +1 -1
  21. package/build/kit-api.js +11 -35
  22. package/build/kit-api.js.map +1 -1
  23. package/build/modules/android.d.ts +5 -7
  24. package/build/modules/android.d.ts.map +1 -1
  25. package/build/modules/android.js +10 -16
  26. package/build/modules/android.js.map +1 -1
  27. package/build/modules/ios.d.ts +12 -30
  28. package/build/modules/ios.d.ts.map +1 -1
  29. package/build/modules/ios.js +14 -37
  30. package/build/modules/ios.js.map +1 -1
  31. package/build/onside/index.d.ts +7 -7
  32. package/build/onside/index.d.ts.map +1 -1
  33. package/build/onside/index.js +7 -8
  34. package/build/onside/index.js.map +1 -1
  35. package/build/types.d.ts +40 -40
  36. package/build/types.js.map +1 -1
  37. package/build/useIAP.d.ts +4 -7
  38. package/build/useIAP.d.ts.map +1 -1
  39. package/build/useIAP.js +11 -32
  40. package/build/useIAP.js.map +1 -1
  41. package/build/utils/debug.d.ts +3 -3
  42. package/build/utils/debug.d.ts.map +1 -1
  43. package/build/utils/debug.js +7 -24
  44. package/build/utils/debug.js.map +1 -1
  45. package/build/utils/errorMapping.d.ts +4 -12
  46. package/build/utils/errorMapping.d.ts.map +1 -1
  47. package/build/utils/errorMapping.js +4 -12
  48. package/build/utils/errorMapping.js.map +1 -1
  49. package/build/utils/restorePurchases.d.ts.map +1 -1
  50. package/build/utils/restorePurchases.js +3 -4
  51. package/build/utils/restorePurchases.js.map +1 -1
  52. package/ios/ExpoIap.podspec +4 -7
  53. package/ios/ExpoIapHelper.swift +2 -3
  54. package/ios/ExpoIapModule.swift +2 -3
  55. package/openiap-versions.json +1 -1
  56. package/package.json +2 -2
  57. package/plugin/build/withIAP.d.ts +16 -5
  58. package/plugin/build/withIAP.js +194 -166
  59. package/plugin/build/withLocalOpenIAP.d.ts +15 -12
  60. package/plugin/build/withLocalOpenIAP.js +139 -113
  61. package/plugin/build/withVega.d.ts +7 -0
  62. package/plugin/build/withVega.js +43 -13
  63. package/plugin/src/expoConfig.augmentation.d.ts +22 -11
  64. package/plugin/src/withIAP.ts +251 -226
  65. package/plugin/src/withLocalOpenIAP.ts +221 -159
  66. package/plugin/src/withVega.ts +45 -13
  67. package/scripts/update-types.mjs +12 -8
  68. package/src/ExpoIapModule.ts +136 -18
  69. package/src/index.kepler.ts +2 -2
  70. package/src/index.ts +28 -65
  71. package/src/kit-api.ts +21 -46
  72. package/src/modules/android.ts +12 -27
  73. package/src/modules/ios.ts +22 -45
  74. package/src/onside/index.ts +7 -9
  75. package/src/types.ts +40 -40
  76. package/src/useIAP.ts +15 -39
  77. package/src/utils/debug.ts +13 -31
  78. package/src/utils/errorMapping.ts +4 -12
  79. package/src/utils/restorePurchases.ts +3 -4
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAA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,IAAI,EAAE,CAAC,CAAC,IAAc,CAAC,CAAC;IAClE,CAAC;CACF,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,WAAW,EAAE,CAAC,MAAM,CAAC;AAC9B,CAAC;AAED,eAAe,IAAI,KAAK,CAAC,EAAS,EAAE;IAClC,GAAG,CAAC,MAAM,EAAE,IAAI;QACd,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC9B,OAAO,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC;QACzC,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,mBAAmB,CAC3B,UAAU,EACV,2CAA2C,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAC3G,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {requireNativeModule, UnavailabilityError} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\nlet cached: {module: any; name: NativeIapModuleName} | null = null;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): {module: any; name: NativeIapModuleName} {\n function shouldUseOnsideModule(): boolean {\n if (installedFromOnside === true) {\n return true;\n }\n\n if (typeof installedFromOnside !== 'string') {\n return false;\n }\n\n const normalized = installedFromOnside.trim().toLowerCase();\n return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;\n }\n\n function getExpectedModuleName(): NativeIapModuleName {\n if (isVegaOS()) {\n return 'ExpoIapVega';\n }\n\n return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';\n }\n\n function resolveNativeModule(): {\n module: any;\n name: NativeIapModuleName;\n } {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'Amazon Vega IAP module is unavailable. Install @amazon-devices/keplerscript-appstore-iap-lib in the Vega app target and build with the React Native for Vega kepler platform.',\n );\n }\n return {module: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n if (onsideModuleUnavailable) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n try {\n return {\n module: requireNativeModule('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n }\n\n return {module: requireNativeModule('ExpoIap'), name: 'ExpoIap'};\n }\n\n const expectedName = getExpectedModuleName();\n if (!cached || cached.name !== expectedName) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction isMissingModuleError(error: unknown, moduleName: string): boolean {\n if (error instanceof UnavailabilityError) {\n return true;\n }\n\n if (error instanceof Error) {\n return error.message.includes(`Cannot find native module '${moduleName}'`);\n }\n\n return false;\n}\n\nexport const NATIVE_ERROR_CODES: Record<string, unknown> = new Proxy(\n {} as Record<string, unknown>,\n {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n return (getResolved().module.ERROR_CODES || {})[prop as string];\n },\n },\n);\n\n/**\n * Returns the raw native module (not wrapped in a Proxy).\n * Use this for EventEmitter / addListener calls — JSI HostObjects\n * require the real native module as `this`; a Proxy triggers\n * \"native state unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule() {\n return getResolved().module;\n}\n\nexport default new Proxy({} as any, {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const resolved = getResolved();\n if (prop === 'USING_ONSIDE_SDK') {\n return resolved.name === 'ExpoIapOnside';\n }\n if (prop === 'USING_VEGA_SDK') {\n return resolved.name === 'ExpoIapVega';\n }\n\n const value = resolved.module[prop];\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return () => {\n throw new UnavailabilityError(\n 'expo-iap',\n `The Onside marketplace does not support ${String(prop)}. The call was not routed through Apple StoreKit.`,\n );\n };\n },\n});\n"]}
1
+ {"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAe7C,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAGlD,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAkG3D,IAAI,MAAM,GAAgC,IAAI,CAAC;AAC/C,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC,SAAS,WAAW;IAClB,SAAS,qBAAqB;QAC5B,IAAI,mBAAmB,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,mBAAmB,KA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IAAI,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC9B,OAAO,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC;QACzC,CAAC;QAED,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1D,IAAI,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,mBAAmB,CAC3B,UAAU,EACV,2CAA2C,MAAM,CAC/C,IAAI,CACL,mDAAmD,CACrD,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {\n requireNativeModule,\n UnavailabilityError,\n type EventSubscription,\n} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\nimport type {\n BillingProgramAndroid,\n BillingProgramReportingDetailsAndroid,\n DeveloperBillingTypeAndroid,\n Mutation,\n MutationField,\n ProductQueryType,\n PurchaseInput,\n PurchaseOptions,\n PurchaseUpdatedListenerOptions,\n Query,\n QueryField,\n SubscriptionStatusIOS,\n} from './types';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\n/** Members read from the raw module; every store module provides them. */\ntype NativeEventModule = {\n ERROR_CODES?: Record<string, unknown>;\n addListener<T>(\n eventName: string,\n listener: (payload: T) => void,\n ): EventSubscription | undefined;\n removeListener?<T>(eventName: string, listener: (payload: T) => void): void;\n setPurchaseUpdatedListenerOptions?(\n options?: PurchaseUpdatedListenerOptions | null,\n ): Promise<void>;\n};\n\ntype QueryFields<K extends keyof Query> = {[P in K]: QueryField<P>};\ntype MutationFields<K extends keyof Mutation> = {[P in K]: MutationField<P>};\n\n/**\n * Native surface behind the default export. Results the wrappers decode stay\n * `unknown`; the rest match the generated operation signatures.\n */\nexport type ExpoIapNativeModule = NativeEventModule &\n QueryFields<\n | 'canPresentExternalPurchaseNoticeIOS'\n | 'currentEntitlementIOS'\n | 'getActiveSubscriptions'\n | 'getAppTransactionIOS'\n | 'getBillingChoiceInfoAndroid'\n | 'getExternalPurchaseCustomLinkTokenIOS'\n | 'getPromotedProductIOS'\n | 'getReceiptDataIOS'\n | 'getTransactionJwsIOS'\n | 'hasActiveSubscriptions'\n | 'isEligibleForExternalPurchaseCustomLinkIOS'\n | 'isEligibleForIntroOfferIOS'\n | 'isTransactionVerifiedIOS'\n | 'latestTransactionIOS'\n > &\n MutationFields<\n | 'beginRefundRequestIOS'\n | 'clearTransactionIOS'\n | 'endConnection'\n | 'initConnection'\n | 'isBillingProgramAvailableAndroid'\n | 'launchExternalLinkAndroid'\n | 'openRedeemOfferCodeAndroid'\n | 'presentCodeRedemptionSheetIOS'\n | 'presentExternalPurchaseLinkIOS'\n | 'presentExternalPurchaseNoticeSheetIOS'\n | 'showBillingProgramInformationDialogAndroid'\n | 'showExternalPurchaseCustomLinkNoticeIOS'\n | 'showInAppMessagesAndroid'\n | 'syncIOS'\n | 'verifyPurchase'\n | 'verifyPurchaseWithProvider'\n > & {\n USING_ONSIDE_SDK: boolean;\n USING_VEGA_SDK: boolean;\n fetchProducts(request: {\n skus: string[];\n type: ProductQueryType;\n }): Promise<unknown[]>;\n fetchProducts(type: ProductQueryType, skus: string[]): Promise<unknown[]>;\n getAvailableItems(\n alsoPublishToEventListenerIOS: boolean,\n onlyIncludeActiveItemsIOS: boolean,\n ): Promise<unknown>;\n getAvailableItems(options: PurchaseOptions): Promise<unknown>;\n getAllTransactionsIOS(): Promise<unknown>;\n getPendingTransactionsIOS(): Promise<unknown>;\n showManageSubscriptionsIOS(): Promise<unknown>;\n requestPurchase(request: object): Promise<unknown>;\n finishTransaction(\n purchase: PurchaseInput,\n isConsumable: boolean | null,\n ): Promise<boolean>;\n acknowledgePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n consumePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n createBillingProgramReportingDetailsAndroid(\n program: BillingProgramAndroid,\n developerBillingType: DeveloperBillingTypeAndroid | null,\n ): Promise<BillingProgramReportingDetailsAndroid>;\n subscriptionStatusIOS(sku: string): Promise<SubscriptionStatusIOS[] | null>;\n requestReceiptRefreshIOS(): Promise<string>;\n deepLinkToSubscriptionsAndroid?(options: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }): Promise<void> | void;\n getStorefront?(): Promise<string> | string;\n restorePurchases?(): Promise<boolean>;\n };\n\ntype ResolvedNativeModule = {\n module: NativeEventModule;\n name: NativeIapModuleName;\n};\n\nlet cached: ResolvedNativeModule | null = null;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): ResolvedNativeModule {\n function shouldUseOnsideModule(): boolean {\n if (installedFromOnside === true) {\n return true;\n }\n\n if (typeof installedFromOnside !== 'string') {\n return false;\n }\n\n const normalized = installedFromOnside.trim().toLowerCase();\n return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;\n }\n\n function getExpectedModuleName(): NativeIapModuleName {\n if (isVegaOS()) {\n return 'ExpoIapVega';\n }\n\n return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';\n }\n\n function resolveNativeModule(): ResolvedNativeModule {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'Amazon Vega IAP module is unavailable. Install @amazon-devices/keplerscript-appstore-iap-lib in the Vega app target and build with the React Native for Vega kepler platform.',\n );\n }\n return {module: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n if (onsideModuleUnavailable) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n try {\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n }\n\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIap'),\n name: 'ExpoIap',\n };\n }\n\n const expectedName = getExpectedModuleName();\n if (!cached || cached.name !== expectedName) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction isMissingModuleError(error: unknown, moduleName: string): boolean {\n if (error instanceof UnavailabilityError) {\n return true;\n }\n\n if (error instanceof Error) {\n return error.message.includes(`Cannot find native module '${moduleName}'`);\n }\n\n return false;\n}\n\nexport const NATIVE_ERROR_CODES: Record<string, unknown> = new Proxy(\n {} as Record<string, unknown>,\n {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const errorCodes: Record<string, unknown> =\n getResolved().module.ERROR_CODES || {};\n return errorCodes[prop];\n },\n },\n);\n\n/**\n * Returns the raw native module, not the Proxy. Use it for addListener: a JSI\n * HostObject needs the real module as `this`, and a Proxy throws \"native state\n * unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule(): NativeEventModule {\n return getResolved().module;\n}\n\n// The Proxy forwards every member to the lazily resolved store module.\nexport default new Proxy({} as ExpoIapNativeModule, {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const resolved = getResolved();\n if (prop === 'USING_ONSIDE_SDK') {\n return resolved.name === 'ExpoIapOnside';\n }\n if (prop === 'USING_VEGA_SDK') {\n return resolved.name === 'ExpoIapVega';\n }\n\n const value: unknown = Reflect.get(resolved.module, prop);\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return () => {\n throw new UnavailabilityError(\n 'expo-iap',\n `The Onside marketplace does not support ${String(\n prop,\n )}. The call was not routed through Apple StoreKit.`,\n );\n };\n },\n});\n"]}
package/build/index.d.ts CHANGED
@@ -15,11 +15,7 @@ export declare enum OpenIapEvent {
15
15
  * developer billing flows. Nullable fields depend on the selected flow.
16
16
  */
17
17
  DeveloperProvidedBillingAndroid = "developer-provided-billing-android",
18
- /**
19
- * Fired when a subscription enters a billing-issue state (cross-platform).
20
- * Unifies StoreKit 2 `Message.Reason.billingIssue` (iOS / Mac Catalyst 16.4+, visionOS 1.0+) and Play Billing 8.1+
21
- * `Purchase.isSuspended`. NOT fired on the Meta Horizon flavor.
22
- */
18
+ /** Fired when a subscription enters a billing-issue state; see `subscriptionBillingIssueListener`. */
23
19
  SubscriptionBillingIssue = "subscription-billing-issue"
24
20
  }
25
21
  type ExpoIapEventPayloads = {
@@ -104,8 +100,6 @@ export declare const userChoiceBillingListenerAndroid: (listener: (details: User
104
100
  * This fires when a user selects the developer's option in an External Payments
105
101
  * or Billing Choice purchase flow.
106
102
  *
107
- * Requires Google Play Billing Library 8.3.0+; Billing Choice fields require 9.1.0+.
108
- *
109
103
  * @param listener - Callback that receives selected products and flow details
110
104
  * @returns EventSubscription that can be used to unsubscribe
111
105
  *
@@ -122,7 +116,7 @@ export declare const userChoiceBillingListenerAndroid: (listener: (details: User
122
116
  * subscription.remove();
123
117
  * ```
124
118
  *
125
- * @platform Android (8.3.0+; Billing Choice 9.1.0+)
119
+ * @platform Android (Play Billing Library 8.3.0+; Billing Choice 9.1.0+)
126
120
  */
127
121
  export declare const developerProvidedBillingListenerAndroid: (listener: (details: DeveloperProvidedBillingDetailsAndroid) => void) => {
128
122
  remove: () => void;
@@ -134,7 +128,7 @@ export declare const developerProvidedBillingListenerAndroid: (listener: (detail
134
128
  * for a payment problem. Unifies:
135
129
  * - iOS / Mac Catalyst 16.4+ and visionOS 1.0+: StoreKit 2 `Message.Reason.billingIssue`.
136
130
  * - Android (Play Billing 8.1+): when `Purchase.isSuspendedAndroid === true`.
137
- * - Meta Horizon / iOS 17 / older platforms: never fires.
131
+ * - Meta Horizon, Amazon, macOS, tvOS, watchOS, and iOS before 16.4: never fires.
138
132
  *
139
133
  * Recommended UX: call `deepLinkToSubscriptions()` when this fires so the user
140
134
  * can update their payment method in the platform subscription center.
@@ -193,7 +187,7 @@ export declare const endConnection: MutationField<'endConnection'>;
193
187
  * @returns Promise resolving to a `FetchProductsResult` union — `Product[]` for `'in-app'`,
194
188
  * `ProductSubscription[]` for `'subs'`, or a mixed array for `'all'`.
195
189
  * @throws When the store rejects the request (empty `skus`, not connected,
196
- * network/store error). Unknown SKUs are simply omitted from the result, not thrown.
190
+ * network/store error). Unknown SKUs are omitted from the result, not thrown.
197
191
  *
198
192
  * @example
199
193
  * ```ts
@@ -203,15 +197,14 @@ export declare const endConnection: MutationField<'endConnection'>;
203
197
  * });
204
198
  * ```
205
199
  *
206
- * @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
207
- * (`requestPurchase`), which are event-based.
200
+ * @remarks Promise-based, unlike the event-based `request*` APIs such as `requestPurchase`.
208
201
  *
209
202
  * @see {@link https://openiap.dev/docs/apis/fetch-products}
210
203
  */
211
204
  export declare const fetchProducts: QueryField<'fetchProducts'>;
212
205
  /**
213
- * List the user's unfinished purchases — non-consumables, active subscriptions, and any
214
- * pending transactions not yet finished.
206
+ * List the user's unfinished purchases: non-consumables, active subscriptions,
207
+ * and pending transactions.
215
208
  *
216
209
  * @param options Optional `PurchaseOptions`. iOS-only flags:
217
210
  * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
@@ -230,13 +223,9 @@ export declare const fetchProducts: QueryField<'fetchProducts'>;
230
223
  */
231
224
  export declare const getAvailablePurchases: QueryField<'getAvailablePurchases'>;
232
225
  /**
233
- * Get all active subscriptions with detailed information.
234
- * Uses native OpenIAP module for accurate subscription status and renewal info.
235
- *
236
- * On iOS: Returns subscriptions with renewalInfoIOS containing pendingUpgradeProductId,
237
- * willAutoRenew, autoRenewPreference, and other renewal details.
238
- *
239
- * On Android: Filters available purchases to find active subscriptions (fallback implementation).
226
+ * Get all active subscriptions. On iOS each entry carries `renewalInfoIOS`
227
+ * (e.g. pendingUpgradeProductId, willAutoRenew, autoRenewPreference); on
228
+ * Android they are filtered from the available purchases.
240
229
  *
241
230
  * @param subscriptionIds - Optional array of subscription product IDs to filter. If not provided, returns all active subscriptions.
242
231
  * @returns Promise resolving to array of active subscriptions with details
@@ -285,14 +274,15 @@ export declare const hasActiveSubscriptions: QueryField<'hasActiveSubscriptions'
285
274
  */
286
275
  export declare const getStorefront: QueryField<'getStorefront'>;
287
276
  /**
288
- * Initiate a purchase or subscription flow. The result is delivered through
289
- * `purchaseUpdatedListener` — NOT the return value.
277
+ * Initiate a purchase or subscription flow. The result arrives through
278
+ * `purchaseUpdatedListener` / `purchaseErrorListener` (or `useIAP`'s
279
+ * `onPurchaseSuccess` / `onPurchaseError`), not the return value.
290
280
  *
291
281
  * @param args `RequestPurchaseProps`, discriminated by `type`:
292
282
  * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
293
283
  * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
294
- * @returns The dispatched purchase payload. **Do not rely on it** for the actual outcome.
295
- * @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
284
+ * @returns The dispatched purchase payload; do not rely on it for the outcome.
285
+ * @throws Synchronous rejection from the store (e.g. `ErrorCode.NotPrepared`, validation failure).
296
286
  *
297
287
  * @example
298
288
  * ```ts
@@ -305,9 +295,6 @@ export declare const getStorefront: QueryField<'getStorefront'>;
305
295
  * });
306
296
  * ```
307
297
  *
308
- * @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
309
- * {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
310
- *
311
298
  * @see {@link https://openiap.dev/docs/apis/request-purchase}
312
299
  */
313
300
  export declare const requestPurchase: MutationField<'requestPurchase'>;
@@ -329,21 +316,18 @@ export declare const requestPurchase: MutationField<'requestPurchase'>;
329
316
  * }
330
317
  * ```
331
318
  *
332
- * @remarks **Critical:** Android purchases must be finalized within 3 days or Google
319
+ * @remarks Android purchases must be finalized within 3 days or Google
333
320
  * auto-refunds. iOS unfinished transactions replay on every app launch.
334
321
  *
335
322
  * @see {@link https://openiap.dev/docs/apis/finish-transaction}
336
323
  */
337
324
  export declare const finishTransaction: MutationField<'finishTransaction'>;
338
325
  /**
339
- * Restore completed transactions (cross-platform behavior)
340
- *
341
- * - iOS: perform a lightweight sync, or Onside restore when OnsideKit is active,
342
- * then fetch available purchases to surface restored items to the app.
343
- * - Android: simply fetch available purchases (restoration happens via query).
326
+ * Restore completed transactions. Returns nothing; read the restored items with
327
+ * `getAvailablePurchases` or from hook state.
344
328
  *
345
- * This helper triggers the refresh flows but does not return the purchases; consumers should
346
- * call `getAvailablePurchases` or rely on hook state to inspect the latest items.
329
+ * - iOS: sync (or Onside restore when OnsideKit is active), then fetch available purchases.
330
+ * - Android: fetch available purchases; the query itself restores them.
347
331
  *
348
332
  * @see {@link https://openiap.dev/docs/apis/restore-purchases}
349
333
  */
@@ -383,10 +367,7 @@ export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscript
383
367
  */
384
368
  export declare const openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;
385
369
  /**
386
- * Verify purchase with the configured providers
387
- *
388
- * This function uses the native OpenIAP verifyPurchase implementation
389
- * which validates purchases using platform-specific methods.
370
+ * Verify purchase with the configured providers.
390
371
  *
391
372
  * @param options - Receipt validation options containing the SKU
392
373
  * @returns Promise resolving to receipt validation result
@@ -395,10 +376,7 @@ export declare const openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;
395
376
  */
396
377
  export declare const verifyPurchase: MutationField<'verifyPurchase'>;
397
378
  /**
398
- * Verify purchase with a specific provider (e.g., IAPKit)
399
- *
400
- * This function allows you to verify purchases using external verification
401
- * services like IAPKit, which provide additional validation and security.
379
+ * Verify purchase with a specific provider (e.g., IAPKit).
402
380
  *
403
381
  * @param options - Verification options including provider and credentials
404
382
  * @returns Promise resolving to provider-specific verification result
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAGV,sCAAsC,EAEtC,aAAa,EAEb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,8BAA8B,EAC9B,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAG9B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAGvB,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,wBAAwB,gCAAgC;IACxD;;;OAGG;IACH,+BAA+B,uCAAuC;IACtE;;;;OAIG;IACH,wBAAwB,+BAA+B;CACxD;AAED,KAAK,oBAAoB,GAAG;IAC1B,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC;IACzC,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC5C,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAC7B,OAAO,GACP,MAAM,GACN;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACtC,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAClE,CAAC,YAAY,CAAC,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mB,EACnB,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC"}
package/build/index.js CHANGED
@@ -10,13 +10,11 @@ import { restorePurchasesIOSNative } from './utils/restorePurchases';
10
10
  import { decodeAndroidPurchases, decodeApplePurchases, } from './utils/availablePurchases';
11
11
  import { ErrorCode } from './types';
12
12
  import { createPurchaseError, createPurchaseErrorFromNativeException, OPENIAP_ERROR_ENVELOPE_PREFIX, } from './utils/errorMapping';
13
- // Export all types
14
13
  export * from './types';
15
14
  export * from './modules/android';
16
15
  export * from './modules/ios';
17
16
  export * from './onside';
18
17
  export * from './vega';
19
- // Get the native constant value
20
18
  export var OpenIapEvent;
21
19
  (function (OpenIapEvent) {
22
20
  OpenIapEvent["PurchaseUpdated"] = "purchase-updated";
@@ -28,20 +26,14 @@ export var OpenIapEvent;
28
26
  * developer billing flows. Nullable fields depend on the selected flow.
29
27
  */
30
28
  OpenIapEvent["DeveloperProvidedBillingAndroid"] = "developer-provided-billing-android";
31
- /**
32
- * Fired when a subscription enters a billing-issue state (cross-platform).
33
- * Unifies StoreKit 2 `Message.Reason.billingIssue` (iOS / Mac Catalyst 16.4+, visionOS 1.0+) and Play Billing 8.1+
34
- * `Purchase.isSuspended`. NOT fired on the Meta Horizon flavor.
35
- */
29
+ /** Fired when a subscription enters a billing-issue state; see `subscriptionBillingIssueListener`. */
36
30
  OpenIapEvent["SubscriptionBillingIssue"] = "subscription-billing-issue";
37
31
  })(OpenIapEvent || (OpenIapEvent = {}));
38
32
  const isStorePlatform = () => Platform.OS === 'ios' || Platform.OS === 'android';
39
33
  const isStoreRuntime = () => Platform.OS === 'ios' || isAndroidStoreRuntime();
40
34
  const unsupportedPlatformError = () => new Error(`Unsupported platform: ${Platform.OS}`);
41
- // Use the raw native module for listener calls — JSI HostObjects require the
42
- // real native module as `this` when calling addListener. Using a Proxy as
43
- // `this` triggers "native state unsupported on Proxy" on New Architecture / Hermes.
44
- // Resolved lazily so importing this module doesn't throw on unsupported platforms.
35
+ // Listener calls go to the raw native module (see getNativeModule), resolved
36
+ // lazily so importing this module doesn't throw on unsupported platforms.
45
37
  export const emitter = {
46
38
  addListener(eventName, listener) {
47
39
  const nativeModule = getNativeModule();
@@ -110,8 +102,7 @@ const resetPurchaseUpdatedDedupeHistoryIOS = () => {
110
102
  const configurePurchaseUpdatedListenerOptionsIOS = (dedupeTransactionIOS) => {
111
103
  if (Platform.OS !== 'ios')
112
104
  return;
113
- const nativeModule = getNativeModule();
114
- const promise = nativeModule.setPurchaseUpdatedListenerOptions?.({
105
+ const promise = getNativeModule().setPurchaseUpdatedListenerOptions?.({
115
106
  dedupeTransactionIOS,
116
107
  });
117
108
  void promise?.catch((error) => {
@@ -299,8 +290,6 @@ export const userChoiceBillingListenerAndroid = (listener) => {
299
290
  * This fires when a user selects the developer's option in an External Payments
300
291
  * or Billing Choice purchase flow.
301
292
  *
302
- * Requires Google Play Billing Library 8.3.0+; Billing Choice fields require 9.1.0+.
303
- *
304
293
  * @param listener - Callback that receives selected products and flow details
305
294
  * @returns EventSubscription that can be used to unsubscribe
306
295
  *
@@ -317,7 +306,7 @@ export const userChoiceBillingListenerAndroid = (listener) => {
317
306
  * subscription.remove();
318
307
  * ```
319
308
  *
320
- * @platform Android (8.3.0+; Billing Choice 9.1.0+)
309
+ * @platform Android (Play Billing Library 8.3.0+; Billing Choice 9.1.0+)
321
310
  */
322
311
  export const developerProvidedBillingListenerAndroid = (listener) => {
323
312
  if (Platform.OS !== 'android') {
@@ -333,7 +322,7 @@ export const developerProvidedBillingListenerAndroid = (listener) => {
333
322
  * for a payment problem. Unifies:
334
323
  * - iOS / Mac Catalyst 16.4+ and visionOS 1.0+: StoreKit 2 `Message.Reason.billingIssue`.
335
324
  * - Android (Play Billing 8.1+): when `Purchase.isSuspendedAndroid === true`.
336
- * - Meta Horizon / iOS 17 / older platforms: never fires.
325
+ * - Meta Horizon, Amazon, macOS, tvOS, watchOS, and iOS before 16.4: never fires.
337
326
  *
338
327
  * Recommended UX: call `deepLinkToSubscriptions()` when this fires so the user
339
328
  * can update their payment method in the platform subscription center.
@@ -435,7 +424,7 @@ const invokeNativeWithPurchaseError = async (operation, platform, fallback) => {
435
424
  * @returns Promise resolving to a `FetchProductsResult` union — `Product[]` for `'in-app'`,
436
425
  * `ProductSubscription[]` for `'subs'`, or a mixed array for `'all'`.
437
426
  * @throws When the store rejects the request (empty `skus`, not connected,
438
- * network/store error). Unknown SKUs are simply omitted from the result, not thrown.
427
+ * network/store error). Unknown SKUs are omitted from the result, not thrown.
439
428
  *
440
429
  * @example
441
430
  * ```ts
@@ -445,8 +434,7 @@ const invokeNativeWithPurchaseError = async (operation, platform, fallback) => {
445
434
  * });
446
435
  * ```
447
436
  *
448
- * @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
449
- * (`requestPurchase`), which are event-based.
437
+ * @remarks Promise-based, unlike the event-based `request*` APIs such as `requestPurchase`.
450
438
  *
451
439
  * @see {@link https://openiap.dev/docs/apis/fetch-products}
452
440
  */
@@ -482,8 +470,7 @@ export const fetchProducts = async (request) => {
482
470
  if (canonical === 'subs') {
483
471
  return items;
484
472
  }
485
- // For 'all' type, items contain both Product and ProductSubscription
486
- // Return as ProductOrSubscription[] to preserve discriminated union
473
+ // 'all' mixes products and subscriptions; returned as-is to keep the discriminated union.
487
474
  return items;
488
475
  };
489
476
  if (Platform.OS === 'ios') {
@@ -507,8 +494,8 @@ export const fetchProducts = async (request) => {
507
494
  throw unsupportedPlatformError();
508
495
  };
509
496
  /**
510
- * List the user's unfinished purchases — non-consumables, active subscriptions, and any
511
- * pending transactions not yet finished.
497
+ * List the user's unfinished purchases: non-consumables, active subscriptions,
498
+ * and pending transactions.
512
499
  *
513
500
  * @param options Optional `PurchaseOptions`. iOS-only flags:
514
501
  * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
@@ -550,13 +537,9 @@ export const getAvailablePurchases = async (options) => {
550
537
  : decodeAndroidPurchases(purchases);
551
538
  };
552
539
  /**
553
- * Get all active subscriptions with detailed information.
554
- * Uses native OpenIAP module for accurate subscription status and renewal info.
555
- *
556
- * On iOS: Returns subscriptions with renewalInfoIOS containing pendingUpgradeProductId,
557
- * willAutoRenew, autoRenewPreference, and other renewal details.
558
- *
559
- * On Android: Filters available purchases to find active subscriptions (fallback implementation).
540
+ * Get all active subscriptions. On iOS each entry carries `renewalInfoIOS`
541
+ * (e.g. pendingUpgradeProductId, willAutoRenew, autoRenewPreference); on
542
+ * Android they are filtered from the available purchases.
560
543
  *
561
544
  * @param subscriptionIds - Optional array of subscription product IDs to filter. If not provided, returns all active subscriptions.
562
545
  * @returns Promise resolving to array of active subscriptions with details
@@ -675,14 +658,15 @@ function validateAndroidPurchaseBranchOptions(request, type) {
675
658
  }
676
659
  }
677
660
  /**
678
- * Initiate a purchase or subscription flow. The result is delivered through
679
- * `purchaseUpdatedListener` — NOT the return value.
661
+ * Initiate a purchase or subscription flow. The result arrives through
662
+ * `purchaseUpdatedListener` / `purchaseErrorListener` (or `useIAP`'s
663
+ * `onPurchaseSuccess` / `onPurchaseError`), not the return value.
680
664
  *
681
665
  * @param args `RequestPurchaseProps`, discriminated by `type`:
682
666
  * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
683
667
  * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
684
- * @returns The dispatched purchase payload. **Do not rely on it** for the actual outcome.
685
- * @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
668
+ * @returns The dispatched purchase payload; do not rely on it for the outcome.
669
+ * @throws Synchronous rejection from the store (e.g. `ErrorCode.NotPrepared`, validation failure).
686
670
  *
687
671
  * @example
688
672
  * ```ts
@@ -695,9 +679,6 @@ function validateAndroidPurchaseBranchOptions(request, type) {
695
679
  * });
696
680
  * ```
697
681
  *
698
- * @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
699
- * {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
700
- *
701
682
  * @see {@link https://openiap.dev/docs/apis/request-purchase}
702
683
  */
703
684
  export const requestPurchase = async (args) => {
@@ -849,7 +830,7 @@ export const requestPurchase = async (args) => {
849
830
  * }
850
831
  * ```
851
832
  *
852
- * @remarks **Critical:** Android purchases must be finalized within 3 days or Google
833
+ * @remarks Android purchases must be finalized within 3 days or Google
853
834
  * auto-refunds. iOS unfinished transactions replay on every app launch.
854
835
  *
855
836
  * @see {@link https://openiap.dev/docs/apis/finish-transaction}
@@ -879,14 +860,11 @@ export const finishTransaction = async ({ purchase, isConsumable = false, }) =>
879
860
  throw unsupportedPlatformError();
880
861
  };
881
862
  /**
882
- * Restore completed transactions (cross-platform behavior)
883
- *
884
- * - iOS: perform a lightweight sync, or Onside restore when OnsideKit is active,
885
- * then fetch available purchases to surface restored items to the app.
886
- * - Android: simply fetch available purchases (restoration happens via query).
863
+ * Restore completed transactions. Returns nothing; read the restored items with
864
+ * `getAvailablePurchases` or from hook state.
887
865
  *
888
- * This helper triggers the refresh flows but does not return the purchases; consumers should
889
- * call `getAvailablePurchases` or rely on hook state to inspect the latest items.
866
+ * - iOS: sync (or Onside restore when OnsideKit is active), then fetch available purchases.
867
+ * - Android: fetch available purchases; the query itself restores them.
890
868
  *
891
869
  * @see {@link https://openiap.dev/docs/apis/restore-purchases}
892
870
  */
@@ -954,10 +932,7 @@ export const openRedeemOfferCode = async () => {
954
932
  throw unsupportedPlatformError();
955
933
  };
956
934
  /**
957
- * Verify purchase with the configured providers
958
- *
959
- * This function uses the native OpenIAP verifyPurchase implementation
960
- * which validates purchases using platform-specific methods.
935
+ * Verify purchase with the configured providers.
961
936
  *
962
937
  * @param options - Receipt validation options containing the SKU
963
938
  * @returns Promise resolving to receipt validation result
@@ -971,10 +946,7 @@ export const verifyPurchase = async (options) => {
971
946
  return ExpoIapModule.verifyPurchase(options);
972
947
  };
973
948
  /**
974
- * Verify purchase with a specific provider (e.g., IAPKit)
975
- *
976
- * This function allows you to verify purchases using external verification
977
- * services like IAPKit, which provide additional validation and security.
949
+ * Verify purchase with a specific provider (e.g., IAPKit).
978
950
  *
979
951
  * @param options - Verification options including provider and credentials
980
952
  * @returns Promise resolving to provider-specific verification result