expo-iap 6.4.2 → 6.4.4

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 (43) hide show
  1. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +17 -0
  2. package/build/ExpoIapModule.d.ts +1 -1
  3. package/build/ExpoIapModule.d.ts.map +1 -1
  4. package/build/ExpoIapModule.js.map +1 -1
  5. package/build/index.d.ts +2 -2
  6. package/build/index.d.ts.map +1 -1
  7. package/build/index.js +6 -3
  8. package/build/index.js.map +1 -1
  9. package/build/index.kepler.d.ts +1 -0
  10. package/build/index.kepler.d.ts.map +1 -1
  11. package/build/index.kepler.js +1 -0
  12. package/build/index.kepler.js.map +1 -1
  13. package/build/modules/android.d.ts +2 -0
  14. package/build/modules/android.d.ts.map +1 -1
  15. package/build/modules/android.js +5 -0
  16. package/build/modules/android.js.map +1 -1
  17. package/build/modules/ios.d.ts +1 -1
  18. package/build/modules/ios.js +2 -2
  19. package/build/modules/ios.js.map +1 -1
  20. package/build/purchase-flow-confirmers.d.ts +10 -2
  21. package/build/purchase-flow-confirmers.d.ts.map +1 -1
  22. package/build/purchase-flow-confirmers.js +32 -15
  23. package/build/purchase-flow-confirmers.js.map +1 -1
  24. package/build/types.d.ts +13 -2
  25. package/build/types.d.ts.map +1 -1
  26. package/build/types.js.map +1 -1
  27. package/build/useIAP.d.ts +1 -0
  28. package/build/useIAP.d.ts.map +1 -1
  29. package/build/useIAP.js +21 -6
  30. package/build/useIAP.js.map +1 -1
  31. package/bun.lock +2 -2
  32. package/ios/ExpoIapModule.swift +1 -1
  33. package/openiap-versions.json +3 -3
  34. package/osv-scanner.toml +6 -6
  35. package/package.json +2 -2
  36. package/src/ExpoIapModule.ts +1 -0
  37. package/src/index.kepler.ts +5 -0
  38. package/src/index.ts +7 -3
  39. package/src/modules/android.ts +8 -0
  40. package/src/modules/ios.ts +2 -2
  41. package/src/purchase-flow-confirmers.ts +45 -22
  42. package/src/types.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AE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,EAAE,2BAA2B,CAAC,OAAO,CAAC;QACzD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC;QAExE,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;YAC7B,gBAAgB,EAAE,CAAC;YACnB,IAAI,kCAAkC,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC9D,kCAAkC,CAAC,OAAO,GAAG,CAAC,CAAC;gBAC/C,iBAAiB,EAAE,CAAC;YACtB,CAAC;YACD,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEjD,OAAO;QACL,SAAS;QACT,QAAQ;QACR,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,qBAAqB,EAAE,6BAA6B;QACpD,aAAa,EAAE,qBAAqB;QACpC,eAAe;QACf,cAAc;QACd,0BAA0B;QAC1B,gBAAgB,EAAE,wBAAwB;QAC1C,qBAAqB;QACrB,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;QACtD,SAAS;QACT,2BAA2B;QAC3B,gCAAgC;QAChC,2CAA2C;QAC3C,yBAAyB;QACzB,0CAA0C;QAC1C,wBAAwB;QACxB,wBAAwB;QACxB,mBAAmB;KACpB,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useLayoutEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport type {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n userChoiceBillingListenerAndroid,\n developerProvidedBillingListenerAndroid,\n subscriptionBillingIssueListener,\n getAvailablePurchases,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n verifyPurchase as verifyPurchaseInternal,\n verifyPurchaseWithProvider as verifyPurchaseWithProviderInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n openRedeemOfferCode,\n type ActiveSubscription,\n type ProductTypeInput,\n} from './index';\nimport {ExpoIapConsole} from './utils/debug';\nimport type {PurchaseFlow, PurchaseFlowOutcome} from './purchase-flow-core';\nimport {getPromotedProductIOS} from './modules/ios';\nimport {restorePurchasesNative} from './utils/restorePurchases';\nimport {\n getBillingChoiceInfoAndroid,\n isBillingProgramAvailableAndroid,\n createBillingProgramReportingDetailsAndroid,\n launchExternalLinkAndroid,\n showBillingProgramInformationDialogAndroid,\n showInAppMessagesAndroid,\n} from './modules/android';\n\n// Types\nimport type {\n Product,\n ProductSubscription,\n ProductQueryType,\n ProductRequest,\n BillingChoiceScreenTypeAndroid,\n BillingProgramAndroid,\n DeveloperProvidedBillingDetailsAndroid,\n InitConnectionConfig,\n Purchase,\n MutationRequestPurchaseArgs,\n PurchaseInput,\n PurchaseUpdatedListenerOptions,\n VerifyPurchaseProps,\n VerifyPurchaseResult,\n VerifyPurchaseWithProviderProps,\n VerifyPurchaseWithProviderResult,\n PurchaseOptions,\n MutationField,\n QueryField,\n UserChoiceBillingDetails,\n} from './types';\nimport {ErrorCode} from './types';\nimport type {PurchaseError} from './utils/errorMapping';\nimport {\n getUserFriendlyErrorMessage,\n isUserCancelledError,\n isRecoverableError,\n} from './utils/errorMapping';\n\n// Hooks share one native connection; the last mounted hook ends it.\nlet connectionOwnerCount = 0;\n\nconst releaseConnection = (): void => {\n connectionOwnerCount = Math.max(0, connectionOwnerCount - 1);\n if (connectionOwnerCount > 0) return;\n endConnection().catch((error: unknown) => {\n ExpoIapConsole.warn('[useIAP] endConnection failed:', error);\n });\n};\n\ntype UseIap = {\n connected: boolean;\n products: Product[];\n subscriptions: ProductSubscription[];\n availablePurchases: Purchase[];\n promotedProductIOS?: Product;\n activeSubscriptions: ActiveSubscription[];\n finishTransaction: ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }) => Promise<void>;\n getAvailablePurchases: (options?: PurchaseOptions) => Promise<void>;\n fetchProducts: (params: {\n skus: string[];\n type?: ProductTypeInput;\n }) => Promise<void>;\n\n requestPurchase: (\n params: MutationRequestPurchaseArgs,\n ) => ReturnType<typeof requestPurchaseInternal>;\n verifyPurchase: (props: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;\n verifyPurchaseWithProvider: (\n props: VerifyPurchaseWithProviderProps,\n ) => Promise<VerifyPurchaseWithProviderResult>;\n restorePurchases: (options?: PurchaseOptions) => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<void>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n /**\n * Manually retry the store connection.\n * Useful when the initial auto-connect fails (e.g., Play Store not ready at mount time).\n * Updates the `connected` state on success.\n */\n reconnect: () => Promise<boolean>;\n getBillingChoiceInfoAndroid: QueryField<'getBillingChoiceInfoAndroid'>;\n isBillingProgramAvailableAndroid: MutationField<'isBillingProgramAvailableAndroid'>;\n createBillingProgramReportingDetailsAndroid: MutationField<'createBillingProgramReportingDetailsAndroid'>;\n launchExternalLinkAndroid: MutationField<'launchExternalLinkAndroid'>;\n showBillingProgramInformationDialogAndroid: MutationField<'showBillingProgramInformationDialogAndroid'>;\n showInAppMessagesAndroid: MutationField<'showInAppMessagesAndroid'>;\n openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n /**\n * The app's flow from `createPurchaseFlow`, which confirms and finishes\n * every purchase. The hook recovers unfinished purchases once connected or\n * when the flow changes, reports outcomes, and refreshes ownership after\n * each. Leave finishing out of `onPurchaseSuccess` when this is set.\n */\n purchaseFlow?: PurchaseFlow<Purchase>;\n /** Each purchase's outcome from `purchaseFlow`. */\n onPurchaseFlowOutcome?: (outcome: PurchaseFlowOutcome<Purchase>) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n /**\n * Options for the purchase success listener. iOS defaults to suppressing\n * StoreKit replay events for the same transaction ID; set\n * `dedupeTransactionIOS` to false only for diagnostics.\n */\n purchaseUpdatedListenerOptions?: PurchaseUpdatedListenerOptions | null;\n /**\n * Called when a hook method such as fetchProducts, getAvailablePurchases,\n * getActiveSubscriptions or restorePurchases fails.\n */\n onError?: (error: Error) => void;\n onPromotedProductIOS?: (product: Product) => void;\n onUserChoiceBillingAndroid?: (details: UserChoiceBillingDetails) => void;\n /**\n * Fires when the user selects developer-provided billing in an External\n * Payments or Google-rendered Billing Choice flow.\n */\n onDeveloperProvidedBillingAndroid?: (\n details: DeveloperProvidedBillingDetailsAndroid,\n ) => void;\n /** Fires when a subscription enters a billing-issue state. */\n onSubscriptionBillingIssue?: (purchase: Purchase) => void;\n /**\n * Enable a specific billing program for Android (8.2.0+).\n * Use 'external-payments' for Developer Provided Billing (Japan only, 8.3.0+).\n * Use 'user-choice-billing' for User Choice Billing (7.0+).\n * Use 'billing-choice' for Billing Choice (9.1.0+).\n */\n enableBillingProgramAndroid?: BillingProgramAndroid;\n /**\n * Select who renders the Billing Choice screen (9.1.0+). Must match the\n * choiceScreenType returned by isBillingProgramAvailableAndroid.\n */\n billingChoiceScreenTypeAndroid?: BillingChoiceScreenTypeAndroid;\n}\n\n// The store refused a new billing program because a purchase is in progress;\n// the live connection stays up.\nconst isRefusedRebuild = (error: unknown): boolean =>\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === ErrorCode.DeveloperError;\n\n// A fetched item replaces the one it updates, keeping the list's order.\nfunction mergeByKey<T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n): T[] {\n const merged = new Map(\n existingItems.map((item) => [getKey(item), item] as const),\n );\n newItems.forEach((item) => merged.set(getKey(item), item));\n return Array.from(merged.values());\n}\n\n// Store reads can resolve out of order. A result publishes only when no newer\n// read has published, so a failed newer read lets an older result through,\n// and a purchase makes every read that started before it stale.\ninterface ReadOrder {\n started: number;\n published: number;\n}\nconst startRead = (order: ReadOrder): number => ++order.started;\nconst claimPublish = (order: ReadOrder, read: number): boolean => {\n if (read <= order.published) return false;\n order.published = read;\n return true;\n};\nconst invalidateReads = (order: ReadOrder): void => {\n order.published = ++order.started;\n};\n\n/**\n * React Hook for managing In-App Purchases. Mounted hooks share one store\n * connection, which ends when the last of them unmounts.\n * See documentation at https://openiap.dev/docs/setup/expo#useIAP-hook\n */\nexport function useIAP(options?: UseIAPOptions): UseIap {\n const [connected, setConnected] = useState<boolean>(false);\n const [products, setProducts] = useState<Product[]>([]);\n const [subscriptions, setSubscriptions] = useState<ProductSubscription[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>([]);\n const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();\n const [activeSubscriptions, setActiveSubscriptions] = useState<\n ActiveSubscription[]\n >([]);\n\n const optionsRef = useRef<UseIAPOptions | undefined>(options);\n const connectedRef = useRef<boolean>(false);\n const isMountedRef = useRef<boolean>(false);\n const initializationGenerationRef = useRef(0);\n const startedInitializationGenerationRef = useRef(0);\n const availablePurchasesReads = useRef<ReadOrder>({started: 0, published: 0});\n const activeSubscriptionsReads = useRef<ReadOrder>({\n started: 0,\n published: 0,\n });\n\n // Before any effect runs, so a purchase never reaches a stale callback.\n useLayoutEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n connectedRef.current = connected;\n }, [connected]);\n\n const subscriptionsRef = useRef<{\n purchaseUpdate?: EventSubscription;\n purchaseError?: EventSubscription;\n promotedProductIOS?: EventSubscription;\n userChoiceBillingAndroid?: EventSubscription;\n developerProvidedBillingAndroid?: EventSubscription;\n subscriptionBillingIssue?: EventSubscription;\n }>({});\n\n const subscriptionsRefState = useRef<ProductSubscription[]>([]);\n\n useEffect(() => {\n subscriptionsRefState.current = subscriptions;\n }, [subscriptions]);\n\n const normalizeProductQueryType = useCallback(\n (type?: ProductTypeInput): ProductQueryType => {\n if (!type || type === 'in-app') {\n return 'in-app';\n }\n return type;\n },\n [],\n );\n\n const canonicalProductType = useCallback(\n (value?: string): ProductQueryType => {\n if (!value) {\n return 'in-app';\n }\n\n const normalized = value.trim().toLowerCase().replace(/[_-]/g, '');\n return normalized === 'subs' ? 'subs' : 'in-app';\n },\n [],\n );\n\n const toPurchaseInput = useCallback(\n (purchase: Purchase): PurchaseInput => ({\n ...purchase,\n ids: purchase.ids ?? undefined,\n }),\n [],\n );\n\n const invokeOnError = useCallback((error: unknown) => {\n if (isMountedRef.current && optionsRef.current?.onError) {\n optionsRef.current.onError(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }, []);\n\n /**\n * Retrieve products or subscriptions from the store by SKU.\n *\n * @param params `ProductRequest` — `skus` (string[]) and optional `type`\n * (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).\n * @returns Promise that resolves when the request is dispatched; results land in the\n * hook's reactive `products` / `subscriptions` state.\n * @throws When the store rejects the request (empty `skus`, not connected,\n * network/store error). Unknown SKUs are omitted from the result, not thrown.\n *\n * @example\n * ```ts\n * const { fetchProducts, products } = useIAP();\n * await fetchProducts({\n * skus: ['com.app.coins_100', 'com.app.premium'],\n * type: 'in-app',\n * });\n * ```\n *\n * @remarks Promise-based, unlike the event-based `request*` APIs such as `requestPurchase`.\n *\n * @see {@link https://openiap.dev/docs/apis/fetch-products}\n */\n const fetchProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: ProductTypeInput;\n }): Promise<void> => {\n try {\n const queryType = normalizeProductQueryType(params.type);\n const request: ProductRequest = {skus: params.skus, type: queryType};\n const result = await fetchProducts(request);\n const items = (result ?? []) as (Product | ProductSubscription)[];\n\n ExpoIapConsole.debug('Fetched products:', items);\n\n if (queryType === 'subs') {\n const subscriptionsResult = items as ProductSubscription[];\n setSubscriptions((prevSubscriptions) =>\n mergeByKey(\n prevSubscriptions,\n subscriptionsResult,\n (subscription) => subscription.id,\n ),\n );\n } else if (queryType === 'in-app') {\n const productsResult = items as Product[];\n setProducts((prevProducts) =>\n mergeByKey(prevProducts, productsResult, (product) => product.id),\n );\n } else {\n const productItems = items.filter(\n (item) => canonicalProductType(item.type as string) === 'in-app',\n ) as Product[];\n\n const subscriptionItems = items.filter(\n (item) => canonicalProductType(item.type as string) === 'subs',\n ) as ProductSubscription[];\n\n setProducts((prevProducts) =>\n mergeByKey(prevProducts, productItems, (product) => product.id),\n );\n\n setSubscriptions((prevSubscriptions) =>\n mergeByKey(\n prevSubscriptions,\n subscriptionItems,\n (subscription) => subscription.id,\n ),\n );\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching products:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [canonicalProductType, invokeOnError, normalizeProductQueryType],\n );\n\n /**\n * List the user's unfinished purchases: non-consumables, active subscriptions,\n * and pending transactions.\n *\n * @param options Optional `PurchaseOptions`. iOS-only flags:\n * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.\n * @returns Promise that resolves when the request is dispatched; results land in the\n * hook's reactive `availablePurchases` state.\n * @throws When the platform query fails.\n *\n * @example\n * ```ts\n * const { getAvailablePurchases, availablePurchases } = useIAP();\n * await getAvailablePurchases();\n * for (const p of availablePurchases) {\n * if (await verifyOnServer(p)) await finishTransaction({ purchase: p, isConsumable: false });\n * }\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/get-available-purchases}\n */\n const getAvailablePurchasesInternal = useCallback(\n async (options?: PurchaseOptions): Promise<void> => {\n const read = startRead(availablePurchasesReads.current);\n try {\n const result = await getAvailablePurchases({\n alsoPublishToEventListenerIOS:\n options?.alsoPublishToEventListenerIOS ?? false,\n onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,\n includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,\n });\n if (claimPublish(availablePurchasesReads.current, read)) {\n setAvailablePurchases(result);\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching available purchases:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Get details of all currently active subscriptions.\n *\n * @see {@link https://openiap.dev/docs/apis/get-active-subscriptions}\n */\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<void> => {\n const read = startRead(activeSubscriptionsReads.current);\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n if (claimPublish(activeSubscriptionsReads.current, read)) {\n setActiveSubscriptions(result);\n }\n } catch (error) {\n ExpoIapConsole.error('Error getting active subscriptions:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Check whether the user has any active subscription.\n *\n * @see {@link https://openiap.dev/docs/apis/has-active-subscriptions}\n */\n const hasActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<boolean> => {\n try {\n return await hasActiveSubscriptions(subscriptionIds);\n } catch (error) {\n ExpoIapConsole.error('Error checking active subscriptions:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Complete a purchase transaction. Call after server-side verification to remove it\n * from the queue.\n *\n * @param args.purchase The `Purchase` to finalize.\n * @param args.isConsumable `true` for consumables (consumes the token so the SKU can be\n * re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.\n * @returns Promise that resolves once the platform finalizes the transaction.\n * @throws When the platform finalize call fails.\n *\n * @example\n * ```ts\n * // Inside purchaseUpdatedListener:\n * if (await verifyOnServer(purchase)) {\n * await finishTransaction({ purchase, isConsumable: false });\n * }\n * ```\n *\n * @remarks Android purchases must be finalized within 3 days or Google\n * auto-refunds. iOS unfinished transactions replay on every app launch.\n *\n * @see {@link https://openiap.dev/docs/apis/finish-transaction}\n */\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }): Promise<void> => {\n await finishTransactionInternal({\n purchase: toPurchaseInput(purchase),\n isConsumable,\n });\n },\n [toPurchaseInput],\n );\n\n // Replaces the reads a purchase invalidated; a known subscription also\n // refreshes its catalog entry first.\n const refreshAfterPurchase = useCallback(\n async (productId: string) => {\n const generation = initializationGenerationRef.current;\n const isCurrent = (): boolean =>\n isMountedRef.current &&\n initializationGenerationRef.current === generation;\n const ownership = [\n getAvailablePurchasesInternal,\n getActiveSubscriptionsInternal,\n ];\n const refreshes = subscriptionsRefState.current.some(\n (sub) => sub.id === productId,\n )\n ? [\n () => fetchProductsInternal({skus: [productId], type: 'subs'}),\n ...ownership,\n ]\n : ownership;\n for (const refresh of refreshes) {\n if (!isCurrent()) return;\n try {\n await refresh();\n } catch (error) {\n if (isCurrent()) {\n ExpoIapConsole.warn('Failed to refresh after a purchase:', error);\n }\n }\n }\n },\n [\n fetchProductsInternal,\n getAvailablePurchasesInternal,\n getActiveSubscriptionsInternal,\n ],\n );\n\n /**\n * Restore non-consumable and active subscription purchases.\n *\n * @see {@link https://openiap.dev/docs/apis/restore-purchases}\n */\n const restorePurchasesInternal = useCallback(\n async (options?: PurchaseOptions): Promise<void> => {\n try {\n await restorePurchasesNative();\n await optionsRef.current?.purchaseFlow?.recoverPurchases({\n includeFinished: true,\n });\n\n const read = startRead(availablePurchasesReads.current);\n const purchases = await getAvailablePurchases({\n alsoPublishToEventListenerIOS:\n options?.alsoPublishToEventListenerIOS ?? false,\n onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,\n includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,\n });\n if (claimPublish(availablePurchasesReads.current, read)) {\n setAvailablePurchases(purchases);\n }\n } catch (error) {\n ExpoIapConsole.warn('Failed to restore purchases:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Verify a purchase against your own backend (returns isValid + raw store metadata).\n *\n * @see {@link https://openiap.dev/docs/features/validation#verify-purchase}\n */\n const verifyPurchase = useCallback(async (props: VerifyPurchaseProps) => {\n return verifyPurchaseInternal(props);\n }, []);\n\n /**\n * Verify via a managed provider; `iapkit` (IAPKit) is the only one.\n *\n * @see {@link https://openiap.dev/docs/features/validation#verify-purchase-with-provider}\n */\n const verifyPurchaseWithProvider = useCallback(\n async (props: VerifyPurchaseWithProviderProps) => {\n return verifyPurchaseWithProviderInternal(props);\n },\n [],\n );\n\n const buildConnectionConfig = useCallback(():\n | InitConnectionConfig\n | undefined => {\n if (optionsRef.current?.enableBillingProgramAndroid) {\n return {\n enableBillingProgramAndroid:\n optionsRef.current.enableBillingProgramAndroid,\n ...(optionsRef.current.billingChoiceScreenTypeAndroid\n ? {\n billingChoiceScreenTypeAndroid:\n optionsRef.current.billingChoiceScreenTypeAndroid,\n }\n : {}),\n };\n }\n\n return undefined;\n }, []);\n\n const handlePurchaseUpdate = useCallback(\n async (purchase: Purchase): Promise<void> => {\n // Before the callback, which may read again: a read that started before\n // this purchase is stale.\n invalidateReads(availablePurchasesReads.current);\n invalidateReads(activeSubscriptionsReads.current);\n // Deliver first so a store refresh cannot delay finishing the transaction.\n try {\n const callbackResult: unknown =\n optionsRef.current?.onPurchaseSuccess?.(purchase);\n Promise.resolve(callbackResult).catch((error: unknown) => {\n ExpoIapConsole.error('[useIAP] onPurchaseSuccess failed:', error);\n });\n } catch (error) {\n ExpoIapConsole.error('[useIAP] onPurchaseSuccess failed:', error);\n }\n\n // With a purchase flow, its outcome refreshes once the purchase is\n // finished instead.\n if (!optionsRef.current?.purchaseFlow) {\n await refreshAfterPurchase(purchase.productId);\n }\n },\n [refreshAfterPurchase],\n );\n\n // Registers only missing listeners, so reconnect can restore removed ones.\n const registerListeners = useCallback(() => {\n const current = subscriptionsRef.current;\n if (!current.purchaseUpdate) {\n current.purchaseUpdate = purchaseUpdatedListener(\n handlePurchaseUpdate,\n optionsRef.current?.purchaseUpdatedListenerOptions,\n );\n }\n\n if (!current.purchaseError) {\n current.purchaseError = purchaseErrorListener((error: PurchaseError) => {\n if (!connectedRef.current && error.code === ErrorCode.InitConnection) {\n return; // Ignore initialization error before connected\n }\n if (\n error.code !== ErrorCode.AlreadyOwned &&\n !isUserCancelledError(error) &&\n !isRecoverableError(error)\n ) {\n ExpoIapConsole.warn(\n '[useIAP] Purchase error:',\n getUserFriendlyErrorMessage(error),\n );\n }\n optionsRef.current?.onPurchaseError?.(error);\n });\n }\n\n // Android billing callbacks are read at event time, so they may be set after mount.\n if (Platform.OS === 'android' && !current.userChoiceBillingAndroid) {\n current.userChoiceBillingAndroid = userChoiceBillingListenerAndroid(\n (details) => {\n optionsRef.current?.onUserChoiceBillingAndroid?.(details);\n },\n );\n }\n\n if (Platform.OS === 'android' && !current.developerProvidedBillingAndroid) {\n current.developerProvidedBillingAndroid =\n developerProvidedBillingListenerAndroid((details) => {\n optionsRef.current?.onDeveloperProvidedBillingAndroid?.(details);\n });\n }\n\n if (!current.subscriptionBillingIssue) {\n current.subscriptionBillingIssue = subscriptionBillingIssueListener(\n (purchase) => {\n optionsRef.current?.onSubscriptionBillingIssue?.(purchase);\n },\n );\n }\n\n if (Platform.OS === 'ios' && !current.promotedProductIOS) {\n current.promotedProductIOS = promotedProductListenerIOS(\n (product: Product) => {\n setPromotedProductIOS(product);\n optionsRef.current?.onPromotedProductIOS?.(product);\n },\n );\n }\n }, [handlePurchaseUpdate]);\n\n /**\n * Initiate a purchase or subscription flow. The result arrives through\n * `purchaseUpdatedListener` / `purchaseErrorListener`, not the return value.\n *\n * @param props `RequestPurchaseProps`, discriminated by `type`:\n * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).\n * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.\n * @returns Promise that resolves when the request is dispatched; the actual purchase\n * outcome lands in the hook's `onPurchaseSuccess` / `onPurchaseError` callbacks.\n * @throws Synchronous rejection from the store (e.g. `ErrorCode.NotPrepared`, validation failure).\n *\n * @example\n * ```ts\n * await requestPurchase({\n * request: {\n * apple: { sku: 'com.app.premium' },\n * google: { skus: ['com.app.premium'] },\n * },\n * type: 'in-app',\n * });\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/request-purchase}\n */\n const requestPurchase = useCallback(\n (requestObj: MutationRequestPurchaseArgs) => {\n // A failed hook init removes the purchase listener; restore it before buying.\n if (isMountedRef.current) {\n registerListeners();\n }\n return requestPurchaseInternal(requestObj);\n },\n [registerListeners],\n );\n\n // Purchase-error listening stays on so later retries still report errors.\n const removePurchaseListeners = useCallback(() => {\n subscriptionsRef.current.purchaseUpdate?.remove();\n subscriptionsRef.current.promotedProductIOS?.remove();\n subscriptionsRef.current.purchaseUpdate = undefined;\n subscriptionsRef.current.promotedProductIOS = undefined;\n }, []);\n\n const cleanupListeners = useCallback(() => {\n const current = subscriptionsRef.current;\n current.purchaseUpdate?.remove();\n current.purchaseError?.remove();\n current.promotedProductIOS?.remove();\n current.userChoiceBillingAndroid?.remove();\n current.developerProvidedBillingAndroid?.remove();\n current.subscriptionBillingIssue?.remove();\n subscriptionsRef.current = {};\n }, []);\n\n const initIapWithSubscriptions = useCallback(\n async (generation: number): Promise<void> => {\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n return;\n }\n startedInitializationGenerationRef.current = generation;\n connectionOwnerCount += 1;\n\n // Register listeners before initConnection; events can fire as soon as it connects.\n registerListeners();\n\n const config = buildConnectionConfig();\n\n try {\n const result = await initConnection(config);\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n if (startedInitializationGenerationRef.current === generation) {\n startedInitializationGenerationRef.current = 0;\n releaseConnection();\n }\n return;\n }\n setConnected(result);\n if (!result) {\n ExpoIapConsole.warn(\n '[useIAP] Connection failed, cleaning up listeners...',\n );\n removePurchaseListeners();\n }\n } catch (error) {\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n return;\n }\n invokeOnError(error);\n if (isRefusedRebuild(error)) {\n setConnected(true);\n return;\n }\n ExpoIapConsole.error('initConnection failed:', error);\n removePurchaseListeners();\n }\n },\n [\n buildConnectionConfig,\n registerListeners,\n removePurchaseListeners,\n invokeOnError,\n ],\n );\n\n const reconnect = useCallback(async (): Promise<boolean> => {\n const config = buildConnectionConfig();\n\n try {\n const result = await initConnection(config);\n setConnected(result);\n\n if (result) {\n registerListeners();\n }\n\n return result;\n } catch (error) {\n if (!isRefusedRebuild(error)) {\n ExpoIapConsole.error('[useIAP] reconnect failed:', error);\n }\n invokeOnError(error);\n return false;\n }\n }, [buildConnectionConfig, registerListeners, invokeOnError]);\n\n const purchaseFlow = options?.purchaseFlow;\n useEffect(\n () =>\n purchaseFlow?.subscribe((outcome) => {\n // Reads that started before the purchase settled are stale.\n invalidateReads(availablePurchasesReads.current);\n invalidateReads(activeSubscriptionsReads.current);\n try {\n optionsRef.current?.onPurchaseFlowOutcome?.(outcome);\n } catch (error) {\n ExpoIapConsole.error('[useIAP] onPurchaseFlowOutcome failed:', error);\n }\n void refreshAfterPurchase(outcome.purchase.productId);\n }),\n [purchaseFlow, refreshAfterPurchase],\n );\n\n // Once connected, and again for a new account's flow.\n useEffect(() => {\n if (!connected || !purchaseFlow) return;\n purchaseFlow.recoverPurchases().catch((error: unknown) => {\n ExpoIapConsole.warn('[useIAP] purchase recovery failed:', error);\n invokeOnError(error);\n });\n }, [connected, purchaseFlow, invokeOnError]);\n\n useEffect(() => {\n const generation = ++initializationGenerationRef.current;\n isMountedRef.current = true;\n void Promise.resolve().then(() => initIapWithSubscriptions(generation));\n\n return () => {\n isMountedRef.current = false;\n cleanupListeners();\n if (startedInitializationGenerationRef.current === generation) {\n startedInitializationGenerationRef.current = 0;\n releaseConnection();\n }\n setConnected(false);\n };\n }, [initIapWithSubscriptions, cleanupListeners]);\n\n return {\n connected,\n products,\n subscriptions,\n finishTransaction,\n availablePurchases,\n promotedProductIOS,\n activeSubscriptions,\n getAvailablePurchases: getAvailablePurchasesInternal,\n fetchProducts: fetchProductsInternal,\n requestPurchase,\n verifyPurchase,\n verifyPurchaseWithProvider,\n restorePurchases: restorePurchasesInternal,\n getPromotedProductIOS,\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n reconnect,\n getBillingChoiceInfoAndroid,\n isBillingProgramAvailableAndroid,\n createBillingProgramReportingDetailsAndroid,\n launchExternalLinkAndroid,\n showBillingProgramInformationDialogAndroid,\n showInAppMessagesAndroid,\n // Offer code redemption\n openRedeemOfferCode,\n };\n}\n"]}
