expo-iap 2.4.1 → 2.4.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.
package/build/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Product, ProductPurchase, Purchase, PurchaseError, PurchaseResult, RequestSubscriptionProps, SubscriptionProduct, SubscriptionPurchase } from './ExpoIap.types';
2
2
  import { RequestPurchaseAndroidProps, RequestSubscriptionAndroidProps } from './types/ExpoIapAndroid.types';
3
3
  import { RequestPurchaseIosProps, RequestSubscriptionIosProps } from './types/ExpoIapIos.types';
4
+ export * from './ExpoIap.types';
4
5
  export * from './modules/android';
5
6
  export * from './modules/ios';
6
7
  export declare const PI: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAIlC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,eAAO,MAAM,EAAE,KAAmB,CAAC;AAEnC,oBAAY,QAAQ;IAClB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,yFAAyF;IACzF,qBAAqB,4BAA4B;CAClD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAE1C;AAGD,eAAO,MAAM,OAAO,EAAoD;IACtE,WAAW,EAAE,CACX,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAC/B;QAAC,MAAM,EAAE,MAAM,IAAI,CAAA;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N,eAAe,GACf,oBAAoB,GACpB,eAAe,EAAE,GACjB,oBAAoB,EAAE,GACtB,IAAI,CAyFP,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,wBAAwB,KAChC,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,GAAG,IAAI,CASrE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,6BAG/B;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAiCnC,CAAC;AAEF,cAAc,UAAU,CAAC"}
package/build/index.js CHANGED
@@ -5,6 +5,7 @@ import { Platform } from 'react-native';
5
5
  import ExpoIapModule from './ExpoIapModule';
6
6
  import { isProductIos } from './modules/ios';
7
7
  import { isProductAndroid } from './modules/android';
8
+ export * from './ExpoIap.types';
8
9
  export * from './modules/android';
9
10
  export * from './modules/ios';
