expo-iap 3.3.2 → 3.3.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.
- package/build/modules/android.d.ts +5 -5
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +1 -1
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +4 -1
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +5 -2
- package/build/modules/ios.js.map +1 -1
- package/build/types.d.ts +56 -2
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts +4 -0
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js.map +1 -1
- package/coverage/clover.xml +104 -101
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/index.html +18 -18
- package/coverage/lcov-report/src/index.html +14 -14
- package/coverage/lcov-report/src/index.ts.html +35 -35
- package/coverage/lcov-report/src/modules/android.ts.html +17 -29
- package/coverage/lcov-report/src/modules/index.html +8 -8
- package/coverage/lcov-report/src/modules/ios.ts.html +18 -12
- package/coverage/lcov-report/src/utils/debug.ts.html +1 -1
- package/coverage/lcov-report/src/utils/errorMapping.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov.info +169 -164
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/modules/android.ts +10 -14
- package/src/modules/ios.ts +8 -6
- package/src/types.ts +59 -2
- package/src/useIAP.ts +4 -0
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8CAA8C;AAC9C,yEAAyE;AACzE,+EAA+E;AA8K/E,MAAM,CAAN,IAAY,SAsCX;AAtCD,WAAY,SAAS;IACnB,yDAA4C,CAAA;IAC5C,2CAA8B,CAAA;IAC9B,iDAAoC,CAAA;IACpC,gFAAmE,CAAA;IACnE,uDAA0C,CAAA;IAC1C,mDAAsC,CAAA;IACtC,iDAAoC,CAAA;IACpC,+CAAkC,CAAA;IAClC,4CAA+B,CAAA;IAC/B,0DAA6C,CAAA;IAC7C,kDAAqC,CAAA;IACrC,+CAAkC,CAAA;IAClC,wCAA2B,CAAA;IAC3B,4CAA+B,CAAA;IAC/B,iDAAoC,CAAA;IACpC,2CAA8B,CAAA;IAC9B,mCAAsB,CAAA;IACtB,yCAA4B,CAAA;IAC5B,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;IAChC,wEAA2D,CAAA;IAC3D,qFAAwE,CAAA;IACxE,4EAA+D,CAAA;IAC/D,2CAA8B,CAAA;IAC9B,6CAAgC,CAAA;IAChC,iDAAoC,CAAA;IACpC,8DAAiD,CAAA;IACjD,yCAA4B,CAAA;IAC5B,yDAA4C,CAAA;IAC5C,2CAA8B,CAAA;IAC9B,0CAA6B,CAAA;IAC7B,oDAAuC,CAAA;IACvC,qCAAwB,CAAA;IACxB,0EAA6D,CAAA;IAC7D,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;IAChC,qCAAwB,CAAA;AAC1B,CAAC,EAtCW,SAAS,KAAT,SAAS,QAsCpB;AAimCD,mCAAmC","sourcesContent":["// ============================================================================\n// AUTO-GENERATED TYPES — DO NOT EDIT DIRECTLY\n// Run `bun run generate:types` after updating any *.graphql schema file.\n// ============================================================================\n\nexport interface ActiveSubscription {\n autoRenewingAndroid?: (boolean | null);\n basePlanIdAndroid?: (string | null);\n /**\n * The current plan identifier. This is:\n * - On Android: the basePlanId (e.g., \"premium\", \"premium-year\")\n * - On iOS: the productId (e.g., \"com.example.premium_monthly\", \"com.example.premium_yearly\")\n * This provides a unified way to identify which specific plan/tier the user is subscribed to.\n */\n currentPlanId?: (string | null);\n daysUntilExpirationIOS?: (number | null);\n environmentIOS?: (string | null);\n expirationDateIOS?: (number | null);\n isActive: boolean;\n productId: string;\n purchaseToken?: (string | null);\n /** Required for subscription upgrade/downgrade on Android */\n purchaseTokenAndroid?: (string | null);\n /**\n * Renewal information from StoreKit 2 (iOS only). Contains details about subscription renewal status,\n * pending upgrades/downgrades, and auto-renewal preferences.\n */\n renewalInfoIOS?: (RenewalInfoIOS | null);\n transactionDate: number;\n transactionId: string;\n /**\n * @deprecated iOS only - use daysUntilExpirationIOS instead.\n * Whether the subscription will expire soon (within 7 days).\n * Consider using daysUntilExpirationIOS for more precise control.\n */\n willExpireSoon?: (boolean | null);\n}\n\n/**\n * Alternative billing mode for Android\n * Controls which billing system is used\n */\nexport type AlternativeBillingModeAndroid = 'none' | 'user-choice' | 'alternative-only';\n\nexport interface AndroidSubscriptionOfferInput {\n /** Offer token */\n offerToken: string;\n /** Product SKU */\n sku: string;\n}\n\nexport interface AppTransaction {\n appId: number;\n appTransactionId?: (string | null);\n appVersion: string;\n appVersionId: number;\n bundleId: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n environment: string;\n originalAppVersion: string;\n originalPlatform?: (string | null);\n originalPurchaseDate: number;\n preorderDate?: (number | null);\n signedDate: number;\n}\n\n/**\n * Billing program types for external content links and external offers (Android)\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type BillingProgramAndroid = 'unspecified' | 'external-content-link' | 'external-offer';\n\n/**\n * Result of checking billing program availability (Android)\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface BillingProgramAvailabilityResultAndroid {\n /** The billing program that was checked */\n billingProgram: BillingProgramAndroid;\n /** Whether the billing program is available for the user */\n isAvailable: boolean;\n}\n\n/**\n * Reporting details for transactions made outside of Google Play Billing (Android)\n * Contains the external transaction token needed for reporting\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface BillingProgramReportingDetailsAndroid {\n /** The billing program that the reporting details are associated with */\n billingProgram: BillingProgramAndroid;\n /**\n * External transaction token used to report transactions made outside of Google Play Billing.\n * This token must be used when reporting the external transaction to Google.\n */\n externalTransactionToken: string;\n}\n\nexport interface DeepLinkOptions {\n /** Android package name to target (required on Android) */\n packageNameAndroid?: (string | null);\n /** Android SKU to open (required on Android) */\n skuAndroid?: (string | null);\n}\n\n/**\n * Discount amount details for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface DiscountAmountAndroid {\n /** Discount amount in micro-units (1,000,000 = 1 unit of currency) */\n discountAmountMicros: string;\n /** Formatted discount amount with currency sign (e.g., \"$4.99\") */\n formattedDiscountAmount: string;\n}\n\n/**\n * Discount display information for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface DiscountDisplayInfoAndroid {\n /**\n * Absolute discount amount details\n * Only returned for fixed amount discounts\n */\n discountAmount?: (DiscountAmountAndroid | null);\n /**\n * Percentage discount (e.g., 33 for 33% off)\n * Only returned for percentage-based discounts\n */\n percentageDiscount?: (number | null);\n}\n\nexport interface DiscountIOS {\n identifier: string;\n localizedPrice?: (string | null);\n numberOfPeriods: number;\n paymentMode: PaymentModeIOS;\n price: string;\n priceAmount: number;\n subscriptionPeriod: string;\n type: string;\n}\n\nexport interface DiscountOfferIOS {\n /** Discount identifier */\n identifier: string;\n /** Key identifier for validation */\n keyIdentifier: string;\n /** Cryptographic nonce */\n nonce: string;\n /** Signature for validation */\n signature: string;\n /** Timestamp of discount offer */\n timestamp: number;\n}\n\nexport interface DiscountOfferInputIOS {\n /** Discount identifier */\n identifier: string;\n /** Key identifier for validation */\n keyIdentifier: string;\n /** Cryptographic nonce */\n nonce: string;\n /** Signature for validation */\n signature: string;\n /** Timestamp of discount offer */\n timestamp: number;\n}\n\nexport interface EntitlementIOS {\n jsonRepresentation: string;\n sku: string;\n transactionId: string;\n}\n\nexport enum ErrorCode {\n ActivityUnavailable = 'activity-unavailable',\n AlreadyOwned = 'already-owned',\n AlreadyPrepared = 'already-prepared',\n BillingResponseJsonParseError = 'billing-response-json-parse-error',\n BillingUnavailable = 'billing-unavailable',\n ConnectionClosed = 'connection-closed',\n DeferredPayment = 'deferred-payment',\n DeveloperError = 'developer-error',\n EmptySkuList = 'empty-sku-list',\n FeatureNotSupported = 'feature-not-supported',\n IapNotAvailable = 'iap-not-available',\n InitConnection = 'init-connection',\n Interrupted = 'interrupted',\n ItemNotOwned = 'item-not-owned',\n ItemUnavailable = 'item-unavailable',\n NetworkError = 'network-error',\n NotEnded = 'not-ended',\n NotPrepared = 'not-prepared',\n Pending = 'pending',\n PurchaseError = 'purchase-error',\n PurchaseVerificationFailed = 'purchase-verification-failed',\n PurchaseVerificationFinishFailed = 'purchase-verification-finish-failed',\n PurchaseVerificationFinished = 'purchase-verification-finished',\n QueryProduct = 'query-product',\n ReceiptFailed = 'receipt-failed',\n ReceiptFinished = 'receipt-finished',\n ReceiptFinishedFailed = 'receipt-finished-failed',\n RemoteError = 'remote-error',\n ServiceDisconnected = 'service-disconnected',\n ServiceError = 'service-error',\n SkuNotFound = 'sku-not-found',\n SkuOfferMismatch = 'sku-offer-mismatch',\n SyncError = 'sync-error',\n TransactionValidationFailed = 'transaction-validation-failed',\n Unknown = 'unknown',\n UserCancelled = 'user-cancelled',\n UserError = 'user-error'\n}\n\n/**\n * Launch mode for external link flow (Android)\n * Determines how the external URL is launched\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type ExternalLinkLaunchModeAndroid = 'unspecified' | 'launch-in-external-browser-or-app' | 'caller-will-launch-link';\n\n/**\n * Link type for external link flow (Android)\n * Specifies the type of external link destination\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type ExternalLinkTypeAndroid = 'unspecified' | 'link-to-digital-content-offer' | 'link-to-app-download';\n\n/**\n * External offer availability result (Android)\n * @deprecated Use BillingProgramAvailabilityResultAndroid with isBillingProgramAvailableAsync instead\n * Available in Google Play Billing Library 6.2.0+, deprecated in 8.2.0\n */\nexport interface ExternalOfferAvailabilityResultAndroid {\n /** Whether external offers are available for the user */\n isAvailable: boolean;\n}\n\n/**\n * External offer reporting details (Android)\n * @deprecated Use BillingProgramReportingDetailsAndroid with createBillingProgramReportingDetailsAsync instead\n * Available in Google Play Billing Library 6.2.0+, deprecated in 8.2.0\n */\nexport interface ExternalOfferReportingDetailsAndroid {\n /** External transaction token for reporting external offer transactions */\n externalTransactionToken: string;\n}\n\n/** Result of presenting an external purchase link (iOS 18.2+) */\nexport interface ExternalPurchaseLinkResultIOS {\n /** Optional error message if the presentation failed */\n error?: (string | null);\n /** Whether the user completed the external purchase flow */\n success: boolean;\n}\n\n/** User actions on external purchase notice sheet (iOS 18.2+) */\nexport type ExternalPurchaseNoticeAction = 'continue' | 'dismissed';\n\n/** Result of presenting external purchase notice sheet (iOS 18.2+) */\nexport interface ExternalPurchaseNoticeResultIOS {\n /** Optional error message if the presentation failed */\n error?: (string | null);\n /** Notice result indicating user action */\n result: ExternalPurchaseNoticeAction;\n}\n\nexport type FetchProductsResult = ProductOrSubscription[] | Product[] | ProductSubscription[] | null;\n\nexport type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android';\n\nexport type IapPlatform = 'ios' | 'android';\n\nexport type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';\n\n/** Unified purchase states from IAPKit verification response. */\nexport type IapkitPurchaseState = 'entitled' | 'pending-acknowledgment' | 'pending' | 'canceled' | 'expired' | 'ready-to-consume' | 'consumed' | 'unknown' | 'inauthentic';\n\n/** Connection initialization configuration */\nexport interface InitConnectionConfig {\n /**\n * Alternative billing mode for Android\n * If not specified, defaults to NONE (standard Google Play billing)\n */\n alternativeBillingModeAndroid?: (AlternativeBillingModeAndroid | null);\n}\n\n/**\n * Parameters for launching an external link (Android)\n * Used with launchExternalLink to initiate external offer or app install flows\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface LaunchExternalLinkParamsAndroid {\n /** The billing program (EXTERNAL_CONTENT_LINK or EXTERNAL_OFFER) */\n billingProgram: BillingProgramAndroid;\n /** The external link launch mode */\n launchMode: ExternalLinkLaunchModeAndroid;\n /** The type of the external link */\n linkType: ExternalLinkTypeAndroid;\n /** The URI where the content will be accessed from */\n linkUri: string;\n}\n\n/**\n * Limited quantity information for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface LimitedQuantityInfoAndroid {\n /** Maximum quantity a user can purchase */\n maximumQuantity: number;\n /** Remaining quantity the user can still purchase */\n remainingQuantity: number;\n}\n\nexport interface Mutation {\n /** Acknowledge a non-consumable purchase or subscription */\n acknowledgePurchaseAndroid: Promise<boolean>;\n /** Initiate a refund request for a product (iOS 15+) */\n beginRefundRequestIOS?: Promise<(string | null)>;\n /**\n * Check if alternative billing is available for this user/device\n * Step 1 of alternative billing flow\n *\n * Returns true if available, false otherwise\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n checkAlternativeBillingAvailabilityAndroid: Promise<boolean>;\n /** Clear pending transactions from the StoreKit payment queue */\n clearTransactionIOS: Promise<boolean>;\n /** Consume a purchase token so it can be repurchased */\n consumePurchaseAndroid: Promise<boolean>;\n /**\n * Create external transaction token for Google Play reporting\n * Step 3 of alternative billing flow\n * Must be called AFTER successful payment in your payment system\n * Token must be reported to Google Play backend within 24 hours\n *\n * Returns token string, or null if creation failed\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n createAlternativeBillingTokenAndroid?: Promise<(string | null)>;\n /** Open the native subscription management surface */\n deepLinkToSubscriptions: Promise<void>;\n /** Close the platform billing connection */\n endConnection: Promise<boolean>;\n /** Finish a transaction after validating receipts */\n finishTransaction: Promise<void>;\n /** Establish the platform billing connection */\n initConnection: Promise<boolean>;\n /** Present the App Store code redemption sheet */\n presentCodeRedemptionSheetIOS: Promise<boolean>;\n /** Present external purchase custom link with StoreKit UI (iOS 18.2+) */\n presentExternalPurchaseLinkIOS: Promise<ExternalPurchaseLinkResultIOS>;\n /** Present external purchase notice sheet (iOS 18.2+) */\n presentExternalPurchaseNoticeSheetIOS: Promise<ExternalPurchaseNoticeResultIOS>;\n /** Initiate a purchase flow; rely on events for final state */\n requestPurchase?: Promise<(Purchase | Purchase[] | null)>;\n /** Purchase the promoted product surfaced by the App Store */\n requestPurchaseOnPromotedProductIOS: Promise<boolean>;\n /** Restore completed purchases across platforms */\n restorePurchases: Promise<void>;\n /**\n * Show alternative billing information dialog to user\n * Step 2 of alternative billing flow\n * Must be called BEFORE processing payment in your payment system\n *\n * Returns true if user accepted, false if user canceled\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n showAlternativeBillingDialogAndroid: Promise<boolean>;\n /** Open subscription management UI and return changed purchases (iOS 15+) */\n showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;\n /** Force a StoreKit sync for transactions (iOS 15+) */\n syncIOS: Promise<boolean>;\n /**\n * Validate purchase receipts with the configured providers\n * @deprecated Use verifyPurchase\n */\n validateReceipt: Promise<VerifyPurchaseResult>;\n /** Verify purchases with the configured providers */\n verifyPurchase: Promise<VerifyPurchaseResult>;\n /** Verify purchases with a specific provider (e.g., IAPKit) */\n verifyPurchaseWithProvider: Promise<VerifyPurchaseWithProviderResult>;\n}\n\n\n\nexport type MutationAcknowledgePurchaseAndroidArgs = string;\n\nexport type MutationBeginRefundRequestIosArgs = string;\n\nexport type MutationConsumePurchaseAndroidArgs = string;\n\nexport type MutationDeepLinkToSubscriptionsArgs = (DeepLinkOptions | null) | undefined;\n\nexport interface MutationFinishTransactionArgs {\n isConsumable?: (boolean | null);\n purchase: PurchaseInput;\n}\n\n\nexport type MutationInitConnectionArgs = (InitConnectionConfig | null) | undefined;\n\nexport type MutationPresentExternalPurchaseLinkIosArgs = string;\n\nexport type MutationRequestPurchaseArgs =\n | {\n /** Per-platform purchase request props */\n request: RequestPurchasePropsByPlatforms;\n type: 'in-app';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n }\n | {\n /** Per-platform subscription request props */\n request: RequestSubscriptionPropsByPlatforms;\n type: 'subs';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n };\n\n\nexport type MutationValidateReceiptArgs = VerifyPurchaseProps;\n\nexport type MutationVerifyPurchaseArgs = VerifyPurchaseProps;\n\nexport type MutationVerifyPurchaseWithProviderArgs = VerifyPurchaseWithProviderProps;\n\nexport type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';\n\n/**\n * Pre-order details for one-time purchase products (Android)\n * Available in Google Play Billing Library 8.1.0+\n */\nexport interface PreorderDetailsAndroid {\n /**\n * Pre-order presale end time in milliseconds since epoch.\n * This is when the presale period ends and the product will be released.\n */\n preorderPresaleEndTimeMillis: string;\n /**\n * Pre-order release time in milliseconds since epoch.\n * This is when the product will be available to users who pre-ordered.\n */\n preorderReleaseTimeMillis: string;\n}\n\nexport interface PricingPhaseAndroid {\n billingCycleCount: number;\n billingPeriod: string;\n formattedPrice: string;\n priceAmountMicros: string;\n priceCurrencyCode: string;\n recurrenceMode: number;\n}\n\nexport interface PricingPhasesAndroid {\n pricingPhaseList: PricingPhaseAndroid[];\n}\n\nexport type Product = ProductAndroid | ProductIOS;\n\nexport interface ProductAndroid extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n nameAndroid: string;\n /**\n * One-time purchase offer details including discounts (Android)\n * Returns all eligible offers. Available in Google Play Billing Library 7.0+\n */\n oneTimePurchaseOfferDetailsAndroid?: (ProductAndroidOneTimePurchaseOfferDetail[] | null);\n platform: 'android';\n price?: (number | null);\n subscriptionOfferDetailsAndroid?: (ProductSubscriptionAndroidOfferDetails[] | null);\n title: string;\n type: 'in-app';\n}\n\n/**\n * One-time purchase offer details (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface ProductAndroidOneTimePurchaseOfferDetail {\n /**\n * Discount display information\n * Only available for discounted offers\n */\n discountDisplayInfo?: (DiscountDisplayInfoAndroid | null);\n formattedPrice: string;\n /**\n * Full (non-discounted) price in micro-units\n * Only available for discounted offers\n */\n fullPriceMicros?: (string | null);\n /** Limited quantity information */\n limitedQuantityInfo?: (LimitedQuantityInfoAndroid | null);\n /** Offer ID */\n offerId?: (string | null);\n /** List of offer tags */\n offerTags: string[];\n /** Offer token for use in BillingFlowParams when purchasing */\n offerToken: string;\n /**\n * Pre-order details for products available for pre-order\n * Available in Google Play Billing Library 8.1.0+\n */\n preorderDetailsAndroid?: (PreorderDetailsAndroid | null);\n priceAmountMicros: string;\n priceCurrencyCode: string;\n /** Rental details for rental offers */\n rentalDetailsAndroid?: (RentalDetailsAndroid | null);\n /** Valid time window for the offer */\n validTimeWindow?: (ValidTimeWindowAndroid | null);\n}\n\nexport interface ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n platform: 'android' | 'ios';\n price?: (number | null);\n title: string;\n type: 'in-app' | 'subs';\n} \n\nexport interface ProductIOS extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayNameIOS: string;\n displayPrice: string;\n id: string;\n isFamilyShareableIOS: boolean;\n jsonRepresentationIOS: string;\n platform: 'ios';\n price?: (number | null);\n subscriptionInfoIOS?: (SubscriptionInfoIOS | null);\n title: string;\n type: 'in-app';\n typeIOS: ProductTypeIOS;\n}\n\nexport type ProductOrSubscription = Product | ProductSubscription;\n\nexport type ProductQueryType = 'in-app' | 'subs' | 'all';\n\nexport interface ProductRequest {\n skus: string[];\n type?: (ProductQueryType | null);\n}\n\nexport type ProductSubscription = ProductSubscriptionAndroid | ProductSubscriptionIOS;\n\nexport interface ProductSubscriptionAndroid extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n nameAndroid: string;\n /**\n * One-time purchase offer details including discounts (Android)\n * Returns all eligible offers. Available in Google Play Billing Library 7.0+\n */\n oneTimePurchaseOfferDetailsAndroid?: (ProductAndroidOneTimePurchaseOfferDetail[] | null);\n platform: 'android';\n price?: (number | null);\n subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[];\n title: string;\n type: 'subs';\n}\n\nexport interface ProductSubscriptionAndroidOfferDetails {\n basePlanId: string;\n offerId?: (string | null);\n offerTags: string[];\n offerToken: string;\n pricingPhases: PricingPhasesAndroid;\n}\n\nexport interface ProductSubscriptionIOS extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n discountsIOS?: (DiscountIOS[] | null);\n displayName?: (string | null);\n displayNameIOS: string;\n displayPrice: string;\n id: string;\n introductoryPriceAsAmountIOS?: (string | null);\n introductoryPriceIOS?: (string | null);\n introductoryPriceNumberOfPeriodsIOS?: (string | null);\n introductoryPricePaymentModeIOS: PaymentModeIOS;\n introductoryPriceSubscriptionPeriodIOS?: (SubscriptionPeriodIOS | null);\n isFamilyShareableIOS: boolean;\n jsonRepresentationIOS: string;\n platform: 'ios';\n price?: (number | null);\n subscriptionInfoIOS?: (SubscriptionInfoIOS | null);\n subscriptionPeriodNumberIOS?: (string | null);\n subscriptionPeriodUnitIOS?: (SubscriptionPeriodIOS | null);\n title: string;\n type: 'subs';\n typeIOS: ProductTypeIOS;\n}\n\nexport type ProductType = 'in-app' | 'subs';\n\nexport type ProductTypeIOS = 'consumable' | 'non-consumable' | 'auto-renewable-subscription' | 'non-renewing-subscription';\n\nexport type Purchase = PurchaseAndroid | PurchaseIOS;\n\nexport interface PurchaseAndroid extends PurchaseCommon {\n autoRenewingAndroid?: (boolean | null);\n currentPlanId?: (string | null);\n dataAndroid?: (string | null);\n developerPayloadAndroid?: (string | null);\n id: string;\n ids?: (string[] | null);\n isAcknowledgedAndroid?: (boolean | null);\n isAutoRenewing: boolean;\n /**\n * Whether the subscription is suspended (Android)\n * A suspended subscription means the user's payment method failed and they need to fix it.\n * Users should be directed to the subscription center to resolve the issue.\n * Do NOT grant entitlements for suspended subscriptions.\n * Available in Google Play Billing Library 8.1.0+\n */\n isSuspendedAndroid?: (boolean | null);\n obfuscatedAccountIdAndroid?: (string | null);\n obfuscatedProfileIdAndroid?: (string | null);\n packageNameAndroid?: (string | null);\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n purchaseToken?: (string | null);\n quantity: number;\n signatureAndroid?: (string | null);\n /** Store where purchase was made */\n store: IapStore;\n transactionDate: number;\n transactionId?: (string | null);\n}\n\nexport interface PurchaseCommon {\n /**\n * The current plan identifier. This is:\n * - On Android: the basePlanId (e.g., \"premium\", \"premium-year\")\n * - On iOS: the productId (e.g., \"com.example.premium_monthly\", \"com.example.premium_yearly\")\n * This provides a unified way to identify which specific plan/tier the user is subscribed to.\n */\n currentPlanId?: (string | null);\n id: string;\n ids?: (string[] | null);\n isAutoRenewing: boolean;\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n /** Unified purchase token (iOS JWS, Android purchaseToken) */\n purchaseToken?: (string | null);\n quantity: number;\n /** Store where purchase was made */\n store: IapStore;\n transactionDate: number;\n}\n\nexport interface PurchaseError {\n code: ErrorCode;\n message: string;\n productId?: (string | null);\n}\n\nexport interface PurchaseIOS extends PurchaseCommon {\n appAccountToken?: (string | null);\n appBundleIdIOS?: (string | null);\n countryCodeIOS?: (string | null);\n currencyCodeIOS?: (string | null);\n currencySymbolIOS?: (string | null);\n currentPlanId?: (string | null);\n environmentIOS?: (string | null);\n expirationDateIOS?: (number | null);\n id: string;\n ids?: (string[] | null);\n isAutoRenewing: boolean;\n isUpgradedIOS?: (boolean | null);\n offerIOS?: (PurchaseOfferIOS | null);\n originalTransactionDateIOS?: (number | null);\n originalTransactionIdentifierIOS?: (string | null);\n ownershipTypeIOS?: (string | null);\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n purchaseToken?: (string | null);\n quantity: number;\n quantityIOS?: (number | null);\n reasonIOS?: (string | null);\n reasonStringRepresentationIOS?: (string | null);\n renewalInfoIOS?: (RenewalInfoIOS | null);\n revocationDateIOS?: (number | null);\n revocationReasonIOS?: (string | null);\n /** Store where purchase was made */\n store: IapStore;\n storefrontCountryCodeIOS?: (string | null);\n subscriptionGroupIdIOS?: (string | null);\n transactionDate: number;\n transactionId: string;\n transactionReasonIOS?: (string | null);\n webOrderLineItemIdIOS?: (string | null);\n}\n\nexport type PurchaseInput = Purchase;\n\nexport interface PurchaseOfferIOS {\n id: string;\n paymentMode: string;\n type: string;\n}\n\nexport interface PurchaseOptions {\n /** Also emit results through the iOS event listeners */\n alsoPublishToEventListenerIOS?: (boolean | null);\n /** Limit to currently active items on iOS */\n onlyIncludeActiveItemsIOS?: (boolean | null);\n}\n\nexport type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';\n\nexport type PurchaseVerificationProvider = 'iapkit';\n\nexport interface Query {\n /** Check if external purchase notice sheet can be presented (iOS 18.2+) */\n canPresentExternalPurchaseNoticeIOS: Promise<boolean>;\n /** Get current StoreKit 2 entitlements (iOS 15+) */\n currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;\n /** Retrieve products or subscriptions from the store */\n fetchProducts: Promise<(ProductOrSubscription[] | Product[] | ProductSubscription[] | null)>;\n /** Get active subscriptions (filters by subscriptionIds when provided) */\n getActiveSubscriptions: Promise<ActiveSubscription[]>;\n /** Fetch the current app transaction (iOS 16+) */\n getAppTransactionIOS?: Promise<(AppTransaction | null)>;\n /** Get all available purchases for the current user */\n getAvailablePurchases: Promise<Purchase[]>;\n /** Retrieve all pending transactions in the StoreKit queue */\n getPendingTransactionsIOS: Promise<PurchaseIOS[]>;\n /** Get the currently promoted product (iOS 11+) */\n getPromotedProductIOS?: Promise<(ProductIOS | null)>;\n /** Get base64-encoded receipt data for validation */\n getReceiptDataIOS?: Promise<(string | null)>;\n /** Get the current storefront country code */\n getStorefront: Promise<string>;\n /**\n * Get the current App Store storefront country code\n * @deprecated Use getStorefront\n */\n getStorefrontIOS: Promise<string>;\n /** Get the transaction JWS (StoreKit 2) */\n getTransactionJwsIOS?: Promise<(string | null)>;\n /** Check whether the user has active subscriptions */\n hasActiveSubscriptions: Promise<boolean>;\n /** Check introductory offer eligibility for a subscription group */\n isEligibleForIntroOfferIOS: Promise<boolean>;\n /** Verify a StoreKit 2 transaction signature */\n isTransactionVerifiedIOS: Promise<boolean>;\n /** Get the latest transaction for a product using StoreKit 2 */\n latestTransactionIOS?: Promise<(PurchaseIOS | null)>;\n /** Get StoreKit 2 subscription status details (iOS 15+) */\n subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;\n /**\n * Validate a receipt for a specific product\n * @deprecated Use verifyPurchase\n */\n validateReceiptIOS: Promise<VerifyPurchaseResultIOS>;\n}\n\n\n\nexport type QueryCurrentEntitlementIosArgs = string;\n\nexport type QueryFetchProductsArgs = ProductRequest;\n\nexport type QueryGetActiveSubscriptionsArgs = (string[] | null) | undefined;\n\nexport type QueryGetAvailablePurchasesArgs = (PurchaseOptions | null) | undefined;\n\nexport type QueryGetTransactionJwsIosArgs = string;\n\nexport type QueryHasActiveSubscriptionsArgs = (string[] | null) | undefined;\n\nexport type QueryIsEligibleForIntroOfferIosArgs = string;\n\nexport type QueryIsTransactionVerifiedIosArgs = string;\n\nexport type QueryLatestTransactionIosArgs = string;\n\nexport type QuerySubscriptionStatusIosArgs = string;\n\nexport type QueryValidateReceiptIosArgs = VerifyPurchaseProps;\n\nexport interface RefundResultIOS {\n message?: (string | null);\n status: string;\n}\n\n/**\n * Subscription renewal information from Product.SubscriptionInfo.RenewalInfo\n * https://developer.apple.com/documentation/storekit/product/subscriptioninfo/renewalinfo\n */\nexport interface RenewalInfoIOS {\n autoRenewPreference?: (string | null);\n /**\n * When subscription expires due to cancellation/billing issue\n * Possible values: \"VOLUNTARY\", \"BILLING_ERROR\", \"DID_NOT_AGREE_TO_PRICE_INCREASE\", \"PRODUCT_NOT_AVAILABLE\", \"UNKNOWN\"\n */\n expirationReason?: (string | null);\n /**\n * Grace period expiration date (milliseconds since epoch)\n * When set, subscription is in grace period (billing issue but still has access)\n */\n gracePeriodExpirationDate?: (number | null);\n /**\n * True if subscription failed to renew due to billing issue and is retrying\n * Note: Not directly available in RenewalInfo, available in Status\n */\n isInBillingRetry?: (boolean | null);\n jsonRepresentation?: (string | null);\n /**\n * Product ID that will be used on next renewal (when user upgrades/downgrades)\n * If set and different from current productId, subscription will change on expiration\n */\n pendingUpgradeProductId?: (string | null);\n /**\n * User's response to subscription price increase\n * Possible values: \"AGREED\", \"PENDING\", null (no price increase)\n */\n priceIncreaseStatus?: (string | null);\n /**\n * Expected renewal date (milliseconds since epoch)\n * For active subscriptions, when the next renewal/charge will occur\n */\n renewalDate?: (number | null);\n /** Offer ID applied to next renewal (promotional offer, subscription offer code, etc.) */\n renewalOfferId?: (string | null);\n /**\n * Type of offer applied to next renewal\n * Possible values: \"PROMOTIONAL\", \"SUBSCRIPTION_OFFER_CODE\", \"WIN_BACK\", etc.\n */\n renewalOfferType?: (string | null);\n willAutoRenew: boolean;\n}\n\n/**\n * Rental details for one-time purchase products that can be rented (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface RentalDetailsAndroid {\n /**\n * Rental expiration period in ISO 8601 format\n * Time after rental period ends when user can still extend\n */\n rentalExpirationPeriod?: (string | null);\n /** Rental period in ISO 8601 format (e.g., P7D for 7 days) */\n rentalPeriod: string;\n}\n\nexport interface RequestPurchaseAndroidProps {\n /** Personalized offer flag */\n isOfferPersonalized?: (boolean | null);\n /** Obfuscated account ID */\n obfuscatedAccountIdAndroid?: (string | null);\n /** Obfuscated profile ID */\n obfuscatedProfileIdAndroid?: (string | null);\n /** List of product SKUs */\n skus: string[];\n}\n\nexport interface RequestPurchaseIosProps {\n /** Auto-finish transaction (dangerous) */\n andDangerouslyFinishTransactionAutomatically?: (boolean | null);\n /** App account token for user tracking */\n appAccountToken?: (string | null);\n /** Purchase quantity */\n quantity?: (number | null);\n /** Product SKU */\n sku: string;\n /** Discount offer to apply */\n withOffer?: (DiscountOfferInputIOS | null);\n}\n\nexport type RequestPurchaseProps =\n | {\n /** Per-platform purchase request props */\n request: RequestPurchasePropsByPlatforms;\n type: 'in-app';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n }\n | {\n /** Per-platform subscription request props */\n request: RequestSubscriptionPropsByPlatforms;\n type: 'subs';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n };\n\n/**\n * Platform-specific purchase request parameters.\n *\n * Note: \"Platforms\" refers to the SDK/OS level (apple, google), not the store.\n * - apple: Always targets App Store\n * - google: Targets Play Store by default, or Horizon when built with horizon flavor\n * (determined at build time, not runtime)\n */\nexport interface RequestPurchasePropsByPlatforms {\n /** @deprecated Use google instead */\n android?: (RequestPurchaseAndroidProps | null);\n /** Apple-specific purchase parameters */\n apple?: (RequestPurchaseIosProps | null);\n /** Google-specific purchase parameters */\n google?: (RequestPurchaseAndroidProps | null);\n /** @deprecated Use apple instead */\n ios?: (RequestPurchaseIosProps | null);\n}\n\nexport type RequestPurchaseResult = Purchase | Purchase[] | null;\n\nexport interface RequestSubscriptionAndroidProps {\n /** Personalized offer flag */\n isOfferPersonalized?: (boolean | null);\n /** Obfuscated account ID */\n obfuscatedAccountIdAndroid?: (string | null);\n /** Obfuscated profile ID */\n obfuscatedProfileIdAndroid?: (string | null);\n /** Purchase token for upgrades/downgrades */\n purchaseTokenAndroid?: (string | null);\n /**\n * Replacement mode for subscription changes\n * @deprecated Use subscriptionProductReplacementParams instead for item-level replacement (8.1.0+)\n */\n replacementModeAndroid?: (number | null);\n /** List of subscription SKUs */\n skus: string[];\n /** Subscription offers */\n subscriptionOffers?: (AndroidSubscriptionOfferInput[] | null);\n /**\n * Product-level replacement parameters (8.1.0+)\n * Use this instead of replacementModeAndroid for item-level replacement\n */\n subscriptionProductReplacementParams?: (SubscriptionProductReplacementParamsAndroid | null);\n}\n\nexport interface RequestSubscriptionIosProps {\n andDangerouslyFinishTransactionAutomatically?: (boolean | null);\n appAccountToken?: (string | null);\n quantity?: (number | null);\n sku: string;\n withOffer?: (DiscountOfferInputIOS | null);\n}\n\n/**\n * Platform-specific subscription request parameters.\n *\n * Note: \"Platforms\" refers to the SDK/OS level (apple, google), not the store.\n * - apple: Always targets App Store\n * - google: Targets Play Store by default, or Horizon when built with horizon flavor\n * (determined at build time, not runtime)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n /** @deprecated Use google instead */\n android?: (RequestSubscriptionAndroidProps | null);\n /** Apple-specific subscription parameters */\n apple?: (RequestSubscriptionIosProps | null);\n /** Google-specific subscription parameters */\n google?: (RequestSubscriptionAndroidProps | null);\n /** @deprecated Use apple instead */\n ios?: (RequestSubscriptionIosProps | null);\n}\n\nexport interface RequestVerifyPurchaseWithIapkitAppleProps {\n /** The JWS token returned with the purchase response. */\n jws: string;\n}\n\nexport interface RequestVerifyPurchaseWithIapkitGoogleProps {\n /** The token provided to the user's device when the product or subscription was purchased. */\n purchaseToken: string;\n}\n\n/**\n * Platform-specific verification parameters for IAPKit.\n *\n * - apple: Verifies via App Store (JWS token)\n * - google: Verifies via Play Store (purchase token)\n */\nexport interface RequestVerifyPurchaseWithIapkitProps {\n /** API key used for the Authorization header (Bearer {apiKey}). */\n apiKey?: (string | null);\n /** Apple App Store verification parameters. */\n apple?: (RequestVerifyPurchaseWithIapkitAppleProps | null);\n /** Google Play Store verification parameters. */\n google?: (RequestVerifyPurchaseWithIapkitGoogleProps | null);\n}\n\nexport interface RequestVerifyPurchaseWithIapkitResult {\n /** Whether the purchase is valid (not falsified). */\n isValid: boolean;\n /** The current state of the purchase. */\n state: IapkitPurchaseState;\n store: IapStore;\n}\n\nexport interface Subscription {\n /** Fires when the App Store surfaces a promoted product (iOS only) */\n promotedProductIOS: string;\n /** Fires when a purchase fails or is cancelled */\n purchaseError: PurchaseError;\n /** Fires when a purchase completes successfully or a pending purchase resolves */\n purchaseUpdated: Purchase;\n /**\n * Fires when a user selects alternative billing in the User Choice Billing dialog (Android only)\n * Only triggered when the user selects alternative billing instead of Google Play billing\n */\n userChoiceBillingAndroid: UserChoiceBillingDetails;\n}\n\n\nexport interface SubscriptionInfoIOS {\n introductoryOffer?: (SubscriptionOfferIOS | null);\n promotionalOffers?: (SubscriptionOfferIOS[] | null);\n subscriptionGroupId: string;\n subscriptionPeriod: SubscriptionPeriodValueIOS;\n}\n\nexport interface SubscriptionOfferIOS {\n displayPrice: string;\n id: string;\n paymentMode: PaymentModeIOS;\n period: SubscriptionPeriodValueIOS;\n periodCount: number;\n price: number;\n type: SubscriptionOfferTypeIOS;\n}\n\nexport type SubscriptionOfferTypeIOS = 'introductory' | 'promotional';\n\nexport type SubscriptionPeriodIOS = 'day' | 'week' | 'month' | 'year' | 'empty';\n\nexport interface SubscriptionPeriodValueIOS {\n unit: SubscriptionPeriodIOS;\n value: number;\n}\n\n/**\n * Product-level subscription replacement parameters (Android)\n * Used with setSubscriptionProductReplacementParams in BillingFlowParams.ProductDetailsParams\n * Available in Google Play Billing Library 8.1.0+\n */\nexport interface SubscriptionProductReplacementParamsAndroid {\n /** The old product ID that needs to be replaced */\n oldProductId: string;\n /** The replacement mode for this product change */\n replacementMode: SubscriptionReplacementModeAndroid;\n}\n\n/**\n * Replacement mode for subscription changes (Android)\n * These modes determine how the subscription replacement affects billing.\n * Available in Google Play Billing Library 8.1.0+\n */\nexport type SubscriptionReplacementModeAndroid = 'unknown-replacement-mode' | 'with-time-proration' | 'charge-prorated-price' | 'charge-full-price' | 'without-proration' | 'deferred' | 'keep-existing';\n\nexport interface SubscriptionStatusIOS {\n renewalInfo?: (RenewalInfoIOS | null);\n state: string;\n}\n\n/**\n * User Choice Billing event details (Android)\n * Fired when a user selects alternative billing in the User Choice Billing dialog\n */\nexport interface UserChoiceBillingDetails {\n /** Token that must be reported to Google Play within 24 hours */\n externalTransactionToken: string;\n /** List of product IDs selected by the user */\n products: string[];\n}\n\n/**\n * Valid time window for when an offer is available (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface ValidTimeWindowAndroid {\n /** End time in milliseconds since epoch */\n endTimeMillis: string;\n /** Start time in milliseconds since epoch */\n startTimeMillis: string;\n}\n\n/**\n * Apple App Store verification parameters.\n * Used for server-side receipt validation via App Store Server API.\n */\nexport interface VerifyPurchaseAppleOptions {\n /** Product SKU to validate */\n sku: string;\n}\n\n/**\n * Google Play Store verification parameters.\n * Used for server-side receipt validation via Google Play Developer API.\n *\n * ⚠️ SECURITY: Contains sensitive tokens (accessToken, purchaseToken). Do not log or persist this data.\n */\nexport interface VerifyPurchaseGoogleOptions {\n /**\n * Google OAuth2 access token for API authentication.\n * ⚠️ Sensitive: Do not log this value.\n */\n accessToken: string;\n /** Whether this is a subscription purchase (affects API endpoint used) */\n isSub?: (boolean | null);\n /** Android package name (e.g., com.example.app) */\n packageName: string;\n /**\n * Purchase token from the purchase response.\n * ⚠️ Sensitive: Do not log this value.\n */\n purchaseToken: string;\n /** Product SKU to validate */\n sku: string;\n}\n\n/**\n * Meta Horizon (Quest) verification parameters.\n * Used for server-side entitlement verification via Meta's S2S API.\n * POST https://graph.oculus.com/$APP_ID/verify_entitlement\n *\n * ⚠️ SECURITY: Contains sensitive token (accessToken). Do not log or persist this data.\n */\nexport interface VerifyPurchaseHorizonOptions {\n /**\n * Access token for Meta API authentication (OC|$APP_ID|$APP_SECRET or User Access Token).\n * ⚠️ Sensitive: Do not log this value.\n */\n accessToken: string;\n /** The SKU for the add-on item, defined in Meta Developer Dashboard */\n sku: string;\n /** The user ID of the user whose purchase you want to verify */\n userId: string;\n}\n\n/**\n * Platform-specific purchase verification parameters.\n *\n * - apple: Verifies via App Store Server API\n * - google: Verifies via Google Play Developer API\n * - horizon: Verifies via Meta's S2S API (verify_entitlement endpoint)\n */\nexport interface VerifyPurchaseProps {\n /** Apple App Store verification parameters. */\n apple?: (VerifyPurchaseAppleOptions | null);\n /** Google Play Store verification parameters. */\n google?: (VerifyPurchaseGoogleOptions | null);\n /** Meta Horizon (Quest) verification parameters. */\n horizon?: (VerifyPurchaseHorizonOptions | null);\n}\n\nexport type VerifyPurchaseResult = VerifyPurchaseResultAndroid | VerifyPurchaseResultHorizon | VerifyPurchaseResultIOS;\n\nexport interface VerifyPurchaseResultAndroid {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate?: (number | null);\n cancelReason?: (string | null);\n deferredDate?: (number | null);\n deferredSku?: (string | null);\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n}\n\n/**\n * Result from Meta Horizon verify_entitlement API.\n * Returns verification status and grant time for the entitlement.\n */\nexport interface VerifyPurchaseResultHorizon {\n /** Unix timestamp (seconds) when the entitlement was granted. */\n grantTime?: (number | null);\n /** Whether the entitlement verification succeeded. */\n success: boolean;\n}\n\nexport interface VerifyPurchaseResultIOS {\n /** Whether the receipt is valid */\n isValid: boolean;\n /** JWS representation */\n jwsRepresentation: string;\n /** Latest transaction if available */\n latestTransaction?: (Purchase | null);\n /** Receipt data string */\n receiptData: string;\n}\n\nexport interface VerifyPurchaseWithProviderError {\n code?: (string | null);\n message: string;\n}\n\nexport interface VerifyPurchaseWithProviderProps {\n iapkit?: (RequestVerifyPurchaseWithIapkitProps | null);\n provider: PurchaseVerificationProvider;\n}\n\nexport interface VerifyPurchaseWithProviderResult {\n /** Error details if verification failed */\n errors?: (VerifyPurchaseWithProviderError[] | null);\n /** IAPKit verification result */\n iapkit?: (RequestVerifyPurchaseWithIapkitResult | null);\n provider: PurchaseVerificationProvider;\n}\n\nexport type VoidResult = void;\n\n// -- Query helper types (auto-generated)\nexport type QueryArgsMap = {\n canPresentExternalPurchaseNoticeIOS: never;\n currentEntitlementIOS: QueryCurrentEntitlementIosArgs;\n fetchProducts: QueryFetchProductsArgs;\n getActiveSubscriptions: QueryGetActiveSubscriptionsArgs;\n getAppTransactionIOS: never;\n getAvailablePurchases: QueryGetAvailablePurchasesArgs;\n getPendingTransactionsIOS: never;\n getPromotedProductIOS: never;\n getReceiptDataIOS: never;\n getStorefront: never;\n getStorefrontIOS: never;\n getTransactionJwsIOS: QueryGetTransactionJwsIosArgs;\n hasActiveSubscriptions: QueryHasActiveSubscriptionsArgs;\n isEligibleForIntroOfferIOS: QueryIsEligibleForIntroOfferIosArgs;\n isTransactionVerifiedIOS: QueryIsTransactionVerifiedIosArgs;\n latestTransactionIOS: QueryLatestTransactionIosArgs;\n subscriptionStatusIOS: QuerySubscriptionStatusIosArgs;\n validateReceiptIOS: QueryValidateReceiptIosArgs;\n};\n\nexport type QueryField<K extends keyof Query> =\n QueryArgsMap[K] extends never\n ? () => NonNullable<Query[K]>\n : undefined extends QueryArgsMap[K]\n ? (args?: QueryArgsMap[K]) => NonNullable<Query[K]>\n : (args: QueryArgsMap[K]) => NonNullable<Query[K]>;\n\nexport type QueryFieldMap = {\n [K in keyof Query]?: QueryField<K>;\n};\n// -- End query helper types\n\n// -- Mutation helper types (auto-generated)\nexport type MutationArgsMap = {\n acknowledgePurchaseAndroid: MutationAcknowledgePurchaseAndroidArgs;\n beginRefundRequestIOS: MutationBeginRefundRequestIosArgs;\n checkAlternativeBillingAvailabilityAndroid: never;\n clearTransactionIOS: never;\n consumePurchaseAndroid: MutationConsumePurchaseAndroidArgs;\n createAlternativeBillingTokenAndroid: never;\n deepLinkToSubscriptions: MutationDeepLinkToSubscriptionsArgs;\n endConnection: never;\n finishTransaction: MutationFinishTransactionArgs;\n initConnection: MutationInitConnectionArgs;\n presentCodeRedemptionSheetIOS: never;\n presentExternalPurchaseLinkIOS: MutationPresentExternalPurchaseLinkIosArgs;\n presentExternalPurchaseNoticeSheetIOS: never;\n requestPurchase: MutationRequestPurchaseArgs;\n requestPurchaseOnPromotedProductIOS: never;\n restorePurchases: never;\n showAlternativeBillingDialogAndroid: never;\n showManageSubscriptionsIOS: never;\n syncIOS: never;\n validateReceipt: MutationValidateReceiptArgs;\n verifyPurchase: MutationVerifyPurchaseArgs;\n verifyPurchaseWithProvider: MutationVerifyPurchaseWithProviderArgs;\n};\n\nexport type MutationField<K extends keyof Mutation> =\n MutationArgsMap[K] extends never\n ? () => NonNullable<Mutation[K]>\n : undefined extends MutationArgsMap[K]\n ? (args?: MutationArgsMap[K]) => NonNullable<Mutation[K]>\n : (args: MutationArgsMap[K]) => NonNullable<Mutation[K]>;\n\nexport type MutationFieldMap = {\n [K in keyof Mutation]?: MutationField<K>;\n};\n// -- End mutation helper types\n\n// -- Subscription helper types (auto-generated)\nexport type SubscriptionArgsMap = {\n promotedProductIOS: never;\n purchaseError: never;\n purchaseUpdated: never;\n userChoiceBillingAndroid: never;\n};\n\nexport type SubscriptionField<K extends keyof Subscription> =\n SubscriptionArgsMap[K] extends never\n ? () => NonNullable<Subscription[K]>\n : undefined extends SubscriptionArgsMap[K]\n ? (args?: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>\n : (args: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>;\n\nexport type SubscriptionFieldMap = {\n [K in keyof Subscription]?: SubscriptionField<K>;\n};\n// -- End subscription helper types\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8CAA8C;AAC9C,yEAAyE;AACzE,+EAA+E;AA8K/E,MAAM,CAAN,IAAY,SAsCX;AAtCD,WAAY,SAAS;IACnB,yDAA4C,CAAA;IAC5C,2CAA8B,CAAA;IAC9B,iDAAoC,CAAA;IACpC,gFAAmE,CAAA;IACnE,uDAA0C,CAAA;IAC1C,mDAAsC,CAAA;IACtC,iDAAoC,CAAA;IACpC,+CAAkC,CAAA;IAClC,4CAA+B,CAAA;IAC/B,0DAA6C,CAAA;IAC7C,kDAAqC,CAAA;IACrC,+CAAkC,CAAA;IAClC,wCAA2B,CAAA;IAC3B,4CAA+B,CAAA;IAC/B,iDAAoC,CAAA;IACpC,2CAA8B,CAAA;IAC9B,mCAAsB,CAAA;IACtB,yCAA4B,CAAA;IAC5B,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;IAChC,wEAA2D,CAAA;IAC3D,qFAAwE,CAAA;IACxE,4EAA+D,CAAA;IAC/D,2CAA8B,CAAA;IAC9B,6CAAgC,CAAA;IAChC,iDAAoC,CAAA;IACpC,8DAAiD,CAAA;IACjD,yCAA4B,CAAA;IAC5B,yDAA4C,CAAA;IAC5C,2CAA8B,CAAA;IAC9B,0CAA6B,CAAA;IAC7B,oDAAuC,CAAA;IACvC,qCAAwB,CAAA;IACxB,0EAA6D,CAAA;IAC7D,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;IAChC,qCAAwB,CAAA;AAC1B,CAAC,EAtCW,SAAS,KAAT,SAAS,QAsCpB;AA0pCD,mCAAmC","sourcesContent":["// ============================================================================\n// AUTO-GENERATED TYPES — DO NOT EDIT DIRECTLY\n// Run `bun run generate:types` after updating any *.graphql schema file.\n// ============================================================================\n\nexport interface ActiveSubscription {\n autoRenewingAndroid?: (boolean | null);\n basePlanIdAndroid?: (string | null);\n /**\n * The current plan identifier. This is:\n * - On Android: the basePlanId (e.g., \"premium\", \"premium-year\")\n * - On iOS: the productId (e.g., \"com.example.premium_monthly\", \"com.example.premium_yearly\")\n * This provides a unified way to identify which specific plan/tier the user is subscribed to.\n */\n currentPlanId?: (string | null);\n daysUntilExpirationIOS?: (number | null);\n environmentIOS?: (string | null);\n expirationDateIOS?: (number | null);\n isActive: boolean;\n productId: string;\n purchaseToken?: (string | null);\n /** Required for subscription upgrade/downgrade on Android */\n purchaseTokenAndroid?: (string | null);\n /**\n * Renewal information from StoreKit 2 (iOS only). Contains details about subscription renewal status,\n * pending upgrades/downgrades, and auto-renewal preferences.\n */\n renewalInfoIOS?: (RenewalInfoIOS | null);\n transactionDate: number;\n transactionId: string;\n /**\n * @deprecated iOS only - use daysUntilExpirationIOS instead.\n * Whether the subscription will expire soon (within 7 days).\n * Consider using daysUntilExpirationIOS for more precise control.\n */\n willExpireSoon?: (boolean | null);\n}\n\n/**\n * Alternative billing mode for Android\n * Controls which billing system is used\n */\nexport type AlternativeBillingModeAndroid = 'none' | 'user-choice' | 'alternative-only';\n\nexport interface AndroidSubscriptionOfferInput {\n /** Offer token */\n offerToken: string;\n /** Product SKU */\n sku: string;\n}\n\nexport interface AppTransaction {\n appId: number;\n appTransactionId?: (string | null);\n appVersion: string;\n appVersionId: number;\n bundleId: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n environment: string;\n originalAppVersion: string;\n originalPlatform?: (string | null);\n originalPurchaseDate: number;\n preorderDate?: (number | null);\n signedDate: number;\n}\n\n/**\n * Billing program types for external content links and external offers (Android)\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type BillingProgramAndroid = 'unspecified' | 'external-content-link' | 'external-offer';\n\n/**\n * Result of checking billing program availability (Android)\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface BillingProgramAvailabilityResultAndroid {\n /** The billing program that was checked */\n billingProgram: BillingProgramAndroid;\n /** Whether the billing program is available for the user */\n isAvailable: boolean;\n}\n\n/**\n * Reporting details for transactions made outside of Google Play Billing (Android)\n * Contains the external transaction token needed for reporting\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface BillingProgramReportingDetailsAndroid {\n /** The billing program that the reporting details are associated with */\n billingProgram: BillingProgramAndroid;\n /**\n * External transaction token used to report transactions made outside of Google Play Billing.\n * This token must be used when reporting the external transaction to Google.\n */\n externalTransactionToken: string;\n}\n\nexport interface DeepLinkOptions {\n /** Android package name to target (required on Android) */\n packageNameAndroid?: (string | null);\n /** Android SKU to open (required on Android) */\n skuAndroid?: (string | null);\n}\n\n/**\n * Discount amount details for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface DiscountAmountAndroid {\n /** Discount amount in micro-units (1,000,000 = 1 unit of currency) */\n discountAmountMicros: string;\n /** Formatted discount amount with currency sign (e.g., \"$4.99\") */\n formattedDiscountAmount: string;\n}\n\n/**\n * Discount display information for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface DiscountDisplayInfoAndroid {\n /**\n * Absolute discount amount details\n * Only returned for fixed amount discounts\n */\n discountAmount?: (DiscountAmountAndroid | null);\n /**\n * Percentage discount (e.g., 33 for 33% off)\n * Only returned for percentage-based discounts\n */\n percentageDiscount?: (number | null);\n}\n\nexport interface DiscountIOS {\n identifier: string;\n localizedPrice?: (string | null);\n numberOfPeriods: number;\n paymentMode: PaymentModeIOS;\n price: string;\n priceAmount: number;\n subscriptionPeriod: string;\n type: string;\n}\n\nexport interface DiscountOfferIOS {\n /** Discount identifier */\n identifier: string;\n /** Key identifier for validation */\n keyIdentifier: string;\n /** Cryptographic nonce */\n nonce: string;\n /** Signature for validation */\n signature: string;\n /** Timestamp of discount offer */\n timestamp: number;\n}\n\nexport interface DiscountOfferInputIOS {\n /** Discount identifier */\n identifier: string;\n /** Key identifier for validation */\n keyIdentifier: string;\n /** Cryptographic nonce */\n nonce: string;\n /** Signature for validation */\n signature: string;\n /** Timestamp of discount offer */\n timestamp: number;\n}\n\nexport interface EntitlementIOS {\n jsonRepresentation: string;\n sku: string;\n transactionId: string;\n}\n\nexport enum ErrorCode {\n ActivityUnavailable = 'activity-unavailable',\n AlreadyOwned = 'already-owned',\n AlreadyPrepared = 'already-prepared',\n BillingResponseJsonParseError = 'billing-response-json-parse-error',\n BillingUnavailable = 'billing-unavailable',\n ConnectionClosed = 'connection-closed',\n DeferredPayment = 'deferred-payment',\n DeveloperError = 'developer-error',\n EmptySkuList = 'empty-sku-list',\n FeatureNotSupported = 'feature-not-supported',\n IapNotAvailable = 'iap-not-available',\n InitConnection = 'init-connection',\n Interrupted = 'interrupted',\n ItemNotOwned = 'item-not-owned',\n ItemUnavailable = 'item-unavailable',\n NetworkError = 'network-error',\n NotEnded = 'not-ended',\n NotPrepared = 'not-prepared',\n Pending = 'pending',\n PurchaseError = 'purchase-error',\n PurchaseVerificationFailed = 'purchase-verification-failed',\n PurchaseVerificationFinishFailed = 'purchase-verification-finish-failed',\n PurchaseVerificationFinished = 'purchase-verification-finished',\n QueryProduct = 'query-product',\n ReceiptFailed = 'receipt-failed',\n ReceiptFinished = 'receipt-finished',\n ReceiptFinishedFailed = 'receipt-finished-failed',\n RemoteError = 'remote-error',\n ServiceDisconnected = 'service-disconnected',\n ServiceError = 'service-error',\n SkuNotFound = 'sku-not-found',\n SkuOfferMismatch = 'sku-offer-mismatch',\n SyncError = 'sync-error',\n TransactionValidationFailed = 'transaction-validation-failed',\n Unknown = 'unknown',\n UserCancelled = 'user-cancelled',\n UserError = 'user-error'\n}\n\n/**\n * Launch mode for external link flow (Android)\n * Determines how the external URL is launched\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type ExternalLinkLaunchModeAndroid = 'unspecified' | 'launch-in-external-browser-or-app' | 'caller-will-launch-link';\n\n/**\n * Link type for external link flow (Android)\n * Specifies the type of external link destination\n * Available in Google Play Billing Library 8.2.0+\n */\nexport type ExternalLinkTypeAndroid = 'unspecified' | 'link-to-digital-content-offer' | 'link-to-app-download';\n\n/**\n * External offer availability result (Android)\n * @deprecated Use BillingProgramAvailabilityResultAndroid with isBillingProgramAvailableAsync instead\n * Available in Google Play Billing Library 6.2.0+, deprecated in 8.2.0\n */\nexport interface ExternalOfferAvailabilityResultAndroid {\n /** Whether external offers are available for the user */\n isAvailable: boolean;\n}\n\n/**\n * External offer reporting details (Android)\n * @deprecated Use BillingProgramReportingDetailsAndroid with createBillingProgramReportingDetailsAsync instead\n * Available in Google Play Billing Library 6.2.0+, deprecated in 8.2.0\n */\nexport interface ExternalOfferReportingDetailsAndroid {\n /** External transaction token for reporting external offer transactions */\n externalTransactionToken: string;\n}\n\n/** Result of presenting an external purchase link (iOS 18.2+) */\nexport interface ExternalPurchaseLinkResultIOS {\n /** Optional error message if the presentation failed */\n error?: (string | null);\n /** Whether the user completed the external purchase flow */\n success: boolean;\n}\n\n/** User actions on external purchase notice sheet (iOS 18.2+) */\nexport type ExternalPurchaseNoticeAction = 'continue' | 'dismissed';\n\n/** Result of presenting external purchase notice sheet (iOS 18.2+) */\nexport interface ExternalPurchaseNoticeResultIOS {\n /** Optional error message if the presentation failed */\n error?: (string | null);\n /** Notice result indicating user action */\n result: ExternalPurchaseNoticeAction;\n}\n\nexport type FetchProductsResult = ProductOrSubscription[] | Product[] | ProductSubscription[] | null;\n\nexport type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android';\n\nexport type IapPlatform = 'ios' | 'android';\n\nexport type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';\n\n/** Unified purchase states from IAPKit verification response. */\nexport type IapkitPurchaseState = 'entitled' | 'pending-acknowledgment' | 'pending' | 'canceled' | 'expired' | 'ready-to-consume' | 'consumed' | 'unknown' | 'inauthentic';\n\n/** Connection initialization configuration */\nexport interface InitConnectionConfig {\n /**\n * Alternative billing mode for Android\n * If not specified, defaults to NONE (standard Google Play billing)\n */\n alternativeBillingModeAndroid?: (AlternativeBillingModeAndroid | null);\n}\n\n/**\n * Parameters for launching an external link (Android)\n * Used with launchExternalLink to initiate external offer or app install flows\n * Available in Google Play Billing Library 8.2.0+\n */\nexport interface LaunchExternalLinkParamsAndroid {\n /** The billing program (EXTERNAL_CONTENT_LINK or EXTERNAL_OFFER) */\n billingProgram: BillingProgramAndroid;\n /** The external link launch mode */\n launchMode: ExternalLinkLaunchModeAndroid;\n /** The type of the external link */\n linkType: ExternalLinkTypeAndroid;\n /** The URI where the content will be accessed from */\n linkUri: string;\n}\n\n/**\n * Limited quantity information for one-time purchase offers (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface LimitedQuantityInfoAndroid {\n /** Maximum quantity a user can purchase */\n maximumQuantity: number;\n /** Remaining quantity the user can still purchase */\n remainingQuantity: number;\n}\n\nexport interface Mutation {\n /** Acknowledge a non-consumable purchase or subscription */\n acknowledgePurchaseAndroid: Promise<boolean>;\n /** Initiate a refund request for a product (iOS 15+) */\n beginRefundRequestIOS?: Promise<(string | null)>;\n /**\n * Check if alternative billing is available for this user/device\n * Step 1 of alternative billing flow\n *\n * Returns true if available, false otherwise\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n checkAlternativeBillingAvailabilityAndroid: Promise<boolean>;\n /** Clear pending transactions from the StoreKit payment queue */\n clearTransactionIOS: Promise<boolean>;\n /** Consume a purchase token so it can be repurchased */\n consumePurchaseAndroid: Promise<boolean>;\n /**\n * Create external transaction token for Google Play reporting\n * Step 3 of alternative billing flow\n * Must be called AFTER successful payment in your payment system\n * Token must be reported to Google Play backend within 24 hours\n *\n * Returns token string, or null if creation failed\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n createAlternativeBillingTokenAndroid?: Promise<(string | null)>;\n /**\n * Create reporting details for a billing program\n * Replaces the deprecated createExternalOfferReportingDetailsAsync API\n *\n * Available in Google Play Billing Library 8.2.0+\n * Returns external transaction token needed for reporting external transactions\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n createBillingProgramReportingDetailsAndroid: Promise<BillingProgramReportingDetailsAndroid>;\n /** Open the native subscription management surface */\n deepLinkToSubscriptions: Promise<void>;\n /** Close the platform billing connection */\n endConnection: Promise<boolean>;\n /** Finish a transaction after validating receipts */\n finishTransaction: Promise<void>;\n /** Establish the platform billing connection */\n initConnection: Promise<boolean>;\n /**\n * Check if a billing program is available for the current user\n * Replaces the deprecated isExternalOfferAvailableAsync API\n *\n * Available in Google Play Billing Library 8.2.0+\n * Returns availability result with isAvailable flag\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n isBillingProgramAvailableAndroid: Promise<BillingProgramAvailabilityResultAndroid>;\n /**\n * Launch external link flow for external billing programs\n * Replaces the deprecated showExternalOfferInformationDialog API\n *\n * Available in Google Play Billing Library 8.2.0+\n * Shows Play Store dialog and optionally launches external URL\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n launchExternalLinkAndroid: Promise<boolean>;\n /** Present the App Store code redemption sheet */\n presentCodeRedemptionSheetIOS: Promise<boolean>;\n /** Present external purchase custom link with StoreKit UI (iOS 18.2+) */\n presentExternalPurchaseLinkIOS: Promise<ExternalPurchaseLinkResultIOS>;\n /** Present external purchase notice sheet (iOS 18.2+) */\n presentExternalPurchaseNoticeSheetIOS: Promise<ExternalPurchaseNoticeResultIOS>;\n /** Initiate a purchase flow; rely on events for final state */\n requestPurchase?: Promise<(Purchase | Purchase[] | null)>;\n /**\n * Purchase the promoted product surfaced by the App Store.\n *\n * @deprecated Use promotedProductListenerIOS to receive the productId,\n * then call requestPurchase with that SKU instead. In StoreKit 2,\n * promoted products can be purchased directly via the standard purchase flow.\n * @deprecated Use promotedProductListenerIOS + requestPurchase instead\n */\n requestPurchaseOnPromotedProductIOS: boolean;\n /** Restore completed purchases across platforms */\n restorePurchases: Promise<void>;\n /**\n * Show alternative billing information dialog to user\n * Step 2 of alternative billing flow\n * Must be called BEFORE processing payment in your payment system\n *\n * Returns true if user accepted, false if user canceled\n * Throws OpenIapError.NotPrepared if billing client not ready\n */\n showAlternativeBillingDialogAndroid: Promise<boolean>;\n /** Open subscription management UI and return changed purchases (iOS 15+) */\n showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;\n /** Force a StoreKit sync for transactions (iOS 15+) */\n syncIOS: Promise<boolean>;\n /**\n * Validate purchase receipts with the configured providers\n * @deprecated Use verifyPurchase\n */\n validateReceipt: Promise<VerifyPurchaseResult>;\n /** Verify purchases with the configured providers */\n verifyPurchase: Promise<VerifyPurchaseResult>;\n /** Verify purchases with a specific provider (e.g., IAPKit) */\n verifyPurchaseWithProvider: Promise<VerifyPurchaseWithProviderResult>;\n}\n\n\n\nexport type MutationAcknowledgePurchaseAndroidArgs = string;\n\nexport type MutationBeginRefundRequestIosArgs = string;\n\nexport type MutationConsumePurchaseAndroidArgs = string;\n\nexport type MutationCreateBillingProgramReportingDetailsAndroidArgs = BillingProgramAndroid;\n\nexport type MutationDeepLinkToSubscriptionsArgs = (DeepLinkOptions | null) | undefined;\n\nexport interface MutationFinishTransactionArgs {\n isConsumable?: (boolean | null);\n purchase: PurchaseInput;\n}\n\n\nexport type MutationInitConnectionArgs = (InitConnectionConfig | null) | undefined;\n\nexport type MutationIsBillingProgramAvailableAndroidArgs = BillingProgramAndroid;\n\nexport type MutationLaunchExternalLinkAndroidArgs = LaunchExternalLinkParamsAndroid;\n\nexport type MutationPresentExternalPurchaseLinkIosArgs = string;\n\nexport type MutationRequestPurchaseArgs =\n | {\n /** Per-platform purchase request props */\n request: RequestPurchasePropsByPlatforms;\n type: 'in-app';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n }\n | {\n /** Per-platform subscription request props */\n request: RequestSubscriptionPropsByPlatforms;\n type: 'subs';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n };\n\n\nexport type MutationValidateReceiptArgs = VerifyPurchaseProps;\n\nexport type MutationVerifyPurchaseArgs = VerifyPurchaseProps;\n\nexport type MutationVerifyPurchaseWithProviderArgs = VerifyPurchaseWithProviderProps;\n\nexport type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';\n\n/**\n * Pre-order details for one-time purchase products (Android)\n * Available in Google Play Billing Library 8.1.0+\n */\nexport interface PreorderDetailsAndroid {\n /**\n * Pre-order presale end time in milliseconds since epoch.\n * This is when the presale period ends and the product will be released.\n */\n preorderPresaleEndTimeMillis: string;\n /**\n * Pre-order release time in milliseconds since epoch.\n * This is when the product will be available to users who pre-ordered.\n */\n preorderReleaseTimeMillis: string;\n}\n\nexport interface PricingPhaseAndroid {\n billingCycleCount: number;\n billingPeriod: string;\n formattedPrice: string;\n priceAmountMicros: string;\n priceCurrencyCode: string;\n recurrenceMode: number;\n}\n\nexport interface PricingPhasesAndroid {\n pricingPhaseList: PricingPhaseAndroid[];\n}\n\nexport type Product = ProductAndroid | ProductIOS;\n\nexport interface ProductAndroid extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n nameAndroid: string;\n /**\n * One-time purchase offer details including discounts (Android)\n * Returns all eligible offers. Available in Google Play Billing Library 7.0+\n */\n oneTimePurchaseOfferDetailsAndroid?: (ProductAndroidOneTimePurchaseOfferDetail[] | null);\n platform: 'android';\n price?: (number | null);\n subscriptionOfferDetailsAndroid?: (ProductSubscriptionAndroidOfferDetails[] | null);\n title: string;\n type: 'in-app';\n}\n\n/**\n * One-time purchase offer details (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface ProductAndroidOneTimePurchaseOfferDetail {\n /**\n * Discount display information\n * Only available for discounted offers\n */\n discountDisplayInfo?: (DiscountDisplayInfoAndroid | null);\n formattedPrice: string;\n /**\n * Full (non-discounted) price in micro-units\n * Only available for discounted offers\n */\n fullPriceMicros?: (string | null);\n /** Limited quantity information */\n limitedQuantityInfo?: (LimitedQuantityInfoAndroid | null);\n /** Offer ID */\n offerId?: (string | null);\n /** List of offer tags */\n offerTags: string[];\n /** Offer token for use in BillingFlowParams when purchasing */\n offerToken: string;\n /**\n * Pre-order details for products available for pre-order\n * Available in Google Play Billing Library 8.1.0+\n */\n preorderDetailsAndroid?: (PreorderDetailsAndroid | null);\n priceAmountMicros: string;\n priceCurrencyCode: string;\n /** Rental details for rental offers */\n rentalDetailsAndroid?: (RentalDetailsAndroid | null);\n /** Valid time window for the offer */\n validTimeWindow?: (ValidTimeWindowAndroid | null);\n}\n\nexport interface ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n platform: 'android' | 'ios';\n price?: (number | null);\n title: string;\n type: 'in-app' | 'subs';\n} \n\nexport interface ProductIOS extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayNameIOS: string;\n displayPrice: string;\n id: string;\n isFamilyShareableIOS: boolean;\n jsonRepresentationIOS: string;\n platform: 'ios';\n price?: (number | null);\n subscriptionInfoIOS?: (SubscriptionInfoIOS | null);\n title: string;\n type: 'in-app';\n typeIOS: ProductTypeIOS;\n}\n\nexport type ProductOrSubscription = Product | ProductSubscription;\n\nexport type ProductQueryType = 'in-app' | 'subs' | 'all';\n\nexport interface ProductRequest {\n skus: string[];\n type?: (ProductQueryType | null);\n}\n\nexport type ProductSubscription = ProductSubscriptionAndroid | ProductSubscriptionIOS;\n\nexport interface ProductSubscriptionAndroid extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n displayName?: (string | null);\n displayPrice: string;\n id: string;\n nameAndroid: string;\n /**\n * One-time purchase offer details including discounts (Android)\n * Returns all eligible offers. Available in Google Play Billing Library 7.0+\n */\n oneTimePurchaseOfferDetailsAndroid?: (ProductAndroidOneTimePurchaseOfferDetail[] | null);\n platform: 'android';\n price?: (number | null);\n subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[];\n title: string;\n type: 'subs';\n}\n\nexport interface ProductSubscriptionAndroidOfferDetails {\n basePlanId: string;\n offerId?: (string | null);\n offerTags: string[];\n offerToken: string;\n pricingPhases: PricingPhasesAndroid;\n}\n\nexport interface ProductSubscriptionIOS extends ProductCommon {\n currency: string;\n debugDescription?: (string | null);\n description: string;\n discountsIOS?: (DiscountIOS[] | null);\n displayName?: (string | null);\n displayNameIOS: string;\n displayPrice: string;\n id: string;\n introductoryPriceAsAmountIOS?: (string | null);\n introductoryPriceIOS?: (string | null);\n introductoryPriceNumberOfPeriodsIOS?: (string | null);\n introductoryPricePaymentModeIOS: PaymentModeIOS;\n introductoryPriceSubscriptionPeriodIOS?: (SubscriptionPeriodIOS | null);\n isFamilyShareableIOS: boolean;\n jsonRepresentationIOS: string;\n platform: 'ios';\n price?: (number | null);\n subscriptionInfoIOS?: (SubscriptionInfoIOS | null);\n subscriptionPeriodNumberIOS?: (string | null);\n subscriptionPeriodUnitIOS?: (SubscriptionPeriodIOS | null);\n title: string;\n type: 'subs';\n typeIOS: ProductTypeIOS;\n}\n\nexport type ProductType = 'in-app' | 'subs';\n\nexport type ProductTypeIOS = 'consumable' | 'non-consumable' | 'auto-renewable-subscription' | 'non-renewing-subscription';\n\nexport type Purchase = PurchaseAndroid | PurchaseIOS;\n\nexport interface PurchaseAndroid extends PurchaseCommon {\n autoRenewingAndroid?: (boolean | null);\n currentPlanId?: (string | null);\n dataAndroid?: (string | null);\n developerPayloadAndroid?: (string | null);\n id: string;\n ids?: (string[] | null);\n isAcknowledgedAndroid?: (boolean | null);\n isAutoRenewing: boolean;\n /**\n * Whether the subscription is suspended (Android)\n * A suspended subscription means the user's payment method failed and they need to fix it.\n * Users should be directed to the subscription center to resolve the issue.\n * Do NOT grant entitlements for suspended subscriptions.\n * Available in Google Play Billing Library 8.1.0+\n */\n isSuspendedAndroid?: (boolean | null);\n obfuscatedAccountIdAndroid?: (string | null);\n obfuscatedProfileIdAndroid?: (string | null);\n packageNameAndroid?: (string | null);\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n purchaseToken?: (string | null);\n quantity: number;\n signatureAndroid?: (string | null);\n /** Store where purchase was made */\n store: IapStore;\n transactionDate: number;\n transactionId?: (string | null);\n}\n\nexport interface PurchaseCommon {\n /**\n * The current plan identifier. This is:\n * - On Android: the basePlanId (e.g., \"premium\", \"premium-year\")\n * - On iOS: the productId (e.g., \"com.example.premium_monthly\", \"com.example.premium_yearly\")\n * This provides a unified way to identify which specific plan/tier the user is subscribed to.\n */\n currentPlanId?: (string | null);\n id: string;\n ids?: (string[] | null);\n isAutoRenewing: boolean;\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n /** Unified purchase token (iOS JWS, Android purchaseToken) */\n purchaseToken?: (string | null);\n quantity: number;\n /** Store where purchase was made */\n store: IapStore;\n transactionDate: number;\n}\n\nexport interface PurchaseError {\n code: ErrorCode;\n message: string;\n productId?: (string | null);\n}\n\nexport interface PurchaseIOS extends PurchaseCommon {\n appAccountToken?: (string | null);\n appBundleIdIOS?: (string | null);\n countryCodeIOS?: (string | null);\n currencyCodeIOS?: (string | null);\n currencySymbolIOS?: (string | null);\n currentPlanId?: (string | null);\n environmentIOS?: (string | null);\n expirationDateIOS?: (number | null);\n id: string;\n ids?: (string[] | null);\n isAutoRenewing: boolean;\n isUpgradedIOS?: (boolean | null);\n offerIOS?: (PurchaseOfferIOS | null);\n originalTransactionDateIOS?: (number | null);\n originalTransactionIdentifierIOS?: (string | null);\n ownershipTypeIOS?: (string | null);\n /** @deprecated Use store instead */\n platform: IapPlatform;\n productId: string;\n purchaseState: PurchaseState;\n purchaseToken?: (string | null);\n quantity: number;\n quantityIOS?: (number | null);\n reasonIOS?: (string | null);\n reasonStringRepresentationIOS?: (string | null);\n renewalInfoIOS?: (RenewalInfoIOS | null);\n revocationDateIOS?: (number | null);\n revocationReasonIOS?: (string | null);\n /** Store where purchase was made */\n store: IapStore;\n storefrontCountryCodeIOS?: (string | null);\n subscriptionGroupIdIOS?: (string | null);\n transactionDate: number;\n transactionId: string;\n transactionReasonIOS?: (string | null);\n webOrderLineItemIdIOS?: (string | null);\n}\n\nexport type PurchaseInput = Purchase;\n\nexport interface PurchaseOfferIOS {\n id: string;\n paymentMode: string;\n type: string;\n}\n\nexport interface PurchaseOptions {\n /** Also emit results through the iOS event listeners */\n alsoPublishToEventListenerIOS?: (boolean | null);\n /** Limit to currently active items on iOS */\n onlyIncludeActiveItemsIOS?: (boolean | null);\n}\n\nexport type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';\n\nexport type PurchaseVerificationProvider = 'iapkit';\n\nexport interface Query {\n /** Check if external purchase notice sheet can be presented (iOS 18.2+) */\n canPresentExternalPurchaseNoticeIOS: Promise<boolean>;\n /** Get current StoreKit 2 entitlements (iOS 15+) */\n currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;\n /** Retrieve products or subscriptions from the store */\n fetchProducts: Promise<(ProductOrSubscription[] | Product[] | ProductSubscription[] | null)>;\n /** Get active subscriptions (filters by subscriptionIds when provided) */\n getActiveSubscriptions: Promise<ActiveSubscription[]>;\n /** Fetch the current app transaction (iOS 16+) */\n getAppTransactionIOS?: Promise<(AppTransaction | null)>;\n /** Get all available purchases for the current user */\n getAvailablePurchases: Promise<Purchase[]>;\n /** Retrieve all pending transactions in the StoreKit queue */\n getPendingTransactionsIOS: Promise<PurchaseIOS[]>;\n /** Get the currently promoted product (iOS 11+) */\n getPromotedProductIOS?: Promise<(ProductIOS | null)>;\n /** Get base64-encoded receipt data for validation */\n getReceiptDataIOS?: Promise<(string | null)>;\n /** Get the current storefront country code */\n getStorefront: Promise<string>;\n /**\n * Get the current App Store storefront country code\n * @deprecated Use getStorefront\n */\n getStorefrontIOS: Promise<string>;\n /** Get the transaction JWS (StoreKit 2) */\n getTransactionJwsIOS?: Promise<(string | null)>;\n /** Check whether the user has active subscriptions */\n hasActiveSubscriptions: Promise<boolean>;\n /** Check introductory offer eligibility for a subscription group */\n isEligibleForIntroOfferIOS: Promise<boolean>;\n /** Verify a StoreKit 2 transaction signature */\n isTransactionVerifiedIOS: Promise<boolean>;\n /** Get the latest transaction for a product using StoreKit 2 */\n latestTransactionIOS?: Promise<(PurchaseIOS | null)>;\n /** Get StoreKit 2 subscription status details (iOS 15+) */\n subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;\n /**\n * Validate a receipt for a specific product\n * @deprecated Use verifyPurchase\n */\n validateReceiptIOS: Promise<VerifyPurchaseResultIOS>;\n}\n\n\n\nexport type QueryCurrentEntitlementIosArgs = string;\n\nexport type QueryFetchProductsArgs = ProductRequest;\n\nexport type QueryGetActiveSubscriptionsArgs = (string[] | null) | undefined;\n\nexport type QueryGetAvailablePurchasesArgs = (PurchaseOptions | null) | undefined;\n\nexport type QueryGetTransactionJwsIosArgs = string;\n\nexport type QueryHasActiveSubscriptionsArgs = (string[] | null) | undefined;\n\nexport type QueryIsEligibleForIntroOfferIosArgs = string;\n\nexport type QueryIsTransactionVerifiedIosArgs = string;\n\nexport type QueryLatestTransactionIosArgs = string;\n\nexport type QuerySubscriptionStatusIosArgs = string;\n\nexport type QueryValidateReceiptIosArgs = VerifyPurchaseProps;\n\nexport interface RefundResultIOS {\n message?: (string | null);\n status: string;\n}\n\n/**\n * Subscription renewal information from Product.SubscriptionInfo.RenewalInfo\n * https://developer.apple.com/documentation/storekit/product/subscriptioninfo/renewalinfo\n */\nexport interface RenewalInfoIOS {\n autoRenewPreference?: (string | null);\n /**\n * When subscription expires due to cancellation/billing issue\n * Possible values: \"VOLUNTARY\", \"BILLING_ERROR\", \"DID_NOT_AGREE_TO_PRICE_INCREASE\", \"PRODUCT_NOT_AVAILABLE\", \"UNKNOWN\"\n */\n expirationReason?: (string | null);\n /**\n * Grace period expiration date (milliseconds since epoch)\n * When set, subscription is in grace period (billing issue but still has access)\n */\n gracePeriodExpirationDate?: (number | null);\n /**\n * True if subscription failed to renew due to billing issue and is retrying\n * Note: Not directly available in RenewalInfo, available in Status\n */\n isInBillingRetry?: (boolean | null);\n jsonRepresentation?: (string | null);\n /**\n * Product ID that will be used on next renewal (when user upgrades/downgrades)\n * If set and different from current productId, subscription will change on expiration\n */\n pendingUpgradeProductId?: (string | null);\n /**\n * User's response to subscription price increase\n * Possible values: \"AGREED\", \"PENDING\", null (no price increase)\n */\n priceIncreaseStatus?: (string | null);\n /**\n * Expected renewal date (milliseconds since epoch)\n * For active subscriptions, when the next renewal/charge will occur\n */\n renewalDate?: (number | null);\n /** Offer ID applied to next renewal (promotional offer, subscription offer code, etc.) */\n renewalOfferId?: (string | null);\n /**\n * Type of offer applied to next renewal\n * Possible values: \"PROMOTIONAL\", \"SUBSCRIPTION_OFFER_CODE\", \"WIN_BACK\", etc.\n */\n renewalOfferType?: (string | null);\n willAutoRenew: boolean;\n}\n\n/**\n * Rental details for one-time purchase products that can be rented (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface RentalDetailsAndroid {\n /**\n * Rental expiration period in ISO 8601 format\n * Time after rental period ends when user can still extend\n */\n rentalExpirationPeriod?: (string | null);\n /** Rental period in ISO 8601 format (e.g., P7D for 7 days) */\n rentalPeriod: string;\n}\n\nexport interface RequestPurchaseAndroidProps {\n /** Personalized offer flag */\n isOfferPersonalized?: (boolean | null);\n /** Obfuscated account ID */\n obfuscatedAccountIdAndroid?: (string | null);\n /** Obfuscated profile ID */\n obfuscatedProfileIdAndroid?: (string | null);\n /** List of product SKUs */\n skus: string[];\n}\n\nexport interface RequestPurchaseIosProps {\n /**\n * Advanced commerce data token (iOS 15+).\n * Used with StoreKit 2's Product.PurchaseOption.custom API for passing\n * campaign tokens, affiliate IDs, or other attribution data.\n * The data is formatted as JSON: {\"signatureInfo\": {\"token\": \"<value>\"}}\n */\n advancedCommerceData?: (string | null);\n /** Auto-finish transaction (dangerous) */\n andDangerouslyFinishTransactionAutomatically?: (boolean | null);\n /** App account token for user tracking */\n appAccountToken?: (string | null);\n /** Purchase quantity */\n quantity?: (number | null);\n /** Product SKU */\n sku: string;\n /** Discount offer to apply */\n withOffer?: (DiscountOfferInputIOS | null);\n}\n\nexport type RequestPurchaseProps =\n | {\n /** Per-platform purchase request props */\n request: RequestPurchasePropsByPlatforms;\n type: 'in-app';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n }\n | {\n /** Per-platform subscription request props */\n request: RequestSubscriptionPropsByPlatforms;\n type: 'subs';\n /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */\n useAlternativeBilling?: boolean | null;\n };\n\n/**\n * Platform-specific purchase request parameters.\n *\n * Note: \"Platforms\" refers to the SDK/OS level (apple, google), not the store.\n * - apple: Always targets App Store\n * - google: Targets Play Store by default, or Horizon when built with horizon flavor\n * (determined at build time, not runtime)\n */\nexport interface RequestPurchasePropsByPlatforms {\n /** @deprecated Use google instead */\n android?: (RequestPurchaseAndroidProps | null);\n /** Apple-specific purchase parameters */\n apple?: (RequestPurchaseIosProps | null);\n /** Google-specific purchase parameters */\n google?: (RequestPurchaseAndroidProps | null);\n /** @deprecated Use apple instead */\n ios?: (RequestPurchaseIosProps | null);\n}\n\nexport type RequestPurchaseResult = Purchase | Purchase[] | null;\n\nexport interface RequestSubscriptionAndroidProps {\n /** Personalized offer flag */\n isOfferPersonalized?: (boolean | null);\n /** Obfuscated account ID */\n obfuscatedAccountIdAndroid?: (string | null);\n /** Obfuscated profile ID */\n obfuscatedProfileIdAndroid?: (string | null);\n /** Purchase token for upgrades/downgrades */\n purchaseTokenAndroid?: (string | null);\n /**\n * Replacement mode for subscription changes\n * @deprecated Use subscriptionProductReplacementParams instead for item-level replacement (8.1.0+)\n */\n replacementModeAndroid?: (number | null);\n /** List of subscription SKUs */\n skus: string[];\n /** Subscription offers */\n subscriptionOffers?: (AndroidSubscriptionOfferInput[] | null);\n /**\n * Product-level replacement parameters (8.1.0+)\n * Use this instead of replacementModeAndroid for item-level replacement\n */\n subscriptionProductReplacementParams?: (SubscriptionProductReplacementParamsAndroid | null);\n}\n\nexport interface RequestSubscriptionIosProps {\n /**\n * Advanced commerce data token (iOS 15+).\n * Used with StoreKit 2's Product.PurchaseOption.custom API for passing\n * campaign tokens, affiliate IDs, or other attribution data.\n * The data is formatted as JSON: {\"signatureInfo\": {\"token\": \"<value>\"}}\n */\n advancedCommerceData?: (string | null);\n andDangerouslyFinishTransactionAutomatically?: (boolean | null);\n appAccountToken?: (string | null);\n quantity?: (number | null);\n sku: string;\n withOffer?: (DiscountOfferInputIOS | null);\n}\n\n/**\n * Platform-specific subscription request parameters.\n *\n * Note: \"Platforms\" refers to the SDK/OS level (apple, google), not the store.\n * - apple: Always targets App Store\n * - google: Targets Play Store by default, or Horizon when built with horizon flavor\n * (determined at build time, not runtime)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n /** @deprecated Use google instead */\n android?: (RequestSubscriptionAndroidProps | null);\n /** Apple-specific subscription parameters */\n apple?: (RequestSubscriptionIosProps | null);\n /** Google-specific subscription parameters */\n google?: (RequestSubscriptionAndroidProps | null);\n /** @deprecated Use apple instead */\n ios?: (RequestSubscriptionIosProps | null);\n}\n\nexport interface RequestVerifyPurchaseWithIapkitAppleProps {\n /** The JWS token returned with the purchase response. */\n jws: string;\n}\n\nexport interface RequestVerifyPurchaseWithIapkitGoogleProps {\n /** The token provided to the user's device when the product or subscription was purchased. */\n purchaseToken: string;\n}\n\n/**\n * Platform-specific verification parameters for IAPKit.\n *\n * - apple: Verifies via App Store (JWS token)\n * - google: Verifies via Play Store (purchase token)\n */\nexport interface RequestVerifyPurchaseWithIapkitProps {\n /** API key used for the Authorization header (Bearer {apiKey}). */\n apiKey?: (string | null);\n /** Apple App Store verification parameters. */\n apple?: (RequestVerifyPurchaseWithIapkitAppleProps | null);\n /** Google Play Store verification parameters. */\n google?: (RequestVerifyPurchaseWithIapkitGoogleProps | null);\n}\n\nexport interface RequestVerifyPurchaseWithIapkitResult {\n /** Whether the purchase is valid (not falsified). */\n isValid: boolean;\n /** The current state of the purchase. */\n state: IapkitPurchaseState;\n store: IapStore;\n}\n\nexport interface Subscription {\n /** Fires when the App Store surfaces a promoted product (iOS only) */\n promotedProductIOS: string;\n /** Fires when a purchase fails or is cancelled */\n purchaseError: PurchaseError;\n /** Fires when a purchase completes successfully or a pending purchase resolves */\n purchaseUpdated: Purchase;\n /**\n * Fires when a user selects alternative billing in the User Choice Billing dialog (Android only)\n * Only triggered when the user selects alternative billing instead of Google Play billing\n */\n userChoiceBillingAndroid: UserChoiceBillingDetails;\n}\n\n\nexport interface SubscriptionInfoIOS {\n introductoryOffer?: (SubscriptionOfferIOS | null);\n promotionalOffers?: (SubscriptionOfferIOS[] | null);\n subscriptionGroupId: string;\n subscriptionPeriod: SubscriptionPeriodValueIOS;\n}\n\nexport interface SubscriptionOfferIOS {\n displayPrice: string;\n id: string;\n paymentMode: PaymentModeIOS;\n period: SubscriptionPeriodValueIOS;\n periodCount: number;\n price: number;\n type: SubscriptionOfferTypeIOS;\n}\n\nexport type SubscriptionOfferTypeIOS = 'introductory' | 'promotional';\n\nexport type SubscriptionPeriodIOS = 'day' | 'week' | 'month' | 'year' | 'empty';\n\nexport interface SubscriptionPeriodValueIOS {\n unit: SubscriptionPeriodIOS;\n value: number;\n}\n\n/**\n * Product-level subscription replacement parameters (Android)\n * Used with setSubscriptionProductReplacementParams in BillingFlowParams.ProductDetailsParams\n * Available in Google Play Billing Library 8.1.0+\n */\nexport interface SubscriptionProductReplacementParamsAndroid {\n /** The old product ID that needs to be replaced */\n oldProductId: string;\n /** The replacement mode for this product change */\n replacementMode: SubscriptionReplacementModeAndroid;\n}\n\n/**\n * Replacement mode for subscription changes (Android)\n * These modes determine how the subscription replacement affects billing.\n * Available in Google Play Billing Library 8.1.0+\n */\nexport type SubscriptionReplacementModeAndroid = 'unknown-replacement-mode' | 'with-time-proration' | 'charge-prorated-price' | 'charge-full-price' | 'without-proration' | 'deferred' | 'keep-existing';\n\nexport interface SubscriptionStatusIOS {\n renewalInfo?: (RenewalInfoIOS | null);\n state: string;\n}\n\n/**\n * User Choice Billing event details (Android)\n * Fired when a user selects alternative billing in the User Choice Billing dialog\n */\nexport interface UserChoiceBillingDetails {\n /** Token that must be reported to Google Play within 24 hours */\n externalTransactionToken: string;\n /** List of product IDs selected by the user */\n products: string[];\n}\n\n/**\n * Valid time window for when an offer is available (Android)\n * Available in Google Play Billing Library 7.0+\n */\nexport interface ValidTimeWindowAndroid {\n /** End time in milliseconds since epoch */\n endTimeMillis: string;\n /** Start time in milliseconds since epoch */\n startTimeMillis: string;\n}\n\n/**\n * Apple App Store verification parameters.\n * Used for server-side receipt validation via App Store Server API.\n */\nexport interface VerifyPurchaseAppleOptions {\n /** Product SKU to validate */\n sku: string;\n}\n\n/**\n * Google Play Store verification parameters.\n * Used for server-side receipt validation via Google Play Developer API.\n *\n * ⚠️ SECURITY: Contains sensitive tokens (accessToken, purchaseToken). Do not log or persist this data.\n */\nexport interface VerifyPurchaseGoogleOptions {\n /**\n * Google OAuth2 access token for API authentication.\n * ⚠️ Sensitive: Do not log this value.\n */\n accessToken: string;\n /** Whether this is a subscription purchase (affects API endpoint used) */\n isSub?: (boolean | null);\n /** Android package name (e.g., com.example.app) */\n packageName: string;\n /**\n * Purchase token from the purchase response.\n * ⚠️ Sensitive: Do not log this value.\n */\n purchaseToken: string;\n /** Product SKU to validate */\n sku: string;\n}\n\n/**\n * Meta Horizon (Quest) verification parameters.\n * Used for server-side entitlement verification via Meta's S2S API.\n * POST https://graph.oculus.com/$APP_ID/verify_entitlement\n *\n * ⚠️ SECURITY: Contains sensitive token (accessToken). Do not log or persist this data.\n */\nexport interface VerifyPurchaseHorizonOptions {\n /**\n * Access token for Meta API authentication (OC|$APP_ID|$APP_SECRET or User Access Token).\n * ⚠️ Sensitive: Do not log this value.\n */\n accessToken: string;\n /** The SKU for the add-on item, defined in Meta Developer Dashboard */\n sku: string;\n /** The user ID of the user whose purchase you want to verify */\n userId: string;\n}\n\n/**\n * Platform-specific purchase verification parameters.\n *\n * - apple: Verifies via App Store Server API\n * - google: Verifies via Google Play Developer API\n * - horizon: Verifies via Meta's S2S API (verify_entitlement endpoint)\n */\nexport interface VerifyPurchaseProps {\n /** Apple App Store verification parameters. */\n apple?: (VerifyPurchaseAppleOptions | null);\n /** Google Play Store verification parameters. */\n google?: (VerifyPurchaseGoogleOptions | null);\n /** Meta Horizon (Quest) verification parameters. */\n horizon?: (VerifyPurchaseHorizonOptions | null);\n}\n\nexport type VerifyPurchaseResult = VerifyPurchaseResultAndroid | VerifyPurchaseResultHorizon | VerifyPurchaseResultIOS;\n\nexport interface VerifyPurchaseResultAndroid {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate?: (number | null);\n cancelReason?: (string | null);\n deferredDate?: (number | null);\n deferredSku?: (string | null);\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n}\n\n/**\n * Result from Meta Horizon verify_entitlement API.\n * Returns verification status and grant time for the entitlement.\n */\nexport interface VerifyPurchaseResultHorizon {\n /** Unix timestamp (seconds) when the entitlement was granted. */\n grantTime?: (number | null);\n /** Whether the entitlement verification succeeded. */\n success: boolean;\n}\n\nexport interface VerifyPurchaseResultIOS {\n /** Whether the receipt is valid */\n isValid: boolean;\n /** JWS representation */\n jwsRepresentation: string;\n /** Latest transaction if available */\n latestTransaction?: (Purchase | null);\n /** Receipt data string */\n receiptData: string;\n}\n\nexport interface VerifyPurchaseWithProviderError {\n code?: (string | null);\n message: string;\n}\n\nexport interface VerifyPurchaseWithProviderProps {\n iapkit?: (RequestVerifyPurchaseWithIapkitProps | null);\n provider: PurchaseVerificationProvider;\n}\n\nexport interface VerifyPurchaseWithProviderResult {\n /** Error details if verification failed */\n errors?: (VerifyPurchaseWithProviderError[] | null);\n /** IAPKit verification result */\n iapkit?: (RequestVerifyPurchaseWithIapkitResult | null);\n provider: PurchaseVerificationProvider;\n}\n\nexport type VoidResult = void;\n\n// -- Query helper types (auto-generated)\nexport type QueryArgsMap = {\n canPresentExternalPurchaseNoticeIOS: never;\n currentEntitlementIOS: QueryCurrentEntitlementIosArgs;\n fetchProducts: QueryFetchProductsArgs;\n getActiveSubscriptions: QueryGetActiveSubscriptionsArgs;\n getAppTransactionIOS: never;\n getAvailablePurchases: QueryGetAvailablePurchasesArgs;\n getPendingTransactionsIOS: never;\n getPromotedProductIOS: never;\n getReceiptDataIOS: never;\n getStorefront: never;\n getStorefrontIOS: never;\n getTransactionJwsIOS: QueryGetTransactionJwsIosArgs;\n hasActiveSubscriptions: QueryHasActiveSubscriptionsArgs;\n isEligibleForIntroOfferIOS: QueryIsEligibleForIntroOfferIosArgs;\n isTransactionVerifiedIOS: QueryIsTransactionVerifiedIosArgs;\n latestTransactionIOS: QueryLatestTransactionIosArgs;\n subscriptionStatusIOS: QuerySubscriptionStatusIosArgs;\n validateReceiptIOS: QueryValidateReceiptIosArgs;\n};\n\nexport type QueryField<K extends keyof Query> =\n QueryArgsMap[K] extends never\n ? () => NonNullable<Query[K]>\n : undefined extends QueryArgsMap[K]\n ? (args?: QueryArgsMap[K]) => NonNullable<Query[K]>\n : (args: QueryArgsMap[K]) => NonNullable<Query[K]>;\n\nexport type QueryFieldMap = {\n [K in keyof Query]?: QueryField<K>;\n};\n// -- End query helper types\n\n// -- Mutation helper types (auto-generated)\nexport type MutationArgsMap = {\n acknowledgePurchaseAndroid: MutationAcknowledgePurchaseAndroidArgs;\n beginRefundRequestIOS: MutationBeginRefundRequestIosArgs;\n checkAlternativeBillingAvailabilityAndroid: never;\n clearTransactionIOS: never;\n consumePurchaseAndroid: MutationConsumePurchaseAndroidArgs;\n createAlternativeBillingTokenAndroid: never;\n createBillingProgramReportingDetailsAndroid: MutationCreateBillingProgramReportingDetailsAndroidArgs;\n deepLinkToSubscriptions: MutationDeepLinkToSubscriptionsArgs;\n endConnection: never;\n finishTransaction: MutationFinishTransactionArgs;\n initConnection: MutationInitConnectionArgs;\n isBillingProgramAvailableAndroid: MutationIsBillingProgramAvailableAndroidArgs;\n launchExternalLinkAndroid: MutationLaunchExternalLinkAndroidArgs;\n presentCodeRedemptionSheetIOS: never;\n presentExternalPurchaseLinkIOS: MutationPresentExternalPurchaseLinkIosArgs;\n presentExternalPurchaseNoticeSheetIOS: never;\n requestPurchase: MutationRequestPurchaseArgs;\n requestPurchaseOnPromotedProductIOS: never;\n restorePurchases: never;\n showAlternativeBillingDialogAndroid: never;\n showManageSubscriptionsIOS: never;\n syncIOS: never;\n validateReceipt: MutationValidateReceiptArgs;\n verifyPurchase: MutationVerifyPurchaseArgs;\n verifyPurchaseWithProvider: MutationVerifyPurchaseWithProviderArgs;\n};\n\nexport type MutationField<K extends keyof Mutation> =\n MutationArgsMap[K] extends never\n ? () => NonNullable<Mutation[K]>\n : undefined extends MutationArgsMap[K]\n ? (args?: MutationArgsMap[K]) => NonNullable<Mutation[K]>\n : (args: MutationArgsMap[K]) => NonNullable<Mutation[K]>;\n\nexport type MutationFieldMap = {\n [K in keyof Mutation]?: MutationField<K>;\n};\n// -- End mutation helper types\n\n// -- Subscription helper types (auto-generated)\nexport type SubscriptionArgsMap = {\n promotedProductIOS: never;\n purchaseError: never;\n purchaseUpdated: never;\n userChoiceBillingAndroid: never;\n};\n\nexport type SubscriptionField<K extends keyof Subscription> =\n SubscriptionArgsMap[K] extends never\n ? () => NonNullable<Subscription[K]>\n : undefined extends SubscriptionArgsMap[K]\n ? (args?: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>\n : (args: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>;\n\nexport type SubscriptionFieldMap = {\n [K in keyof Subscription]?: SubscriptionField<K>;\n};\n// -- End subscription helper types\n"]}
|
package/build/useIAP.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ type UseIap = {
|
|
|
24
24
|
verifyPurchaseWithProvider: (props: VerifyPurchaseWithProviderProps) => Promise<VerifyPurchaseWithProviderResult>;
|
|
25
25
|
restorePurchases: () => Promise<void>;
|
|
26
26
|
getPromotedProductIOS: () => Promise<Product | null>;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use promotedProductListenerIOS to receive the productId,
|
|
29
|
+
* then call requestPurchase with that SKU instead.
|
|
30
|
+
*/
|
|
27
31
|
requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
|
|
28
32
|
getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<void>;
|
|
29
33
|
hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;
|
package/build/useIAP.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIAP.d.ts","sourceRoot":"","sources":["../src/useIAP.ts"],"names":[],"mappings":"AAMA,OAAO,EAQL,eAAe,IAAI,uBAAuB,EAO1C,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AAcjB,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EAGnB,QAAQ,EACR,2BAA2B,EAE3B,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,EAGjC,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAC,aAA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AE,MAAM,EAAE,CAAC;YAC9C,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;YAC7C,oBAAoB,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;YAClD,aAAa,EAAE,CAAC;YAChB,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAE/B,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,EAAE,wBAAwB;QACzC,eAAe;QACf,cAAc;QACd,0BAA0B;QAC1B,gBAAgB,EAAE,wBAAwB;QAC1C,kDAAkD;QAClD,qBAAqB;QACrB,mCAAmC;QACnC,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;QACtD,6CAA6C;QAC7C,0CAA0C;QAC1C,mCAAmC;QACnC,oCAAoC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n getAvailablePurchases,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n validateReceipt as validateReceiptInternal,\n verifyPurchase as verifyPurchaseInternal,\n verifyPurchaseWithProvider as verifyPurchaseWithProviderInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n type ActiveSubscription,\n type ProductTypeInput,\n} from './index';\nimport {ExpoIapConsole} from './utils/debug';\nimport {\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n syncIOS,\n} from './modules/ios';\nimport {\n checkAlternativeBillingAvailabilityAndroid,\n showAlternativeBillingDialogAndroid,\n createAlternativeBillingTokenAndroid,\n} from './modules/android';\n\n// Types\nimport type {\n Product,\n ProductSubscription,\n ProductQueryType,\n ProductRequest,\n Purchase,\n MutationRequestPurchaseArgs,\n PurchaseInput,\n VerifyPurchaseProps,\n VerifyPurchaseResult,\n VerifyPurchaseWithProviderProps,\n VerifyPurchaseWithProviderResult,\n ProductAndroid,\n ProductSubscriptionIOS,\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\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: () => 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 /** @deprecated Use verifyPurchase instead */\n validateReceipt: (\n props: VerifyPurchaseProps,\n ) => Promise<VerifyPurchaseResult>;\n verifyPurchase: (props: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;\n verifyPurchaseWithProvider: (\n props: VerifyPurchaseWithProviderProps,\n ) => Promise<VerifyPurchaseWithProviderResult>;\n restorePurchases: () => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;\n getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<void>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n checkAlternativeBillingAvailabilityAndroid: () => Promise<boolean>;\n showAlternativeBillingDialogAndroid: () => Promise<boolean>;\n createAlternativeBillingTokenAndroid: (\n sku?: string,\n ) => Promise<string | null>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n onPromotedProductIOS?: (product: Product) => void;\n /**\n * Alternative billing mode for Android\n * If not specified, defaults to NONE (standard Google Play billing)\n */\n alternativeBillingModeAndroid?: 'none' | 'user-choice' | 'alternative-only';\n}\n\n/**\n * React Hook for managing In-App Purchases.\n * See documentation at https://hyochan.github.io/expo-iap/docs/hooks/useIAP\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\n // Helper function to merge arrays with duplicate checking\n const mergeWithDuplicateCheck = useCallback(\n <T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n ): T[] => {\n const merged = [...existingItems];\n newItems.forEach((newItem) => {\n const isDuplicate = merged.some(\n (existingItem) => getKey(existingItem) === getKey(newItem),\n );\n if (!isDuplicate) {\n merged.push(newItem);\n }\n });\n return merged;\n },\n [],\n );\n\n useEffect(() => {\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 }>({});\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 === 'inapp' || 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 id: purchase.id,\n ids: purchase.ids ?? undefined,\n isAutoRenewing: purchase.isAutoRenewing,\n platform: purchase.platform,\n productId: purchase.productId,\n purchaseState: purchase.purchaseState,\n purchaseToken: purchase.purchaseToken ?? null,\n quantity: purchase.quantity,\n store: purchase.store,\n transactionDate: purchase.transactionDate,\n transactionId: purchase.transactionId,\n }),\n [],\n );\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 mergeWithDuplicateCheck(\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 mergeWithDuplicateCheck(\n prevProducts,\n productsResult,\n (product) => product.id,\n ),\n );\n } else {\n // For 'all' type, need to properly distinguish between products and subscriptions\n // On Android, check subscriptionOfferDetailsAndroid to determine if it's a real subscription\n const productItems = items.filter((item) => {\n // iOS: check type\n if (Platform.OS === 'ios') {\n return canonicalProductType(item.type as string) === 'in-app';\n }\n // Android: check if it has actual subscription details\n const androidItem = item as ProductAndroid;\n return (\n !androidItem.subscriptionOfferDetailsAndroid ||\n (Array.isArray(androidItem.subscriptionOfferDetailsAndroid) &&\n androidItem.subscriptionOfferDetailsAndroid.length === 0)\n );\n }) as Product[];\n\n const subscriptionItems = items.filter((item) => {\n // iOS: check type\n if (Platform.OS === 'ios') {\n return (\n canonicalProductType(\n item.type as ProductSubscriptionIOS['type'],\n ) === 'subs'\n );\n }\n // Android: check if it has actual subscription details\n const androidItem = item as ProductAndroid;\n\n return (\n androidItem.subscriptionOfferDetailsAndroid &&\n Array.isArray(androidItem.subscriptionOfferDetailsAndroid) &&\n androidItem.subscriptionOfferDetailsAndroid.length > 0\n );\n }) as ProductSubscription[];\n\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n productItems,\n (product) => product.id,\n ),\n );\n\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n subscriptionItems,\n (subscription) => subscription.id,\n ),\n );\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching products:', error);\n }\n },\n [canonicalProductType, mergeWithDuplicateCheck, normalizeProductQueryType],\n );\n\n const getAvailablePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n const result = await getAvailablePurchases({\n alsoPublishToEventListenerIOS: false,\n onlyIncludeActiveItemsIOS: true,\n });\n setAvailablePurchases(result);\n } catch (error) {\n ExpoIapConsole.error('Error fetching available purchases:', error);\n }\n }, []);\n\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<void> => {\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n setActiveSubscriptions(result);\n } catch (error) {\n ExpoIapConsole.error('Error getting active subscriptions:', error);\n // Preserve existing state on error\n }\n },\n [],\n );\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 return false;\n }\n },\n [],\n );\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 const requestPurchaseWithReset = useCallback(\n (requestObj: MutationRequestPurchaseArgs) => {\n return requestPurchaseInternal(requestObj);\n },\n [],\n );\n\n const refreshSubscriptionStatus = useCallback(\n async (productId: string) => {\n try {\n if (subscriptionsRefState.current.some((sub) => sub.id === productId)) {\n await fetchProductsInternal({skus: [productId], type: 'subs'});\n await getAvailablePurchasesInternal();\n }\n } catch (error) {\n ExpoIapConsole.warn('Failed to refresh subscription status:', error);\n }\n },\n [fetchProductsInternal, getAvailablePurchasesInternal],\n );\n\n // Restore completed transactions with cross-platform behavior.\n // iOS: best-effort sync (ignore sync errors) then fetch available purchases.\n // Android: fetch available purchases directly.\n const restorePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n // iOS: Try to sync first, but don't fail if sync errors occur\n if (Platform.OS === 'ios') {\n await syncIOS().catch(() => undefined); // syncIOS returns Promise<boolean>, we don't need the result\n }\n\n const purchases = await getAvailablePurchases({\n alsoPublishToEventListenerIOS: false,\n onlyIncludeActiveItemsIOS: true,\n });\n setAvailablePurchases(purchases);\n } catch (error) {\n ExpoIapConsole.warn('Failed to restore purchases:', error);\n }\n }, []);\n\n const validateReceipt = useCallback(async (props: VerifyPurchaseProps) => {\n return validateReceiptInternal(props);\n }, []);\n\n const verifyPurchase = useCallback(async (props: VerifyPurchaseProps) => {\n return verifyPurchaseInternal(props);\n }, []);\n\n const verifyPurchaseWithProvider = useCallback(\n async (props: VerifyPurchaseWithProviderProps) => {\n return verifyPurchaseWithProviderInternal(props);\n },\n [],\n );\n\n const initIapWithSubscriptions = useCallback(async (): Promise<void> => {\n // CRITICAL: Register listeners BEFORE initConnection to avoid race condition\n // Events might fire immediately after initConnection, so listeners must be ready\n // Register purchase update listener BEFORE initConnection to avoid race conditions.\n subscriptionsRef.current.purchaseUpdate = purchaseUpdatedListener(\n async (purchase: Purchase) => {\n if ('expirationDateIOS' in purchase) {\n await refreshSubscriptionStatus(purchase.id);\n }\n\n if (optionsRef.current?.onPurchaseSuccess) {\n optionsRef.current.onPurchaseSuccess(purchase);\n }\n },\n );\n\n // Register purchase error listener EARLY. Ignore init-related errors until connected.\n subscriptionsRef.current.purchaseError = purchaseErrorListener(\n (error: PurchaseError) => {\n if (!connectedRef.current && error.code === ErrorCode.InitConnection) {\n return; // Ignore initialization error before connected\n }\n const friendly = getUserFriendlyErrorMessage(error);\n if (!isUserCancelledError(error) && !isRecoverableError(error)) {\n ExpoIapConsole.warn('[useIAP] Purchase error:', friendly);\n }\n\n if (optionsRef.current?.onPurchaseError) {\n optionsRef.current.onPurchaseError(error);\n }\n },\n );\n\n if (Platform.OS === 'ios') {\n // iOS promoted products listener\n subscriptionsRef.current.promotedProductIOS = promotedProductListenerIOS(\n (product: Product) => {\n setPromotedProductIOS(product);\n\n if (optionsRef.current?.onPromotedProductIOS) {\n optionsRef.current.onPromotedProductIOS(product);\n }\n },\n );\n }\n\n // NOW call initConnection after listeners are ready\n const config = optionsRef.current?.alternativeBillingModeAndroid\n ? {\n alternativeBillingModeAndroid:\n optionsRef.current.alternativeBillingModeAndroid,\n }\n : undefined;\n const result = await initConnection(config);\n setConnected(result);\n if (!result) {\n // If connection failed, clean up listeners\n ExpoIapConsole.warn(\n '[useIAP] Connection failed, cleaning up listeners...',\n );\n subscriptionsRef.current.purchaseUpdate?.remove();\n subscriptionsRef.current.promotedProductIOS?.remove();\n subscriptionsRef.current.purchaseUpdate = undefined;\n subscriptionsRef.current.promotedProductIOS = undefined;\n // Keep purchaseError listener registered to capture subsequent retries\n return;\n }\n }, [refreshSubscriptionStatus]);\n\n useEffect(() => {\n initIapWithSubscriptions();\n const currentSubscriptions = subscriptionsRef.current;\n\n return () => {\n currentSubscriptions.purchaseUpdate?.remove();\n currentSubscriptions.purchaseError?.remove();\n currentSubscriptions.promotedProductIOS?.remove();\n endConnection();\n setConnected(false);\n };\n }, [initIapWithSubscriptions]);\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: requestPurchaseWithReset,\n validateReceipt,\n verifyPurchase,\n verifyPurchaseWithProvider,\n restorePurchases: restorePurchasesInternal,\n // internal getters kept for hook state management\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n // Alternative billing methods (Android only)\n checkAlternativeBillingAvailabilityAndroid,\n showAlternativeBillingDialogAndroid,\n createAlternativeBillingTokenAndroid,\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,QAAQ,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAGtC,mBAAmB;AACnB,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,IAAI,yBAAyB,EAC9C,eAAe,IAAI,uBAAuB,EAC1C,aAAa,EACb,eAAe,IAAI,uBAAuB,EAC1C,cAAc,IAAI,sBAAsB,EACxC,0BAA0B,IAAI,kCAAkC,EAChE,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,mCAAmC,EACnC,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,0CAA0C,EAC1C,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAAC,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aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,qBAAqB,EAAE,6BAA6B;QACpD,aAAa,EAAE,qBAAqB;QACpC,eAAe,EAAE,wBAAwB;QACzC,eAAe;QACf,cAAc;QACd,0BAA0B;QAC1B,gBAAgB,EAAE,wBAAwB;QAC1C,kDAAkD;QAClD,qBAAqB;QACrB,mCAAmC;QACnC,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;QACtD,6CAA6C;QAC7C,0CAA0C;QAC1C,mCAAmC;QACnC,oCAAoC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n getAvailablePurchases,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n validateReceipt as validateReceiptInternal,\n verifyPurchase as verifyPurchaseInternal,\n verifyPurchaseWithProvider as verifyPurchaseWithProviderInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n type ActiveSubscription,\n type ProductTypeInput,\n} from './index';\nimport {ExpoIapConsole} from './utils/debug';\nimport {\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n syncIOS,\n} from './modules/ios';\nimport {\n checkAlternativeBillingAvailabilityAndroid,\n showAlternativeBillingDialogAndroid,\n createAlternativeBillingTokenAndroid,\n} from './modules/android';\n\n// Types\nimport type {\n Product,\n ProductSubscription,\n ProductQueryType,\n ProductRequest,\n Purchase,\n MutationRequestPurchaseArgs,\n PurchaseInput,\n VerifyPurchaseProps,\n VerifyPurchaseResult,\n VerifyPurchaseWithProviderProps,\n VerifyPurchaseWithProviderResult,\n ProductAndroid,\n ProductSubscriptionIOS,\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\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: () => 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 /** @deprecated Use verifyPurchase instead */\n validateReceipt: (\n props: VerifyPurchaseProps,\n ) => Promise<VerifyPurchaseResult>;\n verifyPurchase: (props: VerifyPurchaseProps) => Promise<VerifyPurchaseResult>;\n verifyPurchaseWithProvider: (\n props: VerifyPurchaseWithProviderProps,\n ) => Promise<VerifyPurchaseWithProviderResult>;\n restorePurchases: () => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n /**\n * @deprecated Use promotedProductListenerIOS to receive the productId,\n * then call requestPurchase with that SKU instead.\n */\n requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;\n getActiveSubscriptions: (subscriptionIds?: string[]) => Promise<void>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n checkAlternativeBillingAvailabilityAndroid: () => Promise<boolean>;\n showAlternativeBillingDialogAndroid: () => Promise<boolean>;\n createAlternativeBillingTokenAndroid: (\n sku?: string,\n ) => Promise<string | null>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n onPromotedProductIOS?: (product: Product) => void;\n /**\n * Alternative billing mode for Android\n * If not specified, defaults to NONE (standard Google Play billing)\n */\n alternativeBillingModeAndroid?: 'none' | 'user-choice' | 'alternative-only';\n}\n\n/**\n * React Hook for managing In-App Purchases.\n * See documentation at https://hyochan.github.io/expo-iap/docs/hooks/useIAP\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\n // Helper function to merge arrays with duplicate checking\n const mergeWithDuplicateCheck = useCallback(\n <T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n ): T[] => {\n const merged = [...existingItems];\n newItems.forEach((newItem) => {\n const isDuplicate = merged.some(\n (existingItem) => getKey(existingItem) === getKey(newItem),\n );\n if (!isDuplicate) {\n merged.push(newItem);\n }\n });\n return merged;\n },\n [],\n );\n\n useEffect(() => {\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 }>({});\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 === 'inapp' || 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 id: purchase.id,\n ids: purchase.ids ?? undefined,\n isAutoRenewing: purchase.isAutoRenewing,\n platform: purchase.platform,\n productId: purchase.productId,\n purchaseState: purchase.purchaseState,\n purchaseToken: purchase.purchaseToken ?? null,\n quantity: purchase.quantity,\n store: purchase.store,\n transactionDate: purchase.transactionDate,\n transactionId: purchase.transactionId,\n }),\n [],\n );\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 mergeWithDuplicateCheck(\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 mergeWithDuplicateCheck(\n prevProducts,\n productsResult,\n (product) => product.id,\n ),\n );\n } else {\n // For 'all' type, need to properly distinguish between products and subscriptions\n // On Android, check subscriptionOfferDetailsAndroid to determine if it's a real subscription\n const productItems = items.filter((item) => {\n // iOS: check type\n if (Platform.OS === 'ios') {\n return canonicalProductType(item.type as string) === 'in-app';\n }\n // Android: check if it has actual subscription details\n const androidItem = item as ProductAndroid;\n return (\n !androidItem.subscriptionOfferDetailsAndroid ||\n (Array.isArray(androidItem.subscriptionOfferDetailsAndroid) &&\n androidItem.subscriptionOfferDetailsAndroid.length === 0)\n );\n }) as Product[];\n\n const subscriptionItems = items.filter((item) => {\n // iOS: check type\n if (Platform.OS === 'ios') {\n return (\n canonicalProductType(\n item.type as ProductSubscriptionIOS['type'],\n ) === 'subs'\n );\n }\n // Android: check if it has actual subscription details\n const androidItem = item as ProductAndroid;\n\n return (\n androidItem.subscriptionOfferDetailsAndroid &&\n Array.isArray(androidItem.subscriptionOfferDetailsAndroid) &&\n androidItem.subscriptionOfferDetailsAndroid.length > 0\n );\n }) as ProductSubscription[];\n\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n productItems,\n (product) => product.id,\n ),\n );\n\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n subscriptionItems,\n (subscription) => subscription.id,\n ),\n );\n }\n } catch (error) {\n ExpoIapConsole.error('Error fetching products:', error);\n }\n },\n [canonicalProductType, mergeWithDuplicateCheck, normalizeProductQueryType],\n );\n\n const getAvailablePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n const result = await getAvailablePurchases({\n alsoPublishToEventListenerIOS: false,\n onlyIncludeActiveItemsIOS: true,\n });\n setAvailablePurchases(result);\n } catch (error) {\n ExpoIapConsole.error('Error fetching available purchases:', error);\n }\n }, []);\n\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<void> => {\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n setActiveSubscriptions(result);\n } catch (error) {\n ExpoIapConsole.error('Error getting active subscriptions:', error);\n // Preserve existing state on error\n }\n },\n [],\n );\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 return false;\n }\n },\n [],\n );\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 const requestPurchaseWithReset = useCallback(\n (requestObj: MutationRequestPurchaseArgs) => {\n return requestPurchaseInternal(requestObj);\n },\n [],\n );\n\n const refreshSubscriptionStatus = useCallback(\n async (productId: string) => {\n try {\n if (subscriptionsRefState.current.some((sub) => sub.id === productId)) {\n await fetchProductsInternal({skus: [productId], type: 'subs'});\n await getAvailablePurchasesInternal();\n }\n } catch (error) {\n ExpoIapConsole.warn('Failed to refresh subscription status:', error);\n }\n },\n [fetchProductsInternal, getAvailablePurchasesInternal],\n );\n\n // Restore completed transactions with cross-platform behavior.\n // iOS: best-effort sync (ignore sync errors) then fetch available purchases.\n // Android: fetch available purchases directly.\n const restorePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n // iOS: Try to sync first, but don't fail if sync errors occur\n if (Platform.OS === 'ios') {\n await syncIOS().catch(() => undefined); // syncIOS returns Promise<boolean>, we don't need the result\n }\n\n const purchases = await getAvailablePurchases({\n alsoPublishToEventListenerIOS: false,\n onlyIncludeActiveItemsIOS: true,\n });\n setAvailablePurchases(purchases);\n } catch (error) {\n ExpoIapConsole.warn('Failed to restore purchases:', error);\n }\n }, []);\n\n const validateReceipt = useCallback(async (props: VerifyPurchaseProps) => {\n return validateReceiptInternal(props);\n }, []);\n\n const verifyPurchase = useCallback(async (props: VerifyPurchaseProps) => {\n return verifyPurchaseInternal(props);\n }, []);\n\n const verifyPurchaseWithProvider = useCallback(\n async (props: VerifyPurchaseWithProviderProps) => {\n return verifyPurchaseWithProviderInternal(props);\n },\n [],\n );\n\n const initIapWithSubscriptions = useCallback(async (): Promise<void> => {\n // CRITICAL: Register listeners BEFORE initConnection to avoid race condition\n // Events might fire immediately after initConnection, so listeners must be ready\n // Register purchase update listener BEFORE initConnection to avoid race conditions.\n subscriptionsRef.current.purchaseUpdate = purchaseUpdatedListener(\n async (purchase: Purchase) => {\n if ('expirationDateIOS' in purchase) {\n await refreshSubscriptionStatus(purchase.id);\n }\n\n if (optionsRef.current?.onPurchaseSuccess) {\n optionsRef.current.onPurchaseSuccess(purchase);\n }\n },\n );\n\n // Register purchase error listener EARLY. Ignore init-related errors until connected.\n subscriptionsRef.current.purchaseError = purchaseErrorListener(\n (error: PurchaseError) => {\n if (!connectedRef.current && error.code === ErrorCode.InitConnection) {\n return; // Ignore initialization error before connected\n }\n const friendly = getUserFriendlyErrorMessage(error);\n if (!isUserCancelledError(error) && !isRecoverableError(error)) {\n ExpoIapConsole.warn('[useIAP] Purchase error:', friendly);\n }\n\n if (optionsRef.current?.onPurchaseError) {\n optionsRef.current.onPurchaseError(error);\n }\n },\n );\n\n if (Platform.OS === 'ios') {\n // iOS promoted products listener\n subscriptionsRef.current.promotedProductIOS = promotedProductListenerIOS(\n (product: Product) => {\n setPromotedProductIOS(product);\n\n if (optionsRef.current?.onPromotedProductIOS) {\n optionsRef.current.onPromotedProductIOS(product);\n }\n },\n );\n }\n\n // NOW call initConnection after listeners are ready\n const config = optionsRef.current?.alternativeBillingModeAndroid\n ? {\n alternativeBillingModeAndroid:\n optionsRef.current.alternativeBillingModeAndroid,\n }\n : undefined;\n const result = await initConnection(config);\n setConnected(result);\n if (!result) {\n // If connection failed, clean up listeners\n ExpoIapConsole.warn(\n '[useIAP] Connection failed, cleaning up listeners...',\n );\n subscriptionsRef.current.purchaseUpdate?.remove();\n subscriptionsRef.current.promotedProductIOS?.remove();\n subscriptionsRef.current.purchaseUpdate = undefined;\n subscriptionsRef.current.promotedProductIOS = undefined;\n // Keep purchaseError listener registered to capture subsequent retries\n return;\n }\n }, [refreshSubscriptionStatus]);\n\n useEffect(() => {\n initIapWithSubscriptions();\n const currentSubscriptions = subscriptionsRef.current;\n\n return () => {\n currentSubscriptions.purchaseUpdate?.remove();\n currentSubscriptions.purchaseError?.remove();\n currentSubscriptions.promotedProductIOS?.remove();\n endConnection();\n setConnected(false);\n };\n }, [initIapWithSubscriptions]);\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: requestPurchaseWithReset,\n validateReceipt,\n verifyPurchase,\n verifyPurchaseWithProvider,\n restorePurchases: restorePurchasesInternal,\n // internal getters kept for hook state management\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n // Alternative billing methods (Android only)\n checkAlternativeBillingAvailabilityAndroid,\n showAlternativeBillingDialogAndroid,\n createAlternativeBillingTokenAndroid,\n };\n}\n"]}
|