1
+ {"version":3,"file":"useIAP.js","sourceRoot":"","sources":["../src/useIAP.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAGtC,mBAAmB;AACnB,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,uCAAuC,EACvC,gCAAgC,EAChC,qBAAqB,EACrB,iBAAiB,IAAI,yBAAyB,EAC9C,eAAe,IAAI,uBAAuB,EAC1C,aAAa,EACb,cAAc,IAAI,sBAAsB,EACxC,0BAA0B,IAAI,kCAAkC,EAChE,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GAGpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,2CAA2C,EAC3C,yBAAyB,EACzB,0CAA0C,EAC1C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YACtB,CAAC;YACD,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEjD,OAAO;QACL,SAAS;QACT,QAAQ;QACR,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,qBAAqB,EAAE,6BAA6B;QACpD,aAAa,EAAE,qBAAqB;QACpC,eAAe;QACf,cAAc;QACd,0BAA0B;QAC1B,gBAAgB,EAAE,wBAAwB;QAC1C,qBAAqB;QACrB,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;QACtD,SAAS;QACT,2BAA2B;QAC3B,gCAAgC;QAChC,2CAA2C;QAC3C,yBAAyB;QACzB,0CAA0C;QAC1C,kDAAkD;QAClD,wBAAwB;QACxB,wBAAwB;QACxB,mBAAmB;KACpB,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useLayoutEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport type {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n userChoiceBillingListenerAndroid,\n developerProvidedBillingListenerAndroid,\n subscriptionBillingIssueListener,\n getAvailablePurchases,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n verifyPurchase as verifyPurchaseInternal,\n verifyPurchaseWithProvider as verifyPurchaseWithProviderInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n openRedeemOfferCode,\n type ActiveSubscription,\n type ProductTypeInput,\n} from './index';\nimport {ExpoIapConsole} from './utils/debug';\nimport type {PurchaseFlow, PurchaseFlowOutcome} from './purchase-flow-core';\nimport {getPromotedProductIOS} from './modules/ios';\nimport {restorePurchasesNative} from './utils/restorePurchases';\nimport {\n getBillingChoiceInfoAndroid,\n isBillingProgramAvailableAndroid,\n createBillingProgramReportingDetailsAndroid,\n launchExternalLinkAndroid,\n showBillingProgramInformationDialogAndroid,\n showAlternativeBillingOnlyInformationDialogAndroid,\n showInAppMessagesAndroid,\n} from './modules/android';\n\n// Types\nimport type {\n Product,\n ProductSubscription,\n ProductQueryType,\n ProductRequest,\n BillingChoiceScreenTypeAndroid,\n BillingProgramAndroid,\n DeveloperProvidedBillingDetailsAndroid,\n InitConnectionConfig,\n Purchase,\n MutationRequestPurchaseArgs,\n PurchaseInput,\n PurchaseUpdatedListenerOptions,\n VerifyPurchaseProps,\n VerifyPurchaseResult,\n VerifyPurchaseWithProviderProps,\n VerifyPurchaseWithProviderResult,\n PurchaseOptions,\n MutationField,\n QueryField,\n UserChoiceBillingDetails,\n} from './types';\nimport {ErrorCode} from './types';\nimport type {PurchaseError} from './utils/errorMapping';\nimport {\n getUserFriendlyErrorMessage,\n isUserCancelledError,\n isRecoverableError,\n} from './utils/errorMapping';\n\n// Hooks share one native connection; the last mounted hook ends it.\nlet connectionOwnerCount = 0;\n\nconst releaseConnection = (): void => {\n connectionOwnerCount = Math.max(0, connectionOwnerCount - 1);\n if (connectionOwnerCount > 0) return;\n endConnection().catch((error: unknown) => {\n ExpoIapConsole.warn('[useIAP] endConnection failed:', error);\n });\n};\n\ntype UseIap = {\n connected: boolean;\n products: Product[];\n subscriptions: ProductSubscription[];\n availablePurchases: Purchase[];\n promotedProductIOS?: Product;\n activeSubscriptions: ActiveSubscription[];\n finishTransaction: ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }) => Promise<void>;\n getAvailablePurchases: (options?: PurchaseOptions) => Promise<void>;\n fetchProducts: (params: {\n skus: string[];\n type?: ProductTypeInput;\n }) => Promise<void>;\n\n requestPurchase: (\n params: MutationRequestPurchaseArgs,\n ) => ReturnType<typeof requestPurchaseInternal>;\n verifyPurchase: (props: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;\n verifyPurchaseWithProvider: (\n props: VerifyPurchaseWithProviderProps,\n ) => Promise<VerifyPurchaseWithProviderResult>;\n restorePurchases: (options?: PurchaseOptions) => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<void>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n /**\n * Manually retry the store connection.\n * Useful when the initial auto-connect fails (e.g., Play Store not ready at mount time).\n * Updates the `connected` state on success.\n */\n reconnect: () => Promise<boolean>;\n getBillingChoiceInfoAndroid: QueryField<'getBillingChoiceInfoAndroid'>;\n isBillingProgramAvailableAndroid: MutationField<'isBillingProgramAvailableAndroid'>;\n createBillingProgramReportingDetailsAndroid: MutationField<'createBillingProgramReportingDetailsAndroid'>;\n launchExternalLinkAndroid: MutationField<'launchExternalLinkAndroid'>;\n showBillingProgramInformationDialogAndroid: MutationField<'showBillingProgramInformationDialogAndroid'>;\n showAlternativeBillingOnlyInformationDialogAndroid: MutationField<'showAlternativeBillingOnlyInformationDialogAndroid'>;\n showInAppMessagesAndroid: MutationField<'showInAppMessagesAndroid'>;\n openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n /**\n * The app's flow from `createPurchaseFlow`, which confirms and finishes\n * every purchase. The hook recovers unfinished purchases once connected or\n * when the flow changes, reports outcomes, and refreshes ownership after\n * each. Leave finishing out of `onPurchaseSuccess` when this is set.\n */\n purchaseFlow?: PurchaseFlow<Purchase>;\n /** Each purchase's outcome from `purchaseFlow`. */\n onPurchaseFlowOutcome?: (outcome: PurchaseFlowOutcome<Purchase>) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n /**\n * Options for the purchase success listener. iOS defaults to suppressing\n * StoreKit replay events for the same transaction ID; set\n * `dedupeTransactionIOS` to false only for diagnostics.\n */\n purchaseUpdatedListenerOptions?: PurchaseUpdatedListenerOptions | null;\n /**\n * Called when a hook method such as fetchProducts, getAvailablePurchases,\n * getActiveSubscriptions or restorePurchases fails.\n */\n onError?: (error: Error) => void;\n onPromotedProductIOS?: (product: Product) => void;\n onUserChoiceBillingAndroid?: (details: UserChoiceBillingDetails) => void;\n /**\n * Fires when the user selects developer-provided billing in an External\n * Payments or Google-rendered Billing Choice flow.\n */\n onDeveloperProvidedBillingAndroid?: (\n details: DeveloperProvidedBillingDetailsAndroid,\n ) => void;\n /** Fires when a subscription enters a billing-issue state. */\n onSubscriptionBillingIssue?: (purchase: Purchase) => void;\n /**\n * Enable a specific billing program for Android (8.2.0+).\n * Use 'external-payments' for Developer Provided Billing (Japan only, 8.3.0+).\n * Use 'user-choice-billing' for User Choice Billing (7.0+).\n * Use 'billing-choice' for Billing Choice (9.1.0+).\n */\n enableBillingProgramAndroid?: BillingProgramAndroid;\n /**\n * Select who renders the Billing Choice screen (9.1.0+). Must match the\n * choiceScreenType returned by isBillingProgramAvailableAndroid.\n */\n billingChoiceScreenTypeAndroid?: BillingChoiceScreenTypeAndroid;\n}\n\n// The store refused a new billing program because a purchase is in progress;\n// the live connection stays up.\nconst isRefusedRebuild = (error: unknown): boolean =>\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === ErrorCode.DeveloperError;\n\n// A fetched item replaces the one it updates, keeping the list's order.\nfunction mergeByKey<T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n): T[] {\n const merged = new Map(\n existingItems.map((item) => [getKey(item), item] as const),\n );\n newItems.forEach((item) => merged.set(getKey(item), item));\n return Array.from(merged.values());\n}\n\n// Store reads can resolve out of order. A result publishes only when no newer\n// read has published, so a failed newer read lets an older result through,\n// and a purchase makes every read that started before it stale.\ninterface ReadOrder {\n started: number;\n published: number;\n}\nconst startRead = (order: ReadOrder): number => ++order.started;\nconst claimPublish = (order: ReadOrder, read: number): boolean => {\n if (read <= order.published) return false;\n order.published = read;\n return true;\n};\nconst invalidateReads = (order: ReadOrder): void => {\n order.published = ++order.started;\n};\n\n/**\n * React Hook for managing In-App Purchases. Mounted hooks share one store\n * connection, which ends when the last of them unmounts.\n * See documentation at https://openiap.dev/docs/setup/expo#useIAP-hook\n */\nexport function useIAP(options?: UseIAPOptions): UseIap {\n const [connected, setConnected] = useState<boolean>(false);\n const [products, setProducts] = useState<Product[]>([]);\n const [subscriptions, setSubscriptions] = useState<ProductSubscription[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>([]);\n const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();\n const [activeSubscriptions, setActiveSubscriptions] = useState<\n ActiveSubscription[]\n >([]);\n\n const optionsRef = useRef<UseIAPOptions | undefined>(options);\n const connectedRef = useRef<boolean>(false);\n const isMountedRef = useRef<boolean>(false);\n const initializationGenerationRef = useRef(0);\n const startedInitializationGenerationRef = useRef(0);\n const availablePurchasesReads = useRef<ReadOrder>({started: 0, published: 0});\n const activeSubscriptionsReads = useRef<ReadOrder>({\n started: 0,\n published: 0,\n });\n\n // Before any effect runs, so a purchase never reaches a stale callback.\n useLayoutEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n connectedRef.current = connected;\n }, [connected]);\n\n const subscriptionsRef = useRef<{\n purchaseUpdate?: EventSubscription;\n purchaseError?: EventSubscription;\n promotedProductIOS?: EventSubscription;\n userChoiceBillingAndroid?: EventSubscription;\n developerProvidedBillingAndroid?: EventSubscription;\n subscriptionBillingIssue?: EventSubscription;\n }>({});\n\n const subscriptionsRefState = useRef<ProductSubscription[]>([]);\n\n useEffect(() => {\n subscriptionsRefState.current = subscriptions;\n }, [subscriptions]);\n\n const normalizeProductQueryType = useCallback(\n (type?: ProductTypeInput): ProductQueryType => {\n if (!type || type === 'in-app') {\n return 'in-app';\n }\n return type;\n },\n [],\n );\n\n const canonicalProductType = useCallback(\n (value?: string): ProductQueryType => {\n if (!value) {\n return 'in-app';\n }\n\n const normalized = value.trim().toLowerCase().replace(/[_-]/g, '');\n return normalized === 'subs' ? 'subs' : 'in-app';\n },\n [],\n );\n\n const toPurchaseInput = useCallback(\n (purchase: Purchase): PurchaseInput => ({\n ...purchase,\n ids: purchase.ids ?? undefined,\n }),\n [],\n );\n\n const invokeOnError = useCallback((error: unknown) => {\n if (isMountedRef.current && optionsRef.current?.onError) {\n optionsRef.current.onError(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }, []);\n\n /**\n * Retrieve products or subscriptions from the store by SKU.\n *\n * @param params `ProductRequest` — `skus` (string[]) and optional `type`\n * (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).\n * @returns Promise that resolves when the request is dispatched; results land in the\n * hook's reactive `products` / `subscriptions` state.\n * @throws When the store rejects the request (empty `skus`, not connected,\n * network/store error). Unknown SKUs are omitted from the result, not thrown.\n *\n * @example\n * ```ts\n * const { fetchProducts, products } = useIAP();\n * await fetchProducts({\n * skus: ['com.app.coins_100', 'com.app.premium'],\n * type: 'in-app',\n * });\n * ```\n *\n * @remarks Promise-based, unlike the event-based `request*` APIs such as `requestPurchase`.\n *\n * @see {@link https://openiap.dev/docs/apis/fetch-products}\n */\n const fetchProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: ProductTypeInput;\n }): Promise<void> => {\n try {\n const queryType = normalizeProductQueryType(params.type);\n const request: ProductRequest = {skus: params.skus, type: queryType};\n const result = await fetchProducts(request);\n const items = (result ?? []) as (Product | ProductSubscription)[];\n\n ExpoIapConsole.debug('Fetched products:', items);\n\n if (queryType === 'subs') {\n const subscriptionsResult = items as ProductSubscription[];\n setSubscriptions((prevSubscriptions) =>\n mergeByKey(\n prevSubscriptions,\n subscriptionsResult,\n (subscription) => subscription.id,\n ),\n );\n } else if (queryType === 'in-app') {\n const productsResult = items as Product[];\n setProducts((prevProducts) =>\n mergeByKey(prevProducts, productsResult, (product) => product.id),\n );\n } else {\n const productItems = items.filter(\n (item) => canonicalProductType(item.type as string) === 'in-app',\n ) as Product[];\n\n const subscriptionItems = items.filter(\n (item) => canonicalProductType(item.type as string) === 'subs',\n ) as ProductSubscription[];\n\n setProducts((prevProducts) =>\n mergeByKey(prevProducts, productItems, (product) => product.id),\n );\n\n setSubscriptions((prevSubscriptions) =>\n mergeByKey(\n prevSubscriptions,\n subscriptionItems,\n (subscription) => subscription.id,\n ),\n );\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching products:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [canonicalProductType, invokeOnError, normalizeProductQueryType],\n );\n\n /**\n * List the user's unfinished purchases: non-consumables, active subscriptions,\n * and pending transactions.\n *\n * @param options Optional `PurchaseOptions`. iOS-only flags:\n * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.\n * @returns Promise that resolves when the request is dispatched; results land in the\n * hook's reactive `availablePurchases` state.\n * @throws When the platform query fails.\n *\n * @example\n * ```ts\n * const { getAvailablePurchases, availablePurchases } = useIAP();\n * await getAvailablePurchases();\n * for (const p of availablePurchases) {\n * if (await verifyOnServer(p)) await finishTransaction({ purchase: p, isConsumable: false });\n * }\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/get-available-purchases}\n */\n const getAvailablePurchasesInternal = useCallback(\n async (options?: PurchaseOptions): Promise<void> => {\n const read = startRead(availablePurchasesReads.current);\n try {\n const result = await getAvailablePurchases({\n alsoPublishToEventListenerIOS:\n options?.alsoPublishToEventListenerIOS ?? false,\n onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,\n includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,\n });\n if (claimPublish(availablePurchasesReads.current, read)) {\n setAvailablePurchases(result);\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching available purchases:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Get details of all currently active subscriptions.\n *\n * @see {@link https://openiap.dev/docs/apis/get-active-subscriptions}\n */\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<void> => {\n const read = startRead(activeSubscriptionsReads.current);\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n if (claimPublish(activeSubscriptionsReads.current, read)) {\n setActiveSubscriptions(result);\n }\n } catch (error) {\n ExpoIapConsole.error('Error getting active subscriptions:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Check whether the user has any active subscription.\n *\n * @see {@link https://openiap.dev/docs/apis/has-active-subscriptions}\n */\n const hasActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<boolean> => {\n try {\n return await hasActiveSubscriptions(subscriptionIds);\n } catch (error) {\n ExpoIapConsole.error('Error checking active subscriptions:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Complete a purchase transaction. Call after server-side verification to remove it\n * from the queue.\n *\n * @param args.purchase The `Purchase` to finalize.\n * @param args.isConsumable `true` for consumables (consumes the token so the SKU can be\n * re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.\n * @returns Promise that resolves once the platform finalizes the transaction.\n * @throws When the platform finalize call fails.\n *\n * @example\n * ```ts\n * // Inside purchaseUpdatedListener:\n * if (await verifyOnServer(purchase)) {\n * await finishTransaction({ purchase, isConsumable: false });\n * }\n * ```\n *\n * @remarks Android purchases must be finalized within 3 days or Google\n * auto-refunds. iOS unfinished transactions replay on every app launch.\n *\n * @see {@link https://openiap.dev/docs/apis/finish-transaction}\n */\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }): Promise<void> => {\n await finishTransactionInternal({\n purchase: toPurchaseInput(purchase),\n isConsumable,\n });\n },\n [toPurchaseInput],\n );\n\n // Replaces the reads a purchase invalidated; a known subscription also\n // refreshes its catalog entry first.\n const refreshAfterPurchase = useCallback(\n async (productId: string) => {\n const generation = initializationGenerationRef.current;\n const isCurrent = (): boolean =>\n isMountedRef.current &&\n initializationGenerationRef.current === generation;\n const ownership = [\n getAvailablePurchasesInternal,\n getActiveSubscriptionsInternal,\n ];\n const refreshes = subscriptionsRefState.current.some(\n (sub) => sub.id === productId,\n )\n ? [\n () => fetchProductsInternal({skus: [productId], type: 'subs'}),\n ...ownership,\n ]\n : ownership;\n for (const refresh of refreshes) {\n if (!isCurrent()) return;\n try {\n await refresh();\n } catch (error) {\n if (isCurrent()) {\n ExpoIapConsole.warn('Failed to refresh after a purchase:', error);\n }\n }\n }\n },\n [\n fetchProductsInternal,\n getAvailablePurchasesInternal,\n getActiveSubscriptionsInternal,\n ],\n );\n\n /**\n * Restore non-consumable and active subscription purchases. With\n * `purchaseFlow`, confirms every owned purchase through the flow instead of\n * the provider's restore, so iOS asks for no App Store sign-in, and rejects\n * when a confirmation fails.\n *\n * @see {@link https://openiap.dev/docs/apis/restore-purchases}\n */\n const restorePurchasesInternal = useCallback(\n async (options?: PurchaseOptions): Promise<void> => {\n try {\n const flow = optionsRef.current?.purchaseFlow;\n // The provider's restore adds an iOS sign-in and Horizon redeliveries;\n // the flow reads the store's history itself.\n if (flow) {\n const outcomes = await flow.recoverPurchases({includeFinished: true});\n // A failed confirmation fails the restore; its purchase stays\n // unfinished, so the next restore retries it.\n for (const {status} of outcomes) {\n if (status.status === 'failed') throw status.error;\n }\n } else {\n await restorePurchasesNative();\n }\n\n const read = startRead(availablePurchasesReads.current);\n const purchases = await getAvailablePurchases({\n alsoPublishToEventListenerIOS:\n options?.alsoPublishToEventListenerIOS ?? false,\n onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,\n includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,\n });\n if (claimPublish(availablePurchasesReads.current, read)) {\n setAvailablePurchases(purchases);\n }\n } catch (error) {\n ExpoIapConsole.warn('Failed to restore purchases:', error);\n invokeOnError(error);\n throw error;\n }\n },\n [invokeOnError],\n );\n\n /**\n * Verify a purchase against your own backend (returns isValid + raw store metadata).\n *\n * @see {@link https://openiap.dev/docs/features/validation#verify-purchase}\n */\n const verifyPurchase = useCallback(async (props: VerifyPurchaseProps) => {\n return verifyPurchaseInternal(props);\n }, []);\n\n /**\n * Verify via a managed provider; `iapkit` (IAPKit) is the only one.\n *\n * @see {@link https://openiap.dev/docs/features/validation#verify-purchase-with-provider}\n */\n const verifyPurchaseWithProvider = useCallback(\n async (props: VerifyPurchaseWithProviderProps) => {\n return verifyPurchaseWithProviderInternal(props);\n },\n [],\n );\n\n const buildConnectionConfig = useCallback(():\n | InitConnectionConfig\n | undefined => {\n if (optionsRef.current?.enableBillingProgramAndroid) {\n return {\n enableBillingProgramAndroid:\n optionsRef.current.enableBillingProgramAndroid,\n ...(optionsRef.current.billingChoiceScreenTypeAndroid\n ? {\n billingChoiceScreenTypeAndroid:\n optionsRef.current.billingChoiceScreenTypeAndroid,\n }\n : {}),\n };\n }\n\n return undefined;\n }, []);\n\n const handlePurchaseUpdate = useCallback(\n async (purchase: Purchase): Promise<void> => {\n // Before the callback, which may read again: a read that started before\n // this purchase is stale.\n invalidateReads(availablePurchasesReads.current);\n invalidateReads(activeSubscriptionsReads.current);\n // Deliver first so a store refresh cannot delay finishing the transaction.\n try {\n const callbackResult: unknown =\n optionsRef.current?.onPurchaseSuccess?.(purchase);\n Promise.resolve(callbackResult).catch((error: unknown) => {\n ExpoIapConsole.error('[useIAP] onPurchaseSuccess failed:', error);\n });\n } catch (error) {\n ExpoIapConsole.error('[useIAP] onPurchaseSuccess failed:', error);\n }\n\n // With a purchase flow, its outcome refreshes once the purchase is\n // finished instead.\n if (!optionsRef.current?.purchaseFlow) {\n await refreshAfterPurchase(purchase.productId);\n }\n },\n [refreshAfterPurchase],\n );\n\n // Registers only missing listeners, so reconnect can restore removed ones.\n const registerListeners = useCallback(() => {\n const current = subscriptionsRef.current;\n if (!current.purchaseUpdate) {\n current.purchaseUpdate = purchaseUpdatedListener(\n handlePurchaseUpdate,\n optionsRef.current?.purchaseUpdatedListenerOptions,\n );\n }\n\n if (!current.purchaseError) {\n current.purchaseError = purchaseErrorListener((error: PurchaseError) => {\n if (!connectedRef.current && error.code === ErrorCode.InitConnection) {\n return; // Ignore initialization error before connected\n }\n if (\n error.code !== ErrorCode.AlreadyOwned &&\n !isUserCancelledError(error) &&\n !isRecoverableError(error)\n ) {\n ExpoIapConsole.warn(\n '[useIAP] Purchase error:',\n getUserFriendlyErrorMessage(error),\n );\n }\n optionsRef.current?.onPurchaseError?.(error);\n });\n }\n\n // Android billing callbacks are read at event time, so they may be set after mount.\n if (Platform.OS === 'android' && !current.userChoiceBillingAndroid) {\n current.userChoiceBillingAndroid = userChoiceBillingListenerAndroid(\n (details) => {\n optionsRef.current?.onUserChoiceBillingAndroid?.(details);\n },\n );\n }\n\n if (Platform.OS === 'android' && !current.developerProvidedBillingAndroid) {\n current.developerProvidedBillingAndroid =\n developerProvidedBillingListenerAndroid((details) => {\n optionsRef.current?.onDeveloperProvidedBillingAndroid?.(details);\n });\n }\n\n if (!current.subscriptionBillingIssue) {\n current.subscriptionBillingIssue = subscriptionBillingIssueListener(\n (purchase) => {\n optionsRef.current?.onSubscriptionBillingIssue?.(purchase);\n },\n );\n }\n\n if (Platform.OS === 'ios' && !current.promotedProductIOS) {\n current.promotedProductIOS = promotedProductListenerIOS(\n (product: Product) => {\n setPromotedProductIOS(product);\n optionsRef.current?.onPromotedProductIOS?.(product);\n },\n );\n }\n }, [handlePurchaseUpdate]);\n\n /**\n * Initiate a purchase or subscription flow. The result arrives through\n * `purchaseUpdatedListener` / `purchaseErrorListener`, not the return value.\n *\n * @param props `RequestPurchaseProps`, discriminated by `type`:\n * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).\n * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.\n * @returns Promise that resolves when the request is dispatched; the actual purchase\n * outcome lands in the hook's `onPurchaseSuccess` / `onPurchaseError` callbacks.\n * @throws Synchronous rejection from the store (e.g. `ErrorCode.NotPrepared`, validation failure).\n *\n * @example\n * ```ts\n * await requestPurchase({\n * request: {\n * apple: { sku: 'com.app.premium' },\n * google: { skus: ['com.app.premium'] },\n * },\n * type: 'in-app',\n * });\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/request-purchase}\n */\n const requestPurchase = useCallback(\n (requestObj: MutationRequestPurchaseArgs) => {\n // A failed hook init removes the purchase listener; restore it before buying.\n if (isMountedRef.current) {\n registerListeners();\n }\n return requestPurchaseInternal(requestObj);\n },\n [registerListeners],\n );\n\n // Purchase-error listening stays on so later retries still report errors.\n const removePurchaseListeners = useCallback(() => {\n subscriptionsRef.current.purchaseUpdate?.remove();\n subscriptionsRef.current.promotedProductIOS?.remove();\n subscriptionsRef.current.purchaseUpdate = undefined;\n subscriptionsRef.current.promotedProductIOS = undefined;\n }, []);\n\n const cleanupListeners = useCallback(() => {\n const current = subscriptionsRef.current;\n current.purchaseUpdate?.remove();\n current.purchaseError?.remove();\n current.promotedProductIOS?.remove();\n current.userChoiceBillingAndroid?.remove();\n current.developerProvidedBillingAndroid?.remove();\n current.subscriptionBillingIssue?.remove();\n subscriptionsRef.current = {};\n }, []);\n\n const initIapWithSubscriptions = useCallback(\n async (generation: number): Promise<void> => {\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n return;\n }\n startedInitializationGenerationRef.current = generation;\n connectionOwnerCount += 1;\n\n // Register listeners before initConnection; events can fire as soon as it connects.\n registerListeners();\n\n const config = buildConnectionConfig();\n\n try {\n const result = await initConnection(config);\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n if (startedInitializationGenerationRef.current === generation) {\n startedInitializationGenerationRef.current = 0;\n releaseConnection();\n }\n return;\n }\n setConnected(result);\n if (!result) {\n ExpoIapConsole.warn(\n '[useIAP] Connection failed, cleaning up listeners...',\n );\n removePurchaseListeners();\n }\n } catch (error) {\n if (\n !isMountedRef.current ||\n initializationGenerationRef.current !== generation\n ) {\n return;\n }\n invokeOnError(error);\n if (isRefusedRebuild(error)) {\n setConnected(true);\n return;\n }\n ExpoIapConsole.error('initConnection failed:', error);\n removePurchaseListeners();\n }\n },\n [\n buildConnectionConfig,\n registerListeners,\n removePurchaseListeners,\n invokeOnError,\n ],\n );\n\n const reconnect = useCallback(async (): Promise<boolean> => {\n const config = buildConnectionConfig();\n\n try {\n const result = await initConnection(config);\n setConnected(result);\n\n if (result) {\n registerListeners();\n }\n\n return result;\n } catch (error) {\n if (!isRefusedRebuild(error)) {\n ExpoIapConsole.error('[useIAP] reconnect failed:', error);\n }\n invokeOnError(error);\n return false;\n }\n }, [buildConnectionConfig, registerListeners, invokeOnError]);\n\n const purchaseFlow = options?.purchaseFlow;\n useEffect(\n () =>\n purchaseFlow?.subscribe((outcome) => {\n // Reads that started before the purchase settled are stale.\n invalidateReads(availablePurchasesReads.current);\n invalidateReads(activeSubscriptionsReads.current);\n try {\n optionsRef.current?.onPurchaseFlowOutcome?.(outcome);\n } catch (error) {\n ExpoIapConsole.error('[useIAP] onPurchaseFlowOutcome failed:', error);\n }\n void refreshAfterPurchase(outcome.purchase.productId);\n }),\n [purchaseFlow, refreshAfterPurchase],\n );\n\n // Once connected, and again for a new account's flow.\n useEffect(() => {\n if (!connected || !purchaseFlow) return;\n purchaseFlow.recoverPurchases().catch((error: unknown) => {\n ExpoIapConsole.warn('[useIAP] purchase recovery failed:', error);\n invokeOnError(error);\n });\n }, [connected, purchaseFlow, invokeOnError]);\n\n useEffect(() => {\n const generation = ++initializationGenerationRef.current;\n isMountedRef.current = true;\n void Promise.resolve().then(() => initIapWithSubscriptions(generation));\n\n return () => {\n isMountedRef.current = false;\n cleanupListeners();\n if (startedInitializationGenerationRef.current === generation) {\n startedInitializationGenerationRef.current = 0;\n releaseConnection();\n }\n setConnected(false);\n };\n }, [initIapWithSubscriptions, cleanupListeners]);\n\n return {\n connected,\n products,\n subscriptions,\n finishTransaction,\n availablePurchases,\n promotedProductIOS,\n activeSubscriptions,\n getAvailablePurchases: getAvailablePurchasesInternal,\n fetchProducts: fetchProductsInternal,\n requestPurchase,\n verifyPurchase,\n verifyPurchaseWithProvider,\n restorePurchases: restorePurchasesInternal,\n getPromotedProductIOS,\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n reconnect,\n getBillingChoiceInfoAndroid,\n isBillingProgramAvailableAndroid,\n createBillingProgramReportingDetailsAndroid,\n launchExternalLinkAndroid,\n showBillingProgramInformationDialogAndroid,\n showAlternativeBillingOnlyInformationDialogAndroid,\n showInAppMessagesAndroid,\n // Offer code redemption\n openRedeemOfferCode,\n };\n}\n"]}
package/bun.lock CHANGED
@@ -39,7 +39,7 @@
39
39
  },