10
11
  // Get the native constant value
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wCAAwC;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAWtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAW5C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAE9B,gCAAgC;AAChC,MAAM,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC;AAEnC,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,gDAAoC,CAAA;IACpC,4CAAgC,CAAA;IAChC,yFAAyF;IACzF,6DAAiD,CA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,GAAG,CAAC,EAChC,QAAQ,EACR,YAAY,GAIb,EAAqC,EAAE;IACtC,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,KAAK,IAAI,EAAE;YACd,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;YAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAC9D,CAAC;YACJ,CAAC;YACD,MAAM,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,eAAe,GAAG,QAAkC,CAAC;YAE3D,IAAI,CAAC,CAAC,sBAAsB,IAAI,eAAe,CAAC,EAAE,CAAC;gBACjD,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAC7D,CAAC;YACJ,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,aAAa,CAAC,cAAc,CACjC,eAAe,CAAC,oBAAoB,CACrC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,aAAa,CAAC,mBAAmB,CACtC,eAAe,CAAC,oBAAoB,CACrC,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAChE,EAAE,CAAC;AACN,CAAC,CAAC;AAEF,cAAc,UAAU,CAAC","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoIap.web.ts\n// and on native platforms to ExpoIap.ts\nimport {NativeModulesProxy} from 'expo-modules-core';\nimport {Platform} from 'react-native';\nimport {\n Product,\n ProductPurchase,\n Purchase,\n PurchaseError,\n PurchaseResult,\n RequestSubscriptionProps,\n SubscriptionProduct,\n SubscriptionPurchase,\n} from './ExpoIap.types';\nimport ExpoIapModule from './ExpoIapModule';\nimport {\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n} from './types/ExpoIapAndroid.types';\nimport {\n PaymentDiscount,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n} from './types/ExpoIapIos.types';\nimport {isProductIos} from './modules/ios';\nimport {isProductAndroid} from './modules/android';\n\nexport * from './modules/android';\nexport * from './modules/ios';\n\n// Get the native constant value\nexport const PI = ExpoIapModule.PI;\n\nexport enum IapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n /** @deprecated Use PurchaseUpdated instead. This will be removed in a future version. */\n TransactionIapUpdated = 'iap-transaction-updated',\n}\n\nexport function setValueAsync(value: string) {\n return ExpoIapModule.setValueAsync(value);\n}\n\n// Ensure the emitter has proper EventEmitter interface\nexport const emitter = (ExpoIapModule || NativeModulesProxy.ExpoIap) as {\n addListener: (\n eventName: string,\n listener: (...args: any[]) => void,\n ) => {remove: () => void};\n removeListener: (\n eventName: string,\n listener: (...args: any[]) => void,\n ) => void;\n};\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const emitterSubscription = emitter.addListener(\n IapEvent.PurchaseUpdated,\n listener,\n );\n return emitterSubscription;\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n) => {\n return emitter.addListener(IapEvent.PurchaseError, listener);\n};\n\nexport function initConnection() {\n return ExpoIapModule.initConnection();\n}\n\nexport const getProducts = async (skus: string[]): Promise<Product[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as Product[];\n },\n android: async () => {\n const products = await ExpoIapModule.getItemsByType('inapp', skus);\n return products.filter((product: unknown) =>\n isProductAndroid<Product>(product),\n );\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport const getSubscriptions = async (\n skus: string[],\n): Promise<SubscriptionProduct[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n android: async () => {\n const rawItems = await ExpoIapModule.getItemsByType('subs', skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductAndroid(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport async function endConnection(): Promise<boolean> {\n return ExpoIapModule.endConnection();\n}\n\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = false,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: async () => {\n return ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n );\n },\n android: async () => {\n const products = await ExpoIapModule.getPurchaseHistoryByType('inapp');\n const subscriptions =\n await ExpoIapModule.getPurchaseHistoryByType('subs');\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = true,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: () =>\n ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n ),\n android: async () => {\n const products = await ExpoIapModule.getAvailableItemsByType('inapp');\n const subscriptions =\n await ExpoIapModule.getAvailableItemsByType('subs');\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nconst offerToRecordIos = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) return undefined;\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n\n// Define discriminated union with explicit type parameter\ntype PurchaseRequest =\n | {\n request: RequestPurchaseIosProps | RequestPurchaseAndroidProps;\n type?: 'inapp';\n }\n | {\n request: RequestSubscriptionAndroidProps | RequestSubscriptionIosProps;\n type: 'subs';\n };\n\n// Type guards for request objects\nconst isIosRequest = (\n request: any,\n): request is RequestPurchaseIosProps | RequestSubscriptionIosProps =>\n 'sku' in request && typeof request.sku === 'string';\n\nexport const requestPurchase = (\n requestObj: PurchaseRequest,\n): Promise<\n | ProductPurchase\n | SubscriptionPurchase\n | ProductPurchase[]\n | SubscriptionPurchase[]\n | void\n> => {\n const {request, type = 'inapp'} = requestObj;\n\n if (Platform.OS === 'ios') {\n if (!isIosRequest(request)) {\n throw new Error(\n 'Invalid request for iOS. The `sku` property is required and must be a string.',\n );\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n\n return (async () => {\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n\n return type === 'inapp'\n ? (purchase as ProductPurchase)\n : (purchase as SubscriptionPurchase);\n })();\n }\n\n if (Platform.OS === 'android') {\n if (type === 'inapp') {\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request as RequestPurchaseAndroidProps;\n\n return (async () => {\n return ExpoIapModule.buyItemByType({\n type: 'inapp',\n skuArr: skus,\n purchaseToken: undefined,\n replacementMode: -1,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: [],\n isOfferPersonalized: isOfferPersonalized ?? false,\n }) as Promise<ProductPurchase[]>;\n })();\n }\n\n if (type === 'subs') {\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n subscriptionOffers = [],\n replacementModeAndroid = -1,\n purchaseTokenAndroid,\n } = request as RequestSubscriptionAndroidProps;\n\n return (async () => {\n return ExpoIapModule.buyItemByType({\n type: 'subs',\n skuArr: skus,\n purchaseToken: purchaseTokenAndroid,\n replacementMode: replacementModeAndroid,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: subscriptionOffers.map((so) => so.offerToken),\n isOfferPersonalized: isOfferPersonalized ?? false,\n }) as Promise<SubscriptionPurchase[]>;\n })();\n }\n\n throw new Error(\n \"Invalid request for Android: Expected a 'RequestPurchaseAndroidProps' object with a valid 'skus' array or a 'RequestSubscriptionAndroidProps' object with 'skus' and 'subscriptionOffers'.\",\n );\n }\n\n return Promise.resolve(); // Fallback for unsupported platforms\n};\n\n/**\n * @deprecated Use `requestPurchase({ request, type: 'subs' })` instead. This method will be removed in version 3.0.0+.\n */\nexport const requestSubscription = async (\n request: RequestSubscriptionProps,\n): Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void> => {\n console.warn(\n \"`requestSubscription` is deprecated. Use `requestPurchase({ request, type: 'subs' })` instead. This method will be removed in version 3.0.0+.\",\n );\n return (await requestPurchase({request, type: 'subs'})) as\n | SubscriptionPurchase\n | SubscriptionPurchase[]\n | null\n | void;\n};\n\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n}: {\n purchase: Purchase;\n isConsumable?: boolean;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n await ExpoIapModule.finishTransaction(transactionId);\n return Promise.resolve(true);\n },\n android: async () => {\n const androidPurchase = purchase as ProductPurchaseAndroid;\n\n if (!('purchaseTokenAndroid' in androidPurchase)) {\n return Promise.reject(\n new Error('purchaseToken is required to finish transaction'),\n );\n }\n if (isConsumable) {\n return ExpoIapModule.consumeProduct(\n androidPurchase.purchaseTokenAndroid,\n );\n } else {\n return ExpoIapModule.acknowledgePurchase(\n androidPurchase.purchaseTokenAndroid,\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\nexport * from './useIap';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wCAAwC;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAWtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAW5C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAE9B,gCAAgC;AAChC,MAAM,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC;AAEnC,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,gDAAoC,CAAA;IACpC,4CAAgC,CAAA;IAChC,yFAAyF;IACzF,6DAAiD,CAA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GAAG,CAAC,EAChC,QAAQ,EACR,YAAY,GAIb,EAAqC,EAAE;IACtC,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,KAAK,IAAI,EAAE;YACd,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;YAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAC9D,CAAC;YACJ,CAAC;YACD,MAAM,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,eAAe,GAAG,QAAkC,CAAC;YAE3D,IAAI,CAAC,CAAC,sBAAsB,IAAI,eAAe,CAAC,EAAE,CAAC;gBACjD,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAC7D,CAAC;YACJ,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,aAAa,CAAC,cAAc,CACjC,eAAe,CAAC,oBAAoB,CACrC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,aAAa,CAAC,mBAAmB,CACtC,eAAe,CAAC,oBAAoB,CACrC,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAChE,EAAE,CAAC;AACN,CAAC,CAAC;AAEF,cAAc,UAAU,CAAC","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoIap.web.ts\n// and on native platforms to ExpoIap.ts\nimport {NativeModulesProxy} from 'expo-modules-core';\nimport {Platform} from 'react-native';\nimport {\n Product,\n ProductPurchase,\n Purchase,\n PurchaseError,\n PurchaseResult,\n RequestSubscriptionProps,\n SubscriptionProduct,\n SubscriptionPurchase,\n} from './ExpoIap.types';\nimport ExpoIapModule from './ExpoIapModule';\nimport {\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n} from './types/ExpoIapAndroid.types';\nimport {\n PaymentDiscount,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n} from './types/ExpoIapIos.types';\nimport {isProductIos} from './modules/ios';\nimport {isProductAndroid} from './modules/android';\n\nexport * from './ExpoIap.types';\nexport * from './modules/android';\nexport * from './modules/ios';\n\n// Get the native constant value\nexport const PI = ExpoIapModule.PI;\n\nexport enum IapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n /** @deprecated Use PurchaseUpdated instead. This will be removed in a future version. */\n TransactionIapUpdated = 'iap-transaction-updated',\n}\n\nexport function setValueAsync(value: string) {\n return ExpoIapModule.setValueAsync(value);\n}\n\n// Ensure the emitter has proper EventEmitter interface\nexport const emitter = (ExpoIapModule || NativeModulesProxy.ExpoIap) as {\n addListener: (\n eventName: string,\n listener: (...args: any[]) => void,\n ) => {remove: () => void};\n removeListener: (\n eventName: string,\n listener: (...args: any[]) => void,\n ) => void;\n};\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const emitterSubscription = emitter.addListener(\n IapEvent.PurchaseUpdated,\n listener,\n );\n return emitterSubscription;\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n) => {\n return emitter.addListener(IapEvent.PurchaseError, listener);\n};\n\nexport function initConnection() {\n return ExpoIapModule.initConnection();\n}\n\nexport const getProducts = async (skus: string[]): Promise<Product[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as Product[];\n },\n android: async () => {\n const products = await ExpoIapModule.getItemsByType('inapp', skus);\n return products.filter((product: unknown) =>\n isProductAndroid<Product>(product),\n );\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport const getSubscriptions = async (\n skus: string[],\n): Promise<SubscriptionProduct[]> => {\n if (!skus?.length) {\n return Promise.reject(new Error('\"skus\" is required'));\n }\n\n return Platform.select({\n ios: async () => {\n const rawItems = await ExpoIapModule.getItems(skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductIos(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n android: async () => {\n const rawItems = await ExpoIapModule.getItemsByType('subs', skus);\n return rawItems.filter((item: unknown) => {\n if (!isProductAndroid(item)) return false;\n return (\n typeof item === 'object' &&\n item !== null &&\n 'id' in item &&\n typeof item.id === 'string' &&\n skus.includes(item.id)\n );\n }) as SubscriptionProduct[];\n },\n default: () => Promise.reject(new Error('Unsupported Platform')),\n })();\n};\n\nexport async function endConnection(): Promise<boolean> {\n return ExpoIapModule.endConnection();\n}\n\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = false,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: async () => {\n return ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n );\n },\n android: async () => {\n const products = await ExpoIapModule.getPurchaseHistoryByType('inapp');\n const subscriptions =\n await ExpoIapModule.getPurchaseHistoryByType('subs');\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n onlyIncludeActiveItems = true,\n}: {\n alsoPublishToEventListener?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<ProductPurchase[]> =>\n (\n Platform.select({\n ios: () =>\n ExpoIapModule.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n ),\n android: async () => {\n const products = await ExpoIapModule.getAvailableItemsByType('inapp');\n const subscriptions =\n await ExpoIapModule.getAvailableItemsByType('subs');\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\nconst offerToRecordIos = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) return undefined;\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n\n// Define discriminated union with explicit type parameter\ntype PurchaseRequest =\n | {\n request: RequestPurchaseIosProps | RequestPurchaseAndroidProps;\n type?: 'inapp';\n }\n | {\n request: RequestSubscriptionAndroidProps | RequestSubscriptionIosProps;\n type: 'subs';\n };\n\n// Type guards for request objects\nconst isIosRequest = (\n request: any,\n): request is RequestPurchaseIosProps | RequestSubscriptionIosProps =>\n 'sku' in request && typeof request.sku === 'string';\n\nexport const requestPurchase = (\n requestObj: PurchaseRequest,\n): Promise<\n | ProductPurchase\n | SubscriptionPurchase\n | ProductPurchase[]\n | SubscriptionPurchase[]\n | void\n> => {\n const {request, type = 'inapp'} = requestObj;\n\n if (Platform.OS === 'ios') {\n if (!isIosRequest(request)) {\n throw new Error(\n 'Invalid request for iOS. The `sku` property is required and must be a string.',\n );\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n\n return (async () => {\n const offer = offerToRecordIos(withOffer);\n const purchase = await ExpoIapModule.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n\n return type === 'inapp'\n ? (purchase as ProductPurchase)\n : (purchase as SubscriptionPurchase);\n })();\n }\n\n if (Platform.OS === 'android') {\n if (type === 'inapp') {\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request as RequestPurchaseAndroidProps;\n\n return (async () => {\n return ExpoIapModule.buyItemByType({\n type: 'inapp',\n skuArr: skus,\n purchaseToken: undefined,\n replacementMode: -1,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: [],\n isOfferPersonalized: isOfferPersonalized ?? false,\n }) as Promise<ProductPurchase[]>;\n })();\n }\n\n if (type === 'subs') {\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n subscriptionOffers = [],\n replacementModeAndroid = -1,\n purchaseTokenAndroid,\n } = request as RequestSubscriptionAndroidProps;\n\n return (async () => {\n return ExpoIapModule.buyItemByType({\n type: 'subs',\n skuArr: skus,\n purchaseToken: purchaseTokenAndroid,\n replacementMode: replacementModeAndroid,\n obfuscatedAccountId: obfuscatedAccountIdAndroid,\n obfuscatedProfileId: obfuscatedProfileIdAndroid,\n offerTokenArr: subscriptionOffers.map((so) => so.offerToken),\n isOfferPersonalized: isOfferPersonalized ?? false,\n }) as Promise<SubscriptionPurchase[]>;\n })();\n }\n\n throw new Error(\n \"Invalid request for Android: Expected a 'RequestPurchaseAndroidProps' object with a valid 'skus' array or a 'RequestSubscriptionAndroidProps' object with 'skus' and 'subscriptionOffers'.\",\n );\n }\n\n return Promise.resolve(); // Fallback for unsupported platforms\n};\n\n/**\n * @deprecated Use `requestPurchase({ request, type: 'subs' })` instead. This method will be removed in version 3.0.0+.\n */\nexport const requestSubscription = async (\n request: RequestSubscriptionProps,\n): Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void> => {\n console.warn(\n \"`requestSubscription` is deprecated. Use `requestPurchase({ request, type: 'subs' })` instead. This method will be removed in version 3.0.0+.\",\n );\n return (await requestPurchase({request, type: 'subs'})) as\n | SubscriptionPurchase\n | SubscriptionPurchase[]\n | null\n | void;\n};\n\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n}: {\n purchase: Purchase;\n isConsumable?: boolean;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n await ExpoIapModule.finishTransaction(transactionId);\n return Promise.resolve(true);\n },\n android: async () => {\n const androidPurchase = purchase as ProductPurchaseAndroid;\n\n if (!('purchaseTokenAndroid' in androidPurchase)) {\n return Promise.reject(\n new Error('purchaseToken is required to finish transaction'),\n );\n }\n if (isConsumable) {\n return ExpoIapModule.consumeProduct(\n androidPurchase.purchaseTokenAndroid,\n );\n } else {\n return ExpoIapModule.acknowledgePurchase(\n androidPurchase.purchaseTokenAndroid,\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\nexport * from './useIap';\n"]}
@@ -209,9 +209,7 @@ public class ExpoIapModule: Module {
209
209
 
210
210
  AsyncFunction("getItems") { (skus: [String]) -> [[String: Any?]?] in
211
211
  guard let productStore = self.productStore else {
212
- throw NSError(
213
- domain: "ExpoIapModule", code: 1,
214
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
212
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
215
213
  }
216
214
 
217
215
  do {
@@ -225,6 +223,9 @@ public class ExpoIapModule: Module {
225
223
  return products.map { serializeProduct($0) }.compactMap { $0 }
226
224
  } catch {
227
225
  print("Error fetching items: \(error)")
226
+ if error is Exception {
227
+ throw error
228
+ }
228
229
  throw error
229
230
  }
230
231
  }
@@ -325,9 +326,7 @@ public class ExpoIapModule: Module {
325
326
  appAccountToken: String?, quantity: Int, discountOffer: [String: String]?
326
327
  ) -> [String: Any?]? in
327
328
  guard let productStore = self.productStore else {
328
- throw NSError(
329
- domain: "ExpoIapModule", code: 1,
330
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
329
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
331
330
  }
332
331
 
333
332
  let product: Product? = await productStore.getProduct(productID: sku)
@@ -357,9 +356,7 @@ public class ExpoIapModule: Module {
357
356
  options.insert(.appAccountToken(appAccountUUID))
358
357
  }
359
358
  guard let windowScene = await self.currentWindowScene() else {
360
- throw NSError(
361
- domain: "ExpoIapModule", code: 2,
362
- userInfo: [NSLocalizedDescriptionKey: "Could not find window scene"])
359
+ throw Exception(name: "ExpoIapModule", description: "Could not find window scene", code: "2")
363
360
  }
364
361
  let result: Product.PurchaseResult
365
362
  #if swift(>=5.9)
@@ -402,30 +399,20 @@ public class ExpoIapModule: Module {
402
399
  return serialized
403
400
  }
404
401
  case .userCancelled:
405
- throw NSError(
406
- domain: "ExpoIapModule", code: 3,
407
- userInfo: [NSLocalizedDescriptionKey: "User cancelled the purchase"])
402
+ throw Exception(name: "ExpoIapModule", description: "User cancelled the purchase", code: "3")
408
403
  case .pending:
409
- throw NSError(
410
- domain: "ExpoIapModule", code: 4,
411
- userInfo: [NSLocalizedDescriptionKey: "The payment was deferred"])
404
+ throw Exception(name: "ExpoIapModule", description: "The payment was deferred", code: "4")
412
405
  @unknown default:
413
- throw NSError(
414
- domain: "ExpoIapModule", code: 5,
415
- userInfo: [NSLocalizedDescriptionKey: "Unknown purchase result"])
406
+ throw Exception(name: "ExpoIapModule", description: "Unknown purchase result", code: "5")
416
407
  }
417
408
  } catch {
418
- throw NSError(
419
- domain: "ExpoIapModule", code: 6,
420
- userInfo: [
421
- NSLocalizedDescriptionKey:
422
- "Purchase failed: \(error.localizedDescription)"
423
- ])
409
+ if error is Exception {
410
+ throw error
411
+ }
412
+ throw Exception(name: "ExpoIapModule", description: "Purchase failed: \(error.localizedDescription)", code: "6")
424
413
  }
425
414
  } else {
426
- throw NSError(
427
- domain: "ExpoIapModule", code: 7,
428
- userInfo: [NSLocalizedDescriptionKey: "Invalid product ID"])
415
+ throw Exception(name: "ExpoIapModule", description: "Invalid product ID", code: "7")
429
416
  }
430
417
  }