40
40
  },
41
41
  "overrides": {
42
- "node-forge": "1.4.2",
42
+ "node-forge": "1.4.3",
43
43
  "shell-quote": "1.12.0",
44
44
  "uuid": "11.1.1",
45
45
  "zod": "4.6.7",
@@ -1403,7 +1403,7 @@
1403
1403
 
1404
1404
  "node-exports-info": ["node-exports-info@1.6.2", "", { "dependencies": { "array.prototype.flatmap": "^1.3.3", "es-errors": "^1.3.0", "object.entries": "^1.1.9", "semver": "^6.3.1" } }, "sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag=="],
1405
1405
 
1406
- "node-forge": ["node-forge@1.4.2", "", {}, "sha512-rRtAR5XLJ8gCKd9du4qrKAsgCG1ObGP4gLeNJMa4vYSeq4bmBMOJk5IHkrviBV0q7uoAJlVd8HEQYQSVUb4FGQ=="],
1406
+ "node-forge": ["node-forge@1.4.3", "", {}, "sha512-P6wzfh6t70avmV8FrVEAd/36sOPJQ+hkaJVX1Laap9J/77m7M0eyozDvc8SwnDf4P7MP94gwbAAo0rg3YVXT+g=="],
1407
1407
 
1408
1408
  "node-int64": ["node-int64@0.4.0", "", {}, "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw=="],
1409
1409
 
@@ -481,7 +481,7 @@ public final class ExpoIapModule: Module {
481
481
  guard let type = ExternalPurchaseCustomLinkTokenTypeIOS(rawValue: tokenType) else {
482
482
  throw PurchaseError.make(
483
483
  code: .developerError,
484
- message: "Invalid token type: \(tokenType). Must be 'acquisition' or 'services'"
484
+ message: "Invalid token type: \(tokenType)"
485
485
  )
486
486
  }
487
487
  let result = try await OpenIapModule.shared.getExternalPurchaseCustomLinkTokenIOS(type)
@@ -1,6 +1,6 @@
1
1
  {
2
- "clientProtocol": "1.3.2",
3
- "google": "4.0.9",
4
- "apple": "4.0.8",
2
+ "clientProtocol": "1.4.0",
3
+ "google": "4.1.0",
4
+ "apple": "4.1.0",
5
5
  "plugin": "0.1.1"
6
6
  }
package/osv-scanner.toml CHANGED
@@ -1,14 +1,14 @@
1
1
  [[IgnoredVulns]]
2
2
  id = "GHSA-gcqx-w48m-w2h4"
3
- ignoreUntil = 2026-11-04
4
- reason = "No patched deepmerge release exists. This lock reaches it only through Jest, Expo configuration, or React Native/Kepler CLI configuration used for trusted local builds and tests; mobile entry points and the published SDK runtime do not import those tools. Do not load untrusted project configuration. Revisit the upstream fix before expiry: https://github.com/advisories/GHSA-gcqx-w48m-w2h4."
3
+ ignoreUntil = 2026-12-04
4
+ reason = "No patched deepmerge release exists. This lock reaches it only through Jest, Expo configuration, or React Native/Kepler CLI configuration used for trusted local builds and tests; mobile entry points and the published SDK runtime do not import those tools. Do not load untrusted project configuration. Revisit the upstream fix before expiry: https://github.com/advisories/GHSA-gcqx-w48m-w2h4. Rechecked 2026-11-04: still no patched release."
5
5
 
6
6
  [[IgnoredVulns]]
7
7
  id = "GHSA-3g3m-2fjr-6pw4"
8
- ignoreUntil = 2026-11-04
9
- reason = "The fix is glob 14.0.2, outside Expo 57 dependency ranges. Expo uses glob for trusted local project discovery and builds, including early cancellation after the first match; cancellation must not be treated as an enforced traversal budget. The published expo-iap mobile entry points do not import glob. Do not run this tooling on untrusted directory trees or expose it as a public request handler. Recheck compatible upstream upgrades before expiry: https://github.com/advisories/GHSA-3g3m-2fjr-6pw4."
8
+ ignoreUntil = 2026-12-04
9
+ reason = "The fix is glob 14.0.2, outside Expo 57 dependency ranges. Expo uses glob for trusted local project discovery and builds, including early cancellation after the first match; cancellation must not be treated as an enforced traversal budget. The published expo-iap mobile entry points do not import glob. Do not run this tooling on untrusted directory trees or expose it as a public request handler. Recheck compatible upstream upgrades before expiry: https://github.com/advisories/GHSA-3g3m-2fjr-6pw4. Rechecked 2026-11-04: still no fix inside these dependency ranges."
10
10
 
11
11
  [[IgnoredVulns]]
12
12
  id = "GHSA-g3hv-75wg-m249"
13
- ignoreUntil = 2026-11-04
14
- reason = "The fix is minimatch 11.0.1, outside the Expo 57, Jest and ESLint dependency ranges. These copies serve local project discovery, fingerprinting, lint and coverage; the published expo-iap mobile entry points do not import them. Patterns come from the trusted checkout and build configuration; do not load untrusted project patterns or expose this tooling as a public request handler. Recheck compatible upstream upgrades before expiry: https://github.com/advisories/GHSA-g3hv-75wg-m249."
13
+ ignoreUntil = 2026-12-04
14
+ reason = "The fix is minimatch 11.0.1, outside the Expo 57, Jest and ESLint dependency ranges. These copies serve local project discovery, fingerprinting, lint and coverage; the published expo-iap mobile entry points do not import them. Patterns come from the trusted checkout and build configuration; do not load untrusted project patterns or expose this tooling as a public request handler. Recheck compatible upstream upgrades before expiry: https://github.com/advisories/GHSA-g3hv-75wg-m249. Rechecked 2026-11-04: still no fix inside these dependency ranges."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "6.4.2",
3
+ "version": "6.4.4",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -104,7 +104,7 @@
104
104
  "zod": "4.6.7",
105
105
  "uuid": "11.1.1",
106
106
  "shell-quote": "1.12.0",
107
- "node-forge": "1.4.2"
107
+ "node-forge": "1.4.3"
108
108
  },
109
109
  "expo": {
110
110
  "plugin": "./app.plugin.js"
@@ -74,6 +74,7 @@ export type ExpoIapNativeModule = NativeEventModule &
74
74
  | 'presentExternalPurchaseNoticeSheetIOS'
75
75
  | 'showBillingProgramInformationDialogAndroid'
76
76
  | 'showExternalPurchaseCustomLinkNoticeIOS'
77
+ | 'showAlternativeBillingOnlyInformationDialogAndroid'
77
78
  | 'showInAppMessagesAndroid'
78
79
  | 'syncIOS'
79
80
  | 'verifyPurchase'
@@ -348,6 +348,11 @@ export const createBillingProgramReportingDetailsAndroid: MutationField<
348
348
  export const showBillingProgramInformationDialogAndroid: MutationField<
349
349
  'showBillingProgramInformationDialogAndroid'
350
350
  > = async () => unsupported('showBillingProgramInformationDialogAndroid');
351
+ export const showAlternativeBillingOnlyInformationDialogAndroid: MutationField<
352
+ 'showAlternativeBillingOnlyInformationDialogAndroid'
353
+ > = async () =>
354
+ unsupported('showAlternativeBillingOnlyInformationDialogAndroid');
355
+
351
356
  export const showInAppMessagesAndroid: MutationField<
352
357
  'showInAppMessagesAndroid'
353
358
  > = async () => unsupported('showInAppMessagesAndroid');
package/src/index.ts CHANGED
@@ -1509,8 +1509,8 @@ export function confirmWithIapkit(
1509
1509
 
1510
1510
  /**
1511
1511
  * Confirms App Store purchases on the device, for apps with neither a backend
1512
- * nor IAPKit: StoreKit must still list the transaction as unfinished and
1513
- * valid. Credit consumables in `grant`.
1512
+ * nor IAPKit: StoreKit must list the transaction as unfinished, or for a
1513
+ * restore in its verified history, and valid. Credit consumables in `grant`.
1514
1514
  */
1515
1515
  export function confirmOnDeviceIOS(
1516
1516
  options: {
@@ -1523,7 +1523,11 @@ export function confirmOnDeviceIOS(
1523
1523
  ): PurchaseFlowOptions<Purchase>['confirmWithBackend'] {
1524
1524
  return createDeviceConfirmationIOS<Purchase>(
1525
1525
  () => getPendingTransactionsIOS(),
1526
- options,
1526
+ {
1527
+ ...options,
1528
+ getTransactionHistoryIOS: () =>
1529
+ getAvailablePurchases({onlyIncludeActiveItemsIOS: false}),
1530
+ },
1527
1531
  );
1528
1532
  }
1529
1533
 
@@ -314,6 +314,14 @@ export const showBillingProgramInformationDialogAndroid: MutationField<
314
314
  });
315
315
  };
316
316
 
317
+ /** Show the mandatory Google Play Alternative Billing Only notice before checkout. */
318
+ export const showAlternativeBillingOnlyInformationDialogAndroid: MutationField<
319
+ 'showAlternativeBillingOnlyInformationDialogAndroid'
320
+ > = async () => {
321
+ requireAndroidPlatform('showAlternativeBillingOnlyInformationDialogAndroid');
322
+ return ExpoIapModule.showAlternativeBillingOnlyInformationDialogAndroid();
323
+ };
324
+
317
325
  /**
318
326
  * Show Play Billing in-app messages, such as transactional subscription updates.
319
327
  * Available in Google Play Billing Library 4.1.0+.
@@ -467,7 +467,7 @@ export const isEligibleForExternalPurchaseCustomLinkIOS: QueryField<
467
467
  * Get external purchase token for reporting to Apple (iOS 18.1+).
468
468
  * Use this token with Apple's External Purchase Server API to report transactions.
469
469
  *
470
- * @param tokenType - Token type: 'acquisition' (new customers) or 'services' (existing customers)
470
+ * @param tokenType - Reporting token type for the app's storefront.
471
471
  * @returns Promise resolving to the token result with token string or error
472
472
  * @platform iOS
473
473
  * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
@@ -480,7 +480,7 @@ export const getExternalPurchaseCustomLinkTokenIOS: QueryField<
480
480
  requireIosPlatform('getExternalPurchaseCustomLinkTokenIOS');
481
481
  if (!tokenType) {
482
482
  throw new Error(
483
- "getExternalPurchaseCustomLinkTokenIOS requires a tokenType ('acquisition' or 'services')",
483
+ 'getExternalPurchaseCustomLinkTokenIOS requires a tokenType',
484
484
  );
485
485
  }
486
486
  const result = await callNativeIOS(() =>
@@ -66,6 +66,8 @@ export interface IapkitVerificationResult {
66
66
  }
67
67
 
68
68
  const IAPKIT_UNKNOWN_RETRY_MS = 30_000;
69
+ // An expired App Store receipt may still be in billing grace; check it again.
70
+ const DEVICE_EXPIRED_RETRY_MS = 30_000;
69
71
 
70
72
  /**
71
73
  * @internal Use the SDK's confirmWithIapkit.
@@ -100,14 +102,22 @@ export function createIapkitConfirmation<P extends PurchaseFlowPurchase>(
100
102
  * @internal Use the SDK's confirmOnDeviceIOS.
101
103
  * The SDK's `confirmOnDeviceIOS`, given its `getPendingTransactionsIOS`, for an
102
104
  * app with neither a backend nor IAPKit. StoreKit verified the transaction if
103
- * it is still unfinished, unrevoked, not upgraded, unexpired, and from the
104
- * purchase's environment; `grant` then runs before the flow finishes it.
105
+ * it lists it as unfinished, or, for a purchase the flow already finished, in
106
+ * `getTransactionHistoryIOS`, from the purchase's environment. A revoked or
107
+ * upgraded one is `invalid`, and an expired one `verification_delayed`, since
108
+ * billing grace can still cover it; `grant` runs before an unfinished one is
109
+ * finished, and again for a finished non-consumable a restore reads.
105
110
  */
106
111
  export function createDeviceConfirmationIOS<P extends PurchaseFlowPurchase>(
107
112
  getPendingTransactionsIOS: () => Promise<P[]>,
108
113
  options: {
109
114
  /** Required for consumables; credit each purchase.id only once. */
110
115
  grant?: (purchase: P, context: { isConsumable: boolean }) => Promise<void>;
116
+ /**
117
+ * StoreKit's verified history, such as `getAvailablePurchases` with
118
+ * `onlyIncludeActiveItemsIOS: false`; without it a finished purchase throws.
119
+ */
120
+ getTransactionHistoryIOS?: () => Promise<P[]>;
111
121
  } = {},
112
122
  ): PurchaseFlowOptions<P>["confirmWithBackend"] {
113
123
  return async (purchase, context) => {
@@ -121,29 +131,42 @@ export function createDeviceConfirmationIOS<P extends PurchaseFlowPurchase>(
121
131
  `Device confirmation covers App Store purchases, not ${purchase.storeId ?? purchase.store}`,
122
132
  );
123
133
  }
124
- const pending = await getPendingTransactionsIOS();
125
- // After the query: a transaction can expire while StoreKit answers.
126
- const now = Date.now();
127
- const verified = pending.some(
128
- (candidate) =>
129
- candidate.store === "apple" &&
130
- purchase.id !== "" &&
131
- candidate.id === purchase.id &&
132
- candidate.productId === purchase.productId &&
133
- candidate.revocationDateIOS == null &&
134
- candidate.isUpgradedIOS !== true &&
135
- (candidate.expirationDateIOS == null ||
136
- candidate.expirationDateIOS > now) &&
137
- (purchase.environmentIOS == null ||
138
- candidate.environmentIOS === purchase.environmentIOS),
139
- );
140
- if (!verified) {
134
+ const isSame = (candidate: P) =>
135
+ candidate.store === "apple" &&
136
+ purchase.id !== "" &&
137
+ candidate.id === purchase.id &&
138
+ candidate.productId === purchase.productId &&
139
+ (purchase.environmentIOS == null ||
140
+ candidate.environmentIOS === purchase.environmentIOS);
141
+ const pending = (await getPendingTransactionsIOS()).find(isSame);
142
+ const transaction =
143
+ pending ?? (await options.getTransactionHistoryIOS?.())?.find(isSame);
144
+ if (!transaction) {
141
145
  throw new Error(
142
- `StoreKit lists no valid unfinished transaction for ${purchase.productId}`,
146
+ `StoreKit lists no transaction for ${purchase.productId}`,
143
147
  );
144
148
  }
145
- await options.grant?.(purchase, context);
146
- return { status: "entitled", alreadyGranted: false };
149
+ if (transaction.revocationDateIOS != null) {
150
+ return { status: "invalid", reason: "revoked" };
151
+ }
152
+ if (transaction.isUpgradedIOS === true) {
153
+ return { status: "invalid", reason: "upgraded" };
154
+ }
155
+ // After the reads: a transaction can expire while StoreKit answers.
156
+ if (
157
+ transaction.expirationDateIOS != null &&
158
+ transaction.expirationDateIOS <= Date.now()
159
+ ) {
160
+ return {
161
+ status: "verification_delayed",
162
+ retryAfterMs: DEVICE_EXPIRED_RETRY_MS,
163
+ };
164
+ }
165
+ // A finished consumable was credited before it was consumed.
166
+ if (pending || !context.isConsumable) {
167
+ await options.grant?.(purchase, context);
168
+ }
169
+ return { status: "entitled", alreadyGranted: !pending };
147
170
  };
148
171
  }
149
172
 
package/src/types.ts CHANGED
@@ -191,7 +191,7 @@ export type BillingChoiceScreenTypeAndroid = 'unspecified' | 'developer-rendered
191
191
  * BILLING_CHOICE added in OpenIAP 2.1.0 / openiap-google 2.3.0
192
192
  * (requires Play Billing 9.1.0+).
193
193
  */
194
- export type BillingProgramAndroid = 'unspecified' | 'user-choice-billing' | 'external-content-link' | 'external-offer' | 'external-payments' | 'billing-choice';
194
+ export type BillingProgramAndroid = 'unspecified' | 'user-choice-billing' | 'external-content-link' | 'external-offer' | 'external-payments' | 'billing-choice' | 'alternative-billing-only';
195
195
 
196
196
  /**
197
197
  * Result of checking billing program availability (Android)
@@ -573,7 +573,7 @@ export interface ExternalPurchaseCustomLinkTokenResultIOS {
573
573
  * Used to request different types of external purchase tokens for reporting to Apple.
574
574
  * Reference: https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
575
575
  */
576
- export type ExternalPurchaseCustomLinkTokenTypeIOS = 'acquisition' | 'services';
576
+ export type ExternalPurchaseCustomLinkTokenTypeIOS = 'acquisition' | 'services' | 'in-app' | 'link-out';
577
577
 
578
578
  /** Result of presenting an external purchase link */
579
579
  export interface ExternalPurchaseLinkResultIOS {
@@ -699,6 +699,7 @@ export interface InitConnectionConfig {
699
699
  * - EXTERNAL_PAYMENTS: Developer provided billing, Japan only (8.3.0+)
700
700
  * - BILLING_CHOICE: Google-rendered or developer-rendered billing choice
701
701
  * (OpenIAP 2.1.0 / openiap-google 2.3.0; requires Play Billing 9.1.0+)
702
+ * - ALTERNATIVE_BILLING_ONLY: Exclusive Google Play connection for in-app alternative billing
702
703
  */
703
704
  enableBillingProgramAndroid?: (BillingProgramAndroid | null);
704
705
  }
@@ -789,6 +790,7 @@ export interface Mutation {
789
790
  * Returns external transaction token needed for reporting external transactions.
790
791
  * developerBillingType is optional. When program is BILLING_CHOICE and developerBillingType is omitted,
791
792
  * native Android defaults it to IN_APP.
793
+ * For ALTERNATIVE_BILLING_ONLY, call after the information dialog succeeds; developerBillingType is ignored.
792
794
  * The Billing Choice extension is available in OpenIAP 2.1.0 /
793
795
  * openiap-google 2.3.0 (requires Play Billing 9.1.0+).
794
796
  * Throws OpenIapError.NotPrepared if billing client not ready.
@@ -821,6 +823,7 @@ export interface Mutation {
821
823
  * Introduced in Google Play Billing Library 8.2.0. External Offer and External
822
824
  * Content Link integrations must use 8.2.1+ because 8.2.1 fixes this API.
823
825
  * Returns availability result with isAvailable flag.
826
+ * For ALTERNATIVE_BILLING_ONLY, connect with that program before checking.
824
827
  * Throws OpenIapError.NotPrepared if billing client not ready.
825
828
  * See: https://openiap.dev/docs/apis/android/is-billing-program-available-android
826
829
  */
@@ -869,6 +872,13 @@ export interface Mutation {
869
872
  * See: https://openiap.dev/docs/apis/restore-purchases
870
873
  */
871
874
  restorePurchases: Promise<void>;
875
+ /**
876
+ * Show the Google Play Alternative Billing Only information dialog before each checkout attempt.
877
+ * Continue only when responseCode is OK (0).
878
+ * See: https://openiap.dev/docs/features/external-purchase#alternative-billing-only
879
+ * Available in OpenIAP 1.4.0 / openiap-google 4.1.0.
880
+ */
881
+ showAlternativeBillingOnlyInformationDialogAndroid: Promise<BillingResultAndroid>;
872
882
  /**
873
883
  * Show Google's mandatory information dialog before a developer-rendered,
874
884
  * in-app Billing Choice screen.
@@ -2365,6 +2375,7 @@ export type MutationArgsMap = {
2365
2375
  presentExternalPurchaseNoticeSheetIOS: never;
2366
2376
  requestPurchase: MutationRequestPurchaseArgs;
2367
2377
  restorePurchases: never;
2378
+ showAlternativeBillingOnlyInformationDialogAndroid: never;
2368
2379
  showBillingProgramInformationDialogAndroid: MutationShowBillingProgramInformationDialogAndroidArgs;
2369
2380
  showExternalPurchaseCustomLinkNoticeIOS: MutationShowExternalPurchaseCustomLinkNoticeIosArgs;
2370
2381
  showInAppMessagesAndroid: MutationShowInAppMessagesAndroidArgs;
package/src/useIAP.ts CHANGED
@@ -35,6 +35,7 @@ import {
35
35
  createBillingProgramReportingDetailsAndroid,
36
36
  launchExternalLinkAndroid,
37
37
  showBillingProgramInformationDialogAndroid,
38
+ showAlternativeBillingOnlyInformationDialogAndroid,
38
39
  showInAppMessagesAndroid,
39
40
  } from './modules/android';
40
41
 
@@ -122,6 +123,7 @@ type UseIap = {
122
123
  createBillingProgramReportingDetailsAndroid: MutationField<'createBillingProgramReportingDetailsAndroid'>;
123
124
  launchExternalLinkAndroid: MutationField<'launchExternalLinkAndroid'>;
124
125
  showBillingProgramInformationDialogAndroid: MutationField<'showBillingProgramInformationDialogAndroid'>;
126
+ showAlternativeBillingOnlyInformationDialogAndroid: MutationField<'showAlternativeBillingOnlyInformationDialogAndroid'>;
125
127
  showInAppMessagesAndroid: MutationField<'showInAppMessagesAndroid'>;
126
128
  openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;
127
129
  };
@@ -542,17 +544,29 @@ export function useIAP(options?: UseIAPOptions): UseIap {
542
544
  );
543
545
 
544
546
  /**
545
- * Restore non-consumable and active subscription purchases.
547
+ * Restore non-consumable and active subscription purchases. With
548
+ * `purchaseFlow`, confirms every owned purchase through the flow instead of
549
+ * the provider's restore, so iOS asks for no App Store sign-in, and rejects
550
+ * when a confirmation fails.
546
551
  *
547
552
  * @see {@link https://openiap.dev/docs/apis/restore-purchases}
548
553
  */
549
554
  const restorePurchasesInternal = useCallback(
550
555
  async (options?: PurchaseOptions): Promise<void> => {
551
556
  try {
552
- await restorePurchasesNative();
553
- await optionsRef.current?.purchaseFlow?.recoverPurchases({
554
- includeFinished: true,
555
- });
557
+ const flow = optionsRef.current?.purchaseFlow;
558
+ // The provider's restore adds an iOS sign-in and Horizon redeliveries;
559
+ // the flow reads the store's history itself.
560
+ if (flow) {
561
+ const outcomes = await flow.recoverPurchases({includeFinished: true});
562
+ // A failed confirmation fails the restore; its purchase stays
563
+ // unfinished, so the next restore retries it.
564
+ for (const {status} of outcomes) {
565
+ if (status.status === 'failed') throw status.error;
566
+ }
567
+ } else {
568
+ await restorePurchasesNative();
569
+ }
556
570
 
557
571
  const read = startRead(availablePurchasesReads.current);
558
572
  const purchases = await getAvailablePurchases({
@@ -901,6 +915,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
901
915
  createBillingProgramReportingDetailsAndroid,
902
916
  launchExternalLinkAndroid,
903
917
  showBillingProgramInformationDialogAndroid,
918
+ showAlternativeBillingOnlyInformationDialogAndroid,
904
919
  showInAppMessagesAndroid,
905
920
  // Offer code redemption
906
921
  openRedeemOfferCode,