431
418
 
@@ -435,9 +422,7 @@ public class ExpoIapModule: Module {
435
422
 
436
423
  AsyncFunction("subscriptionStatus") { (sku: String) -> [[String: Any?]?]? in
437
424
  guard let productStore = self.productStore else {
438
- throw NSError(
439
- domain: "ExpoIapModule", code: 1,
440
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
425
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
441
426
  }
442
427
 
443
428
  do {
@@ -449,20 +434,16 @@ public class ExpoIapModule: Module {
449
434
  }
450
435
  return status.map { serializeSubscriptionStatus($0) }
451
436
  } catch {
452
- throw NSError(
453
- domain: "ExpoIapModule", code: 2,
454
- userInfo: [
455
- NSLocalizedDescriptionKey:
456
- "Error getting subscription status: \(error.localizedDescription)"
457
- ])
437
+ if error is Exception {
438
+ throw error
439
+ }
440
+ throw Exception(name: "ExpoIapModule", description: "Error getting subscription status: \(error.localizedDescription)", code: "2")
458
441
  }
459
442
  }
460
443
 
461
444
  AsyncFunction("currentEntitlement") { (sku: String) -> [String: Any?]? in
462
445
  guard let productStore = self.productStore else {
463
- throw NSError(
464
- domain: "ExpoIapModule", code: 1,
465
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
446
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
466
447
  }
467
448
 
468
449
  if let product = await productStore.getProduct(productID: sku) {
@@ -471,37 +452,24 @@ public class ExpoIapModule: Module {
471
452
  let transaction = try self.checkVerified(result)
472
453
  return serializeTransaction(transaction)
473
454
  } catch StoreError.failedVerification {
474
- throw NSError(
475
- domain: "ExpoIapModule", code: 2,
476
- userInfo: [
477
- NSLocalizedDescriptionKey:
478
- "Failed to verify transaction for sku \(sku)"
479
- ])
455
+ throw Exception(name: "ExpoIapModule", description: "Failed to verify transaction for sku \(sku)", code: "2")
480
456
  } catch {
481
- throw NSError(
482
- domain: "ExpoIapModule", code: 3,
483
- userInfo: [
484
- NSLocalizedDescriptionKey:
485
- "Error fetching entitlement for sku \(sku): \(error.localizedDescription)"
486
- ])
457
+ if error is Exception {
458
+ throw error
459
+ }
460
+ throw Exception(name: "ExpoIapModule", description: "Error fetching entitlement for sku \(sku): \(error.localizedDescription)", code: "3")
487
461
  }
488
462
  } else {
489
- throw NSError(
490
- domain: "ExpoIapModule", code: 4,
491
- userInfo: [NSLocalizedDescriptionKey: "Can't find entitlement for sku \(sku)"])
463
+ throw Exception(name: "ExpoIapModule", description: "Can't find entitlement for sku \(sku)", code: "4")
492
464
  }
493
465
  } else {
494
- throw NSError(
495
- domain: "ExpoIapModule", code: 5,
496
- userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
466
+ throw Exception(name: "ExpoIapModule", description: "Can't find product for sku \(sku)", code: "5")
497
467
  }
498
468
  }
499
469
 
500
470
  AsyncFunction("latestTransaction") { (sku: String) -> [String: Any?]? in
501
471
  guard let productStore = self.productStore else {
502
- throw NSError(
503
- domain: "ExpoIapModule", code: 1,
504
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
472
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
505
473
  }
506
474
 
507
475
  if let product = await productStore.getProduct(productID: sku) {
@@ -510,29 +478,18 @@ public class ExpoIapModule: Module {
510
478
  let transaction = try self.checkVerified(result)
511
479
  return serializeTransaction(transaction)
512
480
  } catch StoreError.failedVerification {
513
- throw NSError(
514
- domain: "ExpoIapModule", code: 2,
515
- userInfo: [
516
- NSLocalizedDescriptionKey:
517
- "Failed to verify transaction for sku \(sku)"
518
- ])
481
+ throw Exception(name: "ExpoIapModule", description: "Failed to verify transaction for sku \(sku)", code: "2")
519
482
  } catch {
520
- throw NSError(
521
- domain: "ExpoIapModule", code: 3,
522
- userInfo: [
523
- NSLocalizedDescriptionKey:
524
- "Error fetching latest transaction for sku \(sku): \(error.localizedDescription)"
525
- ])
483
+ if error is Exception {
484
+ throw error
485
+ }
486
+ throw Exception(name: "ExpoIapModule", description: "Error fetching latest transaction for sku \(sku): \(error.localizedDescription)", code: "3")
526
487
  }
527
488
  } else {
528
- throw NSError(
529
- domain: "ExpoIapModule", code: 4,
530
- userInfo: [NSLocalizedDescriptionKey: "Can't find latest transaction for sku \(sku)"])
489
+ throw Exception(name: "ExpoIapModule", description: "Can't find latest transaction for sku \(sku)", code: "4")
531
490
  }
532
491
  } else {
533
- throw NSError(
534
- domain: "ExpoIapModule", code: 5,
535
- userInfo: [NSLocalizedDescriptionKey: "Can't find product for sku \(sku)"])
492
+ throw Exception(name: "ExpoIapModule", description: "Can't find product for sku \(sku)", code: "5")
536
493
  }
537
494
  }
538
495
 
@@ -542,9 +499,7 @@ public class ExpoIapModule: Module {
542
499
  self.transactions.removeValue(forKey: transactionIdentifier)
543
500
  return true
544
501
  } else {
545
- throw NSError(
546
- domain: "ExpoIapModule", code: 8,
547
- userInfo: [NSLocalizedDescriptionKey: "Invalid transaction ID"])
502
+ throw Exception(name: "ExpoIapModule", description: "Invalid transaction ID", code: "8")
548
503
  }
549
504
  }
550
505
 
@@ -557,12 +512,10 @@ public class ExpoIapModule: Module {
557
512
  try await AppStore.sync()
558
513
  return true
559
514
  } catch {
560
- throw NSError(
561
- domain: "ExpoIapModule", code: 9,
562
- userInfo: [
563
- NSLocalizedDescriptionKey:
564
- "Error synchronizing with the AppStore: \(error.localizedDescription)"
565
- ])
515
+ if error is Exception {
516
+ throw error
517
+ }
518
+ throw Exception(name: "ExpoIapModule", description: "Error synchronizing with the AppStore: \(error.localizedDescription)", code: "9")
566
519
  }
567
520
  }
568
521
 
@@ -571,21 +524,14 @@ public class ExpoIapModule: Module {
571
524
  SKPaymentQueue.default().presentCodeRedemptionSheet()
572
525
  return true
573
526
  #else
574
- throw NSError(
575
- domain: "ExpoIapModule", code: 10,
576
- userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
527
+ throw Exception(name: "ExpoIapModule", description: "This method is not available on tvOS", code: "10")
577
528
  #endif
578
529
  }
579
530
 
580
531
  AsyncFunction("showManageSubscriptions") { () -> Bool in
581
532
  #if !os(tvOS)
582
533
  guard let windowScene = await self.currentWindowScene() else {
583
- throw NSError(
584
- domain: "ExpoIapModule", code: 11,
585
- userInfo: [
586
- NSLocalizedDescriptionKey:
587
- "Cannot find window scene or not available on macOS"
588
- ])
534
+ throw Exception(name: "ExpoIapModule", description: "Cannot find window scene or not available on macOS", code: "11")
589
535
  }
590
536
  // Get all subscription products before showing the management UI
591
537
  let subscriptionSkus = await self.getAllSubscriptionProductIds()
@@ -596,9 +542,7 @@ public class ExpoIapModule: Module {
596
542
  self.pollForSubscriptionStatusChanges()
597
543
  return true
598
544
  #else
599
- throw NSError(
600
- domain: "ExpoIapModule", code: 12,
601
- userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
545
+ throw Exception(name: "ExpoIapModule", description: "This method is not available on tvOS", code: "12")
602
546
  #endif
603
547
  }
604
548
 
@@ -610,6 +554,9 @@ public class ExpoIapModule: Module {
610
554
  await transaction.finish()
611
555
  self.transactions.removeValue(forKey: String(transaction.id))
612
556
  } catch {
557
+ if error is Exception {
558
+ throw error
559
+ }
613
560
  print("Failed to finish transaction")
614
561
  }
615
562
  }
@@ -621,44 +568,26 @@ public class ExpoIapModule: Module {
621
568
  guard let product = await self.productStore?.getProduct(productID: sku),
622
569
  let result = await product.latestTransaction
623
570
  else {
624
- throw NSError(
625
- domain: "ExpoIapModule", code: 5,
626
- userInfo: [
627
- NSLocalizedDescriptionKey:
628
- "Can't find product or transaction for sku \(sku)"
629
- ])
571
+ throw Exception(name: "ExpoIapModule", description: "Can't find product or transaction for sku \(sku)", code: "5")
630
572
  }
631
573
 
632
574
  do {
633
575
  let transaction = try self.checkVerified(result)
634
576
  guard let windowScene = await self.currentWindowScene() else {
635
- throw NSError(
636
- domain: "ExpoIapModule", code: 11,
637
- userInfo: [
638
- NSLocalizedDescriptionKey:
639
- "Cannot find window scene or not available on macOS"
640
- ])
577
+ throw Exception(name: "ExpoIapModule", description: "Cannot find window scene or not available on macOS", code: "11")
641
578
  }
642
579
  let refundStatus = try await transaction.beginRefundRequest(in: windowScene)
643
580
  return serialize(refundStatus)
644
581
  } catch StoreError.failedVerification {
645
- throw NSError(
646
- domain: "ExpoIapModule", code: 2,
647
- userInfo: [
648
- NSLocalizedDescriptionKey: "Failed to verify transaction for sku \(sku)"
649
- ])
582
+ throw Exception(name: "ExpoIapModule", description: "Failed to verify transaction for sku \(sku)", code: "2")
650
583
  } catch {
651
- throw NSError(
652
- domain: "ExpoIapModule", code: 3,
653
- userInfo: [
654
- NSLocalizedDescriptionKey:
655
- "Failed to refund purchase: \(error.localizedDescription)"
656
- ])
584
+ if error is Exception {
585
+ throw error
586
+ }
587
+ throw Exception(name: "ExpoIapModule", description: "Failed to refund purchase: \(error.localizedDescription)", code: "3")
657
588
  }
658
589
  #else
659
- throw NSError(
660
- domain: "ExpoIapModule", code: 12,
661
- userInfo: [NSLocalizedDescriptionKey: "This method is not available on tvOS"])
590
+ throw Exception(name: "ExpoIapModule", description: "This method is not available on tvOS", code: "12")
662
591
  #endif
663
592
  }
664
593
 
@@ -673,9 +602,7 @@ public class ExpoIapModule: Module {
673
602
 
674
603
  AsyncFunction("isTransactionVerified") { (sku: String) -> Bool in
675
604
  guard let productStore = self.productStore else {
676
- throw NSError(
677
- domain: "ExpoIapModule", code: 1,
678
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
605
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
679
606
  }
680
607
 
681
608
  if let product = await productStore.getProduct(productID: sku),
@@ -693,26 +620,20 @@ public class ExpoIapModule: Module {
693
620
 
694
621
  AsyncFunction("getTransactionJws") { (sku: String) -> String? in
695
622
  guard let productStore = self.productStore else {
696
- throw NSError(
697
- domain: "ExpoIapModule", code: 1,
698
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
623
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
699
624
  }
700
625
 
701
626
  if let product = await productStore.getProduct(productID: sku),
702
627
  let result = await product.latestTransaction {
703
628
  return result.jwsRepresentation
704
629
  } else {
705
- throw NSError(
706
- domain: "ExpoIapModule", code: 5,
707
- userInfo: [NSLocalizedDescriptionKey: "Can't find transaction for sku \(sku)"])
630
+ throw Exception(name: "ExpoIapModule", description: "Can't find transaction for sku \(sku)", code: "5")
708
631
  }
709
632
  }
710
633
 
711
634
  AsyncFunction("validateReceiptIos") { (sku: String) -> [String: Any] in
712
635
  guard let productStore = self.productStore else {
713
- throw NSError(
714
- domain: "ExpoIapModule", code: 1,
715
- userInfo: [NSLocalizedDescriptionKey: "Connection not initialized"])
636
+ throw Exception(name: "ExpoIapModule", description: "Connection not initialized", code: "1")
716
637
  }
717
638
 
718
639
  // Get receipt data
@@ -897,17 +818,10 @@ public class ExpoIapModule: Module {
897
818
  let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
898
819
  return receiptData.base64EncodedString(options: [])
899
820
  } catch {
900
- throw NSError(
901
- domain: "ExpoIapModule", code: 13,
902
- userInfo: [
903
- NSLocalizedDescriptionKey:
904
- "Error reading receipt data: \(error.localizedDescription)"
905
- ])
821
+ throw Exception(name: "ExpoIapModule", description: "Error reading receipt data: \(error.localizedDescription)", code: "13")
906
822
  }
907
823
  } else {
908
- throw NSError(
909
- domain: "ExpoIapModule", code: 14,
910
- userInfo: [NSLocalizedDescriptionKey: "App Store receipt not found"])
824
+ throw Exception(name: "ExpoIapModule", description: "App Store receipt not found", code: "14")
911
825
  }
912
826
  }
913
827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  import {isProductIos} from './modules/ios';
27
27
  import {isProductAndroid} from './modules/android';
28
28
 
29
+ export * from './ExpoIap.types';
29
30
  export * from './modules/android';
30
31
  export * from './modules/ios';
31
32